[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    =?utf-8?q?=5Bskrooge/Feature=5D_/=3A_First_version_of_graph_in_?=
From:       Stephane Mankowski <stephane () mankowski ! fr>
Date:       2011-06-11 7:02:03
Message-ID: 20110611070203.6F524A60A4 () git ! kde ! org
[Download RAW message or body]

Git commit 49351a5bc980c3e0bbbf7ae2520f85ab84af1de8 by Stephane Mankowski.
Committed on 11/06/2011 at 09:01.
Pushed by smankowski into branch 'Feature'.

First version of graph in "bank" page

M  +15   -6    skgbasegui/skgtablewithgraph.cpp     
M  +2    -0    skgbasegui/skgwidgetselector.cpp     
M  +75   -0    skgbasemodeler/skgservices.cpp     
M  +14   -0    skgbasemodeler/skgservices.h     
M  +121  -13   skrooge_bank/skgbankpluginwidget.cpp     
M  +3    -0    skrooge_bank/skgbankpluginwidget.h     
M  +2    -2    skrooge_bank/skgbankpluginwidget_base.ui     
M  +8    -79   skrooge_report/skgreportpluginwidget.cpp     
M  +0    -13   skrooge_report/skgreportpluginwidget.h     
M  +1    -1    skrooge_report/skgreportpluginwidget_base.ui     

http://commits.kde.org/skrooge/49351a5bc980c3e0bbbf7ae2520f85ab84af1de8

diff --git a/skgbasegui/skgtablewithgraph.cpp b/skgbasegui/skgtablewithgraph.cpp
index 3e5d9f7..e10af4c 100644
--- a/skgbasegui/skgtablewithgraph.cpp
+++ b/skgbasegui/skgtablewithgraph.cpp
@@ -161,14 +161,17 @@ SKGTableWithGraph::SKGTableWithGraph(QWidget *parent)
     connect(displayModeMenu, SIGNAL(currentIndexChanged(int)), m_displayMode, \
                SLOT(setCurrentIndex(int)));
     connect(m_displayMode, SIGNAL(currentIndexChanged(int)), displayModeMenu, \
SLOT(setCurrentIndex(int)));  
-    //Add all positive in menu
+    //Reset Colors
+    QAction* resetColors = m_mainMenu->addAction(KIcon("format-fill-color"), i18nc("Noun, user action", \
"Reset default colors")); +    connect(resetColors, SIGNAL(triggered(bool)), this, \
SLOT(onResetColors())); +    getGraphContextualMenu()->addAction(resetColors);
+
+    //Add item in menu of the graph
     m_allPositiveMenu = getGraphContextualMenu()->addAction(KIcon("go-up-search"), i18nc("Noun, user \
action", "All values in positive"));  if(m_allPositiveMenu)  m_allPositiveMenu->setCheckable(true);
     connect(m_allPositiveMenu, SIGNAL(toggled(bool)), this, SLOT(redrawGraphDelayed()), \
Qt::QueuedConnection);  
-    QAction* resetColors = m_mainMenu->addAction(KIcon("format-fill-color"), i18nc("Noun, user action", \
                "Reset default colors"));
-    connect(resetColors, SIGNAL(triggered(bool)), this, SLOT(onResetColors()));
-
+    //Add item in menu of the graph
     m_actShowLimits = getGraphContextualMenu()->addAction(i18nc("Noun, user action", "Show limits and \
average"));  if(m_actShowLimits) {
         m_actShowLimits->setCheckable(true);
@@ -176,6 +179,7 @@ SKGTableWithGraph::SKGTableWithGraph(QWidget *parent)
         connect(m_actShowLimits, SIGNAL(triggered(bool)), this, SLOT(onSwitchLimits()));
     }
 
+    //Add item in menu of the graph
     m_actShowLinearRegression = getGraphContextualMenu()->addAction(i18nc("Noun, user action", "Show \
tendency line"));  if(m_actShowLinearRegression) {
         m_actShowLinearRegression->setCheckable(true);
@@ -183,6 +187,7 @@ SKGTableWithGraph::SKGTableWithGraph(QWidget *parent)
         connect(m_actShowLinearRegression, SIGNAL(triggered(bool)), this, \
SLOT(onSwitchLinearRegression()));  }
 
+    //Add item in menu of the graph
     m_actShowLegend = getGraphContextualMenu()->addAction(KIcon("help-contents"), i18nc("Noun, user \
action", "Show legend"));  if(m_actShowLegend) {
         m_actShowLegend->setCheckable(true);
@@ -190,6 +195,7 @@ SKGTableWithGraph::SKGTableWithGraph(QWidget *parent)
         connect(m_actShowLegend, SIGNAL(triggered(bool)), this, SLOT(onSwitchLegend()));
     }
 
+    //Add item in menu of the graph
     m_actShowZero = getGraphContextualMenu()->addAction(KIcon("snap-orto"), i18nc("Noun, user action", \
"Show origin"));  if(m_actShowZero) {
         m_actShowZero->setCheckable(true);
@@ -412,6 +418,9 @@ QString SKGTableWithGraph::getState()
 void SKGTableWithGraph::setState(const QString& iState)
 {
     SKGTRACEIN(10, "SKGTableWithGraph::setState");
+    m_timer.stop();
+    m_timerRedraw.stop();
+
     QDomDocument doc("SKGML");
     doc.setContent(iState);
     QDomElement root = doc.documentElement();
@@ -757,7 +766,7 @@ void SKGTableWithGraph::refresh()
                 }
             }
             if(m_additionalInformation & SUM) newLine.push_back(SKGServices::doubleToString(sumy));
-            if(m_additionalInformation & AVERAGE) newLine.push_back(SKGServices::doubleToString(sumy / \
nbVals)); +            if(m_additionalInformation & AVERAGE && nbVals) \
newLine.push_back(SKGServices::doubleToString(sumy / nbVals));  if(m_additionalInformation & LIMITS) {
                 newLine.push_back(SKGServices::doubleToString(min));
                 newLine.push_back(SKGServices::doubleToString(max));
@@ -1275,7 +1284,7 @@ void SKGTableWithGraph::redrawGraph()
         double radius = 0.0;
         int jstep = qMax(computeStepSize(nbColumns, 10), double(1.0));
         double ystep = computeStepSize(maxLimit - minLimit, 10);
-        if(mode != BUBBLE) {
+        if(mode != BUBBLE && ystep) {
             double newMinLimit = ystep * round(minLimit / ystep);
             minLimit = (minLimit - newMinLimit < -EPSILON ? newMinLimit - ystep : newMinLimit);
             double newMaxLimit = ystep * round(maxLimit / ystep);
diff --git a/skgbasegui/skgwidgetselector.cpp b/skgbasegui/skgwidgetselector.cpp
index 891a64e..4ba3117 100644
--- a/skgbasegui/skgwidgetselector.cpp
+++ b/skgbasegui/skgwidgetselector.cpp
@@ -114,6 +114,8 @@ void SKGWidgetSelector::setSelectedMode(int iMode)
             }
         }
 
+        if(m_currentMode < -1) this->hide();
+
         emit selectedModeChanged(m_currentMode);
     }
 }
