[65] | 1 | /*! |
---|
[67] | 2 | * \file tspmodel.h |
---|
[65] | 3 | * \author Copyright © 2007-2009 Lёppa <contacts[at]oleksii[dot]name> |
---|
[14] | 4 | * |
---|
| 5 | * $Id: tspmodel.h 67 2009-10-24 13:37:48Z laleppa $ |
---|
| 6 | * $URL: https://tspsg.svn.sourceforge.net/svnroot/tspsg/trunk/src/tspmodel.h $ |
---|
| 7 | * |
---|
[67] | 8 | * \brief Defines CTSPModel class. |
---|
| 9 | * |
---|
[65] | 10 | * <b>TSPSG: TSP Solver and Generator</b> |
---|
| 11 | * |
---|
[14] | 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 | |
---|
[67] | 31 | #include "globals.h" |
---|
| 32 | |
---|
[66] | 33 | /*! |
---|
[67] | 34 | * \brief This class implements table model for manipulating a task. |
---|
| 35 | * \author Copyright © 2007-2009 Lёppa <contacts[at]oleksii[dot]name> |
---|
[66] | 36 | */ |
---|
[14] | 37 | class CTSPModel: public QAbstractTableModel |
---|
| 38 | { |
---|
| 39 | Q_OBJECT |
---|
[47] | 40 | |
---|
[14] | 41 | public: |
---|
| 42 | CTSPModel(QObject *parent = 0); |
---|
[47] | 43 | void clear(); |
---|
[14] | 44 | int columnCount(const QModelIndex &) const; |
---|
| 45 | QVariant data(const QModelIndex &, int) const; |
---|
| 46 | Qt::ItemFlags flags(const QModelIndex &) const; |
---|
[47] | 47 | QVariant headerData(int, Qt::Orientation, int) const; |
---|
| 48 | bool loadTask(QString); |
---|
[31] | 49 | quint16 numCities() const; |
---|
[47] | 50 | void randomize(); |
---|
| 51 | int rowCount(const QModelIndex &) const; |
---|
| 52 | bool saveTask(QString); |
---|
| 53 | bool setData(const QModelIndex &, const QVariant &, int); |
---|
[14] | 54 | void setNumCities(int); |
---|
[47] | 55 | |
---|
[31] | 56 | signals: |
---|
[67] | 57 | /*! |
---|
| 58 | * \brief This signal is emitted whenever the number of cities in the task changes. |
---|
| 59 | * |
---|
| 60 | * \sa setNumCities() |
---|
| 61 | */ |
---|
[31] | 62 | void numCitiesChanged(int); |
---|
[47] | 63 | |
---|
[14] | 64 | private: |
---|
[21] | 65 | QSettings *settings; |
---|
[46] | 66 | QVector<QVector<double> > table; |
---|
[31] | 67 | quint16 nCities; |
---|
[47] | 68 | bool loadError(QDataStream::Status); |
---|
[50] | 69 | bool loadTSPT(QDataStream *); |
---|
[47] | 70 | bool loadZKT(QDataStream *); |
---|
[35] | 71 | int rand(int, int) const; |
---|
[14] | 72 | }; |
---|
| 73 | |
---|
| 74 | #endif // TSPMODEL_H |
---|