62
62
ui.kLines->addItem(i18n("Accounts"));
63
63
ui.kLines->addItem(i18n("Units"));
65
ui.kMode->addItem(i18n("Sum"));
66
ui.kMode->addItem(i18n("History"));
65
68
ui.kPeriod->addItem(i18n("All dates"));
66
69
ui.kPeriod->addItem(i18n("Current month"));
67
70
ui.kPeriod->addItem(i18n("Previous month"));
79
82
ui.kType->addItem(i18n("All without transfer"));
80
83
ui.kType->addItem(i18n("Income without transfer"));
81
ui.kType->addItem(i18n("Expense without transfer"));
84
ui.kType->addItem(i18n("Expenditure without transfer"));
82
85
ui.kType->addItem(i18n("All with transfers"));
83
86
ui.kType->addItem(i18n("Income with transfers"));
84
ui.kType->addItem(i18n("Expense with transfers"));
87
ui.kType->addItem(i18n("Expenditure with transfers"));
86
89
connect(ui.kTableWithGraph->table(), SIGNAL(currentItemChanged(QTableWidgetItem*, QTableWidgetItem*)), this, SLOT(onSelectionChanged()));
89
92
connect(ui.kColumns, SIGNAL(currentIndexChanged(int)), this, SLOT(refresh()), Qt::QueuedConnection);
90
93
connect(ui.kLines, SIGNAL(currentIndexChanged(int)), this, SLOT(refresh()), Qt::QueuedConnection);
94
connect(ui.kMode, SIGNAL(currentIndexChanged(int)), this, SLOT(refresh()), Qt::QueuedConnection);
91
95
connect(ui.kPeriod, SIGNAL(currentIndexChanged(int)), this, SLOT(refresh()), Qt::QueuedConnection);
92
96
connect(ui.kType, SIGNAL(currentIndexChanged(int)), this, SLOT(refresh()), Qt::QueuedConnection);
93
97
connect((const QObject*) getDocument(), SIGNAL(tableModified(QString, int)), this, SLOT(dataModified(QString, int)));
116
120
root.setAttribute("columns", ui.kColumns->currentIndex());
117
121
root.setAttribute("lines", ui.kLines->currentIndex());
122
root.setAttribute("mode", ui.kMode->currentIndex());
118
123
root.setAttribute("period", ui.kPeriod->currentIndex());
119
124
root.setAttribute("type", ui.kType->currentIndex());
120
125
root.setAttribute("tableAndGraphState", ui.kTableWithGraph->getState());
133
138
QString columns=root.attribute ( "columns");
134
139
QString lines=root.attribute ( "lines");
140
QString mode=root.attribute ( "mode");
135
141
QString period=root.attribute ( "period");
136
142
QString type=root.attribute ( "type");
137
143
QString tableAndGraphState=root.attribute ( "tableAndGraphState");
140
146
operationWhereClause=root.attribute ( "operationWhereClause");
141
147
if (!columns.isEmpty()) ui.kColumns->setCurrentIndex(SKGServices::stringToInt(columns));
142
148
if (!lines.isEmpty()) ui.kLines->setCurrentIndex(SKGServices::stringToInt(lines));
149
if (!mode.isEmpty()) ui.kMode->setCurrentIndex(SKGServices::stringToInt(mode));
143
150
if (!period.isEmpty()) ui.kPeriod->setCurrentIndex(SKGServices::stringToInt(period));
144
151
if (!type.isEmpty()) ui.kType->setCurrentIndex(SKGServices::stringToInt(type));
145
152
ui.kTableWithGraph->setState(tableAndGraphState);
146
153
if (!title.isEmpty()) {
147
ui.kTitle->setText(title);
154
ui.kTitle->setComment("<html><body><b>"+title+"</b></body></html>");
148
155
ui.kTitle->show();
150
157
ui.kTitle->hide();
171
183
if (ui.kTitle->isVisible()) oTitle=ui.kTitle->text()+'\n';
185
bool modeHistory=(ui.kMode->currentIndex()==1);
173
187
//Condition on line attribute
174
188
oTitle+=i18n("Operations with ");
175
if (row+1!=ui.kTableWithGraph->table()->rowCount()) {
189
if (modeHistory || row+1!=ui.kTableWithGraph->table()->rowCount()) {
176
190
QString att=AttsForLines[ui.kLines->currentIndex()];
178
192
QString lineVal=ui.kTableWithGraph->table()->item(row, 0)->text();
190
204
//Condition on column attribute
191
205
int nbCol=ui.kTableWithGraph->table()->columnCount();
192
if (column!=0 && (nbCol==2 || (nbCol>=4 && column<nbCol-2))) {
206
if (modeHistory || (column!=0 && (nbCol==2 || (nbCol>=4 && column<nbCol-2)))) {
193
207
if (!AttsForColumns[ui.kColumns->currentIndex()].isEmpty()) {
194
208
if (!oWc.isEmpty()) {
232
246
//Call operation plugin
233
247
QDomDocument doc("SKGML");
234
QDomElement root = doc.createElement("parameters");
235
doc.appendChild(root);
248
doc.setContent ( getDocument()->getParameter("SKGOPERATION_DEFAULT_PARAMETERS") );
249
QDomElement root = doc.documentElement();
251
root=doc.createElement("parameters");
252
doc.appendChild(root);
236
255
root.setAttribute("operationTable", "v_operation_consolidated");
237
256
root.setAttribute("operationWhereClause", wc);
238
257
root.setAttribute("title", title);
239
258
root.setAttribute("title_icon", "view-statistics");
259
root.setAttribute ( "currentPage", "-1" );
242
261
getMainPanel()->setNewTabContent(getMainPanel()->getPluginByName("Skrooge operation plugin"), -1, doc.toString());
256
275
//Call report plugin
257
276
QDomDocument doc("SKGML");
258
QDomElement root = doc.createElement("parameters");
259
doc.appendChild(root);
277
doc.setContent(getState());
278
QDomElement root = doc.documentElement();
260
279
root.setAttribute("operationWhereClause", wc);
261
280
root.setAttribute("title", title);
262
281
root.setAttribute("title_icon", "view-statistics");
271
290
switch ( ui.kPeriod->currentIndex() ) {
274
wc="d_DATEMONTH=STRFTIME('%Y-%m',date('now'))";
293
wc="d_DATEMONTH=STRFTIME('%Y-%m',date('now'))";
279
wc="d_DATEMONTH=STRFTIME('%Y-%m',date('now','-1 month'))";
298
wc="d_DATEMONTH=STRFTIME('%Y-%m',date('now','-1 month'))";
284
wc="d_DATEYEAR=STRFTIME('%Y',date('now'))";
303
wc="d_DATEYEAR=STRFTIME('%Y',date('now'))";
289
wc="d_DATEYEAR=STRFTIME('%Y',date('now','-1 year'))";
308
wc="d_DATEYEAR=STRFTIME('%Y',date('now','-1 year'))";
409
428
table.replace(0, line1);
431
bool modeHistory=(ui.kMode->currentIndex()==1);
434
SKGStringListList historizedTable;
436
historizedTable.push_back(table.at(0));
439
int nblines=table.count();
442
nbCols=table.at(0).count();
444
for (int i=1; i<nblines; ++i) {
446
newLine.push_back(table.at(i).at(0));
449
for (int j=1; j<nbCols; ++j) {
450
sum+=SKGServices::stringToDouble(table.at(i).at(j));
451
newLine.push_back(SKGServices::doubleToString(sum));
453
historizedTable.push_back(newLine);
456
table=historizedTable;
412
459
QString primaryUnit=((SKGDocumentBank*) getDocument())->getPrimaryUnit();
413
460
QString secondaryUnit=((SKGDocumentBank*) getDocument())->getSecondaryUnit();
414
461
double secondaryUnitValue=((SKGDocumentBank*) getDocument())->getSecondaryUnitValue();
415
ui.kTableWithGraph->setData(table, primaryUnit, secondaryUnit, secondaryUnitValue);
462
ui.kTableWithGraph->setData(table, primaryUnit, secondaryUnit, secondaryUnitValue, !modeHistory);