This class implements table model for manipulating a task.
More...
#include <tspmodel.h>
List of all members.
Signals |
void | numCitiesChanged (int) |
| This signal is emitted whenever the number of cities in the task changes.
|
Public Member Functions |
| CTSPModel (QObject *parent=0) |
| Class constructor.
|
void | clear () |
| Resets the table, setting all its elements to 0.
|
int | columnCount (const QModelIndex &parent=QModelIndex()) const |
| Returns the column count in the table.
|
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.
|
Qt::ItemFlags | flags (const QModelIndex &index) const |
| Returns the item flags for the given index.
|
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.
|
bool | loadTask (const QString &fname) |
| Loads a task from fname.
|
quint16 | numCities () const |
| Returns the number of cities.
|
void | randomize () |
| Randomizes the table by setting all its values to random ones.
|
int | rowCount (const QModelIndex &parent=QModelIndex()) const |
| Returns the row count in the table.
|
bool | saveTask (const QString &fname) |
| Saves current task to fname.
|
bool | setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) |
| Sets the role data for the item at index to value.
|
void | setNumCities (int n) |
| Sets number of cities in the current task to n.
|
Detailed Description
This class implements table model for manipulating a task.
- Author:
- Copyright © 2007-2010 Lёppa <contacts[at]oleksii[dot]name>
Constructor & Destructor Documentation
CTSPModel::CTSPModel |
( |
QObject * |
parent = 0 |
) |
|
Class constructor.
- Parameters:
-
| parent | The parent of the table model. |
Member Function Documentation
void CTSPModel::clear |
( |
|
) |
|
Resets the table, setting all its elements to 0.
- See also:
- randomize()
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()
Returns the data stored under the given role for the item referred to by the index.
- Parameters:
-
| index | An item index to get data from. |
| role | The role to get data for. |
- Returns:
- Corresponding data.
- See also:
- setData(), headerData()
- Hack:
- HACK: Converting to string to prevent spinbox in edit mode
Qt::ItemFlags CTSPModel::flags |
( |
const QModelIndex & |
index |
) |
const |
Returns the item flags for the given index.
- Parameters:
-
| index | An item index to get flags from. |
- Returns:
- Corresponding item flags.
QVariant CTSPModel::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.
- Parameters:
-
| section | The section to get header data for. |
| orientation | The orientation to get header data for. |
| role | The 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.
bool CTSPModel::loadTask |
( |
const QString & |
fname |
) |
|
Loads a task from fname.
- Parameters:
-
| fname | The name of the file to be loaded. |
- Returns:
true
on success, otherwise false
.
- See also:
- saveTask()
quint16 CTSPModel::numCities |
( |
|
) |
const |
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()
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:
-
| fname | The name of the file to seve to. |
- Returns:
true
on success, otherwise false
.
- See also:
- loadTask()
bool CTSPModel::setData |
( |
const QModelIndex & |
index, |
|
|
const QVariant & |
value, |
|
|
int |
role = Qt::EditRole | |
|
) |
| | |
Sets the role data for the item at index to value.
- Parameters:
-
| index | The index of the item to set data at. |
| value | The value of the item data to be set. |
| role | The role of the item to set data for. |
- Returns:
true
on success, otherwise false
.
- See also:
- data()
void CTSPModel::setNumCities |
( |
int |
n |
) |
|
Sets number of cities in the current task to n.
- Parameters:
-
| n | Number of cities to set to. |
- See also:
- numCities()
The documentation for this class was generated from the following files: