All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Signals | Public Member Functions
QGpGuiTools::XMLItem Class Reference

Brief description of class still missing. More...

#include <XMLItem.h>

List of all members.

Signals

void includeChanged (const QModelIndex &index)

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 &index) const
QList< XMLGenericItem * > getSelection (const QItemSelectionModel &sm)
virtual QVariant headerData (int section, Qt::Orientation orientation, int role) const
virtual QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const
QModelIndex index (XMLGenericItem *o)
virtual QModelIndex parent (const QModelIndex &index) const
XMLGenericItemrootItem ()
virtual int rowCount (const QModelIndex &parent=QModelIndex()) const
QByteArray saveByteArray ()
void saveFile (QString fileName)
QString saveString ()
virtual bool setData (const QModelIndex &index, const QVariant &value, int role)
void setText (QString xml)
 XMLItem (QObject *parent=0)
XMLGenericItemxmlItem (const QModelIndex &index) const
 ~XMLItem ()

Detailed Description

Brief description of class still missing.

Full description of class still missing


Constructor & Destructor Documentation

QGpGuiTools::XMLItem::XMLItem ( QObject *  parent = 0)

Description of constructor still missing

References TRACE.

    : QAbstractItemModel(parent)
{
  TRACE;
}
{}

Member Function Documentation

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

Currently return only 1 but may evolve in the future

References TRACE.

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

References QGpCoreTools::XMLGenericItem::isEnabled(), QGpCoreTools::XMLSaveAttributes::toString(), TRACE, QGpCoreTools::XMLGenericItem::value(), QGpCoreTools::XMLGenericItem::xml_attributes(), QGpCoreTools::XMLGenericItem::xml_tagName(), and xmlItem().

{
  TRACE;
  if (!index.isValid()) return QVariant();
  XMLGenericItem * o=xmlItem(index);
  switch (role) {
  case Qt::DisplayRole:
    switch(index.column()) {
    case 0:
      return o->xml_tagName();
    case 1:
      return o->value();
    default:
      break;
    }
    break;
  case Qt::EditRole:
    switch(index.column()) {
    case 1:
      return o->value();
    default:
      break;
    }
    break;
  case Qt::ToolTipRole: {
      XMLSaveAttributes attributes;
      o->xml_attributes(attributes, 0);
      return attributes.toString();
    }
  case Qt::CheckStateRole:
    if(index.column()==2) {
      return o->isEnabled() ? Qt::Checked : Qt::Unchecked;
    }
    break;
  default:
    break;
  }
  return QVariant();
}
Qt::ItemFlags QGpGuiTools::XMLItem::flags ( const QModelIndex &  index) const [virtual]

References QGpCoreTools::TreeContainer::childrenCount(), QGpCoreTools::XMLGenericItem::isParentEnabled(), and xmlItem().

{
  Qt::ItemFlags f=Qt::ItemIsSelectable;
  // Editable or not?
  XMLGenericItem * o=xmlItem(index);
  switch(index.column()) {
  case 1:
    if(o->childrenCount()==0) {
      f|=Qt::ItemIsEditable;
    }
    break;
  case 2:
    if(index.parent().isValid()) {
      f|=Qt::ItemIsUserCheckable;
    }
    break;
  default:
    break;
  }
  // Enabled or not
  // 20130904: fixed that item are disabled when not included.
  //           it was impossible to include them again
  if(o->isParentEnabled()) {
    f|=Qt::ItemIsEnabled;
  }
  return f;
}
QList< XMLGenericItem * > QGpGuiTools::XMLItem::getSelection ( const QItemSelectionModel &  sm)

References TRACE, QGpCoreTools::unique(), and xmlItem().

{
  TRACE;
  QModelIndexList l=sm.selectedIndexes();
  QList<XMLGenericItem *> sel;
  for(QModelIndexList::iterator it=l.begin(); it!=l.end(); it++) {
    sel.append(xmlItem(*it));
  }
  qSort(sel);
  unique(sel);
  return sel;
}
QVariant QGpGuiTools::XMLItem::headerData ( int  section,
Qt::Orientation  orientation,
int  role 
) const [virtual]

References QGpCoreTools::tr(), and TRACE.

