FreeDebks  1.0.3
 All Classes Files Functions Variables Friends Pages
Public Slots | Signals | Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends | List of all members
FdModelJournal Class Reference

A item-based model for storing the journal. More...

#include <FdModelJournal.hpp>

Collaboration diagram for FdModelJournal:
Collaboration graph
[legend]

Public Slots

QModelIndex addEntry (const QModelIndex &selected=QModelIndex())
void removeSelected (const QList< int > &rows)
void orderByDate ()
void copyFromPreviousLine (const QModelIndex &selected)
bool recomputeAccounts ()

Signals

void error (const QModelIndex &index)

Public Member Functions

 FdModelJournal (FdSubWindow *parent)
 FdModelJournal (FdSubWindow *parent, QDomElement &journal)
QVariant data (const FdItemJournal_p entry, JournalColumn column) const
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const
void setData (FdItemJournal_p entry, JournalColumn column, const QVariant &value)
bool setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
Qt::ItemFlags flags (const QModelIndex &index) const
bool removeRows (int row, int count, const QModelIndex &parent=QModelIndex())
int rowCount (const QModelIndex &parent=QModelIndex()) const
int columnCount (const QModelIndex &parent=QModelIndex()) const
void insertEntry (FdItemJournal_p entry, int row)
void insertEntries (QList< FdItemJournal_p > entries, int row)
void removeEntries (QList< FdItemJournal_p > entries)
QModelIndex itemIndex (FdItemJournal_p entry)
QAction * redo ()
QAction * undo ()
QStringList labels () const
FdItemJournal_p lastEntryByLabel (QString label) const
FdItemJournal_p lastEntryByLabel (QString label, int row) const
QModelIndexList entryByPartialText (QString text) const
FdItemCoa_p selectedAccount (const QModelIndex &index) const
QList< FdItemJournal_p > accountEntries (FdItemCoa_p account) const
QDate getMinDate ()
QDate getMaxDate ()
bool isUsed (FdItemCoa_p account) const
QDomElement toXml (QDomDocument &document) const

Protected Attributes

QUndoStack * mStack

Private Member Functions

void init ()

Private Attributes

FdSubWindowmSubwindow
QList< FdItemJournal_p > mEntries

Friends

class FdJournalSetData
class FdJournalRemove

Detailed Description

A item-based model for storing the journal.

The journal logs all money transaction between accounts. Each transaction is called an entry and is stored in a FdItemJournal instance.

