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 "savedgamesmodel.h" 20 #include "gametableview.h" 21 GetSavedGamesModel()22SavedGamesModel* GetSavedGamesModel() 23 { 24 static SavedGamesModel* m = new SavedGamesModel(); 25 return m; 26 } 27 SavedGamesModel(QObject * parent)28SavedGamesModel::SavedGamesModel(QObject* parent) : GamesListModel(parent) 29 { 30 mId = MODEL_ID_SAVED; 31 mEditIndex = QModelIndex(); 32 mMaxSize = 20; 33 } 34 GetColIx(const int ix) const35int SavedGamesModel::GetColIx(const int ix) const 36 { 37 int ret = -1; 38 if (ix == COL_GAMENO) 39 { 40 ret = 0; 41 } 42 else if (ix == COL_CCNT) 43 { 44 ret = 1; 45 } 46 else if (ix == COL_PCNT) 47 { 48 ret = 2; 49 } 50 else if (ix == COL_DOUBLES) 51 { 52 ret = 3; 53 } 54 else if (ix == COL_DELETE) 55 { 56 ret = 4; 57 } 58 return ret; 59 } 60 GetMaxColCnt() const61int SavedGamesModel::GetMaxColCnt() const 62 { 63 return 5; 64 } 65 DoSort(QList<CCGame> & list)66void SavedGamesModel::DoSort(QList<CCGame> &list) 67 { 68 qSort(list.begin(), list.end(), GamesListModel::SortListTime); 69 } 70 71