mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[Cutecash] Fix code to work with glibmm wrappers.
Changes: - Use QT_NO_KEYWORDS because the identifier "signal" collides with some glibmm dependency - Use Glib::RefPtr<> of gnucash objects everywhere. - Use Glib::ustring and Glib::Date instead of qt types The WeakPointer.hpp file is still used for gnc::Session, which is not (yet) a GObject. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21506 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
e4094a69c5
commit
58ed6b9863
@ -23,13 +23,13 @@
|
|||||||
#include "AccountItemModel.hpp"
|
#include "AccountItemModel.hpp"
|
||||||
|
|
||||||
#include "engine/gnc-event.h" // for GNC_EVENT_ITEM_ADDED
|
#include "engine/gnc-event.h" // for GNC_EVENT_ITEM_ADDED
|
||||||
#include "gnc/Numeric.hpp"
|
#include "gncmm/Numeric.hpp"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
namespace gnc
|
namespace gnc
|
||||||
{
|
{
|
||||||
|
|
||||||
AccountTreeModel::AccountTreeModel(Account rootaccount, QObject *parent)
|
AccountTreeModel::AccountTreeModel(Glib::RefPtr<Account> rootaccount, QObject *parent)
|
||||||
: QAbstractItemModel(parent)
|
: QAbstractItemModel(parent)
|
||||||
, m_root(rootaccount)
|
, m_root(rootaccount)
|
||||||
{
|
{
|
||||||
@ -42,18 +42,18 @@ QModelIndex AccountTreeModel::index(int row, int column,
|
|||||||
if (!hasIndex(row, column, parent))
|
if (!hasIndex(row, column, parent))
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
Account parentItem;
|
Glib::RefPtr<Account> parentItem;
|
||||||
|
|
||||||
if (!parent.isValid())
|
if (!parent.isValid())
|
||||||
parentItem = m_root;
|
parentItem = m_root;
|
||||||
else
|
else
|
||||||
parentItem.reset(static_cast< ::Account*>(parent.internalPointer()));
|
parentItem = Glib::wrap(static_cast< ::Account*>(parent.internalPointer()));
|
||||||
|
|
||||||
Account childItem = parentItem.nth_child(row);
|
Glib::RefPtr<Account> childItem = parentItem->nth_child(row);
|
||||||
if (childItem.gobj())
|
if (childItem)
|
||||||
{
|
{
|
||||||
//qDebug() << "returning" << childItem.getName();
|
//qDebug() << "returning" << childItem.getName();
|
||||||
return createIndex(row, column, childItem.gobj());
|
return createIndex(row, column, childItem->gobj());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
@ -65,13 +65,13 @@ QModelIndex AccountTreeModel::parent(const QModelIndex &index) const
|
|||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
Account childItem(static_cast< ::Account*>(index.internalPointer()));
|
Glib::RefPtr<Account> childItem = Glib::wrap(static_cast< ::Account*>(index.internalPointer()));
|
||||||
Account parentItem(childItem.get_parent());
|
Glib::RefPtr<Account> parentItem(childItem->get_parent());
|
||||||
|
|
||||||
if (parentItem.gobj() == m_root.gobj())
|
if (parentItem->gobj() == m_root->gobj())
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
return createIndex(parentItem.child_index(), 0, parentItem.gobj());
|
return createIndex(parentItem->child_index(), 0, parentItem->gobj());
|
||||||
}
|
}
|
||||||
|
|
||||||
int AccountTreeModel::rowCount(const QModelIndex& parent) const
|
int AccountTreeModel::rowCount(const QModelIndex& parent) const
|
||||||
@ -82,14 +82,14 @@ int AccountTreeModel::rowCount(const QModelIndex& parent) const
|
|||||||
// FIXME: Doesn't this just mean the nonzero columns don't have a
|
// FIXME: Doesn't this just mean the nonzero columns don't have a
|
||||||
// tree? In that case it would be correct.
|
// tree? In that case it would be correct.
|
||||||
|
|
||||||
Account parentItem;
|
Glib::RefPtr<Account> parentItem;
|
||||||
if (!parent.isValid())
|
if (!parent.isValid())
|
||||||
parentItem = m_root;
|
parentItem = m_root;
|
||||||
else
|
else
|
||||||
parentItem.reset(static_cast< ::Account*>(parent.internalPointer()));
|
parentItem = Glib::wrap(static_cast< ::Account*>(parent.internalPointer()));
|
||||||
|
|
||||||
//qDebug() << "Returning " << parentItem.n_children();
|
//qDebug() << "Returning " << parentItem.n_children();
|
||||||
return parentItem.n_children();
|
return parentItem->n_children();
|
||||||
}
|
}
|
||||||
|
|
||||||
int AccountTreeModel::columnCount(const QModelIndex& parent) const
|
int AccountTreeModel::columnCount(const QModelIndex& parent) const
|
||||||
@ -107,22 +107,22 @@ QVariant AccountTreeModel::data(const QModelIndex& index, int role) const
|
|||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
Account account(static_cast< ::Account*>(index.internalPointer()));
|
Glib::RefPtr<Account> account = Glib::wrap(static_cast< ::Account*>(index.internalPointer()));
|
||||||
if (role == Qt::DisplayRole)
|
if (role == Qt::DisplayRole)
|
||||||
{
|
{
|
||||||
switch (index.column())
|
switch (index.column())
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
return account.getName();
|
return g2q(account->getName());
|
||||||
case 1:
|
case 1:
|
||||||
return account.getCode();
|
return g2q(account->getCode());
|
||||||
case 2:
|
case 2:
|
||||||
return account.getDescription();
|
return g2q(account->getDescription());
|
||||||
case 3:
|
case 3:
|
||||||
{
|
{
|
||||||
Numeric balance = gnc_ui_account_get_balance(account.gobj(), false);
|
Numeric balance = gnc_ui_account_get_balance(account->gobj(), false);
|
||||||
PrintAmountInfo printInfo(account.gobj(), true);
|
PrintAmountInfo printInfo(account, true);
|
||||||
return balance.printAmount(printInfo);
|
return g2q(balance.printAmount(printInfo));
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
@ -170,7 +170,7 @@ QVariant AccountTreeModel::headerData(int section, Qt::Orientation orientation,
|
|||||||
// ////////////////////////////////////////////////////////////
|
// ////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
AccountListModel::AccountListModel(Account rootaccount, QObject *parent)
|
AccountListModel::AccountListModel(Glib::RefPtr<Account> rootaccount, QObject *parent)
|
||||||
: base_class(rootaccount, parent)
|
: base_class(rootaccount, parent)
|
||||||
, m_list()
|
, m_list()
|
||||||
, m_eventWrapperAccount(*this, &AccountListModel::accountEvent)
|
, m_eventWrapperAccount(*this, &AccountListModel::accountEvent)
|
||||||
@ -180,7 +180,7 @@ AccountListModel::AccountListModel(Account rootaccount, QObject *parent)
|
|||||||
|
|
||||||
void AccountListModel::recreateCache()
|
void AccountListModel::recreateCache()
|
||||||
{
|
{
|
||||||
m_list = accountFromGList(m_root.get_descendants());
|
m_list = accountFromGList(m_root->get_descendants());
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,11 +206,11 @@ QModelIndex AccountListModel::index(int row, int column,
|
|||||||
if (!hasIndex(row, column, parent) || row >= m_list.size())
|
if (!hasIndex(row, column, parent) || row >= m_list.size())
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
Account childItem = m_list.at(row);
|
Glib::RefPtr<Account> childItem = Glib::wrap(m_list.at(row));
|
||||||
if (childItem.gobj())
|
if (childItem)
|
||||||
{
|
{
|
||||||
//qDebug() << "returning" << childItem.getName();
|
//qDebug() << "returning" << childItem.getName();
|
||||||
return createIndex(row, column, childItem.gobj());
|
return createIndex(row, column, childItem->gobj());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
@ -229,14 +229,14 @@ QVariant AccountListNamesModel::data(const QModelIndex& index, int role) const
|
|||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
Account account(static_cast< ::Account*>(index.internalPointer()));
|
Glib::RefPtr<Account> account = Glib::wrap(static_cast< ::Account*>(index.internalPointer()));
|
||||||
switch (index.column())
|
switch (index.column())
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
switch (role)
|
switch (role)
|
||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
return account.getFullName();
|
return g2q(account->getFullName());
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,11 @@
|
|||||||
#ifndef GNC_ACCOUNTITEMMODEL_HPP
|
#ifndef GNC_ACCOUNTITEMMODEL_HPP
|
||||||
#define GNC_ACCOUNTITEMMODEL_HPP
|
#define GNC_ACCOUNTITEMMODEL_HPP
|
||||||
|
|
||||||
#include "gnc/Account.hpp"
|
#include "config.h"
|
||||||
|
#include "gncmm/Account.hpp"
|
||||||
#include "gnc/QofEventWrapper.hpp"
|
#include "gnc/QofEventWrapper.hpp"
|
||||||
|
#include "gnc/conv.hpp"
|
||||||
|
#include "gnc/metatype.hpp"
|
||||||
|
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
|
|
||||||
@ -47,7 +50,7 @@ class AccountTreeModel : public QAbstractItemModel
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
AccountTreeModel(Account rootaccount, QObject *parent = 0);
|
AccountTreeModel(Glib::RefPtr<Account> rootaccount, QObject *parent = 0);
|
||||||
|
|
||||||
int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
||||||
int columnCount(const QModelIndex& parent = QModelIndex()) const;
|
int columnCount(const QModelIndex& parent = QModelIndex()) const;
|
||||||
@ -60,7 +63,7 @@ public:
|
|||||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Account m_root;
|
Glib::RefPtr<Account> m_root;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QList< ::Account*> AccountQList;
|
typedef QList< ::Account*> AccountQList;
|
||||||
@ -77,7 +80,7 @@ class AccountListModel : public AccountTreeModel
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
typedef AccountTreeModel base_class;
|
typedef AccountTreeModel base_class;
|
||||||
AccountListModel(Account rootaccount, QObject *parent = 0);
|
AccountListModel(Glib::RefPtr<Account> rootaccount, QObject *parent = 0);
|
||||||
|
|
||||||
int rowCount(const QModelIndex& parent = QModelIndex()) const { return m_list.size(); }
|
int rowCount(const QModelIndex& parent = QModelIndex()) const { return m_list.size(); }
|
||||||
|
|
||||||
@ -89,7 +92,7 @@ public:
|
|||||||
int indexOf(AccountQList::value_type value) const { return m_list.indexOf(value); }
|
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); }
|
const AccountQList::value_type at(int i) const { return m_list.at(i); }
|
||||||
|
|
||||||
public slots:
|
public Q_SLOTS:
|
||||||
void accountEvent( ::Account* v, QofEventId event_type);
|
void accountEvent( ::Account* v, QofEventId event_type);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -107,15 +110,13 @@ class AccountListNamesModel : public AccountListModel
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
typedef AccountListModel base_class;
|
typedef AccountListModel base_class;
|
||||||
AccountListNamesModel(Account rootaccount, QObject *parent = 0)
|
AccountListNamesModel(Glib::RefPtr<Account> rootaccount, QObject *parent = 0)
|
||||||
: base_class(rootaccount, parent)
|
: base_class(rootaccount, parent)
|
||||||
{}
|
{}
|
||||||
int columnCount(const QModelIndex& parent = QModelIndex()) const;
|
int columnCount(const QModelIndex& parent = QModelIndex()) const;
|
||||||
QVariant data(const QModelIndex& index, int role) const;
|
QVariant data(const QModelIndex& index, int role) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // END namespace gnc
|
} // END namespace gnc
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -23,8 +23,8 @@
|
|||||||
#include "AccountSelectionDelegate.hpp"
|
#include "AccountSelectionDelegate.hpp"
|
||||||
|
|
||||||
#include "gnc/AccountItemModel.hpp"
|
#include "gnc/AccountItemModel.hpp"
|
||||||
#include "gnc/Book.hpp"
|
#include "gncmm/Book.hpp"
|
||||||
#include "gnc/Split.hpp"
|
#include "gncmm/Split.hpp"
|
||||||
#include "gnc/SplitListModel.hpp"
|
#include "gnc/SplitListModel.hpp"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@ -39,10 +39,13 @@ AccountSelectionDelegate::AccountSelectionDelegate(QObject* parent)
|
|||||||
|
|
||||||
QString AccountSelectionDelegate::displayText(const QVariant& value, const QLocale& locale) const
|
QString AccountSelectionDelegate::displayText(const QVariant& value, const QLocale& locale) const
|
||||||
{
|
{
|
||||||
if (value.canConvert<Account>())
|
if (value.canConvert< ::Account*>())
|
||||||
{
|
{
|
||||||
Account acc = value.value<Account>();
|
Glib::RefPtr<Account> acc = Glib::wrap(value.value< ::Account*>());
|
||||||
return acc.getFullName();
|
if (acc)
|
||||||
|
return g2q(acc->getFullName());
|
||||||
|
else
|
||||||
|
return QString();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -60,11 +63,11 @@ QWidget *AccountSelectionDelegate::createEditor(QWidget *parent,
|
|||||||
const SplitListModel* smodel = dynamic_cast<const SplitListModel*>(index.model());
|
const SplitListModel* smodel = dynamic_cast<const SplitListModel*>(index.model());
|
||||||
if (smodel)
|
if (smodel)
|
||||||
{
|
{
|
||||||
Account modelAccount = smodel->getAccount();
|
Glib::RefPtr<Account> modelAccount = smodel->getAccount();
|
||||||
Q_ASSERT(modelAccount);
|
Q_ASSERT(modelAccount);
|
||||||
Book book = modelAccount.getBook();
|
Glib::RefPtr<Book> book = modelAccount->getBook();
|
||||||
Q_ASSERT(book);
|
Q_ASSERT(book);
|
||||||
Account rootaccount = book.get_root_account();
|
Glib::RefPtr<Account> rootaccount = book->get_root_account();
|
||||||
Q_ASSERT(rootaccount);
|
Q_ASSERT(rootaccount);
|
||||||
AccountListModel* model = new AccountListNamesModel(rootaccount, comboBox);
|
AccountListModel* model = new AccountListNamesModel(rootaccount, comboBox);
|
||||||
comboBox->setModel(model);
|
comboBox->setModel(model);
|
||||||
@ -81,14 +84,14 @@ void AccountSelectionDelegate::setEditorData(QWidget *editor, const QModelIndex
|
|||||||
Q_ASSERT(index.isValid());
|
Q_ASSERT(index.isValid());
|
||||||
|
|
||||||
QVariant value = index.model()->data(index, Qt::EditRole);
|
QVariant value = index.model()->data(index, Qt::EditRole);
|
||||||
if (value.canConvert<Account>())
|
if (value.canConvert< ::Account*>())
|
||||||
{
|
{
|
||||||
Account acc = value.value<Account>();
|
Glib::RefPtr<Account> acc = Glib::wrap(value.value< ::Account*>());
|
||||||
if (acc)
|
if (acc)
|
||||||
{
|
{
|
||||||
const AccountListModel* amodel = dynamic_cast<const AccountListModel*>(comboBox->model());
|
const AccountListModel* amodel = dynamic_cast<const AccountListModel*>(comboBox->model());
|
||||||
Q_ASSERT(amodel);
|
Q_ASSERT(amodel);
|
||||||
comboBox->setCurrentIndex(amodel->indexOf(acc.gobj()));
|
comboBox->setCurrentIndex(amodel->indexOf(acc->gobj()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -108,7 +111,7 @@ void AccountSelectionDelegate::setModelData(QWidget *editor, QAbstractItemModel
|
|||||||
return;
|
return;
|
||||||
const AccountListModel* amodel = dynamic_cast<const AccountListModel*>(comboBox->model());
|
const AccountListModel* amodel = dynamic_cast<const AccountListModel*>(comboBox->model());
|
||||||
Q_ASSERT(amodel);
|
Q_ASSERT(amodel);
|
||||||
Account acc(amodel->at(currentIndex));
|
::Account* acc(amodel->at(currentIndex));
|
||||||
if (acc)
|
if (acc)
|
||||||
{
|
{
|
||||||
model->setData(index, QVariant::fromValue(acc), Qt::EditRole);
|
model->setData(index, QVariant::fromValue(acc), Qt::EditRole);
|
||||||
|
@ -23,7 +23,8 @@
|
|||||||
#ifndef GNC_ACCOUNTSELECTIONDELEGATE_HPP
|
#ifndef GNC_ACCOUNTSELECTIONDELEGATE_HPP
|
||||||
#define GNC_ACCOUNTSELECTIONDELEGATE_HPP
|
#define GNC_ACCOUNTSELECTIONDELEGATE_HPP
|
||||||
|
|
||||||
#include "gnc/Account.hpp"
|
#include "config.h"
|
||||||
|
#include "gncmm/Account.hpp"
|
||||||
|
|
||||||
#include <QtGui/QStyledItemDelegate>
|
#include <QtGui/QStyledItemDelegate>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
@ -44,6 +44,8 @@ SET (gnc_QOBJECT_HEADERS
|
|||||||
fpo/ViewletView.hpp
|
fpo/ViewletView.hpp
|
||||||
)
|
)
|
||||||
SET (gnc_HEADERS ${gnc_QOBJECT_HEADERS}
|
SET (gnc_HEADERS ${gnc_QOBJECT_HEADERS}
|
||||||
|
conv.hpp
|
||||||
|
metatype.hpp
|
||||||
Cmd.hpp
|
Cmd.hpp
|
||||||
QofEventWrapper.hpp
|
QofEventWrapper.hpp
|
||||||
Session.hpp
|
Session.hpp
|
||||||
@ -92,6 +94,7 @@ INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/src/engine) # for swig-runtime.h
|
|||||||
INCLUDE_DIRECTORIES (${CMAKE_CURRENT_BINARY_DIR}) # for ui_mainwindow.h
|
INCLUDE_DIRECTORIES (${CMAKE_CURRENT_BINARY_DIR}) # for ui_mainwindow.h
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES (${QT_INCLUDES})
|
INCLUDE_DIRECTORIES (${QT_INCLUDES})
|
||||||
|
ADD_DEFINITIONS(-DQT_NO_KEYWORDS)
|
||||||
|
|
||||||
ADD_EXECUTABLE (cutecash
|
ADD_EXECUTABLE (cutecash
|
||||||
${gnc_FORMS_HEADERS}
|
${gnc_FORMS_HEADERS}
|
||||||
|
229
src/gnc/Cmd.cpp
229
src/gnc/Cmd.cpp
@ -21,9 +21,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Cmd.hpp"
|
#include "Cmd.hpp"
|
||||||
#include "gnc/Split.hpp"
|
#include "gncmm/Split.hpp"
|
||||||
#include "gnc/Account.hpp"
|
#include "gncmm/Account.hpp"
|
||||||
#include "gnc/Transaction.hpp"
|
#include "gncmm/Transaction.hpp"
|
||||||
|
#include "gnc/conv.hpp"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
namespace gnc
|
namespace gnc
|
||||||
@ -37,54 +38,54 @@ namespace cmd
|
|||||||
|
|
||||||
// ////////////////////////////////////////////////////////////
|
// ////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
QUndoCommand* setSplitMemo(Split& t, const QString& newValue)
|
QUndoCommand* setSplitMemo(Glib::RefPtr<Split> t, const QString& newValue)
|
||||||
{
|
{
|
||||||
return new Cmd<Split, QString>(QObject::tr("Edit Split Memo"),
|
return new Cmd<Split, Glib::ustring>(QObject::tr("Edit Split Memo"),
|
||||||
t, &Split::setMemo,
|
t, &Split::setMemo,
|
||||||
t.getMemo(), newValue);
|
t->getMemo(), q2g(newValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
QUndoCommand* setSplitAction(Split& t, const QString& newValue)
|
QUndoCommand* setSplitAction(Glib::RefPtr<Split> t, const QString& newValue)
|
||||||
{
|
{
|
||||||
return new Cmd<Split, QString>(QObject::tr("Edit Split Action"),
|
return new Cmd<Split, Glib::ustring>(QObject::tr("Edit Split Action"),
|
||||||
t, &Split::setAction,
|
t, &Split::setAction,
|
||||||
t.getAction(), newValue);
|
t->getAction(), q2g(newValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
QUndoCommand* setSplitReconcile(Split& t, char newValue)
|
QUndoCommand* setSplitReconcile(Glib::RefPtr<Split> t, char newValue)
|
||||||
{
|
{
|
||||||
if (newValue == t.getReconcile())
|
if (newValue == t->getReconcile())
|
||||||
return NULL;
|
return NULL;
|
||||||
// Special third argument: The setter function takes a value
|
// Special third argument: The setter function takes a value
|
||||||
// directly, instead of a const-reference, so the template type
|
// directly, instead of a const-reference, so the template type
|
||||||
// must be given explicitly.
|
// must be given explicitly.
|
||||||
return new Cmd<Split, char, void (Split::*)(char)>(QObject::tr("Edit Split Reconcile"),
|
return new Cmd<Split, char, void (Split::*)(char)>(QObject::tr("Edit Split Reconcile"),
|
||||||
t, &Split::setReconcile,
|
t, &Split::setReconcile,
|
||||||
t.getReconcile(), newValue);
|
t->getReconcile(), newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
QUndoCommand* setSplitAccount(Split& t, Account newValue)
|
QUndoCommand* setSplitAccount(Glib::RefPtr<Split> t, Glib::RefPtr<Account> newValue)
|
||||||
{
|
{
|
||||||
// Temporary function pointer "tmp" to resolve the ambiguous
|
// Temporary function pointer "tmp" to resolve the ambiguous
|
||||||
// overload "setAccount()".
|
// overload "setAccount()".
|
||||||
void (Split::*tmp)(Account) = &Split::setAccount;
|
void (Split::*tmp)(Glib::RefPtr<Account>) = &Split::setAccount;
|
||||||
return new Cmd<Split, Account, void (Split::*)(Account)>(QObject::tr("Edit Split Account"),
|
return new Cmd<Split, Glib::RefPtr<Account>, void (Split::*)(Glib::RefPtr<Account>)>(QObject::tr("Edit Split Account"),
|
||||||
t, tmp,
|
t, tmp,
|
||||||
t.getAccount(), newValue);
|
t->getAccount(), newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
QUndoCommand* setSplitAmount(Split& t, const Numeric& newValue)
|
QUndoCommand* setSplitAmount(Glib::RefPtr<Split> t, const Numeric& newValue)
|
||||||
{
|
{
|
||||||
return new Cmd<Split, Numeric>(QObject::tr("Edit Split Amount"),
|
return new Cmd<Split, Numeric>(QObject::tr("Edit Split Amount"),
|
||||||
t, &Split::setAmount,
|
t, &Split::setAmount,
|
||||||
t.getAmount(), newValue);
|
t->getAmount(), newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
QUndoCommand* setSplitValue(Split& t, const Numeric& newValue)
|
QUndoCommand* setSplitValue(Glib::RefPtr<Split> t, const Numeric& newValue)
|
||||||
{
|
{
|
||||||
return new Cmd<Split, Numeric>(QObject::tr("Edit Split Value"),
|
return new Cmd<Split, Numeric>(QObject::tr("Edit Split Value"),
|
||||||
t, &Split::setValue,
|
t, &Split::setValue,
|
||||||
t.getValue(), newValue);
|
t->getValue(), newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ////////////////////////////////////////////////////////////
|
// ////////////////////////////////////////////////////////////
|
||||||
@ -100,91 +101,97 @@ public:
|
|||||||
* value given directly.
|
* value given directly.
|
||||||
*/
|
*/
|
||||||
SplitValueAndAmountCmd(const QString& text,
|
SplitValueAndAmountCmd(const QString& text,
|
||||||
WeakPointer<target_type::element_type>& targetPtr,
|
Glib::RefPtr<Split> targetPtr,
|
||||||
const value_type& previousValue,
|
const value_type& previousValue,
|
||||||
const value_type& newValue,
|
const value_type& newValue,
|
||||||
QUndoCommand *parent = 0)
|
QUndoCommand *parent = 0)
|
||||||
: base_class(text, parent)
|
: base_class(text, parent)
|
||||||
, m_target(targetPtr.gobj())
|
, m_target(targetPtr)
|
||||||
, m_previousValue(previousValue)
|
, m_previousValue(previousValue)
|
||||||
, m_newValue(newValue)
|
, m_newValue(newValue)
|
||||||
{
|
{
|
||||||
Q_ASSERT(m_target);
|
Q_ASSERT(m_target);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void redo() { set(m_newValue); }
|
virtual void redo()
|
||||||
virtual void undo() { set(m_previousValue); }
|
{
|
||||||
|
set(m_newValue);
|
||||||
|
}
|
||||||
|
virtual void undo()
|
||||||
|
{
|
||||||
|
set(m_previousValue);
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
void set(const value_type& value)
|
void set(const value_type& value)
|
||||||
{
|
{
|
||||||
Transaction trans = m_target.getParent();
|
Glib::RefPtr<Transaction> trans = m_target->getParent();
|
||||||
if (trans.countSplits() != 2)
|
if (!trans || trans->countSplits() != 2)
|
||||||
return;
|
return;
|
||||||
Split other = m_target.getOtherSplit();
|
Glib::RefPtr<Split> other = m_target->getOtherSplit();
|
||||||
Q_ASSERT(other);
|
Q_ASSERT(other);
|
||||||
Commodity originCommodity = m_target.getAccount().getCommodity();
|
Glib::RefPtr<Commodity> originCommodity = m_target->getAccount()->getCommodity();
|
||||||
Commodity transCommodity = trans.getCurrency();
|
Glib::RefPtr<Commodity> transCommodity = trans->getCurrency();
|
||||||
Commodity otherCommodity = other.getAccount().getCommodity();
|
Glib::RefPtr<Commodity> otherCommodity = other->getAccount()->getCommodity();
|
||||||
if (originCommodity != transCommodity
|
if (originCommodity != transCommodity
|
||||||
|| transCommodity != otherCommodity)
|
|| transCommodity != otherCommodity)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
trans.beginEdit();
|
trans->beginEdit();
|
||||||
m_target.setValue(value);
|
m_target->setValue(value);
|
||||||
m_target.setAmount(value);
|
m_target->setAmount(value);
|
||||||
Numeric valueNeg = value.neg();
|
Numeric valueNeg = value.neg();
|
||||||
other.setAmount(valueNeg);
|
other->setAmount(valueNeg);
|
||||||
other.setValue(valueNeg);
|
other->setValue(valueNeg);
|
||||||
trans.commitEdit();
|
trans->commitEdit();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
target_type m_target;
|
Glib::RefPtr<target_type> m_target;
|
||||||
value_type m_previousValue;
|
value_type m_previousValue;
|
||||||
value_type m_newValue;
|
value_type m_newValue;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
QUndoCommand* setSplitValueAndAmount(Split& t, const Numeric& newValue)
|
QUndoCommand* setSplitValueAndAmount(Glib::RefPtr<Split> t, const Numeric& newValue)
|
||||||
{
|
{
|
||||||
return new SplitValueAndAmountCmd(QObject::tr("Edit Transaction Value"),
|
return new SplitValueAndAmountCmd(QObject::tr("Edit Transaction Value"),
|
||||||
t, t.getValue(), newValue);
|
t, t->getValue(), newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ////////////////////////////////////////////////////////////
|
// ////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
QUndoCommand* setTransactionNum(Transaction& t, const QString& newValue)
|
QUndoCommand* setTransactionNum(Glib::RefPtr<Transaction> t, const QString& newValue)
|
||||||
{
|
{
|
||||||
if (newValue == t.getNum())
|
if (newValue == g2q(t->getNum()))
|
||||||
return NULL;
|
return NULL;
|
||||||
return new Cmd<Transaction, QString>(QObject::tr("Edit Transaction Number"),
|
return new Cmd<Transaction, Glib::ustring>(QObject::tr("Edit Transaction Number"),
|
||||||
t, &Transaction::setNum,
|
t, &Transaction::setNum,
|
||||||
t.getNum(), newValue);
|
t->getNum(), q2g(newValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
QUndoCommand* setTransactionDescription(Transaction& t, const QString& newValue)
|
QUndoCommand* setTransactionDescription(Glib::RefPtr<Transaction> t, const QString& newValue)
|
||||||
{
|
{
|
||||||
if (newValue == t.getDescription())
|
if (newValue == g2q(t->getDescription()))
|
||||||
return NULL;
|
return NULL;
|
||||||
return new Cmd<Transaction, QString>(QObject::tr("Edit Transaction Description"),
|
return new Cmd<Transaction, Glib::ustring>(QObject::tr("Edit Transaction Description"),
|
||||||
t, &Transaction::setDescription,
|
t, &Transaction::setDescription,
|
||||||
t.getDescription(), newValue);
|
t->getDescription(), q2g(newValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
QUndoCommand* setTransactionNotes(Transaction& t, const QString& newValue)
|
QUndoCommand* setTransactionNotes(Glib::RefPtr<Transaction> t, const QString& newValue)
|
||||||
{
|
{
|
||||||
return new Cmd<Transaction, QString>(QObject::tr("Edit Transaction Notes"),
|
return new Cmd<Transaction, Glib::ustring>(QObject::tr("Edit Transaction Notes"),
|
||||||
t, &Transaction::setNotes,
|
t, &Transaction::setNotes,
|
||||||
t.getNotes(), newValue);
|
t->getNotes(), q2g(newValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
QUndoCommand* setTransactionDate(Transaction& t, const QDate& newValue)
|
QUndoCommand* setTransactionDate(Glib::RefPtr<Transaction> t, const QDate& newValue)
|
||||||
{
|
{
|
||||||
if (newValue == t.getDatePosted())
|
if (newValue == g2q(t->getDatePosted()))
|
||||||
return NULL;
|
return NULL;
|
||||||
return new Cmd<Transaction, QDate>(QObject::tr("Edit Transaction Date"),
|
return new Cmd<Transaction, Glib::Date>(QObject::tr("Edit Transaction Date"),
|
||||||
t, &Transaction::setDatePosted,
|
t, &Transaction::setDatePosted,
|
||||||
t.getDatePosted(), newValue);
|
t->getDatePosted(), q2g(newValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ////////////////////////////////////////////////////////////
|
// ////////////////////////////////////////////////////////////
|
||||||
@ -198,38 +205,38 @@ public:
|
|||||||
/** Constructor
|
/** Constructor
|
||||||
*/
|
*/
|
||||||
TransactionDestroyCmd(const QString& text,
|
TransactionDestroyCmd(const QString& text,
|
||||||
WeakPointer<target_type::element_type>& targetPtr,
|
Glib::RefPtr<target_type>& targetPtr,
|
||||||
QUndoCommand *parent = 0)
|
QUndoCommand *parent = 0)
|
||||||
: base_class(text, parent)
|
: base_class(text, parent)
|
||||||
, m_target(targetPtr.gobj())
|
, m_target(targetPtr)
|
||||||
, m_previousValue(m_target)
|
, m_previousValue(*targetPtr.operator->())
|
||||||
, m_book(m_target.getBook())
|
, m_book(m_target->getBook())
|
||||||
{
|
{
|
||||||
Q_ASSERT(m_target);
|
Q_ASSERT(m_target);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void redo()
|
virtual void redo()
|
||||||
{
|
{
|
||||||
xaccTransDestroy(m_target.gobj());
|
xaccTransDestroy(m_target->gobj());
|
||||||
m_target.reset();
|
m_target.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void undo()
|
virtual void undo()
|
||||||
{
|
{
|
||||||
m_target.reset(Transaction::newInstance(m_book));
|
m_target = Glib::wrap(Transaction::newInstance(m_book));
|
||||||
m_target.beginEdit();
|
m_target->beginEdit();
|
||||||
m_previousValue.copyTo(m_target);
|
m_previousValue.copyTo(m_target);
|
||||||
m_target.commitEdit();
|
m_target->commitEdit();
|
||||||
// Could also use m_previousValue.createAsReal()
|
// Could also use m_previousValue.createAsReal()
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
target_type m_target;
|
Glib::RefPtr<Transaction> m_target;
|
||||||
TmpTransaction m_previousValue;
|
TmpTransaction m_previousValue;
|
||||||
Book m_book;
|
Glib::RefPtr<Book> m_book;
|
||||||
};
|
};
|
||||||
|
|
||||||
QUndoCommand* destroyTransaction(Transaction& t)
|
QUndoCommand* destroyTransaction(Glib::RefPtr<Transaction> t)
|
||||||
{
|
{
|
||||||
return new TransactionDestroyCmd(QObject::tr("Delete Transaction"),
|
return new TransactionDestroyCmd(QObject::tr("Delete Transaction"),
|
||||||
t);
|
t);
|
||||||
@ -251,7 +258,7 @@ QUndoCommand* destroyTransaction(Transaction& t)
|
|||||||
* definition keeps a C pointer to the original object, and we hope
|
* definition keeps a C pointer to the original object, and we hope
|
||||||
* that one lives longer than we do.
|
* that one lives longer than we do.
|
||||||
*/
|
*/
|
||||||
template<class TargetT, class ValueT, typename SetterFunc = void (TargetT::*)(const ValueT&)>
|
template < class TargetT, class ValueT, typename SetterFunc = void (TargetT::*)(const ValueT&) >
|
||||||
class CmdRef : public QUndoCommand
|
class CmdRef : public QUndoCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -282,17 +289,23 @@ public:
|
|||||||
const value_type& previousValue,
|
const value_type& previousValue,
|
||||||
const value_type& newValue,
|
const value_type& newValue,
|
||||||
QUndoCommand *parent = 0)
|
QUndoCommand *parent = 0)
|
||||||
: base_class(text, parent)
|
: base_class(text, parent)
|
||||||
, m_target(targetRef)
|
, m_target(targetRef)
|
||||||
, m_setter(setter)
|
, m_setter(setter)
|
||||||
, m_previousValue(previousValue)
|
, m_previousValue(previousValue)
|
||||||
, m_newValue(newValue)
|
, m_newValue(newValue)
|
||||||
{
|
{
|
||||||
Q_ASSERT(m_setter);
|
Q_ASSERT(m_setter);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void redo() { set(m_newValue); }
|
virtual void redo()
|
||||||
virtual void undo() { set(m_previousValue); }
|
{
|
||||||
|
set(m_newValue);
|
||||||
|
}
|
||||||
|
virtual void undo()
|
||||||
|
{
|
||||||
|
set(m_previousValue);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void set(const value_type& value)
|
void set(const value_type& value)
|
||||||
@ -309,11 +322,11 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
QUndoCommand* setSplitAccount(TmpSplit& t, Account newValue)
|
QUndoCommand* setSplitAccount(TmpSplit& t, Glib::RefPtr<Account> newValue)
|
||||||
{
|
{
|
||||||
return new CmdRef<TmpSplit, ::Account*, void(TmpSplit::*)(::Account*)>(QObject::tr("Edit Split Account"),
|
return new CmdRef<TmpSplit, ::Account*, void(TmpSplit::*)(::Account*)>(QObject::tr("Edit Split Account"),
|
||||||
t, &TmpSplit::setAccount,
|
t, &TmpSplit::setAccount,
|
||||||
t.getAccount(), newValue.gobj());
|
t.getAccount(), newValue->gobj());
|
||||||
}
|
}
|
||||||
QUndoCommand* setSplitReconcile(TmpSplit& t, char newValue)
|
QUndoCommand* setSplitReconcile(TmpSplit& t, char newValue)
|
||||||
{
|
{
|
||||||
@ -326,21 +339,21 @@ QUndoCommand* setSplitReconcile(TmpSplit& t, char newValue)
|
|||||||
}
|
}
|
||||||
QUndoCommand* setTransactionNum(TmpTransaction& t, const QString& newValue)
|
QUndoCommand* setTransactionNum(TmpTransaction& t, const QString& newValue)
|
||||||
{
|
{
|
||||||
return new CmdRef<TmpTransaction, QString>(QObject::tr("Edit Transaction Number"),
|
return new CmdRef<TmpTransaction, Glib::ustring>(QObject::tr("Edit Transaction Number"),
|
||||||
t, &TmpTransaction::setNum,
|
t, &TmpTransaction::setNum,
|
||||||
t.getNum(), newValue);
|
t.getNum(), q2g(newValue));
|
||||||
}
|
}
|
||||||
QUndoCommand* setTransactionDescription(TmpTransaction& t, const QString& newValue)
|
QUndoCommand* setTransactionDescription(TmpTransaction& t, const QString& newValue)
|
||||||
{
|
{
|
||||||
return new CmdRef<TmpTransaction, QString>(QObject::tr("Edit Transaction Description"),
|
return new CmdRef<TmpTransaction, Glib::ustring>(QObject::tr("Edit Transaction Description"),
|
||||||
t, &TmpTransaction::setDescription,
|
t, &TmpTransaction::setDescription,
|
||||||
t.getDescription(), newValue);
|
t.getDescription(), q2g(newValue));
|
||||||
}
|
}
|
||||||
QUndoCommand* setTransactionDate(TmpTransaction& t, const QDate& newValue)
|
QUndoCommand* setTransactionDate(TmpTransaction& t, const QDate& newValue)
|
||||||
{
|
{
|
||||||
return new CmdRef<TmpTransaction, QDate>(QObject::tr("Edit Transaction Date"),
|
return new CmdRef<TmpTransaction, Glib::Date>(QObject::tr("Edit Transaction Date"),
|
||||||
t, &TmpTransaction::setDatePosted,
|
t, &TmpTransaction::setDatePosted,
|
||||||
t.getDatePosted(), newValue);
|
t.getDatePosted(), q2g(newValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ////////////////////////////////////////////////////////////
|
// ////////////////////////////////////////////////////////////
|
||||||
@ -360,18 +373,24 @@ public:
|
|||||||
const value_type& previousValue,
|
const value_type& previousValue,
|
||||||
const value_type& newValue,
|
const value_type& newValue,
|
||||||
QUndoCommand *parent = 0)
|
QUndoCommand *parent = 0)
|
||||||
: base_class(text, parent)
|
: base_class(text, parent)
|
||||||
, m_target(targetRef)
|
, m_target(targetRef)
|
||||||
, m_previousValue(previousValue)
|
, m_previousValue(previousValue)
|
||||||
, m_newValue(newValue)
|
, m_newValue(newValue)
|
||||||
{
|
{
|
||||||
Q_ASSERT(m_target.getParent());
|
Q_ASSERT(m_target.getParent());
|
||||||
Q_ASSERT(m_target.getOtherSplit());
|
Q_ASSERT(m_target.getOtherSplit());
|
||||||
Q_ASSERT(m_target.getAccount());
|
Q_ASSERT(m_target.getAccount());
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void redo() { set(m_newValue); }
|
virtual void redo()
|
||||||
virtual void undo() { set(m_previousValue); }
|
{
|
||||||
|
set(m_newValue);
|
||||||
|
}
|
||||||
|
virtual void undo()
|
||||||
|
{
|
||||||
|
set(m_previousValue);
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
void set(const value_type& value)
|
void set(const value_type& value)
|
||||||
{
|
{
|
||||||
@ -382,10 +401,10 @@ private:
|
|||||||
TmpSplit* p_other = m_target.getOtherSplit();
|
TmpSplit* p_other = m_target.getOtherSplit();
|
||||||
Q_ASSERT(p_other);
|
Q_ASSERT(p_other);
|
||||||
TmpSplit& other = *p_other;
|
TmpSplit& other = *p_other;
|
||||||
Commodity originCommodity = Account(m_target.getAccount()).getCommodity();
|
Glib::RefPtr<Commodity> originCommodity = Glib::wrap(m_target.getAccount())->getCommodity();
|
||||||
Commodity transCommodity = trans.getCommodity();
|
Glib::RefPtr<Commodity> transCommodity = trans.getCommodity();
|
||||||
Q_ASSERT(other.getAccount());
|
Q_ASSERT(other.getAccount());
|
||||||
Commodity otherCommodity = Account(other.getAccount()).getCommodity();
|
Glib::RefPtr<Commodity> otherCommodity = Glib::wrap(other.getAccount())->getCommodity();
|
||||||
if (originCommodity != transCommodity
|
if (originCommodity != transCommodity
|
||||||
|| transCommodity != otherCommodity)
|
|| transCommodity != otherCommodity)
|
||||||
return;
|
return;
|
||||||
@ -425,9 +444,9 @@ public:
|
|||||||
TransactionCreateCmd(const QString& text,
|
TransactionCreateCmd(const QString& text,
|
||||||
const TmpTransaction& target,
|
const TmpTransaction& target,
|
||||||
QUndoCommand *parent = 0)
|
QUndoCommand *parent = 0)
|
||||||
: base_class(text, parent)
|
: base_class(text, parent)
|
||||||
, m_template(target)
|
, m_template(target)
|
||||||
, m_created(NULL)
|
, m_created(NULL)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual void redo()
|
virtual void redo()
|
||||||
@ -437,13 +456,13 @@ public:
|
|||||||
|
|
||||||
virtual void undo()
|
virtual void undo()
|
||||||
{
|
{
|
||||||
xaccTransDestroy(m_created.gobj());
|
xaccTransDestroy(m_created->gobj());
|
||||||
m_created.reset();
|
m_created.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TmpTransaction m_template;
|
TmpTransaction m_template;
|
||||||
Transaction m_created;
|
Glib::RefPtr<Transaction> m_created;
|
||||||
};
|
};
|
||||||
|
|
||||||
QUndoCommand* commitNewTransaction(const TmpTransaction& t)
|
QUndoCommand* commitNewTransaction(const TmpTransaction& t)
|
||||||
|
@ -24,8 +24,9 @@
|
|||||||
#define GNC_CMD_HPP
|
#define GNC_CMD_HPP
|
||||||
|
|
||||||
#include <QUndoCommand>
|
#include <QUndoCommand>
|
||||||
|
#include <QDate>
|
||||||
#include <gnc/WeakPointer.hpp>
|
#include <gnc/WeakPointer.hpp>
|
||||||
#include <gnc/Numeric.hpp>
|
#include <gncmm/Numeric.hpp>
|
||||||
|
|
||||||
namespace gnc
|
namespace gnc
|
||||||
{
|
{
|
||||||
@ -73,32 +74,8 @@ public:
|
|||||||
/// Type of the getter function to retrieve the current value from the target object
|
/// Type of the getter function to retrieve the current value from the target object
|
||||||
typedef value_type (target_type::*getter_func)() const;
|
typedef value_type (target_type::*getter_func)() const;
|
||||||
|
|
||||||
/** Constructor.
|
/** Constructor with the to-be-manipulated object "targetPtr", the setter
|
||||||
* @param text The QUndoCommand's text which will be displayed in the Undo action.
|
* function, the previous value, and the new value.
|
||||||
* @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 getter Pointer to function which returns the current value from the target object
|
|
||||||
* @param newValue The new value to be set
|
|
||||||
* @param parent The parent QUndoCommand instance, or NULL.
|
|
||||||
*/
|
|
||||||
Cmd(const QString& text,
|
|
||||||
WeakPointer<typename target_type::element_type>& targetPtr,
|
|
||||||
setter_func setter,
|
|
||||||
getter_func getter,
|
|
||||||
const value_type& newValue,
|
|
||||||
QUndoCommand *parent = 0)
|
|
||||||
: base_class(text, parent)
|
|
||||||
, m_target(targetPtr.gobj())
|
|
||||||
, m_setter(setter)
|
|
||||||
, m_previousValue((m_target.*getter)())
|
|
||||||
, m_newValue(newValue)
|
|
||||||
{
|
|
||||||
Q_ASSERT(m_target);
|
|
||||||
Q_ASSERT(m_setter);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Overloaded constructor without a getter-function but instead
|
|
||||||
* the previous value given directly.
|
|
||||||
*
|
*
|
||||||
* @param text The QUndoCommand's text which will be displayed in the Undo action.
|
* @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 targetPtr Reference to the target object on which this command is applied.
|
||||||
@ -108,13 +85,13 @@ public:
|
|||||||
* @param parent The parent QUndoCommand instance, or NULL.
|
* @param parent The parent QUndoCommand instance, or NULL.
|
||||||
*/
|
*/
|
||||||
Cmd(const QString& text,
|
Cmd(const QString& text,
|
||||||
WeakPointer<typename target_type::element_type>& targetPtr,
|
Glib::RefPtr<target_type> targetPtr,
|
||||||
setter_func setter,
|
setter_func setter,
|
||||||
const value_type& previousValue,
|
const value_type& previousValue,
|
||||||
const value_type& newValue,
|
const value_type& newValue,
|
||||||
QUndoCommand *parent = 0)
|
QUndoCommand *parent = 0)
|
||||||
: base_class(text, parent)
|
: base_class(text, parent)
|
||||||
, m_target(targetPtr.gobj())
|
, m_target(targetPtr)
|
||||||
, m_setter(setter)
|
, m_setter(setter)
|
||||||
, m_previousValue(previousValue)
|
, m_previousValue(previousValue)
|
||||||
, m_newValue(newValue)
|
, m_newValue(newValue)
|
||||||
@ -139,11 +116,11 @@ private:
|
|||||||
{
|
{
|
||||||
// Uh oh. The calling syntax for pointer-to-member
|
// Uh oh. The calling syntax for pointer-to-member
|
||||||
// variables (here: m_setter) looks rather weird:
|
// variables (here: m_setter) looks rather weird:
|
||||||
(m_target.*m_setter)(value);
|
(m_target.operator->()->*m_setter)(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
target_type m_target;
|
Glib::RefPtr<target_type> m_target;
|
||||||
setter_func m_setter;
|
setter_func m_setter;
|
||||||
value_type m_previousValue;
|
value_type m_previousValue;
|
||||||
value_type m_newValue;
|
value_type m_newValue;
|
||||||
@ -160,22 +137,22 @@ namespace cmd
|
|||||||
// forth. Spooky, IMHO.
|
// forth. Spooky, IMHO.
|
||||||
// QUndoCommand* setSplitMemo(Split& split, const QString& newValue);
|
// QUndoCommand* setSplitMemo(Split& split, const QString& newValue);
|
||||||
// QUndoCommand* setSplitAction(Split& t, const QString& newValue);
|
// QUndoCommand* setSplitAction(Split& t, const QString& newValue);
|
||||||
QUndoCommand* setSplitAccount(Split& t, Account newValue);
|
QUndoCommand* setSplitAccount(Glib::RefPtr<Split> t, Glib::RefPtr<Account> newValue);
|
||||||
QUndoCommand* setSplitAccount(TmpSplit& t, Account newValue);
|
QUndoCommand* setSplitAccount(TmpSplit& t, Glib::RefPtr<Account> newValue);
|
||||||
QUndoCommand* setSplitReconcile(Split& t, char newValue);
|
QUndoCommand* setSplitReconcile(Glib::RefPtr<Split> t, char newValue);
|
||||||
QUndoCommand* setSplitReconcile(TmpSplit& t, char newValue);
|
QUndoCommand* setSplitReconcile(TmpSplit& t, char newValue);
|
||||||
// QUndoCommand* setSplitAmount(Split& t, const Numeric& newValue);
|
// QUndoCommand* setSplitAmount(Glib::RefPtr<Split> t, const Numeric& newValue);
|
||||||
// QUndoCommand* setSplitValue(Split& t, const Numeric& newValue);
|
// QUndoCommand* setSplitValue(Glib::RefPtr<Split> t, const Numeric& newValue);
|
||||||
QUndoCommand* setTransactionNum(Transaction& t, const QString& newValue);
|
QUndoCommand* setTransactionNum(Glib::RefPtr<Transaction> t, const QString& newValue);
|
||||||
QUndoCommand* setTransactionNum(TmpTransaction& t, const QString& newValue);
|
QUndoCommand* setTransactionNum(TmpTransaction& t, const QString& newValue);
|
||||||
QUndoCommand* setTransactionDescription(Transaction& t, const QString& newValue);
|
QUndoCommand* setTransactionDescription(Glib::RefPtr<Transaction> t, const QString& newValue);
|
||||||
QUndoCommand* setTransactionDescription(TmpTransaction& t, const QString& newValue);
|
QUndoCommand* setTransactionDescription(TmpTransaction& t, const QString& newValue);
|
||||||
// QUndoCommand* setTransactionNotes(Transaction& t, const QString& newValue);
|
// QUndoCommand* setTransactionNotes(Glib::RefPtr<Transaction> t, const QString& newValue);
|
||||||
QUndoCommand* setTransactionDate(Transaction& t, const QDate& newValue);
|
QUndoCommand* setTransactionDate(Glib::RefPtr<Transaction> t, const QDate& newValue);
|
||||||
QUndoCommand* setTransactionDate(TmpTransaction& t, const QDate& newValue);
|
QUndoCommand* setTransactionDate(TmpTransaction& t, const QDate& newValue);
|
||||||
QUndoCommand* setSplitValueAndAmount(Split& t, const Numeric& newValue);
|
QUndoCommand* setSplitValueAndAmount(Glib::RefPtr<Split> t, const Numeric& newValue);
|
||||||
QUndoCommand* setSplitValueAndAmount(TmpSplit& t, const Numeric& newValue);
|
QUndoCommand* setSplitValueAndAmount(TmpSplit& t, const Numeric& newValue);
|
||||||
QUndoCommand* destroyTransaction(Transaction& t);
|
QUndoCommand* destroyTransaction(Glib::RefPtr<Transaction> t);
|
||||||
QUndoCommand* commitNewTransaction(const TmpTransaction& t);
|
QUndoCommand* commitNewTransaction(const TmpTransaction& t);
|
||||||
|
|
||||||
} // END namespace cmd
|
} // END namespace cmd
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#include "engine/gnc-event.h"
|
#include "engine/gnc-event.h"
|
||||||
|
|
||||||
#include "gnc/SplitListModel.hpp"
|
#include "gnc/SplitListModel.hpp"
|
||||||
#include "gnc/Transaction.hpp"
|
#include "gncmm/Transaction.hpp"
|
||||||
|
|
||||||
namespace gnc
|
namespace gnc
|
||||||
{
|
{
|
||||||
|
@ -148,7 +148,7 @@ void RecentFileMenu::on_actionRecentFile()
|
|||||||
{
|
{
|
||||||
QString str = action->data().toString();
|
QString str = action->data().toString();
|
||||||
if (!str.isEmpty())
|
if (!str.isEmpty())
|
||||||
emit fileSelected(str);
|
Q_EMIT fileSelected(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
void writeSettings(QSettings *settings, const QString &groupName);
|
void writeSettings(QSettings *settings, const QString &groupName);
|
||||||
|
|
||||||
public slots:
|
public Q_SLOTS:
|
||||||
/**
|
/**
|
||||||
* Record the given string as a filename that was (or is)
|
* Record the given string as a filename that was (or is)
|
||||||
* being used in the application. As a result the given
|
* being used in the application. As a result the given
|
||||||
@ -67,14 +67,14 @@ public slots:
|
|||||||
*/
|
*/
|
||||||
void usingFile(const QString &fileName);
|
void usingFile(const QString &fileName);
|
||||||
|
|
||||||
signals:
|
Q_SIGNALS:
|
||||||
/**
|
/**
|
||||||
* This signal is emitted whenever the user selects a file from the internally managed
|
* 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).
|
* menu (i.e. the user wants to open the given file).
|
||||||
*/
|
*/
|
||||||
void fileSelected(const QString &fileName);
|
void fileSelected(const QString &fileName);
|
||||||
|
|
||||||
private slots:
|
private Q_SLOTS:
|
||||||
void on_actionRecentFile();
|
void on_actionRecentFile();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "gnc/Session.hpp"
|
#include "gnc/Session.hpp"
|
||||||
#include "gnc/Book.hpp"
|
#include "gncmm/Book.hpp"
|
||||||
|
|
||||||
// Explicit instantiation to check for compiler errors in the template
|
// Explicit instantiation to check for compiler errors in the template
|
||||||
template class gnc::WeakPointer< QofSession >;
|
template class gnc::WeakPointer< QofSession >;
|
||||||
@ -31,9 +31,9 @@ template class gnc::WeakPointer< QofSession >;
|
|||||||
namespace gnc
|
namespace gnc
|
||||||
{
|
{
|
||||||
|
|
||||||
Book Session::get_book () const
|
Glib::RefPtr<Book> Session::get_book () const
|
||||||
{
|
{
|
||||||
return Book(qof_session_get_book(gobj()));
|
return Glib::wrap(qof_session_get_book(gobj()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ extern "C"
|
|||||||
}
|
}
|
||||||
|
|
||||||
#include "gnc/WeakPointer.hpp"
|
#include "gnc/WeakPointer.hpp"
|
||||||
|
#include <glibmm/refptr.h>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
namespace gnc
|
namespace gnc
|
||||||
@ -78,7 +79,7 @@ public:
|
|||||||
{
|
{
|
||||||
return QString::fromUtf8(qof_session_get_error_message(gobj()));
|
return QString::fromUtf8(qof_session_get_error_message(gobj()));
|
||||||
}
|
}
|
||||||
Book get_book () const;
|
Glib::RefPtr<Book> get_book () const;
|
||||||
|
|
||||||
QString get_file_path () const
|
QString get_file_path () const
|
||||||
{
|
{
|
||||||
|
@ -22,9 +22,10 @@
|
|||||||
|
|
||||||
#include "SplitListModel.hpp"
|
#include "SplitListModel.hpp"
|
||||||
#include "engine/gnc-event.h" // for GNC_EVENT_ITEM_ADDED
|
#include "engine/gnc-event.h" // for GNC_EVENT_ITEM_ADDED
|
||||||
#include "gnc/Transaction.hpp"
|
#include "gncmm/Transaction.hpp"
|
||||||
#include "gnc/Cmd.hpp"
|
#include "gnc/Cmd.hpp"
|
||||||
#include "gnc/Session.hpp"
|
#include "gnc/Session.hpp"
|
||||||
|
#include "gnc/metatype.hpp"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QUndoStack>
|
#include <QUndoStack>
|
||||||
#include <QBrush>
|
#include <QBrush>
|
||||||
@ -38,7 +39,7 @@ namespace gnc
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
SplitListModel::SplitListModel(const Account& acc, QUndoStack* undoStack, QObject *parent)
|
SplitListModel::SplitListModel(const Glib::RefPtr<Account> acc, QUndoStack* undoStack, QObject *parent)
|
||||||
: QAbstractItemModel(parent)
|
: QAbstractItemModel(parent)
|
||||||
, m_account(acc)
|
, m_account(acc)
|
||||||
, m_list()
|
, m_list()
|
||||||
@ -56,7 +57,7 @@ SplitListModel::SplitListModel(const Account& acc, QUndoStack* undoStack, QObjec
|
|||||||
|
|
||||||
void SplitListModel::recreateCache()
|
void SplitListModel::recreateCache()
|
||||||
{
|
{
|
||||||
SplitQList newSplits = Split::fromGList(m_account.getSplitList());
|
SplitQList newSplits = Split::fromGList(m_account->getSplitList());
|
||||||
bool doReset = (newSplits.size() != m_list.size());
|
bool doReset = (newSplits.size() != m_list.size());
|
||||||
|
|
||||||
m_list = newSplits;
|
m_list = newSplits;
|
||||||
@ -65,7 +66,7 @@ void SplitListModel::recreateCache()
|
|||||||
m_hash.clear();
|
m_hash.clear();
|
||||||
for (int k = 0; k < m_list.size(); ++k)
|
for (int k = 0; k < m_list.size(); ++k)
|
||||||
{
|
{
|
||||||
m_hash.insert(Split(m_list[k]).getParent().gobj(), k);
|
m_hash.insert(Glib::wrap(m_list[k])->getParent()->gobj(), k);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doReset)
|
if (doReset)
|
||||||
@ -79,14 +80,14 @@ void SplitListModel::recreateTmpTrans()
|
|||||||
m_tmpTransaction.getSplits().pop_back();
|
m_tmpTransaction.getSplits().pop_back();
|
||||||
Q_ASSERT(m_tmpTransaction.countSplits() == 2);
|
Q_ASSERT(m_tmpTransaction.countSplits() == 2);
|
||||||
|
|
||||||
m_tmpTransaction.setCommodity(m_account.getCommodity());
|
m_tmpTransaction.setCommodity(m_account->getCommodity());
|
||||||
m_tmpTransaction.setDatePosted(QDate::currentDate());
|
m_tmpTransaction.setDatePosted(q2g(QDate::currentDate()));
|
||||||
TmpSplit& oursplit = m_tmpTransaction.getSplits().front();
|
TmpSplit& oursplit = m_tmpTransaction.getSplits().front();
|
||||||
TmpSplit& othersplit = m_tmpTransaction.getSplits().back();
|
TmpSplit& othersplit = m_tmpTransaction.getSplits().back();
|
||||||
oursplit.setAccount(m_account.gobj());
|
oursplit.setAccount(m_account->gobj());
|
||||||
|
|
||||||
Q_ASSERT(m_tmpTransaction.countSplits() == 2);
|
Q_ASSERT(m_tmpTransaction.countSplits() == 2);
|
||||||
Q_ASSERT(oursplit.getAccount() == m_account.gobj());
|
Q_ASSERT(oursplit.getAccount() == m_account->gobj());
|
||||||
Q_ASSERT(othersplit.getAccount() == NULL);
|
Q_ASSERT(othersplit.getAccount() == NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,11 +105,11 @@ QModelIndex SplitListModel::index(int row, int column,
|
|||||||
if (m_enableNewTransaction && row == m_list.size())
|
if (m_enableNewTransaction && row == m_list.size())
|
||||||
return createIndex(row, column, (void*)NULL);
|
return createIndex(row, column, (void*)NULL);
|
||||||
|
|
||||||
Split childItem = m_list.at(row);
|
Glib::RefPtr<Split> childItem = Glib::wrap(m_list.at(row));
|
||||||
if (childItem.gobj())
|
if (childItem)
|
||||||
{
|
{
|
||||||
//qDebug() << "returning" << childItem.getName();
|
//qDebug() << "returning" << childItem.getName();
|
||||||
return createIndex(row, column, childItem.gobj());
|
return createIndex(row, column, childItem->gobj());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
@ -118,9 +119,9 @@ bool SplitListModel::removeRows(int position, int rows, const QModelIndex &index
|
|||||||
{
|
{
|
||||||
for (int row = position; row < position + rows; ++row)
|
for (int row = position; row < position + rows; ++row)
|
||||||
{
|
{
|
||||||
Split s(m_list.at(row));
|
Glib::RefPtr<Split> s = Glib::wrap(m_list.at(row));
|
||||||
Q_ASSERT(s);
|
Q_ASSERT(s);
|
||||||
Transaction t = s.getParent();
|
Glib::RefPtr<Transaction> t = s->getParent();
|
||||||
Q_ASSERT(t);
|
Q_ASSERT(t);
|
||||||
QUndoCommand* cmd = cmd::destroyTransaction(t);
|
QUndoCommand* cmd = cmd::destroyTransaction(t);
|
||||||
m_undoStack->push(cmd);
|
m_undoStack->push(cmd);
|
||||||
@ -191,7 +192,7 @@ QVariant SplitListModel::data(const QModelIndex& index, int role) const
|
|||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
return trans.getDatePosted();
|
return g2q(trans.getDatePosted());
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@ -200,7 +201,7 @@ QVariant SplitListModel::data(const QModelIndex& index, int role) const
|
|||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
return trans.getNum();
|
return g2q(trans.getNum());
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@ -209,7 +210,7 @@ QVariant SplitListModel::data(const QModelIndex& index, int role) const
|
|||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
return trans.getDescription();
|
return g2q(trans.getDescription());
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@ -219,7 +220,7 @@ QVariant SplitListModel::data(const QModelIndex& index, int role) const
|
|||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
if (trans.countSplits() == 2)
|
if (trans.countSplits() == 2)
|
||||||
return QVariant::fromValue(Account(trans.getSplits().back().getAccount()));
|
return QVariant::fromValue(trans.getSplits().back().getAccount());
|
||||||
else
|
else
|
||||||
return QVariant(); // FIXME: Multi-split txn here
|
return QVariant(); // FIXME: Multi-split txn here
|
||||||
default:
|
default:
|
||||||
@ -240,7 +241,7 @@ QVariant SplitListModel::data(const QModelIndex& index, int role) const
|
|||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
if (!amount.zero_p() && amount.positive_p())
|
if (!amount.zero_p() && amount.positive_p())
|
||||||
return amount.printAmount(printInfo);
|
return g2q(amount.printAmount(printInfo));
|
||||||
else
|
else
|
||||||
return QString();
|
return QString();
|
||||||
default:
|
default:
|
||||||
@ -254,7 +255,7 @@ QVariant SplitListModel::data(const QModelIndex& index, int role) const
|
|||||||
if (amount.zero_p() || amount.positive_p())
|
if (amount.zero_p() || amount.positive_p())
|
||||||
return QString();
|
return QString();
|
||||||
else
|
else
|
||||||
return amount.neg().printAmount(printInfo);
|
return g2q(amount.neg().printAmount(printInfo));
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@ -270,9 +271,9 @@ QVariant SplitListModel::data(const QModelIndex& index, int role) const
|
|||||||
// Normal case: We are in a row that displays a normal
|
// Normal case: We are in a row that displays a normal
|
||||||
// transaction and split
|
// transaction and split
|
||||||
|
|
||||||
Split split(static_cast< ::Split*>(index.internalPointer()));
|
Glib::RefPtr<Split> split = Glib::wrap(static_cast< ::Split*>(index.internalPointer()));
|
||||||
Transaction trans(split.getParent());
|
Glib::RefPtr<Transaction> trans(split->getParent());
|
||||||
Numeric amount = split.getValue(); // Alternatively: xaccSplitConvertAmount(split.gobj(), split.getAccount().gobj());
|
Numeric amount = split->getValue(); // Alternatively: xaccSplitConvertAmount(split.gobj(), split.getAccount().gobj());
|
||||||
PrintAmountInfo printInfo(split, false);
|
PrintAmountInfo printInfo(split, false);
|
||||||
|
|
||||||
switch (index.column())
|
switch (index.column())
|
||||||
@ -282,7 +283,7 @@ QVariant SplitListModel::data(const QModelIndex& index, int role) const
|
|||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
return trans.getDatePosted();
|
return g2q(trans->getDatePosted());
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@ -291,7 +292,7 @@ QVariant SplitListModel::data(const QModelIndex& index, int role) const
|
|||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
return trans.getNum();
|
return g2q(trans->getNum());
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@ -300,7 +301,7 @@ QVariant SplitListModel::data(const QModelIndex& index, int role) const
|
|||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
return trans.getDescription();
|
return g2q(trans->getDescription());
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@ -309,10 +310,10 @@ QVariant SplitListModel::data(const QModelIndex& index, int role) const
|
|||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
if (trans.countSplits() == 2)
|
if (trans->countSplits() == 2)
|
||||||
return QVariant::fromValue(split.getOtherSplit().getAccount());
|
return QVariant::fromValue(split->getOtherSplit()->getAccount()->gobj());
|
||||||
else
|
else
|
||||||
return split.getCorrAccountFullName();
|
return g2q(split->getCorrAccountFullName());
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@ -321,7 +322,7 @@ QVariant SplitListModel::data(const QModelIndex& index, int role) const
|
|||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
return QString::fromUtf8(gnc_get_reconcile_str(split.getReconcile()));
|
return QString::fromUtf8(gnc_get_reconcile_str(split->getReconcile()));
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@ -331,7 +332,7 @@ QVariant SplitListModel::data(const QModelIndex& index, int role) const
|
|||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
if (amount.positive_p())
|
if (amount.positive_p())
|
||||||
return amount.printAmount(printInfo);
|
return g2q(amount.printAmount(printInfo));
|
||||||
else
|
else
|
||||||
return QString();
|
return QString();
|
||||||
default:
|
default:
|
||||||
@ -345,7 +346,7 @@ QVariant SplitListModel::data(const QModelIndex& index, int role) const
|
|||||||
if (amount.positive_p())
|
if (amount.positive_p())
|
||||||
return QString();
|
return QString();
|
||||||
else
|
else
|
||||||
return amount.neg().printAmount(printInfo);
|
return g2q(amount.neg().printAmount(printInfo));
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@ -353,9 +354,9 @@ QVariant SplitListModel::data(const QModelIndex& index, int role) const
|
|||||||
switch (role)
|
switch (role)
|
||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
return split.getBalance().printAmount(printInfo);
|
return g2q(split->getBalance().printAmount(printInfo));
|
||||||
case Qt::ForegroundRole:
|
case Qt::ForegroundRole:
|
||||||
return split.getBalance().negative_p()
|
return split->getBalance().negative_p()
|
||||||
? QBrush(Qt::red)
|
? QBrush(Qt::red)
|
||||||
: QBrush();
|
: QBrush();
|
||||||
default:
|
default:
|
||||||
@ -413,7 +414,7 @@ bool SplitListModel::setData(const QModelIndex &index, const QVariant &value, in
|
|||||||
|
|
||||||
TmpTransaction& trans = m_tmpTransaction;
|
TmpTransaction& trans = m_tmpTransaction;
|
||||||
TmpSplit& split = trans.getSplits().front();
|
TmpSplit& split = trans.getSplits().front();
|
||||||
Q_ASSERT(split.getAccount() == m_account.gobj());
|
Q_ASSERT(split.getAccount() == m_account->gobj());
|
||||||
Q_ASSERT(trans.countSplits() == 2);
|
Q_ASSERT(trans.countSplits() == 2);
|
||||||
TmpSplit& other = trans.getSplits().back();
|
TmpSplit& other = trans.getSplits().back();
|
||||||
|
|
||||||
@ -439,11 +440,11 @@ bool SplitListModel::setData(const QModelIndex &index, const QVariant &value, in
|
|||||||
cmd = cmd::setTransactionDescription(trans, value.toString());
|
cmd = cmd::setTransactionDescription(trans, value.toString());
|
||||||
break;
|
break;
|
||||||
case COLUMN_ACCOUNT:
|
case COLUMN_ACCOUNT:
|
||||||
if (value.canConvert<Account>())
|
if (value.canConvert< ::Account*>())
|
||||||
{
|
{
|
||||||
if (trans.countSplits() == 2)
|
if (trans.countSplits() == 2)
|
||||||
{
|
{
|
||||||
cmd = cmd::setSplitAccount(other, value.value<Account>());
|
cmd = cmd::setSplitAccount(other, Glib::wrap(value.value< ::Account*>()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
QMessageBox::warning(NULL, tr("Unimplemented"),
|
QMessageBox::warning(NULL, tr("Unimplemented"),
|
||||||
@ -478,10 +479,10 @@ bool SplitListModel::setData(const QModelIndex &index, const QVariant &value, in
|
|||||||
if (str.isEmpty())
|
if (str.isEmpty())
|
||||||
break;
|
break;
|
||||||
Numeric n;
|
Numeric n;
|
||||||
QString errmsg = n.parse(str);
|
QString errmsg = g2q(n.parse(q2g(str)));
|
||||||
if (errmsg.isEmpty())
|
if (errmsg.isEmpty())
|
||||||
{
|
{
|
||||||
qDebug() << "Successfully parsed string to numeric=" << n.to_string();
|
qDebug() << "Successfully parsed string to numeric=" << g2q(n.to_string());
|
||||||
if (index.column() == COLUMN_DECREASE)
|
if (index.column() == COLUMN_DECREASE)
|
||||||
n = n.neg();
|
n = n.neg();
|
||||||
// Check whether we have the simple case here
|
// Check whether we have the simple case here
|
||||||
@ -492,12 +493,12 @@ bool SplitListModel::setData(const QModelIndex &index, const QVariant &value, in
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Commodity originCommodity = m_account.getCommodity();
|
Glib::RefPtr<Commodity> originCommodity = m_account->getCommodity();
|
||||||
Commodity transCommodity = trans.getCommodity();
|
Glib::RefPtr<Commodity> transCommodity = trans.getCommodity();
|
||||||
bool sameCommodities = (originCommodity == transCommodity);
|
bool sameCommodities = (originCommodity == transCommodity);
|
||||||
if (other.getAccount())
|
if (other.getAccount())
|
||||||
{
|
{
|
||||||
Commodity otherCommodity = Account(other.getAccount()).getCommodity();
|
Glib::RefPtr<Commodity> otherCommodity = Glib::wrap(other.getAccount())->getCommodity();
|
||||||
sameCommodities = sameCommodities && (transCommodity == otherCommodity);
|
sameCommodities = sameCommodities && (transCommodity == otherCommodity);
|
||||||
}
|
}
|
||||||
if (!sameCommodities)
|
if (!sameCommodities)
|
||||||
@ -528,8 +529,8 @@ bool SplitListModel::setData(const QModelIndex &index, const QVariant &value, in
|
|||||||
// Normal case: We are in a row that displays a normal
|
// Normal case: We are in a row that displays a normal
|
||||||
// transaction and split
|
// transaction and split
|
||||||
|
|
||||||
Split split(static_cast< ::Split*>(index.internalPointer()));
|
Glib::RefPtr<Split> split = Glib::wrap(static_cast< ::Split*>(index.internalPointer()));
|
||||||
Transaction trans(split.getParent());
|
Glib::RefPtr<Transaction> trans(split->getParent());
|
||||||
QVariant y(trans);
|
QVariant y(trans);
|
||||||
|
|
||||||
// "Editing" is done by creating a Cmd-object and adding it to
|
// "Editing" is done by creating a Cmd-object and adding it to
|
||||||
@ -554,16 +555,17 @@ bool SplitListModel::setData(const QModelIndex &index, const QVariant &value, in
|
|||||||
cmd = cmd::setTransactionDescription(trans, value.toString());
|
cmd = cmd::setTransactionDescription(trans, value.toString());
|
||||||
break;
|
break;
|
||||||
case COLUMN_ACCOUNT:
|
case COLUMN_ACCOUNT:
|
||||||
if (value.canConvert<Account>())
|
if (value.canConvert< ::Account*>())
|
||||||
{
|
{
|
||||||
if (trans.countSplits() == 2)
|
if (trans->countSplits() == 2)
|
||||||
{
|
{
|
||||||
Split other = split.getOtherSplit();
|
Glib::RefPtr<Split> other = split->getOtherSplit();
|
||||||
cmd = cmd::setSplitAccount(other, value.value<Account>());
|
cmd = cmd::setSplitAccount(other, Glib::wrap(value.value< ::Account*>()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
QMessageBox::warning(NULL, tr("Unimplemented"),
|
QMessageBox::warning(NULL, tr("Unimplemented"),
|
||||||
tr("Sorry, but editing a transaction with more than two splits (here: %1) is not yet implemented.").arg(trans.countSplits()));
|
tr("Sorry, but editing a transaction with more than two splits "
|
||||||
|
"(here: %1) is not yet implemented.").arg(trans->countSplits()));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case COLUMN_RECONCILE:
|
case COLUMN_RECONCILE:
|
||||||
@ -594,26 +596,27 @@ bool SplitListModel::setData(const QModelIndex &index, const QVariant &value, in
|
|||||||
if (str.isEmpty())
|
if (str.isEmpty())
|
||||||
break;
|
break;
|
||||||
Numeric n;
|
Numeric n;
|
||||||
QString errmsg = n.parse(str);
|
QString errmsg = g2q(n.parse(q2g(str)));
|
||||||
if (errmsg.isEmpty())
|
if (errmsg.isEmpty())
|
||||||
{
|
{
|
||||||
qDebug() << "Successfully parsed string to numeric=" << n.to_string();
|
qDebug() << "Successfully parsed string to numeric=" << g2q(n.to_string());
|
||||||
if (index.column() == COLUMN_DECREASE)
|
if (index.column() == COLUMN_DECREASE)
|
||||||
n = n.neg();
|
n = n.neg();
|
||||||
// Check whether we have the simple case here
|
// Check whether we have the simple case here
|
||||||
if (split.getParent().countSplits() != 2)
|
if (split->getParent()->countSplits() != 2)
|
||||||
{
|
{
|
||||||
QMessageBox::warning(NULL, tr("Unimplemented"),
|
QMessageBox::warning(NULL, tr("Unimplemented"),
|
||||||
tr("Sorry, but editing a transaction with more than two splits (here: %1) is not yet implemented.").arg(split.getParent().countSplits()));
|
tr("Sorry, but editing a transaction with more than two splits "
|
||||||
|
"(here: %1) is not yet implemented.").arg(split->getParent()->countSplits()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Transaction trans = split.getParent();
|
Glib::RefPtr<Transaction> trans = split->getParent();
|
||||||
Split other = split.getOtherSplit();
|
Glib::RefPtr<Split> other = split->getOtherSplit();
|
||||||
Q_ASSERT(other);
|
Q_ASSERT(other);
|
||||||
Commodity originCommodity = split.getAccount().getCommodity();
|
Glib::RefPtr<Commodity> originCommodity = split->getAccount()->getCommodity();
|
||||||
Commodity transCommodity = trans.getCurrency();
|
Glib::RefPtr<Commodity> transCommodity = trans->getCurrency();
|
||||||
Commodity otherCommodity = other.getAccount().getCommodity();
|
Glib::RefPtr<Commodity> otherCommodity = other->getAccount()->getCommodity();
|
||||||
if (originCommodity != transCommodity
|
if (originCommodity != transCommodity
|
||||||
|| transCommodity != otherCommodity)
|
|| transCommodity != otherCommodity)
|
||||||
{
|
{
|
||||||
@ -657,7 +660,7 @@ void SplitListModel::transactionEvent( ::Transaction* trans, QofEventId event_ty
|
|||||||
if (m_hash.contains(trans))
|
if (m_hash.contains(trans))
|
||||||
{
|
{
|
||||||
int row = m_hash.value(trans);
|
int row = m_hash.value(trans);
|
||||||
emit dataChanged(index(row, 0), index(row, columnCount() - 1));
|
Q_EMIT dataChanged(index(row, 0), index(row, columnCount() - 1));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GNC_EVENT_ITEM_REMOVED:
|
case GNC_EVENT_ITEM_REMOVED:
|
||||||
@ -679,7 +682,7 @@ void SplitListModel::transactionEvent( ::Transaction* trans, QofEventId event_ty
|
|||||||
|
|
||||||
void SplitListModel::accountEvent( ::Account* acc, QofEventId event_type)
|
void SplitListModel::accountEvent( ::Account* acc, QofEventId event_type)
|
||||||
{
|
{
|
||||||
if (acc != m_account.gobj())
|
if (acc != m_account->gobj())
|
||||||
return;
|
return;
|
||||||
//qDebug() << "SplitListModel::accountEvent, id=" << qofEventToString(event_type);
|
//qDebug() << "SplitListModel::accountEvent, id=" << qofEventToString(event_type);
|
||||||
|
|
||||||
@ -728,7 +731,7 @@ void SplitListModel::editorClosed(const QModelIndex& index,
|
|||||||
{
|
{
|
||||||
// Commit the new transaction
|
// Commit the new transaction
|
||||||
//qDebug() << "Commit the new transaction as a real one";
|
//qDebug() << "Commit the new transaction as a real one";
|
||||||
m_tmpTransaction.setDateEntered(QDateTime::currentDateTime());
|
m_tmpTransaction.setDateEntered(QDateTime::currentDateTime().toTime_t());
|
||||||
QUndoCommand* cmd = cmd::commitNewTransaction(m_tmpTransaction);
|
QUndoCommand* cmd = cmd::commitNewTransaction(m_tmpTransaction);
|
||||||
recreateTmpTrans();
|
recreateTmpTrans();
|
||||||
m_undoStack->push(cmd);
|
m_undoStack->push(cmd);
|
||||||
|
@ -23,10 +23,12 @@
|
|||||||
#ifndef GNC_SPLITLISTMODEL_HPP
|
#ifndef GNC_SPLITLISTMODEL_HPP
|
||||||
#define GNC_SPLITLISTMODEL_HPP
|
#define GNC_SPLITLISTMODEL_HPP
|
||||||
|
|
||||||
#include "gnc/Account.hpp"
|
#include "config.h"
|
||||||
#include "gnc/Split.hpp"
|
#include "gncmm/Account.hpp"
|
||||||
|
#include "gncmm/Split.hpp"
|
||||||
#include "gnc/QofEventWrapper.hpp"
|
#include "gnc/QofEventWrapper.hpp"
|
||||||
#include "gnc/Transaction.hpp"
|
#include "gncmm/Transaction.hpp"
|
||||||
|
#include "gnc/conv.hpp"
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
@ -61,10 +63,10 @@ public:
|
|||||||
, COLUMN_LAST
|
, COLUMN_LAST
|
||||||
};
|
};
|
||||||
|
|
||||||
SplitListModel(const Account& acc, QUndoStack* undoStack, QObject *parent = 0);
|
SplitListModel(const Glib::RefPtr<Account> acc, QUndoStack* undoStack, QObject *parent = 0);
|
||||||
~SplitListModel();
|
~SplitListModel();
|
||||||
|
|
||||||
Account getAccount() const { return m_account; }
|
Glib::RefPtr<Account> getAccount() const { return m_account; }
|
||||||
|
|
||||||
QModelIndex parent(const QModelIndex &index) const { return QModelIndex(); }
|
QModelIndex parent(const QModelIndex &index) const { return QModelIndex(); }
|
||||||
int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
||||||
@ -79,7 +81,7 @@ public:
|
|||||||
|
|
||||||
bool removeRows(int position, int rows, const QModelIndex &index = QModelIndex());
|
bool removeRows(int position, int rows, const QModelIndex &index = QModelIndex());
|
||||||
|
|
||||||
public slots:
|
public Q_SLOTS:
|
||||||
void transactionEvent( ::Transaction* trans, QofEventId event_type);
|
void transactionEvent( ::Transaction* trans, QofEventId event_type);
|
||||||
void accountEvent( ::Account* trans, QofEventId event_type);
|
void accountEvent( ::Account* trans, QofEventId event_type);
|
||||||
void editorClosed(const QModelIndex& index, QAbstractItemDelegate::EndEditHint hint);
|
void editorClosed(const QModelIndex& index, QAbstractItemDelegate::EndEditHint hint);
|
||||||
@ -89,7 +91,7 @@ private:
|
|||||||
void recreateTmpTrans();
|
void recreateTmpTrans();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Account m_account;
|
Glib::RefPtr<Account> m_account;
|
||||||
SplitQList m_list;
|
SplitQList m_list;
|
||||||
QUndoStack* m_undoStack;
|
QUndoStack* m_undoStack;
|
||||||
typedef QHash< ::Transaction*, int> TransactionRowHash;
|
typedef QHash< ::Transaction*, int> TransactionRowHash;
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include "SplitListView.hpp"
|
#include "SplitListView.hpp"
|
||||||
|
|
||||||
#include "engine/gnc-event.h" // for GNC_EVENT_ITEM_ADDED
|
#include "engine/gnc-event.h" // for GNC_EVENT_ITEM_ADDED
|
||||||
#include "gnc/Account.hpp"
|
#include "gncmm/Account.hpp"
|
||||||
#include "gnc/SplitListModel.hpp"
|
#include "gnc/SplitListModel.hpp"
|
||||||
#include "gnc/AccountSelectionDelegate.hpp"
|
#include "gnc/AccountSelectionDelegate.hpp"
|
||||||
|
|
||||||
@ -34,7 +34,7 @@
|
|||||||
namespace gnc
|
namespace gnc
|
||||||
{
|
{
|
||||||
|
|
||||||
SplitListView::SplitListView(Account account, QUndoStack* undoStack, QWidget* parent)
|
SplitListView::SplitListView(Glib::RefPtr<Account> account, QUndoStack* undoStack, QWidget* parent)
|
||||||
: base_class(parent)
|
: base_class(parent)
|
||||||
, m_account(account)
|
, m_account(account)
|
||||||
, m_eventWrapperAccount(*this, &SplitListView::accountEvent)
|
, m_eventWrapperAccount(*this, &SplitListView::accountEvent)
|
||||||
@ -65,7 +65,7 @@ void SplitListView::closeEditor(QWidget* editor, QAbstractItemDelegate::EndEditH
|
|||||||
//qDebug() << "closeEditor, row=" << currentIndex().row() << "hint=" << hint;
|
//qDebug() << "closeEditor, row=" << currentIndex().row() << "hint=" << hint;
|
||||||
QModelIndex index = currentIndex();
|
QModelIndex index = currentIndex();
|
||||||
if (hint != QAbstractItemDelegate::NoHint)
|
if (hint != QAbstractItemDelegate::NoHint)
|
||||||
emit editorClosed(index, hint);
|
Q_EMIT editorClosed(index, hint);
|
||||||
if (index.isValid()
|
if (index.isValid()
|
||||||
&& hint == QAbstractItemDelegate::SubmitModelCache
|
&& hint == QAbstractItemDelegate::SubmitModelCache
|
||||||
&& index.row() < model()->rowCount() - 1)
|
&& index.row() < model()->rowCount() - 1)
|
||||||
@ -86,7 +86,7 @@ void SplitListView::closeEditor(QWidget* editor, QAbstractItemDelegate::EndEditH
|
|||||||
|
|
||||||
void SplitListView::accountEvent( ::Account* v, QofEventId event_type)
|
void SplitListView::accountEvent( ::Account* v, QofEventId event_type)
|
||||||
{
|
{
|
||||||
if (v != m_account.gobj())
|
if (v != m_account->gobj())
|
||||||
return;
|
return;
|
||||||
//qDebug() << "SplitListView::accountEvent, id=" << qofEventToString(event_type);
|
//qDebug() << "SplitListView::accountEvent, id=" << qofEventToString(event_type);
|
||||||
switch (event_type)
|
switch (event_type)
|
||||||
|
@ -23,7 +23,8 @@
|
|||||||
#ifndef GNC_SPLITLISTVIEW_HPP
|
#ifndef GNC_SPLITLISTVIEW_HPP
|
||||||
#define GNC_SPLITLISTVIEW_HPP
|
#define GNC_SPLITLISTVIEW_HPP
|
||||||
|
|
||||||
#include "gnc/Account.hpp"
|
#include "config.h"
|
||||||
|
#include "gncmm/Account.hpp"
|
||||||
#include "gnc/SplitListModel.hpp"
|
#include "gnc/SplitListModel.hpp"
|
||||||
#include "gnc/QofEventWrapper.hpp"
|
#include "gnc/QofEventWrapper.hpp"
|
||||||
|
|
||||||
@ -40,18 +41,18 @@ class SplitListView : public QTableView
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
typedef QTableView base_class;
|
typedef QTableView base_class;
|
||||||
SplitListView(Account account, QUndoStack* undoStack, QWidget* parent = 0);
|
SplitListView(Glib::RefPtr<Account> account, QUndoStack* undoStack, QWidget* parent = 0);
|
||||||
|
|
||||||
signals:
|
Q_SIGNALS:
|
||||||
void editorClosed(const QModelIndex& index, QAbstractItemDelegate::EndEditHint hint);
|
void editorClosed(const QModelIndex& index, QAbstractItemDelegate::EndEditHint hint);
|
||||||
|
|
||||||
public slots:
|
public Q_SLOTS:
|
||||||
void closeEditor(QWidget* editor, QAbstractItemDelegate::EndEditHint hint);
|
void closeEditor(QWidget* editor, QAbstractItemDelegate::EndEditHint hint);
|
||||||
void accountEvent( ::Account* v, QofEventId event_type);
|
void accountEvent( ::Account* v, QofEventId event_type);
|
||||||
void bookEvent( ::QofBook* v, QofEventId event_type);
|
void bookEvent( ::QofBook* v, QofEventId event_type);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Account m_account;
|
Glib::RefPtr<Account> m_account;
|
||||||
QofEventWrapper<SplitListView, ::Account*> m_eventWrapperAccount;
|
QofEventWrapper<SplitListView, ::Account*> m_eventWrapperAccount;
|
||||||
QofEventWrapper<SplitListView, ::QofBook*> m_eventWrapperBook;
|
QofEventWrapper<SplitListView, ::QofBook*> m_eventWrapperBook;
|
||||||
};
|
};
|
||||||
|
37
src/gnc/conv.hpp
Normal file
37
src/gnc/conv.hpp
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#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
|
@ -322,7 +322,7 @@ Dashboard::on_dockwBasicTxn_visibilityChanged(bool visible)
|
|||||||
void
|
void
|
||||||
Dashboard::transferFundsWidgetButtonToggled(bool checked)
|
Dashboard::transferFundsWidgetButtonToggled(bool checked)
|
||||||
{
|
{
|
||||||
if(checked)
|
if (checked)
|
||||||
{
|
{
|
||||||
ui->dockwBasicTxn->show();
|
ui->dockwBasicTxn->show();
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ public:
|
|||||||
void showDashboardWidgets();
|
void showDashboardWidgets();
|
||||||
void mainWindowCloseEvent();
|
void mainWindowCloseEvent();
|
||||||
|
|
||||||
public slots:
|
public Q_SLOTS:
|
||||||
void transferFundsWidgetButtonToggled(bool checked);
|
void transferFundsWidgetButtonToggled(bool checked);
|
||||||
void transactionEvent( ::Transaction* trans, QofEventId event_type);
|
void transactionEvent( ::Transaction* trans, QofEventId event_type);
|
||||||
void accountEvent( ::Account* acc, QofEventId event_type);
|
void accountEvent( ::Account* acc, QofEventId event_type);
|
||||||
@ -113,7 +113,7 @@ private:
|
|||||||
QofEventWrapper<Dashboard, ::Transaction*> m_eventWrapper;
|
QofEventWrapper<Dashboard, ::Transaction*> m_eventWrapper;
|
||||||
QofEventWrapper<Dashboard, ::Account*> m_eventWrapperAccount;
|
QofEventWrapper<Dashboard, ::Account*> m_eventWrapperAccount;
|
||||||
|
|
||||||
private slots:
|
private Q_SLOTS:
|
||||||
void on_btnCreateBasicTxn_clicked();
|
void on_btnCreateBasicTxn_clicked();
|
||||||
void on_dockwBasicTxn_visibilityChanged(bool visible);
|
void on_dockwBasicTxn_visibilityChanged(bool visible);
|
||||||
};
|
};
|
||||||
|
@ -23,10 +23,10 @@ public:
|
|||||||
|
|
||||||
Session m_session;
|
Session m_session;
|
||||||
|
|
||||||
signals:
|
Q_SIGNALS:
|
||||||
void sessionLoaded();
|
void sessionLoaded();
|
||||||
|
|
||||||
public slots:
|
public Q_SLOTS:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "ViewletModel.hpp"
|
#include "ViewletModel.hpp"
|
||||||
#include "gnc/Transaction.hpp"
|
#include "gncmm/Transaction.hpp"
|
||||||
#include "gnc/Account.hpp"
|
#include "gncmm/Account.hpp"
|
||||||
|
|
||||||
#include "gnc/Numeric.hpp"
|
#include "gncmm/Numeric.hpp"
|
||||||
|
|
||||||
namespace gnc
|
namespace gnc
|
||||||
{
|
{
|
||||||
@ -159,57 +159,53 @@ void
|
|||||||
ViewletModel::buildMiniJournalStruct(SplitQList splitList)
|
ViewletModel::buildMiniJournalStruct(SplitQList splitList)
|
||||||
{
|
{
|
||||||
int numOfSplits = splitList.size();
|
int numOfSplits = splitList.size();
|
||||||
Split split;
|
Glib::Date tempDate;
|
||||||
int i;
|
Glib::ustring tempAccount;
|
||||||
QDate tempDate;
|
|
||||||
QString tempAccount;
|
|
||||||
|
|
||||||
for (i = 0; i < numOfSplits; i++)
|
for (int i = 0; i < numOfSplits; i++)
|
||||||
{
|
{
|
||||||
split = splitList.at(i);
|
Glib::RefPtr<Split> split = Glib::wrap(splitList.at(i));
|
||||||
Transaction txn = split.getParent();
|
Glib::RefPtr<Transaction> txn = split->getParent();
|
||||||
|
|
||||||
structViewletEntries entry;
|
structViewletEntries entry;
|
||||||
|
|
||||||
if(i == 0)
|
if(i == 0)
|
||||||
{
|
{
|
||||||
tempDate = txn.getDatePosted();
|
tempDate = txn->getDatePosted();
|
||||||
entry.isDateEqual = false;
|
entry.isDateEqual = false;
|
||||||
tempAccount = split.getCorrAccountName();
|
tempAccount = split->getCorrAccountName();
|
||||||
entry.isSplitAccountEqual = false;
|
entry.isSplitAccountEqual = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(txn.getDatePosted() == tempDate)
|
if(txn->getDatePosted() == tempDate)
|
||||||
{
|
{
|
||||||
entry.isDateEqual = true;
|
entry.isDateEqual = true;
|
||||||
tempDate = txn.getDatePosted();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
entry.isDateEqual = false;
|
entry.isDateEqual = false;
|
||||||
tempDate = txn.getDatePosted();
|
tempDate = txn->getDatePosted();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(split.getCorrAccountName() == tempAccount)
|
if(split->getCorrAccountName() == tempAccount)
|
||||||
{
|
{
|
||||||
entry.isSplitAccountEqual = true;
|
entry.isSplitAccountEqual = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
entry.isSplitAccountEqual = false;
|
entry.isSplitAccountEqual = false;
|
||||||
tempAccount = split.getCorrAccountName();
|
tempAccount = split->getCorrAccountName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
entry.txnDate = txn.getDatePosted().toString();
|
entry.txnDate = g2q(txn->getDatePosted()).toString();
|
||||||
entry.splitAccount = split.getCorrAccountName();
|
entry.splitAccount = g2q(split->getCorrAccountName());
|
||||||
entry.txnDescription = txn.getDescription();
|
entry.txnDescription = g2q(txn->getDescription());
|
||||||
|
|
||||||
Numeric splitAmount;
|
Numeric splitAmount = split->getAmount();
|
||||||
splitAmount = split.getAmount();
|
|
||||||
PrintAmountInfo printInfo(split, true);
|
PrintAmountInfo printInfo(split, true);
|
||||||
entry.splitAmount = splitAmount.printAmount(printInfo);
|
entry.splitAmount = g2q(splitAmount.printAmount(printInfo));
|
||||||
|
|
||||||
//qDebug()<<entry.isDateEqual;
|
//qDebug()<<entry.isDateEqual;
|
||||||
//qDebug()<<entry.isSplitAccountEqual;
|
//qDebug()<<entry.isSplitAccountEqual;
|
||||||
|
@ -14,7 +14,7 @@ extern "C"
|
|||||||
#include "engine/Split.h"
|
#include "engine/Split.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "gnc/Split.hpp"
|
#include "gncmm/Split.hpp"
|
||||||
#include "gnc/SplitListModel.hpp"
|
#include "gnc/SplitListModel.hpp"
|
||||||
#include "gnc/AccountItemModel.hpp"
|
#include "gnc/AccountItemModel.hpp"
|
||||||
|
|
||||||
|
@ -288,7 +288,7 @@ ViewletView::loadAccountsTreeComboBox(AccountListModel * const m_accountsListMod
|
|||||||
{
|
{
|
||||||
accountsList = m_accountsListModel;
|
accountsList = m_accountsListModel;
|
||||||
comboAccountsList->setModel(accountsList);
|
comboAccountsList->setModel(accountsList);
|
||||||
emit fileLoaded();
|
Q_EMIT fileLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Slots *****/
|
/***** Slots *****/
|
||||||
|
@ -40,10 +40,10 @@ public:
|
|||||||
void leftVUpdate();
|
void leftVUpdate();
|
||||||
void rightVUpdate();
|
void rightVUpdate();
|
||||||
|
|
||||||
signals:
|
Q_SIGNALS:
|
||||||
void fileLoaded();
|
void fileLoaded();
|
||||||
|
|
||||||
public slots:
|
public Q_SLOTS:
|
||||||
void defaultVUpdate();
|
void defaultVUpdate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -91,7 +91,7 @@ private:
|
|||||||
void accountCheckOutput();
|
void accountCheckOutput();
|
||||||
void descriptionAmountOutput();
|
void descriptionAmountOutput();
|
||||||
|
|
||||||
private slots:
|
private Q_SLOTS:
|
||||||
void leftVLoad();
|
void leftVLoad();
|
||||||
void rightVLoad();
|
void rightVLoad();
|
||||||
};
|
};
|
||||||
|
@ -45,11 +45,11 @@ extern "C"
|
|||||||
#include "engine/TransLog.h"
|
#include "engine/TransLog.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "gnc/Account.hpp"
|
#include "gncmm/Account.hpp"
|
||||||
#include "gnc/AccountItemModel.hpp"
|
#include "gnc/AccountItemModel.hpp"
|
||||||
#include "gnc/Book.hpp"
|
#include "gncmm/Book.hpp"
|
||||||
#include "gnc/Numeric.hpp"
|
#include "gncmm/Numeric.hpp"
|
||||||
#include "gnc/Split.hpp"
|
#include "gncmm/Split.hpp"
|
||||||
#include "gnc/SplitListModel.hpp"
|
#include "gnc/SplitListModel.hpp"
|
||||||
#include "gnc/RecentFileMenu.hpp"
|
#include "gnc/RecentFileMenu.hpp"
|
||||||
|
|
||||||
@ -356,7 +356,7 @@ void MainWindow::loadFile(const QString &fileName)
|
|||||||
// copied from gnc_post_file_open, gnome-utils/gnc-file.c
|
// copied from gnc_post_file_open, gnome-utils/gnc-file.c
|
||||||
|
|
||||||
QString newfile_qstring =
|
QString newfile_qstring =
|
||||||
gchar_to_QString(gnc_uri_normalize_uri(fileName.toUtf8(), TRUE));
|
g2q(gchar_to_ustring(gnc_uri_normalize_uri(fileName.toUtf8(), TRUE)));
|
||||||
if (newfile_qstring.isEmpty())
|
if (newfile_qstring.isEmpty())
|
||||||
{
|
{
|
||||||
show_session_error (this, ERR_FILEIO_FILE_NOT_FOUND, fileName,
|
show_session_error (this, ERR_FILEIO_FILE_NOT_FOUND, fileName,
|
||||||
@ -532,7 +532,7 @@ void MainWindow::loadFile(const QString &fileName)
|
|||||||
// ////////////////////////////////////////////////////////////
|
// ////////////////////////////////////////////////////////////
|
||||||
// Some display about this file
|
// Some display about this file
|
||||||
|
|
||||||
Account root (m_session.get_book().get_root_account());
|
Glib::RefPtr<Account> root (m_session.get_book()->get_root_account());
|
||||||
if (root)
|
if (root)
|
||||||
{
|
{
|
||||||
m_accountListModel = new AccountListModel(root, this);
|
m_accountListModel = new AccountListModel(root, this);
|
||||||
@ -541,13 +541,13 @@ void MainWindow::loadFile(const QString &fileName)
|
|||||||
m_accountTreeModel = new AccountTreeModel(root, this);
|
m_accountTreeModel = new AccountTreeModel(root, this);
|
||||||
ui->treeView->setModel(m_accountTreeModel);
|
ui->treeView->setModel(m_accountTreeModel);
|
||||||
/* Load the tree in combo boxes of dashboard */
|
/* Load the tree in combo boxes of dashboard */
|
||||||
dboard->loadAccountsTreeComboBox(m_accountListModel);
|
m_dboard->loadAccountsTreeComboBox(m_accountListModel);
|
||||||
dboard->fpoWidget->defaultViewlet->loadAccountsTreeComboBox(m_accountListModel);
|
m_dboard->fpoWidget->defaultViewlet->loadAccountsTreeComboBox(m_accountListModel);
|
||||||
dboard->fpoWidget->leftViewlet->loadAccountsTreeComboBox(m_accountListModel);
|
m_dboard->fpoWidget->leftViewlet->loadAccountsTreeComboBox(m_accountListModel);
|
||||||
dboard->fpoWidget->rightViewlet->loadAccountsTreeComboBox(m_accountListModel);
|
m_dboard->fpoWidget->rightViewlet->loadAccountsTreeComboBox(m_accountListModel);
|
||||||
|
|
||||||
ui->treeViewTab->setProperty(PROPERTY_TAB_PREVIOUSPOS, ui->tabWidget->currentIndex());
|
ui->treeViewTab->setProperty(PROPERTY_TAB_PREVIOUSPOS, ui->tabWidget->currentIndex());
|
||||||
ui->tabWidget->setCurrentWidget(dboard);
|
ui->tabWidget->setCurrentWidget(m_dboard);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -567,7 +567,7 @@ bool MainWindow::saveFileAs(const QString &fileName)
|
|||||||
{
|
{
|
||||||
if (gnc_uri_is_file_uri(fileName.toUtf8()))
|
if (gnc_uri_is_file_uri(fileName.toUtf8()))
|
||||||
{
|
{
|
||||||
QFile file(gchar_to_QString(gnc_uri_get_path(fileName.toUtf8())));
|
QFile file(g2q(gchar_to_ustring(gnc_uri_get_path(fileName.toUtf8()))));
|
||||||
if (!file.open(QFile::WriteOnly))
|
if (!file.open(QFile::WriteOnly))
|
||||||
{
|
{
|
||||||
QMessageBox::warning(this, tr("Application"),
|
QMessageBox::warning(this, tr("Application"),
|
||||||
@ -583,7 +583,7 @@ bool MainWindow::saveFileAs(const QString &fileName)
|
|||||||
* file. If so, then just do a simple save, instead of a full save as */
|
* 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 */
|
/* FIXME Check if it is ok to have a password in the uri here */
|
||||||
QString newfile_qstring =
|
QString newfile_qstring =
|
||||||
gchar_to_QString(gnc_uri_normalize_uri ( fileName.toUtf8(), TRUE ));
|
g2q(gchar_to_ustring(gnc_uri_normalize_uri ( fileName.toUtf8(), TRUE )));
|
||||||
if (newfile_qstring.isEmpty())
|
if (newfile_qstring.isEmpty())
|
||||||
{
|
{
|
||||||
show_session_error (this, ERR_FILEIO_FILE_NOT_FOUND, fileName,
|
show_session_error (this, ERR_FILEIO_FILE_NOT_FOUND, fileName,
|
||||||
|
@ -44,11 +44,11 @@ extern "C"
|
|||||||
#include "engine/TransLog.h"
|
#include "engine/TransLog.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "gnc/Account.hpp"
|
#include "gncmm/Account.hpp"
|
||||||
#include "gnc/AccountItemModel.hpp"
|
#include "gnc/AccountItemModel.hpp"
|
||||||
#include "gnc/Book.hpp"
|
#include "gncmm/Book.hpp"
|
||||||
#include "gnc/Numeric.hpp"
|
#include "gncmm/Numeric.hpp"
|
||||||
#include "gnc/Split.hpp"
|
#include "gncmm/Split.hpp"
|
||||||
#include "gnc/SplitListModel.hpp"
|
#include "gnc/SplitListModel.hpp"
|
||||||
#include "gnc/RecentFileMenu.hpp"
|
#include "gnc/RecentFileMenu.hpp"
|
||||||
#include "gnc/SplitListView.hpp"
|
#include "gnc/SplitListView.hpp"
|
||||||
@ -87,10 +87,10 @@ MainWindow::MainWindow()
|
|||||||
createStatusBar();
|
createStatusBar();
|
||||||
setIcons();
|
setIcons();
|
||||||
|
|
||||||
dboard = new Dashboard(this);
|
m_dboard = new Dashboard(this);
|
||||||
dboard->setWindowTitle("Dashboard");
|
m_dboard->setWindowTitle("Dashboard");
|
||||||
//dboard->show();
|
//m_dboard->show();
|
||||||
ui->tabWidget->addTab(dboard, "Dashboard");
|
ui->tabWidget->addTab(m_dboard, "Dashboard");
|
||||||
|
|
||||||
/* Properties used by QSettings */
|
/* Properties used by QSettings */
|
||||||
QCoreApplication::setOrganizationName("Gnucash");
|
QCoreApplication::setOrganizationName("Gnucash");
|
||||||
@ -102,15 +102,16 @@ MainWindow::MainWindow()
|
|||||||
connect(m_undoStack, SIGNAL(cleanChanged(bool)),
|
connect(m_undoStack, SIGNAL(cleanChanged(bool)),
|
||||||
this, SLOT(documentCleanStateChanged(bool)));
|
this, SLOT(documentCleanStateChanged(bool)));
|
||||||
connect(m_btnTransferFundsWidget, SIGNAL(toggled(bool)),
|
connect(m_btnTransferFundsWidget, SIGNAL(toggled(bool)),
|
||||||
dboard, SLOT(transferFundsWidgetButtonToggled(bool)));
|
m_dboard, SLOT(transferFundsWidgetButtonToggled(bool)));
|
||||||
connect(this, SIGNAL(dashboardVisible(bool)),
|
connect(this, SIGNAL(dashboardVisible(bool)),
|
||||||
dboard, SLOT(transferFundsWidgetButtonToggled(bool)));
|
m_dboard, SLOT(transferFundsWidgetButtonToggled(bool)));
|
||||||
|
|
||||||
setWindowIcon(QIcon(":/pixmaps/gnucash-icon-64x64.png"));
|
setWindowIcon(QIcon(":/pixmaps/gnucash-icon-64x64.png"));
|
||||||
|
|
||||||
/* Check if the system supports freedesktop standards for icons,
|
/* Check if the system supports freedesktop standards for icons,
|
||||||
* if not, then use the bundled icon set. */
|
* if not, then use the bundled icon set. */
|
||||||
if (!QIcon::hasThemeIcon("document-open")) {
|
if (!QIcon::hasThemeIcon("document-open"))
|
||||||
|
{
|
||||||
QIcon::setThemeName("oxygen");
|
QIcon::setThemeName("oxygen");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,8 +313,8 @@ void MainWindow::autoLoadRecentFile()
|
|||||||
QSettings settings;
|
QSettings settings;
|
||||||
QString lastOpenedFile = "";
|
QString lastOpenedFile = "";
|
||||||
lastOpenedFile = m_menuRecentFiles->getRecentFileName(&settings,
|
lastOpenedFile = m_menuRecentFiles->getRecentFileName(&settings,
|
||||||
"RecentFiles");
|
"RecentFiles");
|
||||||
if(maybeSave())
|
if (maybeSave())
|
||||||
{
|
{
|
||||||
loadFile(lastOpenedFile);
|
loadFile(lastOpenedFile);
|
||||||
}
|
}
|
||||||
@ -399,7 +400,7 @@ void MainWindow::on_tabWidget_tabCloseRequested(int index)
|
|||||||
ui->actionViewAccountList->setChecked(false);
|
ui->actionViewAccountList->setChecked(false);
|
||||||
reallyRemoveTab(index);
|
reallyRemoveTab(index);
|
||||||
}
|
}
|
||||||
else if (widget == dboard)
|
else if (widget == m_dboard)
|
||||||
{
|
{
|
||||||
ui->actionViewDashboard->setChecked(false);
|
ui->actionViewDashboard->setChecked(false);
|
||||||
m_dashboardToolBar->setEnabled(false);
|
m_dashboardToolBar->setEnabled(false);
|
||||||
@ -436,7 +437,7 @@ void MainWindow::on_actionViewWelcomepage_triggered(bool checked)
|
|||||||
|
|
||||||
void MainWindow::on_actionViewDashboard_triggered(bool checked)
|
void MainWindow::on_actionViewDashboard_triggered(bool checked)
|
||||||
{
|
{
|
||||||
viewOrHideTab(checked, dboard);
|
viewOrHideTab(checked, m_dboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::viewOrHideTab(bool checked, QWidget *widget)
|
void MainWindow::viewOrHideTab(bool checked, QWidget *widget)
|
||||||
@ -458,11 +459,11 @@ void MainWindow::viewOrHideTab(bool checked, QWidget *widget)
|
|||||||
if (tabIsCurrent)
|
if (tabIsCurrent)
|
||||||
ui->tabWidget->setCurrentWidget(widget);
|
ui->tabWidget->setCurrentWidget(widget);
|
||||||
|
|
||||||
if(widget == dboard)
|
if(widget == m_dboard)
|
||||||
{
|
{
|
||||||
m_dashboardToolBar->setEnabled(true);
|
m_dashboardToolBar->setEnabled(true);
|
||||||
m_dashboardToolBar->setHidden(false);
|
m_dashboardToolBar->setHidden(false);
|
||||||
emit dashboardVisible(true);
|
Q_EMIT dashboardVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -490,11 +491,11 @@ void MainWindow::on_tabWidget_currentChanged(int index)
|
|||||||
bool tabWithAccounts = (widget != ui->textBrowserTab);
|
bool tabWithAccounts = (widget != ui->textBrowserTab);
|
||||||
ui->menuAccount->setEnabled(tabWithAccounts);
|
ui->menuAccount->setEnabled(tabWithAccounts);
|
||||||
|
|
||||||
if(ui->tabWidget->currentWidget() == dboard)
|
if(ui->tabWidget->currentWidget() == m_dboard)
|
||||||
{
|
{
|
||||||
m_dashboardToolBar->setEnabled(true);
|
m_dashboardToolBar->setEnabled(true);
|
||||||
m_dashboardToolBar->setHidden(false);
|
m_dashboardToolBar->setHidden(false);
|
||||||
dboard->showDashboardWidgets();
|
m_dboard->showDashboardWidgets();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -511,7 +512,7 @@ void MainWindow::accountItemActivated(const QModelIndex & index)
|
|||||||
qDebug() << "Wrong model; row=" << (index.isValid()? index.row() : -1);
|
qDebug() << "Wrong model; row=" << (index.isValid()? index.row() : -1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Account account(static_cast< ::Account*>(index.internalPointer()));
|
Glib::RefPtr<Account> account = Glib::wrap(static_cast< ::Account*>(index.internalPointer()));
|
||||||
if (!account)
|
if (!account)
|
||||||
{
|
{
|
||||||
qDebug() << "Account is null; why?";
|
qDebug() << "Account is null; why?";
|
||||||
@ -526,7 +527,7 @@ void MainWindow::accountItemActivated(const QModelIndex & index)
|
|||||||
|
|
||||||
// Insert this as a new tab
|
// Insert this as a new tab
|
||||||
tableView->setProperty(PROPERTY_TAB_PREVIOUSPOS, ui->tabWidget->currentIndex());
|
tableView->setProperty(PROPERTY_TAB_PREVIOUSPOS, ui->tabWidget->currentIndex());
|
||||||
ui->tabWidget->addTab(tableView, account.getName());
|
ui->tabWidget->addTab(tableView, g2q(account->getName()));
|
||||||
ui->tabWidget->setCurrentWidget(tableView);
|
ui->tabWidget->setCurrentWidget(tableView);
|
||||||
|
|
||||||
connect(tableView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
|
connect(tableView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
|
||||||
@ -568,7 +569,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
|||||||
{
|
{
|
||||||
if (maybeSave())
|
if (maybeSave())
|
||||||
{
|
{
|
||||||
dboard->mainWindowCloseEvent();
|
m_dboard->mainWindowCloseEvent();
|
||||||
writeSettings();
|
writeSettings();
|
||||||
event->accept();
|
event->accept();
|
||||||
|
|
||||||
@ -623,7 +624,7 @@ void MainWindow::newFile()
|
|||||||
|
|
||||||
void MainWindow::dockWidgetsVisibilityChanged(int wdg, bool visible)
|
void MainWindow::dockWidgetsVisibilityChanged(int wdg, bool visible)
|
||||||
{
|
{
|
||||||
if(wdg == 0)
|
if (wdg == 0)
|
||||||
{
|
{
|
||||||
/** todo: handle tabs */
|
/** todo: handle tabs */
|
||||||
m_btnTransferFundsWidget->setChecked(visible);
|
m_btnTransferFundsWidget->setChecked(visible);
|
||||||
|
@ -66,7 +66,7 @@ public:
|
|||||||
bool hasOpenedFile() const { return !m_currentFilename.isEmpty(); }
|
bool hasOpenedFile() const { return !m_currentFilename.isEmpty(); }
|
||||||
void dockWidgetsVisibilityChanged(int wdg, bool visible);
|
void dockWidgetsVisibilityChanged(int wdg, bool visible);
|
||||||
|
|
||||||
public slots:
|
public Q_SLOTS:
|
||||||
void accountItemActivated(const QModelIndex & index);
|
void accountItemActivated(const QModelIndex & index);
|
||||||
void loadFileMaybe(const QString &fileName);
|
void loadFileMaybe(const QString &fileName);
|
||||||
void documentCleanStateChanged(bool clean);
|
void documentCleanStateChanged(bool clean);
|
||||||
@ -74,10 +74,10 @@ public slots:
|
|||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
|
|
||||||
signals:
|
Q_SIGNALS:
|
||||||
void dashboardVisible(bool visible);
|
void dashboardVisible(bool visible);
|
||||||
|
|
||||||
private slots:
|
private Q_SLOTS:
|
||||||
void newFile();
|
void newFile();
|
||||||
void on_actionOpen_triggered();
|
void on_actionOpen_triggered();
|
||||||
bool on_actionSave_triggered();
|
bool on_actionSave_triggered();
|
||||||
@ -100,7 +100,7 @@ private:
|
|||||||
void createToolBars();
|
void createToolBars();
|
||||||
void createStatusBar();
|
void createStatusBar();
|
||||||
void setIcons();
|
void setIcons();
|
||||||
void readSettings();
|
void readSettings();
|
||||||
void autoLoadRecentFile();
|
void autoLoadRecentFile();
|
||||||
void writeSettings();
|
void writeSettings();
|
||||||
bool maybeSave();
|
bool maybeSave();
|
||||||
@ -139,7 +139,7 @@ private:
|
|||||||
QSharedPointer<RecentFileMenu> m_menuRecentFiles;
|
QSharedPointer<RecentFileMenu> m_menuRecentFiles;
|
||||||
QUndoStack *m_undoStack;
|
QUndoStack *m_undoStack;
|
||||||
|
|
||||||
Dashboard *dboard;
|
Dashboard *m_dboard;
|
||||||
|
|
||||||
Session m_session;
|
Session m_session;
|
||||||
AccountListModel *m_accountListModel;
|
AccountListModel *m_accountListModel;
|
||||||
|
12
src/gnc/metatype.hpp
Normal file
12
src/gnc/metatype.hpp
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#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
|
Loading…
Reference in New Issue
Block a user