diff --git a/skgbasemodeler/skgservices.cpp b/skgbasemodeler/skgservices.cpp
index 7c8eb12..b8730ec 100644
--- a/skgbasemodeler/skgservices.cpp
+++ b/skgbasemodeler/skgservices.cpp
@@ -959,4 +959,79 @@ double SKGServices::getMicroTime()
 #endif
 }
 
+SKGStringListList SKGServices::getPourcentTable(const SKGStringListList& iTable)
+{
+    SKGTRACEIN(10, "SKGServices::getPourcentTable");
+
+    //Build history
+    SKGStringListList output;
+
+    output.push_back(iTable.at(0));
+
+    QStringList newLine;
+    int nblines = iTable.count();
+    int nbCols = 0;
+    if(nblines) {
+        nbCols = iTable.at(0).count();
+    }
+
+    //Compute sums
+    QList<double> sums;
+    for(int j = 1; j < nbCols; ++j) {
+
+        //Compute sum
+        double sum = 0;
+        for(int i = 1; i < nblines; ++i) {
+            sum += SKGServices::stringToDouble(iTable.at(i).at(j));
+        }
+
+        sums.push_back(sum);
+    }
+
+    //Create table
+    for(int i = 1; i < nblines; ++i) {
+        QStringList newLine;
+        newLine.push_back(iTable.at(i).at(0));
+
+        for(int j = 1; j < nbCols; ++j) {
+            double val = SKGServices::stringToDouble(iTable.at(i).at(j));
+            double sum = sums.at(j - 1);
+            newLine.push_back(SKGServices::doubleToString(sum == 0.0 ? 0.0 : 100.0 * val / sum));
+        }
+        output.push_back(newLine);
+    }
+
+    return output;
+}
+
+SKGStringListList SKGServices::getHistorizedTable(const SKGStringListList& iTable)
+{
+    SKGTRACEIN(10, "SKGServices::getHistorizedTable");
+
+    //Build history
+    SKGStringListList output;
+
+    output.push_back(iTable.at(0));
+
+    QStringList newLine;
+    int nblines = iTable.count();
+    int nbCols = 0;
+    if(nblines) {
+        nbCols = iTable.at(0).count();
+    }
+    for(int i = 1; i < nblines; ++i) {
+        QStringList newLine;
+        newLine.push_back(iTable.at(i).at(0));
+
+        double sum = 0;
+        for(int j = 1; j < nbCols; ++j) {
+            sum += SKGServices::stringToDouble(iTable.at(i).at(j));
+            newLine.push_back(SKGServices::doubleToString(sum));
+        }
+        output.push_back(newLine);
+    }
+
+    return output;
+}
+
 #include "skgservices.moc"
diff --git a/skgbasemodeler/skgservices.h b/skgbasemodeler/skgservices.h
index ab25c97..4ed7432 100644
--- a/skgbasemodeler/skgservices.h
+++ b/skgbasemodeler/skgservices.h
@@ -416,6 +416,20 @@ public:
      */
     static int SKGSqlTraces;
 
+
+    /**
+     * Create a table with all values expressed in % of the column
+     * @param iTable table
+     */
+    static SKGStringListList getPourcentTable(const SKGStringListList& iTable);
+
+    /**
+     * Create an historized table.
+     * Each column is the sum of previous ones
+     * @param iTable table
+     */
+    static SKGStringListList getHistorizedTable(const SKGStringListList& iTable);
+
 private:
     Q_DISABLE_COPY(SKGServices);
     static SKGError m_lastCallbackError;
diff --git a/skrooge_bank/skgbankpluginwidget.cpp b/skrooge_bank/skgbankpluginwidget.cpp
index 5efaa9d..6368bbd 100644
--- a/skrooge_bank/skgbankpluginwidget.cpp
+++ b/skrooge_bank/skgbankpluginwidget.cpp
@@ -28,6 +28,8 @@
 #include "skgbankobject.h"
 #include "skgdocumentbank.h"
 #include "skgtraces.h"
+#include "skginterfaceplugin.h"
+#include <skgtablewithgraph.h>
 
 #include <kstandarddirs.h>
 #include <kmessagebox.h>
@@ -46,6 +48,52 @@ SKGBankPluginWidget::SKGBankPluginWidget(SKGDocumentBank* iDocument)
 
     ui.setupUi(this);
 
