mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Cutecash: Add Timespec conversion to QDateTime. Add display of transaction date in register tabs.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18874 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
e42a405785
commit
95fa70fec6
@ -28,10 +28,12 @@
|
|||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
#include "qof.h"
|
#include "qof.h"
|
||||||
|
#include "gnc-date.h"
|
||||||
#include "engine/gnc-ui-util.h"
|
#include "engine/gnc-ui-util.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QDateTime>
|
||||||
|
|
||||||
namespace gnc
|
namespace gnc
|
||||||
{
|
{
|
||||||
@ -46,6 +48,22 @@ inline QString gchar_to_QString(gchar* tmp_string)
|
|||||||
return result;
|
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
|
class PrintAmountInfo : public ::GNCPrintAmountInfo
|
||||||
{
|
{
|
||||||
|
@ -56,7 +56,7 @@ int SplitListModel::columnCount(const QModelIndex& parent) const
|
|||||||
// if (!parent.isValid())
|
// if (!parent.isValid())
|
||||||
// return 0;
|
// return 0;
|
||||||
// else
|
// else
|
||||||
return 5; // Fixed number for now
|
return 6; // Fixed number for now
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant SplitListModel::data(const QModelIndex& index, int role) const
|
QVariant SplitListModel::data(const QModelIndex& index, int role) const
|
||||||
@ -71,14 +71,16 @@ QVariant SplitListModel::data(const QModelIndex& index, int role) const
|
|||||||
switch (index.column())
|
switch (index.column())
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
return trans.getNum();
|
return trans.getDatePosted().date().toString(Qt::ISODate);
|
||||||
case 1:
|
case 1:
|
||||||
return trans.getDescription();
|
return trans.getNum();
|
||||||
case 2:
|
case 2:
|
||||||
return split.getCorrAccountFullName();
|
return trans.getDescription();
|
||||||
case 3:
|
case 3:
|
||||||
return QChar(split.getReconcile());
|
return split.getCorrAccountFullName();
|
||||||
case 4:
|
case 4:
|
||||||
|
return QChar(split.getReconcile());
|
||||||
|
case 5:
|
||||||
{
|
{
|
||||||
Numeric amount = split.getAmount(); // Alternatively: xaccSplitConvertAmount(split.get(), split.getAccount().get());
|
Numeric amount = split.getAmount(); // Alternatively: xaccSplitConvertAmount(split.get(), split.getAccount().get());
|
||||||
PrintAmountInfo printInfo(split.get(), true);
|
PrintAmountInfo printInfo(split.get(), true);
|
||||||
@ -112,14 +114,16 @@ QVariant SplitListModel::headerData(int section, Qt::Orientation orientation, in
|
|||||||
switch (section)
|
switch (section)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
return QString("Num");
|
return QString("Date");
|
||||||
case 1:
|
case 1:
|
||||||
return QString("Description");
|
return QString("Num");
|
||||||
case 2:
|
case 2:
|
||||||
return QString("Account");
|
return QString("Description");
|
||||||
case 3:
|
case 3:
|
||||||
return QString("Reconciled?");
|
return QString("Account");
|
||||||
case 4:
|
case 4:
|
||||||
|
return QString("Reconciled?");
|
||||||
|
case 5:
|
||||||
return QString("Amount");
|
return QString("Amount");
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
@ -34,6 +34,7 @@ extern "C"
|
|||||||
#include "gnc/WeakPointer.hpp"
|
#include "gnc/WeakPointer.hpp"
|
||||||
#include "gnc/Account.hpp"
|
#include "gnc/Account.hpp"
|
||||||
#include "gnc/Book.hpp"
|
#include "gnc/Book.hpp"
|
||||||
|
#include "gnc/Numeric.hpp"
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
@ -60,6 +61,10 @@ public:
|
|||||||
|
|
||||||
int countSplits() const { return xaccTransCountSplits(get()); }
|
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())); }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -493,7 +493,7 @@ void MainWindow::loadFile(const QString &fileName)
|
|||||||
progressBar.setMinimum(0);
|
progressBar.setMinimum(0);
|
||||||
progressBar.setMaximum(100);
|
progressBar.setMaximum(100);
|
||||||
statusBar()->showMessage(tr("Loading user data..."));
|
statusBar()->showMessage(tr("Loading user data..."));
|
||||||
statusBar()->addWidget(&progressBar);
|
statusBar()->addPermanentWidget(&progressBar);
|
||||||
progressBar.show();
|
progressBar.show();
|
||||||
// This local progress_functor is a workaround on how to
|
// This local progress_functor is a workaround on how to
|
||||||
// pass the suitable function pointer to session_load -
|
// pass the suitable function pointer to session_load -
|
||||||
@ -564,7 +564,7 @@ void MainWindow::loadFile(const QString &fileName)
|
|||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
|
|
||||||
setCurrentFile(fileName);
|
setCurrentFile(fileName);
|
||||||
statusBar()->showMessage(tr("File loaded"), 2000);
|
statusBar()->showMessage(tr("File loaded"), 5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWindow::saveFile(const QString &fileName)
|
bool MainWindow::saveFile(const QString &fileName)
|
||||||
|
@ -113,7 +113,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuFile">
|
<widget class="QMenu" name="menuFile">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>File</string>
|
<string>&File</string>
|
||||||
</property>
|
</property>
|
||||||
<addaction name="actionNew"/>
|
<addaction name="actionNew"/>
|
||||||
<addaction name="actionOpen"/>
|
<addaction name="actionOpen"/>
|
||||||
@ -124,14 +124,14 @@ p, li { white-space: pre-wrap; }
|
|||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuHelp">
|
<widget class="QMenu" name="menuHelp">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Help</string>
|
<string>&Help</string>
|
||||||
</property>
|
</property>
|
||||||
<addaction name="actionAbout"/>
|
<addaction name="actionAbout"/>
|
||||||
<addaction name="actionAbout_Qt"/>
|
<addaction name="actionAbout_Qt"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuAccount">
|
<widget class="QMenu" name="menuAccount">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Account</string>
|
<string>&Account</string>
|
||||||
</property>
|
</property>
|
||||||
<addaction name="actionOpenAccount"/>
|
<addaction name="actionOpenAccount"/>
|
||||||
<addaction name="actionNewAccount"/>
|
<addaction name="actionNewAccount"/>
|
||||||
@ -141,7 +141,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuEdit">
|
<widget class="QMenu" name="menuEdit">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Edit</string>
|
<string>&Edit</string>
|
||||||
</property>
|
</property>
|
||||||
<addaction name="actionCut"/>
|
<addaction name="actionCut"/>
|
||||||
<addaction name="actionCopy"/>
|
<addaction name="actionCopy"/>
|
||||||
@ -198,7 +198,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
<normaloff>:/gtk-icons/gtk-save.png</normaloff>:/gtk-icons/gtk-save.png</iconset>
|
<normaloff>:/gtk-icons/gtk-save.png</normaloff>:/gtk-icons/gtk-save.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Save</string>
|
<string>&Save</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="statusTip">
|
<property name="statusTip">
|
||||||
<string>Save the document to disk</string>
|
<string>Save the document to disk</string>
|
||||||
@ -213,7 +213,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
<normaloff>:/gtk-icons/gtk-save-as.png</normaloff>:/gtk-icons/gtk-save-as.png</iconset>
|
<normaloff>:/gtk-icons/gtk-save-as.png</normaloff>:/gtk-icons/gtk-save-as.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Save as...</string>
|
<string>Save &as...</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="statusTip">
|
<property name="statusTip">
|
||||||
<string>Save the document under a new name</string>
|
<string>Save the document under a new name</string>
|
||||||
@ -225,7 +225,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
<normaloff>:/gtk-icons/gtk-quit.png</normaloff>:/gtk-icons/gtk-quit.png</iconset>
|
<normaloff>:/gtk-icons/gtk-quit.png</normaloff>:/gtk-icons/gtk-quit.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Exit</string>
|
<string>E&xit</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="whatsThis">
|
<property name="whatsThis">
|
||||||
<string>Exit the application</string>
|
<string>Exit the application</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user