A item-based model for storing accounting results. More...
#include <FdModelResults.hpp>
Public Slots | |
QModelIndex | addCalculation (const QModelIndex &selected) |
void | removeSelected (const QList< int > &rows) |
void | recomputeResults () |
Public Member Functions | |
FdModelResults (FdSubWindow *parent) | |
FdModelResults (FdSubWindow *parent, QDomElement &results) | |
FdModelResults (FdSubWindow *parent, const FdModelResults *model) | |
QVariant | data (const FdItemResults_p calculation, ResultsColumn column) const |
QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const |
void | setData (FdItemResults_p calculation, ResultsColumn 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 |
Qt::DropActions | supportedDropActions () const |
QStringList | mimeTypes () const |
QMimeData * | mimeData (const QModelIndexList &indexes) const |
bool | dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) |
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 | insertCalculation (FdItemResults_p calculation, int row) |
void | insertCalculations (QList< FdItemResults_p > calculations, int row) |
void | removeCalculation (FdItemResults_p calculation) |
void | removeCalculations (QList< FdItemResults_p > calculations) |
QAction * | redo () |
QAction * | undo () |
bool | idExists (QString id) const |
FdItemResults_p | item (QString id) const |
FdItemResults_p | item (int row) const |
QList< FdItemResults_p > | items () const |
QModelIndexList | entryByPartialText (QString text) const |
bool | isValid (QString calculation) const |
double | parse (QString calculation) const |
double | parseItem (QString element) const |
QDomElement | toXml (QDomDocument &document) const |
Static Public Member Functions | |
static QStack< QString > | infixToPostfix (QString expr) |
static int | opPriority (QString op) |
Protected Attributes | |
QUndoStack * | mStack |
Private Member Functions | |
void | init () |
Private Attributes | |
FdSubWindow * | mSubwindow |
QList< FdItemResults_p > | mResults |
Friends | |
class | FdResultsSetData |
class | FdResultsRemove |
class | FdResultsDragDrop |
A item-based model for storing accounting results.
A result in a FdItemResults instance.
Definition at line 37 of file FdModelResults.hpp.
|
explicit |
Definition at line 28 of file FdModelResults.cpp.
FdModelResults::FdModelResults | ( | FdSubWindow * | parent, |
QDomElement & | results | ||
) |
Constructor to create an instance from data file.
Definition at line 36 of file FdModelResults.cpp.
FdModelResults::FdModelResults | ( | FdSubWindow * | parent, |
const FdModelResults * | model | ||
) |
Copy constructor to build an instance based on model.
This is no exact copy, it is used to create a new year accounting.
Definition at line 54 of file FdModelResults.cpp.
|
slot |
Add a new calculation just after selected or at the end of the table if there is no selection.
Definition at line 501 of file FdModelResults.cpp.
int FdModelResults::columnCount | ( | const QModelIndex & | parent = QModelIndex() | ) | const |
Definition at line 264 of file FdModelResults.cpp.
QVariant FdModelResults::data | ( | const FdItemResults_p | calculation, |
ResultsColumn | column | ||
) | const |
Definition at line 70 of file FdModelResults.cpp.
QVariant FdModelResults::data | ( | const QModelIndex & | index, |
int | role = Qt::DisplayRole |
||
) | const |
Definition at line 87 of file FdModelResults.cpp.
bool FdModelResults::dropMimeData | ( | const QMimeData * | data, |
Qt::DropAction | action, | ||
int | row, | ||
int | column, | ||
const QModelIndex & | parent | ||
) |
Handles items drop. This action is undoable, see FdCoaDragDrop.
Definition at line 222 of file FdModelResults.cpp.
QModelIndexList FdModelResults::entryByPartialText | ( | QString | text | ) | const |
This function returns the index of the first entry whose label contains text, or an invalid index if it founds nothing.
Definition at line 350 of file FdModelResults.cpp.
Qt::ItemFlags FdModelResults::flags | ( | const QModelIndex & | index | ) | const |
Definition at line 175 of file FdModelResults.cpp.
QVariant FdModelResults::headerData | ( | int | section, |
Qt::Orientation | orientation, | ||
int | role = Qt::DisplayRole |
||
) | const |
Definition at line 154 of file FdModelResults.cpp.
bool FdModelResults::idExists | ( | QString | id | ) | const |
Returns true if the id id already exists. It will also check if id already exists in the chart of accounts.
Definition at line 315 of file FdModelResults.cpp.
|
static |
Convert a user input infix expression into a postfix expression, so that the expression can then be computed. It returns a QStack of QString, sorted like a postfix string from bottom to top.
Definition at line 556 of file FdModelResults.cpp.
|
private |
Definition at line 63 of file FdModelResults.cpp.
void FdModelResults::insertCalculation | ( | FdItemResults_p | calculation, |
int | row | ||
) |
Definition at line 269 of file FdModelResults.cpp.
void FdModelResults::insertCalculations | ( | QList< FdItemResults_p > | calculations, |
int | row | ||
) |
Definition at line 274 of file FdModelResults.cpp.
bool FdModelResults::isValid | ( | QString | calculation | ) | const |
Parses the expression calculation, a user input and returns false if it contains error.
Definition at line 364 of file FdModelResults.cpp.
FdItemResults_p FdModelResults::item | ( | QString | id | ) | const |
Returns the #FdItemResults_p with the given id, which is invalid if id does not exist. Therefore, the validity of the pointer returned by this function should always be tested calling QSharedPointer::isNull().
Definition at line 326 of file FdModelResults.cpp.
FdItemResults_p FdModelResults::item | ( | int | row | ) | const |
Definition at line 337 of file FdModelResults.cpp.
QList< FdItemResults_p > FdModelResults::items | ( | ) | const |
Definition at line 342 of file FdModelResults.cpp.
QMimeData * FdModelResults::mimeData | ( | const QModelIndexList & | indexes | ) | const |
This function doesn't serialise the items. It simply stores in a QMimeData the row number of dragged rows.
In this class, drag and drop of items is a simple change of row number. There are no destruction/creation.
Definition at line 203 of file FdModelResults.cpp.
QStringList FdModelResults::mimeTypes | ( | ) | const |
Definition at line 193 of file FdModelResults.cpp.
|
static |
Definition at line 638 of file FdModelResults.cpp.
double FdModelResults::parse | ( | QString | calculation | ) | const |
Parses the expression calculation, a user input.
This function recognizes items id, you just have to put them between quoting marks "<i>id</i>". First, the function will try to match an FdItemCoa, then an FdItemResults. Symbols +, -, *, /, ( and ) can be used to set up calculs. Everything else will be treated as scalars.
Definition at line 415 of file FdModelResults.cpp.
double FdModelResults::parseItem | ( | QString | element | ) | const |
Parses element. If element is an account/category or result id, it returns its value. If element is a scalar, it converts it to double.
Definition at line 454 of file FdModelResults.cpp.
|
slot |
Recomputes all results.
Definition at line 542 of file FdModelResults.cpp.
QAction * FdModelResults::redo | ( | ) |
Creates redo action for the tab.
Definition at line 299 of file FdModelResults.cpp.
void FdModelResults::removeCalculation | ( | FdItemResults_p | calculation | ) |
Definition at line 285 of file FdModelResults.cpp.
void FdModelResults::removeCalculations | ( | QList< FdItemResults_p > | calculations | ) |
Definition at line 290 of file FdModelResults.cpp.
bool FdModelResults::removeRows | ( | int | row, |
int | count, | ||
const QModelIndex & | parent = QModelIndex() |
||
) |
Definition at line 248 of file FdModelResults.cpp.
|
slot |
Removes the selected calculations. This action is undoable (see FdResultsRemove).
Definition at line 531 of file FdModelResults.cpp.
int FdModelResults::rowCount | ( | const QModelIndex & | parent = QModelIndex() | ) | const |
Definition at line 259 of file FdModelResults.cpp.
void FdModelResults::setData | ( | FdItemResults_p | calculation, |
ResultsColumn | column, | ||
const QVariant & | value | ||
) |
Definition at line 101 of file FdModelResults.cpp.
bool FdModelResults::setData | ( | const QModelIndex & | index, |
const QVariant & | value, | ||
int | role = Qt::EditRole |
||
) |
Handles user modification of the item fields, calld automatically by the view (FdViewResults).
This function filters user input. It rejects :
Definition at line 130 of file FdModelResults.cpp.
Qt::DropActions FdModelResults::supportedDropActions | ( | ) | const |
Definition at line 188 of file FdModelResults.cpp.
QDomElement FdModelResults::toXml | ( | QDomDocument & | document | ) | const |
Sets the undostack as cleaned.
Definition at line 481 of file FdModelResults.cpp.
QAction * FdModelResults::undo | ( | ) |
Creates undo action for the tab.
Definition at line 307 of file FdModelResults.cpp.
|
friend |
Definition at line 43 of file FdModelResults.hpp.
|
friend |
Definition at line 42 of file FdModelResults.hpp.
|
friend |
Definition at line 41 of file FdModelResults.hpp.
|
private |
Definition at line 47 of file FdModelResults.hpp.
|
protected |
Definition at line 51 of file FdModelResults.hpp.
|
private |
Definition at line 46 of file FdModelResults.hpp.