+    //Add report
+    SKGInterfacePlugin* reportPlugin = SKGMainPanel::getMainPanel()->getPluginByName("Skrooge report \
plugin"); +    if(reportPlugin) {
+        m_graph = qobject_cast< SKGWidget* >(reportPlugin->getDashboardWidget(0));
+        if(m_graph) {
+            ui.verticalLayout->insertWidget(2, m_graph);
+            //Set initial state
+            m_graph->hide();
+
+            QDomDocument doc1("SKGML");
+            QDomElement root1 = doc1.createElement("parameters");
+            doc1.appendChild(root1);
+
+            root1.setAttribute("period", "0");
+            root1.setAttribute("columns", "d_DATEMONTH");
+            root1.setAttribute("mode", "1");
+            root1.setAttribute("currentPage", "-2");
+
+            {
+                QDomDocument doc2("SKGML");
+                QDomElement root2 = doc2.createElement("parameters");
+                doc2.appendChild(root2);
+                root2.setAttribute("graphMode", SKGServices::intToString((int) \
SKGTableWithGraph::LINE)); +
+                {
+                    QDomDocument doc3("SKGML");
+                    QDomElement root3 = doc3.createElement("parameters");
+                    doc3.appendChild(root3);
+                    root3.setAttribute("isToolBarVisible", "N");
+
+                    root2.setAttribute("graphicViewState", doc3.toString());
+                }
+
+                root1.setAttribute("tableAndGraphState", doc2.toString());
+            }
+            m_graph->setState(doc1.toString());
+
+            connect(ui.kView->getShowWidget(), SIGNAL(stateChanged()), this, SLOT(onRefreshGraph()));
+            onRefreshGraph();
+
+            m_timer2.setSingleShot(true);
+            connect(&m_timer2, SIGNAL(timeout()), this, SLOT(onRefreshGraph()));
+        }
+    }
+
+    //Set label titles
     ui.kAccountLbl->setText(i18n("%1:", iDocument->getDisplay("t_ACCOUNT")));
     ui.kTypeLbl->setText(i18n("%1:", iDocument->getDisplay("t_type")));
     ui.kBankNumberLbl->setText(i18n("%1:", iDocument->getDisplay("t_bank_number")));
@@ -56,8 +104,13 @@ SKGBankPluginWidget::SKGBankPluginWidget(SKGDocumentBank* iDocument)
 
     ui.kUnitEdit->setDocument(iDocument);
 
+    //Set show widget
     ui.kView->getShowWidget()->addItem("opened", i18n("Opened"), "", "t_close='N'", "", "", "closed");
     ui.kView->getShowWidget()->addItem("closed", i18n("Closed"), "dialog-close", "t_close='Y'", "", "", \
"opened"); +    if(m_graph) {
+        ui.kView->getShowWidget()->addSeparator();
+        ui.kView->getShowWidget()->addItem("graph", i18n("Graph"), "view-investment", "1=0", "", "", \
""); +    }
 
     ui.kView->getShowWidget()->setDefaultState("opened");
 
@@ -224,17 +277,69 @@ void SKGBankPluginWidget::onSelectionChanged()
         ui.kUnitEdit->setText(NOUPDATE);
     }
 
+    //Refresh graph
+    m_timer2.start(300);
+
     onAccountCreatorModified();
     Q_EMIT selectionChanged();
 }
 
