COOLFluiD
Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
|
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< SpecialDir > | m_special_dirs |
List of special directory. More... | |
QStringList | m_data |
Model data. More... | |
QFileIconProvider | m_provider |
The icon provider. More... | |
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.
FavoritesModel | ( | ) |
Constructor.
Definition at line 29 of file FavoritesModel.cpp.
bool add_string | ( | const QString & | str | ) |
Adds a string.
str | The string to add. |
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.
|
virtual |
Implements QAbstractItemModel::columnCount
.
Gives the column count for a specified index.
parent | The index. |
Definition at line 94 of file FavoritesModel.cpp.
|
virtual |
Implements QAbstractItemModel::data
.
index | Index of the wanted data. |
role | Desired role. Only Qt::DisplayRole (text), Qt::DecorationRole (icon) and Qt::ToolTipRole roles are accepted. |
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.
index | The index. |
Definition at line 161 of file FavoritesModel.cpp.
|
virtual |
Implements QAbstractItemModel::index
.
Gives a child index of a specified parent, at a specified position.
row | The row number of the wanted index. |
column | The column number of te wanted index. |
parent | The parent index. |
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.
index | The index. |
true
if the directory is a special one; otherwose, returns false
. Definition at line 153 of file FavoritesModel.cpp.
|
virtual |
Implements QAbstractItemModel::parent
.
Gives the parent index of a specified index.
child | The child index. |
Definition at line 62 of file FavoritesModel.cpp.
bool remove_string | ( | int | i | ) |
Removes a string.
i | Index of the string to remove |
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.
|
virtual |
Implements QAbstractItemModel::rowCount
.
Gives the row count (number of children) for a specified parent.
parent | The parent. |
Definition at line 84 of file FavoritesModel.cpp.
|
slot |
Sets the string list.
list | The 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.
Definition at line 117 of file FavoritesModel.cpp.
|
private |
Model data.
Definition at line 161 of file FavoritesModel.hpp.
|
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.
|
private |
List of special directory.
Definition at line 158 of file FavoritesModel.hpp.
Send comments to: COOLFluiD Web Admin |