COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
Classes | Public Slots | Public Member Functions | Private Attributes | List of all members
FavoritesModel Class Reference

Model that manages a list of favorite directories. More...

#include <FavoritesModel.hpp>

Inherits QAbstractItemModel.

Classes

struct  SpecialDir
 

Public Slots

void set_string_list (const QStringList &list)
 

Public Member Functions

 FavoritesModel ()
 Constructor. More...
 
virtual QVariant data (const QModelIndex &index, int role) const
 Implements QAbstractItemModel::data. More...
 
virtual QModelIndex parent (const QModelIndex &child) const
 Implements QAbstractItemModel::parent. More...
 
virtual QModelIndex index (int row, int column, const QModelIndex &parent) const
 Implements QAbstractItemModel::index. More...
 
virtual int rowCount (const QModelIndex &parent) const
 Implements QAbstractItemModel::rowCount. More...
 
virtual int columnCount (const QModelIndex &parent) const
 Implements QAbstractItemModel::columnCount. More...
 
QStringList string_list () const
 Gives the list of favorites. More...
 
bool add_string (const QString &str)
 Adds a string. More...
 
bool remove_string (int i)
 Removes a string. More...
 
bool is_special_dir (const QModelIndex &index) const
 
QString full_path (const QModelIndex &index) const
 Gives the full path of teh directory pointed by the provided index. More...
 

Private Attributes

QList< SpecialDirm_special_dirs
 List of special directory. More...
 
QStringList m_data
 Model data. More...
 
QFileIconProvider m_provider
 The icon provider. More...
 

Detailed Description

Model that manages a list of favorite directories.

The model has two type of favorite directies : the normal favorites and the special ones. The normal favorites are managed by the server that saves the list to the disc and sends it to the GUI. It contains absolute paths to the directories. The special favorites are keywords giving access to special directories on the the server side, such as the remote home directory.
The model accepts new entries and entries removing with the following conditions:

Definition at line 39 of file FavoritesModel.hpp.

Constructor & Destructor Documentation

Constructor.

Definition at line 29 of file FavoritesModel.cpp.

Member Function Documentation

bool add_string ( const QString &  str)

Adds a string.

Parameters
strThe string to add.
Returns
Returns true if the string was successfuly added or false if the string was already present in the list.

Definition at line 129 of file FavoritesModel.cpp.

int columnCount ( const QModelIndex &  parent) const
virtual

Implements QAbstractItemModel::columnCount.

Gives the column count for a specified index.

Parameters
parentThe index.
Returns
Always returns 1.

Definition at line 94 of file FavoritesModel.cpp.

QVariant data ( const QModelIndex &  index,
int  role 
) const
virtual

Implements QAbstractItemModel::data.

Parameters
indexIndex of the wanted data.
roleDesired role. Only Qt::DisplayRole (text), Qt::DecorationRole (icon) and Qt::ToolTipRole roles are accepted.
Returns
Returns the desired value in the form of a QVariant. If the index or the role is not valid, an invalid QVariant is returned. In the case of Qt::DisplayRole, only the directory name is returned (not the full path).

Definition at line 40 of file FavoritesModel.cpp.

QString full_path ( const QModelIndex &  index) const

Gives the full path of teh directory pointed by the provided index.

Parameters
indexThe index.
Returns
Returns the directory full path, the favority directory name or an empty string if the index if not valid.

Definition at line 161 of file FavoritesModel.cpp.

QModelIndex index ( int  row,
int  column,
const QModelIndex &  parent 
) const
virtual

Implements QAbstractItemModel::index.

Gives a child index of a specified parent, at a specified position.

Parameters
rowThe row number of the wanted index.
columnThe column number of te wanted index.
parentThe parent index.
Returns
Returns the index, or an invalid index if it does not exist.

Definition at line 69 of file FavoritesModel.cpp.

bool is_special_dir ( const QModelIndex &  index) const

Indicates whether the favorite directory pointed by the index is a special directory.

Parameters
indexThe index.
Returns
Returns true if the directory is a special one; otherwose, returns false.

Definition at line 153 of file FavoritesModel.cpp.

QModelIndex parent ( const QModelIndex &  child) const
virtual

Implements QAbstractItemModel::parent.

Gives the parent index of a specified index.

Parameters
childThe child index.
Returns
Returns the parent index, or an invalid one if the specified index is not valid or has no parent.

Definition at line 62 of file FavoritesModel.cpp.

bool remove_string ( int  i)

Removes a string.

Parameters
iIndex of the string to remove
Returns
Returns true if the string was removed successfully or false if the index was not out of the list bounds or is the one of a special favorite.

Definition at line 141 of file FavoritesModel.cpp.

int rowCount ( const QModelIndex &  parent) const
virtual

Implements QAbstractItemModel::rowCount.

Gives the row count (number of children) for a specified parent.

Parameters
parentThe parent.
Returns
Returns number of children the parent has.

Definition at line 84 of file FavoritesModel.cpp.

void set_string_list ( const QStringList &  list)
slot

Sets the string list.

Parameters
listThe list to set.

Definition at line 101 of file FavoritesModel.cpp.

QStringList string_list ( ) const

Gives the list of favorites.

The special places are not present in this list.

Returns
Returns the list of favorites.

Definition at line 117 of file FavoritesModel.cpp.

Member Data Documentation

QStringList m_data
private

Model data.

Definition at line 161 of file FavoritesModel.hpp.

QFileIconProvider m_provider
private

The icon provider.

This class is heavy to initiate, so we create one instance for the object lifetime, instead of creating a new one each time the view calls data().

Definition at line 167 of file FavoritesModel.hpp.

QList<SpecialDir> m_special_dirs
private

List of special directory.

Definition at line 158 of file FavoritesModel.hpp.


The documentation for this class was generated from the following files:
Send comments to:
COOLFluiD Web Admin