r18872 - gnucash/trunk/src/gnc - Cutecash: Display account balance in tree and split amount in account register.

Christian Stimming cstim at code.gnucash.org
Sun Mar 7 16:27:55 EST 2010


Author: cstim
Date: 2010-03-07 16:27:55 -0500 (Sun, 07 Mar 2010)
New Revision: 18872
Trac: http://svn.gnucash.org/trac/changeset/18872

Modified:
   gnucash/trunk/src/gnc/AccountItemModel.cpp
   gnucash/trunk/src/gnc/Split.hpp
   gnucash/trunk/src/gnc/SplitListModel.cpp
   gnucash/trunk/src/gnc/mainwindow.cpp
   gnucash/trunk/src/gnc/mainwindow.ui
Log:
Cutecash: Display account balance in tree and split amount in account register.

Modified: gnucash/trunk/src/gnc/AccountItemModel.cpp
===================================================================
--- gnucash/trunk/src/gnc/AccountItemModel.cpp	2010-03-07 21:27:38 UTC (rev 18871)
+++ gnucash/trunk/src/gnc/AccountItemModel.cpp	2010-03-07 21:27:55 UTC (rev 18872)
@@ -21,6 +21,7 @@
  */
 
 #include "AccountItemModel.hpp"
+#include "gnc/Numeric.hpp"
 #include <QDebug>
 
 namespace gnc
@@ -95,7 +96,7 @@
 //     if (!parent.isValid())
 //         return 0;
 //     else
-    return 3; // Fixed number for now
+    return 4; // Fixed number for now
 }
 
 QVariant AccountTreeModel::data(const QModelIndex& index, int role) const
@@ -114,6 +115,12 @@
             return account.getCode();
         case 2:
             return account.getDescription();
+        case 3:
+        {
+            Numeric balance = gnc_ui_account_get_balance(account.get(), false);
+            PrintAmountInfo printInfo(account.get(), true);
+            return balance.printAmount(printInfo);
+        }
         default:
             return QVariant();
         }
@@ -147,6 +154,8 @@
             return QString("Code");
         case 2:
             return QString("Description");
+        case 3:
+            return QString("Balance");
         default:
             return QVariant();
         }

Modified: gnucash/trunk/src/gnc/Split.hpp
===================================================================
--- gnucash/trunk/src/gnc/Split.hpp	2010-03-07 21:27:38 UTC (rev 18871)
+++ gnucash/trunk/src/gnc/Split.hpp	2010-03-07 21:27:55 UTC (rev 18872)
@@ -79,7 +79,17 @@
     QString getCorrAccountName() const { return QString::fromUtf8(xaccSplitGetCorrAccountName(get())); }
     QString getCorrAccountCode() const { return QString::fromUtf8(xaccSplitGetCorrAccountCode(get())); }
 
+    void setAmount(const Numeric& amount) { xaccSplitSetAmount(get(), amount); }
+    Numeric getAmount() const { return xaccSplitGetAmount(get()); }
+    void setValue(const Numeric& value) { xaccSplitSetValue(get(), value); }
+    Numeric getValue() const { return xaccSplitGetValue(get()); }
+    Numeric getSharePrice() const { return xaccSplitGetSharePrice(get()); }
+    Numeric getBalance() const { return xaccSplitGetBalance(get()); }
+    Numeric getClearedBalance() const { return xaccSplitGetClearedBalance(get()); }
+    Numeric getReconciledBalance() const { return xaccSplitGetReconciledBalance(get()); }
 
+
+
     static SplitQList fromGList(GList* glist)
     {
         SplitQList result;

Modified: gnucash/trunk/src/gnc/SplitListModel.cpp
===================================================================
--- gnucash/trunk/src/gnc/SplitListModel.cpp	2010-03-07 21:27:38 UTC (rev 18871)
+++ gnucash/trunk/src/gnc/SplitListModel.cpp	2010-03-07 21:27:55 UTC (rev 18872)
@@ -56,7 +56,7 @@
 //     if (!parent.isValid())
 //         return 0;
 //     else
-    return 4; // Fixed number for now
+    return 5; // Fixed number for now
 }
 
 QVariant SplitListModel::data(const QModelIndex& index, int role) const
@@ -78,6 +78,12 @@
             return split.getCorrAccountFullName();
         case 3:
             return QChar(split.getReconcile());
+        case 4:
+        {
+            Numeric amount = split.getAmount(); // Alternatively: xaccSplitConvertAmount(split.get(), split.getAccount().get());
+            PrintAmountInfo printInfo(split.get(), true);
+            return amount.printAmount(printInfo);
+        }
         default:
             return QVariant();
         }
