Changeset 807cbdb


Ignore:
Timestamp:
01/20/10 13:26:30 (12 years ago)
Author:
korrco <korrco@…>
Branches:
master, qt5
Children:
b8fda99
Parents:
5d7c9e5
Message:

static allocation instead of dynamic added when creating activity map

Location:
src/mvc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/mvc/activity.cpp

    r5d7c9e5 r807cbdb  
    1515    << QSqlField("name", QVariant::String));
    1616
     17QMap<int, Activity> Activity::mIdToActivity;
     18
    1719QList<Activity> Activity::getAll()
    1820{
     
    2224}
    2325
    24 QMap<int, Activity>* Activity::mIdToActivity = 0;
    25 
    2626void Activity::updateActivityMap()
    2727{
    28     if (mIdToActivity)
    29     {
    30         delete mIdToActivity;
    31     }
    32     mIdToActivity = new QMap<int, Activity>;
     28    mIdToActivity.clear();
    3329    QList<Activity> activityList = Activity::getAll();
    3430    Activity activity;
    3531    for (int id = 0; id < activityList.count(); ++id) {
    3632        activity = activityList.at(id);
    37         mIdToActivity->insert(activity.id(), activity);
     33        mIdToActivity.insert(activity.id(), activity);
    3834    }
    3935}
     
    4137QString Activity::getActivityName(int id)
    4238{
    43     QString name = mIdToActivity->value(id).name();
     39    QString name = mIdToActivity.value(id).name();
    4440    if (name == "") {
    4541        qDebug() << QString("Error: undefined activity name for id %1").arg(id);
  • src/mvc/activity.h

    r5d7c9e5 r807cbdb  
    1818    static const int sTableColCount;
    1919public:
     20    static QMap<int, Activity> mIdToActivity;
     21public:
    2022    static QList<Activity> getAll();
    2123    int id() const { return value("id").toInt(); }
     
    2628    static void updateActivityMap();
    2729    static QString getActivityName(int id);
    28 private:
    29     static QMap<int, Activity>* mIdToActivity;
    3030};
    3131
Note: See TracChangeset for help on using the changeset viewer.