Revert "rework xqitem::setData, part I"
This reverts commit 20b9ba967d
.
This commit is contained in:
@@ -37,18 +37,18 @@ XQItem::XQItemFlagMap XQItem::s_ItemFlagMap
|
|||||||
|
|
||||||
XQItem::XQItemDataRoleMap XQItem::s_ItemDataRoleMap
|
XQItem::XQItemDataRoleMap XQItem::s_ItemDataRoleMap
|
||||||
{
|
{
|
||||||
{"ItemTypeRole", ItemTypeRole},
|
{"ItemType", ItemTypeRole},
|
||||||
{"ContentRole", ContentRole},
|
{"Content", ContentRole},
|
||||||
{"RenderStyleRole", RenderStyleRole},
|
{"RenderStyle", RenderStyleRole},
|
||||||
{"EditorTypeRole", EditorTypeRole},
|
{"EditorType", EditorTypeRole},
|
||||||
{"ItemFlagsRole", FlagsRole},
|
{"ItemFlags", FlagsRole},
|
||||||
{"UnitTypeRole", UnitTypeRole},
|
{"UnitType", UnitTypeRole},
|
||||||
{"ContentFormatRole", ContentFormatRole},
|
{"ContentFormat", ContentFormatRole},
|
||||||
{"FlagsRoleRole", FlagsRole},
|
{"FlagsRole", FlagsRole},
|
||||||
{"IconRole", IconRole},
|
{"Icon", IconRole},
|
||||||
{"FixedChoicesRole", FixedChoicesRole},
|
{"FixedChoices", FixedChoicesRole},
|
||||||
{"DataNodeRole", ContentNodeRole},
|
{"DataNode", ContentNodeRole},
|
||||||
{"SheetNodeRole", SheetNodeRole}
|
{"SheetNode", SheetNodeRole}
|
||||||
};
|
};
|
||||||
|
|
||||||
// No bi-map needed here, qmap.key() is sufficient for the job
|
// No bi-map needed here, qmap.key() is sufficient for the job
|
||||||
@@ -388,12 +388,7 @@ bool XQItem::isHeaderStyle()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString XQItem::dataRoleName(int role)
|
|
||||||
{
|
|
||||||
if( role < XQItem::NoRole && model() )
|
|
||||||
return model()->roleNames()[role];
|
|
||||||
return XQItem::fetchItemDataRoleName(role);
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant XQItem::data(int role ) const
|
QVariant XQItem::data(int role ) const
|
||||||
{
|
{
|
||||||
@@ -475,8 +470,7 @@ QVariant XQItem::data(int role ) const
|
|||||||
|
|
||||||
void XQItem::setData(const QVariant& value, int role )
|
void XQItem::setData(const QVariant& value, int role )
|
||||||
{
|
{
|
||||||
|
//replaceAttribute( XQItem* item, XQItem::ItemDataRole role, const QVariant& newValue)
|
||||||
//qDebug() << " -- item set data: " << value.toString() << " for: " << role << ": " << dataRoleName(role);
|
|
||||||
|
|
||||||
//emitDataChanged()
|
//emitDataChanged()
|
||||||
switch(role)
|
switch(role)
|
||||||
@@ -495,34 +489,19 @@ void XQItem::setData(const QVariant& value, int role )
|
|||||||
itemType().replaceAttribute( this, value, role );
|
itemType().replaceAttribute( this, value, role );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ContentNodeRole:
|
||||||
|
case SheetNodeRole:
|
||||||
|
|
||||||
|
case TypeKeyRole:
|
||||||
case Qt::DisplayRole :
|
case Qt::DisplayRole :
|
||||||
case Qt::EditRole :
|
case Qt::EditRole :
|
||||||
// return the raw, unformatted data
|
// return the raw, unformatted data
|
||||||
case ContentRole:
|
case ContentRole:
|
||||||
{
|
|
||||||
//qDebug() << " -- item set data xxx: " << value.toString() << " for: " << role;
|
|
||||||
break;
|
|
||||||
|
|
||||||
QString* contentPtr = QStandardItem::data( XQItem::ContentRole ).value<QString*>();
|
|
||||||
if(contentPtr)
|
|
||||||
{
|
|
||||||
|
|
||||||
contentPtr->operator=( value.toString() );
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// what to do here?
|
|
||||||
case ContentNodeRole:
|
|
||||||
case SheetNodeRole:
|
|
||||||
case TypeKeyRole:
|
|
||||||
default:
|
default:
|
||||||
break;
|
QStandardItem::setData( value,role);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QStandardItem::setData( value,role);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -555,8 +534,6 @@ int XQItem::fetchItemDataRole( const QString& dataRoleKey )
|
|||||||
|
|
||||||
QString XQItem::fetchItemDataRoleName( int dataRole )
|
QString XQItem::fetchItemDataRoleName( int dataRole )
|
||||||
{
|
{
|
||||||
//if( dataRole < XQItem::NoRole)
|
|
||||||
// return this->model()->
|
|
||||||
return s_ItemDataRoleMap.key(dataRole);
|
return s_ItemDataRoleMap.key(dataRole);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -225,7 +225,6 @@ public:
|
|||||||
bool isHeaderStyle();
|
bool isHeaderStyle();
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
QString dataRoleName(int role);
|
|
||||||
QVariant data(int role = Qt::DisplayRole ) const override;
|
QVariant data(int role = Qt::DisplayRole ) const override;
|
||||||
void setData(const QVariant &value, int role ) override;
|
void setData(const QVariant &value, int role ) override;
|
||||||
|
|
||||||
|
@@ -40,7 +40,6 @@ public:
|
|||||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||||
QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||||
|
|
||||||
void setEditorData(QWidget *editor, const QModelIndex &index) const override;
|
void setEditorData(QWidget *editor, const QModelIndex &index) const override;
|
||||||
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
|
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
|
||||||
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||||
|
@@ -105,7 +105,6 @@ void XQCommand::saveNodes( const QModelIndexList& list )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! erzeugt einen string aus dem command-type, fürs debuggen.
|
//! erzeugt einen string aus dem command-type, fürs debuggen.
|
||||||
|
|
||||||
QString XQCommand::toString()
|
QString XQCommand::toString()
|
||||||
|
@@ -27,9 +27,6 @@ struct XQNodeBackup
|
|||||||
XQNodePtr contentNode;
|
XQNodePtr contentNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
//!
|
|
||||||
//! \brief The XQNodeStore class
|
|
||||||
//!
|
|
||||||
class XQNodeStore : public QVector<XQNodeBackup>
|
class XQNodeStore : public QVector<XQNodeBackup>
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -40,9 +37,8 @@ public:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Das command enthält immer auch die betroffenen items
|
// Das command enthält immer auch die betroffenen items
|
||||||
//! ist also auch ein node store
|
// ist also auch eine SavedNodeList
|
||||||
|
|
||||||
class XQCommand : public QUndoCommand, public XQNodeStore
|
class XQCommand : public QUndoCommand, public XQNodeStore
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user