{
  TRACE;
  if(role!=Qt::DisplayRole) return QVariant();
  if(orientation==Qt::Horizontal) {
    switch(section) {
    case 0:
      return tr("Property name");
    case 1:
      return tr("Value");
    case 2:
      return tr("Included?");
    default:
      break;
    }
  }
  return QVariant();
}
void QGpGuiTools::XMLItem::includeChanged ( const QModelIndex &  index) [signal]

Referenced by setData().

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

References QGpCoreTools::TreeContainer::containerAt(), TRACE, and xmlItem().

Referenced by QGpGuiTools::XMLEditor::setEnabled().

{
  TRACE;
  if( !parent.isValid()) return createIndex(row, column, (void *)&_rootItem);
  XMLGenericItem * o=xmlItem(parent);
  XMLGenericItem * oi=static_cast<XMLGenericItem *>(o->containerAt(row));
  if(oi)
    return createIndex(row, column, oi);
  else
    return QModelIndex();
}

References QGpCoreTools::XMLGenericItem::parent(), QGpCoreTools::TreeContainer::rank(), and TRACE.

{
  TRACE;
  if(o) {
    if(o->parent()) {
      return createIndex(o->parent()->rank(o) , 0, o);
    } else {
      return createIndex(0 , 0, o);
    }
  } else {
    return QModelIndex();
  }
}
QModelIndex QGpGuiTools::XMLItem::parent ( const QModelIndex &  index) const [virtual]

References QGpCoreTools::TreeContainer::containerIndex(), QGpCoreTools::XMLGenericItem::parent(), TRACE, and xmlItem().

{
  TRACE;
  if(!index.isValid()) return QModelIndex();
  XMLGenericItem * o=xmlItem(index);
  XMLGenericItem * parent=o->parent();
  if(parent) {
    return createIndex(parent->containerIndex(), 0, parent);
  } else
    return QModelIndex();
}
int QGpGuiTools::XMLItem::rowCount ( const QModelIndex &  parent = QModelIndex()) const [virtual]

References QGpCoreTools::TreeContainer::childrenCount(), TRACE, and xmlItem().

{
  TRACE;
  if(!parent.isValid()) return 1;
  const XMLGenericItem * oParent=xmlItem(parent);
  return oParent->childrenCount();
}

References TRACE, and QGpCoreTools::XMLHeader::xml_saveByteArray().

{
  TRACE;
  XMLHeader hdr(&_rootItem);
  return hdr.xml_saveByteArray();
}
void QGpGuiTools::XMLItem::saveFile ( QString  fileName)

References TRACE, and QGpCoreTools::XMLHeader::xml_saveFile().

{
  TRACE;
  XMLHeader hdr(&_rootItem);
  hdr.xml_saveFile(fileName);
}

References TRACE, and QGpCoreTools::XMLHeader::xml_saveString().

{
  TRACE;
  XMLHeader hdr(&_rootItem);
  return hdr.xml_saveString();
}
bool QGpGuiTools::XMLItem::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role 
) [virtual]

References includeChanged(), QGpCoreTools::XMLGenericItem::setEnabled(), QGpCoreTools::XMLGenericItem::setValue(), TRACE, and xmlItem().

{
  TRACE;
  if (!index.isValid()) return false;
  XMLGenericItem * o=xmlItem(index);
  switch (role) {
  case Qt::EditRole:
    if(index.column()==1) {
      o->setValue(value);
      return true;
    }
    break;
  case Qt::CheckStateRole:
    if(index.column()==2) {
      o->setEnabled(value==Qt::Checked);
      emit(includeChanged(index));
      return true;
    }
    break;
  default:
    break;
  }
  return false;
}
void QGpGuiTools::XMLItem::setText ( QString  xml)

References TRACE, and QGpCoreTools::XMLHeader::xml_restoreString().

{
  TRACE;
  XMLHeader hdr(&_rootItem);
  hdr.xml_restoreString(xml);
}
XMLGenericItem * QGpGuiTools::XMLItem::xmlItem ( const QModelIndex &  index) const

References TRACE.

Referenced by data(), flags(), getSelection(), index(), parent(), rowCount(), and setData().

{
  TRACE;
  return static_cast<XMLGenericItem *>(index.internalPointer());
}

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