Tedious Memory.xml rewrite, part 1

develop
Petr Mrázek 2010-08-11 12:56:06 +02:00
parent c8092afddc
commit ca7b2219da
2 changed files with 2104 additions and 9 deletions

File diff suppressed because it is too large Load Diff

@ -100,8 +100,9 @@ MemXMLModel::~MemXMLModel()
delete rootItem; delete rootItem;
} }
int MemXMLModel::columnCount(const QModelIndex &/*parent*/) const int MemXMLModel::columnCount(const QModelIndex & parent) const
{ {
Q_UNUSED(parent);
return 3; return 3;
} }
@ -123,10 +124,10 @@ QVariant MemXMLModel::data(const QModelIndex &index, int role) const
case 0: case 0:
return node.nodeName(); return node.nodeName();
case 1: case 1:
for (int i = 0; (unsigned int)(i) < attributeMap.count(); ++i) { for (int i = 0; (unsigned int)(i) < attributeMap.count(); ++i)
{
QDomNode attribute = attributeMap.item(i); QDomNode attribute = attributeMap.item(i);
attributes << attribute.nodeName() + "=\"" attributes << attribute.nodeName() + "=\"" +attribute.nodeValue() + "\"";
+attribute.nodeValue() + "\"";
} }
return attributes.join(" "); return attributes.join(" ");
case 2: case 2:
@ -139,13 +140,14 @@ QVariant MemXMLModel::data(const QModelIndex &index, int role) const
Qt::ItemFlags MemXMLModel::flags(const QModelIndex &index) const Qt::ItemFlags MemXMLModel::flags(const QModelIndex &index) const
{ {
if (!index.isValid()) if (!index.isValid())
{
return Qt::ItemIsEnabled; return Qt::ItemIsEnabled;
}
return Qt::ItemIsEnabled | Qt::ItemIsSelectable; return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
} }
QVariant MemXMLModel::headerData(int section, Qt::Orientation orientation, QVariant MemXMLModel::headerData(int section, Qt::Orientation orientation, int role) const
int role) const
{ {
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
switch (section) { switch (section) {
@ -163,8 +165,7 @@ QVariant MemXMLModel::headerData(int section, Qt::Orientation orientation,
return QVariant(); return QVariant();
} }
QModelIndex MemXMLModel::index(int row, int column, const QModelIndex &parent) QModelIndex MemXMLModel::index(int row, int column, const QModelIndex &parent) const
const
{ {
DomItem *parentItem; DomItem *parentItem;
@ -206,4 +207,4 @@ int MemXMLModel::rowCount(const QModelIndex &parent) const
return parentItem->node().childNodes().count(); return parentItem->node().childNodes().count();
} }
#include "memxmlModel.moc" #include "memxmlModel.moc"