TSP Solver and Generator
Signals | Public Member Functions | List of all members
CTSPModel Class Reference

This class implements table model for manipulating a task. More...

#include <tspmodel.h>

+ Inheritance diagram for CTSPModel:
+ Collaboration diagram for CTSPModel:

Signals

void numCitiesChanged (int)
 This signal is emitted whenever the number of cities in the task changes. More...
 

Public Member Functions

 CTSPModel (QObject *parent=0)
 Class constructor. More...
 
void clear ()
 Resets the table, setting all its elements to 0. More...
 
int columnCount (const QModelIndex &parent=QModelIndex()) const
 Returns the column count in the table. More...
 
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const
 Returns the data stored under the given role for the item referred to by the index. More...
 
Qt::ItemFlags flags (const QModelIndex &index) const
 Returns the item flags for the given index. More...
 
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
 Returns the data for the given role and section in the header with the specified orientation. More...
 
bool loadTask (const QString &fname)
 Loads a task from fname. More...
 
quint16 numCities () const
 Returns the number of cities. More...
 
void randomize ()
 Randomizes the table by setting all its values to random ones. More...
 
int rowCount (const QModelIndex &parent=QModelIndex()) const
 Returns the row count in the table. More...
 
bool saveTask (const QString &fname)
 Saves current task to fname. More...
 
bool setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
 Sets the role data for the item at index to value. More...
 
void setNumCities (int n)
 Sets number of cities in the current task to n. More...
 
- Public Member Functions inherited from QAbstractTableModel
 QAbstractTableModel (QObject *parent)
 
virtual QModelIndex index (int row, int column, const QModelIndex &parent) const
 
virtual bool dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
 
- Public Member Functions inherited from QAbstractItemModel
 QAbstractItemModel (QObject *parent)
 
bool hasIndex (int row, int column, const QModelIndex &parent) const
 
virtual QModelIndex index (int row, int column, const QModelIndex &parent) const =0
 
virtual QModelIndex parent (const QModelIndex &index) const =0
 
QModelIndex sibling (int row, int column, const QModelIndex &index) const
 
virtual int rowCount (const QModelIndex &parent) const =0
 
virtual int columnCount (const QModelIndex &parent) const =0
 
virtual bool hasChildren (const QModelIndex &parent) const
 
virtual QVariant data (const QModelIndex &index, int role) const =0
 
virtual bool setHeaderData (int section, Qt::Orientation orientation, const QVariant &value, int role)
 
virtual QMap< int, QVariantitemData (const QModelIndex &index) const
 
virtual bool setItemData (const QModelIndex &index, const QMap< int, QVariant > &roles)
 
virtual QStringList mimeTypes () const
 
virtual QMimeDatamimeData (const QModelIndexList &indexes) const
 
virtual Qt::DropActions supportedDropActions () const
 
Qt::DropActions supportedDragActions () const
 
void setSupportedDragActions (QFlags< Qt::DropAction > actions)
 
virtual bool insertRows (int row, int count, const QModelIndex &parent)
 
virtual bool insertColumns (int column, int count, const QModelIndex &parent)
 
virtual bool removeRows (int row, int count, const QModelIndex &parent)
 
virtual bool removeColumns (int column, int count, const QModelIndex &parent)
 
bool insertRow (int row, const QModelIndex &parent)
 
bool insertColumn (int column, const QModelIndex &parent)
 
bool removeRow (int row, const QModelIndex &parent)
 
bool removeColumn (int column, const QModelIndex &parent)
 
virtual void fetchMore (const QModelIndex &parent)
 
virtual bool canFetchMore (const QModelIndex &parent) const
 
virtual void sort (int column, Qt::SortOrder order)
 
virtual QModelIndex buddy (const QModelIndex &index) const
 
virtual QModelIndexList match (const QModelIndex &start, int role, const QVariant &value, int hits, QFlags< Qt::MatchFlag > flags) const
 
