source: src/mvc/activity.cpp @ a5c1179

qt5
Last change on this file since a5c1179 was 807cbdb, checked in by korrco <korrco@…>, 12 years ago

static allocation instead of dynamic added when creating activity map

  • Property mode set to 100644
File size: 1.0 KB
Line 
1/*
2 * activity.cpp
3 *
4 *  Created on: Dec 27, 2009
5 *      Author: Pavol Korinek
6 */
7
8#include "activity.h"
9
10QString const Activity::sTableName = QString("activity");
11int const Activity::sTableColCount = 2;
12
13QSqlRecord const Activity::sColumns = Activity::toRecord(QList<QSqlField>()
14    << QSqlField("id", QVariant::Int)
15    << QSqlField("name", QVariant::String));
16
17QMap<int, Activity> Activity::mIdToActivity;
18
19QList<Activity> Activity::getAll()
20{
21    QSqlQuery query;
22    query.prepare(selectQuery());
23    return load(query);
24}
25
26void Activity::updateActivityMap()
27{
28    mIdToActivity.clear();
29    QList<Activity> activityList = Activity::getAll();
30    Activity activity;
31    for (int id = 0; id < activityList.count(); ++id) {
32        activity = activityList.at(id);
33        mIdToActivity.insert(activity.id(), activity);
34    }
35}
36
37QString Activity::getActivityName(int id)
38{
39    QString name = mIdToActivity.value(id).name();
40    if (name == "") {
41        qDebug() << QString("Error: undefined activity name for id %1").arg(id);
42    }
43    return name;
44}
Note: See TracBrowser for help on using the repository browser.