source: tspsg-svn/trunk/src/tspmodel.h @ 88

Last change on this file since 88 was 87, checked in by laleppa, 15 years ago

+ Added Fractional accuracy (in decimail places) to settings.
+ Created defaults.h file. Moved all default defines there.

  • Replaced all double types with qreal.
  • Replaced all calls to trUtf8() with tr() as we use setCodecForTr() to set UTF-8 encoding as default and tr() is enough.
  • Replaced all 2009 with 2010 in copyrights.
  • Fixed an error when loading .zkt file with less than 5 cities.
  • Property svn:keywords set to Id URL
File size: 2.2 KB
Line 
1/*!
2 * \file tspmodel.h
3 * \author Copyright &copy; 2007-2010 Lёppa <contacts[at]oleksii[dot]name>
4 *
5 *  $Id: tspmodel.h 87 2010-01-12 14:11:24Z laleppa $
6 *  $URL: https://tspsg.svn.sourceforge.net/svnroot/tspsg/trunk/src/tspmodel.h $
7 *
8 * \brief Defines CTSPModel class.
9 *
10 *  <b>TSPSG: TSP Solver and Generator</b>
11 *
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
31#include "globals.h"
32
33/*!
34 * \brief This class implements table model for manipulating a task.
35 * \author Copyright &copy; 2007-2010 Lёppa <contacts[at]oleksii[dot]name>
36 */
37class CTSPModel: public QAbstractTableModel
38{
39        Q_OBJECT
40
41public:
42        CTSPModel(QObject *parent = 0);
43        void clear();
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);
49        quint16 numCities() const;
50        void randomize();
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);
55
56signals:
57        /*!
58         * \brief This signal is emitted whenever the number of cities in the task changes.
59         *
60         * \sa setNumCities()
61         */
62        void numCitiesChanged(int);
63
64private:
65        QSettings *settings;
66        QVector<QVector<qreal> > table;
67        quint16 nCities;
68        bool loadError(QDataStream::Status);
69        bool loadTSPT(QDataStream *);
70        bool loadZKT(QDataStream *);
71        qreal rand(int, int) const;
72};
73
74#endif // TSPMODEL_H
Note: See TracBrowser for help on using the repository browser.