1 /* ColorCode, a free MasterMind clone with built in solver
2  * Copyright (C) 2009  Dirk Laebisch
3  * http://www.laebisch.com/
4  *
5  * ColorCode is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * ColorCode is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with ColorCode. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #include "prevgamesmodel.h"
20 #include "gametableview.h"
21 
GetPrevGamesModel()22 PrevGamesModel* GetPrevGamesModel()
23 {
24     static PrevGamesModel* m = new PrevGamesModel();
25     return m;
26 }
27 
PrevGamesModel(QObject * parent)28 PrevGamesModel::PrevGamesModel(QObject* parent) : GamesListModel(parent)
29 {
30     mId = MODEL_ID_PREV;
31     mEditIndex = QModelIndex();
32     mMaxSize = 20;
33 }
34 
GetColIx(const int ix) const35 int PrevGamesModel::GetColIx(const int ix) const
36 {
37     int ret = -1;
38     if (ix == COL_RANKING)
39     {
40         ret = 0;
41     }
42     else if (ix == COL_DATE)
43     {
44         ret = 1;
45     }
46     else if (ix == COL_TIME)
47     {
48         ret = 2;
49     }
50     else if (ix == COL_DELETE)
51     {
52         ret = 3;
53     }
54     return ret;
55 }
56 
GetMaxColCnt() const57 int PrevGamesModel::GetMaxColCnt() const
58 {
59     return 4;
60 }
61 
DoSort(QList<CCGame> & list)62 void PrevGamesModel::DoSort(QList<CCGame> &list)
63 {
64     qSort(list.begin(), list.end(), GamesListModel::SortListTime);
65 }
66