+void SKGBankPluginWidget::onRefreshGraph()
+{
+    SKGTRACEIN(10, "SKGBankPluginWidget::onRefreshGraph");
+    if(m_graph) {
+        bool visible = ui.kView->getShowWidget()->getState().contains("graph");
+
+        QDomDocument doc("SKGML");
+        if(doc.setContent(m_graph->getState())) {
+            QDomElement root = doc.documentElement();
+
+            QString graphS = root.attribute("graph");
+
+            QDomDocument doc2("SKGML");
+            if(doc2.setContent(graphS)) {
+                QDomElement root2 = doc2.documentElement();
+                QString wc;
+                QString title;
+                int nbSelect = 0;
+                if(visible) {
+                    SKGObjectBase::SKGListSKGObjectBase objs = \
ui.kView->getView()->getSelectedObjects(); +                    nbSelect = objs.count();
+                    if(nbSelect) {
+                        wc = "t_ACCOUNT IN (";
+                        title = i18nc("Noun, a list of items", "Operations of account ");
+                        for(int i = 0; i < nbSelect; ++i) {
+                            if(i) {
+                                wc += ',';
+                                title += ',';
+                            }
+                            SKGAccountObject act = objs.at(i);
+                            wc += '\'' % SKGServices::stringToSqlString(act.getName()) % '\'';
+                            title += i18n("'%1'", act.getName());
+                        }
+                        wc += ')';
+                    }
+                } else wc = "1=0";
+                root2.setAttribute("operationWhereClause", wc);
+                root2.setAttribute("title", title);
+                root2.setAttribute("lines", nbSelect ? "t_ACCOUNT" : "#NOTHING#");
+            }
+            root.setAttribute("graph", doc2.toString());
+        }
+
+        m_graph->setState(doc.toString());
+
+        m_graph->setVisible(visible);
+    }
+}
+
 void SKGBankPluginWidget::onIconChanged()
 {
     SKGTRACEIN(10, "SKGBankPluginWidget::onIconChanged");
 
     int c = ui.kAccountCreatorIcon->currentIndex();
     if(c && c == ui.kAccountCreatorIcon->count() - 1) {
-        QString fileName = KFileDialog::getOpenFileName(KUrl(KStandardDirs::locate("data", \
"skrooge/images/logo/")), "image/png image/jpeg image/gif image/tiff" , this); +        QString fileName \
= KFileDialog::getOpenFileName(KUrl(KStandardDirs::locate("data", "skrooge / images / logo / ")), "image \
/ png image / jpeg image / gif image / tiff" , this);  if(!fileName.isEmpty()) {
             if(ui.kAccountCreatorIcon->contains(fileName)) ui.kAccountCreatorIcon->setText(fileName);
             else {
@@ -341,7 +446,7 @@ void SKGBankPluginWidget::onAddAccountClicked()
         if(err.isSucceeded()) {
             err = SKGError(0, i18nc("Successfully created an account", "Account '%1' created", name));
             ui.kView->getView()->selectObject(accountObj.getUniqueID());
-        } else err.addError(ERR_FAIL, i18nc("Error message: Could not create an account",  "Account \
creation failed")); +        } else err.addError(ERR_FAIL, i18nc("Error message : Could not create an \
account",  "Account creation failed"));  }
 
     //Display error
@@ -360,7 +465,7 @@ void SKGBankPluginWidget::onModifyAccountClicked()
 
         //Is it a massive modification of accounts to merge them ?
         SKGBEGINPROGRESSTRANSACTION(*getDocument(), i18nc("Updating an account", "Account update"), err, \
                nb);
-        if(nb > 1 && ui.kAccountCreatorAccount->text() != NOUPDATE && \
!ui.kAccountCreatorAccount->text().startsWith(QLatin1String("="))) { +        if(nb > 1 && \
ui.kAccountCreatorAccount->text() != NOUPDATE && \
                !ui.kAccountCreatorAccount->text().startsWith(QLatin1String(" = "))) {
             getDocument()->sendMessage(i18nc("Information message", "You tried to modify all names of \
selected accounts. Accounts have been merged."));  
             //Do the merge
@@ -410,7 +515,7 @@ void SKGBankPluginWidget::onModifyAccountClicked()
                         err = currentBank.getAccounts(accounts);
                         if(err.isSucceeded() && accounts.count() > 1) {
                             QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
-                            code = KMessageBox::questionYesNo(this, i18nc("Question", "You are trying to \
modify bank name of account named '%1'.\nDo you want to do this modification for all accounts of this \
bank?",  accountObj.getName())); +                            code = KMessageBox::questionYesNo(this, \
i18nc("Question", "You are trying to modify bank name of account named '%1'.\nDo you want to do this \
modification for all accounts of this bank ? ",  accountObj.getName()));  \
QApplication::restoreOverrideCursor();  }
                     }
@@ -450,12 +555,12 @@ void SKGBankPluginWidget::onModifyAccountClicked()
 
         //Remove bank without account
         if(err.isSucceeded()) {
-            err = getDocument()->executeSqliteOrder("DELETE FROM bank WHERE NOT EXISTS(SELECT 1 FROM \
account WHERE account.rd_bank_id=bank.id)"); +            err = getDocument()->executeSqliteOrder("DELETE \
FROM bank WHERE NOT EXISTS(SELECT 1 FROM account WHERE account.rd_bank_id = bank.id)");  }
 
         //status bar
         if(err.isSucceeded()) err = SKGError(0, i18nc("Successfully updated an account", "Account \
                updated."));
-        else err.addError(ERR_FAIL, i18nc("Error message: Could not update an account",  "Update \
failed")); +        else err.addError(ERR_FAIL, i18nc("Error message : Could not update an account",  \
"Update failed"));  }
 
     //Display error
@@ -499,12 +604,12 @@ void SKGBankPluginWidget::onComputeRIB()
         sc = sc.replace(l1[i], l2[i]);
     }
 
-//         int b=SKGServices::stringToInt ( sb );
-//         int g=SKGServices::stringToInt ( sg );
-//         int d=SKGServices::stringToInt ( sc.left ( 6 ) );
-//         int c=SKGServices::stringToInt ( sc.right ( 5 ) );
+    //         int b=SKGServices::stringToInt ( sb );
+    //         int g=SKGServices::stringToInt ( sg );
+    //         int d=SKGServices::stringToInt ( sc.left ( 6 ) );
+    //         int c=SKGServices::stringToInt ( sc.right ( 5 ) );
 
-//         ui.kRib->setText ( SKGServices::intToString ( 97 - ( ( 89 * b + 15 * g + 76 * d + 3 * c ) % \
97 ) ) ); +    //         ui.kRib->setText ( SKGServices::intToString ( 97 - ( ( 89 * b + 15 * g + 76 * d \
+ 3 * c ) % 97 ) ) );  }
 
 void SKGBankPluginWidget::cleanEditor()