Id and account label fields are interdependant (#JournalDebitId <–> #JournalDebitLabel and #JournalCreditId <–> #JournalCreditLabel). The completion of the one imply the automatic completion of the other.

Remarks
When changing the number of columns, it is necessary to update #JournalColumn enum, headerData(), data() and setData().

Definition at line 37 of file FdModelJournal.hpp.

Constructor & Destructor Documentation

FdModelJournal::FdModelJournal ( FdSubWindow parent)
explicit

Creates undo/redo actions for the journal tab, calling QUndoStack::createUndoAction() and QUndoStack::createRedoAction().

Definition at line 30 of file FdModelJournal.cpp.

FdModelJournal::FdModelJournal ( FdSubWindow parent,
QDomElement &  journal 
)

Constructor to create an instance from data file.

Definition at line 39 of file FdModelJournal.cpp.

Member Function Documentation

QList< FdItemJournal_p > FdModelJournal::accountEntries ( FdItemCoa_p  account) const

Returns all entries involving account.

Definition at line 394 of file FdModelJournal.cpp.

QModelIndex FdModelJournal::addEntry ( const QModelIndex &  selected = QModelIndex())
slot

Add a new entry just after selected or at the end of the journal if there is no selection, with a date equal to the one of the line just above.

Returns
The model index of the new row.

Definition at line 464 of file FdModelJournal.cpp.

int FdModelJournal::columnCount ( const QModelIndex &  parent = QModelIndex()) const

Definition at line 258 of file FdModelJournal.cpp.

void FdModelJournal::copyFromPreviousLine ( const QModelIndex &  selected)
slot

Copy into the current cell the content of the cell just above.

Definition at line 535 of file FdModelJournal.cpp.

QVariant FdModelJournal::data ( const FdItemJournal_p  entry,
JournalColumn  column 
) const

Definition at line 59 of file FdModelJournal.cpp.

QVariant FdModelJournal::data ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const

Definition at line 88 of file FdModelJournal.cpp.

QModelIndexList FdModelJournal::entryByPartialText ( QString  text) const

This function returns the index of the first entry whose label contains or amount is text, or an invalid index if it founds nothing.

Definition at line 366 of file FdModelJournal.cpp.

void FdModelJournal::error ( const QModelIndex &  index)
signal
Qt::ItemFlags FdModelJournal::flags ( const QModelIndex &  index) const

Definition at line 234 of file FdModelJournal.cpp.

QDate FdModelJournal::getMaxDate ( )

Returns the maximal date used.

Called by FdDialogBkgProperties::checkDates() when editing bookkeeping properties, to make sure dates will modified correctly.

Definition at line 422 of file FdModelJournal.cpp.

QDate FdModelJournal::getMinDate ( )

Returns the minimal date used.

Called by FdDialogBkgProperties::checkDates() when editing bookkeeping properties, to make sure dates will modified correctly.

Definition at line 411 of file FdModelJournal.cpp.

QVariant FdModelJournal::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const

Definition at line 209 of file FdModelJournal.cpp.

void FdModelJournal::init ( )
private

Definition at line 53 of file FdModelJournal.cpp.

void FdModelJournal::insertEntries ( QList< FdItemJournal_p >  entries,
int  row 
)

Definition at line 268 of file FdModelJournal.cpp.

void FdModelJournal::insertEntry ( FdItemJournal_p  entry,
int  row 
)

Definition at line 263 of file FdModelJournal.cpp.

bool FdModelJournal::isUsed ( FdItemCoa_p  account) const

Returns true if the account account is involved in an entry.

Definition at line 431 of file FdModelJournal.cpp.

QModelIndex FdModelJournal::itemIndex ( FdItemJournal_p  entry)

Creates the index of entry

Definition at line 297 of file FdModelJournal.cpp.

QStringList FdModelJournal::labels ( ) const

Returns a list of all labels typed by the user.

It is called by FdDelegateJournal::createEditor() to construct a completer.

Definition at line 329 of file FdModelJournal.cpp.

FdItemJournal_p FdModelJournal::lastEntryByLabel ( QString  label) const

Returns the last entry with the given label. If no such entry exists, it returns an invalid #FdItemJournal_p. Therefore, the validity of the pointer returned by this function should always be tested calling QSharedPointer::isNull().

Definition at line 344 of file FdModelJournal.cpp.

FdItemJournal_p FdModelJournal::lastEntryByLabel ( QString  label,
int  row 
) const

Returns the last entry with the given label, searching upwards from row row. If no such entry exists, it returns an invalid #FdItemJournal_p. Therefore, the validity of the pointer returned by this function should always be tested calling QSharedPointer::isNull().

Definition at line 352 of file FdModelJournal.cpp.

void FdModelJournal::orderByDate ( )
slot

Orders all entry by date.

Definition at line 507 of file FdModelJournal.cpp.

bool FdModelJournal::recomputeAccounts ( )
slot

Computes the variation of all accounts.

Definition at line 545 of file FdModelJournal.cpp.

QAction * FdModelJournal::redo ( )

Creates redo action for the tab.

Definition at line 311 of file FdModelJournal.cpp.

void FdModelJournal::removeEntries ( QList< FdItemJournal_p >  entries)

Definition at line 288 of file FdModelJournal.cpp.

bool FdModelJournal::removeRows ( int  row,
int  count,
const QModelIndex &  parent = QModelIndex() 
)

Definition at line 242 of file FdModelJournal.cpp.

void FdModelJournal::removeSelected ( const QList< int > &  rows)
slot

Removes the selected entries. This action is undoable (see FdJournalRemove), with this restriction : when undoing, rows are append at the end of the journal.

Definition at line 486 of file FdModelJournal.cpp.

int FdModelJournal::rowCount ( const QModelIndex &  parent = QModelIndex()) const

Definition at line 253 of file FdModelJournal.cpp.

FdItemCoa_p FdModelJournal::selectedAccount ( const QModelIndex &  index) const

Returns the selected account or a null FdItemCoa_p pointer if no account is selected.

Definition at line 380 of file FdModelJournal.cpp.

void FdModelJournal::setData ( FdItemJournal_p  entry,
JournalColumn  column,
const QVariant &  value 
)

Definition at line 103 of file FdModelJournal.cpp.

bool FdModelJournal::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role = Qt::EditRole 
)

Handles user modification of the item fields, called automatically by the view (FdViewJournal).

This function filters user input. It rejects :

Definition at line 151 of file FdModelJournal.cpp.

QDomElement FdModelJournal::toXml ( QDomDocument &  document) const

Sets the undostack as cleaned.

Definition at line 442 of file FdModelJournal.cpp.

QAction * FdModelJournal::undo ( )

Creates undo action for the tab.

Definition at line 319 of file FdModelJournal.cpp.

Friends And Related Function Documentation

friend class FdJournalRemove
friend

Definition at line 42 of file FdModelJournal.hpp.

friend class FdJournalSetData
friend

Definition at line 41 of file FdModelJournal.hpp.

Member Data Documentation

QList<FdItemJournal_p> FdModelJournal::mEntries
private

Definition at line 49 of file FdModelJournal.hpp.

QUndoStack* FdModelJournal::mStack
protected

Definition at line 45 of file FdModelJournal.hpp.

FdSubWindow* FdModelJournal::mSubwindow
private

Definition at line 48 of file FdModelJournal.hpp.


The documentation for this class was generated from the following files: