Classified ads
|
datamodel-parts common part. this is inherited and contains common funcs More...
#include <datamodelbase.h>
Signals | |
void | error (MController::CAErrorSituation aError, const QString &aExplanation) |
Public Member Functions | |
ModelBase (QString aDataTableName, unsigned aMaxRowsToKeep) | |
~ModelBase () | |
bool | setTimeLastReference (const Hash &aObjectFingerPrint, quint32 aTimeWhenLastReferenced) |
unsigned | getMaxRowsToKeep () |
void | setMaxRowsToKeep (unsigned aRows) |
void | truncateDataTableToMaxRows (void) |
void | updateDbTableRowCount () |
Protected Attributes | |
QString | iDataTableName |
unsigned | iMaxRowsToKeep |
unsigned | iCurrentDbTableRowCount |
Private Member Functions | |
virtual bool | deleteOldestDataRowInTable () |
datamodel-parts common part. this is inherited and contains common funcs
There are several datamodel parts (profiles, files, ads etc.) that need some almost-equivalent functions ; this class is an attempt to provide those with minimal code duplication.
ModelBase::ModelBase | ( | QString | aDataTableName, |
unsigned | aMaxRowsToKeep | ||
) |
Constructor.
aDataTableName | specifies the database table where (most) of the data related to this model-part is stored in |
aMaxRowsToKeep | initial value (from const.h) for max number of rows to keep in aDataTableName table ; class will check for modified value in settings table and if there is any, it will be used. |
ModelBase::~ModelBase | ( | ) |
|
privatevirtual |
Reimplemented in ProfileModel.
|
signal |
unsigned ModelBase::getMaxRowsToKeep | ( | ) |
method for controlling table truncation length
void ModelBase::setMaxRowsToKeep | ( | unsigned | aRows | ) |
method for controlling table truncation length variable
bool ModelBase::setTimeLastReference | ( | const Hash & | aObjectFingerPrint, |
quint32 | aTimeWhenLastReferenced | ||
) |
this method sets time of last reference for an object. this is supposed to be called in situations where we know that a human requested the object to be displayed ; calls from UI layer are natural, also maybe situations where neighboring node sends a request that can only result from UI action.
Reason for the UI-requirement is this: we use the time of last reference to remove content from database, starting from data that has not been referenced for some time.
void ModelBase::truncateDataTableToMaxRows | ( | void | ) |
method that truncates the main data table size to iCurrentDbTableRowCount rows. This is to be periodically called, currently via timer in model.
void ModelBase::updateDbTableRowCount | ( | ) |
method for getting initial value for iCurrentDbTableRowCount
|
protected |
Number of rows currently on table. This may get incremented by classes that inherint this class.
|
protected |
name of primary table where data related to each model part is kept ; in runtime this gets values like "binaryfile" or "profle"
|
protected |
max number of rows to keep in db table whose name is in iDataTableName