Ejemplo n.º 1
0
bool AMActionHistoryModel3::logCompletedAction(const AMAction3 *completedAction, AMDatabase *database, int parentLogId){
	if(completedAction && completedAction->inFinalState()) {

		if(database == AMDatabase::database("scanActions") && AMActionRunner3::scanActionRunner()->cachedLogCount() > 200){
			database->commitTransaction();
			AMActionRunner3::scanActionRunner()->resetCachedLogCount();
		}
		if(database == AMDatabase::database("scanActions")){
			if(!database->transactionInProgress())
				database->startTransaction();
			AMActionRunner3::scanActionRunner()->incrementCachedLogCount();
		}

		AMActionLog3 actionLog(completedAction);
		actionLog.setParentId(parentLogId);
		if(actionLog.storeToDb(database)){
			AMActionLogItem3* item = new AMActionLogItem3(actionLog);
			emit modelAboutToBeRefreshed();
			/// \todo Ordering... This may end up at the wrong spot until a full refresh is done.  Most of the time, any actions added will be the most recent ones, however that is not guaranteed.
			appendItem(item);
			visibleActionsCount_++;
			emit modelRefreshed();

			return true;
		}
		return false;
	}
	else {
		return false;
	}
}
Ejemplo n.º 2
0
bool AMActionLog::logCompletedAction(const AMAction *completedAction, AMDatabase *database)
{
	if(completedAction && completedAction->inFinalState()) {
		AMActionLog actionLog(completedAction);
		return actionLog.storeToDb(database);
	}
	else {
		return false;
	}
}