Add lib/libkdchart
This commit is contained in:
145
src/view/ExportPanel.cpp
Normal file
145
src/view/ExportPanel.cpp
Normal file
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
Copyright 2010-2012 Grégory Soutadé
|
||||
|
||||
This file is part of KissCount.
|
||||
|
||||
KissCount is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
KissCount is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with KissCount. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "ExportPanel.hpp"
|
||||
|
||||
ExportPanel::ExportPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent), _operations(0)
|
||||
{
|
||||
DEFAULT_FONT(font);
|
||||
std::vector<Account>::iterator accountIt;
|
||||
std::vector<Category>::iterator categoryIt;
|
||||
|
||||
QVBoxLayout *vbox = new QVBoxLayout;
|
||||
QVBoxLayout *vbox2 = new QVBoxLayout;
|
||||
QHBoxLayout *hbox = new QHBoxLayout;
|
||||
|
||||
setLayout(vbox);
|
||||
|
||||
_searchButton = new QPushButton(_("Search"));
|
||||
|
||||
connect(_searchButton, SIGNAL(clicked()), this, SLOT(OnButtonSearch()));
|
||||
|
||||
_banner = new SearchBanner(kiss, this, this, OnEnter);
|
||||
|
||||
vbox->addWidget(_banner);
|
||||
vbox->addWidget(_searchButton);
|
||||
|
||||
_grid = new GridAccount(_kiss, this, false, false, true);
|
||||
|
||||
hbox->addWidget(_grid);
|
||||
|
||||
_exportButton = new QPushButton(_("Export"));
|
||||
|
||||
connect(_exportButton, SIGNAL(clicked()), this, SLOT(OnButtonExport()));
|
||||
|
||||
vbox2->addWidget(_exportButton);
|
||||
|
||||
hbox->addLayout(vbox2);
|
||||
|
||||
vbox->addLayout(hbox);
|
||||
}
|
||||
|
||||
ExportPanel::~ExportPanel()
|
||||
{
|
||||
}
|
||||
|
||||
KissPanel* ExportPanel::CreatePanel()
|
||||
{
|
||||
return new ExportPanel(_kiss, _wxUI);
|
||||
}
|
||||
|
||||
QPushButton* ExportPanel::GetButton()
|
||||
{
|
||||
if (!_KissButton)
|
||||
{
|
||||
_KissButton = new QPushButton(QIcon(EXPORT_ICON), "", this);
|
||||
_KissButton->setFixedSize(128, 128);
|
||||
_KissButton->setIconSize(QSize(128, 128));
|
||||
}
|
||||
|
||||
return _KissButton;
|
||||
}
|
||||
|
||||
QString ExportPanel::GetToolTip()
|
||||
{
|
||||
return _("Export");
|
||||
}
|
||||
|
||||
void ExportPanel::OnEnter(void* caller)
|
||||
{
|
||||
ExportPanel* _this = (ExportPanel*) caller;
|
||||
|
||||
_this->OnButtonExport();
|
||||
}
|
||||
|
||||
void ExportPanel::OnButtonSearch()
|
||||
{
|
||||
_operations = _banner->Search();
|
||||
|
||||
if (!_operations) return;
|
||||
|
||||
if (_operations->size() > 1)
|
||||
QMessageBox::information(0, _("KissCount"), QString::number(_operations->size()) + _(" entries found"));
|
||||
else if (_operations->size() == 1)
|
||||
QMessageBox::information(0, _("KissCount"), _("1 entry found"));
|
||||
else
|
||||
{
|
||||
QMessageBox::information(0, _("KissCount"), _("No entry found"));
|
||||
return;
|
||||
}
|
||||
|
||||
_grid->LoadOperations(_operations, 0, 0);
|
||||
|
||||
layout();
|
||||
}
|
||||
|
||||
void ExportPanel::OnButtonExport()
|
||||
{
|
||||
QString path;
|
||||
|
||||
if (!_operations || !_operations->size())
|
||||
{
|
||||
QMessageBox::critical(0, _("Error"), _("No operation to save"));
|
||||
return;
|
||||
}
|
||||
|
||||
path = QFileDialog::getSaveFileName(0, _("Save as"), "", _kiss->GetExportEngineExtensions());
|
||||
|
||||
if (path.size() == 0)
|
||||
return;
|
||||
|
||||
_exportEngine = _kiss->GetExportEngine(path);
|
||||
|
||||
if (!_exportEngine)
|
||||
{
|
||||
QMessageBox::critical(0, _("Error"), _("Any engine can process this file !"));
|
||||
return ;
|
||||
}
|
||||
|
||||
if (_exportEngine->SaveFile(_operations))
|
||||
QMessageBox::information(0, _("KissCount"), _("Operations successfuly saved"));
|
||||
else
|
||||
QMessageBox::critical(0, _("Error"), _("Failed to save operations"));
|
||||
|
||||
}
|
||||
|
||||
void ExportPanel::OnShow()
|
||||
{
|
||||
_wxUI->setWindowTitle(_("KissCount - Export"));
|
||||
}
|
||||
63
src/view/ExportPanel.hpp
Normal file
63
src/view/ExportPanel.hpp
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
Copyright 2010-2012 Grégory Soutadé
|
||||
|
||||
This file is part of KissCount.
|
||||
|
||||
KissCount is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
KissCount is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with KissCount. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef EXPORTPANEL_H
|
||||
#define EXPORTPANEL_H
|
||||
|
||||
#include <QtGui>
|
||||
|
||||
#include "view.hpp"
|
||||
#include "grid/GridAccount.hpp"
|
||||
#include "AccountPanel.hpp"
|
||||
#include "SearchBanner.hpp"
|
||||
#include <model/model.hpp>
|
||||
#include <model/export/ExportEngine.hpp>
|
||||
|
||||
class GridAccount;
|
||||
class SearchBanner;
|
||||
class ExportEngine;
|
||||
|
||||
class ExportPanel: public KissPanel
|
||||
{
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
ExportPanel(KissCount* kiss, wxUI *parent);
|
||||
~ExportPanel();
|
||||
|
||||
KissPanel* CreatePanel();
|
||||
QPushButton* GetButton();
|
||||
QString GetToolTip();
|
||||
void OnShow();
|
||||
|
||||
private slots:
|
||||
void OnButtonSearch();
|
||||
void OnButtonExport();
|
||||
|
||||
private:
|
||||
std::vector<Operation> *_operations;
|
||||
SearchBanner* _banner;
|
||||
GridAccount *_grid;
|
||||
QPushButton* _searchButton, *_exportButton;
|
||||
ExportEngine* _exportEngine;
|
||||
|
||||
static void OnEnter(void* caller);
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user