@@ -532,12 +637,14 @@ QString SKGBankPluginWidget::getState()
     doc.appendChild(root);
     root.setAttribute("currentPage", SKGServices::intToString(ui.kWidgetSelector->getSelectedMode()));
     root.setAttribute("view", ui.kView->getState());
+    root.setAttribute("graph", m_graph->getState());
     return doc.toString();
 }
 
 void SKGBankPluginWidget::setState(const QString& iState)
 {
     SKGTRACEIN(10, "SKGBankPluginWidget::setState");
+
     QDomDocument doc("SKGML");
     doc.setContent(iState);
     QDomElement root = doc.documentElement();
@@ -547,6 +654,7 @@ void SKGBankPluginWidget::setState(const QString& iState)
     ui.kWidgetSelector->setSelectedMode(SKGServices::stringToInt(currentPage));
 
     ui.kView->setState(root.attribute("view"));
+    m_graph->setState(root.attribute("graph"));
 }
 
 QString SKGBankPluginWidget::getDefaultStateAttribute()
@@ -602,7 +710,7 @@ void SKGBankPluginWidget::refreshInfoZone()
             QString s2 = doc->formatMoney(v2, primary);
             QString s3 = doc->formatMoney(v3, primary);
             QString s4 = doc->formatMoney(v4, primary);
-            ui.kInfo->setText(i18nc("Information on an account's status : Balance is the current amount \
of money on the account, Cleared is the amount of money on your last bank's statement, In Transit is the \
differences between these two values", "Today balance: %1     Balance: %2     Cleared: %3     In Transit: \
%4", s1, s2, s3, s4)); +            ui.kInfo->setText(i18nc("Information on an account's status : Balance \
is the current amount of money on the account, Cleared is the amount of money on your last bank's \
statement, In Transit is the differences between these two values", "Today balance : %1     Balance : %2  \
Cleared : %3     In Transit : %4", s1, s2, s3, s4));  
             SKGServices::SKGUnitInfo secondaryUnit = doc->getSecondaryUnit();
             if(!secondaryUnit.Symbol.isEmpty() && secondaryUnit.Value) {
@@ -611,7 +719,7 @@ void SKGBankPluginWidget::refreshInfoZone()
                 s3 = doc->formatMoney(v3, secondaryUnit);
                 s4 = doc->formatMoney(v4, secondaryUnit);
             }
-            ui.kInfo->setToolTip(i18nc("Information on an account's status : Balance is the current \
amount of money on the account, Cleared is the amount of money on your last bank's statement, In Transit \
is the differences between these two values", "<p>Today balance: %1</p><p>Balance: %2</p><p>Cleared: \
%3</p><p>In Transit: %4</p>", s1, s2, s3, s4)); +            ui.kInfo->setToolTip(i18nc("Information on \
an account's status : Balance is the current amount of money on the account, Cleared is the amount of \
money on your last bank's statement, In Transit is the differences between these two values", "<p>Today \
balance : %1 < / p > <p>Balance : %2 < / p > <p>Cleared : %3 < / p > <p>In Transit : %4 < / p > ", s1, \
s2, s3, s4));  }
     }
 }
