[caef58b531] | 1 | /*! |
---|
| 2 | * \class CTSPModel |
---|
| 3 | * \author Copyright © 2007-2009 Lёppa <contacts[at]oleksii[dot]name> |
---|
| 4 | * \brief This class implements table model for manipulating a task. |
---|
[2f915f19f2] | 5 | * |
---|
| 6 | * $Id$ |
---|
| 7 | * $URL$ |
---|
| 8 | * |
---|
[caef58b531] | 9 | * <b>TSPSG: TSP Solver and Generator</b> |
---|
| 10 | * |
---|
[2f915f19f2] | 11 | * This file is part of TSPSG. |
---|
| 12 | * |
---|
| 13 | * TSPSG is free software: you can redistribute it and/or modify |
---|
| 14 | * it under the terms of the GNU General Public License as published by |
---|
| 15 | * the Free Software Foundation, either version 3 of the License, or |
---|
| 16 | * (at your option) any later version. |
---|
| 17 | * |
---|
| 18 | * TSPSG is distributed in the hope that it will be useful, |
---|
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 21 | * GNU General Public License for more details. |
---|
| 22 | * |
---|
| 23 | * You should have received a copy of the GNU General Public License |
---|
| 24 | * along with TSPSG. If not, see <http://www.gnu.org/licenses/>. |
---|
| 25 | */ |
---|
| 26 | |
---|
| 27 | #ifndef TSPMODEL_H |
---|
| 28 | #define TSPMODEL_H |
---|
| 29 | |
---|
[85ad815b0b] | 30 | /*! |
---|
| 31 | * \file tspmodel.h |
---|
| 32 | * \brief Defines CTSPModel class. |
---|
| 33 | */ |
---|
| 34 | |
---|
[993d5af6f6] | 35 | #include "globals.h" |
---|
[2f915f19f2] | 36 | |
---|
| 37 | class CTSPModel: public QAbstractTableModel |
---|
| 38 | { |
---|
| 39 | Q_OBJECT |
---|
[b424a7e320] | 40 | |
---|
[2f915f19f2] | 41 | public: |
---|
| 42 | CTSPModel(QObject *parent = 0); |
---|
[b424a7e320] | 43 | void clear(); |
---|
[2f915f19f2] | 44 | int columnCount(const QModelIndex &) const; |
---|
| 45 | QVariant data(const QModelIndex &, int) const; |
---|
| 46 | Qt::ItemFlags flags(const QModelIndex &) const; |
---|
[b424a7e320] | 47 | QVariant headerData(int, Qt::Orientation, int) const; |
---|
| 48 | bool loadTask(QString); |
---|
[993d5af6f6] | 49 | quint16 numCities() const; |
---|
[2bc8e278b7] | 50 | void randomize(); |
---|
[b424a7e320] | 51 | int rowCount(const QModelIndex &) const; |
---|
| 52 | bool saveTask(QString); |
---|
| 53 | bool setData(const QModelIndex &, const QVariant &, int); |
---|
| 54 | void setNumCities(int); |
---|
| 55 | |
---|
[993d5af6f6] | 56 | signals: |
---|
| 57 | void numCitiesChanged(int); |
---|
[b424a7e320] | 58 | |
---|
[2f915f19f2] | 59 | private: |
---|
[aecdf994f9] | 60 | QSettings *settings; |
---|
[9aa0e521ed] | 61 | QVector<QVector<double> > table; |
---|
[993d5af6f6] | 62 | quint16 nCities; |
---|
[430bd7f7e9] | 63 | bool loadError(QDataStream::Status); |
---|
[b424a7e320] | 64 | bool loadTSPT(QDataStream *); |
---|
[aaf2113307] | 65 | bool loadZKT(QDataStream *); |
---|
[b424a7e320] | 66 | int rand(int, int) const; |
---|
[2f915f19f2] | 67 | }; |
---|
| 68 | |
---|
| 69 | #endif // TSPMODEL_H |
---|