Quick and dirty port to Qt5
This commit is contained in:
parent
7b6d0bb870
commit
2b664c3b4f
47
Makefile
47
Makefile
@ -1,4 +1,5 @@
|
|||||||
ROOT_DIR="/usr"
|
#ROOT_DIR="/usr"
|
||||||
|
ROOT_DIR="."
|
||||||
LIB_DIR=$(DESTDIR)$(ROOT_DIR)"/lib/kisscount/"
|
LIB_DIR=$(DESTDIR)$(ROOT_DIR)"/lib/kisscount/"
|
||||||
SHARE_DIR=$(DESTDIR)$(ROOT_DIR)"/share/kisscount/"
|
SHARE_DIR=$(DESTDIR)$(ROOT_DIR)"/share/kisscount/"
|
||||||
DOC_DIR=$(DESTDIR)$(ROOT_DIR)"/share/doc/kisscount/"
|
DOC_DIR=$(DESTDIR)$(ROOT_DIR)"/share/doc/kisscount/"
|
||||||
@ -7,9 +8,11 @@ BIN_DIR=$(DESTDIR)$(ROOT_DIR)"/bin/"
|
|||||||
CXX=$(HOST)g++
|
CXX=$(HOST)g++
|
||||||
KISSCOUNT=kc
|
KISSCOUNT=kc
|
||||||
|
|
||||||
QT_PACKAGES="QtCore QtGui QtSql QtXml"
|
QT_PACKAGES="Qt5Core Qt5Gui Qt5Sql Qt5Xml Qt5Widgets"
|
||||||
CXXFLAGS+=`pkg-config --cflags $(QT_PACKAGES)`
|
CXXFLAGS+=`pkg-config --cflags $(QT_PACKAGES)`
|
||||||
CXXFLAGS+=-Wall -Isrc -Isrc/win32
|
CXXFLAGS+=-Wall -Isrc -Isrc/win32 -I${PWD}/lib/qt5charts/usr/include/x86_64-linux-gnu/qt5/ -L${PWD}/lib/qtcharts/lib/ -L${PWD}/lib/qt5charts/usr/lib/x86_64-linux-gnu/
|
||||||
|
CXXFLAGS+=-Wall
|
||||||
|
#-Dnullptr=0
|
||||||
ifdef WIN32
|
ifdef WIN32
|
||||||
CXXFLAGS+=-DRESOURCES_ROOT="\"./resources/\"" -static
|
CXXFLAGS+=-DRESOURCES_ROOT="\"./resources/\"" -static
|
||||||
else
|
else
|
||||||
@ -24,24 +27,24 @@ MOC_HEADERS=$(shell find src/view -name '*.hpp' -type f | tr '\n' ' ')
|
|||||||
MOCS=$(MOC_HEADERS:.hpp=.objs)
|
MOCS=$(MOC_HEADERS:.hpp=.objs)
|
||||||
MOCS_OBJS=$(MOC_HEADERS:.hpp=.moc)
|
MOCS_OBJS=$(MOC_HEADERS:.hpp=.moc)
|
||||||
|
|
||||||
CXXFLAGS+=-Ilib/libkdchart/include -Ilib/libkdchart/src -Ilib/libkdchart/kdablibfakes/include
|
#CXXFLAGS+=-Ilib/libkdchart/include -Ilib/libkdchart/src -Ilib/libkdchart/kdablibfakes/include
|
||||||
CXXFLAGS+=-DKDCHART_BUILD_KDCHART_LIB
|
#CXXFLAGS+=-DKDCHART_BUILD_KDCHART_LIB
|
||||||
KDCHART_SOURCES=$(shell find lib/libkdchart/src -name '*.cpp' -type f | tr '\n' ' ')
|
#KDCHART_SOURCES=$(shell find lib/libkdchart/src -name '*.cpp' -type f | tr '\n' ' ')
|
||||||
KDCHART_OBJS=$(KDCHART_SOURCES:.cpp=.o)
|
#KDCHART_OBJS=$(KDCHART_SOURCES:.cpp=.o)
|
||||||
UI_CHARTSELECTOR=lib/libkdchart/src/ui_KDChartDatasetSelector.h
|
#UI_CHARTSELECTOR=lib/libkdchart/src/ui_KDChartDatasetSelector.h
|
||||||
KDCHART_MOC_HEADERS=$(shell find lib/libkdchart/src -name '*.h' -type f | tr '\n' ' ')
|
#KDCHART_MOC_HEADERS=$(shell find lib/libkdchart/src -name '*.h' -type f | tr '\n' ' ')
|
||||||
KDCHART_MOCS=$(KDCHART_MOC_HEADERS:.h=.objs)
|
#KDCHART_MOCS=$(KDCHART_MOC_HEADERS:.h=.objs)
|
||||||
KDCHART_MOCS_OBJS=$(KDCHART_MOC_HEADERS:.h=.moc)
|
#KDCHART_MOCS_OBJS=$(KDCHART_MOC_HEADERS:.h=.moc)
|
||||||
LDFLAGS+=lib/libkdchart.a
|
#LDFLAGS+=lib/libkdchart.a
|
||||||
|
|
||||||
ifndef WIN32
|
ifndef WIN32
|
||||||
LDFLAGS+=`pkg-config --libs $(QT_PACKAGES)`
|
LDFLAGS+=`pkg-config --libs $(QT_PACKAGES)`
|
||||||
LDFLAGS+=-lofx
|
LDFLAGS+=-lofx -lQt5Charts
|
||||||
else
|
else
|
||||||
LDFLAGS+=lib_mingw_32/QtCore4.dll lib_mingw_32/QtGui4.dll lib_mingw_32/QtSql4.dll lib_mingw_32/QtXml4.dll
|
LDFLAGS+=lib_mingw_32/QtCore4.dll lib_mingw_32/QtGui4.dll lib_mingw_32/QtSql4.dll lib_mingw_32/QtXml4.dll
|
||||||
endif
|
endif
|
||||||
|
|
||||||
all: mojito lib/libkdchart.a $(KISSCOUNT)
|
all: mojito $(KISSCOUNT)
|
||||||
|
|
||||||
clean_all: clean clean_libkdchart
|
clean_all: clean clean_libkdchart
|
||||||
|
|
||||||
@ -59,22 +62,22 @@ clean:
|
|||||||
$(CXX) $(CXXFLAGS) -x c++ $< -c -o $@
|
$(CXX) $(CXXFLAGS) -x c++ $< -c -o $@
|
||||||
|
|
||||||
%.moc : %.hpp
|
%.moc : %.hpp
|
||||||
moc-qt4 -nw $< -o $@
|
moc -nw $< -o $@
|
||||||
|
|
||||||
%.moc : %.h
|
%.moc : %.h
|
||||||
moc-qt4 -nw $< -o $@
|
moc -nw $< -o $@
|
||||||
|
|
||||||
mojito : $(MOCS_OBJS) $(KDCHART_MOCS_OBJS)
|
mojito : $(MOCS_OBJS)
|
||||||
|
|
||||||
$(KISSCOUNT): $(MOCS) $(OBJS)
|
$(KISSCOUNT): $(MOCS) $(OBJS)
|
||||||
$(CXX) $(CXXFLAGS) $^ -o $@ $(LDFLAGS)
|
$(CXX) $(CXXFLAGS) $^ -o $@ $(LDFLAGS)
|
||||||
|
|
||||||
$(UI_CHARTSELECTOR): lib/libkdchart/src/KDChartDatasetSelector.ui
|
# $(UI_CHARTSELECTOR): lib/libkdchart/src/KDChartDatasetSelector.ui
|
||||||
uic $< > $(UI_CHARTSELECTOR)
|
# uic $< > $(UI_CHARTSELECTOR)
|
||||||
sed s/KDCHARTDATASETSELECTOR_H/UI_KDCHARTDATASETSELECTOR_H/g -i $(UI_CHARTSELECTOR)
|
# sed s/KDCHARTDATASETSELECTOR_H/UI_KDCHARTDATASETSELECTOR_H/g -i $(UI_CHARTSELECTOR)
|
||||||
|
|
||||||
lib/libkdchart.a: $(UI_CHARTSELECTOR) $(KDCHART_MOCS) $(KDCHART_OBJS)
|
# lib/libkdchart.a: $(UI_CHARTSELECTOR) $(KDCHART_MOCS) $(KDCHART_OBJS)
|
||||||
$(HOST)ar rcu lib/libkdchart.a $(KDCHART_MOCS) $(KDCHART_OBJS)
|
# $(HOST)ar rcu lib/libkdchart.a $(KDCHART_MOCS) $(KDCHART_OBJS)
|
||||||
|
|
||||||
clean_libkdchart:
|
clean_libkdchart:
|
||||||
rm -rf lib/libkdchart.a
|
rm -rf lib/libkdchart.a
|
||||||
|
@ -180,9 +180,10 @@ bool GrisbiImportEngine::HandleFile(const QString& path, User* user, Database* d
|
|||||||
|
|
||||||
if (!ImportEngine::HandleFile(path, user, db, kiss)) return false;
|
if (!ImportEngine::HandleFile(path, user, db, kiss)) return false;
|
||||||
|
|
||||||
|
QXmlInputSource *source = new QXmlInputSource(&file);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
res = _sax.parse(&file);
|
res = _sax.parse(source, false);
|
||||||
LinkChilds();
|
LinkChilds();
|
||||||
}
|
}
|
||||||
catch (const char* s)
|
catch (const char* s)
|
||||||
@ -192,6 +193,7 @@ bool GrisbiImportEngine::HandleFile(const QString& path, User* user, Database* d
|
|||||||
}
|
}
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
|
delete source;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -51,9 +51,11 @@ bool XMLImportEngine::HandleFile(const QString& path, User* user, Database* db,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QXmlInputSource *source = new QXmlInputSource(&file);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
res = _sax.parse(&file);
|
res = _sax.parse(source, false);
|
||||||
LinkChilds();
|
LinkChilds();
|
||||||
}
|
}
|
||||||
catch (const char* s)
|
catch (const char* s)
|
||||||
@ -63,6 +65,7 @@ bool XMLImportEngine::HandleFile(const QString& path, User* user, Database* db,
|
|||||||
}
|
}
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
|
delete source;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
#include "AccountPanel.hpp"
|
#include "AccountPanel.hpp"
|
||||||
#include "grid/FloatDelegate.hpp"
|
#include "grid/FloatDelegate.hpp"
|
||||||
|
@ -17,11 +17,15 @@
|
|||||||
along with KissCount. If not, see <http://www.gnu.org/licenses/>.
|
along with KissCount. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <KDChartLegend>
|
#include <QtCharts/QChartView>
|
||||||
#include <KDChartPieDiagram>
|
#include <QtCharts/QPieSeries>
|
||||||
|
#include <QtCharts/QPieSlice>
|
||||||
|
|
||||||
|
#include <QHeaderView>
|
||||||
#include "CostRepartitionBanner.hpp"
|
#include "CostRepartitionBanner.hpp"
|
||||||
|
|
||||||
|
using namespace QtCharts;
|
||||||
|
|
||||||
CostRepartitionBanner::CostRepartitionBanner(KissCount* kiss, QFrame* parent, QString* categories) : QFrame(parent), _kiss(kiss), _categories(categories)
|
CostRepartitionBanner::CostRepartitionBanner(KissCount* kiss, QFrame* parent, QString* categories) : QFrame(parent), _kiss(kiss), _categories(categories)
|
||||||
{
|
{
|
||||||
User* user = _kiss->GetUser();
|
User* user = _kiss->GetUser();
|
||||||
@ -32,43 +36,51 @@ CostRepartitionBanner::CostRepartitionBanner(KissCount* kiss, QFrame* parent, QS
|
|||||||
|
|
||||||
nbCategories = user->GetCategoriesNumber();
|
nbCategories = user->GetCategoriesNumber();
|
||||||
|
|
||||||
_pie = new KDChart::Widget();
|
QPieSeries *series = new QPieSeries();
|
||||||
_pie->setType( KDChart::Widget::Pie );
|
QPieSlice* slice;
|
||||||
|
|
||||||
|
_pie = new QChart();
|
||||||
|
|
||||||
QPen pen;
|
QPen pen;
|
||||||
pen.setWidth(2);
|
pen.setWidth(2);
|
||||||
pen.setColor(Qt::black);
|
pen.setColor(Qt::black);
|
||||||
_pie->pieDiagram()->setPen(pen);
|
//_pie->pieDiagram()->setPen(pen);
|
||||||
|
|
||||||
_pie->addLegend(KDChart::Position::South);
|
QLegend* legend = _pie->legend();
|
||||||
KDChart::Legend* legend = _pie->legend();
|
legend->detachFromChart();
|
||||||
|
legend->setAlignment(Qt::AlignTop);
|
||||||
|
legend->setVisible(false);
|
||||||
|
legend->setShowToolTips(true);
|
||||||
|
// legend->setAlignment(Qt::AlignBottom);
|
||||||
|
|
||||||
|
//_pie->addLegend(KDChart::Position::South);
|
||||||
|
// KDChart::Legend* legend = //_pie->legend();
|
||||||
// legend->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
|
// legend->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
|
||||||
legend->setOrientation( Qt::Vertical );
|
// legend->setOrientation( Qt::Vertical );
|
||||||
legend->setTitleText( _("Cost repartition") );
|
|
||||||
QVector< double > vec;
|
_pie->setMargins(QMargins(5, 5, 5, 5));
|
||||||
vec << 0.0;
|
|
||||||
_dataset = new QStandardItemModel(nbCategories, 2, this);
|
|
||||||
for(i=0; i<nbCategories; i++)
|
for(i=0; i<nbCategories; i++)
|
||||||
{
|
{
|
||||||
_pie->setDataset( i, vec, _categories[i] );
|
slice = series->append(_categories[i], 0);
|
||||||
_pie->pieDiagram()->setBrush(i, QBrush(wxUI::categoryColors[i]));
|
|
||||||
legend->setText( i, _categories[i] );
|
|
||||||
_dataset->setData(_dataset->index(i, 0, QModelIndex()), _categories[i]);
|
|
||||||
_dataset->setData(_dataset->index(i, 1, QModelIndex()), 0.0);
|
|
||||||
if (i < wxUI::MAX_CATEGORY)
|
if (i < wxUI::MAX_CATEGORY)
|
||||||
_dataset->setData(_dataset->index(i, 0, QModelIndex()), wxUI::categoryColors[i], Qt::DecorationRole);
|
slice->setBrush(QBrush(wxUI::categoryColors[i]));
|
||||||
|
slice->setLabelVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
_pie->setMaximumSize( 200, 400 );
|
_pie->addSeries(series);
|
||||||
|
//_pie->setTitle(_("Cost repartition"));
|
||||||
|
//_pie->setMaximumSize( 200, 400 );
|
||||||
|
|
||||||
KDChart::TextAttributes legendTextAttr(legend->textAttributes());
|
// KDChart::TextAttributes legendTextAttr(legend->textAttributes());
|
||||||
legendTextAttr.setFontSize(64);
|
// legendTextAttr.setFontSize(64);
|
||||||
legendTextAttr.setAutoShrink(true);
|
// legendTextAttr.setAutoShrink(true);
|
||||||
legend->setTextAttributes(legendTextAttr);
|
// legend->setTextAttributes(legendTextAttr);
|
||||||
|
|
||||||
legendTextAttr = KDChart::TextAttributes(legend->titleTextAttributes());
|
// legendTextAttr = KDChart::TextAttributes(legend->titleTextAttributes());
|
||||||
legendTextAttr.setFontSize(64);
|
// legendTextAttr.setFontSize(64);
|
||||||
legendTextAttr.setAutoShrink(true);
|
// legendTextAttr.setAutoShrink(true);
|
||||||
legend->setTitleTextAttributes(legendTextAttr);
|
// legend->setTitleTextAttributes(legendTextAttr);
|
||||||
|
|
||||||
_statsGrid = new QTableWidget(this);
|
_statsGrid = new QTableWidget(this);
|
||||||
_statsGrid->verticalHeader()->setHidden(true);
|
_statsGrid->verticalHeader()->setHidden(true);
|
||||||
@ -77,13 +89,13 @@ CostRepartitionBanner::CostRepartitionBanner(KissCount* kiss, QFrame* parent, QS
|
|||||||
|
|
||||||
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
|
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
|
||||||
|
|
||||||
QSize s = legend->sizeHint();
|
QChartView *chartView = new QChartView(_pie);
|
||||||
legend->setMaximumSize(s.width(), s.height()/3);
|
chartView->setRenderHint(QPainter::Antialiasing);
|
||||||
|
|
||||||
vbox->addWidget(_statsGrid);
|
vbox->addWidget(_statsGrid);
|
||||||
vbox->addWidget(_pie);
|
vbox->addWidget(chartView);
|
||||||
|
|
||||||
setMaximumWidth(300);
|
setMaximumWidth(350);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CostRepartitionBanner::Reset()
|
void CostRepartitionBanner::Reset()
|
||||||
@ -132,27 +144,24 @@ void CostRepartitionBanner::UpdateCosts(int *categoriesValues, int totalDebit)
|
|||||||
User* user = _kiss->GetUser();
|
User* user = _kiss->GetUser();
|
||||||
int value, percents;
|
int value, percents;
|
||||||
QString v;
|
QString v;
|
||||||
|
QPieSeries* series = (QPieSeries*) (_pie->series()[0]);
|
||||||
|
QList<QtCharts::QPieSlice*> slices = series->slices();
|
||||||
|
|
||||||
for(i=0; i<user->GetCategoriesNumber(); i++)
|
for(i=0; i<user->GetCategoriesNumber(); i++)
|
||||||
{
|
{
|
||||||
if (totalDebit != 0)
|
if (totalDebit != 0)
|
||||||
percents = (categoriesValues[i]*100)/totalDebit;
|
percents = (categoriesValues[i]*100)/totalDebit;
|
||||||
else
|
else
|
||||||
percents = 0.0;
|
percents = 0.0;
|
||||||
|
|
||||||
if (!i)
|
if (!i)
|
||||||
_statsGrid->item(i, 1)->setText(v.sprintf("%.2lf (%02d %%)", (double)categoriesValues[i]/100, (int)percents));
|
_statsGrid->item(i, 1)->setText(v.sprintf("%.2lf (%02d %%)", (double)categoriesValues[i]/100, (int)percents));
|
||||||
else
|
else
|
||||||
_statsGrid->item(i+1, 1)->setText(v.sprintf("%.2lf (%02d %%)", (double)categoriesValues[i]/100, (int)percents));
|
_statsGrid->item(i+1, 1)->setText(v.sprintf("%.2lf (%02d %%)", (double)categoriesValues[i]/100, (int)percents));
|
||||||
|
|
||||||
// KDChart::Legend* legend = _pie->legend();
|
slices[i]->setValue(categoriesValues[i] / 100);
|
||||||
QVector< double > vec;
|
|
||||||
vec << (double) categoriesValues[i] / 100;
|
slices[i]->setLabelVisible(categoriesValues[i] != 0.0);
|
||||||
_pie->setDataset( i, vec, _categories[i] );
|
|
||||||
// if (categoriesValues[i] == 0.0)
|
|
||||||
// legend->setDatasetHidden(i, true);
|
|
||||||
// else
|
|
||||||
// legend->setDatasetHidden(i, false);
|
|
||||||
// _dataset->setData(_dataset->index(i, 1, QModelIndex()), categoriesValues[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
value = totalDebit - categoriesValues[0];
|
value = totalDebit - categoriesValues[0];
|
||||||
|
@ -21,7 +21,8 @@
|
|||||||
#define COSTREPARTITIONBANNER_H
|
#define COSTREPARTITIONBANNER_H
|
||||||
|
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include <KDChartWidget>
|
#include <QTableWidget>
|
||||||
|
#include <QtCharts/QChart>
|
||||||
|
|
||||||
#include "view.hpp"
|
#include "view.hpp"
|
||||||
#include <model/model.hpp>
|
#include <model/model.hpp>
|
||||||
@ -40,7 +41,7 @@ private:
|
|||||||
KissCount* _kiss;
|
KissCount* _kiss;
|
||||||
QString* _categories;
|
QString* _categories;
|
||||||
QTableWidget* _statsGrid;
|
QTableWidget* _statsGrid;
|
||||||
KDChart::Widget* _pie;
|
QtCharts::QChart* _pie;
|
||||||
QStandardItemModel* _dataset;
|
QStandardItemModel* _dataset;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -17,6 +17,9 @@
|
|||||||
along with KissCount. If not, see <http://www.gnu.org/licenses/>.
|
along with KissCount. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
#include "ExportPanel.hpp"
|
#include "ExportPanel.hpp"
|
||||||
|
|
||||||
ExportPanel::ExportPanel(KissCount* kiss, wxUI *parent, bool lowResolution) :
|
ExportPanel::ExportPanel(KissCount* kiss, wxUI *parent, bool lowResolution) :
|
||||||
|
@ -18,6 +18,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QHeaderView>
|
||||||
|
#include <QGroupBox>
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
#include "ImportPanel.hpp"
|
#include "ImportPanel.hpp"
|
||||||
#include "grid/ChoiceDelegate.hpp"
|
#include "grid/ChoiceDelegate.hpp"
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#define IMPORTPANEL_H
|
#define IMPORTPANEL_H
|
||||||
|
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
#include <QCheckBox>
|
||||||
|
|
||||||
#include "view.hpp"
|
#include "view.hpp"
|
||||||
#include <model/model.hpp>
|
#include <model/model.hpp>
|
||||||
|
@ -17,6 +17,14 @@
|
|||||||
along with KissCount. If not, see <http://www.gnu.org/licenses/>.
|
along with KissCount. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <QGroupBox>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QColorDialog>
|
||||||
|
#include <QFontDialog>
|
||||||
|
#include <QInputDialog>
|
||||||
|
#include <QCheckBox>
|
||||||
|
#include <QHeaderView>
|
||||||
|
#include <QLabel>
|
||||||
|
|
||||||
#include "PasswordDialog.hpp"
|
#include "PasswordDialog.hpp"
|
||||||
|
|
||||||
|
@ -21,7 +21,9 @@
|
|||||||
#define PREFERENCESPANEL_H
|
#define PREFERENCESPANEL_H
|
||||||
|
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
#include <QListWidgetItem>
|
||||||
|
#include <QTableWidget>
|
||||||
|
#include <QComboBox>
|
||||||
#include "SupportedLanguages.hpp"
|
#include "SupportedLanguages.hpp"
|
||||||
#include "view.hpp"
|
#include "view.hpp"
|
||||||
#include <model/model.hpp>
|
#include <model/model.hpp>
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
along with KissCount. If not, see <http://www.gnu.org/licenses/>.
|
along with KissCount. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <QtWidgets>
|
||||||
|
|
||||||
#include "SearchBanner.hpp"
|
#include "SearchBanner.hpp"
|
||||||
|
|
||||||
SearchBanner::SearchBanner(KissCount* kiss, QFrame *parent, void* caller, OnButtonEnter enterCallback) : QFrame(parent), _kiss(kiss), _caller(caller), _enterCallback(enterCallback), _operations(0)
|
SearchBanner::SearchBanner(KissCount* kiss, QFrame *parent, void* caller, OnButtonEnter enterCallback) : QFrame(parent), _kiss(kiss), _caller(caller), _enterCallback(enterCallback), _operations(0)
|
||||||
|
@ -21,6 +21,9 @@
|
|||||||
#define SEARCHBANNER_H
|
#define SEARCHBANNER_H
|
||||||
|
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
#include <QCheckBox>
|
||||||
|
#include <QListWidget>
|
||||||
|
#include <QCalendarWidget>
|
||||||
|
|
||||||
#include "view.hpp"
|
#include "view.hpp"
|
||||||
#include <model/model.hpp>
|
#include <model/model.hpp>
|
||||||
|
@ -17,6 +17,9 @@
|
|||||||
along with KissCount. If not, see <http://www.gnu.org/licenses/>.
|
along with KissCount. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QInputDialog>
|
||||||
|
|
||||||
#include "SearchPanel.hpp"
|
#include "SearchPanel.hpp"
|
||||||
|
|
||||||
SearchPanel::SearchPanel(KissCount* kiss, wxUI *parent, bool lowResolution) :
|
SearchPanel::SearchPanel(KissCount* kiss, wxUI *parent, bool lowResolution) :
|
||||||
|
@ -18,14 +18,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <KDChartLegend>
|
#include <QLabel>
|
||||||
#include <KDChartLineDiagram>
|
#include <QtCharts/QLineSeries>
|
||||||
#include <KDChartCartesianAxis>
|
#include <QtCharts/QCategoryAxis>
|
||||||
|
#include <QtCharts/QDateTimeAxis>
|
||||||
#include "StatsPanel.hpp"
|
#include "StatsPanel.hpp"
|
||||||
|
|
||||||
|
using namespace QtCharts;
|
||||||
|
|
||||||
StatsPanel::StatsPanel(KissCount* kiss, wxUI *parent, bool lowResolution) :
|
StatsPanel::StatsPanel(KissCount* kiss, wxUI *parent, bool lowResolution) :
|
||||||
KissPanel(kiss, parent, lowResolution), _plot(0)
|
KissPanel(kiss, parent, lowResolution), _chartView(0)
|
||||||
{
|
{
|
||||||
QHBoxLayout *hbox = new QHBoxLayout();
|
QHBoxLayout *hbox = new QHBoxLayout();
|
||||||
QVBoxLayout *vbox = new QVBoxLayout();
|
QVBoxLayout *vbox = new QVBoxLayout();
|
||||||
@ -158,16 +160,19 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT
|
|||||||
User* user = _kiss->GetUser();
|
User* user = _kiss->GetUser();
|
||||||
QDate date;
|
QDate date;
|
||||||
bool failed;
|
bool failed;
|
||||||
QVector<double> vec;
|
QLineSeries * series = new QLineSeries();
|
||||||
QStringList xlabels;
|
QLineSeries * series0 = series;
|
||||||
|
QDateTimeAxis *axisX = new QDateTimeAxis;
|
||||||
|
QDateTime xValue;
|
||||||
|
|
||||||
if (_plot)
|
if (_chartView)
|
||||||
{
|
{
|
||||||
_vbox2->removeWidget(_plot);
|
_vbox2->removeWidget(_chartView);
|
||||||
delete _plot;
|
delete _chartView;
|
||||||
}
|
}
|
||||||
|
|
||||||
_plot = new KDChart::Widget();
|
_plot = new QChart();
|
||||||
|
_plot->createDefaultAxes();
|
||||||
|
|
||||||
if (monthFrom == monthTo && yearFrom == yearTo)
|
if (monthFrom == monthTo && yearFrom == yearTo)
|
||||||
{
|
{
|
||||||
@ -178,9 +183,16 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT
|
|||||||
|
|
||||||
// Line on 0 all over the years
|
// Line on 0 all over the years
|
||||||
for (a=0; a<nbDays; a++)
|
for (a=0; a<nbDays; a++)
|
||||||
vec << 0.0;
|
{
|
||||||
|
date = QDate(yearFrom, monthFrom+1, a+1);
|
||||||
|
xValue.setDate(date);
|
||||||
|
series->append(xValue.toMSecsSinceEpoch(), 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
_plot->setDataset(0, vec, "");
|
series->setName(_("0 line"));
|
||||||
|
series->setColor(Qt::red);
|
||||||
|
axisX->setFormat("dd");
|
||||||
|
_plot->addSeries(series);
|
||||||
|
|
||||||
i=0;
|
i=0;
|
||||||
for (account = 0, i = 0, accountIt = user->_accounts.begin(); accountIt != user->_accounts.end();
|
for (account = 0, i = 0, accountIt = user->_accounts.begin(); accountIt != user->_accounts.end();
|
||||||
@ -189,11 +201,17 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT
|
|||||||
if (_account->item(account)->checkState() != Qt::Checked)
|
if (_account->item(account)->checkState() != Qt::Checked)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
vec.clear();
|
series = new QLineSeries();
|
||||||
for (a=0; a<nbDays; a++)
|
for (a=0; a<nbDays; a++)
|
||||||
vec << (double) operations[accountIt->id][a] / 100;
|
{
|
||||||
|
date = QDate(yearFrom, monthFrom+1, a+1);
|
||||||
|
xValue.setDate(date);
|
||||||
|
series->append(xValue.toMSecsSinceEpoch(),
|
||||||
|
(double) operations[accountIt->id][a] / 100);
|
||||||
|
}
|
||||||
|
|
||||||
_plot->setDataset(++i, vec, user->GetAccountName(accountIt->id));
|
series->setName(user->GetAccountName(accountIt->id));
|
||||||
|
_plot->addSeries(series);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -206,15 +224,18 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT
|
|||||||
{
|
{
|
||||||
for(b=0; b<12; b++)
|
for(b=0; b<12; b++)
|
||||||
{
|
{
|
||||||
vec << 0.0;
|
date = QDate(yearFrom+a, monthFrom+b+1, 1);
|
||||||
if (b == 0 || b == 5 || (b == 11 /*&& a == ((nbDays/12)-1))*/))
|
xValue.setDate(date);
|
||||||
xlabels << wxUI::months[b] + " " + QString::number(yearFrom+a);
|
series->append(xValue.toMSecsSinceEpoch(), 0.0);
|
||||||
else
|
|
||||||
xlabels << "" ;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_plot->setDataset(0, vec, "");
|
axisX->setLabelsAngle(-60);
|
||||||
|
axisX->setLineVisible(true);
|
||||||
|
axisX->setFormat("MM yyyy");
|
||||||
|
series->setName(_("0 line"));
|
||||||
|
series->setColor(Qt::red);
|
||||||
|
_plot->addSeries(series);
|
||||||
|
|
||||||
for (account = 0, i = 0, accountIt = user->_accounts.begin(); accountIt != user->_accounts.end();
|
for (account = 0, i = 0, accountIt = user->_accounts.begin(); accountIt != user->_accounts.end();
|
||||||
account++, accountIt++, i++)
|
account++, accountIt++, i++)
|
||||||
@ -225,13 +246,15 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
vec.clear();
|
series = new QLineSeries();
|
||||||
for(a = 0, accountYearIt = accountAmounts[accountIt->id].begin();
|
for(a = 0, accountYearIt = accountAmounts[accountIt->id].begin();
|
||||||
accountYearIt != accountAmounts[accountIt->id].end();
|
accountYearIt != accountAmounts[accountIt->id].end();
|
||||||
accountYearIt++, a++)
|
accountYearIt++, a++)
|
||||||
{
|
{
|
||||||
for(b = 0; b<=12; b++)
|
for(b = 0; b<=12; b++)
|
||||||
{
|
{
|
||||||
|
date = QDate(yearFrom+a, b+1, 1);
|
||||||
|
xValue.setDate(date);
|
||||||
if (!accountAmounts[accountIt->id][accountYearIt->first].count(b))
|
if (!accountAmounts[accountIt->id][accountYearIt->first].count(b))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@ -243,61 +266,35 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT
|
|||||||
Compute cur month value (if there are operations)
|
Compute cur month value (if there are operations)
|
||||||
as next month value
|
as next month value
|
||||||
*/
|
*/
|
||||||
vec << (double) (accountAmounts[accountIt->id][accountYearIt->first][b-1]
|
*series << QPointF(xValue.toMSecsSinceEpoch(),
|
||||||
+ _kiss->CalcAccountAmount(accountIt->id, b-1, accountYearIt->first, 0)) / 100;
|
(double) (accountAmounts[accountIt->id][accountYearIt->first][b-1]
|
||||||
|
+ _kiss->CalcAccountAmount(accountIt->id, b-1, accountYearIt->first, 0)) / 100);
|
||||||
failed = true;
|
failed = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vec << (double) accountAmounts[accountIt->id][accountYearIt->first][b] / 100;
|
*series << QPointF(xValue.toMSecsSinceEpoch(),
|
||||||
|
(double) accountAmounts[accountIt->id][accountYearIt->first][b] / 100);
|
||||||
failed = false;
|
failed = false;
|
||||||
}
|
}
|
||||||
size++;
|
size++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_plot->setDataset(i+1, vec, user->GetAccountName(accountIt->id));
|
series->setName(user->GetAccountName(accountIt->id));
|
||||||
|
_plot->addSeries(series);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KDChart::CartesianAxis *xAxis = new KDChart::CartesianAxis(_plot->lineDiagram());
|
// yAxis->setTitleText (_("Amount"));
|
||||||
KDChart::CartesianAxis *yAxis = new KDChart::CartesianAxis (_plot->lineDiagram());
|
|
||||||
xAxis->setPosition (KDChart::CartesianAxis::Bottom);
|
QLegend* legend = _plot->legend();
|
||||||
yAxis->setPosition (KDChart::CartesianAxis::Left);
|
legend->setAlignment(Qt::AlignRight);
|
||||||
yAxis->setTitleText (_("Amount"));
|
|
||||||
|
|
||||||
xAxis->setLabels(xlabels);
|
_plot->createDefaultAxes();
|
||||||
xAxis->setShortLabels(xlabels);
|
_plot->setAxisX(axisX, series0);
|
||||||
|
_chartView = new QChartView(_plot);
|
||||||
// Rotate only for months names
|
_chartView->setRenderHint(QPainter::Antialiasing);
|
||||||
if (monthFrom != monthTo || yearFrom != yearTo)
|
_vbox2->addWidget(_chartView);
|
||||||
{
|
|
||||||
KDChart::TextAttributes axisTextAttr(xAxis->textAttributes());
|
|
||||||
axisTextAttr.setRotation(-60);
|
|
||||||
xAxis->setTextAttributes(axisTextAttr);
|
|
||||||
xAxis->setTitleText (_("Months"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
xAxis->setTitleText (_("Days"));
|
|
||||||
|
|
||||||
_plot->lineDiagram()->addAxis(xAxis);
|
|
||||||
_plot->lineDiagram()->addAxis(yAxis);
|
|
||||||
|
|
||||||
_plot->addLegend(KDChart::Position::East);
|
|
||||||
KDChart::Legend* legend = _plot->legend();
|
|
||||||
legend->setOrientation(Qt::Vertical);
|
|
||||||
legend->setTitleText(_("Accounts"));
|
|
||||||
legend->setText(0, _("0 line"));
|
|
||||||
{
|
|
||||||
i = 1;
|
|
||||||
for (a=0, accountIt = user->_accounts.begin(); accountIt != user->_accounts.end();
|
|
||||||
a++, accountIt++)
|
|
||||||
{
|
|
||||||
if (_account->item(a)->checkState() == Qt::Checked)
|
|
||||||
legend->setText(i++, accountIt->name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_vbox2->addWidget(_plot);
|
|
||||||
|
|
||||||
total = 0.0;
|
total = 0.0;
|
||||||
for(i=0, categoriesIt = categories.begin(); categoriesIt != categories.end(); categoriesIt++, i++)
|
for(i=0, categoriesIt = categories.begin(); categoriesIt != categories.end(); categoriesIt++, i++)
|
||||||
|
@ -21,7 +21,13 @@
|
|||||||
#define STATSPANEL_H
|
#define STATSPANEL_H
|
||||||
|
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include <KDChartWidget>
|
#include <QListWidgetItem>
|
||||||
|
#include <QCalendarWidget>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QListWidget>
|
||||||
|
#include <QtCharts/QChart>
|
||||||
|
#include <QtCharts/QChartView>
|
||||||
|
|
||||||
#include "CostRepartitionBanner.hpp"
|
#include "CostRepartitionBanner.hpp"
|
||||||
|
|
||||||
#include "view.hpp"
|
#include "view.hpp"
|
||||||
@ -47,8 +53,8 @@ private:
|
|||||||
QComboBox* _monthFrom, *_yearFrom, *_monthTo, *_yearTo;
|
QComboBox* _monthFrom, *_yearFrom, *_monthTo, *_yearTo;
|
||||||
CostRepartitionBanner* _costRepartitionBanner;
|
CostRepartitionBanner* _costRepartitionBanner;
|
||||||
int *_categoriesValues;
|
int *_categoriesValues;
|
||||||
//CategorySimpleDataset* _dataset;
|
QtCharts::QChartView * _chartView;
|
||||||
KDChart::Widget *_plot ;
|
QtCharts::QChart *_plot ;
|
||||||
QString* _categories;
|
QString* _categories;
|
||||||
std::map<int, int> _categoriesIndexes;
|
std::map<int, int> _categoriesIndexes;
|
||||||
QBoxLayout *_hbox2, *_vbox2, *_vbox3;
|
QBoxLayout *_hbox2, *_vbox2, *_vbox3;
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
#include <QtWidgets>
|
||||||
|
|
||||||
#include "ChoiceDelegate.hpp"
|
#include "ChoiceDelegate.hpp"
|
||||||
|
|
||||||
@ -44,7 +45,7 @@ void ChoiceDelegate::setEditorData(QWidget *editor,
|
|||||||
const QModelIndex &index) const
|
const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
QComboBox* combo = qobject_cast<QComboBox *>(editor);
|
QComboBox* combo = qobject_cast<QComboBox *>(editor);
|
||||||
int i = combo->findText(qVariantValue<QString>(index.data()));
|
int i = combo->findText(index.data().toString());
|
||||||
|
|
||||||
if (i != -1) combo->setCurrentIndex(i);
|
if (i != -1) combo->setCurrentIndex(i);
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
#include <QtWidgets>
|
||||||
|
|
||||||
#include "DateDelegate.hpp"
|
#include "DateDelegate.hpp"
|
||||||
|
|
||||||
@ -49,6 +50,6 @@ void DateDelegate::setEditorData(QWidget *editor,
|
|||||||
int day;
|
int day;
|
||||||
|
|
||||||
QComboBox* combo = qobject_cast<QComboBox *>(editor);
|
QComboBox* combo = qobject_cast<QComboBox *>(editor);
|
||||||
day = QDate::fromString(qVariantValue<QString>(index.data()), _dateFormat).day()-1;
|
day = QDate::fromString(index.data().toString(), _dateFormat).day()-1;
|
||||||
combo->setCurrentIndex(day);
|
combo->setCurrentIndex(day);
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
#include <QtWidgets>
|
||||||
|
|
||||||
#include "FloatDelegate.hpp"
|
#include "FloatDelegate.hpp"
|
||||||
|
|
||||||
@ -41,5 +42,5 @@ void FloatDelegate::setEditorData(QWidget *editor,
|
|||||||
const QModelIndex &index) const
|
const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
QLineEdit* line = qobject_cast<QLineEdit *>(editor);
|
QLineEdit* line = qobject_cast<QLineEdit *>(editor);
|
||||||
line->setText(qVariantValue<QString>(index.data()));
|
line->setText(index.data().toString());
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QtWidgets>
|
||||||
|
|
||||||
#include "FormulaDelegate.hpp"
|
#include "FormulaDelegate.hpp"
|
||||||
#include <ParseExp.hpp>
|
#include <ParseExp.hpp>
|
||||||
@ -81,7 +82,7 @@ void FormulaDelegate::setEditorData(QWidget *editor,
|
|||||||
const QModelIndex &index) const
|
const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
QLineEdit* line = qobject_cast<QLineEdit *>(editor);
|
QLineEdit* line = qobject_cast<QLineEdit *>(editor);
|
||||||
QString s = qVariantValue<QString>(index.data());
|
QString s = index.data().toString();
|
||||||
|
|
||||||
if ((*_operations)[index.row()].formula.length())
|
if ((*_operations)[index.row()].formula.length())
|
||||||
line->setText((*_operations)[index.row()].formula);
|
line->setText((*_operations)[index.row()].formula);
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
#include <QtWidgets>
|
||||||
|
|
||||||
#include "GridAccount.hpp"
|
#include "GridAccount.hpp"
|
||||||
#include "TableViewDelegate.hpp"
|
#include "TableViewDelegate.hpp"
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
#include <QtWidgets>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include "StarDelegate.hpp"
|
#include "StarDelegate.hpp"
|
||||||
@ -43,7 +44,7 @@ void StarDelegate::setEditorData(QWidget *editor,
|
|||||||
const QModelIndex &index) const
|
const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
QLineEdit* line = qobject_cast<QLineEdit *>(editor);
|
QLineEdit* line = qobject_cast<QLineEdit *>(editor);
|
||||||
QString s = qVariantValue<QString>(index.data());
|
QString s = index.data().toString();
|
||||||
|
|
||||||
if (s.endsWith("*"))
|
if (s.endsWith("*"))
|
||||||
line->setText(s.left(s.size()-1));
|
line->setText(s.left(s.size()-1));
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QtWidgets>
|
||||||
|
|
||||||
#include "TabDelegate.hpp"
|
#include "TabDelegate.hpp"
|
||||||
|
|
||||||
@ -49,7 +50,7 @@ void TabDelegate::setEditorData(QWidget *editor,
|
|||||||
const QModelIndex &index) const
|
const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
QLineEdit* line = qobject_cast<QLineEdit *>(editor);
|
QLineEdit* line = qobject_cast<QLineEdit *>(editor);
|
||||||
QString s = qVariantValue<QString>(index.data());
|
QString s = index.data().toString();
|
||||||
|
|
||||||
line->setText(s.trimmed());
|
line->setText(s.trimmed());
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
#define TABLEVIEWDELEGATE_H
|
#define TABLEVIEWDELEGATE_H
|
||||||
|
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
#include <QStyledItemDelegate>
|
||||||
|
|
||||||
#include "GridAccount.hpp"
|
#include "GridAccount.hpp"
|
||||||
|
|
||||||
class TableViewDelegate : public QStyledItemDelegate
|
class TableViewDelegate : public QStyledItemDelegate
|
||||||
|
Loading…
x
Reference in New Issue
Block a user