diff --git a/skrooge_bank/skgbankpluginwidget.h b/skrooge_bank/skgbankpluginwidget.h
index e92092c..7120253 100644
--- a/skrooge_bank/skgbankpluginwidget.h
+++ b/skrooge_bank/skgbankpluginwidget.h
@@ -104,6 +104,7 @@ private Q_SLOTS:
     void onModifyAccountClicked();
     void onDoubleClickedAccount();
     void onSelectionChanged();
+    void onRefreshGraph();
     void onComputeRIB();
     void cleanEditor();
     void refreshInfoZone();
@@ -114,6 +115,8 @@ private:
 
     Ui::skgbankplugin_base ui;
     QTimer m_timer;
+    QTimer m_timer2;
+    SKGWidget* m_graph;
 };
 
 #endif // SKGDEBUGPLUGIN_H
diff --git a/skrooge_bank/skgbankpluginwidget_base.ui b/skrooge_bank/skgbankpluginwidget_base.ui
index 29cd803..3ffee57 100644
--- a/skrooge_bank/skgbankpluginwidget_base.ui
+++ b/skrooge_bank/skgbankpluginwidget_base.ui
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>730</width>
-    <height>376</height>
+    <width>759</width>
+    <height>451</height>
    </rect>
   </property>
   <layout class="QVBoxLayout" name="verticalLayout">
diff --git a/skrooge_report/skgreportpluginwidget.cpp b/skrooge_report/skgreportpluginwidget.cpp
index c65f8c0..11adb38 100644
--- a/skrooge_report/skgreportpluginwidget.cpp
+++ b/skrooge_report/skgreportpluginwidget.cpp
@@ -232,6 +232,8 @@ QString SKGReportPluginWidget::getState()
 void SKGReportPluginWidget::setState(const QString& iState)
 {
     SKGTRACEIN(10, "SKGReportPluginWidget::setState");
+    m_timer.stop();
+
     QDomDocument doc("SKGML");
     doc.setContent(iState);
     QDomElement root = doc.documentElement();
@@ -292,7 +294,9 @@ void SKGReportPluginWidget::setState(const QString& iState)
     ui.kIncomes->setChecked(incomes != "N");
     ui.kExpenses->setChecked(expenses != "N");
     ui.kTransfers->setChecked(transfers != "N");
-    ui.kWidgetSelector->setSelectedMode(SKGServices::stringToInt(currentPage));
+    int currentPageInt = SKGServices::stringToInt(currentPage);
+    ui.kWidgetSelector->setSelectedMode(currentPageInt);
+    ui.kLine->setVisible(currentPageInt >= -1);
     ui.kForecastCmb->setCurrentIndex(ui.kForecastCmb->findData(SKGServices::stringToInt(forecast)));
     ui.kForecastValue->setValue(SKGServices::stringToInt(forecastValue));
 
@@ -312,7 +316,7 @@ void SKGReportPluginWidget::setState(const QString& iState)
         //We keep a copy of given state in case of bookmark
         m_lastState = doc;
         dataModified("", 0);
-    }
+    } else m_lastState.clear();
 }
 
 QString SKGReportPluginWidget::getDefaultStateAttribute()
