CTSPModel Class Reference

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

#include <tspmodel.h>

Inheritance diagram for CTSPModel:
Inheritance graph
[legend]
Collaboration diagram for CTSPModel:
Collaboration graph
[legend]

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-2009 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()

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:
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

Here is the call graph for this function:

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.

Here is the call graph for this function:

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()

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:
fname The 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 
)

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()

Here is the call graph for this function:

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()

Here is the call graph for this function:


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Defines

Generated on Thu Jan 7 18:22:50 2010 for TSPSG: TSP Solver and Generator by  doxygen 1.6.1