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