Back to index

salome-paravis  6.5.0
Public Member Functions | Private Member Functions | Private Attributes
OptionsDialogModel Class Reference
Collaboration diagram for OptionsDialogModel:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 OptionsDialogModel (QObject *parent=0)
virtual ~OptionsDialogModel ()
virtual int rowCount (const QModelIndex &parent=QModelIndex()) const
virtual int columnCount (const QModelIndex &parent=QModelIndex()) const
virtual QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const
virtual QModelIndex parent (const QModelIndex &child) const
virtual QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const
QModelIndex getIndex (const QString &path) const
QString getPath (const QModelIndex &index) const
void addPath (const QString &path)
bool removeIndex (const QModelIndex &index)

Private Member Functions

QModelIndex getIndex (OptionsDialogModelItem *item) const

Private Attributes

OptionsDialogModelItemRoot

Detailed Description

Definition at line 58 of file PVGUI_ParaViewSettingsPane.cxx.


Constructor & Destructor Documentation

OptionsDialogModel::OptionsDialogModel ( QObject *  parent = 0)

Definition at line 123 of file PVGUI_ParaViewSettingsPane.cxx.

  : QAbstractItemModel(parentObject)
{
  this->Root = new OptionsDialogModelItem();
}

Definition at line 129 of file PVGUI_ParaViewSettingsPane.cxx.

{
  delete this->Root;
}

Member Function Documentation

void OptionsDialogModel::addPath ( const QString &  path)

Definition at line 250 of file PVGUI_ParaViewSettingsPane.cxx.

{
  OptionsDialogModelItem *item = this->Root;
  QStringList names = path.split(".");
  QStringList::Iterator iter = names.begin();
  for( ; iter != names.end(); ++iter)
    {
    OptionsDialogModelItem *child = 0;
    QList<OptionsDialogModelItem *>::Iterator jter = item->Children.begin();
    for( ; jter != item->Children.end(); ++jter)
      {
      if((*jter)->Name == *iter)
        {
        child = *jter;
        break;
        }
      }

    if(!child)
      {
      child = new OptionsDialogModelItem(*iter);
      child->Parent = item;
      QModelIndex parentIndex = this->getIndex(item);
      int row = item->Children.size();
      this->beginInsertRows(parentIndex, row, row);
      item->Children.append(child);
      this->endInsertRows();
      }

    item = child;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int OptionsDialogModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const [virtual]

Definition at line 146 of file PVGUI_ParaViewSettingsPane.cxx.

{
  return 1;
}
QVariant OptionsDialogModel::data ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const [virtual]

Definition at line 181 of file PVGUI_ParaViewSettingsPane.cxx.

{
  if(idx.isValid())
    {
    OptionsDialogModelItem *item =
        reinterpret_cast<OptionsDialogModelItem *>(idx.internalPointer());
    if(role == Qt::DisplayRole || role == Qt::ToolTipRole)
      {
      return QVariant(item->Name);
      }
    }

  return QVariant();
}
QModelIndex OptionsDialogModel::getIndex ( const QString &  path) const

Definition at line 196 of file PVGUI_ParaViewSettingsPane.cxx.

{
  OptionsDialogModelItem *item = this->Root;
  QStringList names = path.split(".");
  QStringList::Iterator iter = names.begin();
  for( ; item && iter != names.end(); ++iter)
    {
    OptionsDialogModelItem *child = 0;
    QList<OptionsDialogModelItem *>::Iterator jter = item->Children.begin();
    for( ; jter != item->Children.end(); ++jter)
      {
      if((*jter)->Name == *iter)
        {
        child = *jter;
        break;
        }
      }

    item = child;
    }

  if(item && item != this->Root)
    {
    return this->getIndex(item);
    }

  return QModelIndex();
}

Here is the caller graph for this function:

QModelIndex OptionsDialogModel::getIndex ( OptionsDialogModelItem item) const [private]

Definition at line 303 of file PVGUI_ParaViewSettingsPane.cxx.

{
  if(item && item->Parent)
    {
    return this->createIndex(item->Parent->Children.indexOf(item), 0, item);
    }

  return QModelIndex();
}
QString OptionsDialogModel::getPath ( const QModelIndex &  index) const

Definition at line 225 of file PVGUI_ParaViewSettingsPane.cxx.

{
  if(idx.isValid())
    {
    QString path;
    OptionsDialogModelItem *item =
        reinterpret_cast<OptionsDialogModelItem *>(idx.internalPointer());
    if(item)
      {
      path = item->Name;
      item = item->Parent;
      }

    while(item && item != this->Root)
      {
      path.prepend(".").prepend(item->Name);
      item = item->Parent;
      }

    return path;
    }

  return QString();
}

Here is the caller graph for this function:

QModelIndex OptionsDialogModel::index ( int  row,
int  column,
const QModelIndex &  parent = QModelIndex() 
) const [virtual]

Definition at line 151 of file PVGUI_ParaViewSettingsPane.cxx.

{
  OptionsDialogModelItem *item = this->Root;
  if(parentIndex.isValid())
    {
    item = reinterpret_cast<OptionsDialogModelItem *>(
        parentIndex.internalPointer());
    }

  if(column == 0 && row >= 0 && row < item->Children.size())
    {
    return this->createIndex(row, column, item->Children[row]);
    }

  return QModelIndex();
}
QModelIndex OptionsDialogModel::parent ( const QModelIndex &  child) const [virtual]

Definition at line 169 of file PVGUI_ParaViewSettingsPane.cxx.

{
  if(child.isValid())
    {
    OptionsDialogModelItem *item =
        reinterpret_cast<OptionsDialogModelItem *>(child.internalPointer());
    return this->getIndex(item->Parent);
    }

  return QModelIndex();
}

Here is the call graph for this function:

bool OptionsDialogModel::removeIndex ( const QModelIndex &  index)

Definition at line 283 of file PVGUI_ParaViewSettingsPane.cxx.

{
  if(idx.isValid())
    {
    OptionsDialogModelItem *item =
        reinterpret_cast<OptionsDialogModelItem *>(idx.internalPointer());
    if(item->Children.size() == 0)
      {
      QModelIndex parentIndex = this->getIndex(item->Parent);
      this->beginRemoveRows(parentIndex, idx.row(), idx.row());
      item->Parent->Children.removeAt(idx.row());
      this->endRemoveRows();
      delete item;
      return true;
      }
    }

  return false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int OptionsDialogModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const [virtual]

Definition at line 134 of file PVGUI_ParaViewSettingsPane.cxx.

{
  OptionsDialogModelItem *item = this->Root;
  if(parentIndex.isValid())
    {
    item = reinterpret_cast<OptionsDialogModelItem *>(
        parentIndex.internalPointer());
    }

  return item->Children.size();
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 82 of file PVGUI_ParaViewSettingsPane.cxx.


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