@@ -113,6 +119,8 @@
             return QString("Account");
         case 3:
             return QString("Reconciled?");
+        case 4:
+            return QString("Amount");
         default:
             return QVariant();
         }

Modified: gnucash/trunk/src/gnc/mainwindow.cpp
===================================================================
--- gnucash/trunk/src/gnc/mainwindow.cpp	2010-03-07 21:27:38 UTC (rev 18871)
+++ gnucash/trunk/src/gnc/mainwindow.cpp	2010-03-07 21:27:55 UTC (rev 18872)
@@ -179,6 +179,8 @@
 
     connect(ui->treeView, SIGNAL(activated(const QModelIndex &)),
             this, SLOT(activatedAccount(const QModelIndex&)));
+    connect(ui->tableView, SIGNAL(activated(const QModelIndex &)),
+            this, SLOT(activatedAccount(const QModelIndex&)));
 }
 
 void MainWindow::createToolBars()
@@ -254,7 +256,8 @@
 
 void MainWindow::activatedAccount(const QModelIndex & index)
 {
-    if (index.model() != m_accountTreeModel)
+    if (index.model() != m_accountTreeModel
+            && index.model() != m_accountListModel)
     {
         qDebug() << "Wrong model";
         return;
@@ -274,6 +277,7 @@
     QTableView *tableView = new QTableView(this); // FIXME: Parent object unclear
     SplitListModel *smodel = new SplitListModel(Split::fromGList(slist), tableView);
     tableView->setModel(smodel);
+    tableView->setAlternatingRowColors(true);
 
     // Insert this as a new tab
     ui->tabWidget->addTab(tableView, account.getName());

Modified: gnucash/trunk/src/gnc/mainwindow.ui
===================================================================
--- gnucash/trunk/src/gnc/mainwindow.ui	2010-03-07 21:27:38 UTC (rev 18871)
+++ gnucash/trunk/src/gnc/mainwindow.ui	2010-03-07 21:27:55 UTC (rev 18872)
@@ -53,11 +53,14 @@
 &lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
 &lt;p style=&quot; margin-top:18px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:12pt; font-weight:600;&quot;&gt;Cutecash&lt;/span&gt;&lt;/p&gt;
 &lt;p style=&quot; margin-top:18px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:12pt; font-weight:600;&quot;&gt;Free Finance Software. Easy to develop, easy to use.&lt;/span&gt;&lt;/p&gt;
-&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;Currently this is just a proof-of-concept for developers:&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;Currently this is more or less a proof-of-concept for developers:&lt;/span&gt;&lt;/p&gt;
 &lt;ol style=&quot;-qt-list-indent: 1;&quot;&gt;&lt;li style=&quot; margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Load an existing gnucash XML file&lt;/li&gt;
 &lt;li style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;It will show the account tree in a QTreeView&lt;/li&gt;
-&lt;li style=&quot; margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Additionally the accounts will be shown in a flat list in a QTableView&lt;/li&gt;&lt;/ol&gt;
-&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;The fun part is how easy it was to add this display of all accounts. And a QTableView with the splits of an account can't be far...&lt;/span&gt;&lt;/p&gt;
+&lt;li style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Additionally the accounts will be shown in a flat list in a QTableView&lt;/li&gt;
+&lt;li style=&quot; margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Double-click on  any account in either view; it will open the list of splits in that account.&lt;/li&gt;&lt;/ol&gt;
+&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;The list of splits in the account is comparable to gnucash's single line view.  The amounts are already there. The dates are still missing, but that can't be hard, too.&lt;/p&gt;
+&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;This is all read-only access so far, although &quot;Save&quot; probably works but hasn't been tested.&lt;/p&gt;
+&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;The fun part is how easy it was to add this. Let's see how far we will get...&lt;/span&gt;&lt;/p&gt;
 &lt;p style=&quot; margin-top:16px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:600;&quot;&gt;Images&lt;/span&gt;&lt;/p&gt;
 &lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;img src=&quot;:/pixmaps/gnucash_splash.png&quot; /&gt;&lt;/p&gt;
 &lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;We can also embed images here in this compiled-in HTML page, as you can see above. Eventually, this page should explain what this software can do for the new user. Maybe a &lt;/span&gt;&lt;a href=&quot;gnc:test&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;hyperlink &lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;here?&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>



More information about the gnucash-changes mailing list