Qt: Fix warning and remove dead code
Fix a "discard const qualifier" warning and remove code, which should be active in Qt5, but never made it to majurity Change-Id: I8d4dd526d07413ca30ab0b8430c6b8205e4e3063 Reviewed-on: https://code.wireshark.org/review/33896 Petri-Dish: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall <rknall@gmail.com>
This commit is contained in:
parent
a87ca4e017
commit
251b66da30
|
@ -69,10 +69,12 @@ public:
|
|||
return childItems_.count();
|
||||
}
|
||||
|
||||
int row() const
|
||||
int row()
|
||||
{
|
||||
if (parent_)
|
||||
return parent_->childItems_.indexOf(VariantPointer<Item>::asQVariant((Item*)this));
|
||||
{
|
||||
return parent_->childItems_.indexOf(VariantPointer<Item>::asQVariant((Item *)this));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -84,91 +86,6 @@ protected:
|
|||
QList<QVariant> childItems_;
|
||||
};
|
||||
|
||||
//XXX - Qt 4.8 doesn't work with these types of templated classes, so save the functionality for now.
|
||||
#ifdef WIRESHARK_SUPPORTS_QT_5_0_MINIMUM
|
||||
|
||||
//Base class to inherit basic model for tree
|
||||
template <typename Item>
|
||||
class ModelHelperTreeModel : public QAbstractItemModel
|
||||
{
|
||||
public:
|
||||
explicit ModelHelperTreeModel(QObject * parent = Q_NULLPTR) : QAbstractItemModel(parent),
|
||||
root_(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~ModelHelperTreeModel()
|
||||
{
|
||||
delete root_;
|
||||
}
|
||||
|
||||
virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const
|
||||
{
|
||||
if (!hasIndex(row, column, parent))
|
||||
return QModelIndex();
|
||||
|
||||
Item *parent_item, *child_item;
|
||||
|
||||
if (!parent.isValid())
|
||||
parent_item = root_;
|
||||
else
|
||||
parent_item = static_cast<Item*>(parent.internalPointer());
|
||||
|
||||
Q_ASSERT(parent_item);
|
||||
|
||||
child_item = parent_item->child(row);
|
||||
if (child_item) {
|
||||
return createIndex(row, column, child_item);
|
||||
}
|
||||
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
virtual QModelIndex parent(const QModelIndex& indexItem) const
|
||||
{
|
||||
if (!indexItem.isValid())
|
||||
return QModelIndex();
|
||||
|
||||
Item* item = static_cast<Item*>(indexItem.internalPointer());
|
||||
if (item != NULL) {
|
||||
Item* parent_item = item->parentItem();
|
||||
if (parent_item != NULL) {
|
||||
if (parent_item == root_)
|
||||
return QModelIndex();
|
||||
|
||||
return createIndex(parent_item->row(), 0, parent_item);
|
||||
}
|
||||
}
|
||||
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
virtual int rowCount(const QModelIndex& parent = QModelIndex()) const
|
||||
{
|
||||
Item *parent_item;
|
||||
|
||||
if (parent.column() > 0)
|
||||
return 0;
|
||||
|
||||
if (!parent.isValid())
|
||||
parent_item = root_;
|
||||
else
|
||||
parent_item = static_cast<Item*>(parent.internalPointer());
|
||||
|
||||
if (parent_item == NULL)
|
||||
return 0;
|
||||
|
||||
return parent_item->childCount();
|
||||
}
|
||||
|
||||
protected:
|
||||
Item* root_;
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif // TREE_MODEL_HELPERS_H
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue