/*! * \file tspmodel.h * \author Copyright © 2007-2010 Lёppa * * $Id: tspmodel.h 87 2010-01-12 14:11:24Z laleppa $ * $URL: https://tspsg.svn.sourceforge.net/svnroot/tspsg/trunk/src/tspmodel.h $ * * \brief Defines CTSPModel class. * * TSPSG: TSP Solver and Generator * * This file is part of TSPSG. * * TSPSG is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * TSPSG is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with TSPSG. If not, see . */ #ifndef TSPMODEL_H #define TSPMODEL_H #include "globals.h" /*! * \brief This class implements table model for manipulating a task. * \author Copyright © 2007-2010 Lёppa */ class CTSPModel: public QAbstractTableModel { Q_OBJECT public: CTSPModel(QObject *parent = 0); void clear(); int columnCount(const QModelIndex &parent = QModelIndex()) const; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; Qt::ItemFlags flags(const QModelIndex &index) const; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; bool loadTask(const QString &fname); quint16 numCities() const; void randomize(); int rowCount(const QModelIndex &parent = QModelIndex()) const; bool saveTask(const QString &fname); bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); void setNumCities(int n); signals: /*! * \brief This signal is emitted whenever the number of cities in the task changes. * * \sa setNumCities() */ void numCitiesChanged(int); private: QSettings *settings; QVector > table; quint16 nCities; bool loadError(QDataStream::Status); bool loadTSPT(QDataStream *); bool loadZKT(QDataStream *); qreal rand(int, int) const; }; #endif // TSPMODEL_H