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 @@
</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;">
<p style=" margin-top:18px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:12pt; font-weight:600;">Cutecash</span></p>
<p style=" margin-top:18px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:12pt; font-weight:600;">Free Finance Software. Easy to develop, easy to use.</span></p>
-<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt;">Currently this is just a proof-of-concept for developers:</span></p>
+<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt;">Currently this is more or less a proof-of-concept for developers:</span></p>
<ol style="-qt-list-indent: 1;"><li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Load an existing gnucash XML file</li>
<li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">It will show the account tree in a QTreeView</li>
-<li style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Additionally the accounts will be shown in a flat list in a QTableView</li></ol>
-<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt;">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...</span></p>
+<li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Additionally the accounts will be shown in a flat list in a QTableView</li>
+<li style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Double-click on any account in either view; it will open the list of splits in that account.</li></ol>
+<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">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.</p>
+<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This is all read-only access so far, although "Save" probably works but hasn't been tested.</p>
+<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt;">The fun part is how easy it was to add this. Let's see how far we will get...</span></p>
<p style=" margin-top:16px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:600;">Images</span></p>
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src=":/pixmaps/gnucash_splash.png" /></p>
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt;">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 </span><a href="gnc:test"><span style=" text-decoration: underline; color:#0000ff;">hyperlink </span></a><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt;">here?</span></p></body></html></string>
More information about the gnucash-changes
mailing list