00001 00028 #ifndef TSPMODEL_H 00029 #define TSPMODEL_H 00030 00031 #include "globals.h" 00032 00037 class CTSPModel: public QAbstractTableModel 00038 { 00039 Q_OBJECT 00040 00041 public: 00042 CTSPModel(QObject *parent = 0); 00043 void clear(); 00044 int columnCount(const QModelIndex &parent = QModelIndex()) const; 00045 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; 00046 Qt::ItemFlags flags(const QModelIndex &index) const; 00047 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; 00048 bool loadTask(const QString &fname); 00049 quint16 numCities() const; 00050 void randomize(); 00051 int rowCount(const QModelIndex &parent = QModelIndex()) const; 00052 bool saveTask(const QString &fname); 00053 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); 00054 void setNumCities(int n); 00055 00056 signals: 00062 void numCitiesChanged(int); 00063 00064 private: 00065 QSettings *settings; 00066 QVector<QVector<double> > table; 00067 quint16 nCities; 00068 bool loadError(QDataStream::Status); 00069 bool loadTSPT(QDataStream *); 00070 bool loadZKT(QDataStream *); 00071 int rand(int, int) const; 00072 }; 00073 00074 #endif // TSPMODEL_H