All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Public Member Functions
SciFigs::LayerPropertiesItem Class Reference

#include <GraphContentLayerProperties.h>

List of all members.

Public Member Functions

virtual int columnCount (const QModelIndex &parent=QModelIndex()) const
virtual QVariant data (const QModelIndex &index, int role) const
virtual Qt::ItemFlags flags (const QModelIndex &) const
virtual QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
virtual QModelIndex index (int, int column, const QModelIndex &parent=QModelIndex()) const
 LayerPropertiesItem (QObject *parent=0)
void moveLayersDown (QModelIndexList l)
void moveLayersUp (QModelIndexList l)
virtual QModelIndex parent (const QModelIndex &) const
int removeLayers (QModelIndexList l)
virtual int rowCount (const QModelIndex &parent=QModelIndex()) const
void selectAllLayers (bool s)
void selectLayers (QModelIndexList l)
virtual bool setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
void setGraph (GraphContent *g)

Constructor & Destructor Documentation

SciFigs::LayerPropertiesItem::LayerPropertiesItem ( QObject *  parent = 0) [inline]
: QAbstractItemModel(parent) {_graph=0;}

Member Function Documentation

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

References TRACE.

{
  TRACE;
  return 3;
}
QVariant SciFigs::LayerPropertiesItem::data ( const QModelIndex &  index,
int  role 
) const [virtual]

References SciFigs::GraphContent::layerCount(), SciFigs::GraphContentLayer::objectName, SciFigs::GraphContentLayer::opacity, TRACE, and SciFigs::GraphContentLayer::xml_tagName().

{
  TRACE;
  if( !index.isValid() ||
       index.row() >= _graph->layerCount() ||
       index.column() >=3) return QVariant();
  const GraphContentLayer * layer=_graph->layer(_graph->layerCount()-index.row()-1);
  switch (role) {
  case Qt::DisplayRole:
    switch(index.column()) {
    case 0: return layer->xml_tagName();
    case 1: return layer->objectName();
    default: return layer->opacity();
    }
  default:
    return QVariant();
  }
}
Qt::ItemFlags SciFigs::LayerPropertiesItem::flags ( const QModelIndex &  index) const [virtual]

References TRACE.

{
  TRACE;
  if(index.column()==0) {
    return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
  } else {
    return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;
  }
}
QVariant SciFigs::LayerPropertiesItem::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const [virtual]

References SciFigs::GraphContent::layerCount(), QGpCoreTools::tr(), and TRACE.

{
  TRACE;
  if(role!=Qt::DisplayRole) return QVariant();
  if(orientation==Qt::Horizontal) {
    switch(section) {
    case 0: return tr("Type");
    case 1: return tr("Name");
    default: return tr("Opacity");
    }
  } else {
    return _graph->layerCount() - section;
  }
}
QModelIndex SciFigs::LayerPropertiesItem::index ( int  row,
int  column,
const QModelIndex &  parent = QModelIndex() 
) const [virtual]

References TRACE.

Referenced by moveLayersDown(), moveLayersUp(), removeLayers(), and selectLayers().

{
  TRACE;
  return createIndex(row, column);
}
void SciFigs::LayerPropertiesItem::moveLayersDown ( QModelIndexList  l)

References index(), SciFigs::GraphContent::layerCount(), SciFigs::GraphContent::moveLayerDown(), and TRACE.

{
  TRACE;
  QList<int> indexList;
  QModelIndex index;
  foreach(index, l) indexList << _graph->layerCount()-index.row()-1;
  qSort(indexList);
  if(indexList.first()==0) {
    return; // Selected layers are already on bottom
  }
  int n=indexList.count();
  QList<GraphContentLayer *> layers;
  for(int i=0;i<n;i++) {
    layers << _graph->layer(indexList.at(i));
  }
  for(int i=0;i<n;i++) {
    _graph->moveLayerDown(layers.at(i));
  }
  reset();
}
void SciFigs::LayerPropertiesItem::moveLayersUp ( QModelIndexList  l)

References index(), SciFigs::GraphContent::layerCount(), SciFigs::GraphContent::moveLayerUp(), and TRACE.

{
  TRACE;
  QList<int> indexList;
  QModelIndex index;
  foreach(index, l) indexList << _graph->layerCount()-index.row()-1;
  qSort(indexList);
  if(indexList.last()==_graph->layerCount()-1) {
    return; // Selected layers are already on top
  }
  int n=indexList.count();
  QList<GraphContentLayer *> layers;
  for(int i=n-1;i>=0;i--) {
    layers << _graph->layer(indexList.at(i));
  }
  for(int i=0;i<n;i++) {
    _graph->moveLayerUp(layers.at(i));
  }
  reset();
}
virtual QModelIndex SciFigs::LayerPropertiesItem::parent ( const QModelIndex &  ) const [inline, virtual]
{return QModelIndex();}
int SciFigs::LayerPropertiesItem::removeLayers ( QModelIndexList  l)

References index(), SciFigs::GraphContentLayer::isRemovable(), SciFigs::GraphContent::layerCount(), SciFigs::GraphContent::removeLayer(), and TRACE.

{
  TRACE;
  int nRemoved=0;
  QList<GraphContentLayer *> layers;
  // First convert index list to layer pointers
  QModelIndex index;
  foreach(index, l) {
    GraphContentLayer * layer=_graph->layer(_graph->layerCount()-index.row()-1);
    if(layer->isRemovable()) {
      layers.append(layer);
      nRemoved++;
    }
  }
  int n=layers.count();
  for(int i=0;i<n;i++) {
    const QModelIndex& index=l.at(i);
    beginRemoveRows(index.parent(), index.row(), index.row());
    _graph->removeLayer(layers.at(i));
    endRemoveRows();
  }
  return nRemoved;
}
int SciFigs::LayerPropertiesItem::rowCount ( const QModelIndex &  parent = QModelIndex()) const [virtual]

References SciFigs::GraphContent::layerCount(), and TRACE.

{
  TRACE;
  if( !parent.isValid() && _graph)
    return _graph->layerCount();
  return 0;
}

References SciFigs::GraphContent::layerCount(), SciFigs::GraphContentLayer::setSelected(), and TRACE.

{
  TRACE;
  for(int i=_graph->layerCount()-1;i>=0;i--) {
    _graph->layer(i)->setSelected(s);
  }
}
void SciFigs::LayerPropertiesItem::selectLayers ( QModelIndexList  l)

References index(), SciFigs::GraphContent::layerCount(), and TRACE.

{
  TRACE;
  QModelIndex index;
  foreach(index, l) _graph->layer(_graph->layerCount()-index.row()-1)->setSelected(true);
}
bool SciFigs::LayerPropertiesItem::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role = Qt::EditRole 
) [virtual]

References SciFigs::GraphContentLayer::deepUpdate(), SciFigs::GraphContent::layerCount(), SciFigs::GraphContentLayer::setOpacity(), and TRACE.

{
  TRACE;
  if( !index.isValid() ||
       index.row() >= _graph->layerCount() ||
       index.column() >=3) return false;
  GraphContentLayer * layer=_graph->layer(_graph->layerCount()-index.row()-1);
  switch (role) {
  case Qt::EditRole:
    switch(index.column()) {
    case 1:
      layer->setObjectName(value.toString());
      return true;
    case 2:
      layer->setOpacity(value.toDouble());
      layer->deepUpdate();
      return true;
    default: return false;
    }
  default:
    return false;
  }
}

References TRACE.

{
  TRACE;
  _graph=g;
  reset();
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines