r18874 - gnucash/trunk/src/gnc - Cutecash: Add Timespec conversion to QDateTime. Add display of transaction date in register tabs.

Christian Stimming cstim at code.gnucash.org
Mon Mar 8 13:48:04 EST 2010


Author: cstim
Date: 2010-03-08 13:48:03 -0500 (Mon, 08 Mar 2010)
New Revision: 18874
Trac: http://svn.gnucash.org/trac/changeset/18874

Modified:
   gnucash/trunk/src/gnc/Numeric.hpp
   gnucash/trunk/src/gnc/SplitListModel.cpp
   gnucash/trunk/src/gnc/Transaction.hpp
   gnucash/trunk/src/gnc/mainwindow.cpp
   gnucash/trunk/src/gnc/mainwindow.ui
Log:
Cutecash: Add Timespec conversion to QDateTime. Add display of transaction date in register tabs.

Modified: gnucash/trunk/src/gnc/Numeric.hpp
===================================================================
--- gnucash/trunk/src/gnc/Numeric.hpp	2010-03-07 21:28:15 UTC (rev 18873)
+++ gnucash/trunk/src/gnc/Numeric.hpp	2010-03-08 18:48:03 UTC (rev 18874)
@@ -28,10 +28,12 @@
 extern "C"
 {
 #include "qof.h"
+#include "gnc-date.h"
 #include "engine/gnc-ui-util.h"
 }
 
 #include <QString>
+#include <QDateTime>
 
 namespace gnc
 {
@@ -46,7 +48,23 @@
     return result;
 }
 
+inline QDateTime toQDateTime(const ::Timespec& timespec)
+{
+    QDateTime result = QDateTime::fromTime_t(timespec.tv_sec);
+    result.addMSecs(timespec.tv_nsec / 1000000);
+    result.setTimeSpec(Qt::UTC);
+    return result;
+}
+inline ::Timespec toTimespec(const QDateTime& qdt)
+{
+    ::Timespec result;
+    result.tv_sec = qdt.toTime_t();
+    result.tv_nsec = qdt.time().msec() * 1000000;
+    return result;
+}
 
+
+
 class PrintAmountInfo : public ::GNCPrintAmountInfo
 {
 public:

Modified: gnucash/trunk/src/gnc/SplitListModel.cpp
===================================================================
--- gnucash/trunk/src/gnc/SplitListModel.cpp	2010-03-07 21:28:15 UTC (rev 18873)
+++ gnucash/trunk/src/gnc/SplitListModel.cpp	2010-03-08 18:48:03 UTC (rev 18874)
@@ -56,7 +56,7 @@
 //     if (!parent.isValid())
 //         return 0;
 //     else
-    return 5; // Fixed number for now
+    return 6; // Fixed number for now
 }
 
 QVariant SplitListModel::data(const QModelIndex& index, int role) const
@@ -71,14 +71,16 @@
         switch (index.column())
         {
         case 0:
+            return trans.getDatePosted().date().toString(Qt::ISODate);
+        case 1:
             return trans.getNum();
-        case 1:
+        case 2:
             return trans.getDescription();
-        case 2:
+        case 3:
             return split.getCorrAccountFullName();
-        case 3:
+        case 4:
             return QChar(split.getReconcile());
-        case 4:
+        case 5:
         {
             Numeric amount = split.getAmount(); // Alternatively: xaccSplitConvertAmount(split.get(), split.getAccount().get());
             PrintAmountInfo printInfo(split.get(), true);
@@ -112,14 +114,16 @@
         switch (section)
         {
         case 0:
+            return QString("Date");
+        case 1:
             return QString("Num");
-        case 1:
+        case 2:
             return QString("Description");
-        case 2:
+        case 3:
             return QString("Account");
-        case 3:
+        case 4:
             return QString("Reconciled?");
-        case 4:
+        case 5:
             return QString("Amount");
         default:
             return QVariant();

Modified: gnucash/trunk/src/gnc/Transaction.hpp
===================================================================
--- gnucash/trunk/src/gnc/Transaction.hpp	2010-03-07 21:28:15 UTC (rev 18873)
+++ gnucash/trunk/src/gnc/Transaction.hpp	2010-03-08 18:48:03 UTC (rev 18874)
@@ -34,6 +34,7 @@
 #include "gnc/WeakPointer.hpp"
 #include "gnc/Account.hpp"
 #include "gnc/Book.hpp"
+#include "gnc/Numeric.hpp"
 
 #include <QString>
 #include <QList>
@@ -60,6 +61,10 @@
 
     int countSplits() const { return xaccTransCountSplits(get()); }
 
+    void setDatePosted(const QDateTime& t);
+    void setDateEntered(const QDateTime& t);
+    QDateTime getDatePosted() const { return toQDateTime(xaccTransRetDatePostedTS(get())); }
+    QDateTime getDateEntered() const { return toQDateTime(xaccTransRetDateEnteredTS(get())); }
 
 };
 

Modified: gnucash/trunk/src/gnc/mainwindow.cpp
===================================================================
--- gnucash/trunk/src/gnc/mainwindow.cpp	2010-03-07 21:28:15 UTC (rev 18873)
+++ gnucash/trunk/src/gnc/mainwindow.cpp	2010-03-08 18:48:03 UTC (rev 18874)
@@ -493,7 +493,7 @@
             progressBar.setMinimum(0);
             progressBar.setMaximum(100);
             statusBar()->showMessage(tr("Loading user data..."));
-            statusBar()->addWidget(&progressBar);
+            statusBar()->addPermanentWidget(&progressBar);
             progressBar.show();
             // This local progress_functor is a workaround on how to
             // pass the suitable function pointer to session_load -
@@ -564,7 +564,7 @@
     QApplication::restoreOverrideCursor();
 
     setCurrentFile(fileName);
-    statusBar()->showMessage(tr("File loaded"), 2000);
+    statusBar()->showMessage(tr("File loaded"), 5000);
 }
 
 bool MainWindow::saveFile(const QString &fileName)

Modified: gnucash/trunk/src/gnc/mainwindow.ui
===================================================================
--- gnucash/trunk/src/gnc/mainwindow.ui	2010-03-07 21:28:15 UTC (rev 18873)
+++ gnucash/trunk/src/gnc/mainwindow.ui	2010-03-08 18:48:03 UTC (rev 18874)
@@ -113,7 +113,7 @@
    </property>
    <widget class="QMenu" name="menuFile">
     <property name="title">
-     <string>File</string>
+     <string>&amp;File</string>
     </property>
     <addaction name="actionNew"/>
     <addaction name="actionOpen"/>
@@ -124,14 +124,14 @@
    </widget>
    <widget class="QMenu" name="menuHelp">
     <property name="title">
-     <string>Help</string>
+     <string>&amp;Help</string>
     </property>
     <addaction name="actionAbout"/>
     <addaction name="actionAbout_Qt"/>
    </widget>
    <widget class="QMenu" name="menuAccount">
     <property name="title">
-     <string>Account</string>
+     <string>&amp;Account</string>
     </property>
     <addaction name="actionOpenAccount"/>
     <addaction name="actionNewAccount"/>
@@ -141,7 +141,7 @@
    </widget>
    <widget class="QMenu" name="menuEdit">
     <property name="title">
-     <string>Edit</string>
+     <string>&amp;Edit</string>
     </property>
     <addaction name="actionCut"/>
     <addaction name="actionCopy"/>
@@ -198,7 +198,7 @@
      <normaloff>:/gtk-icons/gtk-save.png</normaloff>:/gtk-icons/gtk-save.png</iconset>
    </property>
    <property name="text">
-    <string>Save</string>
+    <string>&amp;Save</string>
    </property>
    <property name="statusTip">
     <string>Save the document to disk</string>
@@ -213,7 +213,7 @@
      <normaloff>:/gtk-icons/gtk-save-as.png</normaloff>:/gtk-icons/gtk-save-as.png</iconset>
    </property>
    <property name="text">
-    <string>Save as...</string>
+    <string>Save &amp;as...</string>
    </property>
    <property name="statusTip">
     <string>Save the document under a new name</string>
@@ -225,7 +225,7 @@
      <normaloff>:/gtk-icons/gtk-quit.png</normaloff>:/gtk-icons/gtk-quit.png</iconset>
    </property>
    <property name="text">
-    <string>Exit</string>
+    <string>E&amp;xit</string>
    </property>
    <property name="whatsThis">
     <string>Exit the application</string>



More information about the gnucash-changes mailing list