source: src/mvc/track.cpp @ e662750

qt5
Last change on this file since e662750 was 4693fa6, checked in by pavelpa <pavelpa@…>, 13 years ago

changed 'Activity' -> 'Track'

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