projects
/
quassel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
modernize: Use nullptr
[quassel.git]
/
src
/
client
/
treemodel.cpp
diff --git
a/src/client/treemodel.cpp
b/src/client/treemodel.cpp
index
220c843
..
fa66ba6
100644
(file)
--- a/
src/client/treemodel.cpp
+++ b/
src/client/treemodel.cpp
@@
-1,5
+1,5
@@
/***************************************************************************
/***************************************************************************
- * Copyright (C) 2005-201
5
by the Quassel Project *
+ * Copyright (C) 2005-201
8
by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
@@
-41,7
+41,7
@@
private:
AbstractTreeItem::AbstractTreeItem(AbstractTreeItem *parent)
: QObject(parent),
_flags(Qt::ItemIsSelectable | Qt::ItemIsEnabled),
AbstractTreeItem::AbstractTreeItem(AbstractTreeItem *parent)
: QObject(parent),
_flags(Qt::ItemIsSelectable | Qt::ItemIsEnabled),
- _treeItemFlags(
0
)
+ _treeItemFlags(
nullptr
)
{
}
{
}
@@
-103,7
+103,7
@@
void AbstractTreeItem::removeAllChilds()
childIter = _childItems.begin();
while (childIter != _childItems.end()) {
child = *childIter;
childIter = _childItems.begin();
while (childIter != _childItems.end()) {
child = *childIter;
- child->setTreeItemFlags(
0
); // disable self deletion, as this would only fuck up consitency and the child gets deleted anyways
+ child->setTreeItemFlags(
nullptr
); // disable self deletion, as this would only fuck up consitency and the child gets deleted anyways
child->removeAllChilds();
++childIter;
}
child->removeAllChilds();
++childIter;
}
@@
-182,7
+182,7
@@
bool AbstractTreeItem::reParent(AbstractTreeItem *newParent)
AbstractTreeItem *AbstractTreeItem::child(int row) const
{
if (childCount() <= row)
AbstractTreeItem *AbstractTreeItem::child(int row) const
{
if (childCount() <= row)
- return
0
;
+ return
nullptr
;
else
return _childItems[row];
}
else
return _childItems[row];
}
@@
-275,21
+275,8
@@
int SimpleTreeItem::columnCount() const
/*****************************************
* PropertyMapItem
*****************************************/
/*****************************************
* PropertyMapItem
*****************************************/
-PropertyMapItem::PropertyMapItem(const QStringList &propertyOrder, AbstractTreeItem *parent)
- : AbstractTreeItem(parent),
- _propertyOrder(propertyOrder)
-{
-}
-
-
PropertyMapItem::PropertyMapItem(AbstractTreeItem *parent)
PropertyMapItem::PropertyMapItem(AbstractTreeItem *parent)
- : AbstractTreeItem(parent),
- _propertyOrder(QStringList())
-{
-}
-
-
-PropertyMapItem::~PropertyMapItem()
+ : AbstractTreeItem(parent)
{
}
{
}
@@
-304,7
+291,7
@@
QVariant PropertyMapItem::data(int column, int role) const
return toolTip(column);
case Qt::DisplayRole:
case TreeModel::SortRole: // fallthrough, since SortRole should default to DisplayRole
return toolTip(column);
case Qt::DisplayRole:
case TreeModel::SortRole: // fallthrough, since SortRole should default to DisplayRole
- return property(
_propertyOrder
[column].toLatin1());
+ return property(
propertyOrder()
[column].toLatin1());
default:
return QVariant();
}
default:
return QVariant();
}
@@
-316,20
+303,15
@@
bool PropertyMapItem::setData(int column, const QVariant &value, int role)
if (column >= columnCount() || role != Qt::DisplayRole)
return false;
if (column >= columnCount() || role != Qt::DisplayRole)
return false;
+ setProperty(propertyOrder()[column].toLatin1(), value);
emit dataChanged(column);
emit dataChanged(column);
- return
setProperty(_propertyOrder[column].toLatin1(), value)
;
+ return
true
;
}
int PropertyMapItem::columnCount() const
{
}
int PropertyMapItem::columnCount() const
{
- return _propertyOrder.count();
-}
-
-
-void PropertyMapItem::appendProperty(const QString &property)
-{
- _propertyOrder << property;
+ return propertyOrder().count();
}
}
@@
-341,7
+323,7
@@
TreeModel::TreeModel(const QList<QVariant> &data, QObject *parent)
_childStatus(QModelIndex(), 0, 0, 0),
_aboutToRemoveOrInsert(false)
{
_childStatus(QModelIndex(), 0, 0, 0),
_aboutToRemoveOrInsert(false)
{
- rootItem = new SimpleTreeItem(data,
0
);
+ rootItem = new SimpleTreeItem(data,
nullptr
);
connectItem(rootItem);
if (Quassel::isOptionSet("debugmodel")) {
connectItem(rootItem);
if (Quassel::isOptionSet("debugmodel")) {
@@
-365,6
+347,12
@@
TreeModel::~TreeModel()
}
}
+AbstractTreeItem *TreeModel::root() const
+{
+ return rootItem;
+}
+
+
QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent) const
{
if (row < 0 || row >= rowCount(parent) || column < 0 || column >= columnCount(parent))
QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent) const
{
if (row < 0 || row >= rowCount(parent) || column < 0 || column >= columnCount(parent))
@@
-388,7
+376,7
@@
QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent) con
QModelIndex TreeModel::indexByItem(AbstractTreeItem *item) const
{
QModelIndex TreeModel::indexByItem(AbstractTreeItem *item) const
{
- if (item ==
0
) {
+ if (item ==
nullptr
) {
qWarning() << "TreeModel::indexByItem(AbstractTreeItem *item) received NULL-Pointer";
return QModelIndex();
}
qWarning() << "TreeModel::indexByItem(AbstractTreeItem *item) received NULL-Pointer";
return QModelIndex();
}
@@
-576,7
+564,7
@@
void TreeModel::beginRemoveChilds(int firstRow, int lastRow)
}
for (int i = firstRow; i <= lastRow; i++) {
}
for (int i = firstRow; i <= lastRow; i++) {
- disconnect(parentItem->child(i),
0, this, 0
);
+ disconnect(parentItem->child(i),
nullptr, this, nullptr
);
}
// consitency checks
}
// consitency checks