virtual QSize span (const QModelIndex &index) const
 
const QHash< int, QByteArray > & roleNames () const
 
void dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight)
 
void headerDataChanged (Qt::Orientation orientation, int first, int last)
 
void layoutChanged ()
 
void layoutAboutToBeChanged ()
 
void rowsAboutToBeInserted (const QModelIndex &parent, int start, int end)
 
void rowsInserted (const QModelIndex &parent, int start, int end)
 
void rowsAboutToBeRemoved (const QModelIndex &parent, int start, int end)
 
void rowsRemoved (const QModelIndex &parent, int start, int end)
 
void columnsAboutToBeInserted (const QModelIndex &parent, int start, int end)
 
void columnsInserted (const QModelIndex &parent, int start, int end)
 
void columnsAboutToBeRemoved (const QModelIndex &parent, int start, int end)
 
void columnsRemoved (const QModelIndex &parent, int start, int end)
 
void modelAboutToBeReset ()
 
void modelReset ()
 
void rowsAboutToBeMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow)
 
void rowsMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow)
 
void columnsAboutToBeMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn)
 
void columnsMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn)
 
virtual bool submit ()
 
virtual void revert ()
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
virtual const QMetaObjectmetaObject () const
 
QString objectName () const
 
void setObjectName (const QString &name)
 
bool isWidgetType () const
 
bool signalsBlocked () const
 
bool blockSignals (bool block)
 
QThreadthread () const
 
void moveToThread (QThread *targetThread)
 
int startTimer (int interval)
 
void killTimer (int id)
 
findChild (const QString &name) const
 
QList< T > findChildren (const QString &name) const
 
QList< T > findChildren (const QRegExp &regExp) const
 
QObjectchild (const char *objName, const char *inheritsClass, bool recursiveSearch) const
 
const QObjectList & children () const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
bool connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const
 
bool disconnect (const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *receiver, const char *method)
 
void dumpObjectTree ()
 
void dumpObjectInfo ()
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const
 
QList< QByteArraydynamicPropertyNames () const
 
void destroyed (QObject *obj)
 
QObjectparent () const
 
bool inherits (const char *className) const
 
void deleteLater ()
 
 QObject (QObject *parent, const char *name)
 
void insertChild (QObject *object)
 
void removeChild (QObject *object)
 
bool isA (const char *className) const
 
const char * className () const
 
const char * name () const
 
const char * name (const char *defaultName) const
 
void setName (const char *name)
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
- Protected Member Functions inherited from QAbstractItemModel
QModelIndex createIndex (int row, int column, void *ptr) const
 
QModelIndex createIndex (int row, int column, int id) const
 
QModelIndex createIndex (int row, int column, quint32 id) const
 
void beginInsertRows (const QModelIndex &parent, int first, int last)
 
void endInsertRows ()
 
void beginRemoveRows (const QModelIndex &parent, int first, int last)
 
void endRemoveRows ()
 
bool beginMoveRows (const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationChild)
 
void endMoveRows ()
 
void beginInsertColumns (const QModelIndex &parent, int first, int last)
 
void endInsertColumns ()
 
void beginRemoveColumns (const QModelIndex &parent, int first, int last)
 
void endRemoveColumns ()
 
bool beginMoveColumns (const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationChild)
 
void endMoveColumns ()
 
void reset ()
 
void beginResetModel ()
 
void endResetModel ()
 
void changePersistentIndex (const QModelIndex &from, const QModelIndex &to)
 
void changePersistentIndexList (const QModelIndexList &from, const QModelIndexList &to)
 
QModelIndexList persistentIndexList () const
 
void setRoleNames (const QHash< int, QByteArray > &roleNames)
 
void resetInternalData ()
 
- Protected Member Functions inherited from QObject
QObjectsender () const
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const char *signal)
 
virtual void disconnectNotify (const char *signal)
 
