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