@@ -1169,7 +1173,7 @@ void SKGReportPluginWidget::dataModified(const QString& iTableName, int iIdTrans
                         if(m_attsForColumns.at(col).startsWith(QLatin1String("d_"))) dmode |= \
SKGTableWithGraph::AVERAGE | SKGTableWithGraph::LIMITS;  
                         //Create history (must be done after groups)
-                        if(modeHistory) table = SKGReportPluginWidget::getHistorizedTable(table);
+                        if(modeHistory) table = SKGServices::getHistorizedTable(table);
                         else {
                             //Add SUM if not in HISTORY mode
                             dmode |= SKGTableWithGraph::SUM;
@@ -1182,7 +1186,7 @@ void SKGReportPluginWidget::dataModified(const QString& iTableName, int iIdTrans
                             SKGServices::SKGUnitInfo empty;
                             secondaryUnit = empty;
 
-                            table = SKGReportPluginWidget::getPourcentTable(table);
+                            table = SKGServices::getPourcentTable(table);
                         }
 
                         //Set data
@@ -1208,81 +1212,6 @@ void SKGReportPluginWidget::dataModified(const QString& iTableName, int iIdTrans
     }
 }
 
-SKGStringListList SKGReportPluginWidget::getPourcentTable(const SKGStringListList& iTable)
-{
-    SKGTRACEIN(10, "SKGReportPluginWidget::getPourcentTable");
-
-    //Build history
-    SKGStringListList output;
-
-    output.push_back(iTable.at(0));
-
-    QStringList newLine;
-    int nblines = iTable.count();
-    int nbCols = 0;
-    if(nblines) {
-        nbCols = iTable.at(0).count();
-    }
-
-    //Compute sums
-    QList<double> sums;
-    for(int j = 1; j < nbCols; ++j) {
-
-        //Compute sum
-        double sum = 0;
-        for(int i = 1; i < nblines; ++i) {
-            sum += SKGServices::stringToDouble(iTable.at(i).at(j));
-        }
-
-        sums.push_back(sum);
-    }
-
-    //Create table
-    for(int i = 1; i < nblines; ++i) {
-        QStringList newLine;
-        newLine.push_back(iTable.at(i).at(0));
-
-        for(int j = 1; j < nbCols; ++j) {
-            double val = SKGServices::stringToDouble(iTable.at(i).at(j));
-            double sum = sums.at(j - 1);
-            newLine.push_back(SKGServices::doubleToString(sum == 0.0 ? 0.0 : 100.0 * val / sum));
-        }
-        output.push_back(newLine);
-    }
-
-    return output;
-}
-
-SKGStringListList SKGReportPluginWidget::getHistorizedTable(const SKGStringListList& iTable)
-{
-    SKGTRACEIN(10, "SKGReportPluginWidget::getHistorizedTable");
-
-    //Build history
-    SKGStringListList output;
-
-    output.push_back(iTable.at(0));
-
-    QStringList newLine;
-    int nblines = iTable.count();
-    int nbCols = 0;
-    if(nblines) {
-        nbCols = iTable.at(0).count();
-    }
-    for(int i = 1; i < nblines; ++i) {
-        QStringList newLine;
-        newLine.push_back(iTable.at(i).at(0));
-
-        double sum = 0;
-        for(int j = 1; j < nbCols; ++j) {
-            sum += SKGServices::stringToDouble(iTable.at(i).at(j));
-            newLine.push_back(SKGServices::doubleToString(sum));
-        }
-        output.push_back(newLine);
-    }
-
-    return output;
-}
-
 void SKGReportPluginWidget::setSettings()
 {
     ui.kTableWithGraph->setAxisColor(skgreport_settings::axisColor());
diff --git a/skrooge_report/skgreportpluginwidget.h b/skrooge_report/skgreportpluginwidget.h
index cb2385d..59e1335 100644
--- a/skrooge_report/skgreportpluginwidget.h
+++ b/skrooge_report/skgreportpluginwidget.h
@@ -79,19 +79,6 @@ public:
      */
     virtual QWidget* zoomableWidget() const;
 
-    /**
-     * Create a table with all values expressed in % of the column
-     * @param iTable table
-     */
-    static SKGStringListList getPourcentTable(const SKGStringListList& iTable);
-
-    /**
-     * Create an historized table.
-     * Each column is the sum of previous ones
-     * @param iTable table
-     */
-    static SKGStringListList getHistorizedTable(const SKGStringListList& iTable);
-
 public Q_SLOTS:
     /**
      * Refresh the panel
diff --git a/skrooge_report/skgreportpluginwidget_base.ui b/skrooge_report/skgreportpluginwidget_base.ui
index c758f23..8c317af 100644
--- a/skrooge_report/skgreportpluginwidget_base.ui
+++ b/skrooge_report/skgreportpluginwidget_base.ui
@@ -66,7 +66,7 @@
     </widget>
    </item>
    <item>
-    <widget class="Line" name="line_3">
+    <widget class="Line" name="kLine">
      <property name="orientation">
       <enum>Qt::Horizontal</enum>
      </property>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic