Drop the cutecash experiment and the gtkmm optional bindings
These are currently unmaintained, cutecash us based on the obsolete qt4 and gtkmm is only used by cutecash. Whenever someone wishes to revive this experiment it can be recovered from git history and be brought into a separate repository.
1
.gitignore
vendored
@ -193,7 +193,6 @@ src/import-export/qif-import/test/test-link
|
||||
src/import-export/test/test-import-parse
|
||||
src/import-export/test/test-link
|
||||
src/engine/test/test-qof
|
||||
src/optional/gtkmm/test/test-gtkmm
|
||||
src/optional/python-bindings/.py-links
|
||||
src/optional/python-bindings/gnucash/
|
||||
src/optional/python-bindings/gnucash_core.c
|
||||
|
@ -53,8 +53,7 @@ INCLUDE (MakeDistFiles)
|
||||
|
||||
OPTION (WITH_SQL "Build this project with SQL (libdbi) support" ON)
|
||||
OPTION (WITH_AQBANKING "Build this project with aqbanking (online banking) support" ON)
|
||||
OPTION (WITH_GNUCASH "Build all of GnuCash, not just cutecash" ON)
|
||||
OPTION (WITH_CUTECASH "Also build cutecash" OFF)
|
||||
OPTION (WITH_GNUCASH "Build all of GnuCash, not just the library" ON)
|
||||
OPTION (WITH_OFX "compile with ofx support (needs LibOFX)" ON)
|
||||
OPTION (WITH_PYTHON "enable python plugin and bindings" OFF)
|
||||
OPTION (ENABLE_BINRELOC "compile with binary relocation support" ON)
|
||||
@ -197,9 +196,6 @@ IF (WITH_GNUCASH)
|
||||
ENDIF (WITH_GNUCASH)
|
||||
|
||||
GNC_PKG_CHECK_MODULES (ZLIB REQUIRED zlib)
|
||||
IF (WITH_CUTECASH)
|
||||
GNC_PKG_CHECK_MODULES (GLIBMM REQUIRED glibmm-2.4>=2.24)
|
||||
ENDIF(WITH_CUTECASH)
|
||||
|
||||
IF (MSVC)
|
||||
MESSAGE (STATUS "Hint: To create the import libraries for the gnome DLLs (e.g. gconf-2.lib), use the dlltool as follows: pexports bin/libgconf-2-4.dll > lib/libgconf-2.def ; dlltool -d lib/libgconf-2.def -D bin/libgconf-2-4.dll -l lib/gconf-2.lib")
|
||||
@ -289,12 +285,6 @@ IF (NOT GUILE_EXECUTABLE)
|
||||
MESSAGE (SEND_ERROR "The guile executable was not found, but is required. Please set GUILE_EXECUTABLE.")
|
||||
ENDIF (NOT GUILE_EXECUTABLE)
|
||||
|
||||
# Qt
|
||||
IF (WITH_CUTECASH)
|
||||
SET (QT_MIN_VERSION "4.5.0")
|
||||
FIND_PACKAGE (Qt4 REQUIRED) # find and setup Qt4 for this project
|
||||
ENDIF (WITH_CUTECASH)
|
||||
|
||||
# ############################################################
|
||||
IF (WITH_AQBANKING)
|
||||
GNC_PKG_CHECK_MODULES (GWENHYWFAR REQUIRED gwenhywfar)
|
||||
@ -731,22 +721,6 @@ ENDIF()
|
||||
# ############################################################
|
||||
# Package creation rules
|
||||
|
||||
IF (WITH_CUTECASH)
|
||||
SET (CUTECASH_VERSION_MAJOR "0")
|
||||
SET (CUTECASH_VERSION_MINOR "1")
|
||||
SET (CUTECASH_VERSION_PATCH "0")
|
||||
SET (CUTECASH_VERSION_NANO "0")
|
||||
|
||||
SET (CPACK_PACKAGE_NAME "Cutecash")
|
||||
SET (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Cutecash Free Finance Software")
|
||||
SET (CPACK_PACKAGE_VERSION_MAJOR ${CUTECASH_VERSION_MAJOR})
|
||||
SET (CPACK_PACKAGE_VERSION_MINOR ${CUTECASH_VERSION_MINOR})
|
||||
SET (CPACK_PACKAGE_VERSION_PATCH ${CUTECASH_VERSION_PATCH})
|
||||
SET (CPACK_PACKAGE_VENDOR "Christian Stimming")
|
||||
SET (CPACK_SOURCE_IGNORE_FILES "/\\\\.svn/;/\\\\.git/;.*~;build.*;html;Debug;Release")
|
||||
SET (CPACK_STRIP_FILES "bin/cutecash")
|
||||
#SET (CPACK_PACKAGE_EXECUTABLES "bin/carclient")
|
||||
ENDIF (WITH_CUTECASH)
|
||||
IF(UNIX)
|
||||
SET(CPACK_GENERATOR "TGZ")
|
||||
ENDIF(UNIX)
|
||||
|
25
configure.ac
@ -153,30 +153,7 @@ AX_BOOST_BASE([1.53.0], [ac_cv_BOOST=yes], [ac_cv_BOOST=no])
|
||||
if test x$ac_cv_BOOST != xyes; then
|
||||
AC_MSG_ERROR([Boost 1.53.0 or later was not found and is required to build GnuCash])
|
||||
fi
|
||||
###--------------------------------------------------------
|
||||
### Optionally enable gtkmm plugin (requires c++ compiler)
|
||||
###--------------------------------------------------------
|
||||
enable_GTKMM=false
|
||||
|
||||
AC_ARG_ENABLE(gtkmm,
|
||||
[AS_HELP_STRING([--enable-gtkmm],[enable gtkmm gui])],
|
||||
[case "${enableval}" in
|
||||
yes) enable_GTKMM=true ;;
|
||||
no) enable_GTKMM=false ;;
|
||||
*) enable_GTKMM=false ;;
|
||||
esac]
|
||||
)
|
||||
|
||||
AS_IF([test x${enable_GTKMM} = "xtrue"],
|
||||
[
|
||||
# We require gtkmm, of course
|
||||
PKG_CHECK_MODULES(GTKMM, gtkmm-2.4 >= 2.24)
|
||||
# and also the c++ compiler
|
||||
AC_PROG_CXXCPP
|
||||
AC_PROG_CXX
|
||||
_COMPONENTS="$_COMPONENTS gtkmm"
|
||||
])
|
||||
AM_CONDITIONAL([WITH_GTKMM], [test x${enable_GTKMM} = "xtrue"])
|
||||
# This section must come before AC_PROG_LIBTOOL because libtool
|
||||
# must know about the c++ compiler.
|
||||
###--------------------------------------------------------
|
||||
@ -1730,8 +1707,6 @@ AC_CONFIG_FILES(
|
||||
src/import-export/aqb/gschemas/Makefile
|
||||
src/import-export/aqb/test/Makefile
|
||||
src/optional/Makefile
|
||||
src/optional/gtkmm/Makefile
|
||||
src/optional/gtkmm/test/Makefile
|
||||
src/optional/python-bindings/Makefile
|
||||
src/optional/python-bindings/tests/Makefile
|
||||
src/pixmaps/Makefile
|
||||
|
@ -66,7 +66,7 @@ ENDFUNCTION()
|
||||
|
||||
FUNCTION(MAKE_GNUCASH_POTFILES)
|
||||
|
||||
SET(IGNORE_PATTERNS "gw-" "test" "experimental" "python-bindings" "swig-.*\\.c" "^src/gnc/" "^src/optional/gtkmm")
|
||||
SET(IGNORE_PATTERNS "gw-" "test" "experimental" "python-bindings" "swig-.*\\.c")
|
||||
|
||||
# Create a list of candidate translation files
|
||||
FILE(GLOB_RECURSE FILES_IN RELATIVE ${CMAKE_SOURCE_DIR}
|
||||
|
@ -5,10 +5,6 @@ src/backend/xml/gncmod-backend-xml.c
|
||||
src/backend/xml/gncmod-backend-xml.cpp
|
||||
src/gnome-utils/gnc-tree-model-selection.c
|
||||
|
||||
# These we don't want to translate because they're experimental:
|
||||
src/gnc/.*
|
||||
src/optional/gtkmm/.*
|
||||
|
||||
# Skip softlinks to scm files. These softlinks are created in builddir
|
||||
# for testing purposes, intltool-extract isn't smart enough to ignore
|
||||
# them when bulddir and srcdir are the same, and both intltool-extract
|
||||
|
@ -6,8 +6,6 @@
|
||||
|
||||
SET (GETTEXT_PACKAGE "gnucash")
|
||||
|
||||
SET(GNOME 1)
|
||||
|
||||
IF (WIN32)
|
||||
IF (MINGW)
|
||||
SET (HAVE_SCANF_LLD 1)
|
||||
@ -169,10 +167,6 @@ IF (WITH_GNUCASH)
|
||||
ADD_SUBDIRECTORY(report)
|
||||
ENDIF (WITH_GNUCASH)
|
||||
|
||||
IF (WITH_CUTECASH)
|
||||
ADD_SUBDIRECTORY (gnc)
|
||||
ENDIF (WITH_CUTECASH)
|
||||
|
||||
SET(src_EXTRA_DIST
|
||||
base-typemaps.i
|
||||
config.h.cmake.in
|
||||
|
@ -507,7 +507,6 @@ load_gnucash_modules()
|
||||
{ "gnucash/report/stylesheets", 0, FALSE },
|
||||
{ "gnucash/report/locale-specific/us", 0, FALSE },
|
||||
{ "gnucash/report/report-gnome", 0, FALSE },
|
||||
{ "gnucash/gtkmm", 0, TRUE },
|
||||
{ "gnucash/python", 0, TRUE },
|
||||
{ "gnucash/plugins/bi_import", 0, TRUE},
|
||||
{ "gnucash/plugins/customer_import", 0, TRUE},
|
||||
|
1
src/gnc/.gitignore
vendored
@ -1 +0,0 @@
|
||||
html
|
@ -1,248 +0,0 @@
|
||||
/*
|
||||
* AccountItemModel.hpp
|
||||
* Copyright (C) 2010 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#include "AccountItemModel.hpp"
|
||||
|
||||
#include "engine/gnc-event.h" // for GNC_EVENT_ITEM_ADDED
|
||||
#include "gncmm/Numeric.hpp"
|
||||
#include <QDebug>
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
AccountTreeModel::AccountTreeModel(Glib::RefPtr<Account> rootaccount, QObject *parent)
|
||||
: QAbstractItemModel(parent)
|
||||
, m_root(rootaccount)
|
||||
{
|
||||
}
|
||||
|
||||
QModelIndex AccountTreeModel::index(int row, int column,
|
||||
const QModelIndex &parent) const
|
||||
{
|
||||
//qDebug() << "index(), " << row << column << parent;
|
||||
if (!hasIndex(row, column, parent))
|
||||
return QModelIndex();
|
||||
|
||||
Glib::RefPtr<Account> parentItem;
|
||||
|
||||
if (!parent.isValid())
|
||||
parentItem = m_root;
|
||||
else
|
||||
parentItem = Glib::wrap(static_cast< ::Account*>(parent.internalPointer()));
|
||||
|
||||
Glib::RefPtr<Account> childItem = parentItem->get_nth_child(row);
|
||||
if (childItem)
|
||||
{
|
||||
//qDebug() << "returning" << childItem.getName();
|
||||
return createIndex(row, column, childItem->gobj());
|
||||
}
|
||||
else
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
QModelIndex AccountTreeModel::parent(const QModelIndex &index) const
|
||||
{
|
||||
//qDebug() << "parent()" << index;
|
||||
if (!index.isValid())
|
||||
return QModelIndex();
|
||||
|
||||
Glib::RefPtr<Account> childItem = Glib::wrap(static_cast< ::Account*>(index.internalPointer()));
|
||||
Glib::RefPtr<Account> parentItem(childItem->get_parent());
|
||||
|
||||
if (parentItem->gobj() == m_root->gobj())
|
||||
return QModelIndex();
|
||||
|
||||
return createIndex(parentItem->child_index(), 0, parentItem->gobj());
|
||||
}
|
||||
|
||||
int AccountTreeModel::rowCount(const QModelIndex& parent) const
|
||||
{
|
||||
//qDebug() << "rowCount()" << parent;
|
||||
if (parent.column() > 0)
|
||||
return 0;
|
||||
// FIXME: Doesn't this just mean the nonzero columns don't have a
|
||||
// tree? In that case it would be correct.
|
||||
|
||||
Glib::RefPtr<Account> parentItem;
|
||||
if (!parent.isValid())
|
||||
parentItem = m_root;
|
||||
else
|
||||
parentItem = Glib::wrap(static_cast< ::Account*>(parent.internalPointer()));
|
||||
|
||||
//qDebug() << "Returning " << parentItem.n_children();
|
||||
return parentItem->get_num_children();
|
||||
}
|
||||
|
||||
int AccountTreeModel::columnCount(const QModelIndex& parent) const
|
||||
{
|
||||
//qDebug() << "columnCount()" << parent;
|
||||
// if (!parent.isValid())
|
||||
// return 0;
|
||||
// else
|
||||
return 4; // Fixed number for now
|
||||
}
|
||||
|
||||
QVariant AccountTreeModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
//qDebug() << "data(), " << index;
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
Glib::RefPtr<Account> account = Glib::wrap(static_cast< ::Account*>(index.internalPointer()));
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case 0:
|
||||
return g2q(account->get_name());
|
||||
case 1:
|
||||
return g2q(account->get_code());
|
||||
case 2:
|
||||
return g2q(account->get_description());
|
||||
case 3:
|
||||
{
|
||||
Numeric balance = gnc_ui_account_get_balance(account->gobj(), false);
|
||||
PrintAmountInfo printInfo(account, true);
|
||||
return g2q(balance.printAmount(printInfo));
|
||||
}
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
else
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
Qt::ItemFlags AccountTreeModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
//qDebug() << "flags()" << index;
|
||||
if (!index.isValid())
|
||||
return 0;
|
||||
|
||||
// Ensure read-only access only
|
||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||
}
|
||||
|
||||
QVariant AccountTreeModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
//qDebug() << "headerData()" << section;
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
if (orientation == Qt::Horizontal)
|
||||
{
|
||||
switch (section)
|
||||
{
|
||||
case 0:
|
||||
return QString("Name");
|
||||
case 1:
|
||||
return QString("Code");
|
||||
case 2:
|
||||
return QString("Description");
|
||||
case 3:
|
||||
return QString("Balance");
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
else
|
||||
return QString("%1").arg(1 + section);
|
||||
}
|
||||
|
||||
// ////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
AccountListModel::AccountListModel(Glib::RefPtr<Account> rootaccount, QObject *parent)
|
||||
: base_class(rootaccount, parent)
|
||||
, m_list()
|
||||
, m_eventWrapperAccount(*this, &AccountListModel::accountEvent)
|
||||
{
|
||||
recreateCache();
|
||||
}
|
||||
|
||||
void AccountListModel::recreateCache()
|
||||
{
|
||||
m_list = accountFromGList(m_root->get_descendants());
|
||||
reset();
|
||||
}
|
||||
|
||||
void AccountListModel::accountEvent( ::Account* acc, QofEventId event_type)
|
||||
{
|
||||
//qDebug() << "AccountListModel::accountEvent, id=" << qofEventToString(event_type);
|
||||
|
||||
switch (event_type)
|
||||
{
|
||||
case QOF_EVENT_CREATE:
|
||||
case QOF_EVENT_DESTROY:
|
||||
recreateCache();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QModelIndex AccountListModel::index(int row, int column,
|
||||
const QModelIndex &parent) const
|
||||
{
|
||||
//qDebug() << "index(), " << row << column << parent;
|
||||
if (!hasIndex(row, column, parent) || row >= m_list.size())
|
||||
return QModelIndex();
|
||||
|
||||
Glib::RefPtr<Account> childItem = Glib::wrap(m_list.at(row));
|
||||
if (childItem)
|
||||
{
|
||||
//qDebug() << "returning" << childItem.getName();
|
||||
return createIndex(row, column, childItem->gobj());
|
||||
}
|
||||
else
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
|
||||
// ////////////////////////////////////////////////////////////
|
||||
|
||||
int AccountListNamesModel::columnCount(const QModelIndex& parent) const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
QVariant AccountListNamesModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
Glib::RefPtr<Account> account = Glib::wrap(static_cast< ::Account*>(index.internalPointer()));
|
||||
switch (index.column())
|
||||
{
|
||||
case 0:
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
return g2q(account->get_full_name());
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
|
||||
} // END namespace gnc
|
@ -1,122 +0,0 @@
|
||||
/*
|
||||
* AccountItemModel.hpp
|
||||
* Copyright (C) 2010 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#ifndef GNC_ACCOUNTITEMMODEL_HPP
|
||||
#define GNC_ACCOUNTITEMMODEL_HPP
|
||||
|
||||
#include "config.h"
|
||||
#include "gncmm/Account.hpp"
|
||||
#include "gnc/QofEventWrapper.hpp"
|
||||
#include "gnc/conv.hpp"
|
||||
#include "gnc/metatype.hpp"
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
/** This is the data model for an account tree.
|
||||
*
|
||||
* It was written following the "Simple Tree Model Example" in the qt4
|
||||
* documentation. In particular, the trick is that each returned
|
||||
* QModelIndex of our model implementation which is valid will have a
|
||||
* ::Account* pointer in its QModelIndex::internalPointer() member,
|
||||
* which can then be used in the data() method and the other
|
||||
* methods. This trick works quite nice because our C structures
|
||||
* ::Account* already have all the methods to iterate the tree back
|
||||
* and forth, and our C++ wrapper gnc::Account doesn't add any
|
||||
* functionality except for some nicer method names.
|
||||
*/
|
||||
class AccountTreeModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AccountTreeModel(Glib::RefPtr<Account> rootaccount, QObject *parent = 0);
|
||||
|
||||
int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
||||
int columnCount(const QModelIndex& parent = QModelIndex()) const;
|
||||
QModelIndex parent(const QModelIndex &index) const;
|
||||
QModelIndex index(int row, int column,
|
||||
const QModelIndex &parent = QModelIndex()) const;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
|
||||
QVariant data(const QModelIndex& index, int role) const;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
||||
|
||||
protected:
|
||||
Glib::RefPtr<Account> m_root;
|
||||
};
|
||||
|
||||
typedef QList< ::Account*> AccountQList;
|
||||
inline AccountQList accountFromGList(GList *glist)
|
||||
{
|
||||
return from_glist<AccountQList>(glist);
|
||||
}
|
||||
|
||||
/** Specialization of the account tree model for when all accounts
|
||||
* should be viewed as a flat list instead of a tree. Only the index()
|
||||
* and parent() functions had to be overridden - quite easy. */
|
||||
class AccountListModel : public AccountTreeModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
typedef AccountTreeModel base_class;
|
||||
AccountListModel(Glib::RefPtr<Account> rootaccount, QObject *parent = 0);
|
||||
|
||||
int rowCount(const QModelIndex& parent = QModelIndex()) const { return m_list.size(); }
|
||||
|
||||
QModelIndex index(int row, int column,
|
||||
const QModelIndex &parent = QModelIndex()) const;
|
||||
|
||||
QModelIndex parent(const QModelIndex &index) const { return QModelIndex(); }
|
||||
|
||||
int indexOf(AccountQList::value_type value) const { return m_list.indexOf(value); }
|
||||
const AccountQList::value_type at(int i) const { return m_list.at(i); }
|
||||
|
||||
public Q_SLOTS:
|
||||
void accountEvent( ::Account* v, QofEventId event_type);
|
||||
|
||||
private:
|
||||
void recreateCache();
|
||||
|
||||
AccountQList m_list;
|
||||
QofEventWrapper<AccountListModel, ::Account*> m_eventWrapperAccount;
|
||||
};
|
||||
|
||||
/** Specialization of the account list model that only shows the
|
||||
* "Account Full Name" in one single column.
|
||||
*/
|
||||
class AccountListNamesModel : public AccountListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
typedef AccountListModel base_class;
|
||||
AccountListNamesModel(Glib::RefPtr<Account> rootaccount, QObject *parent = 0)
|
||||
: base_class(rootaccount, parent)
|
||||
{}
|
||||
int columnCount(const QModelIndex& parent = QModelIndex()) const;
|
||||
QVariant data(const QModelIndex& index, int role) const;
|
||||
};
|
||||
|
||||
} // END namespace gnc
|
||||
|
||||
#endif
|
@ -1,122 +0,0 @@
|
||||
/*
|
||||
* AccountSelectionDelegate.cpp
|
||||
* Copyright (C) 2010 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#include "AccountSelectionDelegate.hpp"
|
||||
|
||||
#include "gnc/AccountItemModel.hpp"
|
||||
#include "gncmm/Book.hpp"
|
||||
#include "gncmm/Split.hpp"
|
||||
#include "gnc/SplitListModel.hpp"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QComboBox>
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
AccountSelectionDelegate::AccountSelectionDelegate(QObject* parent)
|
||||
: base_class(parent)
|
||||
{}
|
||||
|
||||
QString AccountSelectionDelegate::displayText(const QVariant& value, const QLocale& locale) const
|
||||
{
|
||||
if (value.canConvert< ::Account*>())
|
||||
{
|
||||
Glib::RefPtr<Account> acc = Glib::wrap(value.value< ::Account*>());
|
||||
if (acc)
|
||||
return g2q(acc->get_full_name());
|
||||
else
|
||||
return QString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return base_class::displayText(value, locale);
|
||||
}
|
||||
}
|
||||
|
||||
QWidget *AccountSelectionDelegate::createEditor(QWidget *parent,
|
||||
const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const
|
||||
{
|
||||
QComboBox* comboBox = new QComboBox(parent);
|
||||
|
||||
Q_ASSERT(index.isValid());
|
||||
const SplitListModel* smodel = dynamic_cast<const SplitListModel*>(index.model());
|
||||
if (smodel)
|
||||
{
|
||||
Glib::RefPtr<Account> modelAccount = smodel->getAccount();
|
||||
Q_ASSERT(modelAccount);
|
||||
Glib::RefPtr<Book> book = modelAccount->get_book();
|
||||
Q_ASSERT(book);
|
||||
Glib::RefPtr<Account> rootaccount = book->get_root_account();
|
||||
Q_ASSERT(rootaccount);
|
||||
AccountListModel* model = new AccountListNamesModel(rootaccount, comboBox);
|
||||
comboBox->setModel(model);
|
||||
}
|
||||
|
||||
return comboBox;
|
||||
}
|
||||
|
||||
void AccountSelectionDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
|
||||
{
|
||||
QComboBox* comboBox = dynamic_cast<QComboBox*>(editor);
|
||||
Q_ASSERT(comboBox);
|
||||
|
||||
Q_ASSERT(index.isValid());
|
||||
|
||||
QVariant value = index.model()->data(index, Qt::EditRole);
|
||||
if (value.canConvert< ::Account*>())
|
||||
{
|
||||
Glib::RefPtr<Account> acc = Glib::wrap(value.value< ::Account*>());
|
||||
if (acc)
|
||||
{
|
||||
const AccountListModel* amodel = dynamic_cast<const AccountListModel*>(comboBox->model());
|
||||
Q_ASSERT(amodel);
|
||||
comboBox->setCurrentIndex(amodel->indexOf(acc->gobj()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "AccountSelectionDelegate::setEditorData: oops, item returns no account in the column";
|
||||
}
|
||||
}
|
||||
|
||||
void AccountSelectionDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
|
||||
const QModelIndex &index) const
|
||||
{
|
||||
QComboBox* comboBox = dynamic_cast<QComboBox*>(editor);
|
||||
Q_ASSERT(comboBox);
|
||||
|
||||
int currentIndex = comboBox->currentIndex();
|
||||
if (currentIndex == -1)
|
||||
return;
|
||||
const AccountListModel* amodel = dynamic_cast<const AccountListModel*>(comboBox->model());
|
||||
Q_ASSERT(amodel);
|
||||
::Account* acc(amodel->at(currentIndex));
|
||||
if (acc)
|
||||
{
|
||||
model->setData(index, QVariant::fromValue(acc), Qt::EditRole);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // END namespace gnc
|
@ -1,55 +0,0 @@
|
||||
/*
|
||||
* AccountSelectionDelegate.hpp
|
||||
* Copyright (C) 2010 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#ifndef GNC_ACCOUNTSELECTIONDELEGATE_HPP
|
||||
#define GNC_ACCOUNTSELECTIONDELEGATE_HPP
|
||||
|
||||
#include "config.h"
|
||||
#include "gncmm/Account.hpp"
|
||||
|
||||
#include <QtGui/QStyledItemDelegate>
|
||||
#include <QDebug>
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
class AccountSelectionDelegate : public QStyledItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
typedef QStyledItemDelegate base_class;
|
||||
|
||||
AccountSelectionDelegate(QObject* parent = 0);
|
||||
|
||||
virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const;
|
||||
virtual QString displayText(const QVariant& value, const QLocale& locale) const;
|
||||
virtual void setEditorData(QWidget *editor, const QModelIndex &index) const;
|
||||
virtual void setModelData(QWidget *editor, QAbstractItemModel *model,
|
||||
const QModelIndex &index) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // END namespace gnc
|
||||
|
||||
#endif
|
@ -1,133 +0,0 @@
|
||||
# CMakeLists.txt for src/gnc
|
||||
|
||||
|
||||
# A test executable
|
||||
LINK_DIRECTORIES (${GLIB2_LIBRARY_DIRS}
|
||||
${GMODULE_LIBRARY_DIRS}
|
||||
${GOBJECT_LIBRARY_DIRS}
|
||||
${GTHREAD_LIBRARY_DIRS}
|
||||
${GCONF2_LIBRARY_DIRS}
|
||||
${GLIBMM_LIBRARY_DIRS}
|
||||
# ${GWENHYWFAR_LIBRARY_DIRS}
|
||||
# ${AQBANKING_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
SET (gnc_SOURCES
|
||||
AccountItemModel.cpp
|
||||
AccountSelectionDelegate.cpp
|
||||
Cmd.cpp
|
||||
QofEventWrapper.cpp
|
||||
RecentFileMenu.cpp
|
||||
Session.cpp
|
||||
SplitListModel.cpp
|
||||
SplitListView.cpp
|
||||
main.cpp
|
||||
mainwindow.cpp
|
||||
mainwindow-file.cpp
|
||||
dashboard.cpp
|
||||
fpo/FPO.cpp
|
||||
fpo/ViewletModel.cpp
|
||||
fpo/ViewletView.cpp
|
||||
)
|
||||
|
||||
SET (gnc_QOBJECT_HEADERS
|
||||
AccountItemModel.hpp
|
||||
AccountSelectionDelegate.hpp
|
||||
RecentFileMenu.hpp
|
||||
SplitListModel.hpp
|
||||
SplitListView.hpp
|
||||
mainwindow.hpp
|
||||
dashboard.hpp
|
||||
fpo/FPO.hpp
|
||||
fpo/ViewletModel.hpp
|
||||
fpo/ViewletView.hpp
|
||||
)
|
||||
SET (gnc_HEADERS ${gnc_QOBJECT_HEADERS}
|
||||
conv.hpp
|
||||
metatype.hpp
|
||||
Cmd.hpp
|
||||
QofEventWrapper.hpp
|
||||
Session.hpp
|
||||
WeakPointer.hpp
|
||||
)
|
||||
|
||||
SET (gnc_FORMS
|
||||
mainwindow.ui
|
||||
dashboard.ui
|
||||
)
|
||||
|
||||
SET (gnc_RESOURCES
|
||||
gnucash.qrc
|
||||
gtk-icons.qrc
|
||||
fallback-icons.qrc
|
||||
stylesheets.qrc
|
||||
)
|
||||
|
||||
IF (WITH_SQL)
|
||||
ADD_DEFINITIONS (-DWITH_SQL)
|
||||
ENDIF (WITH_SQL)
|
||||
|
||||
# Generation of resource files
|
||||
QT4_ADD_RESOURCES (gnc_RESOURCE ${gnc_RESOURCES})
|
||||
|
||||
# Generation of the foo_MOC_SRCS = moc_Class1.cxx moc_Class2.cxx
|
||||
QT4_WRAP_CPP (gnc_MOC_SOURCES ${gnc_QOBJECT_HEADERS})
|
||||
|
||||
# Generation of the ui source files
|
||||
QT4_WRAP_UI (gnc_FORMS_HEADERS ${gnc_FORMS})
|
||||
|
||||
INCLUDE_DIRECTORIES (${GLIB2_INCLUDE_DIRS})
|
||||
INCLUDE_DIRECTORIES (${GLIBMM_INCLUDE_DIRS})
|
||||
INCLUDE_DIRECTORIES (${GUILE_INCLUDE_DIRS})
|
||||
INCLUDE_DIRECTORIES (${LIBINTL_INCLUDE_PATH})
|
||||
INCLUDE_DIRECTORIES (${REGEX_INCLUDE_PATH})
|
||||
INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/src ) # for config.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src ) # for gnc-ui.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/gnc-module) # for gnc-glib-utils.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/core-utils) # for gnc-glib-utils.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/engine) # for gnc-glib-utils.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/optional/gtkmm)
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/backend/xml)
|
||||
INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/src/engine) # for swig-runtime.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_CURRENT_BINARY_DIR}) # for ui_mainwindow.h
|
||||
|
||||
INCLUDE_DIRECTORIES (${QT_INCLUDES})
|
||||
ADD_DEFINITIONS(-DQT_NO_KEYWORDS)
|
||||
|
||||
ADD_EXECUTABLE (cutecash
|
||||
${gnc_FORMS_HEADERS}
|
||||
${gnc_HEADERS}
|
||||
${gnc_MOC_SOURCES}
|
||||
${gnc_RESOURCE}
|
||||
${gnc_SOURCES}
|
||||
)
|
||||
|
||||
TARGET_LINK_LIBRARIES (cutecash gncmod-backend-xml-utils gnc-backend-xml-utils)
|
||||
TARGET_LINK_LIBRARIES (cutecash gncmod-generic-import)
|
||||
TARGET_LINK_LIBRARIES (cutecash gncmod-app-utils)
|
||||
IF (WITH_SQL)
|
||||
TARGET_LINK_LIBRARIES (cutecash gncmod-backend-dbi gnc-backend-sql)
|
||||
TARGET_LINK_LIBRARIES (cutecash ${LIBDBI_LIBRARY})
|
||||
ENDIF (WITH_SQL)
|
||||
IF (WITH_AQBANKING)
|
||||
TARGET_LINK_LIBRARIES (cutecash gncmod-aqbanking)
|
||||
# TARGET_LINK_LIBRARIES (cutecash ${AQBANKING_LIBRARIES} ${GWENHYWFAR_LIBRARIES})
|
||||
ENDIF (WITH_AQBANKING)
|
||||
TARGET_LINK_LIBRARIES (cutecash libgncmod-gtkmm)
|
||||
TARGET_LINK_LIBRARIES (cutecash gncmod-engine gnc-module gnc-core-utils)
|
||||
|
||||
TARGET_LINK_LIBRARIES (cutecash ${GUILE_LIBRARY} ${GUILE_LIBRARIES})
|
||||
TARGET_LINK_LIBRARIES (cutecash ${GLIBMM_LIBRARIES})
|
||||
TARGET_LINK_LIBRARIES (cutecash ${GCONF2_LIBRARIES})
|
||||
TARGET_LINK_LIBRARIES (cutecash ${GTHREAD_LIBRARIES} ${GOBJECT_LIBRARIES} ${GMODULE_LIBRARIES} ${GLIB2_LIBRARIES})
|
||||
TARGET_LINK_LIBRARIES (cutecash ${LIBXML2_LIBRARIES})
|
||||
TARGET_LINK_LIBRARIES (cutecash ${ZLIB_LIBRARIES})
|
||||
IF (WIN32)
|
||||
TARGET_LINK_LIBRARIES (cutecash ${LIBINTL_LIBRARY} ${REGEX_LIBRARY})
|
||||
ENDIF (WIN32)
|
||||
|
||||
TARGET_LINK_LIBRARIES (cutecash ${Boost_LIBRARIES})
|
||||
TARGET_LINK_LIBRARIES (cutecash ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
|
||||
TARGET_LINK_LIBRARIES (cutecash pthread)
|
||||
|
||||
INSTALL (TARGETS cutecash RUNTIME DESTINATION bin)
|
478
src/gnc/Cmd.cpp
@ -1,478 +0,0 @@
|
||||
/*
|
||||
* Cmd.hpp
|
||||
* Copyright (C) 2010 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#include "Cmd.hpp"
|
||||
#include "gncmm/Split.hpp"
|
||||
#include "gncmm/Account.hpp"
|
||||
#include "gncmm/Transaction.hpp"
|
||||
#include "gnc/conv.hpp"
|
||||
#include <QObject>
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
// Explicit instantiations to check for compiler errors
|
||||
template class Cmd<Account, QString>;
|
||||
|
||||
namespace cmd
|
||||
{
|
||||
|
||||
// ////////////////////////////////////////////////////////////
|
||||
|
||||
QUndoCommand* setSplitMemo(Glib::RefPtr<Split> t, const QString& newValue)
|
||||
{
|
||||
return new Cmd<Split, Glib::ustring>(QObject::tr("Edit Split Memo"),
|
||||
t, &Split::set_memo,
|
||||
t->get_memo(), q2g(newValue));
|
||||
}
|
||||
|
||||
QUndoCommand* setSplitAction(Glib::RefPtr<Split> t, const QString& newValue)
|
||||
{
|
||||
return new Cmd<Split, Glib::ustring>(QObject::tr("Edit Split Action"),
|
||||
t, &Split::set_action,
|
||||
t->get_action(), q2g(newValue));
|
||||
}
|
||||
|
||||
QUndoCommand* setSplitReconcile(Glib::RefPtr<Split> t, char newValue)
|
||||
{
|
||||
if (newValue == t->get_reconcile())
|
||||
return NULL;
|
||||
// Special third argument: The setter function takes a value
|
||||
// directly, instead of a const-reference, so the template type
|
||||
// must be given explicitly.
|
||||
return new Cmd<Split, char, void (Split::*)(char)>(QObject::tr("Edit Split Reconcile"),
|
||||
t, &Split::set_reconcile,
|
||||
t->get_reconcile(), newValue);
|
||||
}
|
||||
|
||||
QUndoCommand* setSplitAccount(Glib::RefPtr<Split> t, Glib::RefPtr<Account> newValue)
|
||||
{
|
||||
// Temporary function pointer "tmp" to resolve the ambiguous
|
||||
// overload "setAccount()".
|
||||
void (Split::*tmp)(Glib::RefPtr<Account>) = &Split::set_account;
|
||||
return new Cmd<Split, Glib::RefPtr<Account>, void (Split::*)(Glib::RefPtr<Account>)>(QObject::tr("Edit Split Account"),
|
||||
t, tmp,
|
||||
t->get_account(), newValue);
|
||||
}
|
||||
|
||||
QUndoCommand* setSplitAmount(Glib::RefPtr<Split> t, const Numeric& newValue)
|
||||
{
|
||||
return new Cmd<Split, Numeric>(QObject::tr("Edit Split Amount"),
|
||||
t, &Split::set_amount,
|
||||
t->get_amount(), newValue);
|
||||
}
|
||||
|
||||
QUndoCommand* setSplitValue(Glib::RefPtr<Split> t, const Numeric& newValue)
|
||||
{
|
||||
return new Cmd<Split, Numeric>(QObject::tr("Edit Split Value"),
|
||||
t, &Split::set_value,
|
||||
t->get_value(), newValue);
|
||||
}
|
||||
|
||||
// ////////////////////////////////////////////////////////////
|
||||
|
||||
class SplitValueAndAmountCmd : public QUndoCommand
|
||||
{
|
||||
public:
|
||||
typedef QUndoCommand base_class;
|
||||
typedef Split target_type;
|
||||
typedef Numeric value_type;
|
||||
|
||||
/** Constructor without a getter-function but instead the previous
|
||||
* value given directly.
|
||||
*/
|
||||
SplitValueAndAmountCmd(const QString& text,
|
||||
Glib::RefPtr<Split> targetPtr,
|
||||
const value_type& previousValue,
|
||||
const value_type& newValue,
|
||||
QUndoCommand *parent = 0)
|
||||
: base_class(text, parent)
|
||||
, m_target(targetPtr)
|
||||
, m_previousValue(previousValue)
|
||||
, m_newValue(newValue)
|
||||
{
|
||||
Q_ASSERT(m_target);
|
||||
}
|
||||
|
||||
virtual void redo()
|
||||
{
|
||||
set(m_newValue);
|
||||
}
|
||||
virtual void undo()
|
||||
{
|
||||
set(m_previousValue);
|
||||
}
|
||||
private:
|
||||
void set(const value_type& value)
|
||||
{
|
||||
Glib::RefPtr<Transaction> trans = m_target->get_parent();
|
||||
if (!trans || trans->get_num_splits() != 2)
|
||||
return;
|
||||
Glib::RefPtr<Split> other = m_target->get_other_split();
|
||||
Q_ASSERT(other);
|
||||
Glib::RefPtr<Commodity> originCommodity = m_target->get_account()->get_commodity();
|
||||
Glib::RefPtr<Commodity> transCommodity = trans->get_currency();
|
||||
Glib::RefPtr<Commodity> otherCommodity = other->get_account()->get_commodity();
|
||||
if (originCommodity != transCommodity
|
||||
|| transCommodity != otherCommodity)
|
||||
return;
|
||||
|
||||
trans->begin_edit();
|
||||
m_target->set_value(value);
|
||||
m_target->set_amount(value);
|
||||
Numeric valueNeg = value.neg();
|
||||
other->set_amount(valueNeg);
|
||||
other->set_value(valueNeg);
|
||||
trans->commit_edit();
|
||||
}
|
||||
|
||||
protected:
|
||||
Glib::RefPtr<target_type> m_target;
|
||||
value_type m_previousValue;
|
||||
value_type m_newValue;
|
||||
|
||||
};
|
||||
|
||||
QUndoCommand* setSplitValueAndAmount(Glib::RefPtr<Split> t, const Numeric& newValue)
|
||||
{
|
||||
return new SplitValueAndAmountCmd(QObject::tr("Edit Transaction Value"),
|
||||
t, t->get_value(), newValue);
|
||||
}
|
||||
|
||||
// ////////////////////////////////////////////////////////////
|
||||
|
||||
QUndoCommand* setTransactionNum(Glib::RefPtr<Transaction> t, const QString& newValue)
|
||||
{
|
||||
if (newValue == g2q(t->get_num()))
|
||||
return NULL;
|
||||
return new Cmd<Transaction, Glib::ustring>(QObject::tr("Edit Transaction Number"),
|
||||
t, &Transaction::set_num,
|
||||
t->get_num(), q2g(newValue));
|
||||
}
|
||||
|
||||
QUndoCommand* setTransactionDescription(Glib::RefPtr<Transaction> t, const QString& newValue)
|
||||
{
|
||||
if (newValue == g2q(t->get_description()))
|
||||
return NULL;
|
||||
return new Cmd<Transaction, Glib::ustring>(QObject::tr("Edit Transaction Description"),
|
||||
t, &Transaction::set_description,
|
||||
t->get_description(), q2g(newValue));
|
||||
}
|
||||
|
||||
QUndoCommand* setTransactionNotes(Glib::RefPtr<Transaction> t, const QString& newValue)
|
||||
{
|
||||
return new Cmd<Transaction, Glib::ustring>(QObject::tr("Edit Transaction Notes"),
|
||||
t, &Transaction::set_notes,
|
||||
t->get_notes(), q2g(newValue));
|
||||
}
|
||||
|
||||
QUndoCommand* setTransactionDate(Glib::RefPtr<Transaction> t, const QDate& newValue)
|
||||
{
|
||||
if (newValue == g2q(t->get_date_posted()))
|
||||
return NULL;
|
||||
return new Cmd<Transaction, Glib::Date>(QObject::tr("Edit Transaction Date"),
|
||||
t, &Transaction::set_date_posted,
|
||||
t->get_date_posted(), q2g(newValue));
|
||||
}
|
||||
|
||||
// ////////////////////////////////////////////////////////////
|
||||
|
||||
class TransactionDestroyCmd : public QUndoCommand
|
||||
{
|
||||
public:
|
||||
typedef QUndoCommand base_class;
|
||||
typedef Transaction target_type;
|
||||
|
||||
/** Constructor
|
||||
*/
|
||||
TransactionDestroyCmd(const QString& text,
|
||||
Glib::RefPtr<target_type>& targetPtr,
|
||||
QUndoCommand *parent = 0)
|
||||
: base_class(text, parent)
|
||||
, m_target(targetPtr)
|
||||
, m_previousValue(*targetPtr.operator->())
|
||||
, m_book(m_target->get_book())
|
||||
{
|
||||
Q_ASSERT(m_target);
|
||||
}
|
||||
|
||||
virtual void redo()
|
||||
{
|
||||
xaccTransDestroy(m_target->gobj());
|
||||
m_target.reset();
|
||||
}
|
||||
|
||||
virtual void undo()
|
||||
{
|
||||
m_target = Glib::wrap(Transaction::new_instance(m_book));
|
||||
m_target->begin_edit();
|
||||
m_previousValue.copy_to(m_target);
|
||||
m_target->commit_edit();
|
||||
// Could also use m_previousValue.createAsReal()
|
||||
}
|
||||
|
||||
protected:
|
||||
Glib::RefPtr<Transaction> m_target;
|
||||
TmpTransaction m_previousValue;
|
||||
Glib::RefPtr<Book> m_book;
|
||||
};
|
||||
|
||||
QUndoCommand* destroyTransaction(Glib::RefPtr<Transaction> t)
|
||||
{
|
||||
return new TransactionDestroyCmd(QObject::tr("Delete Transaction"),
|
||||
t);
|
||||
}
|
||||
|
||||
// ////////////////////////////////////////////////////////////
|
||||
|
||||
/** This is another templated implementation of a QUndoCommand
|
||||
* class, this time with keeping a direct reference to the target object.
|
||||
*
|
||||
* This implements the Command pattern: Any instance of this
|
||||
* class represents the change of one member variable (of type ValueT)
|
||||
* in an instance of a TargetT object.
|
||||
*
|
||||
* As we need to keep a reference to the original object, it is
|
||||
* relevant who owns the life cycle of that original object. For
|
||||
* simplicity, we constrain this current implementation only to
|
||||
* classes which are implementations of a WeakPointer<...> which by
|
||||
* definition keeps a C pointer to the original object, and we hope
|
||||
* that one lives longer than we do.
|
||||
*/
|
||||
template < class TargetT, class ValueT, typename SetterFunc = void (TargetT::*)(const ValueT&) >
|
||||
class CmdRef : public QUndoCommand
|
||||
{
|
||||
public:
|
||||
/// The base class
|
||||
typedef QUndoCommand base_class;
|
||||
|
||||
/// Type of the target object on which this command is applied
|
||||
typedef TargetT target_type;
|
||||
|
||||
/// Type of the value that is set by this command
|
||||
typedef ValueT value_type;
|
||||
|
||||
/// Type of the setter function to set the value in the target object
|
||||
typedef SetterFunc setter_func;
|
||||
|
||||
/** Constructor with the previous value given directly.
|
||||
*
|
||||
* @param text The QUndoCommand's text which will be displayed in the Undo action.
|
||||
* @param targetRef Reference to the target object on which this command is applied.
|
||||
* @param setter Pointer to function which sets the value in the target object
|
||||
* @param previousValue The previous value, in case this command needs to be undone
|
||||
* @param newValue The new value to be set
|
||||
* @param parent The parent QUndoCommand instance, or NULL.
|
||||
*/
|
||||
CmdRef(const QString& text,
|
||||
TargetT& targetRef,
|
||||
setter_func setter,
|
||||
const value_type& previousValue,
|
||||
const value_type& newValue,
|
||||
QUndoCommand *parent = 0)
|
||||
: base_class(text, parent)
|
||||
, m_target(targetRef)
|
||||
, m_setter(setter)
|
||||
, m_previousValue(previousValue)
|
||||
, m_newValue(newValue)
|
||||
{
|
||||
Q_ASSERT(m_setter);
|
||||
}
|
||||
|
||||
virtual void redo()
|
||||
{
|
||||
set(m_newValue);
|
||||
}
|
||||
virtual void undo()
|
||||
{
|
||||
set(m_previousValue);
|
||||
}
|
||||
|
||||
private:
|
||||
void set(const value_type& value)
|
||||
{
|
||||
// Call the pointer-to-member which is stored in m_setter.
|
||||
(m_target.*m_setter)(value);
|
||||
}
|
||||
|
||||
protected:
|
||||
target_type& m_target;
|
||||
setter_func m_setter;
|
||||
value_type m_previousValue;
|
||||
value_type m_newValue;
|
||||
};
|
||||
|
||||
|
||||
QUndoCommand* setSplitAccount(TmpSplit& t, Glib::RefPtr<Account> newValue)
|
||||
{
|
||||
return new CmdRef<TmpSplit, ::Account*, void(TmpSplit::*)(::Account*)>(QObject::tr("Edit Split Account"),
|
||||
t, &TmpSplit::set_account,
|
||||
t.get_account(), newValue->gobj());
|
||||
}
|
||||
QUndoCommand* setSplitReconcile(TmpSplit& t, char newValue)
|
||||
{
|
||||
// Special third argument: The setter function takes a value
|
||||
// directly, instead of a const-reference, so the template type
|
||||
// must be given explicitly.
|
||||
return new CmdRef<TmpSplit, char, void (TmpSplit::*)(char)>(QObject::tr("Edit Split Reconcile"),
|
||||
t, &TmpSplit::set_reconcile,
|
||||
t.get_reconcile(), newValue);
|
||||
}
|
||||
QUndoCommand* setTransactionNum(TmpTransaction& t, const QString& newValue)
|
||||
{
|
||||
return new CmdRef<TmpTransaction, Glib::ustring>(QObject::tr("Edit Transaction Number"),
|
||||
t, &TmpTransaction::set_num,
|
||||
t.get_num(), q2g(newValue));
|
||||
}
|
||||
QUndoCommand* setTransactionDescription(TmpTransaction& t, const QString& newValue)
|
||||
{
|
||||
return new CmdRef<TmpTransaction, Glib::ustring>(QObject::tr("Edit Transaction Description"),
|
||||
t, &TmpTransaction::set_description,
|
||||
t.get_description(), q2g(newValue));
|
||||
}
|
||||
QUndoCommand* setTransactionDate(TmpTransaction& t, const QDate& newValue)
|
||||
{
|
||||
return new CmdRef<TmpTransaction, Glib::Date>(QObject::tr("Edit Transaction Date"),
|
||||
t, &TmpTransaction::set_date_posted,
|
||||
t.get_date_posted(), q2g(newValue));
|
||||
}
|
||||
|
||||
// ////////////////////////////////////////////////////////////
|
||||
|
||||
class TmpSplitValueAndAmountCmd : public QUndoCommand
|
||||
{
|
||||
public:
|
||||
typedef QUndoCommand base_class;
|
||||
typedef TmpSplit target_type;
|
||||
typedef Numeric value_type;
|
||||
|
||||
/** Constructor without a getter-function but instead the previous
|
||||
* value given directly.
|
||||
*/
|
||||
TmpSplitValueAndAmountCmd(const QString& text,
|
||||
target_type& targetRef,
|
||||
const value_type& previousValue,
|
||||
const value_type& newValue,
|
||||
QUndoCommand *parent = 0)
|
||||
: base_class(text, parent)
|
||||
, m_target(targetRef)
|
||||
, m_previousValue(previousValue)
|
||||
, m_newValue(newValue)
|
||||
{
|
||||
Q_ASSERT(m_target.get_parent());
|
||||
Q_ASSERT(m_target.get_other_split());
|
||||
Q_ASSERT(m_target.get_account());
|
||||
}
|
||||
|
||||
virtual void redo()
|
||||
{
|
||||
set(m_newValue);
|
||||
}
|
||||
virtual void undo()
|
||||
{
|
||||
set(m_previousValue);
|
||||
}
|
||||
private:
|
||||
void set(const value_type& value)
|
||||
{
|
||||
Q_ASSERT(m_target.get_parent());
|
||||
const TmpTransaction& trans = *m_target.get_parent();
|
||||
if (trans.get_num_splits() != 2)
|
||||
return;
|
||||
TmpSplit* p_other = m_target.get_other_split();
|
||||
Q_ASSERT(p_other);
|
||||
TmpSplit& other = *p_other;
|
||||
Glib::RefPtr<Commodity> originCommodity = Glib::wrap(m_target.get_account())->get_commodity();
|
||||
Glib::RefPtr<Commodity> transCommodity = trans.get_commodity();
|
||||
Q_ASSERT(other.get_account());
|
||||
Glib::RefPtr<Commodity> otherCommodity = Glib::wrap(other.get_account())->get_commodity();
|
||||
if (originCommodity != transCommodity
|
||||
|| transCommodity != otherCommodity)
|
||||
return;
|
||||
|
||||
m_target.set_value(value);
|
||||
m_target.set_amount(value);
|
||||
Numeric valueNeg = value.neg();
|
||||
other.set_amount(valueNeg);
|
||||
other.set_value(valueNeg);
|
||||
}
|
||||
|
||||
protected:
|
||||
target_type& m_target;
|
||||
value_type m_previousValue;
|
||||
value_type m_newValue;
|
||||
|
||||
};
|
||||
|
||||
|
||||
QUndoCommand* setSplitValueAndAmount(TmpSplit& t, const Numeric& newValue)
|
||||
{
|
||||
return new TmpSplitValueAndAmountCmd(QObject::tr("Edit Transaction Value"),
|
||||
t, t.get_value(), newValue);
|
||||
}
|
||||
|
||||
// ////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
class TransactionCreateCmd : public QUndoCommand
|
||||
{
|
||||
public:
|
||||
typedef QUndoCommand base_class;
|
||||
|
||||
/** Constructor
|
||||
*/
|
||||
TransactionCreateCmd(const QString& text,
|
||||
const TmpTransaction& target,
|
||||
QUndoCommand *parent = 0)
|
||||
: base_class(text, parent)
|
||||
, m_template(target)
|
||||
, m_created(NULL)
|
||||
{}
|
||||
|
||||
virtual void redo()
|
||||
{
|
||||
m_created = m_template.create_as_real();
|
||||
}
|
||||
|
||||
virtual void undo()
|
||||
{
|
||||
xaccTransDestroy(m_created->gobj());
|
||||
m_created.reset();
|
||||
}
|
||||
|
||||
protected:
|
||||
TmpTransaction m_template;
|
||||
Glib::RefPtr<Transaction> m_created;
|
||||
};
|
||||
|
||||
QUndoCommand* commitNewTransaction(const TmpTransaction& t)
|
||||
{
|
||||
return new TransactionCreateCmd(QObject::tr("Create Transaction"), t);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // END namespace cmd
|
||||
|
||||
|
||||
} // END namespace gnc
|
162
src/gnc/Cmd.hpp
@ -1,162 +0,0 @@
|
||||
/*
|
||||
* Cmd.hpp
|
||||
* Copyright (C) 2010 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#ifndef GNC_CMD_HPP
|
||||
#define GNC_CMD_HPP
|
||||
|
||||
#include <QUndoCommand>
|
||||
#include <QDate>
|
||||
#include <gnc/WeakPointer.hpp>
|
||||
#include <gncmm/Numeric.hpp>
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
class Account;
|
||||
class Split;
|
||||
class TmpSplit;
|
||||
class TmpTransaction;
|
||||
class Transaction;
|
||||
|
||||
/** This is a templated implementation of a QUndoCommand class. This
|
||||
* implements the Command pattern: Any instance of this class
|
||||
* represents the change of one member variable (of type ValueT) in an
|
||||
* instance of a TargetT object.
|
||||
*
|
||||
* The fun part is that we can pass pointers to the getter and setter
|
||||
* functions into this class' constructor, and the redo()/undo()
|
||||
* implementations follow naturally. Hence, this class is already
|
||||
* sufficient for any Command that is executed by a particular Setter
|
||||
* function.
|
||||
*
|
||||
* As we need to keep a reference to the original object, it is
|
||||
* relevant who owns the life cycle of that original object. For
|
||||
* simplicity, we constrain this current implementation only to
|
||||
* classes which are implementations of a WeakPointer<...> which by
|
||||
* definition keeps a C pointer to the original object, and we hope
|
||||
* that one lives longer than we do.
|
||||
*/
|
||||
template<class TargetT, class ValueT, typename SetterFunc = void (TargetT::*)(const ValueT&)>
|
||||
class Cmd : public QUndoCommand
|
||||
{
|
||||
public:
|
||||
/// The base class
|
||||
typedef QUndoCommand base_class;
|
||||
|
||||
/// Type of the target object on which this command is applied
|
||||
typedef TargetT target_type;
|
||||
|
||||
/// Type of the value that is set by this command
|
||||
typedef ValueT value_type;
|
||||
|
||||
/// Type of the setter function to set the value in the target object
|
||||
typedef SetterFunc setter_func;
|
||||
|
||||
/// Type of the getter function to retrieve the current value from the target object
|
||||
typedef value_type (target_type::*getter_func)() const;
|
||||
|
||||
/** Constructor with the to-be-manipulated object "targetPtr", the setter
|
||||
* function, the previous value, and the new value.
|
||||
*
|
||||
* @param text The QUndoCommand's text which will be displayed in the Undo action.
|
||||
* @param targetPtr Reference to the target object on which this command is applied.
|
||||
* @param setter Pointer to function which sets the value in the target object
|
||||
* @param previousValue The previous value, in case this command needs to be undone
|
||||
* @param newValue The new value to be set
|
||||
* @param parent The parent QUndoCommand instance, or NULL.
|
||||
*/
|
||||
Cmd(const QString& text,
|
||||
Glib::RefPtr<target_type> targetPtr,
|
||||
setter_func setter,
|
||||
const value_type& previousValue,
|
||||
const value_type& newValue,
|
||||
QUndoCommand *parent = 0)
|
||||
: base_class(text, parent)
|
||||
, m_target(targetPtr)
|
||||
, m_setter(setter)
|
||||
, m_previousValue(previousValue)
|
||||
, m_newValue(newValue)
|
||||
{
|
||||
Q_ASSERT(m_target);
|
||||
Q_ASSERT(m_setter);
|
||||
}
|
||||
|
||||
virtual void redo()
|
||||
{
|
||||
set(m_newValue);
|
||||
}
|
||||
|
||||
virtual void undo()
|
||||
{
|
||||
set(m_previousValue);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
void set(const value_type& value)
|
||||
{
|
||||
// Uh oh. The calling syntax for pointer-to-member
|
||||
// variables (here: m_setter) looks rather weird:
|
||||
(m_target.operator->()->*m_setter)(value);
|
||||
}
|
||||
|
||||
protected:
|
||||
Glib::RefPtr<target_type> m_target;
|
||||
setter_func m_setter;
|
||||
value_type m_previousValue;
|
||||
value_type m_newValue;
|
||||
|
||||
};
|
||||
|
||||
namespace cmd
|
||||
{
|
||||
|
||||
// This is the collection of command objects which are already
|
||||
// provided for the different data types and their simple
|
||||
// members. Just create one of those, add it to a QUndoStack, and
|
||||
// magically the values will change with undo/redo back and
|
||||
// forth. Spooky, IMHO.
|
||||
// QUndoCommand* setSplitMemo(Split& split, const QString& newValue);
|
||||
// QUndoCommand* setSplitAction(Split& t, const QString& newValue);
|
||||
QUndoCommand* setSplitAccount(Glib::RefPtr<Split> t, Glib::RefPtr<Account> newValue);
|
||||
QUndoCommand* setSplitAccount(TmpSplit& t, Glib::RefPtr<Account> newValue);
|
||||
QUndoCommand* setSplitReconcile(Glib::RefPtr<Split> t, char newValue);
|
||||
QUndoCommand* setSplitReconcile(TmpSplit& t, char newValue);
|
||||
// QUndoCommand* setSplitAmount(Glib::RefPtr<Split> t, const Numeric& newValue);
|
||||
// QUndoCommand* setSplitValue(Glib::RefPtr<Split> t, const Numeric& newValue);
|
||||
QUndoCommand* setTransactionNum(Glib::RefPtr<Transaction> t, const QString& newValue);
|
||||
QUndoCommand* setTransactionNum(TmpTransaction& t, const QString& newValue);
|
||||
QUndoCommand* setTransactionDescription(Glib::RefPtr<Transaction> t, const QString& newValue);
|
||||
QUndoCommand* setTransactionDescription(TmpTransaction& t, const QString& newValue);
|
||||
// QUndoCommand* setTransactionNotes(Glib::RefPtr<Transaction> t, const QString& newValue);
|
||||
QUndoCommand* setTransactionDate(Glib::RefPtr<Transaction> t, const QDate& newValue);
|
||||
QUndoCommand* setTransactionDate(TmpTransaction& t, const QDate& newValue);
|
||||
QUndoCommand* setSplitValueAndAmount(Glib::RefPtr<Split> t, const Numeric& newValue);
|
||||
QUndoCommand* setSplitValueAndAmount(TmpSplit& t, const Numeric& newValue);
|
||||
QUndoCommand* destroyTransaction(Glib::RefPtr<Transaction> t);
|
||||
QUndoCommand* commitNewTransaction(const TmpTransaction& t);
|
||||
|
||||
} // END namespace cmd
|
||||
|
||||
} // END namespace gnc
|
||||
|
||||
#endif
|
228
src/gnc/Doxyfile
@ -1,228 +0,0 @@
|
||||
# Doxyfile 1.5.5
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
DOXYFILE_ENCODING = UTF-8
|
||||
PROJECT_NAME = Cutecash
|
||||
PROJECT_NUMBER = 0.1.0
|
||||
OUTPUT_DIRECTORY =
|
||||
CREATE_SUBDIRS = NO
|
||||
OUTPUT_LANGUAGE = English
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
REPEAT_BRIEF = YES
|
||||
ABBREVIATE_BRIEF = "The $name class " \
|
||||
"The $name widget " \
|
||||
"The $name file " \
|
||||
is \
|
||||
provides \
|
||||
specifies \
|
||||
contains \
|
||||
represents \
|
||||
a \
|
||||
an \
|
||||
the
|
||||
ALWAYS_DETAILED_SEC = NO
|
||||
INLINE_INHERITED_MEMB = NO
|
||||
FULL_PATH_NAMES = NO
|
||||
STRIP_FROM_PATH =
|
||||
STRIP_FROM_INC_PATH =
|
||||
SHORT_NAMES = NO
|
||||
JAVADOC_AUTOBRIEF = NO
|
||||
QT_AUTOBRIEF = NO
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
INHERIT_DOCS = YES
|
||||
SEPARATE_MEMBER_PAGES = NO
|
||||
TAB_SIZE = 4
|
||||
ALIASES =
|
||||
OPTIMIZE_OUTPUT_FOR_C = NO
|
||||
OPTIMIZE_OUTPUT_JAVA = NO
|
||||
OPTIMIZE_FOR_FORTRAN = NO
|
||||
OPTIMIZE_OUTPUT_VHDL = NO
|
||||
BUILTIN_STL_SUPPORT = YES
|
||||
CPP_CLI_SUPPORT = NO
|
||||
SIP_SUPPORT = NO
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
SUBGROUPING = YES
|
||||
TYPEDEF_HIDES_STRUCT = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# Build related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
EXTRACT_ALL = YES
|
||||
EXTRACT_PRIVATE = YES
|
||||
EXTRACT_STATIC = YES
|
||||
EXTRACT_LOCAL_CLASSES = YES
|
||||
EXTRACT_LOCAL_METHODS = NO
|
||||
EXTRACT_ANON_NSPACES = NO
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
HIDE_FRIEND_COMPOUNDS = NO
|
||||
HIDE_IN_BODY_DOCS = NO
|
||||
INTERNAL_DOCS = NO
|
||||
CASE_SENSE_NAMES = NO
|
||||
HIDE_SCOPE_NAMES = NO
|
||||
SHOW_INCLUDE_FILES = YES
|
||||
INLINE_INFO = YES
|
||||
SORT_MEMBER_DOCS = YES
|
||||
SORT_BRIEF_DOCS = NO
|
||||
SORT_GROUP_NAMES = NO
|
||||
SORT_BY_SCOPE_NAME = NO
|
||||
GENERATE_TODOLIST = YES
|
||||
GENERATE_TESTLIST = YES
|
||||
GENERATE_BUGLIST = YES
|
||||
GENERATE_DEPRECATEDLIST= YES
|
||||
ENABLED_SECTIONS =
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
SHOW_USED_FILES = YES
|
||||
SHOW_DIRECTORIES = YES
|
||||
FILE_VERSION_FILTER =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to warning and progress messages
|
||||
#---------------------------------------------------------------------------
|
||||
QUIET = YES
|
||||
WARNINGS = YES
|
||||
WARN_IF_UNDOCUMENTED = YES
|
||||
WARN_IF_DOC_ERROR = YES
|
||||
WARN_NO_PARAMDOC = NO
|
||||
WARN_FORMAT = "$file:$line: $text "
|
||||
WARN_LOGFILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the input files
|
||||
#---------------------------------------------------------------------------
|
||||
INPUT = . \
|
||||
../core-utils \
|
||||
../gnc-module \
|
||||
../engine \
|
||||
../app-utils
|
||||
INPUT_ENCODING = UTF-8
|
||||
FILE_PATTERNS = *.cpp \
|
||||
*.hpp \
|
||||
*.h
|
||||
RECURSIVE = NO
|
||||
EXCLUDE =
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
EXCLUDE_PATTERNS = test-*.c
|
||||
EXCLUDE_SYMBOLS =
|
||||
EXAMPLE_PATH =
|
||||
EXAMPLE_PATTERNS = *
|
||||
EXAMPLE_RECURSIVE = NO
|
||||
IMAGE_PATH =
|
||||
INPUT_FILTER =
|
||||
FILTER_PATTERNS =
|
||||
FILTER_SOURCE_FILES = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to source browsing
|
||||
#---------------------------------------------------------------------------
|
||||
SOURCE_BROWSER = NO
|
||||
INLINE_SOURCES = NO
|
||||
STRIP_CODE_COMMENTS = YES
|
||||
REFERENCED_BY_RELATION = NO
|
||||
REFERENCES_RELATION = NO
|
||||
REFERENCES_LINK_SOURCE = YES
|
||||
USE_HTAGS = NO
|
||||
VERBATIM_HEADERS = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the alphabetical class index
|
||||
#---------------------------------------------------------------------------
|
||||
ALPHABETICAL_INDEX = YES
|
||||
COLS_IN_ALPHA_INDEX = 4
|
||||
IGNORE_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the HTML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_HTML = YES
|
||||
HTML_OUTPUT = html
|
||||
HTML_FILE_EXTENSION = .html
|
||||
HTML_HEADER =
|
||||
HTML_FOOTER =
|
||||
HTML_STYLESHEET =
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
GENERATE_HTMLHELP = NO
|
||||
GENERATE_DOCSET = NO
|
||||
DOCSET_FEEDNAME = "Doxygen generated docs"
|
||||
DOCSET_BUNDLE_ID = org.doxygen.Project
|
||||
HTML_DYNAMIC_SECTIONS = NO
|
||||
CHM_FILE =
|
||||
HHC_LOCATION =
|
||||
GENERATE_CHI = NO
|
||||
BINARY_TOC = NO
|
||||
TOC_EXPAND = NO
|
||||
DISABLE_INDEX = NO
|
||||
ENUM_VALUES_PER_LINE = 4
|
||||
GENERATE_TREEVIEW = YES
|
||||
TREEVIEW_WIDTH = 250
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the LaTeX output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_LATEX = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the RTF output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_RTF = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the man page output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_MAN = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the XML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_XML = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options for the AutoGen Definitions output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_AUTOGEN_DEF = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the Perl module output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_PERLMOD = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the preprocessor
|
||||
#---------------------------------------------------------------------------
|
||||
ENABLE_PREPROCESSING = YES
|
||||
MACRO_EXPANSION = NO
|
||||
EXPAND_ONLY_PREDEF = NO
|
||||
SEARCH_INCLUDES = YES
|
||||
INCLUDE_PATH =
|
||||
INCLUDE_FILE_PATTERNS =
|
||||
PREDEFINED = DOXYGEN_IGNORE
|
||||
EXPAND_AS_DEFINED =
|
||||
SKIP_FUNCTION_MACROS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::additions related to external references
|
||||
#---------------------------------------------------------------------------
|
||||
TAGFILES =
|
||||
GENERATE_TAGFILE =
|
||||
ALLEXTERNALS = NO
|
||||
EXTERNAL_GROUPS = YES
|
||||
PERL_PATH = /usr/bin/perl
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the dot tool
|
||||
#---------------------------------------------------------------------------
|
||||
CLASS_DIAGRAMS = YES
|
||||
MSCGEN_PATH =
|
||||
HIDE_UNDOC_RELATIONS = YES
|
||||
HAVE_DOT = YES
|
||||
CLASS_GRAPH = YES
|
||||
COLLABORATION_GRAPH = NO
|
||||
GROUP_GRAPHS = YES
|
||||
UML_LOOK = NO
|
||||
TEMPLATE_RELATIONS = NO
|
||||
INCLUDE_GRAPH = NO
|
||||
INCLUDED_BY_GRAPH = NO
|
||||
CALL_GRAPH = NO
|
||||
CALLER_GRAPH = NO
|
||||
GRAPHICAL_HIERARCHY = YES
|
||||
DIRECTORY_GRAPH = YES
|
||||
DOT_IMAGE_FORMAT = png
|
||||
DOT_PATH =
|
||||
DOTFILE_DIRS =
|
||||
DOT_GRAPH_MAX_NODES = 50
|
||||
MAX_DOT_GRAPH_DEPTH = 1000
|
||||
DOT_TRANSPARENT = NO
|
||||
DOT_MULTI_TARGETS = NO
|
||||
GENERATE_LEGEND = YES
|
||||
DOT_CLEANUP = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::additions related to the search engine
|
||||
#---------------------------------------------------------------------------
|
||||
SEARCHENGINE = NO
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* QofEventWrapper.cpp
|
||||
* Copyright (C) 2010 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#include "QofEventWrapper.hpp"
|
||||
#include "engine/gnc-event.h"
|
||||
|
||||
#include "gnc/SplitListModel.hpp"
|
||||
#include "gncmm/Transaction.hpp"
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
// Explicit instantiation to check for compiler errors
|
||||
template class QofEventWrapper<SplitListModel, ::Transaction*>;
|
||||
|
||||
#define EVENT_TO_STR(result, input, evtype) \
|
||||
if ((input) & (evtype)) result += QString(result.isEmpty() ? "" : ",") + #evtype
|
||||
|
||||
QString qofEventToString(QofEventId event_type)
|
||||
{
|
||||
if (event_type == QOF_EVENT_NONE)
|
||||
return "NONE";
|
||||
QString r;
|
||||
EVENT_TO_STR(r, event_type, QOF_EVENT_CREATE);
|
||||
EVENT_TO_STR(r, event_type, QOF_EVENT_MODIFY);
|
||||
EVENT_TO_STR(r, event_type, QOF_EVENT_DESTROY);
|
||||
EVENT_TO_STR(r, event_type, QOF_EVENT_ADD);
|
||||
EVENT_TO_STR(r, event_type, QOF_EVENT_REMOVE);
|
||||
|
||||
EVENT_TO_STR(r, event_type, GNC_EVENT_ITEM_ADDED);
|
||||
EVENT_TO_STR(r, event_type, GNC_EVENT_ITEM_REMOVED);
|
||||
EVENT_TO_STR(r, event_type, GNC_EVENT_ITEM_CHANGED);
|
||||
|
||||
if (r.isEmpty())
|
||||
r = QString::number(event_type);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
} // END namespace gnc
|
@ -1,157 +0,0 @@
|
||||
/*
|
||||
* QofEventWrapper.hpp
|
||||
* Copyright (C) 2010 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#ifndef GNC_QOFEVENTWRAPPER_HPP
|
||||
#define GNC_QOFEVENTWRAPPER_HPP
|
||||
|
||||
// gnucash includes
|
||||
#include "config.h" // required by qof/qofutil.h
|
||||
#include "engine/guid.hpp"
|
||||
extern "C"
|
||||
{
|
||||
#include "qof.h"
|
||||
#include "engine/gnc-engine.h"
|
||||
#include "engine/Account.h"
|
||||
#include "engine/Transaction.h"
|
||||
#include "engine/gnc-commodity.h"
|
||||
}
|
||||
|
||||
#include <QString>
|
||||
#include <QDebug>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
/** Conversion of the event_type to string (for debugging) */
|
||||
QString qofEventToString(QofEventId event_type);
|
||||
|
||||
/** Retrieval of the Qof instance class name (for debugging) */
|
||||
inline const char* getQofType( ::QofInstance* obj)
|
||||
{
|
||||
return obj->e_type;
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template<class ValuePtrT> inline const char* getQofTypeT()
|
||||
{
|
||||
Q_ASSERT(false);
|
||||
// This would need a BOOST_STATIC_ASSERT(sizeof(T)==0) to
|
||||
// trigger a compile-time warning in case this function is
|
||||
// erroneously instantiated.
|
||||
// This template must not be instantiated. Instead, for each
|
||||
// templated usage there must exist a specialization which
|
||||
// will return the correct QOF_ID string!
|
||||
throw std::runtime_error("Should not have been instantiated");
|
||||
}
|
||||
template<> inline const char* getQofTypeT< ::Transaction*>()
|
||||
{
|
||||
return GNC_ID_TRANS;
|
||||
}
|
||||
template<> inline const char* getQofTypeT< ::Account*>()
|
||||
{
|
||||
return GNC_ID_ACCOUNT;
|
||||
}
|
||||
template<> inline const char* getQofTypeT< ::QofBook*>()
|
||||
{
|
||||
return QOF_ID_BOOK;
|
||||
}
|
||||
template<> inline const char* getQofTypeT< ::QofSession*>()
|
||||
{
|
||||
return QOF_ID_SESSION;
|
||||
}
|
||||
template<> inline const char* getQofTypeT< ::gnc_commodity*>()
|
||||
{
|
||||
return GNC_ID_COMMODITY;
|
||||
}
|
||||
template<> inline const char* getQofTypeT< ::Split*>()
|
||||
{
|
||||
return GNC_ID_SPLIT;
|
||||
}
|
||||
}
|
||||
|
||||
/** Template wrapper class for objects which want to receive
|
||||
* notifications from the qof_event system in any of their member
|
||||
* functions.
|
||||
*
|
||||
* The receiver's class is the first template argument; the argument
|
||||
* type of the to-be-called member function is the second template
|
||||
* (usually a pointer type). */
|
||||
template<class ReceiverT, class ValuePtrT, typename SlotFunc = void (ReceiverT::*)(ValuePtrT, QofEventId)>
|
||||
class QofEventWrapper
|
||||
{
|
||||
public:
|
||||
QofEventWrapper(ReceiverT& receiver,
|
||||
SlotFunc recvSlot)
|
||||
: m_receiver(receiver)
|
||||
, m_receiveFunc(recvSlot)
|
||||
, m_qof_type(gnc::detail::getQofTypeT<ValuePtrT>())
|
||||
{
|
||||
m_handler_id = qof_event_register_handler(QofEventWrapper::event_handler, this);
|
||||
}
|
||||
|
||||
~QofEventWrapper()
|
||||
{
|
||||
qof_event_unregister_handler(m_handler_id);
|
||||
}
|
||||
|
||||
static void event_handler (::QofInstance *entity, QofEventId event_type,
|
||||
gpointer user_data, gpointer event_data)
|
||||
{
|
||||
QofEventWrapper* wrapper = static_cast<QofEventWrapper *>(user_data);
|
||||
wrapper->private_event_handler(entity, event_type, event_data);
|
||||
}
|
||||
|
||||
private:
|
||||
void private_event_handler (::QofInstance *entity, QofEventId event_type,
|
||||
gpointer event_data)
|
||||
{
|
||||
// qDebug() << "private_event_handler, id=" << qofEventToString(event_type)
|
||||
// << "entity=" << getQofType(entity);
|
||||
|
||||
// Verify that we have the correct QofInstance type and also
|
||||
// correct event type
|
||||
if (!QOF_CHECK_TYPE(entity, m_qof_type))
|
||||
return;
|
||||
// if ((event_type & m_event_type) == 0)
|
||||
// return;
|
||||
|
||||
// qDebug() << "private_event_handler, id=" << qofEventToString(event_type)
|
||||
// << "entity=" << getQofType(entity);
|
||||
|
||||
ValuePtrT vptr = reinterpret_cast<ValuePtrT>(entity);
|
||||
|
||||
// Call the pointer-to-member function with that weird C++
|
||||
// syntax
|
||||
(m_receiver.*m_receiveFunc)(vptr, event_type);
|
||||
}
|
||||
|
||||
ReceiverT& m_receiver;
|
||||
SlotFunc m_receiveFunc;
|
||||
const char* m_qof_type;
|
||||
gint m_handler_id;
|
||||
};
|
||||
|
||||
} // END namespace gnc
|
||||
|
||||
#endif
|
@ -1,155 +0,0 @@
|
||||
/*
|
||||
* RecentFileMenu.hpp
|
||||
* Copyright (C) 2010 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
|
||||
#include "RecentFileMenu.hpp"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QAction>
|
||||
#include <QSettings>
|
||||
#include <QFileInfo>
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
RecentFileMenu::RecentFileMenu(const QString& title, QWidget *parent)
|
||||
: QMenu(title, parent)
|
||||
{
|
||||
createActions();
|
||||
}
|
||||
|
||||
|
||||
RecentFileMenu::~RecentFileMenu()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void RecentFileMenu::createActions()
|
||||
{
|
||||
for (int i = 0; i < MaxRecentFiles; ++i)
|
||||
{
|
||||
QAction *newAct = new QAction(this);
|
||||
newAct->setVisible(false);
|
||||
connect(newAct, SIGNAL(triggered()),
|
||||
this, SLOT(on_actionRecentFile()));
|
||||
addAction(newAct);
|
||||
|
||||
m_actionRecentFile[i] = newAct;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RecentFileMenu::usingFile(const QString& filename)
|
||||
{
|
||||
if (filename.isEmpty())
|
||||
return;
|
||||
|
||||
m_fileNames.removeAll(filename);
|
||||
while (m_fileNames.size() > MaxRecentFiles - 1)
|
||||
// remove last allowed position
|
||||
m_fileNames.removeAt(MaxRecentFiles - 1);
|
||||
m_fileNames.insert(0, filename);
|
||||
updateMenu();
|
||||
}
|
||||
|
||||
|
||||
void RecentFileMenu::updateMenu()
|
||||
{
|
||||
setEnabled(!m_fileNames.isEmpty());
|
||||
for (int i = 0; i < std::min(int(MaxRecentFiles), m_fileNames.size()); ++i)
|
||||
{
|
||||
const QString& qs = m_fileNames.at(i);
|
||||
QAction *act = m_actionRecentFile[i];
|
||||
act->setVisible(true);
|
||||
act->setText(tr("&%1 %2").arg(i + 1).arg(QFileInfo(qs).fileName()));
|
||||
act->setStatusTip(qs);
|
||||
act->setData(qs);
|
||||
}
|
||||
for (int i = m_fileNames.size(); i < MaxRecentFiles; ++i)
|
||||
{
|
||||
QAction *act = m_actionRecentFile[i];
|
||||
act->setVisible(false);
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
void RecentFileMenu::readSettings(QSettings *settings, const QString &groupName)
|
||||
{
|
||||
int size = settings->beginReadArray(groupName);
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
settings->setArrayIndex(i);
|
||||
QString qs = settings->value("filename").toString();
|
||||
if (!qs.isEmpty())
|
||||
{
|
||||
m_fileNames << qs;
|
||||
}
|
||||
}
|
||||
settings->endArray();
|
||||
updateMenu();
|
||||
}
|
||||
|
||||
QString RecentFileMenu::getRecentFileName(QSettings *settings,
|
||||
const QString &groupName)
|
||||
{
|
||||
settings->beginReadArray(groupName);
|
||||
settings->setArrayIndex(0);
|
||||
QString qs = settings->value("filename").toString();
|
||||
settings->endArray();
|
||||
return qs;
|
||||
}
|
||||
|
||||
void RecentFileMenu::writeSettings(QSettings *settings, const QString &groupName)
|
||||
{
|
||||
settings->remove(groupName);
|
||||
settings->beginWriteArray(groupName);
|
||||
|
||||
int numElements = m_fileNames.size();
|
||||
int j = 0;
|
||||
for (int i = 0; i < numElements; i++)
|
||||
{
|
||||
QString qs = m_fileNames.at(i);
|
||||
if (!qs.isEmpty())
|
||||
{
|
||||
settings->setArrayIndex(j++);
|
||||
settings->setValue("filename", qs);
|
||||
}
|
||||
}
|
||||
|
||||
settings->endArray();
|
||||
}
|
||||
|
||||
|
||||
void RecentFileMenu::on_actionRecentFile()
|
||||
{
|
||||
QAction *action = qobject_cast<QAction *>(sender());
|
||||
if (action)
|
||||
{
|
||||
QString str = action->data().toString();
|
||||
if (!str.isEmpty())
|
||||
Q_EMIT fileSelected(str);
|
||||
}
|
||||
}
|
||||
|
||||
} // END namespace gnc
|
@ -1,94 +0,0 @@
|
||||
/*
|
||||
* RecentFileMenu.hpp
|
||||
* Copyright (C) 2010 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#ifndef GNC_RECENTFILEMENU_HPP
|
||||
#define GNC_RECENTFILEMENU_HPP
|
||||
|
||||
#include <QtGui/QMenu>
|
||||
#include <QtCore/QStringList>
|
||||
|
||||
class QAction;
|
||||
class QSettings;
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
/**
|
||||
* A menu that shows a list of recently opened files.
|
||||
*/
|
||||
class RecentFileMenu: public QMenu
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RecentFileMenu(const QString& title, QWidget *parent = 0);
|
||||
~RecentFileMenu();
|
||||
|
||||
/**
|
||||
* Read the internal list from a QSettings array.
|
||||
* @param settings QSettings to read from
|
||||
* @param groupName name of the array for QSettings::beginReadArray().
|
||||
*/
|
||||
void readSettings(QSettings *settings, const QString &groupName);
|
||||
|
||||
QString getRecentFileName(QSettings *settings, const QString &groupName);
|
||||
|
||||
/**
|
||||
* Write the internal list to a QSettings array.
|
||||
* @param settings QSettings to write to
|
||||
* @param groupName name of the array for QSettings::beginWriteArray().
|
||||
*/
|
||||
void writeSettings(QSettings *settings, const QString &groupName);
|
||||
|
||||
public Q_SLOTS:
|
||||
/**
|
||||
* Record the given string as a filename that was (or is)
|
||||
* being used in the application. As a result the given
|
||||
* filename will always become the new first menu entry.
|
||||
*/
|
||||
void usingFile(const QString &fileName);
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* This signal is emitted whenever the user selects a file from the internally managed
|
||||
* menu (i.e. the user wants to open the given file).
|
||||
*/
|
||||
void fileSelected(const QString &fileName);
|
||||
|
||||
private Q_SLOTS:
|
||||
void on_actionRecentFile();
|
||||
|
||||
private:
|
||||
void updateMenu();
|
||||
void createActions();
|
||||
|
||||
private:
|
||||
QStringList m_fileNames;
|
||||
|
||||
enum { MaxRecentFiles = 5 };
|
||||
QAction *m_actionRecentFile[MaxRecentFiles];
|
||||
|
||||
};
|
||||
|
||||
} // END namespace gnc
|
||||
|
||||
#endif
|
@ -1,95 +0,0 @@
|
||||
/*
|
||||
* Session.cpp
|
||||
* Copyright (C) 2010 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "gnc/Session.hpp"
|
||||
#include "gncmm/Book.hpp"
|
||||
|
||||
// Explicit instantiation to check for compiler errors in the template
|
||||
template class gnc::WeakPointer< QofSession >;
|
||||
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
Glib::RefPtr<Book> Session::get_book () const
|
||||
{
|
||||
return Glib::wrap(qof_session_get_book(gobj()));
|
||||
}
|
||||
|
||||
|
||||
#define TYPE_TO_STR(tstr, desc) tstr : return std::make_pair<QString,QString>(QString::fromUtf8(#tstr), QString::fromUtf8(desc))
|
||||
|
||||
std::pair<QString, QString> errorToStringPair(QofBackendError err)
|
||||
{
|
||||
switch (err)
|
||||
{
|
||||
case TYPE_TO_STR(ERR_BACKEND_NO_ERR, "No Error");
|
||||
case TYPE_TO_STR(ERR_BACKEND_NO_HANDLER, "no backend handler found for this access method (ENOSYS)");
|
||||
case TYPE_TO_STR(ERR_BACKEND_NO_BACKEND, "Backend * pointer was unexpectedly null");
|
||||
case TYPE_TO_STR(ERR_BACKEND_BAD_URL, "Can't parse url");
|
||||
case TYPE_TO_STR(ERR_BACKEND_NO_SUCH_DB, "the named database doesn't exist");
|
||||
case TYPE_TO_STR(ERR_BACKEND_CANT_CONNECT, "bad dbname/login/passwd or network failure");
|
||||
case TYPE_TO_STR(ERR_BACKEND_CONN_LOST, "Lost connection to server");
|
||||
case TYPE_TO_STR(ERR_BACKEND_LOCKED, "in use by another user (ETXTBSY)");
|
||||
case TYPE_TO_STR(ERR_BACKEND_READONLY, "cannot write to file/directory");
|
||||
case TYPE_TO_STR(ERR_BACKEND_TOO_NEW, "file/db version newer than what we can read");
|
||||
case TYPE_TO_STR(ERR_BACKEND_DATA_CORRUPT, "data in db is corrupt");
|
||||
case TYPE_TO_STR(ERR_BACKEND_SERVER_ERR, "error in response from server");
|
||||
case TYPE_TO_STR(ERR_BACKEND_ALLOC, "internal memory allocation failure");
|
||||
case TYPE_TO_STR(ERR_BACKEND_PERM, "user login successful, but no permissions to access the desired object");
|
||||
case TYPE_TO_STR(ERR_BACKEND_MODIFIED, "commit of object update failed because another user has modified the object");
|
||||
case TYPE_TO_STR(ERR_BACKEND_MOD_DESTROY, "commit of object update failed because another user has deleted the object");
|
||||
case TYPE_TO_STR(ERR_BACKEND_MISC, "undetermined error");
|
||||
case TYPE_TO_STR(ERR_QOF_OVERFLOW, "EOVERFLOW - generated by strtol or strtoll.");
|
||||
case TYPE_TO_STR(ERR_FILEIO_FILE_BAD_READ, "read failed or file prematurely truncated");
|
||||
case TYPE_TO_STR(ERR_FILEIO_FILE_EMPTY, "file exists, is readable, but is empty");
|
||||
case TYPE_TO_STR(ERR_FILEIO_FILE_LOCKERR, "mangled locks (unspecified error)");
|
||||
case TYPE_TO_STR(ERR_FILEIO_FILE_NOT_FOUND, "not found / no such file");
|
||||
case TYPE_TO_STR(ERR_FILEIO_FILE_TOO_OLD, "file version so old we can't read it");
|
||||
case TYPE_TO_STR(ERR_FILEIO_UNKNOWN_FILE_TYPE, "didn't recognize the file type");
|
||||
case TYPE_TO_STR(ERR_FILEIO_PARSE_ERROR, "couldn't parse the data in the file");
|
||||
case TYPE_TO_STR(ERR_FILEIO_BACKUP_ERROR, "couldn't make a backup of the file");
|
||||
case TYPE_TO_STR(ERR_FILEIO_WRITE_ERROR, "couldn't write to the file");
|
||||
case TYPE_TO_STR(ERR_FILEIO_READ_ERROR, "Could not open the file for reading.");
|
||||
case TYPE_TO_STR(ERR_FILEIO_NO_ENCODING, "file does not specify encoding");
|
||||
case TYPE_TO_STR(ERR_FILEIO_FILE_EACCES, "No read access permission for the given file");
|
||||
case TYPE_TO_STR(ERR_NETIO_SHORT_READ, "not enough bytes received");
|
||||
case TYPE_TO_STR(ERR_NETIO_WRONG_CONTENT_TYPE, "wrong kind of server, wrong data served");
|
||||
case TYPE_TO_STR(ERR_NETIO_NOT_GNCXML, "whatever it is, we can't parse it.");
|
||||
case TYPE_TO_STR(ERR_SQL_MISSING_DATA, "database doesn't contain expected data");
|
||||
case TYPE_TO_STR(ERR_SQL_DB_TOO_OLD, "database is old and needs upgrading");
|
||||
case TYPE_TO_STR(ERR_SQL_DB_BUSY, "database is busy, cannot upgrade version");
|
||||
case TYPE_TO_STR(ERR_RPC_HOST_UNK, "Host unknown");
|
||||
case TYPE_TO_STR(ERR_RPC_CANT_BIND, "can't bind to address");
|
||||
case TYPE_TO_STR(ERR_RPC_CANT_ACCEPT, "can't accept connection");
|
||||
case TYPE_TO_STR(ERR_RPC_NO_CONNECTION, "no connection to server");
|
||||
case TYPE_TO_STR(ERR_RPC_BAD_VERSION, "RPC Version Mismatch");
|
||||
case TYPE_TO_STR(ERR_RPC_FAILED, "Operation failed");
|
||||
case TYPE_TO_STR(ERR_RPC_NOT_ADDED, "object not added");
|
||||
default:
|
||||
assert(0); // must not be reached
|
||||
return std::make_pair("Unknown", "Unknown");
|
||||
}
|
||||
}
|
||||
|
||||
} // END namespace gnc
|
@ -1,109 +0,0 @@
|
||||
/*
|
||||
* Session.hpp
|
||||
* Copyright (C) 2010 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#ifndef GNC_SESSION_HPP
|
||||
#define GNC_SESSION_HPP
|
||||
|
||||
// gnucash includes
|
||||
#include "config.h" // required by qof/qofutil.h
|
||||
#include <glib/gi18n.h>
|
||||
#include "engine/guid.hpp"
|
||||
extern "C"
|
||||
{
|
||||
#include "qof.h"
|
||||
#include "engine/gnc-hooks.h"
|
||||
}
|
||||
|
||||
#include "gnc/WeakPointer.hpp"
|
||||
#include <glibmm/refptr.h>
|
||||
#include <QString>
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
class Book;
|
||||
|
||||
/** Wrapper around a gnucash ::QofSession pointer with C++ methods for
|
||||
* easier setter and getter access.
|
||||
*
|
||||
* Unfortunately this object has no information about whether the
|
||||
* underlying gnucash ::QofSession object is still alive or has been
|
||||
* deleted.
|
||||
*/
|
||||
class Session : public WeakPointer< ::QofSession >
|
||||
{
|
||||
public:
|
||||
typedef WeakPointer< ::QofSession > base_class;
|
||||
|
||||
Session(element_type *ptr = 0)
|
||||
: base_class(ptr)
|
||||
{}
|
||||
|
||||
// Now the actual functions on the object
|
||||
|
||||
void begin(const QString& book_id, bool ignore_lock, bool create_if_nonexistent, bool force)
|
||||
{
|
||||
qof_session_begin(gobj(), book_id.toUtf8(), ignore_lock, create_if_nonexistent, force);
|
||||
}
|
||||
void load (QofPercentageFunc percentage_func)
|
||||
{
|
||||
qof_session_load(gobj(), percentage_func);
|
||||
}
|
||||
QofBackendError get_error ()
|
||||
{
|
||||
return qof_session_get_error(gobj());
|
||||
}
|
||||
QofBackendError pop_error ()
|
||||
{
|
||||
return qof_session_pop_error(gobj());
|
||||
}
|
||||
QString get_error_message() const
|
||||
{
|
||||
return QString::fromUtf8(qof_session_get_error_message(gobj()));
|
||||
}
|
||||
Glib::RefPtr<Book> get_book () const;
|
||||
|
||||
QString get_file_path () const
|
||||
{
|
||||
return QString::fromUtf8(qof_session_get_file_path(gobj()));
|
||||
}
|
||||
|
||||
QString get_url() const
|
||||
{
|
||||
return QString::fromUtf8(qof_session_get_url(gobj()));
|
||||
}
|
||||
|
||||
bool save_in_progress() const
|
||||
{
|
||||
return qof_session_save_in_progress(gobj());
|
||||
}
|
||||
void save (QofPercentageFunc percentage_func)
|
||||
{
|
||||
qof_session_save(gobj(), percentage_func);
|
||||
}
|
||||
};
|
||||
|
||||
std::pair<QString, QString> errorToStringPair(QofBackendError err);
|
||||
|
||||
} // END namespace gnc
|
||||
|
||||
#endif
|
@ -1,756 +0,0 @@
|
||||
/*
|
||||
* SplitListModel.cpp
|
||||
* Copyright (C) 2010 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#include "SplitListModel.hpp"
|
||||
#include "engine/gnc-event.h" // for GNC_EVENT_ITEM_ADDED
|
||||
#include "gncmm/Transaction.hpp"
|
||||
#include "gnc/Cmd.hpp"
|
||||
#include "gnc/Session.hpp"
|
||||
#include "gnc/metatype.hpp"
|
||||
#include <QDebug>
|
||||
#include <QUndoStack>
|
||||
#include <QBrush>
|
||||
#include <QMessageBox>
|
||||
#include <QDateTime>
|
||||
|
||||
#include "app-utils/gnc-ui-util.h" // for gnc_get_reconcile_str
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
|
||||
|
||||
SplitListModel::SplitListModel(const Glib::RefPtr<Account> acc, QUndoStack* undoStack, QObject *parent)
|
||||
: QAbstractItemModel(parent)
|
||||
, m_account(acc)
|
||||
, m_list()
|
||||
, m_undoStack(undoStack)
|
||||
, m_eventWrapper(*this, &SplitListModel::transactionEvent)
|
||||
, m_eventWrapperAccount(*this, &SplitListModel::accountEvent)
|
||||
, m_enableNewTransaction(true)
|
||||
{
|
||||
recreateCache();
|
||||
|
||||
m_tmpTransaction.push_back(TmpSplit(NULL));
|
||||
m_tmpTransaction.push_back(TmpSplit(NULL));
|
||||
recreateTmpTrans();
|
||||
}
|
||||
|
||||
void SplitListModel::recreateCache()
|
||||
{
|
||||
SplitQList newSplits = Split::from_glist(m_account->get_split_list());
|
||||
bool doReset = (newSplits.size() != m_list.size());
|
||||
|
||||
m_list = newSplits;
|
||||
|
||||
// Cache the mapping of transactions to split in the m_hash
|
||||
m_hash.clear();
|
||||
for (int k = 0; k < m_list.size(); ++k)
|
||||
{
|
||||
m_hash.insert(Glib::wrap(m_list[k])->get_parent()->gobj(), k);
|
||||
}
|
||||
|
||||
if (doReset)
|
||||
reset();
|
||||
}
|
||||
|
||||
void SplitListModel::recreateTmpTrans()
|
||||
{
|
||||
m_tmpTransaction.reset_content();
|
||||
while (m_tmpTransaction.get_num_splits() > 2)
|
||||
m_tmpTransaction.get_splits().pop_back();
|
||||
Q_ASSERT(m_tmpTransaction.get_num_splits() == 2);
|
||||
|
||||
m_tmpTransaction.set_commodity(m_account->get_commodity());
|
||||
m_tmpTransaction.set_date_posted(q2g(QDate::currentDate()));
|
||||
TmpSplit& oursplit = m_tmpTransaction.get_splits().front();
|
||||
TmpSplit& othersplit = m_tmpTransaction.get_splits().back();
|
||||
oursplit.set_account(m_account->gobj());
|
||||
|
||||
Q_ASSERT(m_tmpTransaction.get_num_splits() == 2);
|
||||
Q_ASSERT(oursplit.get_account() == m_account->gobj());
|
||||
Q_ASSERT(othersplit.get_account() == NULL);
|
||||
}
|
||||
|
||||
SplitListModel::~SplitListModel()
|
||||
{
|
||||
}
|
||||
|
||||
QModelIndex SplitListModel::index(int row, int column,
|
||||
const QModelIndex &parent) const
|
||||
{
|
||||
//qDebug() << "index(), " << row << column << parent;
|
||||
if (!hasIndex(row, column, parent) || row >= rowCount())
|
||||
return QModelIndex();
|
||||
|
||||
if (m_enableNewTransaction && row == m_list.size())
|
||||
return createIndex(row, column, (void*)NULL);
|
||||
|
||||
Glib::RefPtr<Split> childItem = Glib::wrap(m_list.at(row));
|
||||
if (childItem)
|
||||
{
|
||||
//qDebug() << "returning" << childItem.getName();
|
||||
return createIndex(row, column, childItem->gobj());
|
||||
}
|
||||
else
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
bool SplitListModel::removeRows(int position, int rows, const QModelIndex &index)
|
||||
{
|
||||
for (int row = position; row < position + rows; ++row)
|
||||
{
|
||||
Glib::RefPtr<Split> s = Glib::wrap(m_list.at(row));
|
||||
Q_ASSERT(s);
|
||||
Glib::RefPtr<Transaction> t = s->get_parent();
|
||||
Q_ASSERT(t);
|
||||
QUndoCommand* cmd = cmd::destroyTransaction(t);
|
||||
m_undoStack->push(cmd);
|
||||
}
|
||||
// No beginInsertRows/endInsertRows because reset() is called in
|
||||
// recreateCache() anyway.
|
||||
return true;
|
||||
}
|
||||
|
||||
int SplitListModel::rowCount(const QModelIndex& parent) const
|
||||
{
|
||||
return m_list.size() + (m_enableNewTransaction ? 1 : 0);
|
||||
}
|
||||
|
||||
int SplitListModel::columnCount(const QModelIndex& parent) const
|
||||
{
|
||||
//qDebug() << "columnCount()" << parent;
|
||||
// if (!parent.isValid())
|
||||
// return 0;
|
||||
// else
|
||||
return COLUMN_LAST; // Fixed number for now
|
||||
}
|
||||
|
||||
Qt::ItemFlags SplitListModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
//qDebug() << "flags()" << index;
|
||||
if (!index.isValid())
|
||||
return 0;
|
||||
|
||||
Qt::ItemFlags result = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||
switch (index.column())
|
||||
{
|
||||
case COLUMN_DATE:
|
||||
case COLUMN_NUM:
|
||||
case COLUMN_DESC:
|
||||
case COLUMN_RECONCILE:
|
||||
case COLUMN_INCREASE:
|
||||
case COLUMN_DECREASE:
|
||||
case COLUMN_ACCOUNT:
|
||||
// Allow write access as well
|
||||
return result | Qt::ItemIsEditable;
|
||||
case COLUMN_BALANCE:
|
||||
default:
|
||||
// Ensure read-only access only
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
QVariant SplitListModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
//qDebug() << "data(), " << index;
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
if (m_enableNewTransaction && index.row() == m_list.size())
|
||||
{
|
||||
// Special case: We are in the last row which represents the
|
||||
// newly entered txn.
|
||||
|
||||
const TmpSplit& split(m_tmpTransaction.get_splits().front());
|
||||
const TmpTransaction& trans = m_tmpTransaction;
|
||||
Numeric amount = split.get_value();
|
||||
PrintAmountInfo printInfo(m_account, false);
|
||||
switch (index.column())
|
||||
{
|
||||
case COLUMN_DATE:
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
case Qt::EditRole:
|
||||
return g2q(trans.get_date_posted());
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
case COLUMN_NUM:
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
case Qt::EditRole:
|
||||
return g2q(trans.get_num());
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
case COLUMN_DESC:
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
case Qt::EditRole:
|
||||
return g2q(trans.get_description());
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
case COLUMN_ACCOUNT:
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
case Qt::EditRole:
|
||||
if (trans.get_num_splits() == 2)
|
||||
return QVariant::fromValue(trans.get_splits().back().get_account());
|
||||
else
|
||||
return QVariant(); // FIXME: Multi-split txn here
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
case COLUMN_RECONCILE:
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
case Qt::EditRole:
|
||||
return QString::fromUtf8(gnc_get_reconcile_str(split.get_reconcile()));
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
case COLUMN_INCREASE:
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
case Qt::EditRole:
|
||||
if (!amount.zero_p() && amount.positive_p())
|
||||
return g2q(amount.printAmount(printInfo));
|
||||
else
|
||||
return QString();
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
case COLUMN_DECREASE:
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
case Qt::EditRole:
|
||||
if (amount.zero_p() || amount.positive_p())
|
||||
return QString();
|
||||
else
|
||||
return g2q(amount.neg().printAmount(printInfo));
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
case COLUMN_BALANCE:
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// Normal case: We are in a row that displays a normal
|
||||
// transaction and split
|
||||
|
||||
Glib::RefPtr<Split> split = Glib::wrap(static_cast< ::Split*>(index.internalPointer()));
|
||||
Glib::RefPtr<Transaction> trans(split->get_parent());
|
||||
Numeric amount = split->get_value(); // Alternatively: xaccSplitConvertAmount(split.gobj(), split.getAccount().gobj());
|
||||
PrintAmountInfo printInfo(split, false);
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case COLUMN_DATE:
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
case Qt::EditRole:
|
||||
return g2q(trans->get_date_posted());
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
case COLUMN_NUM:
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
case Qt::EditRole:
|
||||
return g2q(trans->get_num());
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
case COLUMN_DESC:
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
case Qt::EditRole:
|
||||
return g2q(trans->get_description());
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
case COLUMN_ACCOUNT:
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
case Qt::EditRole:
|
||||
if (trans->get_num_splits() == 2)
|
||||
return QVariant::fromValue(split->get_other_split()->get_account()->gobj());
|
||||
else
|
||||
return g2q(split->get_corr_account_full_name());
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
case COLUMN_RECONCILE:
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
case Qt::EditRole:
|
||||
return QString::fromUtf8(gnc_get_reconcile_str(split->get_reconcile()));
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
case COLUMN_INCREASE:
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
case Qt::EditRole:
|
||||
if (amount.positive_p())
|
||||
return g2q(amount.printAmount(printInfo));
|
||||
else
|
||||
return QString();
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
case COLUMN_DECREASE:
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
case Qt::EditRole:
|
||||
if (amount.positive_p())
|
||||
return QString();
|
||||
else
|
||||
return g2q(amount.neg().printAmount(printInfo));
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
case COLUMN_BALANCE:
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
return g2q(split->get_balance().printAmount(printInfo));
|
||||
case Qt::ForegroundRole:
|
||||
return split->get_balance().negative_p()
|
||||
? QBrush(Qt::red)
|
||||
: QBrush();
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QVariant SplitListModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
//qDebug() << "headerData()" << section;
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
if (orientation == Qt::Horizontal)
|
||||
{
|
||||
switch (section)
|
||||
{
|
||||
case COLUMN_DATE:
|
||||
return tr("Date");
|
||||
case COLUMN_NUM:
|
||||
return tr("Num");
|
||||
case COLUMN_DESC:
|
||||
return tr("Description");
|
||||
case COLUMN_ACCOUNT:
|
||||
return tr("Transfer");
|
||||
case COLUMN_RECONCILE:
|
||||
return tr("R?");
|
||||
case COLUMN_INCREASE:
|
||||
return tr("Increase");
|
||||
case COLUMN_DECREASE:
|
||||
return tr("Decrease");
|
||||
case COLUMN_BALANCE:
|
||||
return tr("Balance");
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
else
|
||||
return QString("%1").arg(1 + section);
|
||||
}
|
||||
|
||||
bool SplitListModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
{
|
||||
if (!index.isValid() || role != Qt::EditRole)
|
||||
return false;
|
||||
|
||||
QUndoCommand* cmd = NULL;
|
||||
if (m_enableNewTransaction && index.row() == m_list.size())
|
||||
{
|
||||
// Special case: We are in the last row which represents the
|
||||
// newly entered txn.
|
||||
|
||||
TmpTransaction& trans = m_tmpTransaction;
|
||||
TmpSplit& split = trans.get_splits().front();
|
||||
Q_ASSERT(split.get_account() == m_account->gobj());
|
||||
Q_ASSERT(trans.get_num_splits() == 2);
|
||||
TmpSplit& other = trans.get_splits().back();
|
||||
|
||||
// "Editing" is done by creating a Cmd-object and adding it to
|
||||
// the undo stack. That's in fact all that was needed to
|
||||
// create an *undoable* edit of this data cell. Seems almost
|
||||
// spooky, doesn't it?
|
||||
switch (index.column())
|
||||
{
|
||||
case COLUMN_DATE:
|
||||
{
|
||||
QDate date = value.toDate();
|
||||
if (date.isValid())
|
||||
{
|
||||
cmd = cmd::setTransactionDate(trans, date);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case COLUMN_NUM:
|
||||
cmd = cmd::setTransactionNum(trans, value.toString());
|
||||
break;
|
||||
case COLUMN_DESC:
|
||||
cmd = cmd::setTransactionDescription(trans, value.toString());
|
||||
break;
|
||||
case COLUMN_ACCOUNT:
|
||||
if (value.canConvert< ::Account*>())
|
||||
{
|
||||
if (trans.get_num_splits() == 2)
|
||||
{
|
||||
cmd = cmd::setSplitAccount(other, Glib::wrap(value.value< ::Account*>()));
|
||||
}
|
||||
else
|
||||
QMessageBox::warning(NULL, tr("Unimplemented"),
|
||||
tr("Sorry, but editing a transaction with more than two splits (here: %1) is not yet implemented.").arg(trans.get_num_splits()));
|
||||
}
|
||||
break;
|
||||
case COLUMN_RECONCILE:
|
||||
{
|
||||
QString str(value.toString());
|
||||
if (str.size() > 0)
|
||||
{
|
||||
char recn = str[0].toLatin1();
|
||||
switch (recn)
|
||||
{
|
||||
case NREC:
|
||||
case CREC:
|
||||
case YREC:
|
||||
case FREC:
|
||||
case VREC:
|
||||
cmd = cmd::setSplitReconcile(split, recn);
|
||||
break;
|
||||
default:
|
||||
qDebug() << "Unknown reconcile string:" << str;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case COLUMN_INCREASE:
|
||||
case COLUMN_DECREASE:
|
||||
{
|
||||
QString str(value.toString().simplified());
|
||||
if (str.isEmpty())
|
||||
break;
|
||||
Numeric n;
|
||||
QString errmsg = g2q(n.parse(q2g(str)));
|
||||
if (errmsg.isEmpty())
|
||||
{
|
||||
qDebug() << "Successfully parsed string to numeric=" << g2q(n.to_string());
|
||||
if (index.column() == COLUMN_DECREASE)
|
||||
n = n.neg();
|
||||
// Check whether we have the simple case here
|
||||
if (trans.get_num_splits() != 2)
|
||||
{
|
||||
QMessageBox::warning(NULL, tr("Unimplemented"),
|
||||
tr("Sorry, but editing a transaction with more than two splits (here: %1) is not yet implemented.").arg(trans.get_num_splits()));
|
||||
}
|
||||
else
|
||||
{
|
||||
Glib::RefPtr<Commodity> originCommodity = m_account->get_commodity();
|
||||
Glib::RefPtr<Commodity> transCommodity = trans.get_commodity();
|
||||
bool sameCommodities = (originCommodity == transCommodity);
|
||||
if (other.get_account())
|
||||
{
|
||||
Glib::RefPtr<Commodity> otherCommodity = Glib::wrap(other.get_account())->get_commodity();
|
||||
sameCommodities = sameCommodities && (transCommodity == otherCommodity);
|
||||
}
|
||||
if (!sameCommodities)
|
||||
{
|
||||
QMessageBox::warning(NULL, tr("Unimplemented"),
|
||||
tr("Sorry, but editing a transaction with different accounts is not yet implemented."));
|
||||
}
|
||||
else
|
||||
{
|
||||
// This is the really simple case which we can
|
||||
// handle now.
|
||||
cmd = cmd::setSplitValueAndAmount(split, n);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Cannot convert this string to gnc_numeric:" << str;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Normal case: We are in a row that displays a normal
|
||||
// transaction and split
|
||||
|
||||
Glib::RefPtr<Split> split = Glib::wrap(static_cast< ::Split*>(index.internalPointer()));
|
||||
Glib::RefPtr<Transaction> trans(split->get_parent());
|
||||
QVariant y(trans);
|
||||
|
||||
// "Editing" is done by creating a Cmd-object and adding it to
|
||||
// the undo stack. That's in fact all that was needed to
|
||||
// create an *undoable* edit of this data cell. Seems almost
|
||||
// spooky, doesn't it?
|
||||
switch (index.column())
|
||||
{
|
||||
case COLUMN_DATE:
|
||||
{
|
||||
QDate date = value.toDate();
|
||||
if (date.isValid())
|
||||
{
|
||||
cmd = cmd::setTransactionDate(trans, date);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case COLUMN_NUM:
|
||||
cmd = cmd::setTransactionNum(trans, value.toString());
|
||||
break;
|
||||
case COLUMN_DESC:
|
||||
cmd = cmd::setTransactionDescription(trans, value.toString());
|
||||
break;
|
||||
case COLUMN_ACCOUNT:
|
||||
if (value.canConvert< ::Account*>())
|
||||
{
|
||||
if (trans->get_num_splits() == 2)
|
||||
{
|
||||
Glib::RefPtr<Split> other = split->get_other_split();
|
||||
cmd = cmd::setSplitAccount(other, Glib::wrap(value.value< ::Account*>()));
|
||||
}
|
||||
else
|
||||
QMessageBox::warning(NULL, tr("Unimplemented"),
|
||||
tr("Sorry, but editing a transaction with more than two splits "
|
||||
"(here: %1) is not yet implemented.").arg(trans->get_num_splits()));
|
||||
}
|
||||
break;
|
||||
case COLUMN_RECONCILE:
|
||||
{
|
||||
QString str(value.toString());
|
||||
if (!str.isEmpty())
|
||||
{
|
||||
char recn = str[0].toLatin1();
|
||||
switch (recn)
|
||||
{
|
||||
case NREC:
|
||||
case CREC:
|
||||
case YREC:
|
||||
case FREC:
|
||||
case VREC:
|
||||
cmd = cmd::setSplitReconcile(split, recn);
|
||||
break;
|
||||
default:
|
||||
qDebug() << "Unknown reconcile string:" << str;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case COLUMN_INCREASE:
|
||||
case COLUMN_DECREASE:
|
||||
{
|
||||
QString str(value.toString().simplified());
|
||||
if (str.isEmpty())
|
||||
break;
|
||||
Numeric n;
|
||||
QString errmsg = g2q(n.parse(q2g(str)));
|
||||
if (errmsg.isEmpty())
|
||||
{
|
||||
qDebug() << "Successfully parsed string to numeric=" << g2q(n.to_string());
|
||||
if (index.column() == COLUMN_DECREASE)
|
||||
n = n.neg();
|
||||
// Check whether we have the simple case here
|
||||
if (split->get_parent()->get_num_splits() != 2)
|
||||
{
|
||||
QMessageBox::warning(NULL, tr("Unimplemented"),
|
||||
tr("Sorry, but editing a transaction with more than two splits "
|
||||
"(here: %1) is not yet implemented.").arg(split->get_parent()->get_num_splits()));
|
||||
}
|
||||
else
|
||||
{
|
||||
Glib::RefPtr<Transaction> trans = split->get_parent();
|
||||
Glib::RefPtr<Split> other = split->get_other_split();
|
||||
Q_ASSERT(other);
|
||||
Glib::RefPtr<Commodity> originCommodity = split->get_account()->get_commodity();
|
||||
Glib::RefPtr<Commodity> transCommodity = trans->get_currency();
|
||||
Glib::RefPtr<Commodity> otherCommodity = other->get_account()->get_commodity();
|
||||
if (originCommodity != transCommodity
|
||||
|| transCommodity != otherCommodity)
|
||||
{
|
||||
QMessageBox::warning(NULL, tr("Unimplemented"),
|
||||
tr("Sorry, but editing a transaction with different accounts is not yet implemented."));
|
||||
}
|
||||
else
|
||||
{
|
||||
// This is the really simple case which we can
|
||||
// handle now.
|
||||
cmd = cmd::setSplitValueAndAmount(split, n);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Cannot convert this string to gnc_numeric:" << str;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cmd)
|
||||
{
|
||||
m_undoStack->push(cmd);
|
||||
// No dataChanged() signal here because it is emitted from the
|
||||
// transactionChanged slot.
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void SplitListModel::transactionEvent( ::Transaction* trans, QofEventId event_type)
|
||||
{
|
||||
//qDebug() << "SplitListModel::transactionEvent, id=" << qofEventToString(event_type);
|
||||
switch (event_type)
|
||||
{
|
||||
case QOF_EVENT_MODIFY:
|
||||
if (m_hash.contains(trans))
|
||||
{
|
||||
int row = m_hash.value(trans);
|
||||
Q_EMIT dataChanged(index(row, 0), index(row, columnCount() - 1));
|
||||
}
|
||||
break;
|
||||
case GNC_EVENT_ITEM_REMOVED:
|
||||
case GNC_EVENT_ITEM_ADDED:
|
||||
// This event is triggered by a split being added (or removed)
|
||||
// to a transaction. Ignored because we already reacted upon
|
||||
// the MODIFY event.
|
||||
break;
|
||||
case QOF_EVENT_CREATE:
|
||||
// This event is triggered by a newly created transaction, but
|
||||
// we reacted on this in the accountEvent handler already.
|
||||
break;
|
||||
default:
|
||||
qDebug() << "SplitListModel::transactionEvent, ignored event id=" << qofEventToString(event_type);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SplitListModel::accountEvent( ::Account* acc, QofEventId event_type)
|
||||
{
|
||||
if (acc != m_account->gobj())
|
||||
return;
|
||||
//qDebug() << "SplitListModel::accountEvent, id=" << qofEventToString(event_type);
|
||||
|
||||
switch (event_type)
|
||||
{
|
||||
case GNC_EVENT_ITEM_REMOVED:
|
||||
case GNC_EVENT_ITEM_ADDED:
|
||||
recreateCache();
|
||||
break;
|
||||
case QOF_EVENT_MODIFY:
|
||||
case GNC_EVENT_ITEM_CHANGED:
|
||||
// These events are also triggered e.g. by a newly added
|
||||
// transaction/split in this account. However, we already
|
||||
// reacted on this by the above events, so we can ignore them
|
||||
// here.
|
||||
break;
|
||||
default:
|
||||
qDebug() << "SplitListModel::accountEvent, ignored event id=" << qofEventToString(event_type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SplitListModel::editorClosed(const QModelIndex& index,
|
||||
QAbstractItemDelegate::EndEditHint hint)
|
||||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
if (m_enableNewTransaction && index.row() == m_list.size())
|
||||
{
|
||||
// Special case: The line with the new transaction
|
||||
|
||||
switch (hint)
|
||||
{
|
||||
case QAbstractItemDelegate::SubmitModelCache:
|
||||
switch (index.column())
|
||||
{
|
||||
case COLUMN_DATE:
|
||||
case COLUMN_NUM:
|
||||
case COLUMN_DESC:
|
||||
case COLUMN_ACCOUNT:
|
||||
case COLUMN_RECONCILE:
|
||||
break; // we want to do nothing
|
||||
case COLUMN_INCREASE:
|
||||
case COLUMN_DECREASE:
|
||||
{
|
||||
// Commit the new transaction
|
||||
//qDebug() << "Commit the new transaction as a real one";
|
||||
m_tmpTransaction.set_date_entered(QDateTime::currentDateTime().toTime_t());
|
||||
QUndoCommand* cmd = cmd::commitNewTransaction(m_tmpTransaction);
|
||||
recreateTmpTrans();
|
||||
m_undoStack->push(cmd);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break; // nothing to do
|
||||
}
|
||||
case QAbstractItemDelegate::RevertModelCache:
|
||||
recreateTmpTrans();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// We are in the line of an existing transaction - no function
|
||||
// implemented yet.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // END namespace gnc
|
@ -1,110 +0,0 @@
|
||||
/*
|
||||
* SplitListModel.hpp
|
||||
* Copyright (C) 2010 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#ifndef GNC_SPLITLISTMODEL_HPP
|
||||
#define GNC_SPLITLISTMODEL_HPP
|
||||
|
||||
#include "config.h"
|
||||
#include "gncmm/Account.hpp"
|
||||
#include "gncmm/Split.hpp"
|
||||
#include "gnc/QofEventWrapper.hpp"
|
||||
#include "gncmm/Transaction.hpp"
|
||||
#include "gnc/conv.hpp"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "engine/Transaction.h"
|
||||
}
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QAbstractItemDelegate>
|
||||
#include <QHash>
|
||||
class QUndoStack;
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
/** This is the data model for a list of splits.
|
||||
*/
|
||||
class SplitListModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
enum ColumnNumbers
|
||||
{
|
||||
COLUMN_DATE = 0
|
||||
, COLUMN_NUM
|
||||
, COLUMN_DESC
|
||||
, COLUMN_ACCOUNT
|
||||
, COLUMN_RECONCILE
|
||||
, COLUMN_INCREASE
|
||||
, COLUMN_DECREASE
|
||||
, COLUMN_BALANCE
|
||||
, COLUMN_LAST
|
||||
};
|
||||
|
||||
SplitListModel(const Glib::RefPtr<Account> acc, QUndoStack* undoStack, QObject *parent = 0);
|
||||
~SplitListModel();
|
||||
|
||||
Glib::RefPtr<Account> getAccount() const { return m_account; }
|
||||
|
||||
QModelIndex parent(const QModelIndex &index) const { return QModelIndex(); }
|
||||
int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
||||
int columnCount(const QModelIndex& parent = QModelIndex()) const;
|
||||
QModelIndex index(int row, int column,
|
||||
const QModelIndex &parent = QModelIndex()) const;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
|
||||
QVariant data(const QModelIndex& index, int role) const;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role);
|
||||
|
||||
bool removeRows(int position, int rows, const QModelIndex &index = QModelIndex());
|
||||
|
||||
public Q_SLOTS:
|
||||
void transactionEvent( ::Transaction* trans, QofEventId event_type);
|
||||
void accountEvent( ::Account* trans, QofEventId event_type);
|
||||
void editorClosed(const QModelIndex& index, QAbstractItemDelegate::EndEditHint hint);
|
||||
|
||||
private:
|
||||
void recreateCache();
|
||||
void recreateTmpTrans();
|
||||
|
||||
protected:
|
||||
Glib::RefPtr<Account> m_account;
|
||||
SplitQList m_list;
|
||||
QUndoStack* m_undoStack;
|
||||
typedef QHash< ::Transaction*, int> TransactionRowHash;
|
||||
TransactionRowHash m_hash;
|
||||
|
||||
/** The wrapper for receiving events from gnc. */
|
||||
QofEventWrapper<SplitListModel, ::Transaction*> m_eventWrapper;
|
||||
QofEventWrapper<SplitListModel, ::Account*> m_eventWrapperAccount;
|
||||
|
||||
bool m_enableNewTransaction;
|
||||
TmpTransaction m_tmpTransaction;
|
||||
};
|
||||
|
||||
} // END namespace gnc
|
||||
|
||||
#endif
|
@ -1,119 +0,0 @@
|
||||
/*
|
||||
* SplitListView.cpp
|
||||
* Copyright (C) 2010 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#include "SplitListView.hpp"
|
||||
|
||||
#include "engine/gnc-event.h" // for GNC_EVENT_ITEM_ADDED
|
||||
#include "gncmm/Account.hpp"
|
||||
#include "gnc/SplitListModel.hpp"
|
||||
#include "gnc/AccountSelectionDelegate.hpp"
|
||||
|
||||
#include <QtGui/QAbstractItemDelegate>
|
||||
#include <QUndoStack>
|
||||
#include <QDebug>
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
SplitListView::SplitListView(Glib::RefPtr<Account> account, QUndoStack* undoStack, QWidget* parent)
|
||||
: base_class(parent)
|
||||
, m_account(account)
|
||||
, m_eventWrapperAccount(*this, &SplitListView::accountEvent)
|
||||
, m_eventWrapperBook(*this, &SplitListView::bookEvent)
|
||||
{
|
||||
// Create a model that is used in this view
|
||||
SplitListModel *smodel = new SplitListModel(account, undoStack, this);
|
||||
setModel(smodel);
|
||||
connect(this, SIGNAL(editorClosed(const QModelIndex&,QAbstractItemDelegate::EndEditHint)),
|
||||
smodel, SLOT(editorClosed(const QModelIndex&,QAbstractItemDelegate::EndEditHint)));
|
||||
|
||||
// Create a separate delegate only for the Account colum
|
||||
QAbstractItemDelegate *accountDelegate = new AccountSelectionDelegate(this);
|
||||
setItemDelegateForColumn(SplitListModel::COLUMN_ACCOUNT, accountDelegate);
|
||||
|
||||
// Appearance of this view
|
||||
setAlternatingRowColors(true);
|
||||
|
||||
// Move the focus to the latest line
|
||||
scrollToBottom();
|
||||
if (model()->rowCount() > 0)
|
||||
setCurrentIndex(model()->index(model()->rowCount() - 1, 0));
|
||||
}
|
||||
|
||||
void SplitListView::closeEditor(QWidget* editor, QAbstractItemDelegate::EndEditHint hint)
|
||||
{
|
||||
base_class::closeEditor(editor, hint);
|
||||
//qDebug() << "closeEditor, row=" << currentIndex().row() << "hint=" << hint;
|
||||
QModelIndex index = currentIndex();
|
||||
if (hint != QAbstractItemDelegate::NoHint)
|
||||
Q_EMIT editorClosed(index, hint);
|
||||
if (index.isValid()
|
||||
&& hint == QAbstractItemDelegate::SubmitModelCache
|
||||
&& index.row() < model()->rowCount() - 1)
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case SplitListModel::COLUMN_INCREASE:
|
||||
case SplitListModel::COLUMN_DECREASE:
|
||||
setCurrentIndex(model()->index(index.row() + 1,
|
||||
SplitListModel::COLUMN_DATE,
|
||||
index.parent()));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SplitListView::accountEvent( ::Account* v, QofEventId event_type)
|
||||
{
|
||||
if (v != m_account->gobj())
|
||||
return;
|
||||
//qDebug() << "SplitListView::accountEvent, id=" << qofEventToString(event_type);
|
||||
switch (event_type)
|
||||
{
|
||||
case QOF_EVENT_DESTROY:
|
||||
// This account seems to be getting deleted - better close
|
||||
// this view.
|
||||
deleteLater();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SplitListView::bookEvent( ::QofBook* v, QofEventId event_type)
|
||||
{
|
||||
qDebug() << "SplitListView::bookEvent, id=" << qofEventToString(event_type);
|
||||
|
||||
switch (event_type)
|
||||
{
|
||||
case QOF_EVENT_DESTROY:
|
||||
// The book is being deleted - better close this view ASAP!
|
||||
deleteLater();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
/*
|
||||
* SplitListView.hpp
|
||||
* Copyright (C) 2010 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#ifndef GNC_SPLITLISTVIEW_HPP
|
||||
#define GNC_SPLITLISTVIEW_HPP
|
||||
|
||||
#include "config.h"
|
||||
#include "gncmm/Account.hpp"
|
||||
#include "gnc/SplitListModel.hpp"
|
||||
#include "gnc/QofEventWrapper.hpp"
|
||||
|
||||
#include <QtGui/QTableView>
|
||||
#include <QtGui/QAbstractItemDelegate>
|
||||
#include <QUndoStack>
|
||||
#include <QDebug>
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
class SplitListView : public QTableView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
typedef QTableView base_class;
|
||||
SplitListView(Glib::RefPtr<Account> account, QUndoStack* undoStack, QWidget* parent = 0);
|
||||
|
||||
Q_SIGNALS:
|
||||
void editorClosed(const QModelIndex& index, QAbstractItemDelegate::EndEditHint hint);
|
||||
|
||||
public Q_SLOTS:
|
||||
void closeEditor(QWidget* editor, QAbstractItemDelegate::EndEditHint hint);
|
||||
void accountEvent( ::Account* v, QofEventId event_type);
|
||||
void bookEvent( ::QofBook* v, QofEventId event_type);
|
||||
|
||||
private:
|
||||
Glib::RefPtr<Account> m_account;
|
||||
QofEventWrapper<SplitListView, ::Account*> m_eventWrapperAccount;
|
||||
QofEventWrapper<SplitListView, ::QofBook*> m_eventWrapperBook;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -1,94 +0,0 @@
|
||||
/*
|
||||
* WeakPointer.hpp
|
||||
* Copyright (C) 2010 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#ifndef GNC_WEAKPOINTER_HPP
|
||||
#define GNC_WEAKPOINTER_HPP
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
/** A thin wrapper for a C object which is owned by someone else.
|
||||
*
|
||||
* This copies the interface of the boost::scoped_ptr, but in contrast
|
||||
* to the boost::scoped_ptr this class does not take on ownership of
|
||||
* the given pointer. Instead, the pointer is owned by someone else,
|
||||
* and we hope nobody accesses this object after the pointer's object
|
||||
* was deleted somewhere else. Unfortunately currently we have no
|
||||
* information about whether the pointed-to object is still alive or
|
||||
* already deleted. Sorry for that.
|
||||
*/
|
||||
template<class T>
|
||||
class WeakPointer
|
||||
{
|
||||
public:
|
||||
typedef T element_type;
|
||||
private:
|
||||
element_type *m_ptr;
|
||||
typedef WeakPointer<T> this_type;
|
||||
public:
|
||||
|
||||
WeakPointer(element_type* ptr = 0)
|
||||
: m_ptr(ptr)
|
||||
{ }
|
||||
|
||||
void reset(element_type* ptr = 0)
|
||||
{
|
||||
m_ptr = ptr;
|
||||
}
|
||||
|
||||
T & operator*() const // never throws
|
||||
{
|
||||
assert(m_ptr != 0);
|
||||
return *m_ptr;
|
||||
}
|
||||
|
||||
T * operator->() const // never throws
|
||||
{
|
||||
assert(m_ptr != 0);
|
||||
return m_ptr;
|
||||
}
|
||||
|
||||
T * gobj() const // never throws
|
||||
{
|
||||
return m_ptr;
|
||||
}
|
||||
|
||||
// implicit conversion to "bool"
|
||||
typedef T * this_type::*unspecified_bool_type;
|
||||
operator unspecified_bool_type() const // never throws
|
||||
{
|
||||
return m_ptr == 0 ? 0 : &this_type::m_ptr;
|
||||
}
|
||||
|
||||
bool operator! () const // never throws
|
||||
{
|
||||
return m_ptr == 0;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // END namespace gnc
|
||||
|
||||
#endif
|
@ -1,20 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15">
|
||||
<title>GnuCash C++ Test</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>GnuCash C++ Test</h1>
|
||||
|
||||
<p>This is a text that demonstrates how we can build a GnuCash variant in C++ and Qt.</p>
|
||||
|
||||
<h2>Images</h2>
|
||||
<p><img src=":/pixmaps/gnucash_splash.png"></p>
|
||||
<p>We can also embed images here in this compiled-in HTML page.</p>
|
||||
|
||||
<hr>
|
||||
<address></address>
|
||||
<!-- hhmts start -->Last modified: Mon Mar 1 09:11:12 CET 2010 <!-- hhmts end -->
|
||||
</body> </html>
|
@ -1,37 +0,0 @@
|
||||
#ifndef CONV_HPP
|
||||
#define CONV_HPP
|
||||
|
||||
#include <QDate>
|
||||
#include <QString>
|
||||
#include <glibmm/date.h>
|
||||
#include <glibmm/ustring.h>
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
/// Convert the given Glib::Date into a QDate object
|
||||
inline QDate g2q(const Glib::Date& d)
|
||||
{
|
||||
return QDate(d.get_year(), d.get_month(), d.get_day());
|
||||
}
|
||||
|
||||
/// Convert the given QDate into a Glib::Date object
|
||||
inline Glib::Date q2g(const QDate& d)
|
||||
{
|
||||
return Glib::Date(d.day(), Glib::Date::Month(d.month()), d.year());
|
||||
}
|
||||
|
||||
/// Convert the given Glib::ustring into a QString object
|
||||
inline QString g2q(const Glib::ustring& s)
|
||||
{
|
||||
return QString::fromUtf8(s.c_str());
|
||||
}
|
||||
|
||||
/// Convert the given QString into a Glib::ustring object
|
||||
inline Glib::ustring q2g(const QString& s)
|
||||
{
|
||||
return Glib::ustring(s.toUtf8());
|
||||
}
|
||||
}
|
||||
|
||||
#endif // CONV_HPP
|
@ -1,335 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Free Software Foundation, Inc
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/**
|
||||
* @file
|
||||
* Dashboard for embedding various dock widgets.
|
||||
*
|
||||
* Dock Widgets:
|
||||
* 1) Transfer Funds
|
||||
* 2) First Person Overview
|
||||
*/
|
||||
|
||||
#include "dashboard.hpp"
|
||||
#include "ui_dashboard.h"
|
||||
#include "engine/gnc-event.h" // for GNC_EVENT_ITEM_ADDED
|
||||
|
||||
#include <QtGui>
|
||||
#include <QAbstractItemModel>
|
||||
#include <QDate>
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
Dashboard::Dashboard(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::Dashboard),
|
||||
m_eventWrapper(*this, &Dashboard::transactionEvent),
|
||||
m_eventWrapperAccount(*this, &Dashboard::accountEvent)
|
||||
{
|
||||
QSettings settings;
|
||||
restoreGeometry(settings.value("dashboardGeometry").toByteArray());
|
||||
|
||||
ui->setupUi(this);
|
||||
|
||||
// Generate UI
|
||||
setUiWidgets();
|
||||
setBasicTxnEntryFormLayout();
|
||||
setCentralWidget(ui->dockwFPO);
|
||||
setFPO();
|
||||
//this->tabifyDockWidget(ui->dockwBasicTxn, ui->dockwSplitTxn);
|
||||
//ui->dockwBasicTxn->raise();
|
||||
ui->dockwSplitTxn->hide();
|
||||
ui->dockwLogViewer->hide();
|
||||
|
||||
/* Set stylesheet, so that some styling to viewlets can be applied */
|
||||
/*QFile styleSheetFile(":/qss-default");
|
||||
styleSheetFile.open(QFile::ReadOnly);
|
||||
QString styleSheetName = QLatin1String(styleSheetFile.readAll());
|
||||
this->setStyleSheet(styleSheetName);*/
|
||||
|
||||
restoreState(settings.value("dashboardState").toByteArray());
|
||||
bool isBasicTxnDockVisible = settings.value("basic-txn-dockwidget-visible").toBool();
|
||||
ui->dockwBasicTxn->setVisible(isBasicTxnDockVisible);
|
||||
|
||||
/*
|
||||
// Trying to restore pos and size of dockwidget manually
|
||||
QSettings settings;
|
||||
QPoint bTxnWdgPos = settings.value("basic-txn-entry-dockwidget-pos").toPoint();
|
||||
ui->dockwBasicTxn->move(bTxnWdgPos);
|
||||
QSize bTxnWdgSize = settings.value("basic-txn-entry-dockwidget-size").toSize();
|
||||
ui->dockwBasicTxn->resize(bTxnWdgSize);
|
||||
*/
|
||||
|
||||
connect(btnCreateBasicTxn, SIGNAL(clicked()),
|
||||
this, SLOT(on_btnCreateBasicTxn_clicked()));
|
||||
}
|
||||
|
||||
Dashboard::~Dashboard()
|
||||
{
|
||||
/*
|
||||
QSettings settings;
|
||||
settings.setValue("basic-txn-entry-dockwidget-pos", ui->dockwBasicTxn->pos());
|
||||
settings.setValue("basic-txn-entry-dockwidget-size", ui->dockwBasicTxn->size());
|
||||
*/
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void
|
||||
Dashboard::mainWindowCloseEvent()
|
||||
{
|
||||
QSettings settings;
|
||||
settings.setValue("dashboardGeometry", saveGeometry());
|
||||
settings.setValue("dashboardState", saveState());
|
||||
settings.setValue("basic-txn-dockwidget-visible", ui->dockwBasicTxn->isVisible());
|
||||
//qDebug()<<"while writing dockwdg visibility is "<<settings.value("basic-txn-dockwidget-visible").toBool();
|
||||
}
|
||||
|
||||
void
|
||||
Dashboard::showDashboardWidgets()
|
||||
{
|
||||
QSettings settings;
|
||||
ui->dockwBasicTxn->setVisible(settings.value("basic-txn-dockwidget-visible").toBool());
|
||||
ui->dockwFPO->show();
|
||||
}
|
||||
|
||||
/** Initialise widgets to startup defaults */
|
||||
void
|
||||
Dashboard::setUiWidgets()
|
||||
{
|
||||
numer = 0.0;
|
||||
|
||||
lblDescription = new QLabel(tr("Description:"));
|
||||
lblDate = new QLabel(tr("Date:"));
|
||||
lblTransferFrom = new QLabel(tr("Transfer From:"));
|
||||
lblTransferTo = new QLabel(tr("TransferTo:"));
|
||||
lblAmount = new QLabel(tr("Amount:"));
|
||||
lblMemo = new QLabel(tr("Memo:"));
|
||||
lblNum = new QLabel(tr("Num:"));
|
||||
comboTransferFrom = new QComboBox();
|
||||
comboTransferFrom->addItem(tr("- NA -"));
|
||||
comboTransferTo = new QComboBox();
|
||||
comboTransferTo->addItem(tr("- NA -"));
|
||||
lineDescription = new QLineEdit();
|
||||
lineAmount = new QLineEdit();
|
||||
lineAmount->setText(tr("0.00"));
|
||||
lineAmount->setValidator(new QDoubleValidator(0.0, 1e100, 2, this));
|
||||
lineMemo = new QLineEdit();
|
||||
lineNum = new QLineEdit();
|
||||
dateTxnDate = new QDateEdit();
|
||||
dateVal = QDate::currentDate();
|
||||
dateTxnDate->setDate(dateVal);
|
||||
btnCreateBasicTxn = new QPushButton(tr("Create Transaction"));
|
||||
}
|
||||
|
||||
/** Layout for data entry. Type: Form Based
|
||||
*
|
||||
* Set this as default to make this layout as default
|
||||
* for all data entry widgets. */
|
||||
void
|
||||
Dashboard::setBasicTxnEntryFormLayout()
|
||||
{
|
||||
gridBasicTxnEntry = new QGridLayout(ui->dockcBasicTxn);
|
||||
|
||||
gridBasicTxnEntry->addWidget(lblDescription, 0, 0);
|
||||
gridBasicTxnEntry->addWidget(lineDescription, 0, 1);
|
||||
|
||||
gridBasicTxnEntry->addWidget(lblDate, 1, 0);
|
||||
gridBasicTxnEntry->addWidget(dateTxnDate, 1, 1);
|
||||
|
||||
gridBasicTxnEntry->addWidget(lblTransferFrom, 2, 0);
|
||||
gridBasicTxnEntry->addWidget(comboTransferFrom, 2, 1);
|
||||
|
||||
gridBasicTxnEntry->addWidget(lblTransferTo, 3, 0);
|
||||
gridBasicTxnEntry->addWidget(comboTransferTo, 3, 1);
|
||||
|
||||
gridBasicTxnEntry->addWidget(lblAmount, 4, 0);
|
||||
gridBasicTxnEntry->addWidget(lineAmount, 4, 1);
|
||||
|
||||
gridBasicTxnEntry->addWidget(lblMemo, 5, 0);
|
||||
gridBasicTxnEntry->addWidget(lineMemo, 5, 1);
|
||||
|
||||
gridBasicTxnEntry->addWidget(lblNum, 6, 0);
|
||||
gridBasicTxnEntry->addWidget(lineNum, 6, 1);
|
||||
|
||||
gridBasicTxnEntry->addWidget(btnCreateBasicTxn, 7, 1);
|
||||
}
|
||||
|
||||
void
|
||||
Dashboard::setFPO()
|
||||
{
|
||||
QHBoxLayout *FPOLayout = new QHBoxLayout;
|
||||
ui->dockcFPO->setLayout(FPOLayout);
|
||||
fpoWidget = new FPO(ui->dockcFPO, FPOLayout);
|
||||
}
|
||||
|
||||
void
|
||||
Dashboard::clearFields()
|
||||
{
|
||||
lineDescription->clear();
|
||||
lineAmount->clear();
|
||||
lineMemo->clear();
|
||||
lineNum->clear();
|
||||
}
|
||||
|
||||
void
|
||||
Dashboard::transactionEvent( ::Transaction* trans, QofEventId event_type)
|
||||
{
|
||||
//qDebug() << "Dashboard::transactionEvent, id=" << qofEventToString(event_type);
|
||||
switch (event_type)
|
||||
{
|
||||
case QOF_EVENT_MODIFY:
|
||||
fpoWidget->leftViewlet->leftVUpdate();
|
||||
fpoWidget->rightViewlet->rightVUpdate();
|
||||
fpoWidget->defaultViewlet->defaultVUpdate();
|
||||
break;
|
||||
case GNC_EVENT_ITEM_REMOVED:
|
||||
case GNC_EVENT_ITEM_ADDED:
|
||||
// This event is triggered by a split being added (or removed)
|
||||
// to a transaction. Ignored because we already reacted upon
|
||||
// the MODIFY event.
|
||||
break;
|
||||
case QOF_EVENT_CREATE:
|
||||
// This event is triggered by a newly created transaction, but
|
||||
// we reacted on this in the accountEvent handler already.
|
||||
break;
|
||||
default:
|
||||
qDebug() << "Dashboard::transactionEvent, ignored event id=" << qofEventToString(event_type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Dashboard::accountEvent( ::Account* acc, QofEventId event_type)
|
||||
{
|
||||
//qDebug() << "Dashboard::accountEvent, id=" << qofEventToString(event_type);
|
||||
|
||||
switch (event_type)
|
||||
{
|
||||
case GNC_EVENT_ITEM_REMOVED:
|
||||
fpoWidget->leftViewlet->leftVUpdate();
|
||||
fpoWidget->rightViewlet->rightVUpdate();
|
||||
fpoWidget->defaultViewlet->defaultVUpdate();
|
||||
break;
|
||||
case GNC_EVENT_ITEM_CHANGED:
|
||||
case GNC_EVENT_ITEM_ADDED:
|
||||
case QOF_EVENT_MODIFY:
|
||||
// These events are also triggered e.g. by a newly added
|
||||
// transaction/split in this account. However, we already
|
||||
// reacted on this by the above events, so we can ignore them
|
||||
// here.
|
||||
break;
|
||||
default:
|
||||
qDebug() << "Dashboard::accountEvent, ignored event id=" << qofEventToString(event_type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Dashboard::loadAccountsTreeComboBox(AccountListModel * const m_accountsListModel)
|
||||
{
|
||||
accountsList = m_accountsListModel;
|
||||
comboTransferFrom->setModel(accountsList);
|
||||
comboTransferTo->setModel(accountsList);
|
||||
}
|
||||
|
||||
/***** Slots *****/
|
||||
|
||||
/** "Create Transaction" button for Basic Transaction Entry dock widget */
|
||||
void
|
||||
Dashboard::on_btnCreateBasicTxn_clicked()
|
||||
{
|
||||
if (lineDescription->text().isEmpty())
|
||||
{
|
||||
QMessageBox::StandardButton warnEmptyDesc;
|
||||
warnEmptyDesc = QMessageBox::warning(this, tr("Empty Description"), "You have not set a description. Are you sure you want to create a transaction with no description?", QMessageBox::Yes | QMessageBox::No);
|
||||
if (warnEmptyDesc == QMessageBox::No)
|
||||
return;
|
||||
}
|
||||
|
||||
// Allocate memory and start editing a new transaction
|
||||
int index = comboTransferFrom->currentIndex();
|
||||
account = accountsList->at(index);
|
||||
book = gnc_account_get_book(account);
|
||||
transaction = ::xaccMallocTransaction(book);
|
||||
::xaccTransBeginEdit(transaction);
|
||||
|
||||
// Populate transaction details
|
||||
dateVal = dateTxnDate->date();
|
||||
::xaccTransSetDate(transaction, dateVal.day(), dateVal.month(),
|
||||
dateVal.year());
|
||||
|
||||
::xaccTransSetNum(transaction, lineNum->text().toUtf8());
|
||||
::xaccTransSetDescription(transaction, lineDescription->text().toUtf8());
|
||||
|
||||
currency = gnc_account_or_default_currency(account, NULL);
|
||||
::xaccTransSetCurrency(transaction, currency);
|
||||
|
||||
denom = ::gnc_commodity_get_fraction(currency);
|
||||
|
||||
// Populate split 1
|
||||
// Check whether the account for this split is a placeholder
|
||||
qDebug() << ::xaccAccountGetPlaceholder(account);
|
||||
// ^^ does not work as expected, returns false for placeholder accounts too. Why?
|
||||
|
||||
split = xaccMallocSplit(book);
|
||||
::xaccTransAppendSplit(transaction, split);
|
||||
::xaccAccountInsertSplit(account, split);
|
||||
|
||||
numer = lineAmount->text().toDouble();
|
||||
amount = ::double_to_gnc_numeric(numer, denom,
|
||||
GNC_HOW_DENOM_REDUCE | GNC_HOW_RND_NEVER);
|
||||
::xaccSplitSetValue(split, amount);
|
||||
::xaccSplitSetAmount(split, amount);
|
||||
|
||||
// Populate split 2
|
||||
split2 = ::xaccMallocSplit(book);
|
||||
::xaccTransAppendSplit(transaction, split2);
|
||||
int index2 = comboTransferTo->currentIndex();
|
||||
account2 = accountsList->at(index2);
|
||||
::xaccAccountInsertSplit(account2, split2);
|
||||
|
||||
amount2 = ::gnc_numeric_neg(amount);
|
||||
::xaccSplitSetValue(split2, amount2);
|
||||
::xaccSplitSetAmount(split2, amount2);
|
||||
|
||||
// Finally commit the transaction to storage backend.
|
||||
::xaccTransCommitEdit(transaction);
|
||||
|
||||
statusBar()->showMessage(tr("Transaction has been created"), 2000);
|
||||
clearFields();
|
||||
}
|
||||
|
||||
void
|
||||
Dashboard::on_dockwBasicTxn_visibilityChanged(bool visible)
|
||||
{
|
||||
((MainWindow *)parentWidget()->parentWidget()->parentWidget()->parentWidget())->dockWidgetsVisibilityChanged(0, visible);
|
||||
}
|
||||
|
||||
void
|
||||
Dashboard::transferFundsWidgetButtonToggled(bool checked)
|
||||
{
|
||||
if (checked)
|
||||
{
|
||||
ui->dockwBasicTxn->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->dockwBasicTxn->hide();
|
||||
}
|
||||
}
|
||||
|
||||
} // END namespace gnc
|
@ -1,124 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Free Software Foundation, Inc
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/**
|
||||
* @file
|
||||
* Dashboard for embedding various dock widgets.
|
||||
*/
|
||||
|
||||
#ifndef DASHBOARD_HPP
|
||||
#define DASHBOARD_HPP
|
||||
|
||||
#include "config.h"
|
||||
#include "engine/guid.hpp"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "qof.h"
|
||||
#include "engine/Account.h"
|
||||
#include "engine/Transaction.h"
|
||||
}
|
||||
|
||||
#include "AccountItemModel.hpp"
|
||||
#include "fpo/FPO.hpp"
|
||||
#include "gnc/QofEventWrapper.hpp"
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QAbstractItemModel>
|
||||
#include <QtGui>
|
||||
|
||||
namespace Ui {
|
||||
class Dashboard;
|
||||
}
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
class FPO;
|
||||
|
||||
class Dashboard : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Dashboard(QWidget *parent = 0);
|
||||
~Dashboard();
|
||||
|
||||
FPO *fpoWidget;
|
||||
AccountListModel *accountsList;
|
||||
void loadAccountsTreeComboBox(AccountListModel * const m_accountListModel);
|
||||
void showDashboardWidgets();
|
||||
void mainWindowCloseEvent();
|
||||
|
||||
public Q_SLOTS:
|
||||
void transferFundsWidgetButtonToggled(bool checked);
|
||||
void transactionEvent( ::Transaction* trans, QofEventId event_type);
|
||||
void accountEvent( ::Account* acc, QofEventId event_type);
|
||||
|
||||
private:
|
||||
Ui::Dashboard *ui;
|
||||
|
||||
/* UI widgets */
|
||||
QGridLayout *gridBasicTxnEntry;
|
||||
QHBoxLayout *hbox;
|
||||
QVBoxLayout *vbox;
|
||||
QLabel *lblDescription;
|
||||
QLabel *lblDate;
|
||||
QLabel *lblTransferFrom;
|
||||
QLabel *lblTransferTo;
|
||||
QLabel *lblAmount;
|
||||
QLabel *lblMemo;
|
||||
QLabel *lblNum;
|
||||
QComboBox *comboTransferFrom;
|
||||
QComboBox *comboTransferTo;
|
||||
QLineEdit *lineDescription;
|
||||
QLineEdit *lineAmount;
|
||||
QLineEdit *lineMemo;
|
||||
QLineEdit *lineNum;
|
||||
QDateEdit *dateTxnDate;
|
||||
QDate dateVal;
|
||||
QPushButton *btnCreateBasicTxn;
|
||||
|
||||
/* Transaction related data types */
|
||||
::QofBook *book;
|
||||
::Transaction *transaction;
|
||||
::gnc_commodity *currency;
|
||||
int denom;
|
||||
|
||||
::Account *account;
|
||||
::Split *split;
|
||||
double numer;
|
||||
::gnc_numeric amount;
|
||||
|
||||
::Account *account2;
|
||||
::Split *split2;
|
||||
::gnc_numeric amount2;
|
||||
|
||||
void setUiWidgets();
|
||||
void setBasicTxnEntryFormLayout();
|
||||
void setFPO();
|
||||
void clearFields();
|
||||
QofEventWrapper<Dashboard, ::Transaction*> m_eventWrapper;
|
||||
QofEventWrapper<Dashboard, ::Account*> m_eventWrapperAccount;
|
||||
|
||||
private Q_SLOTS:
|
||||
void on_btnCreateBasicTxn_clicked();
|
||||
void on_dockwBasicTxn_visibilityChanged(bool visible);
|
||||
};
|
||||
|
||||
} // END namespace gnc
|
||||
|
||||
#endif // DASHBOARD_HPP
|
@ -1,329 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Dashboard</class>
|
||||
<widget class="QMainWindow" name="Dashboard">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1049</width>
|
||||
<height>617</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<property name="dockOptions">
|
||||
<set>QMainWindow::AllowTabbedDocks|QMainWindow::AnimatedDocks|QMainWindow::ForceTabbedDocks</set>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget"/>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1049</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<widget class="QDockWidget" name="dockwBasicTxn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>300</width>
|
||||
<height>265</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>500</width>
|
||||
<height>275</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>275</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="features">
|
||||
<set>QDockWidget::AllDockWidgetFeatures</set>
|
||||
</property>
|
||||
<property name="allowedAreas">
|
||||
<set>Qt::AllDockWidgetAreas</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Basic</string>
|
||||
</property>
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>4</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="dockcBasicTxn"/>
|
||||
</widget>
|
||||
<widget class="QDockWidget" name="dockwSplitTxn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>265</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>500</width>
|
||||
<height>275</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="features">
|
||||
<set>QDockWidget::AllDockWidgetFeatures</set>
|
||||
</property>
|
||||
<property name="allowedAreas">
|
||||
<set>Qt::AllDockWidgetAreas</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Split</string>
|
||||
</property>
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>4</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="dockcSplitTxn">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>60</y>
|
||||
<width>261</width>
|
||||
<height>161</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Split</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>30</y>
|
||||
<width>101</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Transfer From/To</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="comboBox_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>30</y>
|
||||
<width>111</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>60</y>
|
||||
<width>55</width>
|
||||
<height>15</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Amount</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_12">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>90</y>
|
||||
<width>55</width>
|
||||
<height>15</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Memo</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_13">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>120</y>
|
||||
<width>55</width>
|
||||
<height>15</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Num</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_6">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>60</y>
|
||||
<width>181</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_7">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>90</y>
|
||||
<width>181</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_8">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>120</y>
|
||||
<width>181</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>80</x>
|
||||
<y>0</y>
|
||||
<width>331</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>0</y>
|
||||
<width>81</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Description</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>30</y>
|
||||
<width>55</width>
|
||||
<height>15</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Date</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDateEdit" name="dateEdit_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>80</x>
|
||||
<y>30</y>
|
||||
<width>110</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>280</x>
|
||||
<y>130</y>
|
||||
<width>121</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add Split ></string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>280</x>
|
||||
<y>170</y>
|
||||
<width>121</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Create Transaction</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QDockWidget" name="dockwLogViewer">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Event Logger</string>
|
||||
</property>
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>4</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="dockcLogViewer"/>
|
||||
</widget>
|
||||
<widget class="QDockWidget" name="dockwFPO">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="features">
|
||||
<set>QDockWidget::NoDockWidgetFeatures</set>
|
||||
</property>
|
||||
<property name="allowedAreas">
|
||||
<set>Qt::BottomDockWidgetArea|Qt::TopDockWidgetArea</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>8</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="dockcFPO"/>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -1,18 +0,0 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>icons/oxygen/index.theme</file>
|
||||
<file>icons/oxygen/48x48/actions/list-add.png</file>
|
||||
<file>icons/oxygen/48x48/actions/edit-undo.png</file>
|
||||
<file>icons/oxygen/48x48/actions/edit-redo.png</file>
|
||||
<file>icons/oxygen/48x48/actions/edit-copy.png</file>
|
||||
<file>icons/oxygen/48x48/actions/edit-cut.png</file>
|
||||
<file>icons/oxygen/48x48/actions/edit-paste.png</file>
|
||||
<file>icons/oxygen/48x48/actions/window-close.png</file>
|
||||
<file>icons/oxygen/48x48/actions/tab-close-other.png</file>
|
||||
<file>icons/oxygen/48x48/actions/document-new.png</file>
|
||||
<file>icons/oxygen/48x48/actions/document-open.png</file>
|
||||
<file>icons/oxygen/48x48/actions/document-save.png</file>
|
||||
<file>icons/oxygen/48x48/actions/document-save-as.png</file>
|
||||
<file>icons/oxygen/48x48/actions/help-about.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
@ -1,46 +0,0 @@
|
||||
/********************************************************************\
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
#include "FPO.hpp"
|
||||
#include "gnc/dashboard.hpp"
|
||||
#include "gnc/mainwindow.hpp"
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
FPO::FPO(QWidget *parent, QHBoxLayout *FPOLayout) :
|
||||
QWidget(parent)
|
||||
{
|
||||
/* Left viewlet */
|
||||
leftViewlet = new ViewletView(parent, FPOLayout);
|
||||
leftViewlet->leftVSet(parent, FPOLayout);
|
||||
|
||||
/* Right viewlet */
|
||||
rightViewlet = new ViewletView(parent, FPOLayout);
|
||||
rightViewlet->rightVSet(parent, FPOLayout);
|
||||
|
||||
/* Default viewlet */
|
||||
defaultViewlet = new ViewletView(parent, FPOLayout);
|
||||
defaultViewlet->defaultVSet(parent, FPOLayout);
|
||||
}
|
||||
|
||||
} // END namespace gnc
|
@ -1,35 +0,0 @@
|
||||
#ifndef FPO_HPP
|
||||
#define FPO_HPP
|
||||
|
||||
#include "ViewletView.hpp"
|
||||
#include "gnc/Session.hpp"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QGridLayout>
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
class ViewletView;
|
||||
|
||||
class FPO : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FPO(QWidget *parent = 0, QHBoxLayout *FPOLayout = NULL);
|
||||
ViewletView *leftViewlet;
|
||||
ViewletView *rightViewlet;
|
||||
ViewletView *defaultViewlet;
|
||||
|
||||
Session m_session;
|
||||
|
||||
Q_SIGNALS:
|
||||
void sessionLoaded();
|
||||
|
||||
public Q_SLOTS:
|
||||
|
||||
};
|
||||
|
||||
} // END namespace gnc
|
||||
|
||||
#endif // FPO_HPP
|
@ -1,236 +0,0 @@
|
||||
/********************************************************************\
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
#include "ViewletModel.hpp"
|
||||
#include "gncmm/Transaction.hpp"
|
||||
#include "gncmm/Account.hpp"
|
||||
|
||||
#include "gncmm/Numeric.hpp"
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
ViewletModel::ViewletModel()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
ViewletModel::defaultVGenerate(::Account *selectedAccount)
|
||||
{
|
||||
SplitQList splitList = buildSplitListDateSort(selectedAccount);
|
||||
buildMiniJournalStruct(splitList);
|
||||
}
|
||||
|
||||
void
|
||||
ViewletModel::leftVGenerate(::Account *selectedAccount)
|
||||
{
|
||||
::QofBook *book = gnc_account_get_book(selectedAccount);
|
||||
::Account *rootAccount = gnc_book_get_root_account(book);
|
||||
|
||||
GList *accountsGList = gnc_account_get_descendants(rootAccount);
|
||||
AccountQList accountsList = accountFromGList(accountsGList);
|
||||
|
||||
int numOfAccounts = accountsList.count();
|
||||
qDebug()<<"Total num of accounts: "<<numOfAccounts;
|
||||
|
||||
AccountQList expenseAccountsList;
|
||||
for(int i = 0; i < numOfAccounts; i++)
|
||||
{
|
||||
if(xaccAccountGetType(accountsList.at(i)) == 9)
|
||||
{
|
||||
expenseAccountsList.append(accountsList.at(i));
|
||||
}
|
||||
}
|
||||
|
||||
SplitQList splitsList = buildSplitListDateSort(expenseAccountsList);
|
||||
buildMiniJournalStruct(splitsList);
|
||||
}
|
||||
|
||||
void
|
||||
ViewletModel::rightVGenerate(::Account *selectedAccount)
|
||||
{
|
||||
::QofBook *book = gnc_account_get_book(selectedAccount);
|
||||
::Account *rootAccount = gnc_book_get_root_account(book);
|
||||
|
||||
GList *accountsGList = gnc_account_get_descendants(rootAccount);
|
||||
AccountQList accountsList = accountFromGList(accountsGList);
|
||||
|
||||
int numOfAccounts = accountsList.count();
|
||||
qDebug()<<"Total num of accounts: "<<numOfAccounts;
|
||||
|
||||
AccountQList expenseAccountsList;
|
||||
for(int i = 0; i < numOfAccounts; i++)
|
||||
{
|
||||
if(xaccAccountGetType(accountsList.at(i)) == 8)
|
||||
{
|
||||
expenseAccountsList.append(accountsList.at(i));
|
||||
}
|
||||
}
|
||||
|
||||
SplitQList splitsList = buildSplitListDateSort(expenseAccountsList);
|
||||
buildMiniJournalStruct(splitsList);
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
/* get all transactions earlier than the specified date */
|
||||
QofQuery *qr = qof_query_create_for (GNC_ID_SPLIT);
|
||||
qof_query_set_book(qr, ::gnc_account_get_book(selectedAccount));
|
||||
// To look for dates, you need to create a "PredData" object
|
||||
Timespec calve_date;
|
||||
|
||||
//calve_date = gdate_to_timespec(trans.getGDatePosted());
|
||||
QofQueryPredData *pred_data = qof_query_date_predicate (QOF_COMPARE_LTE,
|
||||
QOF_DATE_MATCH_NORMAL,
|
||||
calve_date);
|
||||
// and additionally a "query parameter" object
|
||||
GSList *param_list = qof_query_build_param_list (TRANS_DATE_POSTED, NULL);
|
||||
// The "PredData" and the "query parameter" object are added to this query
|
||||
qof_query_add_term (qr, param_list, pred_data,
|
||||
QOF_QUERY_FIRST_TERM);
|
||||
|
||||
// Query is run; result is returned
|
||||
GList *result = qof_query_run (qr);
|
||||
|
||||
SplitQList querySplitList = Split::fromGList(result);
|
||||
Split qSplit;
|
||||
int numOfQuerSplits = querySplitList.count();
|
||||
|
||||
for(i=0; i < numOfQuerSplits; ++i)
|
||||
{
|
||||
qSplit = querySplitList.at(i);
|
||||
//qDebug()<<qSplit.getCorrAccountName();
|
||||
qDebug()<<qSplit.getParent().getDatePosted().toString();
|
||||
|
||||
}
|
||||
|
||||
// "result" is now a GList of "Transaction*" because at
|
||||
//qof_query_create_for, we've asked for transactions.
|
||||
|
||||
// When finished, delete the QofQuery object but this will
|
||||
// also delete the "result" list.
|
||||
qof_query_destroy (qr);
|
||||
#endif
|
||||
|
||||
SplitQList
|
||||
ViewletModel::buildSplitListDateSort(::Account *selectedAccount)
|
||||
{
|
||||
::SplitList * splitL = ::xaccAccountGetSplitList(selectedAccount);
|
||||
return Split::from_glist(splitL);
|
||||
}
|
||||
|
||||
static bool greaterThanByDate(const ::Split* a, const ::Split* b)
|
||||
{
|
||||
const ::Transaction* tx_a = xaccSplitGetParent(a);
|
||||
const ::Transaction* tx_b = xaccSplitGetParent(b);
|
||||
return xaccTransGetDate(tx_a) > xaccTransGetDate(tx_b);
|
||||
}
|
||||
|
||||
SplitQList
|
||||
ViewletModel::buildSplitListDateSort(AccountQList accountsList)
|
||||
{
|
||||
int numOfAccounts = accountsList.count();
|
||||
qDebug() <<"Num of accounts of X TYPE: "<<numOfAccounts;
|
||||
|
||||
SplitQList allSplitsList;
|
||||
for(int i=0; i< numOfAccounts; i++)
|
||||
{
|
||||
::Account *C_acct = static_cast< ::Account *>(accountsList.at(i));
|
||||
|
||||
SplitQList tempList = Split::from_glist(::xaccAccountGetSplitList(C_acct));
|
||||
|
||||
int numOfSplits = tempList.size();
|
||||
for(int i=0; i<numOfSplits; i++)
|
||||
{
|
||||
allSplitsList.push_back(tempList.at(i));
|
||||
}
|
||||
}
|
||||
|
||||
qSort(allSplitsList.begin(), allSplitsList.end(), &greaterThanByDate);
|
||||
return allSplitsList;
|
||||
}
|
||||
|
||||
bool
|
||||
ViewletModel::lessThanByDate(::Split* a, ::Split* b)
|
||||
{
|
||||
::Transaction* tx_a = xaccSplitGetParent(a);
|
||||
::Transaction* tx_b = xaccSplitGetParent(b);
|
||||
return xaccTransGetDate(tx_a) < xaccTransGetDate(tx_b);
|
||||
}
|
||||
|
||||
void
|
||||
ViewletModel::buildMiniJournalStruct(SplitQList splitList)
|
||||
{
|
||||
int numOfSplits = splitList.size();
|
||||
Glib::Date tempDate;
|
||||
Glib::ustring tempAccount;
|
||||
|
||||
for (int i = 0; i < numOfSplits; i++)
|
||||
{
|
||||
Glib::RefPtr<Split> split = Glib::wrap(splitList.at(i));
|
||||
Glib::RefPtr<Transaction> txn = split->get_parent();
|
||||
|
||||
structViewletEntries entry;
|
||||
|
||||
if(i == 0)
|
||||
{
|
||||
tempDate = txn->get_date_posted();
|
||||
entry.isDateEqual = false;
|
||||
tempAccount = split->get_corr_account_name();
|
||||
entry.isSplitAccountEqual = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(txn->get_date_posted() == tempDate)
|
||||
{
|
||||
entry.isDateEqual = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
entry.isDateEqual = false;
|
||||
tempDate = txn->get_date_posted();
|
||||
}
|
||||
|
||||
if(split->get_corr_account_name() == tempAccount)
|
||||
{
|
||||
entry.isSplitAccountEqual = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
entry.isSplitAccountEqual = false;
|
||||
tempAccount = split->get_corr_account_name();
|
||||
}
|
||||
}
|
||||
|
||||
entry.txnDate = g2q(txn->get_date_posted()).toString();
|
||||
entry.splitAccount = g2q(split->get_corr_account_name());
|
||||
entry.txnDescription = g2q(txn->get_description());
|
||||
|
||||
Numeric splitAmount = split->get_amount();
|
||||
PrintAmountInfo printInfo(split, true);
|
||||
entry.splitAmount = g2q(splitAmount.printAmount(printInfo));
|
||||
|
||||
//qDebug()<<entry.isDateEqual;
|
||||
//qDebug()<<entry.isSplitAccountEqual;
|
||||
|
||||
queueEntries.enqueue(entry);
|
||||
}
|
||||
}
|
||||
} // END namespace gnc
|
@ -1,55 +0,0 @@
|
||||
#ifndef VIEWLETMODEL_HPP
|
||||
#define VIEWLETMODEL_HPP
|
||||
|
||||
#include <QtCore>
|
||||
#include <QtGui>
|
||||
|
||||
#include "config.h"
|
||||
#include "engine/guid.hpp"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "qof.h"
|
||||
#include "engine/Account.h"
|
||||
#include "engine/Transaction.h"
|
||||
#include "engine/Split.h"
|
||||
}
|
||||
|
||||
#include "gncmm/Split.hpp"
|
||||
#include "gnc/SplitListModel.hpp"
|
||||
#include "gnc/AccountItemModel.hpp"
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
class ViewletModel
|
||||
{
|
||||
public:
|
||||
ViewletModel();
|
||||
void defaultVGenerate(::Account * selectedAccount);
|
||||
void leftVGenerate(::Account * selectedAccount);
|
||||
void rightVGenerate(::Account *selectedAccount);
|
||||
|
||||
struct structViewletEntries
|
||||
{
|
||||
QString txnDate;
|
||||
bool isDateEqual;
|
||||
QString splitAccount;
|
||||
bool isSplitAccountEqual;
|
||||
QString txnDescription;
|
||||
QString splitAmount;
|
||||
};
|
||||
structViewletEntries tempEntry;
|
||||
QQueue<structViewletEntries> queueEntries;
|
||||
|
||||
private:
|
||||
SplitQList buildSplitListDateSort(::Account *selectedAccount);
|
||||
SplitQList buildSplitListDateSort(AccountQList accountsList);
|
||||
bool static lessThanByDate(::Split* a, ::Split* b);
|
||||
void buildMiniJournalStruct(SplitQList splitList);
|
||||
|
||||
};
|
||||
|
||||
} // END namespace gnc
|
||||
|
||||
#endif // VIEWLETMODEL_HPP
|
@ -1,371 +0,0 @@
|
||||
/********************************************************************\
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
#include "ViewletView.hpp"
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
ViewletView::ViewletView(QWidget * parent, QHBoxLayout * FPOlayout) :
|
||||
QWidget(parent)
|
||||
{
|
||||
viewletModel = new ViewletModel();
|
||||
}
|
||||
|
||||
/***** Public *****/
|
||||
|
||||
void
|
||||
ViewletView::defaultVSet(QWidget *parent, QHBoxLayout *FPOLayout)
|
||||
{
|
||||
/* For default viewlet */
|
||||
comboAccountsList = new QComboBox();
|
||||
comboAccountsList->addItem(tr("-NA-"));
|
||||
|
||||
connect(comboAccountsList, SIGNAL(currentIndexChanged(int)),
|
||||
this, SLOT(defaultVUpdate()));
|
||||
|
||||
/* Add a new QWidget (acts as a container for this viewlet) to the
|
||||
layout of QWidget (QDockWidget>QWidget, i.e, dockwFPO>dockcFPO)
|
||||
in dashboard QMainWindow.
|
||||
*/
|
||||
QWidget *viewletContainer = new QWidget;
|
||||
FPOLayout->addWidget(viewletContainer);
|
||||
|
||||
/* Set a layout for the container QWidget */
|
||||
QVBoxLayout *vLay = new QVBoxLayout;
|
||||
viewletContainer->setLayout(vLay);
|
||||
|
||||
/***** Start of viewlet specific implementations *****/
|
||||
/* Specification:
|
||||
This default viewlet contains two widgets, 1) An account
|
||||
selection widget, and 2) A scroll area which wraps a QWidget
|
||||
to show the entries.*/
|
||||
/** @bugid_1 1) Account selection feature of the viewlet */
|
||||
/*
|
||||
comboAccountsList = new QComboBox();
|
||||
comboAccountsList->addItem(tr("-NA-"));
|
||||
*/
|
||||
|
||||
vLay->addWidget(comboAccountsList);
|
||||
|
||||
/* 2) The actual viewlet display of account selected in 1) */
|
||||
QWidget *defaultViewletWidget = new QWidget();
|
||||
defaultVLayout = new QVBoxLayout();
|
||||
QScrollArea *viewletScrollArea = new QScrollArea();
|
||||
|
||||
viewletScrollArea->setWidget(defaultViewletWidget);
|
||||
viewletScrollArea->setAlignment(Qt::AlignLeft);
|
||||
viewletScrollArea->setWidgetResizable(true);
|
||||
defaultViewletWidget->setLayout(defaultVLayout);
|
||||
vLay->addWidget(viewletScrollArea);
|
||||
|
||||
//create viewlet
|
||||
if(comboAccountsList->currentIndex())
|
||||
{
|
||||
selectedAccountIndex = comboAccountsList->currentIndex();
|
||||
selectedAccount = accountsList->at(selectedAccountIndex);
|
||||
|
||||
viewletModel->defaultVGenerate(selectedAccount);
|
||||
defaultVDraw();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ViewletView::leftVSet(QWidget *parent, QHBoxLayout *FPOLayout)
|
||||
{
|
||||
connect(this, SIGNAL(fileLoaded()),
|
||||
this, SLOT(leftVLoad()));
|
||||
|
||||
//connect(comboAccountsList, SIGNAL(currentIndexChanged(int)),
|
||||
// this, SLOT(leftVUpdate()));
|
||||
|
||||
//not required. remove after cleaning loadAccountsTreeComboBox()
|
||||
comboAccountsList = new QComboBox();
|
||||
comboAccountsList->addItem(tr("-NA-"));
|
||||
|
||||
|
||||
QWidget *viewletContainer = new QWidget;
|
||||
FPOLayout->addWidget(viewletContainer);
|
||||
|
||||
QVBoxLayout *vLay = new QVBoxLayout;
|
||||
viewletContainer->setLayout(vLay);
|
||||
|
||||
QLabel *title = new QLabel(tr("Expense"));
|
||||
vLay->addWidget(title);
|
||||
|
||||
/* The actual viewlet display of account(s) chosen*/
|
||||
QWidget *defaultViewletWidget = new QWidget();
|
||||
defaultVLayout = new QVBoxLayout();
|
||||
QScrollArea *viewletScrollArea = new QScrollArea();
|
||||
|
||||
viewletScrollArea->setWidget(defaultViewletWidget);
|
||||
viewletScrollArea->setAlignment(Qt::AlignLeft);
|
||||
viewletScrollArea->setWidgetResizable(true);
|
||||
defaultViewletWidget->setLayout(defaultVLayout);
|
||||
vLay->addWidget(viewletScrollArea);
|
||||
|
||||
/*//create viewlet
|
||||
if(comboAccountsList->currentIndex())
|
||||
{
|
||||
selectedAccountIndex = comboAccountsList->currentIndex();
|
||||
selectedAccount = accountsList->at(selectedAccountIndex);
|
||||
|
||||
defaultVDraw();
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
ViewletView::rightVSet(QWidget *parent, QHBoxLayout *FPOLayout)
|
||||
{
|
||||
connect(this, SIGNAL(fileLoaded()),
|
||||
this, SLOT(rightVLoad()));
|
||||
|
||||
//connect(comboAccountsList, SIGNAL(currentIndexChanged(int)),
|
||||
// this, SLOT(leftVUpdate()));
|
||||
|
||||
//not required. remove after cleaning loadAccountsTreeComboBox()
|
||||
comboAccountsList = new QComboBox();
|
||||
comboAccountsList->addItem(tr("-NA-"));
|
||||
|
||||
|
||||
QWidget *viewletContainer = new QWidget;
|
||||
FPOLayout->addWidget(viewletContainer);
|
||||
|
||||
QVBoxLayout *vLay = new QVBoxLayout;
|
||||
viewletContainer->setLayout(vLay);
|
||||
|
||||
QLabel *title = new QLabel(tr("Income"));
|
||||
vLay->addWidget(title);
|
||||
|
||||
/* The actual viewlet display of account(s) chosen*/
|
||||
QWidget *defaultViewletWidget = new QWidget();
|
||||
defaultVLayout = new QVBoxLayout();
|
||||
QScrollArea *viewletScrollArea = new QScrollArea();
|
||||
|
||||
viewletScrollArea->setWidget(defaultViewletWidget);
|
||||
viewletScrollArea->setAlignment(Qt::AlignLeft);
|
||||
viewletScrollArea->setWidgetResizable(true);
|
||||
defaultViewletWidget->setLayout(defaultVLayout);
|
||||
vLay->addWidget(viewletScrollArea);
|
||||
|
||||
/*//create viewlet
|
||||
if(comboAccountsList->currentIndex())
|
||||
{
|
||||
selectedAccountIndex = comboAccountsList->currentIndex();
|
||||
selectedAccount = accountsList->at(selectedAccountIndex);
|
||||
|
||||
defaultVDraw();
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
/***** Private *****/
|
||||
|
||||
/** Create the widgets for the viewlet entries
|
||||
|
||||
Passes the selected account to the model. The updated textual
|
||||
data in the struct of the model is used in the newly created
|
||||
widgets.
|
||||
*/
|
||||
void
|
||||
ViewletView::defaultVDraw()
|
||||
{
|
||||
/* Update the struct in ViewletModel with data from the selected
|
||||
account
|
||||
*/
|
||||
|
||||
|
||||
int numOfTransactions = viewletModel->queueEntries.count();
|
||||
for (int i = 0; i < numOfTransactions; i++)
|
||||
{
|
||||
viewletModel->tempEntry = viewletModel->queueEntries.at(i);
|
||||
|
||||
//1 & 2
|
||||
if((!viewletModel->tempEntry.isDateEqual && !viewletModel->tempEntry.isSplitAccountEqual)
|
||||
|| (!viewletModel->tempEntry.isDateEqual && viewletModel->tempEntry.isSplitAccountEqual))
|
||||
{
|
||||
dateCheckOutput();
|
||||
accountCheckOutput();
|
||||
descriptionAmountOutput();
|
||||
}
|
||||
|
||||
//3
|
||||
if(viewletModel->tempEntry.isDateEqual && !viewletModel->tempEntry.isSplitAccountEqual)
|
||||
{
|
||||
accountCheckOutput();
|
||||
descriptionAmountOutput();
|
||||
}
|
||||
|
||||
//4
|
||||
if(viewletModel->tempEntry.isDateEqual && viewletModel->tempEntry.isSplitAccountEqual)
|
||||
{
|
||||
descriptionAmountOutput();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ViewletView::dateCheckOutput()
|
||||
{
|
||||
QWidget *dateLevelContainer = new QWidget();
|
||||
QVBoxLayout *dateLayout = new QVBoxLayout;
|
||||
dateLevelContainer->setLayout(dateLayout);
|
||||
|
||||
/* Append the pointer of this top level widget
|
||||
of the viewlet for later removal during update */
|
||||
viewletWidgetContainersList.append(dateLevelContainer);
|
||||
|
||||
defaultVLayout->addWidget(dateLevelContainer, 10, Qt::AlignTop);
|
||||
|
||||
txnDate = viewletModel->tempEntry.txnDate;
|
||||
setLabel(txnDate, "dateWidget", dateLayout);
|
||||
|
||||
QWidget *accountLevelContainer = new QWidget();
|
||||
accountLayout = new QVBoxLayout;
|
||||
accountLevelContainer->setLayout(accountLayout);
|
||||
dateLayout->addWidget(accountLevelContainer);
|
||||
}
|
||||
|
||||
void
|
||||
ViewletView::accountCheckOutput()
|
||||
{
|
||||
QWidget *singleAccountLevelContainer = new QWidget();
|
||||
QVBoxLayout *singleAccountLayout = new QVBoxLayout();
|
||||
singleAccountLevelContainer->setLayout(singleAccountLayout);
|
||||
|
||||
accountLayout->addWidget(singleAccountLevelContainer);
|
||||
|
||||
// 1
|
||||
splitAccount = viewletModel->tempEntry.splitAccount;
|
||||
setLabel(splitAccount, "accountWidget", singleAccountLayout);
|
||||
|
||||
QWidget *descriptionAmountLevelContainer = new QWidget();
|
||||
descriptionAmountLayout = new QVBoxLayout();
|
||||
descriptionAmountLevelContainer->setLayout(descriptionAmountLayout);
|
||||
|
||||
// 2
|
||||
singleAccountLayout->addWidget(descriptionAmountLevelContainer);
|
||||
}
|
||||
|
||||
void
|
||||
ViewletView::descriptionAmountOutput()
|
||||
{
|
||||
txnDescription = viewletModel->tempEntry.txnDescription;
|
||||
setLabel(txnDescription, "descWidget", descriptionAmountLayout);
|
||||
|
||||
splitAmount = viewletModel->tempEntry.splitAmount;
|
||||
setLabel(splitAmount, "amountWidget", descriptionAmountLayout);
|
||||
}
|
||||
|
||||
void
|
||||
ViewletView::defaultVRemoveWidgets()
|
||||
{
|
||||
/* Remove old widgets. */
|
||||
int numOfContainers = viewletWidgetContainersList.count();
|
||||
for (int i=0; i<numOfContainers; i++)
|
||||
{
|
||||
delete viewletWidgetContainersList.at(i);
|
||||
}
|
||||
|
||||
/* Empty the data structures */
|
||||
viewletModel->queueEntries.clear();
|
||||
viewletWidgetContainersList.clear();
|
||||
}
|
||||
|
||||
/**********/
|
||||
|
||||
void
|
||||
ViewletView::setLabel(QString data, QString objectName, QVBoxLayout *layout)
|
||||
{
|
||||
QLabel *lbl = new QLabel();
|
||||
lbl->setText(data);
|
||||
layout->addWidget(lbl);
|
||||
/* Used as CSS ID by QStyleSheet */
|
||||
lbl->setObjectName(objectName);
|
||||
viewletWidgetsList.append(lbl);
|
||||
}
|
||||
|
||||
void
|
||||
ViewletView::loadAccountsTreeComboBox(AccountListModel * const m_accountsListModel)
|
||||
{
|
||||
accountsList = m_accountsListModel;
|
||||
comboAccountsList->setModel(accountsList);
|
||||
Q_EMIT fileLoaded();
|
||||
}
|
||||
|
||||
/***** Slots *****/
|
||||
|
||||
void
|
||||
ViewletView::defaultVUpdate()
|
||||
{
|
||||
selectedAccountIndex = comboAccountsList->currentIndex();
|
||||
selectedAccount = accountsList->at(selectedAccountIndex);
|
||||
|
||||
defaultVRemoveWidgets();
|
||||
viewletModel->defaultVGenerate(selectedAccount);
|
||||
defaultVDraw();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ViewletView::leftVUpdate()
|
||||
{
|
||||
selectedAccountIndex = comboAccountsList->currentIndex();
|
||||
selectedAccount = accountsList->at(selectedAccountIndex);
|
||||
|
||||
//Call this in dboard gnc event switch
|
||||
defaultVRemoveWidgets();
|
||||
viewletModel->leftVGenerate(selectedAccount);
|
||||
defaultVDraw();
|
||||
}
|
||||
|
||||
void
|
||||
ViewletView::leftVLoad()
|
||||
{
|
||||
selectedAccount = accountsList->at(1);
|
||||
defaultVRemoveWidgets();
|
||||
viewletModel->leftVGenerate(selectedAccount);
|
||||
defaultVDraw();
|
||||
}
|
||||
|
||||
void
|
||||
ViewletView::rightVUpdate()
|
||||
{
|
||||
selectedAccountIndex = comboAccountsList->currentIndex();
|
||||
selectedAccount = accountsList->at(selectedAccountIndex);
|
||||
|
||||
//Call this in dboard gnc event switch
|
||||
defaultVRemoveWidgets();
|
||||
viewletModel->rightVGenerate(selectedAccount);
|
||||
defaultVDraw();
|
||||
}
|
||||
|
||||
void
|
||||
ViewletView::rightVLoad()
|
||||
{
|
||||
selectedAccount = accountsList->at(1);
|
||||
defaultVRemoveWidgets();
|
||||
viewletModel->rightVGenerate(selectedAccount);
|
||||
defaultVDraw();
|
||||
}
|
||||
|
||||
} // END namespace gnc
|
||||
|
@ -1,102 +0,0 @@
|
||||
#ifndef VIEWLETVIEW_HPP
|
||||
#define VIEWLETVIEW_HPP
|
||||
|
||||
#include "config.h"
|
||||
#include "engine/guid.hpp"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "qof.h"
|
||||
#include "engine/Account.h"
|
||||
#include "engine/Transaction.h"
|
||||
#include "engine/Split.h"
|
||||
}
|
||||
|
||||
#include "gnc/mainwindow.hpp"
|
||||
#include "gnc/fpo/ViewletModel.hpp"
|
||||
#include "gnc/AccountItemModel.hpp"
|
||||
#include "gnc/SplitListModel.hpp"
|
||||
|
||||
#include <QtCore>
|
||||
#include <QAbstractItemModel>
|
||||
#include <QtGui>
|
||||
#include <QWidget>
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
class ViewletModel;
|
||||
|
||||
class ViewletView : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ViewletView(QWidget * parent = 0, QHBoxLayout * FPOLayout = NULL);
|
||||
void loadAccountsTreeComboBox(AccountListModel * const m_accountsListModel);
|
||||
|
||||
/* Call the appropriate method to set the viewlet of that type */
|
||||
void defaultVSet(QWidget * parent, QHBoxLayout * FPOLayout);
|
||||
void leftVSet(QWidget * parent, QHBoxLayout * FPOLayout);
|
||||
void rightVSet(QWidget * parent, QHBoxLayout * FPOLayout);
|
||||
|
||||
void leftVUpdate();
|
||||
void rightVUpdate();
|
||||
|
||||
Q_SIGNALS:
|
||||
void fileLoaded();
|
||||
|
||||
public Q_SLOTS:
|
||||
void defaultVUpdate();
|
||||
|
||||
private:
|
||||
ViewletModel *viewletModel;
|
||||
AccountListModel *accountsList;
|
||||
|
||||
QString txnDate;
|
||||
QString txnDescription;
|
||||
QString splitAccount;
|
||||
QString splitAmount;
|
||||
|
||||
QVBoxLayout *defaultVLayout;
|
||||
QVBoxLayout *leftVLayout;
|
||||
QVBoxLayout *rightVLayout;
|
||||
|
||||
QVBoxLayout *accountLayout;
|
||||
QVBoxLayout *descriptionAmountLayout;
|
||||
|
||||
/* A simple list to store widgets generated by any of the three
|
||||
viewlet types. When the viewlet updates, a new viewlet could
|
||||
be drawn by first removing the old widgets in this list. */
|
||||
QList<QWidget *> viewletWidgetsList;
|
||||
QList<QWidget *> viewletWidgetContainersList;
|
||||
|
||||
/** @bugid_1 */
|
||||
QComboBox * comboAccountsList;
|
||||
|
||||
/** @todo */
|
||||
::SplitList * pSplitList;
|
||||
::Account * selectedAccount;
|
||||
int selectedAccountIndex;
|
||||
|
||||
/* Widget generator */
|
||||
void setLabel(QString data, QString objectName, QVBoxLayout *layout);
|
||||
|
||||
/* Viewlet generator methods */
|
||||
void defaultVDraw();
|
||||
void defaultVRemoveWidgets();
|
||||
//void leftVDraw();
|
||||
void leftVRemoveWidgets();
|
||||
//void rightVDraw();
|
||||
void rightVRemoveWidgets();
|
||||
|
||||
void dateCheckOutput();
|
||||
void accountCheckOutput();
|
||||
void descriptionAmountOutput();
|
||||
|
||||
private Q_SLOTS:
|
||||
void leftVLoad();
|
||||
void rightVLoad();
|
||||
};
|
||||
|
||||
} // END namespace gnc
|
||||
|
||||
#endif // VIEWLETVIEW_HPP
|
@ -1,21 +0,0 @@
|
||||
<!DOCTYPE RCC>
|
||||
<RCC version="1.0">
|
||||
<qresource prefix="/pixmaps">
|
||||
<file alias="gnc-account-delete.png">../pixmaps/hicolor/24x24/actions/gnc-account-delete.png</file>
|
||||
<file alias="gnc-account-edit.png">../pixmaps/hicolor/24x24/actions/gnc-account-edit.png</file>
|
||||
<file alias="gnc-account-new.png">../pixmaps/hicolor/24x24/actions/gnc-account-new.png</file>
|
||||
<file alias="gnc-account-open.png">../pixmaps/hicolor/24x24/actions/gnc-account-open.png</file>
|
||||
<file alias="gnc-account.png">../pixmaps/hicolor/24x24/actions/gnc-account.png</file>
|
||||
<file alias="gnc-invoice-edit.png">../pixmaps/hicolor/24x24/actions/gnc-invoice-edit.png</file>
|
||||
<file alias="gnc-invoice.png">../pixmaps/hicolor/24x24/actions/gnc-invoice.png</file>
|
||||
<file alias="gnc-invoice-post.png">../pixmaps/hicolor/24x24/actions/gnc-invoice-post.png</file>
|
||||
<file alias="gnc-invoice-unpost.png">../pixmaps/hicolor/24x24/actions/gnc-invoice-unpost.png</file>
|
||||
<file alias="gnc-jumpto.png">../pixmaps/hicolor/24x24/actions/gnc-jumpto.png</file>
|
||||
<file alias="gnc-split-trans.png">../pixmaps/hicolor/24x24/actions/gnc-split-trans.png</file>
|
||||
<file alias="gnc-sx-new.png">../pixmaps/hicolor/24x24/actions/gnc-sx-new.png</file>
|
||||
<file alias="gnc-transfer.png">../pixmaps/hicolor/24x24/actions/gnc-transfer.png</file>
|
||||
<file alias="gnucash-icon-48x48.png">../pixmaps/hicolor/24x24/actions/gnucash-icon.png</file>
|
||||
<file alias="gnucash-icon-64x64.png">../pixmaps/hicolor/24x24/actions/gnucash-icon.png</file>
|
||||
<file alias="gnucash_splash.png">../pixmaps/gnucash_splash.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
@ -1,16 +0,0 @@
|
||||
<RCC>
|
||||
<qresource>
|
||||
<file>gtk-icons/gtk-about.png</file>
|
||||
<file>gtk-icons/gtk-close.png</file>
|
||||
<file>gtk-icons/gtk-copy.png</file>
|
||||
<file>gtk-icons/gtk-cut.png</file>
|
||||
<file>gtk-icons/gtk-new.png</file>
|
||||
<file>gtk-icons/gtk-open.png</file>
|
||||
<file>gtk-icons/gtk-paste.png</file>
|
||||
<file>gtk-icons/gtk-quit.png</file>
|
||||
<file>gtk-icons/gtk-redo.png</file>
|
||||
<file>gtk-icons/gtk-save-as.png</file>
|
||||
<file>gtk-icons/gtk-save.png</file>
|
||||
<file>gtk-icons/gtk-undo.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
Before Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 567 B |
Before Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 971 B |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 3.7 KiB |
@ -1,35 +0,0 @@
|
||||
[Icon Theme]
|
||||
Name=Oxygen
|
||||
|
||||
Comment=Oxygen Team
|
||||
|
||||
DisplayDepth=32
|
||||
|
||||
Inherits=hicolor
|
||||
|
||||
Example=folder
|
||||
|
||||
LinkOverlay=link
|
||||
LockOverlay=lockoverlay
|
||||
ShareOverlay=share
|
||||
ZipOverlay=zip
|
||||
|
||||
DesktopDefault=48
|
||||
DesktopSizes=16,22,32,48,64,128,256
|
||||
ToolbarDefault=22
|
||||
ToolbarSizes=16,22,32,48
|
||||
MainToolbarDefault=22
|
||||
MainToolbarSizes=16,22,32,48
|
||||
SmallDefault=16
|
||||
SmallSizes=16,22,32,48
|
||||
PanelDefault=32
|
||||
PanelSizes=16,22,32,48,64,128,256
|
||||
DialogDefault=32
|
||||
DialogSizes=16,22,32,48,64,128,256
|
||||
|
||||
Directories=48x48/actions
|
||||
|
||||
[48x48/actions]
|
||||
Size=48
|
||||
Context=Actions
|
||||
Type=Threshold
|
221
src/gnc/main.cpp
@ -1,221 +0,0 @@
|
||||
/*
|
||||
* main.cpp -- The program entry point for cutecash
|
||||
*
|
||||
* Copyright (C) 2006 Chris Shoemaker <c.shoemaker@cox.net>
|
||||
* Copyright (C) 2010 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <glib.h>
|
||||
#include <libguile.h>
|
||||
#include "engine/guid.hpp"
|
||||
extern "C"
|
||||
{
|
||||
#include "gnc-module/gnc-module.h"
|
||||
#include "core-utils/gnc-path.h"
|
||||
#include "core-utils/binreloc.h"
|
||||
/* #include "gnc-version.h" */
|
||||
#include "engine/gnc-engine.h"
|
||||
#include "core-utils/gnc-filepath-utils.h"
|
||||
#include "engine/gnc-hooks.h"
|
||||
#include "engine/gnc-commodity.h"
|
||||
#include "core-utils/gnc-prefs.h"
|
||||
#include "engine/gnc-session.h"
|
||||
#include "engine/engine-helpers.h"
|
||||
#include "engine/gnc-engine.h"
|
||||
#include "app-utils/gnc-ui-util.h" // for gnc_ui_util_init()
|
||||
#include "app-utils/gnc-exp-parser.h" // for gnc_exp_parser_init()
|
||||
#include "swig-runtime.h"
|
||||
|
||||
#include "backend/xml/gnc-backend-xml.h"
|
||||
#ifdef WITH_SQL
|
||||
# include "backend/dbi/gnc-backend-dbi.h"
|
||||
#endif
|
||||
} // END extern C
|
||||
|
||||
#ifdef HAVE_GETTEXT
|
||||
# include <libintl.h>
|
||||
# include <locale.h>
|
||||
#endif
|
||||
|
||||
// Glibmm includes
|
||||
#include <glibmm.h>
|
||||
#include "gncmm/wrap_init.hpp"
|
||||
|
||||
// Qt includes
|
||||
#include <QApplication>
|
||||
#include "mainwindow.hpp"
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
#define APP_GNUCASH "/apps/gnucash"
|
||||
|
||||
/* GNUCASH_SCM is defined whenever we're building from an svn/svk/git/bzr tree */
|
||||
#ifdef GNUCASH_SCM
|
||||
static int is_development_version = TRUE;
|
||||
#else
|
||||
static int is_development_version = FALSE;
|
||||
#endif
|
||||
|
||||
static gchar **log_flags = NULL;
|
||||
static gchar *log_to_filename = NULL;
|
||||
|
||||
static void
|
||||
gnc_log_init()
|
||||
{
|
||||
if (log_to_filename != NULL)
|
||||
{
|
||||
qof_log_init_filename_special(log_to_filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* initialize logging to our file. */
|
||||
gchar *tracefilename;
|
||||
tracefilename = g_build_filename(g_get_tmp_dir(), "gnucash.trace",
|
||||
(gchar *)NULL);
|
||||
qof_log_init_filename(tracefilename);
|
||||
g_free(tracefilename);
|
||||
}
|
||||
|
||||
// set a reasonable default.
|
||||
qof_log_set_default(QOF_LOG_WARNING);
|
||||
|
||||
gnc_log_default();
|
||||
|
||||
if (gnc_prefs_is_debugging_enabled())
|
||||
{
|
||||
qof_log_set_level("", QOF_LOG_INFO);
|
||||
qof_log_set_level("qof", QOF_LOG_INFO);
|
||||
qof_log_set_level("gnc", QOF_LOG_INFO);
|
||||
}
|
||||
|
||||
{
|
||||
gchar *log_config_filename;
|
||||
log_config_filename = gnc_build_dotgnucash_path("log.conf");
|
||||
if (g_file_test(log_config_filename, G_FILE_TEST_EXISTS))
|
||||
qof_log_parse_log_config(log_config_filename);
|
||||
g_free(log_config_filename);
|
||||
}
|
||||
|
||||
if (log_flags != NULL)
|
||||
{
|
||||
int i = 0;
|
||||
for (; log_flags[i] != NULL; i++)
|
||||
{
|
||||
QofLogLevel level;
|
||||
gchar **parts = NULL;
|
||||
|
||||
gchar *log_opt = log_flags[i];
|
||||
parts = g_strsplit(log_opt, "=", 2);
|
||||
if (parts == NULL || parts[0] == NULL || parts[1] == NULL)
|
||||
{
|
||||
g_warning("string [%s] not parseable", log_opt);
|
||||
continue;
|
||||
}
|
||||
|
||||
level = qof_log_level_from_string(parts[1]);
|
||||
qof_log_set_level(parts[0], level);
|
||||
g_strfreev(parts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // END namespace gnc
|
||||
|
||||
int
|
||||
main(int argc, char ** argv)
|
||||
{
|
||||
#if !defined(G_THREADS_ENABLED) || defined(G_THREADS_IMPL_NONE)
|
||||
# error "No GLib thread implementation available!"
|
||||
#endif
|
||||
g_thread_init(NULL);
|
||||
|
||||
QApplication app(argc, argv);
|
||||
|
||||
// Binreloc is initialized by the Qt exe path lookup.
|
||||
gnc_gbr_set_exe(QCoreApplication::applicationFilePath().toUtf8());
|
||||
|
||||
#ifdef HAVE_GETTEXT
|
||||
{
|
||||
gchar *localedir = gnc_path_get_localedir();
|
||||
/* setlocale(LC_ALL, ""); is already called by gtk_set_locale()
|
||||
via gtk_init(). */
|
||||
bindtextdomain(GETTEXT_PACKAGE, localedir);
|
||||
textdomain(GETTEXT_PACKAGE);
|
||||
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
|
||||
g_free(localedir);
|
||||
}
|
||||
#endif
|
||||
|
||||
qof_log_init();
|
||||
qof_log_set_default(QOF_LOG_INFO);
|
||||
|
||||
gnc::gnc_log_init();
|
||||
|
||||
qof_init();
|
||||
gnc_module_system_init();
|
||||
gnc_engine_init_static(argc, argv);
|
||||
|
||||
// Initialize glibmm
|
||||
Glib::init();
|
||||
gnc::wrap_init();
|
||||
|
||||
// Call the statically-linked versions of the backend init
|
||||
// functions
|
||||
gnc_module_init_backend_xml();
|
||||
#ifdef WITH_SQL
|
||||
gnc_module_init_backend_dbi();
|
||||
#endif
|
||||
gnc_ui_util_init();
|
||||
gnc_exp_parser_init();
|
||||
|
||||
int r;
|
||||
{
|
||||
// From here on the new C++ code
|
||||
gnc::MainWindow mainWin;
|
||||
mainWin.show();
|
||||
|
||||
/* set stylesheet */
|
||||
QFile styleSheetFile(":/qss-default");
|
||||
styleSheetFile.open(QFile::ReadOnly);
|
||||
QString styleSheetName = QLatin1String(styleSheetFile.readAll());
|
||||
app.setStyleSheet(styleSheetName);
|
||||
|
||||
// Go into the main qt event loop
|
||||
r = app.exec();
|
||||
|
||||
// Destruction of the MainWindow will trigger all the C++
|
||||
// destructors
|
||||
}
|
||||
|
||||
// Shutdown of the C side after all C++ was destructed already.
|
||||
gnc_exp_parser_shutdown();
|
||||
#ifdef WITH_SQL
|
||||
gnc_module_finalize_backend_dbi();
|
||||
#endif
|
||||
qof_close();
|
||||
return r;
|
||||
|
||||
}
|
@ -1,763 +0,0 @@
|
||||
/*
|
||||
* mainwindow-file.cpp
|
||||
* Copyright (C) 2010 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtGui/QCloseEvent>
|
||||
#include <QtGui/QFileDialog>
|
||||
#include <QtGui/QMessageBox>
|
||||
#include <QtGui/QProgressBar>
|
||||
#include <QtGui/QPushButton>
|
||||
#include <QtGui/QToolBar>
|
||||
#include <QtGui/QUndoStack>
|
||||
#include <QDebug>
|
||||
|
||||
#include "config.h"
|
||||
#include "mainwindow.hpp"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
// gnucash includes
|
||||
#include <glib/gi18n.h>
|
||||
extern "C"
|
||||
{
|
||||
#include "qof.h"
|
||||
#include "engine/gnc-hooks.h"
|
||||
#include "core-utils/gnc-uri-utils.h"
|
||||
#include "engine/Account.h"
|
||||
#include "engine/TransLog.h"
|
||||
}
|
||||
|
||||
#include "gncmm/Account.hpp"
|
||||
#include "gnc/AccountItemModel.hpp"
|
||||
#include "gncmm/Book.hpp"
|
||||
#include "gncmm/Numeric.hpp"
|
||||
#include "gncmm/Split.hpp"
|
||||
#include "gnc/SplitListModel.hpp"
|
||||
#include "gnc/RecentFileMenu.hpp"
|
||||
|
||||
/* Temp solution for accounts list */
|
||||
#include "gnc/fpo/ViewletView.hpp"
|
||||
|
||||
#include "gnc/Cmd.hpp"
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
inline QString errorToString(QofBackendError err)
|
||||
{
|
||||
return errorToStringPair(err).first;
|
||||
}
|
||||
inline QString errorToDescription(QofBackendError err)
|
||||
{
|
||||
return errorToStringPair(err).second;
|
||||
}
|
||||
|
||||
/* This static indicates the debugging module that this .o belongs to. */
|
||||
static QofLogModule log_module = GNC_MOD_GUI;
|
||||
static const char* PROPERTY_TAB_PREVIOUSPOS = "tab_previouspos";
|
||||
static gint save_in_progress = 0;
|
||||
|
||||
// ////////////////////////////////////////////////////////////
|
||||
|
||||
bool MainWindow::show_session_error (QWidget *parent,
|
||||
::QofBackendError io_error,
|
||||
const QString& filename,
|
||||
GNCFileDialogType type)
|
||||
{
|
||||
bool should_abort = true;
|
||||
QString fmt;
|
||||
|
||||
switch (io_error)
|
||||
{
|
||||
case ERR_BACKEND_NO_ERR:
|
||||
should_abort = FALSE;
|
||||
break;
|
||||
|
||||
case ERR_BACKEND_NO_HANDLER:
|
||||
QMessageBox::critical(parent, tr("Error"),
|
||||
tr("No suitable backend was found for %1.").arg(filename));
|
||||
break;
|
||||
|
||||
case ERR_BACKEND_NO_BACKEND:
|
||||
QMessageBox::critical(parent, tr("Error"),
|
||||
tr("The URL %1 is not supported by this version of GnuCash.").arg(filename));
|
||||
break;
|
||||
|
||||
case ERR_BACKEND_BAD_URL:
|
||||
QMessageBox::critical(parent, tr("Error"),
|
||||
tr("Can't parse the URL %1.").arg(filename));
|
||||
break;
|
||||
|
||||
case ERR_BACKEND_CANT_CONNECT:
|
||||
QMessageBox::critical(parent, tr("Error"),
|
||||
tr("Can't connect to %1. "
|
||||
"The host, username or password were incorrect.").arg(filename));
|
||||
break;
|
||||
|
||||
case ERR_BACKEND_CONN_LOST:
|
||||
QMessageBox::critical(parent, tr("Error"),
|
||||
tr("Can't connect to %1. "
|
||||
"Connection was lost, unable to send data.").arg(filename));
|
||||
break;
|
||||
|
||||
case ERR_BACKEND_TOO_NEW:
|
||||
QMessageBox::critical(parent, tr("Error"),
|
||||
tr("This file/URL appears to be from a newer version "
|
||||
"of GnuCash. You must upgrade your version of GnuCash "
|
||||
"to work with this data."));
|
||||
break;
|
||||
|
||||
case ERR_BACKEND_NO_SUCH_DB:
|
||||
if (QMessageBox::question(parent, tr("Create New File?"),
|
||||
tr("The database %1 doesn't seem to exist. "
|
||||
"Do you want to create it?").arg(filename),
|
||||
QMessageBox::Ok | QMessageBox::Cancel)
|
||||
== QMessageBox::Ok)
|
||||
{
|
||||
should_abort = false;
|
||||
}
|
||||
break;
|
||||
|
||||
case ERR_BACKEND_LOCKED:
|
||||
switch (type)
|
||||
{
|
||||
case GNC_FILE_DIALOG_OPEN:
|
||||
default:
|
||||
fmt = tr("GnuCash could not obtain the lock for %1. "
|
||||
"That database may be in use by another user, "
|
||||
"in which case you should not open the database. "
|
||||
"Do you want to proceed with opening the database?");
|
||||
break;
|
||||
|
||||
case GNC_FILE_DIALOG_IMPORT:
|
||||
fmt = tr("GnuCash could not obtain the lock for %1. "
|
||||
"That database may be in use by another user, "
|
||||
"in which case you should not import the database. "
|
||||
"Do you want to proceed with importing the database?");
|
||||
break;
|
||||
|
||||
case GNC_FILE_DIALOG_SAVE:
|
||||
fmt = tr("GnuCash could not obtain the lock for %1. "
|
||||
"That database may be in use by another user, "
|
||||
"in which case you should not save the database. "
|
||||
"Do you want to proceed with saving the database?");
|
||||
break;
|
||||
|
||||
case GNC_FILE_DIALOG_EXPORT:
|
||||
fmt = tr("GnuCash could not obtain the lock for %1. "
|
||||
"That database may be in use by another user, "
|
||||
"in which case you should not export the database. "
|
||||
"Do you want to proceed with exporting the database?");
|
||||
break;
|
||||
}
|
||||
|
||||
if (QMessageBox::question(parent, tr("Create New File?"),
|
||||
tr("The database %1 doesn't seem to exist. "
|
||||
"Do you want to create it?").arg(filename),
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
|
||||
== QMessageBox::Yes)
|
||||
{
|
||||
should_abort = false;
|
||||
}
|
||||
break;
|
||||
|
||||
case ERR_BACKEND_READONLY:
|
||||
QMessageBox::critical(parent, tr("Error"),
|
||||
tr("GnuCash could not write to %1. "
|
||||
"That database may be on a read-only file system, "
|
||||
"or you may not have write permission for the directory.").arg(filename));
|
||||
break;
|
||||
|
||||
case ERR_BACKEND_DATA_CORRUPT:
|
||||
QMessageBox::critical(parent, tr("Error"),
|
||||
tr("The file/URL %1 "
|
||||
"does not contain GnuCash data or the data is corrupt.").arg(filename));
|
||||
break;
|
||||
|
||||
case ERR_BACKEND_SERVER_ERR:
|
||||
QMessageBox::critical(parent, tr("Error"),
|
||||
tr("The server at URL %1 "
|
||||
"experienced an error or encountered bad or corrupt data.").arg(filename));
|
||||
break;
|
||||
|
||||
case ERR_BACKEND_PERM:
|
||||
QMessageBox::critical(parent, tr("Error"),
|
||||
tr("You do not have permission to access %1.").arg(filename));
|
||||
break;
|
||||
|
||||
case ERR_BACKEND_MISC:
|
||||
QMessageBox::critical(parent, tr("Error"),
|
||||
tr("An error occurred while processing %1.").arg(filename));
|
||||
break;
|
||||
|
||||
|
||||
case ERR_FILEIO_FILE_BAD_READ:
|
||||
if (QMessageBox::question(parent, tr("Continue?"),
|
||||
tr("There was an error reading the file. "
|
||||
"Do you want to continue?"),
|
||||
QMessageBox::Ok | QMessageBox::Cancel)
|
||||
== QMessageBox::Ok)
|
||||
{
|
||||
should_abort = false;
|
||||
}
|
||||
break;
|
||||
|
||||
case ERR_FILEIO_PARSE_ERROR:
|
||||
QMessageBox::critical(parent, tr("Error"),
|
||||
tr("There was an error parsing the file %1.").arg(filename));
|
||||
break;
|
||||
|
||||
case ERR_FILEIO_FILE_EMPTY:
|
||||
QMessageBox::critical(parent, tr("Error"),
|
||||
tr("The file %1 is empty.").arg(filename));
|
||||
break;
|
||||
|
||||
case ERR_FILEIO_FILE_NOT_FOUND:
|
||||
if (type == GNC_FILE_DIALOG_SAVE)
|
||||
{
|
||||
should_abort = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::critical(parent, tr("Error"),
|
||||
tr("The file %1 could not be found.").arg(filename));
|
||||
}
|
||||
break;
|
||||
|
||||
case ERR_FILEIO_FILE_TOO_OLD:
|
||||
if (QMessageBox::question(parent, tr("Continue?"),
|
||||
tr("This file is from an older version of GnuCash. "
|
||||
"Do you want to continue?"),
|
||||
QMessageBox::Ok | QMessageBox::Cancel)
|
||||
== QMessageBox::Ok)
|
||||
{
|
||||
should_abort = false;
|
||||
}
|
||||
break;
|
||||
|
||||
case ERR_FILEIO_UNKNOWN_FILE_TYPE:
|
||||
QMessageBox::critical(parent, tr("Error"),
|
||||
tr("The file type of file %1 is unknown.").arg(filename));
|
||||
break;
|
||||
|
||||
case ERR_FILEIO_BACKUP_ERROR:
|
||||
QMessageBox::critical(parent, tr("Error"),
|
||||
tr("Could not make a backup of the file %1").arg(filename));
|
||||
break;
|
||||
|
||||
case ERR_FILEIO_WRITE_ERROR:
|
||||
QMessageBox::critical(parent, tr("Error"),
|
||||
tr("Could not write to file %1. Check that you have "
|
||||
"permission to write to this file and that "
|
||||
"there is sufficient space to create it.").arg(filename));
|
||||
break;
|
||||
|
||||
case ERR_FILEIO_FILE_EACCES:
|
||||
QMessageBox::critical(parent, tr("Error"),
|
||||
tr("No read permission to read from file %1.").arg(filename));
|
||||
break;
|
||||
|
||||
case ERR_SQL_DB_TOO_OLD:
|
||||
if (QMessageBox::question(parent, tr("Upgrade Database?"),
|
||||
tr("This database is from an older version of GnuCash. "
|
||||
"Do you want to want to upgrade the database "
|
||||
"to the current version?"),
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
|
||||
== QMessageBox::Yes)
|
||||
{
|
||||
should_abort = false;
|
||||
}
|
||||
break;
|
||||
|
||||
case ERR_SQL_DB_BUSY:
|
||||
QMessageBox::critical(parent, tr("Error"),
|
||||
tr("The SQL database is in use by other users, "
|
||||
"and the upgrade cannot be performed until they logoff. "
|
||||
"If there are currently no other users, consult the "
|
||||
"documentation to learn how to clear out dangling login "
|
||||
"sessions."));
|
||||
break;
|
||||
|
||||
default:
|
||||
PERR("FIXME: Unhandled error %d", io_error);
|
||||
QMessageBox::critical(parent, tr("Error"),
|
||||
tr("An unknown I/O error (%1) occurred.").arg(int(io_error)));
|
||||
break;
|
||||
}
|
||||
|
||||
return should_abort;
|
||||
}
|
||||
|
||||
// ////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
static void
|
||||
gnc_book_opened (Session& sess)
|
||||
{
|
||||
gnc_hook_run(HOOK_BOOK_OPENED, sess.gobj());
|
||||
}
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
/** This is a workaround function object so that we can obtain a
|
||||
* QofPercentageFunc without extra boost::bind usage; obviously due to
|
||||
* the static member variable it will not work if multiple instances
|
||||
* are in use simultaneously */
|
||||
class progress_functor
|
||||
{
|
||||
public:
|
||||
progress_functor(QProgressBar *progressBar)
|
||||
{
|
||||
m_progressBar = progressBar;
|
||||
}
|
||||
~progress_functor()
|
||||
{
|
||||
m_progressBar = NULL;
|
||||
}
|
||||
static void static_func(const char *message, double percent)
|
||||
{
|
||||
assert(m_progressBar);
|
||||
m_progressBar->setValue(int(percent));
|
||||
// Give the Qt event loop some time
|
||||
qApp->processEvents();
|
||||
}
|
||||
private:
|
||||
static QProgressBar *m_progressBar;
|
||||
};
|
||||
QProgressBar *progress_functor::m_progressBar = NULL;
|
||||
|
||||
} // END namespace anonymous
|
||||
|
||||
|
||||
void MainWindow::loadFile(const QString &fileName)
|
||||
{
|
||||
if (fileName.isEmpty())
|
||||
return;
|
||||
|
||||
// copied from gnc_post_file_open, gnome-utils/gnc-file.c
|
||||
|
||||
QString newfile_qstring =
|
||||
g2q(gchar_to_ustring(gnc_uri_normalize_uri(fileName.toUtf8(), TRUE)));
|
||||
if (newfile_qstring.isEmpty())
|
||||
{
|
||||
show_session_error (this, ERR_FILEIO_FILE_NOT_FOUND, fileName,
|
||||
GNC_FILE_DIALOG_OPEN);
|
||||
return;
|
||||
}
|
||||
QByteArray newfile = newfile_qstring.toUtf8();
|
||||
|
||||
/* disable events while moving over to the new set of accounts;
|
||||
* the mass deletion of accounts and transactions during
|
||||
* switchover would otherwise cause excessive redraws. */
|
||||
qof_event_suspend ();
|
||||
|
||||
// Change the mouse to a busy cusor
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
|
||||
/* -------------- BEGIN CORE SESSION CODE ------------- */
|
||||
/* -- this code is almost identical in FileOpen and FileSaveAs -- */
|
||||
gnc_hook_run(HOOK_BOOK_CLOSED, m_session.gobj());
|
||||
qof_session_destroy(m_session.gobj());
|
||||
m_session.reset();
|
||||
|
||||
/* load the accounts from the users datafile */
|
||||
/* but first, check to make sure we've got a session going. */
|
||||
QofSession *new_session = qof_session_new ();
|
||||
|
||||
bool we_are_in_error = false;
|
||||
qof_session_begin (new_session, newfile, FALSE, FALSE, FALSE);
|
||||
QofBackendError io_err = qof_session_get_error (new_session);
|
||||
/* if file appears to be locked, ask the user ... */
|
||||
if (ERR_BACKEND_LOCKED == io_err || ERR_BACKEND_READONLY == io_err)
|
||||
{
|
||||
QString fmt1 = tr("GnuCash could not obtain the lock for %1. ").arg(fileName);
|
||||
QString fmt2 =
|
||||
((ERR_BACKEND_LOCKED == io_err)
|
||||
? tr("That database may be in use by another user, "
|
||||
"in which case you should not open the database. "
|
||||
"What would you like to do?")
|
||||
: tr("That database may be on a read-only file system, "
|
||||
"or you may not have write permission for the directory. "
|
||||
"If you proceed you may not be able to save any changes. "
|
||||
"What would you like to do?"));
|
||||
QMessageBox msgBox(this);
|
||||
msgBox.setWindowTitle(tr("Could not obtain file lock"));
|
||||
msgBox.setText(fmt1 + fmt2);
|
||||
QPushButton *openAnyway = msgBox.addButton(tr("&Open Anyway"), QMessageBox::ActionRole);
|
||||
QPushButton *createNewFile = msgBox.addButton(tr("&Create New File"), QMessageBox::ActionRole);
|
||||
QPushButton *close = msgBox.addButton(QMessageBox::Close);
|
||||
msgBox.exec();
|
||||
if (msgBox.clickedButton() == openAnyway)
|
||||
{
|
||||
/* user told us to ignore locks. So ignore them. */
|
||||
qof_session_begin (new_session, newfile, TRUE, FALSE, FALSE);
|
||||
}
|
||||
else if (msgBox.clickedButton() == createNewFile)
|
||||
{
|
||||
/* Can't use the given file, so just create a new
|
||||
* database so that the user will gobj a window that
|
||||
* they can click "Exit" on.
|
||||
*/
|
||||
newFile();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
qApp->quit();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* if the database doesn't exist, ask the user ... */
|
||||
else if ((ERR_BACKEND_NO_SUCH_DB == io_err) ||
|
||||
(ERR_SQL_DB_TOO_OLD == io_err))
|
||||
{
|
||||
if (false == show_session_error (this, io_err, newfile, GNC_FILE_DIALOG_OPEN))
|
||||
{
|
||||
/* user told us to create a new database. Do it. */
|
||||
qof_session_begin (new_session, newfile, FALSE, TRUE, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
/* Check for errors again, since above may have cleared the lock.
|
||||
* If its still locked, still, doesn't exist, still too old, then
|
||||
* don't bother with the message, just die. */
|
||||
io_err = qof_session_get_error (new_session);
|
||||
if ((ERR_BACKEND_LOCKED == io_err) ||
|
||||
(ERR_BACKEND_READONLY == io_err) ||
|
||||
(ERR_BACKEND_NO_SUCH_DB == io_err) ||
|
||||
(ERR_SQL_DB_TOO_OLD == io_err))
|
||||
{
|
||||
we_are_in_error = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
we_are_in_error = show_session_error (this, io_err, newfile, GNC_FILE_DIALOG_OPEN);
|
||||
}
|
||||
|
||||
if (!we_are_in_error)
|
||||
{
|
||||
xaccLogDisable();
|
||||
|
||||
{
|
||||
// Set up a progress bar in the statusBar()
|
||||
QProgressBar progressBar;
|
||||
progressBar.setMinimum(0);
|
||||
progressBar.setMaximum(100);
|
||||
statusBar()->showMessage(tr("Loading user data..."));
|
||||
statusBar()->addPermanentWidget(&progressBar);
|
||||
progressBar.show();
|
||||
// This local progress_functor is a workaround on how to
|
||||
// pass the suitable function pointer to session_load -
|
||||
// not very nice because of its static member, but it does
|
||||
// the trick for now.
|
||||
progress_functor functor(&progressBar);
|
||||
|
||||
// Do the loading.
|
||||
qof_session_load (new_session, &progress_functor::static_func);
|
||||
|
||||
// Remove the progress bar again from the status bar.
|
||||
statusBar()->removeWidget(&progressBar);
|
||||
}
|
||||
xaccLogEnable();
|
||||
|
||||
/* check for i/o error, put up appropriate error dialog */
|
||||
io_err = qof_session_get_error (new_session);
|
||||
|
||||
we_are_in_error = show_session_error(this, io_err, newfile, GNC_FILE_DIALOG_OPEN);
|
||||
|
||||
::Account* new_root_account = gnc_book_get_root_account (qof_session_get_book (new_session));
|
||||
if (we_are_in_error) new_root_account = NULL;
|
||||
|
||||
/* Umm, came up empty-handed, but no error:
|
||||
* The backend forgot to set an error. So make one up. */
|
||||
if (!we_are_in_error && !new_root_account)
|
||||
{
|
||||
we_are_in_error = show_session_error (this, ERR_BACKEND_MISC, newfile,
|
||||
GNC_FILE_DIALOG_OPEN);
|
||||
}
|
||||
}
|
||||
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
||||
/* going down -- abandon ship */
|
||||
if (we_are_in_error)
|
||||
{
|
||||
xaccLogDisable();
|
||||
qof_session_destroy (new_session);
|
||||
xaccLogEnable();
|
||||
|
||||
/* well, no matter what, I think it's a good idea to have a root
|
||||
* account around. For example, early in the gnucash startup
|
||||
* sequence, the user opens a file; if this open fails for any
|
||||
* reason, we don't want to leave them high & dry without a root
|
||||
* account, because if the user continues, then bad things will
|
||||
* happen. */
|
||||
new_session = qof_session_new ();
|
||||
m_session.reset(new_session);
|
||||
|
||||
qof_event_resume ();
|
||||
return;
|
||||
}
|
||||
|
||||
/* if we got to here, then we've successfully gotten a new session */
|
||||
/* close up the old file session (if any) */
|
||||
m_session.reset(new_session);
|
||||
|
||||
qof_event_resume ();
|
||||
|
||||
/* Call this after re-enabling events. */
|
||||
gnc_book_opened (m_session);
|
||||
|
||||
// ////////////////////////////////////////////////////////////
|
||||
// Some display about this file
|
||||
|
||||
Glib::RefPtr<Account> root (m_session.get_book()->get_root_account());
|
||||
if (root)
|
||||
{
|
||||
m_accountListModel = new AccountListModel(root, this);
|
||||
ui->tableView->setModel(m_accountListModel);
|
||||
|
||||
m_accountTreeModel = new AccountTreeModel(root, this);
|
||||
ui->treeView->setModel(m_accountTreeModel);
|
||||
/* Load the tree in combo boxes of dashboard */
|
||||
m_dboard->loadAccountsTreeComboBox(m_accountListModel);
|
||||
m_dboard->fpoWidget->defaultViewlet->loadAccountsTreeComboBox(m_accountListModel);
|
||||
m_dboard->fpoWidget->leftViewlet->loadAccountsTreeComboBox(m_accountListModel);
|
||||
m_dboard->fpoWidget->rightViewlet->loadAccountsTreeComboBox(m_accountListModel);
|
||||
|
||||
ui->treeViewTab->setProperty(PROPERTY_TAB_PREVIOUSPOS, ui->tabWidget->currentIndex());
|
||||
ui->tabWidget->setCurrentWidget(m_dboard);
|
||||
}
|
||||
else
|
||||
{
|
||||
//ui->labelMain->setText(tr("No root account"));
|
||||
}
|
||||
|
||||
// ////////////////////////////////////////////////////////////
|
||||
|
||||
setCurrentFile(fileName);
|
||||
statusBar()->showMessage(tr("File loaded"), 5000);
|
||||
}
|
||||
|
||||
|
||||
// ////////////////////////////////////////////////////////////
|
||||
|
||||
bool MainWindow::saveFileAs(const QString &fileName)
|
||||
{
|
||||
if (gnc_uri_is_file_uri(fileName.toUtf8()))
|
||||
{
|
||||
QFile file(g2q(gchar_to_ustring(gnc_uri_get_path(fileName.toUtf8()))));
|
||||
if (!file.open(QFile::WriteOnly))
|
||||
{
|
||||
QMessageBox::warning(this, tr("Application"),
|
||||
tr("Cannot write file %1:\n%2.")
|
||||
.arg(fileName)
|
||||
.arg(file.errorString()));
|
||||
return false;
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
|
||||
/* Check to see if the user specified the same file as the current
|
||||
* file. If so, then just do a simple save, instead of a full save as */
|
||||
/* FIXME Check if it is ok to have a password in the uri here */
|
||||
QString newfile_qstring =
|
||||
g2q(gchar_to_ustring(gnc_uri_normalize_uri ( fileName.toUtf8(), TRUE )));
|
||||
if (newfile_qstring.isEmpty())
|
||||
{
|
||||
show_session_error (this, ERR_FILEIO_FILE_NOT_FOUND, fileName,
|
||||
GNC_FILE_DIALOG_SAVE);
|
||||
return false;
|
||||
}
|
||||
QByteArray newfile = newfile_qstring.toUtf8();
|
||||
|
||||
QofSession *session = m_session.gobj();
|
||||
if (m_session.get_url() == fileName)
|
||||
{
|
||||
return saveFile();
|
||||
}
|
||||
|
||||
/* Make sure all of the data from the old file is loaded */
|
||||
qof_session_ensure_all_data_loaded(session);
|
||||
|
||||
/* -- this session code is NOT identical in FileOpen and FileSaveAs -- */
|
||||
|
||||
save_in_progress++;
|
||||
QofSession *new_session = qof_session_new ();
|
||||
qof_session_begin (new_session, newfile, FALSE, FALSE, FALSE);
|
||||
|
||||
QofBackendError io_err = qof_session_get_error (new_session);
|
||||
|
||||
/* if file appears to be locked, ask the user ... */
|
||||
if (ERR_BACKEND_LOCKED == io_err || ERR_BACKEND_READONLY == io_err)
|
||||
{
|
||||
if (false == show_session_error (this, io_err, newfile, GNC_FILE_DIALOG_SAVE))
|
||||
{
|
||||
/* user told us to ignore locks. So ignore them. */
|
||||
qof_session_begin (new_session, newfile, TRUE, FALSE, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
/* if the database doesn't exist, ask the user ... */
|
||||
else if ((ERR_FILEIO_FILE_NOT_FOUND == io_err) ||
|
||||
(ERR_BACKEND_NO_SUCH_DB == io_err) ||
|
||||
(ERR_SQL_DB_TOO_OLD == io_err))
|
||||
{
|
||||
if (false == show_session_error (this, io_err, newfile, GNC_FILE_DIALOG_SAVE))
|
||||
{
|
||||
/* user told us to create a new database. Do it. */
|
||||
qof_session_begin (new_session, newfile, FALSE, TRUE, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
/* check again for session errors (since above dialog may have
|
||||
* cleared a file lock & moved things forward some more)
|
||||
* This time, errors will be fatal.
|
||||
*/
|
||||
io_err = qof_session_get_error (new_session);
|
||||
if (ERR_BACKEND_NO_ERR != io_err)
|
||||
{
|
||||
show_session_error (this, io_err, newfile, GNC_FILE_DIALOG_SAVE);
|
||||
xaccLogDisable();
|
||||
qof_session_destroy (new_session);
|
||||
xaccLogEnable();
|
||||
save_in_progress--;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* oops ... file already exists ... ask user what to do... */
|
||||
if (false) //qof_session_save_may_clobber_data (new_session))
|
||||
// FIXME: Need to copy the other implementation from r19798 in
|
||||
// gnc-file.c for overwrite-on-existing-file.
|
||||
{
|
||||
if (QMessageBox::question(this, tr("File Exists"),
|
||||
tr("The file %1 already exists. "
|
||||
"Are you sure you want to overwrite it?").arg(fileName),
|
||||
QMessageBox::Yes | QMessageBox::No)
|
||||
!= QMessageBox::Yes)
|
||||
{
|
||||
/* if user says cancel, we should break out */
|
||||
xaccLogDisable();
|
||||
qof_session_destroy (new_session);
|
||||
xaccLogEnable();
|
||||
save_in_progress--;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Whoa-ok. Blow away the previous file. */
|
||||
}
|
||||
|
||||
|
||||
/* Prevent race condition between swapping the contents of the two
|
||||
* sessions, and actually installing the new session as the current
|
||||
* one. Any event callbacks that occur in this interval will have
|
||||
* problems if they check for the current book. */
|
||||
qof_event_suspend();
|
||||
|
||||
/* if we got to here, then we've successfully gotten a new session */
|
||||
/* close up the old file session (if any) */
|
||||
qof_session_swap_data (session, new_session);
|
||||
qof_session_destroy(m_session.gobj());
|
||||
m_session.reset();
|
||||
session = NULL;
|
||||
|
||||
/* XXX At this point, we should really mark the data in the new session
|
||||
* as being 'dirty', since we haven't saved it at all under the new
|
||||
* session. But I'm lazy...
|
||||
*/
|
||||
m_session.reset(new_session);
|
||||
|
||||
qof_event_resume();
|
||||
|
||||
/* --------------- END CORE SESSION CODE -------------- */
|
||||
|
||||
bool r = saveFile();
|
||||
|
||||
save_in_progress--;
|
||||
setCurrentFile(fileName);
|
||||
return r;
|
||||
}
|
||||
|
||||
static bool been_here_before = false;
|
||||
|
||||
bool MainWindow::saveFile()
|
||||
{
|
||||
/* hack alert -- Somehow make sure all in-progress edits gobj committed! */
|
||||
|
||||
/* If we don't have a filename/path to save to gobj one. */
|
||||
if (m_session.get_url().isEmpty())
|
||||
return on_actionSave_as_triggered();
|
||||
|
||||
/* use the current session to save to file */
|
||||
save_in_progress++;
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
|
||||
{
|
||||
// Set up a progress bar in the statusBar()
|
||||
QProgressBar progressBar;
|
||||
progressBar.setMinimum(0);
|
||||
progressBar.setMaximum(100);
|
||||
statusBar()->showMessage(tr("Saving user data..."));
|
||||
statusBar()->addPermanentWidget(&progressBar);
|
||||
progressBar.show();
|
||||
// A local progress_functor to pass the suitable function
|
||||
// pointer to session_load
|
||||
progress_functor functor(&progressBar);
|
||||
|
||||
// The actual saving
|
||||
qof_session_save (m_session.gobj(), &progress_functor::static_func);
|
||||
|
||||
// Remove the progress bar again from the status bar.
|
||||
statusBar()->removeWidget(&progressBar);
|
||||
}
|
||||
|
||||
// And saving is finished
|
||||
QApplication::restoreOverrideCursor();
|
||||
save_in_progress--;
|
||||
|
||||
|
||||
/* Make sure everything's OK - disk could be full, file could have
|
||||
become read-only etc. */
|
||||
QofBackendError io_err = m_session.get_error ();
|
||||
if (ERR_BACKEND_NO_ERR != io_err)
|
||||
{
|
||||
show_session_error (this, io_err, m_session.get_url(), GNC_FILE_DIALOG_SAVE);
|
||||
|
||||
if (been_here_before)
|
||||
return true;
|
||||
been_here_before = true;
|
||||
on_actionSave_as_triggered();
|
||||
/* been_here prevents infinite recursion */
|
||||
been_here_before = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
xaccReopenLog();
|
||||
gnc_hook_run(HOOK_BOOK_SAVED, m_session.gobj());
|
||||
|
||||
documentCleanStateChanged(true);
|
||||
statusBar()->showMessage(tr("File saved"), 5000);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // END namespace gnc
|
@ -1,633 +0,0 @@
|
||||
/*
|
||||
* mainwindow.cpp
|
||||
* Copyright (C) 2010 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtGui/QCloseEvent>
|
||||
#include <QtGui/QFileDialog>
|
||||
#include <QtGui/QMessageBox>
|
||||
#include <QtGui/QToolBar>
|
||||
#include <QtGui/QProgressBar>
|
||||
#include <QtGui/QUndoStack>
|
||||
#include <QDebug>
|
||||
|
||||
#include "config.h"
|
||||
#include "mainwindow.hpp"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
// gnucash includes
|
||||
#include <glib/gi18n.h>
|
||||
extern "C"
|
||||
{
|
||||
#include "qof.h"
|
||||
#include "engine/gnc-hooks.h"
|
||||
#include "core-utils/gnc-uri-utils.h"
|
||||
#include "engine/Account.h"
|
||||
#include "engine/TransLog.h"
|
||||
}
|
||||
|
||||
#include "gncmm/Account.hpp"
|
||||
#include "gnc/AccountItemModel.hpp"
|
||||
#include "gncmm/Book.hpp"
|
||||
#include "gncmm/Numeric.hpp"
|
||||
#include "gncmm/Split.hpp"
|
||||
#include "gnc/SplitListModel.hpp"
|
||||
#include "gnc/RecentFileMenu.hpp"
|
||||
#include "gnc/SplitListView.hpp"
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
inline QString errorToString(QofBackendError err)
|
||||
{
|
||||
return errorToStringPair(err).first;
|
||||
}
|
||||
inline QString errorToDescription(QofBackendError err)
|
||||
{
|
||||
return errorToStringPair(err).second;
|
||||
}
|
||||
|
||||
/* This static indicates the debugging module that this .o belongs to. */
|
||||
static QofLogModule log_module = GNC_MOD_GUI;
|
||||
|
||||
static const char* PROPERTY_TAB_LABEL = "tab_label";
|
||||
static const char* PROPERTY_TAB_POSITION = "tab_position";
|
||||
static const char* PROPERTY_TAB_ISCURRENT = "tab_iscurrent";
|
||||
static const char* PROPERTY_TAB_PREVIOUSPOS = "tab_previouspos";
|
||||
|
||||
// ////////////////////////////////////////////////////////////
|
||||
|
||||
MainWindow::MainWindow()
|
||||
: ui(new Ui::MainWindow)
|
||||
, m_menuRecentFiles(new RecentFileMenu(tr("Open &Recent")))
|
||||
, m_undoStack(new QUndoStack(this))
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
createActions();
|
||||
createToolBars();
|
||||
createStatusBar();
|
||||
setIcons();
|
||||
|
||||
m_dboard = new Dashboard(this);
|
||||
m_dboard->setWindowTitle("Dashboard");
|
||||
//m_dboard->show();
|
||||
ui->tabWidget->addTab(m_dboard, "Dashboard");
|
||||
|
||||
/* Properties used by QSettings */
|
||||
QCoreApplication::setOrganizationName("Gnucash");
|
||||
QCoreApplication::setOrganizationDomain("gnucash.org");
|
||||
QCoreApplication::setApplicationName("Cutecash");
|
||||
|
||||
readSettings();
|
||||
|
||||
connect(m_undoStack, SIGNAL(cleanChanged(bool)),
|
||||
this, SLOT(documentCleanStateChanged(bool)));
|
||||
connect(m_btnTransferFundsWidget, SIGNAL(toggled(bool)),
|
||||
m_dboard, SLOT(transferFundsWidgetButtonToggled(bool)));
|
||||
connect(this, SIGNAL(dashboardVisible(bool)),
|
||||
m_dboard, SLOT(transferFundsWidgetButtonToggled(bool)));
|
||||
|
||||
setWindowIcon(QIcon(":/pixmaps/gnucash-icon-64x64.png"));
|
||||
|
||||
/* Check if the system supports freedesktop standards for icons,
|
||||
* if not, then use the bundled icon set. */
|
||||
if (!QIcon::hasThemeIcon("document-open"))
|
||||
{
|
||||
QIcon::setThemeName("oxygen");
|
||||
}
|
||||
|
||||
newFile();
|
||||
setUnifiedTitleAndToolBarOnMac(true);
|
||||
|
||||
autoLoadRecentFile();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
if (m_session.gobj())
|
||||
{
|
||||
qof_session_destroy(m_session.gobj());
|
||||
m_session.reset();
|
||||
}
|
||||
}
|
||||
|
||||
// Auto-connected to ui->actionOpen's signal triggered()
|
||||
void MainWindow::on_actionOpen_triggered()
|
||||
{
|
||||
if (maybeSave())
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this);
|
||||
if (!fileName.isEmpty())
|
||||
loadFile(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::loadFileMaybe(const QString &fileName)
|
||||
{
|
||||
if (maybeSave())
|
||||
{
|
||||
loadFile(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Auto-connected to ui->actionSave's signal triggered()
|
||||
bool MainWindow::on_actionSave_triggered()
|
||||
{
|
||||
if (m_currentFilename.isEmpty())
|
||||
{
|
||||
return on_actionSave_as_triggered();
|
||||
}
|
||||
else
|
||||
{
|
||||
return saveFile();
|
||||
}
|
||||
}
|
||||
|
||||
// Auto-connected to ui->actionSave_as's signal triggered()
|
||||
bool MainWindow::on_actionSave_as_triggered()
|
||||
{
|
||||
QString fileName = QFileDialog::getSaveFileName(this);
|
||||
if (fileName.isEmpty())
|
||||
return false;
|
||||
|
||||
return saveFileAs(fileName);
|
||||
}
|
||||
|
||||
// Auto-connected to ui->actionAbout's signal triggered()
|
||||
void MainWindow::on_actionAbout_triggered()
|
||||
{
|
||||
QMessageBox::about(this, tr("About Application"),
|
||||
tr("This is a Gnucash C++ gui example, from the Qt4 Application example. It demonstrates how to "
|
||||
"write modern GUI applications using Qt, with a menu bar, "
|
||||
"toolbars, and a status bar."));
|
||||
}
|
||||
|
||||
void MainWindow::documentWasModified()
|
||||
{
|
||||
documentCleanStateChanged(false);
|
||||
}
|
||||
|
||||
void MainWindow::documentCleanStateChanged(bool documentIsClean)
|
||||
{
|
||||
bool unchanged = (documentIsClean == isWindowModified());
|
||||
|
||||
setWindowModified(!documentIsClean);
|
||||
if (!unchanged)
|
||||
updateWindowTitle();
|
||||
}
|
||||
|
||||
// Auto-connected to ui->textBrowser's signal anchorClicked()
|
||||
void MainWindow::on_textBrowser_anchorClicked(const QUrl &url)
|
||||
{
|
||||
QMessageBox::information(this, tr("Got you!"),
|
||||
tr("Obviously you clicked the link with the URL %1.")
|
||||
.arg(url.toString()));
|
||||
}
|
||||
|
||||
void MainWindow::createActions()
|
||||
{
|
||||
ui->actionNew->setShortcuts(QKeySequence::New);
|
||||
ui->actionOpen->setShortcuts(QKeySequence::Open);
|
||||
ui->actionSave->setShortcuts(QKeySequence::Save);
|
||||
ui->actionSave_as->setShortcuts(QKeySequence::SaveAs);
|
||||
|
||||
m_actionRedo = m_undoStack->createRedoAction(ui->menuEdit, tr("&Redo"));
|
||||
m_actionRedo->setShortcuts(QKeySequence::Redo);
|
||||
m_actionUndo = m_undoStack->createUndoAction(ui->menuEdit, tr("&Undo"));
|
||||
m_actionUndo->setShortcuts(QKeySequence::Undo);
|
||||
ui->menuEdit->insertAction(ui->actionCut, m_actionUndo);
|
||||
ui->menuEdit->insertAction(ui->actionCut, m_actionRedo);
|
||||
ui->menuEdit->insertSeparator(ui->actionCut);
|
||||
|
||||
ui->actionCut->setShortcuts(QKeySequence::Cut);
|
||||
ui->actionCopy->setShortcuts(QKeySequence::Copy);
|
||||
ui->actionPaste->setShortcuts(QKeySequence::Paste);
|
||||
|
||||
ui->actionCloseTab->setShortcuts(QKeySequence::Close);
|
||||
|
||||
connect(ui->actionNew, SIGNAL(triggered()), this, SLOT(newFile()));
|
||||
connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(close()));
|
||||
connect(ui->actionAbout_Qt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
|
||||
|
||||
ui->actionCut->setEnabled(false);
|
||||
ui->actionCopy->setEnabled(false);
|
||||
|
||||
// connect(ui->textBrowser, SIGNAL(copyAvailable(bool)),
|
||||
// ui->actionCut, SLOT(setEnabled(bool)));
|
||||
connect(ui->textBrowser, SIGNAL(copyAvailable(bool)),
|
||||
ui->actionCopy, SLOT(setEnabled(bool)));
|
||||
connect(ui->actionCopy, SIGNAL(triggered()),
|
||||
ui->textBrowser, SLOT(copy()));
|
||||
|
||||
connect(ui->treeView, SIGNAL(activated(const QModelIndex &)),
|
||||
this, SLOT(accountItemActivated(const QModelIndex&)));
|
||||
connect(ui->tableView, SIGNAL(activated(const QModelIndex &)),
|
||||
this, SLOT(accountItemActivated(const QModelIndex&)));
|
||||
}
|
||||
|
||||
void MainWindow::createToolBars()
|
||||
{
|
||||
ui->menuFile->insertMenu(ui->actionSave, m_menuRecentFiles.data());
|
||||
connect(m_menuRecentFiles.data(), SIGNAL(fileSelected(const QString &)),
|
||||
this, SLOT(loadFileMaybe(const QString&)));
|
||||
|
||||
m_fileToolBar = addToolBar(tr("File"));
|
||||
m_fileToolBar->addAction(ui->actionNew);
|
||||
m_fileToolBar->addAction(ui->actionOpen);
|
||||
m_fileToolBar->addAction(ui->actionSave);
|
||||
m_fileToolBar->addAction(ui->actionCloseTab);
|
||||
|
||||
m_editToolBar = addToolBar(tr("Edit"));
|
||||
m_editToolBar->addAction(m_actionUndo);
|
||||
m_editToolBar->addAction(m_actionRedo);
|
||||
m_editToolBar->addAction(ui->actionCut);
|
||||
m_editToolBar->addAction(ui->actionCopy);
|
||||
m_editToolBar->addAction(ui->actionPaste);
|
||||
|
||||
m_dashboardToolBar = addToolBar(tr("Dashboard"));
|
||||
m_dashboardToolBar->setObjectName("m_dashboardToolBar");
|
||||
m_btnTransferFundsWidget = new QToolButton;
|
||||
m_btnTransferFundsWidget->setCheckable(true);
|
||||
QSettings settings;
|
||||
m_btnTransferFundsWidget->setChecked(settings.value("basic-txn-dockwidget-visible").toBool());
|
||||
m_dashboardToolBar->addWidget(m_btnTransferFundsWidget);
|
||||
}
|
||||
|
||||
void MainWindow::createStatusBar()
|
||||
{
|
||||
statusBar()->showMessage(tr("Ready"));
|
||||
}
|
||||
|
||||
void MainWindow::setIcons()
|
||||
{
|
||||
m_actionRedo->setIcon(QIcon::fromTheme("edit-redo"));
|
||||
m_actionUndo->setIcon(QIcon::fromTheme("edit-undo"));
|
||||
ui->actionCut->setIcon(QIcon::fromTheme("edit-cut"));
|
||||
ui->actionCopy->setIcon(QIcon::fromTheme("edit-copy"));
|
||||
ui->actionPaste->setIcon(QIcon::fromTheme("edit-paste"));
|
||||
ui->actionCloseTab->setIcon(QIcon::fromTheme("tab-close-other"));
|
||||
ui->actionNew->setIcon(QIcon::fromTheme("document-new"));
|
||||
ui->actionOpen->setIcon(QIcon::fromTheme("document-open"));
|
||||
ui->actionSave->setIcon(QIcon::fromTheme("document-save"));
|
||||
ui->actionCloseTab->setIcon(QIcon::fromTheme("tab-close-other"));
|
||||
ui->actionSave_as->setIcon(QIcon::fromTheme("document-save-as"));
|
||||
ui->actionExit->setIcon(QIcon::fromTheme("window-close"));
|
||||
ui->actionAbout->setIcon(QIcon::fromTheme("help-about"));
|
||||
m_btnTransferFundsWidget->setIcon(QIcon::fromTheme("help-about"));
|
||||
}
|
||||
|
||||
void MainWindow::readSettings()
|
||||
{
|
||||
QSettings settings;
|
||||
QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
|
||||
QSize size = settings.value("size", QSize(400, 400)).toSize();
|
||||
//resize(size);
|
||||
//move(pos);
|
||||
restoreState(settings.value("state").toByteArray());
|
||||
restoreGeometry(settings.value("geometry").toByteArray());
|
||||
m_menuRecentFiles->readSettings(&settings, "RecentFiles");
|
||||
}
|
||||
|
||||
void MainWindow::autoLoadRecentFile()
|
||||
{
|
||||
QSettings settings;
|
||||
QString lastOpenedFile = "";
|
||||
lastOpenedFile = m_menuRecentFiles->getRecentFileName(&settings,
|
||||
"RecentFiles");
|
||||
if (maybeSave())
|
||||
{
|
||||
loadFile(lastOpenedFile);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::writeSettings()
|
||||
{
|
||||
QSettings settings;
|
||||
//settings.setValue("pos", pos());
|
||||
//settings.setValue("size", size());
|
||||
settings.setValue("state", saveState());
|
||||
settings.setValue("geometry", saveGeometry());
|
||||
m_menuRecentFiles->writeSettings(&settings, "RecentFiles");
|
||||
}
|
||||
|
||||
bool MainWindow::maybeSave()
|
||||
{
|
||||
if (isWindowModified())
|
||||
{
|
||||
QMessageBox::StandardButton ret;
|
||||
ret = QMessageBox::warning(this, tr("Application"),
|
||||
tr("The document has been modified.\n"
|
||||
"Do you want to save your changes?"),
|
||||
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
|
||||
if (ret == QMessageBox::Save)
|
||||
return on_actionSave_triggered();
|
||||
else if (ret == QMessageBox::Cancel)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void MainWindow::setCurrentFile(const QString &fileName)
|
||||
{
|
||||
m_menuRecentFiles->usingFile(fileName);
|
||||
m_currentFilename = fileName;
|
||||
documentCleanStateChanged(true);
|
||||
|
||||
updateWindowTitle();
|
||||
}
|
||||
|
||||
void MainWindow::updateWindowTitle()
|
||||
{
|
||||
QString shownName;
|
||||
if (m_currentFilename.isEmpty())
|
||||
shownName = "untitled.txt";
|
||||
else
|
||||
shownName = strippedName(m_currentFilename);
|
||||
|
||||
setWindowTitle(tr("%1[*]%2 - %3").arg(shownName).arg(isWindowModified() ? "(*)" : "").arg(tr("Application")));
|
||||
}
|
||||
|
||||
QString MainWindow::strippedName(const QString &fullFileName)
|
||||
{
|
||||
return QFileInfo(fullFileName).fileName();
|
||||
}
|
||||
|
||||
|
||||
// ////////////////////////////////////////////////////////////
|
||||
|
||||
// Auto-connected to ui->actionCloseTab's signal triggered
|
||||
void MainWindow::on_actionCloseTab_triggered()
|
||||
{
|
||||
on_tabWidget_tabCloseRequested(ui->tabWidget->currentIndex());
|
||||
}
|
||||
|
||||
// Auto-connected to ui->tabWidget's signal tabCloseRequested(int)
|
||||
void MainWindow::on_tabWidget_tabCloseRequested(int index)
|
||||
{
|
||||
QWidget *widget = ui->tabWidget->widget(index);
|
||||
if (widget == ui->textBrowserTab)
|
||||
{
|
||||
ui->actionViewWelcomepage->setChecked(false);
|
||||
reallyRemoveTab(index);
|
||||
}
|
||||
else if (widget == ui->treeViewTab)
|
||||
{
|
||||
ui->actionViewAccountTree->setChecked(false);
|
||||
reallyRemoveTab(index);
|
||||
}
|
||||
else if (widget == ui->tableViewTab)
|
||||
{
|
||||
ui->actionViewAccountList->setChecked(false);
|
||||
reallyRemoveTab(index);
|
||||
}
|
||||
else if (widget == m_dboard)
|
||||
{
|
||||
ui->actionViewDashboard->setChecked(false);
|
||||
m_dashboardToolBar->setEnabled(false);
|
||||
m_dashboardToolBar->setHidden(true);
|
||||
reallyRemoveTab(index);
|
||||
}
|
||||
else
|
||||
{
|
||||
QVariant prevPos = widget->property(PROPERTY_TAB_PREVIOUSPOS);
|
||||
if (prevPos.isValid())
|
||||
ui->tabWidget->setCurrentIndex(prevPos.toInt());
|
||||
ui->tabWidget->removeTab(index);
|
||||
delete widget;
|
||||
}
|
||||
}
|
||||
|
||||
// Auto-connected to ui->actionViewAccountTree's signal triggered()
|
||||
void MainWindow::on_actionViewAccountTree_triggered(bool checked)
|
||||
{
|
||||
viewOrHideTab(checked, ui->treeViewTab);
|
||||
}
|
||||
|
||||
// Auto-connected to ui->actionViewAccountList's signal triggered()
|
||||
void MainWindow::on_actionViewAccountList_triggered(bool checked)
|
||||
{
|
||||
viewOrHideTab(checked, ui->tableViewTab);
|
||||
}
|
||||
|
||||
// Auto-connected to ui->actionViewWelcomepage's signal triggered()
|
||||
void MainWindow::on_actionViewWelcomepage_triggered(bool checked)
|
||||
{
|
||||
viewOrHideTab(checked, ui->textBrowserTab);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionViewDashboard_triggered(bool checked)
|
||||
{
|
||||
viewOrHideTab(checked, m_dboard);
|
||||
}
|
||||
|
||||
void MainWindow::viewOrHideTab(bool checked, QWidget *widget)
|
||||
{
|
||||
if (checked)
|
||||
{
|
||||
QVariant tabLabel = widget->property(PROPERTY_TAB_LABEL);
|
||||
Q_ASSERT(tabLabel.isValid());
|
||||
QVariant tabPosition = widget->property(PROPERTY_TAB_POSITION);
|
||||
Q_ASSERT(tabPosition.isValid());
|
||||
QVariant tabIsCurrentV = widget->property(PROPERTY_TAB_ISCURRENT);
|
||||
Q_ASSERT(tabIsCurrentV.isValid());
|
||||
bool tabIsCurrent = tabIsCurrentV.toBool();
|
||||
|
||||
if (tabIsCurrent)
|
||||
widget->setProperty(PROPERTY_TAB_PREVIOUSPOS, ui->tabWidget->currentIndex());
|
||||
|
||||
ui->tabWidget->insertTab(tabPosition.toInt(), widget, tabLabel.toString());
|
||||
if (tabIsCurrent)
|
||||
ui->tabWidget->setCurrentWidget(widget);
|
||||
|
||||
if(widget == m_dboard)
|
||||
{
|
||||
m_dashboardToolBar->setEnabled(true);
|
||||
m_dashboardToolBar->setHidden(false);
|
||||
Q_EMIT dashboardVisible(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
on_tabWidget_tabCloseRequested(ui->tabWidget->indexOf(widget));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::reallyRemoveTab(int index)
|
||||
{
|
||||
QWidget *widget = ui->tabWidget->widget(index);
|
||||
widget->setProperty(PROPERTY_TAB_LABEL, ui->tabWidget->tabText(index));
|
||||
widget->setProperty(PROPERTY_TAB_POSITION, index);
|
||||
widget->setProperty(PROPERTY_TAB_ISCURRENT, (index == ui->tabWidget->currentIndex()));
|
||||
ui->tabWidget->removeTab(index);
|
||||
QVariant prevPos = widget->property(PROPERTY_TAB_PREVIOUSPOS);
|
||||
if (prevPos.isValid())
|
||||
ui->tabWidget->setCurrentIndex(prevPos.toInt());
|
||||
}
|
||||
|
||||
// Auto-connected to ui->tabWidget's signal currentChanged(int)
|
||||
void MainWindow::on_tabWidget_currentChanged(int index)
|
||||
{
|
||||
QWidget *widget = ui->tabWidget->widget(index);
|
||||
bool tabWithAccounts = (widget != ui->textBrowserTab);
|
||||
ui->menuAccount->setEnabled(tabWithAccounts);
|
||||
|
||||
if(ui->tabWidget->currentWidget() == m_dboard)
|
||||
{
|
||||
m_dashboardToolBar->setEnabled(true);
|
||||
m_dashboardToolBar->setHidden(false);
|
||||
m_dboard->showDashboardWidgets();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_dashboardToolBar->setEnabled(false);
|
||||
m_dashboardToolBar->setHidden(true);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::accountItemActivated(const QModelIndex & index)
|
||||
{
|
||||
if (index.model() != m_accountTreeModel
|
||||
&& index.model() != m_accountListModel)
|
||||
{
|
||||
qDebug() << "Wrong model; row=" << (index.isValid()? index.row() : -1);
|
||||
return;
|
||||
}
|
||||
Glib::RefPtr<Account> account = Glib::wrap(static_cast< ::Account*>(index.internalPointer()));
|
||||
if (!account)
|
||||
{
|
||||
qDebug() << "Account is null; why?";
|
||||
return;
|
||||
}
|
||||
|
||||
// We create a new model for this account which will query it for
|
||||
// its splits, and also a view widget for this list.
|
||||
QTableView *tableView =
|
||||
new SplitListView(account, m_undoStack, ui->tabWidget);
|
||||
ui->actionCut->setEnabled(tableView->model()->rowCount() > 0);
|
||||
|
||||
// Insert this as a new tab
|
||||
tableView->setProperty(PROPERTY_TAB_PREVIOUSPOS, ui->tabWidget->currentIndex());
|
||||
ui->tabWidget->addTab(tableView, g2q(account->get_name()));
|
||||
ui->tabWidget->setCurrentWidget(tableView);
|
||||
|
||||
connect(tableView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
|
||||
this, SLOT(selectionChanged(const QItemSelection &, const QItemSelection & )));
|
||||
}
|
||||
|
||||
void MainWindow::selectionChanged(const QItemSelection & selected, const QItemSelection & deselected )
|
||||
{
|
||||
ui->actionCut->setEnabled(!selected.isEmpty());
|
||||
//ui->actionCopy->setEnabled(!selected.isEmpty());
|
||||
}
|
||||
|
||||
// Auto-connected to actionCut's signal triggered()
|
||||
void MainWindow::on_actionCut_triggered()
|
||||
{
|
||||
QWidget *widget = ui->tabWidget->currentWidget();
|
||||
QTableView *tableView = qobject_cast<QTableView *>(widget);
|
||||
if (tableView)
|
||||
{
|
||||
// QModelIndexList selection = tableView->selectionModel()->selectedIndexes();
|
||||
// QSet<int> rows;
|
||||
// Q_FOREACH (QModelIndex index, selection)
|
||||
// {
|
||||
// rows.insert(index.row());
|
||||
// }
|
||||
// qDebug() << "Removing number of rows:" << rows.size();
|
||||
QModelIndex index = tableView->currentIndex();
|
||||
if (!index.isValid())
|
||||
return;
|
||||
QAbstractItemModel *model = tableView->model();
|
||||
Q_ASSERT(model);
|
||||
model->removeRow(index.row());
|
||||
}
|
||||
}
|
||||
|
||||
// ////////////////////////////////////////////////////////////
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if (maybeSave())
|
||||
{
|
||||
m_dboard->mainWindowCloseEvent();
|
||||
writeSettings();
|
||||
event->accept();
|
||||
|
||||
/* disable events; otherwise the mass deletion of accounts and
|
||||
* transactions during shutdown would cause massive redraws */
|
||||
qof_event_suspend ();
|
||||
|
||||
gnc_hook_run(HOOK_BOOK_CLOSED, m_session.gobj());
|
||||
|
||||
qof_session_destroy(m_session.gobj());
|
||||
m_session.reset();
|
||||
|
||||
qof_event_resume ();
|
||||
}
|
||||
else
|
||||
{
|
||||
event->ignore();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::newFile()
|
||||
{
|
||||
if (maybeSave())
|
||||
{
|
||||
|
||||
if (m_session)
|
||||
{
|
||||
/* close any ongoing file sessions, and free the accounts.
|
||||
* disable events so we don't gobj spammed by redraws. */
|
||||
qof_event_suspend ();
|
||||
|
||||
gnc_hook_run(HOOK_BOOK_CLOSED, m_session.gobj());
|
||||
|
||||
qof_session_destroy(m_session.gobj());
|
||||
m_session.reset();
|
||||
qof_event_resume ();
|
||||
}
|
||||
|
||||
/* start a new book */
|
||||
m_session.reset(qof_session_new());
|
||||
|
||||
gnc_hook_run(HOOK_NEW_BOOK, NULL);
|
||||
|
||||
/* Call this after re-enabling events. */
|
||||
gnc_hook_run(HOOK_BOOK_OPENED, m_session.gobj());
|
||||
|
||||
setCurrentFile("");
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::dockWidgetsVisibilityChanged(int wdg, bool visible)
|
||||
{
|
||||
if (wdg == 0)
|
||||
{
|
||||
/** todo: handle tabs */
|
||||
m_btnTransferFundsWidget->setChecked(visible);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // END namespace gnc
|
@ -1,151 +0,0 @@
|
||||
/*
|
||||
* mainwindow.hpp
|
||||
* Copyright (C) 2010 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QItemSelection>
|
||||
#include <QSharedPointer>
|
||||
#include "gnc/Session.hpp"
|
||||
#include "gnc/AccountItemModel.hpp"
|
||||
#include "gnc/dashboard.hpp"
|
||||
|
||||
class QAction;
|
||||
class QMenu;
|
||||
class QPlainTextEdit;
|
||||
class QTextEdit;
|
||||
class QTabWidget;
|
||||
class QUndoStack;
|
||||
class QToolButton;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
class RecentFileMenu;
|
||||
class Dashboard;
|
||||
|
||||
/** The main window of Cutecash.
|
||||
*
|
||||
* Some of the action parts in here should probably be refactored into
|
||||
* separate classes/functions.
|
||||
*/
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWindow();
|
||||
~MainWindow();
|
||||
|
||||
const QString& getCurrentFilename() const { return m_currentFilename; }
|
||||
bool hasOpenedFile() const { return !m_currentFilename.isEmpty(); }
|
||||
void dockWidgetsVisibilityChanged(int wdg, bool visible);
|
||||
|
||||
public Q_SLOTS:
|
||||
void accountItemActivated(const QModelIndex & index);
|
||||
void loadFileMaybe(const QString &fileName);
|
||||
void documentCleanStateChanged(bool clean);
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
||||
Q_SIGNALS:
|
||||
void dashboardVisible(bool visible);
|
||||
|
||||
private Q_SLOTS:
|
||||
void newFile();
|
||||
void on_actionOpen_triggered();
|
||||
bool on_actionSave_triggered();
|
||||
void on_actionAbout_triggered();
|
||||
bool on_actionSave_as_triggered();
|
||||
void on_actionCloseTab_triggered();
|
||||
void on_actionCut_triggered();
|
||||
void on_tabWidget_tabCloseRequested(int index);
|
||||
void on_tabWidget_currentChanged(int index);
|
||||
void on_textBrowser_anchorClicked(const QUrl &);
|
||||
void on_actionViewAccountTree_triggered(bool checked);
|
||||
void on_actionViewAccountList_triggered(bool checked);
|
||||
void on_actionViewWelcomepage_triggered(bool checked);
|
||||
void on_actionViewDashboard_triggered(bool checked);
|
||||
void documentWasModified();
|
||||
void selectionChanged(const QItemSelection & selected, const QItemSelection & deselected );
|
||||
|
||||
private:
|
||||
void createActions();
|
||||
void createToolBars();
|
||||
void createStatusBar();
|
||||
void setIcons();
|
||||
void readSettings();
|
||||
void autoLoadRecentFile();
|
||||
void writeSettings();
|
||||
bool maybeSave();
|
||||
void setCurrentFile(const QString &fileName);
|
||||
QString strippedName(const QString &fullFileName);
|
||||
void viewOrHideTab(bool checkedView, QWidget *widget);
|
||||
void reallyRemoveTab(int index);
|
||||
void updateWindowTitle();
|
||||
|
||||
void loadFile(const QString &fileName);
|
||||
bool saveFile();
|
||||
bool saveFileAs(const QString &fileName);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GNC_FILE_DIALOG_OPEN,
|
||||
GNC_FILE_DIALOG_IMPORT,
|
||||
GNC_FILE_DIALOG_SAVE,
|
||||
GNC_FILE_DIALOG_EXPORT
|
||||
} GNCFileDialogType;
|
||||
static bool show_session_error (QWidget *parent,
|
||||
::QofBackendError io_error,
|
||||
const QString& newfile,
|
||||
GNCFileDialogType type);
|
||||
|
||||
QSharedPointer<Ui::MainWindow> ui;
|
||||
|
||||
QString m_currentFilename;
|
||||
|
||||
QToolBar *m_fileToolBar;
|
||||
QToolBar *m_editToolBar;
|
||||
QToolBar *m_dashboardToolBar;
|
||||
QAction *m_actionUndo;
|
||||
QAction *m_actionRedo;
|
||||
QToolButton *m_btnTransferFundsWidget;
|
||||
QSharedPointer<RecentFileMenu> m_menuRecentFiles;
|
||||
QUndoStack *m_undoStack;
|
||||
|
||||
Dashboard *m_dboard;
|
||||
|
||||
Session m_session;
|
||||
AccountListModel *m_accountListModel;
|
||||
AccountTreeModel *m_accountTreeModel;
|
||||
};
|
||||
|
||||
} // END namespace gnc
|
||||
|
||||
#endif
|
@ -1,430 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>707</width>
|
||||
<height>665</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>GnuCash Qt Example</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset>
|
||||
<normaloff>:/pixmaps/gnucash-icon-32x32.png</normaloff>:/pixmaps/gnucash-icon-32x32.png</iconset>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="documentMode">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="tabsClosable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="movable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="textBrowserTab">
|
||||
<attribute name="icon">
|
||||
<iconset resource="gtk-icons.qrc">
|
||||
<normaloff>:/gtk-icons/gtk-about.png</normaloff>:/gtk-icons/gtk-about.png</iconset>
|
||||
</attribute>
|
||||
<attribute name="title">
|
||||
<string>Example Welcome Page</string>
|
||||
</attribute>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTextBrowser" name="textBrowser">
|
||||
<property name="html">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Ubuntu'; font-size:9pt; 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 more or less a proof-of-concept for developers:</span></p>
|
||||
<ol style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;"><li style=" font-family:'Sans'; font-size:10pt;" 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=" font-family:'Sans'; font-size:10pt;" 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 tree view and also a list view </li>
|
||||
<li style=" font-family:'Sans'; font-size:10pt;" style=" margin-top:0px; margin-bottom:0px; 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>
|
||||
<li style=" font-family:'Sans'; font-size:10pt;" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Save and Save-As works as normal.</li>
|
||||
<li style=" font-family:'Sans'; font-size:10pt;" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Edit any of the existing transaction/splits: Date, Description, or Amount. Click Undo. Click Redo. Click Undo. Etc. etc.</li>
|
||||
<li style=" font-family:'Sans'; font-size:10pt;" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Delete any of the existings transactions. Or entering a new one. Click Undo. Click Redo. Etc. etc.</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:'Sans'; font-size:10pt;">The list of splits in the account is comparable to gnucash's single line view. Amounts, balance, date, all there.</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:'Sans'; font-size:10pt;">The following parts are still missing:</span></p>
|
||||
<ul style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;"><li style=" font-family:'MS Shell Dlg 2'; font-size:8pt;" style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> Currently the accout selection of a transaction cannot be edited. </li>
|
||||
<li style=" font-family:'MS Shell Dlg 2'; font-size:8pt;" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Editing or adding multi-split transactions are not yet supported (it shows only the string &quot;--Split Transaction--&quot;). </li>
|
||||
<li style=" font-family:'MS Shell Dlg 2'; font-size:8pt;" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Editing or adding multi-currency transactions are not yet supported. </li>
|
||||
<li style=" font-family:'MS Shell Dlg 2'; font-size:8pt;" style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Any of the more specialized account views are not yet implemented.</li></ul>
|
||||
<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=" font-family:'Sans'; font-size:10pt; 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>
|
||||
</property>
|
||||
<property name="openLinks">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tableViewTab">
|
||||
<attribute name="icon">
|
||||
<iconset resource="gnucash.qrc">
|
||||
<normaloff>:/pixmaps/gnc-account.png</normaloff>:/pixmaps/gnc-account.png</iconset>
|
||||
</attribute>
|
||||
<attribute name="title">
|
||||
<string>Account List</string>
|
||||
</attribute>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTableView" name="tableView">
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="treeViewTab">
|
||||
<attribute name="icon">
|
||||
<iconset resource="gnucash.qrc">
|
||||
<normaloff>:/pixmaps/gnc-account.png</normaloff>:/pixmaps/gnc-account.png</iconset>
|
||||
</attribute>
|
||||
<attribute name="title">
|
||||
<string>Account Tree</string>
|
||||
</attribute>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTreeView" name="treeView"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>707</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
<property name="title">
|
||||
<string>&File</string>
|
||||
</property>
|
||||
<addaction name="actionNew"/>
|
||||
<addaction name="actionOpen"/>
|
||||
<addaction name="actionSave"/>
|
||||
<addaction name="actionSave_as"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionCloseTab"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionExit"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuHelp">
|
||||
<property name="title">
|
||||
<string>&Help</string>
|
||||
</property>
|
||||
<addaction name="actionAbout"/>
|
||||
<addaction name="actionAbout_Qt"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuAccount">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>&Account</string>
|
||||
</property>
|
||||
<addaction name="actionOpenAccount"/>
|
||||
<addaction name="actionNewAccount"/>
|
||||
<addaction name="actionDeleteAccount"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionAccountProperties"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuEdit">
|
||||
<property name="title">
|
||||
<string>&Edit</string>
|
||||
</property>
|
||||
<addaction name="actionCut"/>
|
||||
<addaction name="actionCopy"/>
|
||||
<addaction name="actionPaste"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menu_View">
|
||||
<property name="title">
|
||||
<string>&View</string>
|
||||
</property>
|
||||
<addaction name="actionViewWelcomepage"/>
|
||||
<addaction name="actionViewAccountList"/>
|
||||
<addaction name="actionViewAccountTree"/>
|
||||
<addaction name="actionViewDashboard"/>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
<addaction name="menuEdit"/>
|
||||
<addaction name="menu_View"/>
|
||||
<addaction name="menuAccount"/>
|
||||
<addaction name="menuHelp"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<action name="actionNew">
|
||||
<property name="text">
|
||||
<string>&New</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string>Create a new file</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+N</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionOpen">
|
||||
<property name="text">
|
||||
<string>&Open...</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string>Open an existing file</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+O</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAbout">
|
||||
<property name="text">
|
||||
<string>&About</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSave">
|
||||
<property name="text">
|
||||
<string>&Save</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string>Save the document to disk</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+S</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSave_as">
|
||||
<property name="text">
|
||||
<string>Save &as...</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string>Save the document under a new name</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionExit">
|
||||
<property name="text">
|
||||
<string>E&xit</string>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>Exit the application</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+Q</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionNewAccount">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="gnucash.qrc">
|
||||
<normaloff>:/pixmaps/gnc-account-new.png</normaloff>:/pixmaps/gnc-account-new.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&New...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionOpenAccount">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="gnucash.qrc">
|
||||
<normaloff>:/pixmaps/gnc-account-open.png</normaloff>:/pixmaps/gnc-account-open.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Open</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAccountProperties">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="gnucash.qrc">
|
||||
<normaloff>:/pixmaps/gnc-account-edit.png</normaloff>:/pixmaps/gnc-account-edit.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Properties...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCut">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Cu&t</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCopy">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Copy</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionPaste">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Paste</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDeleteAccount">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="gnucash.qrc">
|
||||
<normaloff>:/pixmaps/gnc-account-delete.png</normaloff>:/pixmaps/gnc-account-delete.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Delete...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAbout_Qt">
|
||||
<property name="text">
|
||||
<string>About Qt</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionViewWelcomepage">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Welcome Page</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionViewAccountList">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Account &List</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionViewAccountTree">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Account &Tree</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCloseTab">
|
||||
<property name="text">
|
||||
<string>&Close Current Tab</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionViewDashboard">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Dashboard</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionViewTransferFunds">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Transfer Funds</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionViewFPO">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&FPO</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="gnucash.qrc"/>
|
||||
<include location="gtk-icons.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>textBrowser</sender>
|
||||
<signal>copyAvailable(bool)</signal>
|
||||
<receiver>actionCopy</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>352</x>
|
||||
<y>343</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>-1</x>
|
||||
<y>-1</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -1,12 +0,0 @@
|
||||
#ifndef METATYPE_HPP
|
||||
#define METATYPE_HPP
|
||||
|
||||
#include <QMetaType>
|
||||
|
||||
#include "config.h"
|
||||
#include <gncmm/Account.hpp>
|
||||
|
||||
// The macros to declare those types for inclusion in QVariant
|
||||
Q_DECLARE_METATYPE(::Account*);
|
||||
|
||||
#endif // METATYPE_HPP
|
@ -1,48 +0,0 @@
|
||||
#dateWidget {
|
||||
background-color: #FAA0A0;
|
||||
color:black;
|
||||
border-style: outset;
|
||||
border-width: 1px;
|
||||
border-radius: 5px;
|
||||
border-color: beige;
|
||||
|
||||
border-bottom-width: 2px;
|
||||
border-bottom-color: darkgray;
|
||||
border-bottom-style: solid;
|
||||
|
||||
min-width: 12em;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
#accountWidget {
|
||||
background-color: #A0A1FA;
|
||||
border-style: outset;
|
||||
border-width: 1px;
|
||||
border-radius: 5px;
|
||||
border-color: beige;
|
||||
padding: 2px;
|
||||
|
||||
/* Test with colours */
|
||||
/*
|
||||
background-color: qlineargradient(x1: 0, y1: 0, x2: 0.5, y2: 0.5,
|
||||
stop: 0 #FF92BB, stop: 1 white);
|
||||
*/
|
||||
}
|
||||
|
||||
#descWidget {
|
||||
background-color: #A9FAA0;
|
||||
border-style: outset;
|
||||
border-width: 1px;
|
||||
border-radius: 5px;
|
||||
border-color: beige;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
#amountWidget {
|
||||
background-color: #F0F7F0;
|
||||
border-style: outset;
|
||||
border-width: 1px;
|
||||
border-radius: 5px;
|
||||
border-color: beige;
|
||||
padding: 2px;
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file alias="qss-default">qss/default.qss</file>
|
||||
</qresource>
|
||||
</RCC>
|
@ -1,5 +1,4 @@
|
||||
ADD_SUBDIRECTORY(python-bindings)
|
||||
ADD_SUBDIRECTORY(gtkmm)
|
||||
|
||||
SET_LOCAL_DIST(optional_DIST_local CMakeLists.txt Makefile.am)
|
||||
SET(optional_DIST ${optional_DIST_local} ${gtkmm_DIST} ${python_bindings_DIST} PARENT_SCOPE)
|
||||
SET(optional_DIST ${optional_DIST_local} ${python_bindings_DIST} PARENT_SCOPE)
|
||||
|
@ -1,9 +1,6 @@
|
||||
if WITH_PYTHON
|
||||
PYTHON_BINDINGS_DIR = python-bindings
|
||||
endif
|
||||
if WITH_GTKMM
|
||||
GTKMM_DIR=gtkmm
|
||||
endif
|
||||
SUBDIRS = ${PYTHON_BINDINGS_DIR} ${GTKMM_DIR}
|
||||
SUBDIRS = ${PYTHON_BINDINGS_DIR}
|
||||
|
||||
EXTRA_DIST = CMakeLists.txt
|
||||
|
@ -1,63 +0,0 @@
|
||||
# CMakeLists.txt for src/optional/gtkmm
|
||||
#ADD_SUBDIRECTORY(gncmm)
|
||||
ADD_SUBDIRECTORY(test)
|
||||
|
||||
|
||||
ADD_DEFINITIONS (-DG_LOG_DOMAIN=\"gnc.gtkmm\")
|
||||
|
||||
INCLUDE_DIRECTORIES (${GLIB2_INCLUDE_DIRS})
|
||||
INCLUDE_DIRECTORIES (${GLIBMM_INCLUDE_DIRS})
|
||||
INCLUDE_DIRECTORIES (${LIBINTL_INCLUDE_PATH})
|
||||
INCLUDE_DIRECTORIES (${REGEX_INCLUDE_PATH})
|
||||
INCLUDE_DIRECTORIES (${GUILE_INCLUDE_DIRS})
|
||||
INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/src ) # for config.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src ) # for gnc-ui.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/gnc-module) # for gnc-glib-utils.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/core-utils) # for gnc-glib-utils.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/engine) # for gnc-glib-utils.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/backend/xml)
|
||||
INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/src/engine) # for swig-runtime.h
|
||||
|
||||
SET (libgncmod_gtkmm_HEADERS
|
||||
gncmm/Account.hpp
|
||||
gncmm/Book.hpp
|
||||
gncmm/Commodity.hpp
|
||||
gncmm/GncInstance.hpp
|
||||
gncmm/Numeric.hpp
|
||||
gncmm/Split.hpp
|
||||
gncmm/Transaction.hpp
|
||||
gncmm/private/Account_p.hpp
|
||||
gncmm/private/Book_p.hpp
|
||||
gncmm/private/Commodity_p.hpp
|
||||
gncmm/private/GncInstance_p.hpp
|
||||
gncmm/private/Split_p.hpp
|
||||
gncmm/private/Transaction_p.hpp
|
||||
gncmm/wrap_init.hpp
|
||||
)
|
||||
|
||||
SET (libgncmod_gtkmm_SOURCES
|
||||
gncmm/Account.cpp
|
||||
gncmm/Book.cpp
|
||||
gncmm/Commodity.cpp
|
||||
gncmm/GncInstance.cpp
|
||||
gncmm/Numeric.cpp
|
||||
gncmm/Split.cpp
|
||||
gncmm/Transaction.cpp
|
||||
gncmm/wrap_init.cpp
|
||||
)
|
||||
|
||||
SET(gnc_plugin_SOURCES gnc-plugin-gtkmm.cpp gncmod-gtkmm.cpp)
|
||||
SET(gnc_plugin_noinst_SOURCES gnc-plugin-gtkmm.hpp)
|
||||
SET(gnc_plugin_UI gnc-plugin-gtkmm-ui.xml)
|
||||
|
||||
IF (WITH_CUTECASH)
|
||||
ADD_LIBRARY (libgncmod-gtkmm
|
||||
${libgncmod_gtkmm_SOURCES}
|
||||
${libgncmod_gtkmm_HEADERS}
|
||||
)
|
||||
ENDIF()
|
||||
|
||||
SET_LOCAL_DIST(gtkmm_DIST_local CMakeLists.txt Makefile.am
|
||||
${libgncmod_gtkmm_SOURCES} ${libgncmod_gtkmm_HEADERS}
|
||||
${gnc_plugin_SOURCES} ${gnc_plugin_noinst_SOURCES} ${gnc_plugin_UI})
|
||||
SET(gtkmm_DIST ${gtkmm_DIST_local} ${test_gtkmm_DIST} PARENT_SCOPE)
|
@ -1,62 +0,0 @@
|
||||
SUBDIRS = . test
|
||||
|
||||
pkglib_LTLIBRARIES = libgncmod-gtkmm.la
|
||||
|
||||
libgncmod_gtkmm_la_SOURCES = \
|
||||
gncmm/Account.cpp \
|
||||
gncmm/Book.cpp \
|
||||
gncmm/Commodity.cpp \
|
||||
gncmm/GncInstance.cpp \
|
||||
gncmm/Numeric.cpp \
|
||||
gncmm/Split.cpp \
|
||||
gncmm/Transaction.cpp \
|
||||
gncmm/wrap_init.cpp \
|
||||
gnc-plugin-gtkmm.cpp \
|
||||
gncmod-gtkmm.cpp
|
||||
|
||||
noinst_HEADERS = \
|
||||
gncmm/Account.hpp \
|
||||
gncmm/Book.hpp \
|
||||
gncmm/Commodity.hpp \
|
||||
gncmm/GncInstance.hpp \
|
||||
gncmm/Numeric.hpp \
|
||||
gncmm/Split.hpp \
|
||||
gncmm/Transaction.hpp \
|
||||
gncmm/private/Account_p.hpp \
|
||||
gncmm/private/Book_p.hpp \
|
||||
gncmm/private/Commodity_p.hpp \
|
||||
gncmm/private/GncInstance_p.hpp \
|
||||
gncmm/private/Split_p.hpp \
|
||||
gncmm/private/Transaction_p.hpp \
|
||||
gncmm/wrap_init.hpp \
|
||||
gnc-plugin-gtkmm.hpp
|
||||
|
||||
libgncmod_gtkmm_la_LDFLAGS = -avoid-version
|
||||
|
||||
libgncmod_gtkmm_la_LIBADD = \
|
||||
${top_builddir}/src/gnome/libgnc-gnome.la \
|
||||
${top_builddir}/src/gnome-utils/libgncmod-gnome-utils.la \
|
||||
${top_builddir}/src/app-utils/libgncmod-app-utils.la \
|
||||
${top_builddir}/src/engine/libgncmod-engine.la \
|
||||
${top_builddir}/src/core-utils/libgnc-core-utils.la \
|
||||
${top_builddir}/src/gnc-module/libgnc-module.la \
|
||||
${GTKMM_LIBS} \
|
||||
${GLIB_LIBS}
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I${top_srcdir}/src \
|
||||
-I${top_srcdir}/src/gnc-module \
|
||||
-I${top_srcdir}/src/core-utils \
|
||||
-I${top_srcdir}/src/engine \
|
||||
${GTKMM_CFLAGS} \
|
||||
${GLIB_CFLAGS}
|
||||
|
||||
uidir = $(GNC_UI_DIR)
|
||||
ui_DATA = gnc-plugin-gtkmm-ui.xml
|
||||
|
||||
gtkbuilderdir = $(GNC_GTKBUILDER_DIR)
|
||||
gtkbuilder_DATA =
|
||||
|
||||
EXTRA_DIST = ${ui_DATA} ${gtkbuilder_DATA} CMakeLists.txt
|
||||
|
||||
AM_CPPFLAGS += -DG_LOG_DOMAIN=\"gnc.gui.gtkmm\"
|
@ -1,11 +0,0 @@
|
||||
<ui>
|
||||
<menubar>
|
||||
<menu name="File" action="FileAction">
|
||||
<menu name="FileImport" action="FileImportAction">
|
||||
<placeholder name="FileImportPlaceholder">
|
||||
<menuitem name="FileSomethingImport" action="GtkmmSomethingAction"/>
|
||||
</placeholder>
|
||||
</menu>
|
||||
</menu>
|
||||
</menubar>
|
||||
</ui>
|
@ -1,187 +0,0 @@
|
||||
/*
|
||||
* gnc-plugin-gtkmm.cpp --
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @file
|
||||
* @brief Plugin registration of the Gtkmm module
|
||||
* @author Copyright (C) 2011 Christian Stimming <christian@cstimming.de>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <glib/gi18n.h>
|
||||
extern "C" {
|
||||
#include "gnome-utils/gnc-plugin-manager.h"
|
||||
#include "gnome-utils/gnc-main-window.h"
|
||||
#include "engine/Account.h"
|
||||
}
|
||||
|
||||
#include "gnc-plugin-gtkmm.hpp"
|
||||
#include <gtkmm.h>
|
||||
|
||||
namespace gncmm
|
||||
{
|
||||
|
||||
// This static indicates the debugging module that this .o belongs to.
|
||||
static QofLogModule log_module = G_LOG_DOMAIN;
|
||||
|
||||
static void gnc_plugin_gtkmm_class_init (GncPluginGtkmmClass *klass);
|
||||
static void gnc_plugin_gtkmm_init (GncPluginGtkmm *plugin);
|
||||
static void gnc_plugin_gtkmm_finalize (GObject *object);
|
||||
|
||||
/* Command callbacks */
|
||||
static void gnc_plugin_gtkmm_cmd_something (GtkAction *action, GncMainWindowActionData *data);
|
||||
|
||||
#define PLUGIN_ACTIONS_NAME "gnc-plugin-gtkmm-actions"
|
||||
#define PLUGIN_UI_FILENAME "gnc-plugin-gtkmm-ui.xml"
|
||||
|
||||
static GtkActionEntry gnc_plugin_actions [] =
|
||||
{
|
||||
{
|
||||
// FIXME: I've intentionally remove the i18n markers so that
|
||||
// translators don't have to deal with these example strings!
|
||||
"GtkmmSomethingAction", NULL, "Do _Something in C++/gtkmm...", NULL,
|
||||
"This demonstrates how to integrate C++/gtkmm in a plugin of gnucash",
|
||||
G_CALLBACK (gnc_plugin_gtkmm_cmd_something)
|
||||
},
|
||||
};
|
||||
static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions);
|
||||
|
||||
struct GncPluginGtkmmPrivate
|
||||
{
|
||||
gpointer dummy;
|
||||
};
|
||||
|
||||
#define GNC_PLUGIN_GTKMM_GET_PRIVATE(o) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_PLUGIN_GTKMM, GncPluginGtkmmPrivate))
|
||||
|
||||
static GObjectClass *parent_class = NULL;
|
||||
|
||||
GType
|
||||
gnc_plugin_gtkmm_get_type (void)
|
||||
{
|
||||
static GType gnc_plugin_gtkmm_type = 0;
|
||||
|
||||
if (gnc_plugin_gtkmm_type == 0)
|
||||
{
|
||||
static const GTypeInfo our_info =
|
||||
{
|
||||
sizeof (GncPluginGtkmmClass),
|
||||
NULL, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
(GClassInitFunc) gnc_plugin_gtkmm_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GncPluginGtkmm),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gnc_plugin_gtkmm_init,
|
||||
};
|
||||
|
||||
gnc_plugin_gtkmm_type = g_type_register_static (GNC_TYPE_PLUGIN,
|
||||
"GncPluginGtkmm",
|
||||
&our_info, GTypeFlags(0));
|
||||
}
|
||||
|
||||
return gnc_plugin_gtkmm_type;
|
||||
}
|
||||
|
||||
GncPlugin *
|
||||
gnc_plugin_gtkmm_new (void)
|
||||
{
|
||||
return GNC_PLUGIN (g_object_new (GNC_TYPE_PLUGIN_GTKMM, NULL));
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_plugin_gtkmm_class_init (GncPluginGtkmmClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GncPluginClass *plugin_class = GNC_PLUGIN_CLASS (klass);
|
||||
|
||||
parent_class = reinterpret_cast<GObjectClass *>(g_type_class_peek_parent (klass));
|
||||
|
||||
object_class->finalize = gnc_plugin_gtkmm_finalize;
|
||||
|
||||
// plugin info
|
||||
plugin_class->plugin_name = GNC_PLUGIN_GTKMM_NAME;
|
||||
|
||||
// widget addition/removal
|
||||
plugin_class->actions_name = PLUGIN_ACTIONS_NAME;
|
||||
plugin_class->actions = gnc_plugin_actions;
|
||||
plugin_class->n_actions = gnc_plugin_n_actions;
|
||||
plugin_class->ui_filename = PLUGIN_UI_FILENAME;
|
||||
|
||||
g_type_class_add_private(klass, sizeof(GncPluginGtkmmPrivate));
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_plugin_gtkmm_init (GncPluginGtkmm *plugin)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_plugin_gtkmm_finalize (GObject *object)
|
||||
{
|
||||
g_return_if_fail (GNC_IS_PLUGIN_GTKMM (object));
|
||||
|
||||
GncPluginGtkmm *plugin = GNC_PLUGIN_GTKMM (object);
|
||||
GncPluginGtkmmPrivate *priv = GNC_PLUGIN_GTKMM_GET_PRIVATE(plugin);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
* Plugin Function Implementation *
|
||||
************************************************************/
|
||||
|
||||
/************************************************************
|
||||
* Command Callbacks *
|
||||
************************************************************/
|
||||
|
||||
static void
|
||||
gnc_plugin_gtkmm_cmd_something (GtkAction *action,
|
||||
GncMainWindowActionData *data)
|
||||
{
|
||||
// Now we're gonna do something.
|
||||
ENTER("action %p, main window data %p", action, data);
|
||||
g_return_if_fail(data);
|
||||
|
||||
// ::Account *c_account = NULL;//main_window_to_account(data->window);
|
||||
// Glib::RefPtr<Glib::Object> account_ptr = Glib::wrap(c_account);
|
||||
|
||||
LEAVE("");
|
||||
}
|
||||
|
||||
|
||||
/************************************************************
|
||||
* Plugin Bootstrapping *
|
||||
************************************************************/
|
||||
|
||||
void
|
||||
gnc_plugin_gtkmm_create_plugin (void)
|
||||
{
|
||||
GncPlugin *plugin = gnc_plugin_gtkmm_new ();
|
||||
|
||||
gnc_plugin_manager_add_plugin (gnc_plugin_manager_get (), plugin);
|
||||
}
|
||||
|
||||
} // END namespace gncmm
|
@ -1,90 +0,0 @@
|
||||
/*
|
||||
* gnc-plugin-gtkmm.h --
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup GUI
|
||||
* @{
|
||||
* @addtogroup Gtkmm
|
||||
* @{
|
||||
* @file
|
||||
* @brief Plugin registration of the Gtkmm module
|
||||
* @author Copyright (C) 2011 Christian Stimming <christian@cstimming.de>
|
||||
*/
|
||||
|
||||
#ifndef GNC_PLUGIN_GTKMM_H
|
||||
#define GNC_PLUGIN_GTKMM_H
|
||||
|
||||
#include <glib.h>
|
||||
extern "C" {
|
||||
#include "gnome-utils/gnc-plugin.h"
|
||||
}
|
||||
|
||||
namespace gncmm
|
||||
{
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* type macros */
|
||||
#define GNC_TYPE_PLUGIN_GTKMM (gnc_plugin_gtkmm_get_type())
|
||||
#define GNC_PLUGIN_GTKMM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GNC_TYPE_PLUGIN_GTKMM, GncPluginGtkmm))
|
||||
#define GNC_PLUGIN_GTKMM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GNC_TYPE_PLUGIN_GTKMM, GncPluginGtkmmClass))
|
||||
#define GNC_IS_PLUGIN_GTKMM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNC_TYPE_PLUGIN_GTKMM))
|
||||
#define GNC_IS_PLUGIN_GTKMM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GNC_TYPE_PLUGIN_GTKMM))
|
||||
#define GNC_PLUGIN_GTKMM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GNC_TYPE_PLUGIN_GTKMM, GncPluginGtkmmClass))
|
||||
|
||||
#define GNC_PLUGIN_GTKMM_NAME "gnc-plugin-gtkmm"
|
||||
|
||||
/* typedefs & structures */
|
||||
struct GncPluginGtkmm
|
||||
{
|
||||
GncPlugin gnc_plugin;
|
||||
};
|
||||
|
||||
struct GncPluginGtkmmClass
|
||||
{
|
||||
GncPluginClass gnc_plugin;
|
||||
};
|
||||
|
||||
/* function prototypes */
|
||||
|
||||
/**
|
||||
* @return The glib runtime type of an gtkmm plugin page
|
||||
**/
|
||||
GType gnc_plugin_gtkmm_get_type(void);
|
||||
|
||||
/**
|
||||
* @return A new GncPluginGtkmm object
|
||||
*/
|
||||
GncPlugin* gnc_plugin_gtkmm_new(void);
|
||||
|
||||
/**
|
||||
* Create a new GncPluginGtkmm object and register it.
|
||||
*/
|
||||
void gnc_plugin_gtkmm_create_plugin(void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
} // END namespace gncmm
|
||||
|
||||
/** @} */
|
||||
/** @} */
|
||||
|
||||
#endif /* GNC_PLUGIN_GTKMM_H */
|
@ -1,136 +0,0 @@
|
||||
/*
|
||||
* Account.cpp
|
||||
* Copyright (C) 2011 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "Account.hpp"
|
||||
#include "private/Account_p.hpp"
|
||||
#include "Commodity.hpp"
|
||||
|
||||
namespace Glib
|
||||
{
|
||||
|
||||
Glib::RefPtr<gnc::Account> wrap(::Account* object, bool refuse_ownership)
|
||||
{
|
||||
return Glib::RefPtr<gnc::Account>( dynamic_cast<gnc::Account*> (Glib::wrap_auto ((GObject*)(object), refuse_ownership)) );
|
||||
//We use dynamic_cast<> in case of multiple inheritance.
|
||||
}
|
||||
|
||||
} /* namespace Glib */
|
||||
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
|
||||
/* The *_Class implementation: */
|
||||
|
||||
const Glib::Class& Account_Class::init()
|
||||
{
|
||||
if (!gtype_) // create the GType if necessary
|
||||
{
|
||||
// Glib::Class has to know the class init function to clone custom types.
|
||||
class_init_func_ = &Account_Class::class_init_function;
|
||||
|
||||
// This is actually just optimized away, apparently with no harm.
|
||||
// Make sure that the parent type has been created.
|
||||
//CppClassParent::CppObjectType::get_type();
|
||||
|
||||
// Create the wrapper type, with the same class/instance size as the base type.
|
||||
register_derived_type(gnc_account_get_type());
|
||||
|
||||
// Add derived versions of interfaces, if the C type implements any interfaces:
|
||||
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void Account_Class::class_init_function(void* g_class, void* class_data)
|
||||
{
|
||||
BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
|
||||
CppClassParent::class_init_function(klass, class_data);
|
||||
}
|
||||
|
||||
|
||||
Glib::ObjectBase* Account_Class::wrap_new(GObject* object)
|
||||
{
|
||||
return new Account((::Account*)object);
|
||||
}
|
||||
|
||||
|
||||
/* The implementation: */
|
||||
|
||||
::Account* Account::gobj_copy()
|
||||
{
|
||||
reference();
|
||||
return gobj();
|
||||
}
|
||||
|
||||
Account::Account(const Glib::ConstructParams& construct_params)
|
||||
: GncInstance(construct_params)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Account::Account(::Account* castitem)
|
||||
: GncInstance((::QofInstance*)(castitem))
|
||||
{}
|
||||
|
||||
|
||||
Account::~Account()
|
||||
{}
|
||||
|
||||
|
||||
Account::CppClassType Account::account_class_; // initialize static member
|
||||
|
||||
GType Account::get_type()
|
||||
{
|
||||
return account_class_.init().get_type();
|
||||
}
|
||||
|
||||
|
||||
GType Account::get_base_type()
|
||||
{
|
||||
return gnc_account_get_type();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Glib::RefPtr<Commodity> Account::get_commodity() const
|
||||
{
|
||||
return Glib::wrap(xaccAccountGetCommodity(gobj()));
|
||||
}
|
||||
Glib::RefPtr<Account> Account::get_parent() const
|
||||
{
|
||||
return Glib::wrap(gnc_account_get_parent(gobj()));
|
||||
}
|
||||
Glib::RefPtr<Account> Account::get_root()
|
||||
{
|
||||
return Glib::wrap(gnc_account_get_root(gobj()));
|
||||
}
|
||||
Glib::RefPtr<Account> Account::get_nth_child (gint num) const
|
||||
{
|
||||
return Glib::wrap(gnc_account_nth_child(gobj(), num));
|
||||
}
|
||||
|
||||
} // END namespace gnc
|
@ -1,194 +0,0 @@
|
||||
/*
|
||||
* Account.hpp
|
||||
* Copyright (C) 2011 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#ifndef GNC_ACCOUNT_HPP
|
||||
#define GNC_ACCOUNT_HPP
|
||||
|
||||
// gnucash includes
|
||||
#include "engine/guid.hpp"
|
||||
extern "C"
|
||||
{
|
||||
#include "qof.h"
|
||||
#include "engine/Account.h"
|
||||
}
|
||||
|
||||
#include <glibmm/object.h>
|
||||
#include <glibmm/ustring.h>
|
||||
|
||||
#include "Numeric.hpp"
|
||||
#include "GncInstance.hpp"
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
class Account_Class;
|
||||
} // END namespace gnc
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
class Account;
|
||||
class Commodity;
|
||||
|
||||
/** Wrapper around a gnucash ::Account pointer with C++ methods for
|
||||
* easier setter and getter access.
|
||||
*/
|
||||
class Account : public GncInstance
|
||||
{
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
typedef Account CppObjectType;
|
||||
typedef Account_Class CppClassType;
|
||||
typedef ::Account BaseObjectType;
|
||||
typedef ::AccountClass BaseClassType;
|
||||
|
||||
private:
|
||||
friend class Account_Class;
|
||||
static CppClassType account_class_;
|
||||
|
||||
private:
|
||||
// noncopyable
|
||||
Account(const Account&);
|
||||
Account& operator=(const Account&);
|
||||
|
||||
protected:
|
||||
explicit Account(const Glib::ConstructParams& construct_params);
|
||||
explicit Account(::Account* castitem);
|
||||
|
||||
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
|
||||
|
||||
public:
|
||||
virtual ~Account();
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
static GType get_type() G_GNUC_CONST;
|
||||
static GType get_base_type() G_GNUC_CONST;
|
||||
#endif
|
||||
|
||||
///Provides access to the underlying C GObject.
|
||||
::Account* gobj()
|
||||
{
|
||||
return reinterpret_cast< ::Account*>(gobject_);
|
||||
}
|
||||
|
||||
///Provides access to the underlying C GObject.
|
||||
const ::Account* gobj() const
|
||||
{
|
||||
return reinterpret_cast< ::Account*>(gobject_);
|
||||
}
|
||||
|
||||
///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
|
||||
::Account* gobj_copy();
|
||||
|
||||
private:
|
||||
public:
|
||||
|
||||
|
||||
// actual implementation follows here
|
||||
|
||||
Glib::ustring get_name() const
|
||||
{
|
||||
return (xaccAccountGetName(gobj()));
|
||||
}
|
||||
Glib::ustring get_full_name() const
|
||||
{
|
||||
return gchar_to_ustring(gnc_account_get_full_name (gobj()));
|
||||
}
|
||||
Glib::ustring get_code() const
|
||||
{
|
||||
return (xaccAccountGetCode(gobj()));
|
||||
}
|
||||
Glib::ustring get_description() const
|
||||
{
|
||||
return (xaccAccountGetDescription(gobj()));
|
||||
}
|
||||
Glib::RefPtr<Commodity> get_commodity() const;
|
||||
int get_commodity_scu() const
|
||||
{
|
||||
return xaccAccountGetCommoditySCU(gobj());
|
||||
}
|
||||
|
||||
::SplitList* get_split_list() const
|
||||
{
|
||||
return xaccAccountGetSplitList(gobj());
|
||||
}
|
||||
|
||||
/** @name Account tree traversal */
|
||||
//@{
|
||||
|
||||
Glib::RefPtr<Account> get_parent() const;
|
||||
Glib::RefPtr<Account> get_root();
|
||||
bool is_root() const
|
||||
{
|
||||
return gnc_account_is_root(gobj());
|
||||
}
|
||||
gint get_num_children() const
|
||||
{
|
||||
return gnc_account_n_children(gobj());
|
||||
}
|
||||
GList *get_children() const
|
||||
{
|
||||
return gnc_account_get_children(gobj());
|
||||
}
|
||||
GList *get_descendants () const
|
||||
{
|
||||
return gnc_account_get_descendants (gobj());
|
||||
}
|
||||
Glib::RefPtr<Account> get_nth_child (gint num) const;
|
||||
|
||||
|
||||
/** Return the index of this account in the children's list of its
|
||||
* parent account.
|
||||
*/
|
||||
gint child_index () const
|
||||
{
|
||||
Glib::RefPtr<Account> parent(get_parent());
|
||||
if (parent && parent->gobj())
|
||||
return gnc_account_child_index(parent->gobj(), gobj());
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
gint get_current_depth () const
|
||||
{
|
||||
return gnc_account_get_current_depth(gobj());
|
||||
}
|
||||
gint get_tree_depth () const
|
||||
{
|
||||
return gnc_account_get_tree_depth(gobj());
|
||||
}
|
||||
//@}
|
||||
|
||||
};
|
||||
|
||||
} // END namespace gnc
|
||||
|
||||
namespace Glib
|
||||
{
|
||||
/** A Glib::wrap() method for this object.
|
||||
*
|
||||
* @param object The C instance.
|
||||
* @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
|
||||
* @result A C++ instance that wraps this C instance.
|
||||
*
|
||||
* @relates Gio::FileInfo
|
||||
*/
|
||||
Glib::RefPtr<gnc::Account> wrap(::Account* object, bool refuse_ownership = true);
|
||||
}
|
||||
|
||||
#endif
|
@ -1,145 +0,0 @@
|
||||
/*
|
||||
* Book.cpp
|
||||
* Copyright (C) 2011 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "Book.hpp"
|
||||
#include "private/Book_p.hpp"
|
||||
#include "Account.hpp"
|
||||
|
||||
namespace Glib
|
||||
{
|
||||
|
||||
Glib::RefPtr<gnc::Book> wrap(QofBook* object, bool take_copy)
|
||||
{
|
||||
return Glib::RefPtr<gnc::Book>( dynamic_cast<gnc::Book*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
|
||||
//We use dynamic_cast<> in case of multiple inheritance.
|
||||
}
|
||||
|
||||
} /* namespace Glib */
|
||||
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
|
||||
/* The *_Class implementation: */
|
||||
|
||||
const Glib::Class& Book_Class::init()
|
||||
{
|
||||
if (!gtype_) // create the GType if necessary
|
||||
{
|
||||
// Glib::Class has to know the class init function to clone custom types.
|
||||
class_init_func_ = &Book_Class::class_init_function;
|
||||
|
||||
// This is actually just optimized away, apparently with no harm.
|
||||
// Make sure that the parent type has been created.
|
||||
//CppClassParent::CppObjectType::get_type();
|
||||
|
||||
// Create the wrapper type, with the same class/instance size as the base type.
|
||||
register_derived_type(qof_book_get_type());
|
||||
|
||||
// Add derived versions of interfaces, if the C type implements any interfaces:
|
||||
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void Book_Class::class_init_function(void* g_class, void* class_data)
|
||||
{
|
||||
BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
|
||||
CppClassParent::class_init_function(klass, class_data);
|
||||
}
|
||||
|
||||
|
||||
Glib::ObjectBase* Book_Class::wrap_new(GObject* object)
|
||||
{
|
||||
return new Book((QofBook*)object);
|
||||
}
|
||||
|
||||
|
||||
/* The implementation: */
|
||||
|
||||
QofBook* Book::gobj_copy()
|
||||
{
|
||||
reference();
|
||||
return gobj();
|
||||
}
|
||||
|
||||
Book::Book(const Glib::ConstructParams& construct_params)
|
||||
: GncInstance(construct_params)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Book::Book(QofBook* castitem)
|
||||
: GncInstance((::QofInstance*)(castitem))
|
||||
{}
|
||||
|
||||
|
||||
Book::~Book()
|
||||
{}
|
||||
|
||||
|
||||
Book::CppClassType Book::book_class_; // initialize static member
|
||||
|
||||
GType Book::get_type()
|
||||
{
|
||||
return book_class_.init().get_type();
|
||||
}
|
||||
|
||||
|
||||
GType Book::get_base_type()
|
||||
{
|
||||
return qof_book_get_type();
|
||||
}
|
||||
|
||||
|
||||
void Book::string_option_set (const Glib::ustring& opt_name, const Glib::ustring& opt_val)
|
||||
{
|
||||
qof_book_set_string_option(gobj(), opt_name.c_str(), opt_val.c_str());
|
||||
}
|
||||
|
||||
Glib::ustring Book::string_option_get (const Glib::ustring& opt_name) const
|
||||
{
|
||||
const char* r = qof_book_get_string_option(gobj(), opt_name.c_str());
|
||||
if (r)
|
||||
return r;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
bool Book::string_option_exists (const Glib::ustring& opt_name) const
|
||||
{
|
||||
const char* r = qof_book_get_string_option(gobj(), opt_name.c_str());
|
||||
if (r)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
Glib::RefPtr<Account> Book::get_root_account()
|
||||
{
|
||||
return Glib::wrap(gnc_book_get_root_account (gobj()));
|
||||
}
|
||||
|
||||
} // END namespace gnc
|
@ -1,130 +0,0 @@
|
||||
/*
|
||||
* Book.hpp
|
||||
* Copyright (C) 2011 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#ifndef GNC_BOOK_HPP
|
||||
#define GNC_BOOK_HPP
|
||||
|
||||
// gnucash includes
|
||||
#include "engine/guid.hpp"
|
||||
extern "C"
|
||||
{
|
||||
#include "qof.h"
|
||||
#include "engine/gnc-hooks.h"
|
||||
#include "engine/Account.h"
|
||||
}
|
||||
|
||||
#include <glibmm/object.h>
|
||||
#include "GncInstance.hpp"
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
class Book_Class;
|
||||
class Book;
|
||||
class GncInstance;
|
||||
} // END namespace gnc
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
class Account;
|
||||
|
||||
/** Wrapper around a gnucash ::QofBook pointer with C++ methods for
|
||||
* easier setter and getter access.
|
||||
*/
|
||||
class Book : public GncInstance
|
||||
{
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
typedef Book CppObjectType;
|
||||
typedef Book_Class CppClassType;
|
||||
typedef ::QofBook BaseObjectType;
|
||||
typedef ::QofBookClass BaseClassType;
|
||||
|
||||
private:
|
||||
friend class Book_Class;
|
||||
static CppClassType book_class_;
|
||||
|
||||
private:
|
||||
// noncopyable
|
||||
Book(const Book&);
|
||||
Book& operator=(const Book&);
|
||||
|
||||
protected:
|
||||
explicit Book(const Glib::ConstructParams& construct_params);
|
||||
explicit Book(QofBook* castitem);
|
||||
|
||||
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
|
||||
|
||||
public:
|
||||
virtual ~Book();
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
static GType get_type() G_GNUC_CONST;
|
||||
static GType get_base_type() G_GNUC_CONST;
|
||||
#endif
|
||||
|
||||
///Provides access to the underlying C GObject.
|
||||
QofBook* gobj()
|
||||
{
|
||||
return reinterpret_cast<QofBook*>(gobject_);
|
||||
}
|
||||
|
||||
///Provides access to the underlying C GObject.
|
||||
const QofBook* gobj() const
|
||||
{
|
||||
return reinterpret_cast<QofBook*>(gobject_);
|
||||
}
|
||||
|
||||
///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
|
||||
QofBook* gobj_copy();
|
||||
|
||||
private:
|
||||
public:
|
||||
|
||||
|
||||
Glib::RefPtr<Account> get_root_account();
|
||||
bool is_readonly() const
|
||||
{
|
||||
return qof_book_is_readonly(gobj());
|
||||
}
|
||||
void mark_readonly()
|
||||
{
|
||||
qof_book_mark_readonly(gobj());
|
||||
}
|
||||
void string_option_set (const Glib::ustring& opt_name, const Glib::ustring& opt_val);
|
||||
Glib::ustring string_option_get (const Glib::ustring& opt_name) const;
|
||||
bool string_option_exists (const Glib::ustring& opt_name) const;
|
||||
};
|
||||
|
||||
} // END namespace gnc
|
||||
|
||||
namespace Glib
|
||||
{
|
||||
/** A Glib::wrap() method for this object.
|
||||
*
|
||||
* @param object The C instance.
|
||||
* @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
|
||||
* @result A C++ instance that wraps this C instance.
|
||||
*
|
||||
* @relates Gio::FileInfo
|
||||
*/
|
||||
Glib::RefPtr<gnc::Book> wrap(::QofBook* object, bool refuse_ownership = true);
|
||||
}
|
||||
|
||||
#endif
|
@ -1,118 +0,0 @@
|
||||
/*
|
||||
* Commodity.cpp
|
||||
* Copyright (C) 2011 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#include "Commodity.hpp"
|
||||
#include "private/Commodity_p.hpp"
|
||||
|
||||
|
||||
namespace Glib
|
||||
{
|
||||
|
||||
Glib::RefPtr<gnc::Commodity> wrap(gnc_commodity* object, bool take_copy)
|
||||
{
|
||||
return Glib::RefPtr<gnc::Commodity>( dynamic_cast<gnc::Commodity*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
|
||||
//We use dynamic_cast<> in case of multiple inheritance.
|
||||
}
|
||||
|
||||
} /* namespace Glib */
|
||||
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
|
||||
/* The *_Class implementation: */
|
||||
|
||||
const Glib::Class& Commodity_Class::init()
|
||||
{
|
||||
if (!gtype_) // create the GType if necessary
|
||||
{
|
||||
// Glib::Class has to know the class init function to clone custom types.
|
||||
class_init_func_ = &Commodity_Class::class_init_function;
|
||||
|
||||
// This is actually just optimized away, apparently with no harm.
|
||||
// Make sure that the parent type has been created.
|
||||
//CppClassParent::CppObjectType::get_type();
|
||||
|
||||
// Create the wrapper type, with the same class/instance size as the base type.
|
||||
register_derived_type(gnc_commodity_get_type());
|
||||
|
||||
// Add derived versions of interfaces, if the C type implements any interfaces:
|
||||
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void Commodity_Class::class_init_function(void* g_class, void* class_data)
|
||||
{
|
||||
BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
|
||||
CppClassParent::class_init_function(klass, class_data);
|
||||
}
|
||||
|
||||
|
||||
Glib::ObjectBase* Commodity_Class::wrap_new(GObject* object)
|
||||
{
|
||||
return new Commodity((gnc_commodity*)object);
|
||||
}
|
||||
|
||||
|
||||
/* The implementation: */
|
||||
|
||||
gnc_commodity* Commodity::gobj_copy()
|
||||
{
|
||||
reference();
|
||||
return gobj();
|
||||
}
|
||||
|
||||
Commodity::Commodity(const Glib::ConstructParams& construct_params)
|
||||
: GncInstance(construct_params)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Commodity::Commodity(gnc_commodity* castitem)
|
||||
: GncInstance((::QofInstance*)(castitem))
|
||||
{}
|
||||
|
||||
|
||||
Commodity::~Commodity()
|
||||
{}
|
||||
|
||||
|
||||
Commodity::CppClassType Commodity::commodity_class_; // initialize static member
|
||||
|
||||
GType Commodity::get_type()
|
||||
{
|
||||
return commodity_class_.init().get_type();
|
||||
}
|
||||
|
||||
|
||||
GType Commodity::get_base_type()
|
||||
{
|
||||
return gnc_commodity_get_type();
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // END namespace gnc
|
@ -1,159 +0,0 @@
|
||||
/*
|
||||
* Commodity.hpp
|
||||
* Copyright (C) 2011 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#ifndef GNC_COMMODITY_HPP
|
||||
#define GNC_COMMODITY_HPP
|
||||
|
||||
// gnucash includes
|
||||
#include "config.h"
|
||||
#include "engine/guid.hpp"
|
||||
extern "C"
|
||||
{
|
||||
#include "qof.h"
|
||||
#include "engine/gnc-commodity.h"
|
||||
}
|
||||
|
||||
#include <glibmm/object.h>
|
||||
#include <glibmm/ustring.h>
|
||||
#include "GncInstance.hpp"
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
class Commodity_Class;
|
||||
} // END namespace gnc
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
/** Wrapper around a gnucash \ref gnc_commodity object */
|
||||
class Commodity : public GncInstance
|
||||
{
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
typedef Commodity CppObjectType;
|
||||
typedef Commodity_Class CppClassType;
|
||||
typedef ::gnc_commodity BaseObjectType;
|
||||
typedef ::gnc_commodityClass BaseClassType;
|
||||
|
||||
private:
|
||||
friend class Commodity_Class;
|
||||
static CppClassType commodity_class_;
|
||||
|
||||
private:
|
||||
// noncopyable
|
||||
Commodity(const Commodity&);
|
||||
Commodity& operator=(const Commodity&);
|
||||
|
||||
protected:
|
||||
explicit Commodity(const Glib::ConstructParams& construct_params);
|
||||
explicit Commodity(gnc_commodity* castitem);
|
||||
|
||||
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
|
||||
|
||||
public:
|
||||
virtual ~Commodity();
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
static GType get_type() G_GNUC_CONST;
|
||||
static GType get_base_type() G_GNUC_CONST;
|
||||
#endif
|
||||
|
||||
///Provides access to the underlying C GObject.
|
||||
gnc_commodity* gobj()
|
||||
{
|
||||
return reinterpret_cast<gnc_commodity*>(gobject_);
|
||||
}
|
||||
|
||||
///Provides access to the underlying C GObject.
|
||||
const gnc_commodity* gobj() const
|
||||
{
|
||||
return reinterpret_cast<gnc_commodity*>(gobject_);
|
||||
}
|
||||
|
||||
///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
|
||||
gnc_commodity* gobj_copy();
|
||||
|
||||
private:
|
||||
public:
|
||||
|
||||
Glib::ustring get_mnemonic() const
|
||||
{
|
||||
return gnc_commodity_get_mnemonic(gobj());
|
||||
}
|
||||
Glib::ustring get_namespace() const
|
||||
{
|
||||
return gnc_commodity_get_namespace(gobj());
|
||||
}
|
||||
Glib::ustring get_fullname() const
|
||||
{
|
||||
return gnc_commodity_get_fullname(gobj());
|
||||
}
|
||||
Glib::ustring get_printname() const
|
||||
{
|
||||
return gnc_commodity_get_printname(gobj());
|
||||
}
|
||||
|
||||
int get_fraction() const
|
||||
{
|
||||
return gnc_commodity_get_fraction(gobj());
|
||||
}
|
||||
bool get_quote_flag() const
|
||||
{
|
||||
return gnc_commodity_get_quote_flag(gobj());
|
||||
}
|
||||
|
||||
bool is_currency() const
|
||||
{
|
||||
return gnc_commodity_is_currency(gobj());
|
||||
}
|
||||
|
||||
bool equal(const Commodity& other) const
|
||||
{
|
||||
return gnc_commodity_equal(gobj(), other.gobj());
|
||||
}
|
||||
};
|
||||
|
||||
inline bool operator==(const Commodity& a, const Commodity& b)
|
||||
{
|
||||
return a.equal(b);
|
||||
}
|
||||
|
||||
inline bool operator!=(const Commodity& a, const Commodity& b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
} // END namespace gnc
|
||||
|
||||
namespace Glib
|
||||
{
|
||||
/** A Glib::wrap() method for this object.
|
||||
*
|
||||
* @param object The C instance.
|
||||
* @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
|
||||
* @result A C++ instance that wraps this C instance.
|
||||
*
|
||||
* @relates Gio::FileInfo
|
||||
*/
|
||||
Glib::RefPtr<gnc::Commodity> wrap(gnc_commodity* object, bool refuse_ownership = true);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
@ -1,142 +0,0 @@
|
||||
/*
|
||||
* GncInstance.cpp
|
||||
* Copyright (C) 2011 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#include "GncInstance.hpp"
|
||||
#include "private/GncInstance_p.hpp"
|
||||
#include "Book.hpp"
|
||||
#include "qofinstance-p.h"
|
||||
|
||||
|
||||
namespace Glib
|
||||
{
|
||||
|
||||
Glib::RefPtr<gnc::GncInstance> wrap(::QofInstance* object, bool take_copy)
|
||||
{
|
||||
return Glib::RefPtr<gnc::GncInstance>( dynamic_cast<gnc::GncInstance*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
|
||||
//We use dynamic_cast<> in case of multiple inheritance.
|
||||
}
|
||||
|
||||
} /* namespace Glib */
|
||||
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
|
||||
/* The *_Class implementation: */
|
||||
|
||||
const Glib::Class& GncInstance_Class::init()
|
||||
{
|
||||
if (!gtype_) // create the GType if necessary
|
||||
{
|
||||
// Glib::Class has to know the class init function to clone custom types.
|
||||
class_init_func_ = &GncInstance_Class::class_init_function;
|
||||
|
||||
// This is actually just optimized away, apparently with no harm.
|
||||
// Make sure that the parent type has been created.
|
||||
//CppClassParent::CppObjectType::get_type();
|
||||
|
||||
// Create the wrapper type, with the same class/instance size as the base type.
|
||||
register_derived_type(qof_instance_get_type());
|
||||
|
||||
// Add derived versions of interfaces, if the C type implements any interfaces:
|
||||
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void GncInstance_Class::class_init_function(void* g_class, void* class_data)
|
||||
{
|
||||
BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
|
||||
CppClassParent::class_init_function(klass, class_data);
|
||||
}
|
||||
|
||||
|
||||
Glib::ObjectBase* GncInstance_Class::wrap_new(GObject* object)
|
||||
{
|
||||
return new GncInstance((::QofInstance*)object);
|
||||
}
|
||||
|
||||
|
||||
/* The implementation: */
|
||||
|
||||
::QofInstance* GncInstance::gobj_copy()
|
||||
{
|
||||
reference();
|
||||
return gobj();
|
||||
}
|
||||
|
||||
GncInstance::GncInstance(const Glib::ConstructParams& construct_params)
|
||||
: Glib::Object(construct_params)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
GncInstance::GncInstance(::QofInstance* castitem)
|
||||
: Glib::Object((GObject*)(castitem))
|
||||
{}
|
||||
|
||||
|
||||
GncInstance::~GncInstance()
|
||||
{}
|
||||
|
||||
|
||||
GncInstance::CppClassType GncInstance::gncInstance_class_; // initialize static member
|
||||
|
||||
GType GncInstance::get_type()
|
||||
{
|
||||
return gncInstance_class_.init().get_type();
|
||||
}
|
||||
|
||||
|
||||
GType GncInstance::get_base_type()
|
||||
{
|
||||
return qof_instance_get_type();
|
||||
}
|
||||
|
||||
void GncInstance::set_dirty()
|
||||
{
|
||||
return qof_instance_set_dirty(gobj());
|
||||
}
|
||||
void GncInstance::mark_clean()
|
||||
{
|
||||
return qof_instance_mark_clean(gobj());
|
||||
}
|
||||
|
||||
|
||||
// ////////////////////////////////////////
|
||||
|
||||
Glib::RefPtr<Book> GncInstance::get_book() const
|
||||
{
|
||||
return Glib::wrap(qof_instance_get_book (gobj()));
|
||||
}
|
||||
void GncInstance::set_book(Glib::RefPtr<Book> book)
|
||||
{
|
||||
g_assert (book);
|
||||
qof_instance_set_book(gobj(), book->gobj());
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // END namespace gnc
|
@ -1,128 +0,0 @@
|
||||
/*
|
||||
* GncInstance.hpp
|
||||
* Copyright (C) 2011 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#ifndef GNC_GNCINSTANCE_HPP
|
||||
#define GNC_GNCINSTANCE_HPP
|
||||
|
||||
// gnucash includes
|
||||
#include "config.h"
|
||||
#include "engine/guid.hpp"
|
||||
extern "C"
|
||||
{
|
||||
#include "qof.h"
|
||||
}
|
||||
|
||||
#include <glibmm/object.h>
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
class Book;
|
||||
class GncInstance;
|
||||
class GncInstance_Class;
|
||||
} // END namespace gnc
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
/** Wrapper for ::QofInstance
|
||||
* This
|
||||
* base class offers some common methods.
|
||||
*
|
||||
* We cannot name it QofInstance because those stupid C macros (like
|
||||
* QOF_CHECK_TYPE) would always confuse our namespaced declaration
|
||||
* with the C declaration. I hate macros!
|
||||
*/
|
||||
class GncInstance : public Glib::Object
|
||||
{
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
typedef GncInstance CppObjectType;
|
||||
typedef GncInstance_Class CppClassType;
|
||||
typedef ::QofInstance BaseObjectType;
|
||||
typedef ::QofInstanceClass BaseClassType;
|
||||
|
||||
private:
|
||||
friend class GncInstance_Class;
|
||||
static CppClassType gncInstance_class_;
|
||||
|
||||
private:
|
||||
// noncopyable
|
||||
GncInstance(const GncInstance&);
|
||||
GncInstance& operator=(const GncInstance&);
|
||||
|
||||
protected:
|
||||
explicit GncInstance(const Glib::ConstructParams& construct_params);
|
||||
explicit GncInstance(::QofInstance* castitem);
|
||||
|
||||
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
|
||||
|
||||
public:
|
||||
virtual ~GncInstance();
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
static GType get_type() G_GNUC_CONST;
|
||||
static GType get_base_type() G_GNUC_CONST;
|
||||
#endif
|
||||
|
||||
///Provides access to the underlying C GObject.
|
||||
::QofInstance* gobj()
|
||||
{
|
||||
return reinterpret_cast< ::QofInstance*>(gobject_);
|
||||
}
|
||||
|
||||
///Provides access to the underlying C GObject.
|
||||
const ::QofInstance* gobj() const
|
||||
{
|
||||
return reinterpret_cast< ::QofInstance*>(gobject_);
|
||||
}
|
||||
|
||||
///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
|
||||
::QofInstance* gobj_copy();
|
||||
|
||||
public:
|
||||
|
||||
Glib::RefPtr<Book> get_book() const;
|
||||
void set_book(Glib::RefPtr<Book> book);
|
||||
const ::GncGUID* get_guid() const
|
||||
{
|
||||
return qof_entity_get_guid(gobj_const());
|
||||
}
|
||||
|
||||
bool is_dirty() const
|
||||
{
|
||||
return qof_instance_get_dirty(gobj_const());
|
||||
}
|
||||
void set_dirty();
|
||||
void mark_clean();
|
||||
|
||||
//bool check_type(const char* type_id) { return (0 == g_strcmp0(type_id, QOF_INSTANCE(base_class::get())->e_type)); }
|
||||
//Slots getSlots() const { return qof_instance_get_slots(QOF_INSTANCE(get())); }
|
||||
|
||||
private:
|
||||
/*const*/
|
||||
::QofInstance* gobj_const() const
|
||||
{
|
||||
return const_cast< ::QofInstance*>(gobj());
|
||||
}
|
||||
};
|
||||
|
||||
} // END namespace gnc
|
||||
|
||||
#endif
|
@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Numeric.cpp
|
||||
* Copyright (C) 2011 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#include "Numeric.hpp"
|
||||
#include "Account.hpp"
|
||||
#include "Split.hpp"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "app-utils/gnc-exp-parser.h"
|
||||
}
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
// These are in the cpp file to avoid circular dependency between the
|
||||
// headers
|
||||
|
||||
PrintAmountInfo::PrintAmountInfo(const Glib::RefPtr<Account> account, bool use_symbol)
|
||||
: base_class(gnc_account_print_info(account->gobj(), use_symbol))
|
||||
{}
|
||||
PrintAmountInfo::PrintAmountInfo(const Glib::RefPtr<Split> split, bool use_symbol)
|
||||
: base_class(gnc_split_amount_print_info(split->gobj(), use_symbol))
|
||||
{}
|
||||
|
||||
Glib::ustring Numeric::printAmount(const PrintAmountInfo& info) const
|
||||
{
|
||||
char buf[256];
|
||||
if (!xaccSPrintAmount (buf, *this, info))
|
||||
buf[0] = '\0';
|
||||
return Glib::ustring(buf);
|
||||
}
|
||||
|
||||
Glib::ustring Numeric::parse(const Glib::ustring& str)
|
||||
{
|
||||
Glib::ustring errorString;
|
||||
|
||||
const char* input = str.c_str();
|
||||
char *error_loc;
|
||||
Numeric result;
|
||||
gboolean p = gnc_exp_parser_parse(input, &result, &error_loc);
|
||||
if (p)
|
||||
{
|
||||
*this = result;
|
||||
}
|
||||
else
|
||||
{
|
||||
errorString = Glib::ustring(gnc_exp_parser_error_string());
|
||||
}
|
||||
|
||||
return errorString;
|
||||
}
|
||||
|
||||
|
||||
} // END namespace gnc
|
@ -1,340 +0,0 @@
|
||||
/*
|
||||
* Numeric.hpp
|
||||
* Copyright (C) 2011 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#ifndef GNC_NUMERIC_HPP
|
||||
#define GNC_NUMERIC_HPP
|
||||
|
||||
// gnucash includes
|
||||
#include "config.h"
|
||||
#include "engine/guid.hpp"
|
||||
extern "C"
|
||||
{
|
||||
#include "qof.h"
|
||||
#include "gnc-date.h"
|
||||
#include "app-utils/gnc-ui-util.h"
|
||||
#include "app-utils/gnc-ui-balances.h"
|
||||
}
|
||||
|
||||
#include <glibmm/ustring.h>
|
||||
#include <glibmm/refptr.h>
|
||||
|
||||
#if GLIB_HAVE_DATETIME
|
||||
// Glib::DateTime is new in glibmm-2.29 but very useful
|
||||
# include <glibmm/datetime.h>
|
||||
#endif
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
class Account;
|
||||
class Split;
|
||||
|
||||
/** Conversion of a newly allocated gchar* to QString, which will
|
||||
* correctly g_free() the newly allocated gchar* as well.
|
||||
*
|
||||
* If a gchar* does not have to be freed again, the standard
|
||||
* conversion constructor Glib::ustring(const gchar*) is sufficient
|
||||
* (as it expects its input in UTF-8) and we do not need to define an
|
||||
* extra function for that.
|
||||
*/
|
||||
inline Glib::ustring gchar_to_ustring(gchar* tmp_string)
|
||||
{
|
||||
if (!tmp_string)
|
||||
return Glib::ustring();
|
||||
Glib::ustring result(tmp_string); // implies source string in UTF-8
|
||||
g_free(tmp_string);
|
||||
return result;
|
||||
}
|
||||
|
||||
#if GLIB_HAVE_DATETIME
|
||||
// Glib::DateTime is new in glibmm-2.29 but very useful
|
||||
inline Glib::DateTime to_gdatetime(const ::Timespec& timespec)
|
||||
{
|
||||
Glib::DateTime result = Glib::DateTime::create_now_utc(timespec.tv_sec);
|
||||
result.add_seconds(timespec.tv_nsec * 1e-9);
|
||||
return result;
|
||||
}
|
||||
inline ::Timespec to_timespec(const Glib::DateTime& gdt)
|
||||
{
|
||||
::Timespec result;
|
||||
result.tv_sec = qdt.to_unix;
|
||||
result.tv_nsec = qdt.get_microseconds() * 1000;
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
/** Copies the pointer values from the given GList into the specified output
|
||||
* list type, such as std::vector<FooBar*>. */
|
||||
template<class ResultListType>
|
||||
ResultListType from_glist(GList* glist)
|
||||
{
|
||||
ResultListType result;
|
||||
GList* list = glist;
|
||||
while (list)
|
||||
{
|
||||
result.push_back(reinterpret_cast< typename ResultListType::value_type >(list->data));
|
||||
list = g_list_next(list);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Wrapper around a gnucash ::GNCPrintAmountInfo structure with C++
|
||||
* methods for easier setter and getter access.
|
||||
*
|
||||
* Since this class is a derived class of the original gnucash struct,
|
||||
* it keeps the data by-value and its member variables will always
|
||||
* exist as long as this object exists.
|
||||
*/
|
||||
class PrintAmountInfo : public ::GNCPrintAmountInfo
|
||||
{
|
||||
public:
|
||||
typedef ::GNCPrintAmountInfo base_class;
|
||||
|
||||
PrintAmountInfo(const base_class& other)
|
||||
: base_class(other)
|
||||
{}
|
||||
PrintAmountInfo(bool use_symbol)
|
||||
: base_class(gnc_default_print_info(use_symbol))
|
||||
{}
|
||||
|
||||
/* If the boolean set to true, then prefix 3 letter ISO 4217
|
||||
currency code to the amount. */
|
||||
PrintAmountInfo(const Glib::RefPtr<Account> account, bool use_symbol);
|
||||
PrintAmountInfo(const Glib::RefPtr<Split> split, bool use_symbol);
|
||||
|
||||
static PrintAmountInfo share_places(int decplaces)
|
||||
{
|
||||
return gnc_share_print_info_places(decplaces);
|
||||
}
|
||||
static PrintAmountInfo default_share()
|
||||
{
|
||||
return gnc_default_share_print_info();
|
||||
}
|
||||
static PrintAmountInfo default_price()
|
||||
{
|
||||
return gnc_default_price_print_info();
|
||||
}
|
||||
static PrintAmountInfo integral()
|
||||
{
|
||||
return gnc_integral_print_info();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/** Wrapper around a gnucash ::gnc_numeric structure with C++ methods
|
||||
* for easier setter and getter access.
|
||||
*
|
||||
* Since this class is a derived class of the original gnucash struct,
|
||||
* it keeps the data by-value and its member variables will always
|
||||
* exist as long as this object exists.
|
||||
*/
|
||||
class Numeric : public ::gnc_numeric
|
||||
{
|
||||
public:
|
||||
typedef ::gnc_numeric base_class;
|
||||
|
||||
/// Constructor for value zero
|
||||
Numeric()
|
||||
{
|
||||
base_class::num = 0;
|
||||
base_class::denom = 1;
|
||||
}
|
||||
|
||||
/// Constructor with given nominator and denominator
|
||||
Numeric(gint64 num, gint64 denom)
|
||||
{
|
||||
base_class::num = num;
|
||||
base_class::denom = denom;
|
||||
}
|
||||
|
||||
/// Copy constructor
|
||||
Numeric(const base_class& other) : base_class(other) {}
|
||||
|
||||
/// Constructor for value zero
|
||||
static Numeric zero()
|
||||
{
|
||||
return Numeric(0, 1);
|
||||
}
|
||||
|
||||
/// Constructor for value one
|
||||
static Numeric one()
|
||||
{
|
||||
return Numeric(1, 1);
|
||||
}
|
||||
|
||||
/// Conversion from a double value, with the given target
|
||||
/// denominator and the specified rounding method "how".
|
||||
Numeric(double in, gint64 denom, gint how)
|
||||
{
|
||||
*this = double_to_gnc_numeric(in, denom, how);
|
||||
}
|
||||
|
||||
/// Watch out: This conversion never seems to work!
|
||||
static bool string_to_numeric(const Glib::ustring& str, Numeric& n)
|
||||
{
|
||||
return string_to_gnc_numeric(str.c_str(), &n);
|
||||
}
|
||||
|
||||
/// Constructor for representing any of the given
|
||||
/// GNCNumericErrorCode values
|
||||
Numeric(GNCNumericErrorCode error_code)
|
||||
{
|
||||
*this = gnc_numeric_error(error_code);
|
||||
}
|
||||
|
||||
/// Returns the numerator
|
||||
gint64 num() const
|
||||
{
|
||||
return base_class::num;
|
||||
}
|
||||
/// Returns the denominator
|
||||
gint64 denom() const
|
||||
{
|
||||
return base_class::denom;
|
||||
}
|
||||
/// Conversion to double
|
||||
gdouble to_double() const
|
||||
{
|
||||
return gnc_numeric_to_double(*this);
|
||||
}
|
||||
|
||||
/// Conversion to string, but only as a fractional representation
|
||||
/// i.e. "123/456". Use printAmount() for user-visible values
|
||||
/// instead.
|
||||
Glib::ustring to_string() const
|
||||
{
|
||||
return gchar_to_ustring(gnc_numeric_to_string(*this));
|
||||
}
|
||||
|
||||
GNCNumericErrorCode check() const
|
||||
{
|
||||
return gnc_numeric_check(*this);
|
||||
}
|
||||
gint compare(const Numeric& b) const
|
||||
{
|
||||
return gnc_numeric_compare(*this, b);
|
||||
}
|
||||
bool zero_p() const
|
||||
{
|
||||
return gnc_numeric_zero_p(*this);
|
||||
}
|
||||
bool negative_p() const
|
||||
{
|
||||
return gnc_numeric_negative_p(*this);
|
||||
}
|
||||
bool positive_p() const
|
||||
{
|
||||
return gnc_numeric_positive_p(*this);
|
||||
}
|
||||
bool eq(const Numeric& b) const
|
||||
{
|
||||
return gnc_numeric_eq(*this, b);
|
||||
}
|
||||
bool equal(const Numeric& b) const
|
||||
{
|
||||
return gnc_numeric_equal(*this, b);
|
||||
}
|
||||
bool same(const Numeric& b, gint64 denom, gint how) const
|
||||
{
|
||||
return gnc_numeric_same(*this, b, denom, how);
|
||||
}
|
||||
|
||||
Numeric add(const Numeric& b, gint64 denom, gint how) const
|
||||
{
|
||||
return gnc_numeric_add(*this, b, denom, how);
|
||||
}
|
||||
Numeric sub(const Numeric& b, gint64 denom, gint how) const
|
||||
{
|
||||
return gnc_numeric_sub(*this, b, denom, how);
|
||||
}
|
||||
Numeric mul(const Numeric& b, gint64 denom, gint how) const
|
||||
{
|
||||
return gnc_numeric_mul(*this, b, denom, how);
|
||||
}
|
||||
Numeric div(const Numeric& b, gint64 denom, gint how) const
|
||||
{
|
||||
return gnc_numeric_div(*this, b, denom, how);
|
||||
}
|
||||
Numeric neg() const
|
||||
{
|
||||
return gnc_numeric_neg(*this);
|
||||
}
|
||||
Numeric abs() const
|
||||
{
|
||||
return gnc_numeric_abs(*this);
|
||||
}
|
||||
|
||||
Numeric add_fixed(const Numeric& b) const
|
||||
{
|
||||
return gnc_numeric_add_fixed(*this, b);
|
||||
}
|
||||
Numeric sub_fixed(const Numeric& b) const
|
||||
{
|
||||
return gnc_numeric_sub_fixed(*this, b);
|
||||
}
|
||||
|
||||
Numeric reduce() const
|
||||
{
|
||||
return gnc_numeric_reduce(*this);
|
||||
}
|
||||
|
||||
Glib::ustring printAmount(const PrintAmountInfo& info) const;
|
||||
|
||||
/** Parses the given string by the expression parser. On success,
|
||||
* the value is written into this object and an empty string is
|
||||
* returned. On error, this object is unchanged and a string with
|
||||
* the error message is returned. */
|
||||
Glib::ustring parse(const Glib::ustring& str);
|
||||
};
|
||||
|
||||
inline bool operator==(const Numeric& a, const Numeric& b)
|
||||
{
|
||||
return a.equal(b);
|
||||
}
|
||||
|
||||
inline bool operator!=(const Numeric& a, const Numeric& b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
/// Returns the negative value of a
|
||||
inline Numeric operator-(const Numeric& a)
|
||||
{
|
||||
return a.neg();
|
||||
}
|
||||
|
||||
/// Returns a + b
|
||||
inline Numeric operator+(const Numeric& a, const Numeric& b)
|
||||
{
|
||||
return a.add_fixed(b);
|
||||
}
|
||||
|
||||
/// Returns a - b
|
||||
inline Numeric operator-(const Numeric& a, const Numeric& b)
|
||||
{
|
||||
return a.sub_fixed(b);
|
||||
}
|
||||
|
||||
} // END namespace gnc
|
||||
|
||||
|
||||
#endif
|
@ -1,205 +0,0 @@
|
||||
/*
|
||||
* Split.cpp
|
||||
* Copyright (C) 2010 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#include "Split.hpp"
|
||||
|
||||
#include "Account.hpp"
|
||||
#include "Book.hpp"
|
||||
#include "Transaction.hpp"
|
||||
#include "private/Split_p.hpp"
|
||||
|
||||
namespace Glib
|
||||
{
|
||||
|
||||
Glib::RefPtr<gnc::Split> wrap(::Split* object, bool take_copy)
|
||||
{
|
||||
return Glib::RefPtr<gnc::Split>( dynamic_cast<gnc::Split*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
|
||||
//We use dynamic_cast<> in case of multiple inheritance.
|
||||
}
|
||||
|
||||
} /* namespace Glib */
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
/* The *_Class implementation: */
|
||||
|
||||
const Glib::Class& Split_Class::init()
|
||||
{
|
||||
if (!gtype_) // create the GType if necessary
|
||||
{
|
||||
// Glib::Class has to know the class init function to clone custom types.
|
||||
class_init_func_ = &Split_Class::class_init_function;
|
||||
|
||||
// This is actually just optimized away, apparently with no harm.
|
||||
// Make sure that the parent type has been created.
|
||||
//CppClassParent::CppObjectType::get_type();
|
||||
|
||||
// Create the wrapper type, with the same class/instance size as the base type.
|
||||
register_derived_type(gnc_split_get_type());
|
||||
|
||||
// Add derived versions of interfaces, if the C type implements any interfaces:
|
||||
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void Split_Class::class_init_function(void* g_class, void* class_data)
|
||||
{
|
||||
BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
|
||||
CppClassParent::class_init_function(klass, class_data);
|
||||
}
|
||||
|
||||
|
||||
Glib::ObjectBase* Split_Class::wrap_new(GObject* object)
|
||||
{
|
||||
return new Split((::Split*)object);
|
||||
}
|
||||
|
||||
|
||||
/* The implementation: */
|
||||
|
||||
::Split* Split::gobj_copy()
|
||||
{
|
||||
reference();
|
||||
return gobj();
|
||||
}
|
||||
|
||||
Split::Split(const Glib::ConstructParams& construct_params)
|
||||
: GncInstance(construct_params)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Split::Split(::Split* castitem)
|
||||
: GncInstance((::QofInstance*)(castitem))
|
||||
{}
|
||||
|
||||
|
||||
Split::~Split()
|
||||
{}
|
||||
|
||||
|
||||
Split::CppClassType Split::split_class_; // initialize static member
|
||||
|
||||
GType Split::get_type()
|
||||
{
|
||||
return split_class_.init().get_type();
|
||||
}
|
||||
|
||||
|
||||
GType Split::get_base_type()
|
||||
{
|
||||
return gnc_split_get_type();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Glib::RefPtr<Account> Split::get_account() const
|
||||
{
|
||||
return Glib::wrap(xaccSplitGetAccount(gobj()));
|
||||
}
|
||||
void Split::set_account(Glib::RefPtr<Account> acc)
|
||||
{
|
||||
if (acc) xaccSplitSetAccount(gobj(), acc->gobj());
|
||||
}
|
||||
void Split::set_account(::Account* acc)
|
||||
{
|
||||
xaccSplitSetAccount(gobj(), acc);
|
||||
}
|
||||
|
||||
|
||||
Glib::RefPtr<Transaction> Split::get_parent() const
|
||||
{
|
||||
return Glib::wrap(xaccSplitGetParent(gobj()));
|
||||
}
|
||||
void Split::set_parent(Glib::RefPtr<Transaction> trans)
|
||||
{
|
||||
if (trans) xaccSplitSetParent(gobj(), trans->gobj());
|
||||
}
|
||||
void Split::set_parent(Transaction& trans)
|
||||
{
|
||||
xaccSplitSetParent(gobj(), trans.gobj());
|
||||
}
|
||||
|
||||
Glib::RefPtr<Split> Split::get_other_split() const
|
||||
{
|
||||
return Glib::wrap(xaccSplitGetOtherSplit(gobj()));
|
||||
}
|
||||
|
||||
|
||||
TmpSplit::TmpSplit(const Glib::RefPtr<Split>& s, const TmpTransaction* parent_trans)
|
||||
: m_account(s->get_account()->gobj())
|
||||
, m_parent(parent_trans)
|
||||
, m_memo(s->get_memo())
|
||||
, m_action(s->get_action())
|
||||
, m_reconcile(s->get_reconcile())
|
||||
, m_amount(s->get_amount())
|
||||
, m_value(s->get_value())
|
||||
{}
|
||||
|
||||
TmpSplit::TmpSplit(::Account* account)
|
||||
{
|
||||
clear(account);
|
||||
}
|
||||
|
||||
TmpSplit* TmpSplit::get_other_split() const
|
||||
{
|
||||
if (!m_parent)
|
||||
return NULL;
|
||||
const TmpTransaction& p = *m_parent;
|
||||
if (p.get_num_splits() != 2)
|
||||
return NULL;
|
||||
TmpTransaction::TmpSplitList& splits = const_cast<TmpTransaction&>(p).get_splits();
|
||||
if (splits.front().get_account() != m_account)
|
||||
return &splits.front();
|
||||
else
|
||||
return &splits.back();
|
||||
}
|
||||
|
||||
void TmpSplit::clear(::Account* account)
|
||||
{
|
||||
m_account = account;
|
||||
m_parent = NULL;
|
||||
m_memo.clear();
|
||||
m_action.clear();
|
||||
m_reconcile = NREC;
|
||||
m_amount = Numeric::zero();
|
||||
m_value = Numeric::zero();
|
||||
}
|
||||
|
||||
void TmpSplit::copy_into(Glib::RefPtr<Transaction> t) const
|
||||
{
|
||||
g_assert(t);
|
||||
Glib::RefPtr<Split> s(Glib::wrap(xaccMallocSplit(t->get_book()->gobj())));
|
||||
s->set_account(m_account);
|
||||
s->set_parent(t);
|
||||
s->set_memo(m_memo);
|
||||
s->set_action(m_action);
|
||||
s->set_reconcile(m_reconcile);
|
||||
s->set_amount(m_amount);
|
||||
s->set_value(m_value);
|
||||
}
|
||||
|
||||
} // END namespace gnc
|
@ -1,322 +0,0 @@
|
||||
/*
|
||||
* Split.hpp
|
||||
* Copyright (C) 2011 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#ifndef GNC_SPLIT_HPP
|
||||
#define GNC_SPLIT_HPP
|
||||
|
||||
// gnucash includes
|
||||
#include "config.h"
|
||||
#include "engine/guid.hpp"
|
||||
extern "C"
|
||||
{
|
||||
#include "qof.h"
|
||||
#include "engine/Split.h"
|
||||
}
|
||||
|
||||
#include <glibmm/object.h>
|
||||
#include <glibmm/date.h>
|
||||
#include <glibmm/ustring.h>
|
||||
#include <vector>
|
||||
|
||||
#include "GncInstance.hpp"
|
||||
#include "Numeric.hpp"
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
class Split_Class;
|
||||
} // END namespace gnc
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
class Book;
|
||||
class Account;
|
||||
class Transaction;
|
||||
class TmpTransaction;
|
||||
|
||||
typedef std::vector< ::Split*> SplitQList;
|
||||
|
||||
/** Wrapper around a gnucash ::Split pointer with C++ methods for
|
||||
* easier setter and getter access.
|
||||
*/
|
||||
class Split : public GncInstance
|
||||
{
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
typedef Split CppObjectType;
|
||||
typedef Split_Class CppClassType;
|
||||
typedef ::Split BaseObjectType;
|
||||
typedef ::SplitClass BaseClassType;
|
||||
|
||||
private:
|
||||
friend class Split_Class;
|
||||
static CppClassType split_class_;
|
||||
|
||||
private:
|
||||
// noncopyable
|
||||
Split(const Split&);
|
||||
Split& operator=(const Split&);
|
||||
|
||||
protected:
|
||||
explicit Split(const Glib::ConstructParams& construct_params);
|
||||
explicit Split(::Split* castitem);
|
||||
|
||||
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
|
||||
|
||||
public:
|
||||
virtual ~Split();
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
static GType get_type() G_GNUC_CONST;
|
||||
static GType get_base_type() G_GNUC_CONST;
|
||||
#endif
|
||||
|
||||
///Provides access to the underlying C GObject.
|
||||
::Split* gobj()
|
||||
{
|
||||
return reinterpret_cast< ::Split*>(gobject_);
|
||||
}
|
||||
|
||||
///Provides access to the underlying C GObject.
|
||||
const ::Split* gobj() const
|
||||
{
|
||||
return reinterpret_cast< ::Split*>(gobject_);
|
||||
}
|
||||
|
||||
///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
|
||||
::Split* gobj_copy();
|
||||
|
||||
private:
|
||||
public:
|
||||
|
||||
|
||||
Glib::RefPtr<Account> get_account() const;
|
||||
void set_account(Glib::RefPtr<Account> acc);
|
||||
void set_account(::Account* acc);
|
||||
|
||||
Glib::RefPtr<Transaction> get_parent() const;
|
||||
void set_parent(Glib::RefPtr<Transaction> trans);
|
||||
void set_parent(Transaction& trans);
|
||||
|
||||
Glib::ustring get_memo() const
|
||||
{
|
||||
return xaccSplitGetMemo(gobj());
|
||||
}
|
||||
void set_memo(const Glib::ustring& v)
|
||||
{
|
||||
xaccSplitSetMemo(gobj(), v.c_str());
|
||||
}
|
||||
|
||||
Glib::ustring get_action() const
|
||||
{
|
||||
return xaccSplitGetAction(gobj());
|
||||
}
|
||||
void set_action(const Glib::ustring& v)
|
||||
{
|
||||
xaccSplitSetAction(gobj(), v.c_str());
|
||||
}
|
||||
|
||||
char get_reconcile() const
|
||||
{
|
||||
return xaccSplitGetReconcile(gobj());
|
||||
}
|
||||
void set_reconcile(char v)
|
||||
{
|
||||
xaccSplitSetReconcile(gobj(), v);
|
||||
}
|
||||
|
||||
Glib::RefPtr<Split> get_other_split() const;
|
||||
|
||||
Glib::ustring get_corr_account_full_name() const
|
||||
{
|
||||
return gchar_to_ustring(xaccSplitGetCorrAccountFullName(gobj()));
|
||||
}
|
||||
Glib::ustring get_corr_account_name() const
|
||||
{
|
||||
return xaccSplitGetCorrAccountName(gobj());
|
||||
}
|
||||
Glib::ustring get_corr_account_code() const
|
||||
{
|
||||
return xaccSplitGetCorrAccountCode(gobj());
|
||||
}
|
||||
|
||||
void set_amount(const Numeric& amount)
|
||||
{
|
||||
xaccSplitSetAmount(gobj(), amount);
|
||||
}
|
||||
Numeric get_amount() const
|
||||
{
|
||||
return xaccSplitGetAmount(gobj());
|
||||
}
|
||||
void set_value(const Numeric& value)
|
||||
{
|
||||
xaccSplitSetValue(gobj(), value);
|
||||
}
|
||||
Numeric get_value() const
|
||||
{
|
||||
return xaccSplitGetValue(gobj());
|
||||
}
|
||||
Numeric get_share_price() const
|
||||
{
|
||||
return xaccSplitGetSharePrice(gobj());
|
||||
}
|
||||
Numeric get_balance() const
|
||||
{
|
||||
return xaccSplitGetBalance(gobj());
|
||||
}
|
||||
Numeric get_cleared_balance() const
|
||||
{
|
||||
return xaccSplitGetClearedBalance(gobj());
|
||||
}
|
||||
Numeric get_reconciled_balance() const
|
||||
{
|
||||
return xaccSplitGetReconciledBalance(gobj());
|
||||
}
|
||||
|
||||
|
||||
static SplitQList from_glist(GList* glist)
|
||||
{
|
||||
return gnc::from_glist<SplitQList>(glist);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/** This is a temporary split which belongs to a temporary transaction
|
||||
* (class gnc::TmpTransaction). Each of this tmp splits has all data
|
||||
* fields just like a "real" split, but it is not (yet) added to the
|
||||
* respective Account and Book. In other words, it is not stored in
|
||||
* the book yet.
|
||||
*
|
||||
* For this reason this class supports a full copy-by-value, which
|
||||
* will create new independent instances of all data fields. */
|
||||
class TmpSplit
|
||||
{
|
||||
public:
|
||||
/** Creates a new tmp split whose content is copied from the given
|
||||
* real transaction and it should belong to the given
|
||||
* TmpTransaction (but it is not added to the TmpTransaction's
|
||||
* split list here). */
|
||||
TmpSplit(const Glib::RefPtr<Split>& s, const TmpTransaction* parent_trans);
|
||||
|
||||
/** Creates a new empty tmp split, with the Account pointer
|
||||
* initialized with the given value. */
|
||||
TmpSplit(::Account* account = NULL);
|
||||
|
||||
/** Clears all data fields of this split. */
|
||||
void clear(::Account* account = NULL);
|
||||
|
||||
/** Copies the content of this tmp split into the given real
|
||||
* transaction by allocating a new real gnc::Split and adding it
|
||||
* to the given real gnc::Transaction. */
|
||||
void copy_into(Glib::RefPtr<Transaction> t) const;
|
||||
|
||||
::Account* get_account() const
|
||||
{
|
||||
return m_account;
|
||||
}
|
||||
void set_account(::Account* v)
|
||||
{
|
||||
m_account = v;
|
||||
}
|
||||
|
||||
const TmpTransaction* get_parent() const
|
||||
{
|
||||
return m_parent;
|
||||
}
|
||||
void set_parent(const TmpTransaction* v)
|
||||
{
|
||||
m_parent = v;
|
||||
}
|
||||
|
||||
/** Returns a pointer to the "Other" split if it exists, or NULL
|
||||
* if none or multiple of them exist. */
|
||||
TmpSplit* get_other_split() const;
|
||||
|
||||
Glib::ustring get_memo() const
|
||||
{
|
||||
return m_memo;
|
||||
}
|
||||
void set_memo(const Glib::ustring& v)
|
||||
{
|
||||
m_memo = v;
|
||||
}
|
||||
|
||||
Glib::ustring get_action() const
|
||||
{
|
||||
return m_action;
|
||||
}
|
||||
void set_action(const Glib::ustring& v)
|
||||
{
|
||||
m_action = v;
|
||||
}
|
||||
|
||||
char get_reconcile() const
|
||||
{
|
||||
return m_reconcile;
|
||||
}
|
||||
void set_reconcile(char v)
|
||||
{
|
||||
m_reconcile = v;
|
||||
}
|
||||
|
||||
Numeric get_amount() const
|
||||
{
|
||||
return m_amount;
|
||||
}
|
||||
void set_amount(const Numeric& v)
|
||||
{
|
||||
m_amount = v;
|
||||
}
|
||||
|
||||
Numeric get_value() const
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
void set_value(const Numeric& v)
|
||||
{
|
||||
m_value = v;
|
||||
}
|
||||
|
||||
private:
|
||||
::Account* m_account;
|
||||
const TmpTransaction* m_parent;
|
||||
Glib::ustring m_memo;
|
||||
Glib::ustring m_action;
|
||||
char m_reconcile;
|
||||
Numeric m_amount;
|
||||
Numeric m_value;
|
||||
};
|
||||
|
||||
} // END namespace gnc
|
||||
|
||||
namespace Glib
|
||||
{
|
||||
/** A Glib::wrap() method for this object.
|
||||
*
|
||||
* @param object The C instance.
|
||||
* @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
|
||||
* @result A C++ instance that wraps this C instance.
|
||||
*
|
||||
* @relates Gio::FileInfo
|
||||
*/
|
||||
Glib::RefPtr<gnc::Split> wrap(::Split* object, bool refuse_ownership = true);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
@ -1,225 +0,0 @@
|
||||
/*
|
||||
* Transaction.cpp
|
||||
* Copyright (C) 2011 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#include "Transaction.hpp"
|
||||
#include "Split.hpp"
|
||||
#include <cassert>
|
||||
#if HAVE_GLIBMM_VECTORUTILS_H
|
||||
// new in glibmm-2.29
|
||||
#include <glibmm/vectorutils.h>
|
||||
#endif
|
||||
#include "private/Transaction_p.hpp"
|
||||
|
||||
namespace Glib
|
||||
{
|
||||
|
||||
Glib::RefPtr<gnc::Transaction> wrap(::Transaction* object, bool take_copy)
|
||||
{
|
||||
return Glib::RefPtr<gnc::Transaction>( dynamic_cast<gnc::Transaction*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
|
||||
//We use dynamic_cast<> in case of multiple inheritance.
|
||||
}
|
||||
|
||||
} /* namespace Glib */
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
/* The *_Class implementation: */
|
||||
|
||||
const Glib::Class& Transaction_Class::init()
|
||||
{
|
||||
if (!gtype_) // create the GType if necessary
|
||||
{
|
||||
// Glib::Class has to know the class init function to clone custom types.
|
||||
class_init_func_ = &Transaction_Class::class_init_function;
|
||||
|
||||
// This is actually just optimized away, apparently with no harm.
|
||||
// Make sure that the parent type has been created.
|
||||
//CppClassParent::CppObjectType::get_type();
|
||||
|
||||
// Create the wrapper type, with the same class/instance size as the base type.
|
||||
register_derived_type(gnc_transaction_get_type());
|
||||
|
||||
// Add derived versions of interfaces, if the C type implements any interfaces:
|
||||
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void Transaction_Class::class_init_function(void* g_class, void* class_data)
|
||||
{
|
||||
BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
|
||||
CppClassParent::class_init_function(klass, class_data);
|
||||
}
|
||||
|
||||
|
||||
Glib::ObjectBase* Transaction_Class::wrap_new(GObject* object)
|
||||
{
|
||||
return new Transaction((::Transaction*)object);
|
||||
}
|
||||
|
||||
|
||||
/* The implementation: */
|
||||
|
||||
::Transaction* Transaction::gobj_copy()
|
||||
{
|
||||
reference();
|
||||
return gobj();
|
||||
}
|
||||
|
||||
Transaction::Transaction(const Glib::ConstructParams& construct_params)
|
||||
: GncInstance(construct_params)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Transaction::Transaction(::Transaction* castitem)
|
||||
: GncInstance((::QofInstance*)(castitem))
|
||||
{}
|
||||
|
||||
|
||||
Transaction::~Transaction()
|
||||
{}
|
||||
|
||||
|
||||
Transaction::CppClassType Transaction::transaction_class_; // initialize static member
|
||||
|
||||
GType Transaction::get_type()
|
||||
{
|
||||
return transaction_class_.init().get_type();
|
||||
}
|
||||
|
||||
|
||||
GType Transaction::get_base_type()
|
||||
{
|
||||
return gnc_transaction_get_type();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Glib::RefPtr<Split> Transaction::find_split_by_account(const Account& acc) const
|
||||
{
|
||||
return Glib::wrap(xaccTransFindSplitByAccount(gobj(), acc.gobj()));
|
||||
}
|
||||
Glib::RefPtr<Split> Transaction::get_split(int i) const
|
||||
{
|
||||
return Glib::wrap(xaccTransGetSplit(gobj(), i));
|
||||
}
|
||||
void Transaction::append_split(Glib::RefPtr<Split> split)
|
||||
{
|
||||
g_assert(split);
|
||||
xaccSplitSetParent(split->gobj(), gobj());
|
||||
}
|
||||
int Transaction::get_split_index(const Split& split) const
|
||||
{
|
||||
return xaccTransGetSplitIndex(gobj(), split.gobj());
|
||||
}
|
||||
::Transaction* Transaction::new_instance(const Glib::RefPtr<Book> b)
|
||||
{
|
||||
if (b)
|
||||
return xaccMallocTransaction (const_cast< ::QofBook*>(b->gobj()));
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ////////////////////////////////////////////////////////////
|
||||
|
||||
TmpTransaction::TmpTransaction()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
TmpTransaction::TmpTransaction(const Transaction& t)
|
||||
: m_num(t.get_num())
|
||||
, m_description(t.get_description())
|
||||
, m_notes(t.get_notes())
|
||||
, m_commodity(t.get_currency())
|
||||
, m_datePosted(t.get_date_posted())
|
||||
, m_dateTimeEntered(t.get_date_entered_tt())
|
||||
{
|
||||
SplitQList slist = Split::from_glist(t.get_split_list());
|
||||
for (SplitQList::const_iterator iter = slist.begin(); iter != slist.end(); ++iter)
|
||||
{
|
||||
m_splits.push_back(TmpSplit(Glib::wrap(*iter), this));
|
||||
}
|
||||
}
|
||||
|
||||
void TmpTransaction::clear()
|
||||
{
|
||||
m_splits.clear();
|
||||
reset_content();
|
||||
}
|
||||
|
||||
void TmpTransaction::reset_content()
|
||||
{
|
||||
m_num.clear();
|
||||
m_description.clear();
|
||||
m_notes.clear();
|
||||
m_commodity.reset();
|
||||
m_datePosted = Glib::Date();
|
||||
m_dateTimeEntered = 0;
|
||||
for (int i = 0; i < m_splits.size(); ++i)
|
||||
{
|
||||
TmpSplit& split = m_splits[i];
|
||||
split.clear();
|
||||
split.set_parent(this);
|
||||
}
|
||||
}
|
||||
|
||||
void TmpTransaction::copy_to(Glib::RefPtr<Transaction> t) const
|
||||
{
|
||||
assert(t);
|
||||
t->set_num(m_num);
|
||||
t->set_description(m_description);
|
||||
if (!m_notes.empty())
|
||||
t->set_notes(m_notes);
|
||||
t->set_currency(m_commodity);
|
||||
t->set_date_posted(m_datePosted);
|
||||
t->set_date_entered(m_dateTimeEntered);
|
||||
for (int i = 0; i < m_splits.size(); ++i)
|
||||
{
|
||||
m_splits[i].copy_into(t);
|
||||
}
|
||||
}
|
||||
|
||||
Glib::RefPtr<Transaction> TmpTransaction::create_as_real() const
|
||||
{
|
||||
assert (!m_splits.empty());
|
||||
Glib::RefPtr<Account> acc(Glib::wrap(m_splits.front().get_account()));
|
||||
assert (acc);
|
||||
Glib::RefPtr<Book> book(acc->get_book());
|
||||
assert (book);
|
||||
Glib::RefPtr<Transaction> trans(Glib::wrap(Transaction::new_instance(book)));
|
||||
trans->begin_edit();
|
||||
copy_to(trans);
|
||||
trans->commit_edit();
|
||||
return trans;
|
||||
}
|
||||
|
||||
void TmpTransaction::push_back(const TmpSplit& s)
|
||||
{
|
||||
m_splits.push_back(s);
|
||||
m_splits.back().set_parent(this);
|
||||
}
|
||||
|
||||
} // END namespace gnc
|
@ -1,336 +0,0 @@
|
||||
/*
|
||||
* Transaction.hpp
|
||||
* Copyright (C) 2011 Christian Stimming
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#ifndef GNC_TRANSACTION_HPP
|
||||
#define GNC_TRANSACTION_HPP
|
||||
|
||||
// gnucash includes
|
||||
#include "config.h"
|
||||
#include "libqof/qof/guid.hpp"
|
||||
extern "C"
|
||||
{
|
||||
#include "qof.h"
|
||||
#include "engine/Transaction.h"
|
||||
}
|
||||
|
||||
#include "Account.hpp"
|
||||
#include "Book.hpp"
|
||||
#include "Commodity.hpp"
|
||||
#include "Numeric.hpp"
|
||||
#include "GncInstance.hpp"
|
||||
#include "Split.hpp"
|
||||
|
||||
#include <glibmm/object.h>
|
||||
#include <glibmm/date.h>
|
||||
#include <glibmm/ustring.h>
|
||||
#include <vector>
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
class Transaction_Class;
|
||||
} // END namespace gnc
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
class Account;
|
||||
class Split;
|
||||
class TmpSplit;
|
||||
|
||||
/** Wrapper around a gnucash ::Transaction pointer with C++ methods for
|
||||
* easier setter and getter access.
|
||||
*/
|
||||
class Transaction : public GncInstance
|
||||
{
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
typedef Transaction CppObjectType;
|
||||
typedef Transaction_Class CppClassType;
|
||||
typedef ::Transaction BaseObjectType;
|
||||
typedef ::TransactionClass BaseClassType;
|
||||
|
||||
private:
|
||||
friend class Transaction_Class;
|
||||
static CppClassType transaction_class_;
|
||||
|
||||
private:
|
||||
// noncopyable
|
||||
Transaction(const Transaction&);
|
||||
Transaction& operator=(const Transaction&);
|
||||
|
||||
protected:
|
||||
explicit Transaction(const Glib::ConstructParams& construct_params);
|
||||
explicit Transaction(::Transaction* castitem);
|
||||
|
||||
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
|
||||
|
||||
public:
|
||||
virtual ~Transaction();
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
static GType get_type() G_GNUC_CONST;
|
||||
static GType get_base_type() G_GNUC_CONST;
|
||||
#endif
|
||||
|
||||
///Provides access to the underlying C GObject.
|
||||
::Transaction* gobj()
|
||||
{
|
||||
return reinterpret_cast< ::Transaction*>(gobject_);
|
||||
}
|
||||
|
||||
///Provides access to the underlying C GObject.
|
||||
const ::Transaction* gobj() const
|
||||
{
|
||||
return reinterpret_cast< ::Transaction*>(gobject_);
|
||||
}
|
||||
|
||||
///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
|
||||
::Transaction* gobj_copy();
|
||||
|
||||
private:
|
||||
public:
|
||||
|
||||
void begin_edit()
|
||||
{
|
||||
xaccTransBeginEdit(gobj());
|
||||
}
|
||||
void commit_edit()
|
||||
{
|
||||
xaccTransCommitEdit(gobj());
|
||||
}
|
||||
void rollback_edit()
|
||||
{
|
||||
xaccTransRollbackEdit(gobj());
|
||||
}
|
||||
bool is_open() const
|
||||
{
|
||||
return xaccTransIsOpen(gobj());
|
||||
}
|
||||
|
||||
|
||||
Glib::ustring get_num() const
|
||||
{
|
||||
return xaccTransGetNum(gobj());
|
||||
}
|
||||
void set_num(const Glib::ustring& v)
|
||||
{
|
||||
xaccTransSetNum(gobj(), v.c_str());
|
||||
}
|
||||
|
||||
Glib::ustring get_description() const
|
||||
{
|
||||
return xaccTransGetDescription(gobj());
|
||||
}
|
||||
void set_description(const Glib::ustring& v)
|
||||
{
|
||||
xaccTransSetDescription(gobj(), v.c_str());
|
||||
}
|
||||
|
||||
Glib::ustring get_notes() const
|
||||
{
|
||||
return xaccTransGetNotes(gobj());
|
||||
}
|
||||
void set_notes(const Glib::ustring& v)
|
||||
{
|
||||
xaccTransSetNotes(gobj(), v.c_str());
|
||||
}
|
||||
|
||||
int get_num_splits() const
|
||||
{
|
||||
return xaccTransCountSplits(gobj());
|
||||
}
|
||||
Glib::RefPtr<Split> find_split_by_account(const Account& acc) const;
|
||||
void append_split(Glib::RefPtr<Split> split);
|
||||
Glib::RefPtr<Split> get_split(int i) const;
|
||||
int get_split_index(const Split& split) const;
|
||||
::SplitList* get_split_list() const
|
||||
{
|
||||
return xaccTransGetSplitList(gobj());
|
||||
}
|
||||
|
||||
Glib::RefPtr<Commodity> get_currency() const
|
||||
{
|
||||
return Glib::wrap(xaccTransGetCurrency(gobj()));
|
||||
}
|
||||
void set_currency(const Glib::RefPtr<Commodity>& c)
|
||||
{
|
||||
if (c) xaccTransSetCurrency(gobj(), c->gobj());
|
||||
}
|
||||
|
||||
Numeric get_imbalance_value() const
|
||||
{
|
||||
return xaccTransGetImbalanceValue(gobj());
|
||||
}
|
||||
bool is_balanced() const
|
||||
{
|
||||
return xaccTransIsBalanced(gobj());
|
||||
}
|
||||
Numeric get_account_conv_rate(const Account& acc) const
|
||||
{
|
||||
return xaccTransGetAccountConvRate(gobj(), acc.gobj());
|
||||
}
|
||||
|
||||
void set_date_posted(const Glib::Date& d)
|
||||
{
|
||||
xaccTransSetDatePostedGDate(gobj(), *d.gobj());
|
||||
}
|
||||
Glib::Date get_date_posted() const
|
||||
{
|
||||
return Glib::Date(xaccTransGetDatePostedGDate(gobj()));
|
||||
}
|
||||
void set_date_entered(time_t t)
|
||||
{
|
||||
xaccTransSetDateEnteredSecs(gobj(), t);
|
||||
}
|
||||
// void set_date_entered(const Glib::DateTime& t) { xaccTransSetDateEnteredSecs(gobj(), t.toTime_t()); }
|
||||
time_t get_date_entered_tt() const
|
||||
{
|
||||
return timespecToTime64 (xaccTransRetDateEnteredTS(gobj()));
|
||||
}
|
||||
//Glib::DateTime get_date_entered() const { return toGDateTime(xaccTransRetDateEnteredTS(gobj())); }
|
||||
|
||||
static ::Transaction* new_instance(const Glib::RefPtr<Book> b);
|
||||
};
|
||||
|
||||
|
||||
/** This is a temporary transaction. Each of this tmp transactions has
|
||||
* all data fields just like a "real" transaction, but it is not (yet)
|
||||
* added to the respective Account and Book. In other words, it is not
|
||||
* stored in the book yet.
|
||||
*
|
||||
* For this reason this class supports a full copy-by-value, which
|
||||
* will create new independent instances of all data fields. */
|
||||
class TmpTransaction
|
||||
{
|
||||
public:
|
||||
typedef std::vector<TmpSplit> TmpSplitList;
|
||||
|
||||
/** Creates an empty tmp transaction */
|
||||
TmpTransaction();
|
||||
|
||||
/** Creates a tmp transaction whose content is copied from the
|
||||
* given real transaction */
|
||||
TmpTransaction(const Transaction& t);
|
||||
|
||||
/** Clears all data fields of this transaction, including deletion
|
||||
* of all splits stored here. */
|
||||
void clear();
|
||||
|
||||
/** Clears all data fields, but does not delete the splits and
|
||||
* instead only resets the data fields of all splits */
|
||||
void reset_content();
|
||||
|
||||
/** Copies the content of this tmp transaction into the given real
|
||||
* transaction. */
|
||||
void copy_to(Glib::RefPtr<Transaction> t) const;
|
||||
|
||||
/** Allocates a new real transaction in the Book and Account as
|
||||
* stored in the tmp transaction, copies the content of this tmp
|
||||
* transaction into the newly allocated one, and returns the
|
||||
* pointer to the newly created real transaction. */
|
||||
Glib::RefPtr<Transaction> create_as_real() const;
|
||||
|
||||
Glib::ustring get_num() const
|
||||
{
|
||||
return m_num;
|
||||
}
|
||||
void set_num(const Glib::ustring& v)
|
||||
{
|
||||
m_num = v;
|
||||
}
|
||||
|
||||
Glib::ustring get_description() const
|
||||
{
|
||||
return m_description;
|
||||
}
|
||||
void set_description(const Glib::ustring& v)
|
||||
{
|
||||
m_description = v;
|
||||
}
|
||||
|
||||
void push_back(const TmpSplit& s);
|
||||
const TmpSplitList& get_splits() const
|
||||
{
|
||||
return m_splits;
|
||||
}
|
||||
TmpSplitList& get_splits()
|
||||
{
|
||||
return m_splits;
|
||||
}
|
||||
int get_num_splits() const
|
||||
{
|
||||
return m_splits.size();
|
||||
}
|
||||
|
||||
Glib::RefPtr<Commodity> get_commodity() const
|
||||
{
|
||||
return m_commodity;
|
||||
}
|
||||
void set_commodity(const Glib::RefPtr<Commodity>& v)
|
||||
{
|
||||
m_commodity = v;
|
||||
}
|
||||
|
||||
Glib::Date get_date_posted() const
|
||||
{
|
||||
return m_datePosted;
|
||||
}
|
||||
void set_date_posted(const Glib::Date& v)
|
||||
{
|
||||
m_datePosted = v;
|
||||
}
|
||||
|
||||
time_t get_date_entered_tt() const
|
||||
{
|
||||
return m_dateTimeEntered;
|
||||
}
|
||||
void set_date_entered(time_t v)
|
||||
{
|
||||
m_dateTimeEntered = v;
|
||||
}
|
||||
//Glib::DateTime get_date_entered() const { return m_dateTimeEntered; }
|
||||
//void set_date_entered(const Glib::DateTime& v) { m_dateTimeEntered = v; }
|
||||
|
||||
private:
|
||||
Glib::ustring m_num;
|
||||
Glib::ustring m_description;
|
||||
Glib::ustring m_notes;
|
||||
TmpSplitList m_splits;
|
||||
Glib::RefPtr<Commodity> m_commodity;
|
||||
Glib::Date m_datePosted;
|
||||
time_t m_dateTimeEntered;
|
||||
//Glib::DateTime m_dateTimeEntered;
|
||||
};
|
||||
|
||||
} // END namespace gnc
|
||||
|
||||
namespace Glib
|
||||
{
|
||||
/** A Glib::wrap() method for this object.
|
||||
*
|
||||
* @param object The C instance.
|
||||
* @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
|
||||
* @result A C++ instance that wraps this C instance.
|
||||
*
|
||||
* @relates Gio::FileInfo
|
||||
*/
|
||||
Glib::RefPtr<gnc::Transaction> wrap(::Transaction* object, bool refuse_ownership = true);
|
||||
}
|
||||
|
||||
#endif
|
@ -1,48 +0,0 @@
|
||||
// -*- c++ -*-
|
||||
// Generated by gtkmmproc -- DO NOT MODIFY!
|
||||
#ifndef _GNCMM_PRIVATE_ACCOUNT_P_HPP
|
||||
#define _GNCMM_PRIVATE_ACCOUNT_P_HPP
|
||||
|
||||
|
||||
#include <glibmm/private/object_p.h>
|
||||
|
||||
#include <glibmm/class.h>
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
class Account_Class : public Glib::Class
|
||||
{
|
||||
public:
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
typedef Account CppObjectType;
|
||||
typedef ::Account BaseObjectType;
|
||||
typedef ::AccountClass BaseClassType;
|
||||
typedef Glib::Object_Class CppClassParent;
|
||||
typedef GObjectClass BaseClassParent;
|
||||
|
||||
friend class Account;
|
||||
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
|
||||
|
||||
const Glib::Class& init();
|
||||
|
||||
|
||||
static void class_init_function(void* g_class, void* class_data);
|
||||
|
||||
static Glib::ObjectBase* wrap_new(GObject*);
|
||||
|
||||
protected:
|
||||
|
||||
//Callbacks (default signal handlers):
|
||||
//These will call the *_impl member methods, which will then call the existing default signal callbacks, if any.
|
||||
//You could prevent the original default signal handlers being called by overriding the *_impl method.
|
||||
|
||||
//Callbacks (virtual functions):
|
||||
};
|
||||
|
||||
|
||||
} // namespace gnc
|
||||
|
||||
|
||||
#endif /* _GNCMM_PRIVATE_ACCOUNT_P_HPP */
|
||||
|
@ -1,48 +0,0 @@
|
||||
// -*- c++ -*-
|
||||
// Generated by gtkmmproc -- DO NOT MODIFY!
|
||||
#ifndef _GNCMM_PRIVATE_BOOK_P_HPP
|
||||
#define _GNCMM_PRIVATE_BOOK_P_HPP
|
||||
|
||||
|
||||
#include <glibmm/private/object_p.h>
|
||||
|
||||
#include <glibmm/class.h>
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
class Book_Class : public Glib::Class
|
||||
{
|
||||
public:
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
typedef Book CppObjectType;
|
||||
typedef QofBook BaseObjectType;
|
||||
typedef QofBookClass BaseClassType;
|
||||
typedef Glib::Object_Class CppClassParent;
|
||||
typedef GObjectClass BaseClassParent;
|
||||
|
||||
friend class Book;
|
||||
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
|
||||
|
||||
const Glib::Class& init();
|
||||
|
||||
|
||||
static void class_init_function(void* g_class, void* class_data);
|
||||
|
||||
static Glib::ObjectBase* wrap_new(GObject*);
|
||||
|
||||
protected:
|
||||
|
||||
//Callbacks (default signal handlers):
|
||||
//These will call the *_impl member methods, which will then call the existing default signal callbacks, if any.
|
||||
//You could prevent the original default signal handlers being called by overriding the *_impl method.
|
||||
|
||||
//Callbacks (virtual functions):
|
||||
};
|
||||
|
||||
|
||||
} // namespace gnc
|
||||
|
||||
|
||||
#endif /* _GNCMM_PRIVATE_BOOK_P_HPP */
|
||||
|
@ -1,48 +0,0 @@
|
||||
// -*- c++ -*-
|
||||
// Generated by gtkmmproc -- DO NOT MODIFY!
|
||||
#ifndef _GNCMM_GNC_COMMODITY_P_H
|
||||
#define _GNCMM_GNC_COMMODITY_P_H
|
||||
|
||||
|
||||
#include <glibmm/private/object_p.h>
|
||||
|
||||
#include <glibmm/class.h>
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
class Commodity_Class : public Glib::Class
|
||||
{
|
||||
public:
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
typedef Commodity CppObjectType;
|
||||
typedef gnc_commodity BaseObjectType;
|
||||
typedef gnc_commodityClass BaseClassType;
|
||||
typedef Glib::Object_Class CppClassParent;
|
||||
typedef GObjectClass BaseClassParent;
|
||||
|
||||
friend class Commodity;
|
||||
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
|
||||
|
||||
const Glib::Class& init();
|
||||
|
||||
|
||||
static void class_init_function(void* g_class, void* class_data);
|
||||
|
||||
static Glib::ObjectBase* wrap_new(GObject*);
|
||||
|
||||
protected:
|
||||
|
||||
//Callbacks (default signal handlers):
|
||||
//These will call the *_impl member methods, which will then call the existing default signal callbacks, if any.
|
||||
//You could prevent the original default signal handlers being called by overriding the *_impl method.
|
||||
|
||||
//Callbacks (virtual functions):
|
||||
};
|
||||
|
||||
|
||||
} // namespace gnc
|
||||
|
||||
|
||||
#endif /* _GNCMM_GNC_COMMODITY_P_H */
|
||||
|
@ -1,48 +0,0 @@
|
||||
// -*- c++ -*-
|
||||
// Generated by gtkmmproc -- DO NOT MODIFY!
|
||||
#ifndef _GNCMM_GNC_COMMODITY_P_H
|
||||
#define _GNCMM_GNC_COMMODITY_P_H
|
||||
|
||||
|
||||
#include <glibmm/private/object_p.h>
|
||||
|
||||
#include <glibmm/class.h>
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
||||
class GncInstance_Class : public Glib::Class
|
||||
{
|
||||
public:
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
typedef GncInstance CppObjectType;
|
||||
typedef ::QofInstance BaseObjectType;
|
||||
typedef ::QofInstanceClass BaseClassType;
|
||||
typedef Glib::Object_Class CppClassParent;
|
||||
typedef GObjectClass BaseClassParent;
|
||||
|
||||
friend class GncInstance;
|
||||
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
|
||||
|
||||
const Glib::Class& init();
|
||||
|
||||
|
||||
static void class_init_function(void* g_class, void* class_data);
|
||||
|
||||
static Glib::ObjectBase* wrap_new(GObject*);
|
||||
|
||||
protected:
|
||||
|
||||
//Callbacks (default signal handlers):
|
||||
//These will call the *_impl member methods, which will then call the existing default signal callbacks, if any.
|
||||
//You could prevent the original default signal handlers being called by overriding the *_impl method.
|
||||
|
||||
//Callbacks (virtual functions):
|
||||
};
|
||||
|
||||
|
||||
} // namespace gnc
|
||||
|
||||
|
||||
#endif /* _GNCMM_GNC_COMMODITY_P_H */
|
||||
|