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