Classified ads
Signals | Public Member Functions | Protected Attributes | Private Member Functions | List of all members
ModelBase Class Reference

datamodel-parts common part. this is inherited and contains common funcs More...

#include <datamodelbase.h>

Inheritance diagram for ModelBase:
Inheritance graph
[legend]
Collaboration diagram for ModelBase:
Collaboration graph
[legend]

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 ()
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ModelBase()

ModelBase::ModelBase ( QString  aDataTableName,
unsigned  aMaxRowsToKeep 
)

Constructor.

Parameters
aDataTableNamespecifies the database table where (most) of the data related to this model-part is stored in
aMaxRowsToKeepinitial 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::~ModelBase ( )

Member Function Documentation

◆ deleteOldestDataRowInTable()

virtual bool ModelBase::deleteOldestDataRowInTable ( )
privatevirtual

Reimplemented in ProfileModel.

◆ error

void ModelBase::error ( MController::CAErrorSituation  aError,
const QString &  aExplanation 
)
signal

◆ getMaxRowsToKeep()

unsigned ModelBase::getMaxRowsToKeep ( )

method for controlling table truncation length

◆ setMaxRowsToKeep()

void ModelBase::setMaxRowsToKeep ( unsigned  aRows)

method for controlling table truncation length variable

◆ setTimeLastReference()

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.

◆ truncateDataTableToMaxRows()

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.

◆ updateDbTableRowCount()

void ModelBase::updateDbTableRowCount ( )

method for getting initial value for iCurrentDbTableRowCount

Member Data Documentation

◆ iCurrentDbTableRowCount

unsigned ModelBase::iCurrentDbTableRowCount
protected

Number of rows currently on table. This may get incremented by classes that inherint this class.

◆ iDataTableName

QString ModelBase::iDataTableName
protected

name of primary table where data related to each model part is kept ; in runtime this gets values like "binaryfile" or "profle"

◆ iMaxRowsToKeep

unsigned ModelBase::iMaxRowsToKeep
protected

max number of rows to keep in db table whose name is in iDataTableName


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