bool checkConnectArgs (const char *signal, const QObject *object, const char *method)
 
- Static Protected Member Functions inherited from QObject
QByteArray normalizeSignalSlot (const char *signalSlot)
 
- Properties inherited from QObject
 objectName
 

Detailed Description

This class implements table model for manipulating a task.

Author
Copyright © 2007-2016 Oleksii Serdiuk <contacts[at]oleksii[dot]name>

Constructor & Destructor Documentation

CTSPModel::CTSPModel ( QObject parent = 0)

Class constructor.

Parameters
parentThe parent of the table model.

Member Function Documentation

void CTSPModel::clear ( )

Resets the table, setting all its elements to 0.

See also
randomize()

+ Here is the call graph for this function:

int CTSPModel::columnCount ( const QModelIndex parent = QModelIndex()) const

Returns the column count in the table.

Returns
Number of columns in the table.

Actually, this function returns the number of cities in the current task.

See also
numCities(), rowCount()
QVariant CTSPModel::data ( const QModelIndex index,
int  role = Qt::DisplayRole 
) const

Returns the data stored under the given role for the item referred to by the index.

Parameters
indexAn item index to get data from.
roleThe role to get data for.
Returns
Corresponding data.
See also
setData(), headerData()
Hack:
HACK: Converting to string to prevent spinbox in edit mode

+ Here is the call graph for this function:

Qt::ItemFlags CTSPModel::flags ( const QModelIndex index) const
virtual

Returns the item flags for the given index.

Parameters
indexAn item index to get flags from.
Returns
Corresponding item flags.

Reimplemented from QAbstractItemModel.

+ Here is the call graph for this function:

QVariant CTSPModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const
virtual

Returns the data for the given role and section in the header with the specified orientation.

Parameters
sectionThe section to get header data for.
orientationThe orientation to get header data for.
roleThe role to get header data for.
Returns
Corresponding header data.

For horizontal headers, the section number corresponds to the column number of items shown beneath it. For vertical headers, the section number typically to the row number of items shown alongside it.

Reimplemented from QAbstractItemModel.

+ Here is the call graph for this function:

bool CTSPModel::loadTask ( const QString fname)

Loads a task from fname.

Parameters
fnameThe name of the file to be loaded.
Returns
true on success, otherwise false.
See also
saveTask()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

quint16 CTSPModel::numCities ( ) const

Returns the number of cities.

Returns
Number of cities in the current task.
See also
columnCount(), rowCount(), setNumCities()
void CTSPModel::numCitiesChanged ( int  )
signal

This signal is emitted whenever the number of cities in the task changes.

See also
setNumCities()
void CTSPModel::randomize ( )

Randomizes the table by setting all its values to random ones.

Uses TSPSG settings to determine random values range.

See also
clear()

+ Here is the call graph for this function:

int CTSPModel::rowCount ( const QModelIndex parent = QModelIndex()) const

Returns the row count in the table.

Returns
Number of rows in the table.

Actually, this function returns the number of cities in the current task.

See also
columnCount(), numCities()
bool CTSPModel::saveTask ( const QString fname)

Saves current task to fname.

Parameters
fnameThe name of the file to seve to.
Returns
true on success, otherwise false.
See also
loadTask()

+ Here is the call graph for this function:

bool CTSPModel::setData ( const QModelIndex index,
const QVariant value,
int  role = Qt::EditRole 
)
virtual

Sets the role data for the item at index to value.

Parameters
indexThe index of the item to set data at.
valueThe value of the item data to be set.
roleThe role of the item to set data for.
Returns
true on success, otherwise false.
See also
data()

Reimplemented from QAbstractItemModel.

+ Here is the call graph for this function:

void CTSPModel::setNumCities ( int  n)

Sets number of cities in the current task to n.

Parameters
nNumber of cities to set to.
See also
numCities()

+ Here is the call graph for this function:


The documentation for this class was generated from the following files: