#include <QDebug>
FlatProxyModel::FlatProxyModel(QObject *parent)
- : QAbstractProxyModel(parent),
- _rootSourceItem(nullptr)
+ : QAbstractProxyModel(parent)
{
}
QModelIndex FlatProxyModel::mapFromSource(const QModelIndex &sourceIndex) const
{
if (!sourceIndex.isValid())
- return QModelIndex();
+ return {};
SourceItem *sourceItem = sourceToInternal(sourceIndex);
Q_ASSERT(sourceItem);
QModelIndex FlatProxyModel::mapToSource(const QModelIndex &proxyIndex) const
{
if (!proxyIndex.isValid())
- return QModelIndex();
+ return {};
Q_ASSERT(proxyIndex.model() == this);
Q_ASSERT(_rootSourceItem);
qWarning() << "FlatProxyModel::mapToSource(): couldn't find source index for" << proxyIndex;
Q_ASSERT(false);
- return QModelIndex(); // make compilers happy :)
+ return {}; // make compilers happy :)
}
SourceItem *topLeftItem = nullptr;
SourceItem *bottomRightItem = nullptr;
- SourceItem *currentItem = static_cast<SourceItem *>(range.topLeft().internalPointer());
+ auto *currentItem = static_cast<SourceItem *>(range.topLeft().internalPointer());
int row = range.topLeft().row();
int left = range.topLeft().column();
int right = range.bottomRight().column();
{
if (parent.isValid()) {
qWarning() << "FlatProxyModel::index() called with valid parent:" << parent;
- return QModelIndex();
+ return {};
}
if (!_rootSourceItem) {
qWarning() << "FlatProxyModel::index() while model has no root Item";
- return QModelIndex();
+ return {};
}
SourceItem *item = _rootSourceItem;
item = item->findChild(row);
if (!item) {
qWarning() << "FlatProxyModel::index() no such row:" << row;
- return QModelIndex();
+ return {};
}
}
{
Q_UNUSED(index)
// this is a flat model
- return QModelIndex();
+ return {};
}
// SourceItem
// ========================================
FlatProxyModel::SourceItem::SourceItem(int row, SourceItem *parent)
- : _parent(parent),
- _pos(-1),
- _next(nullptr)
+ : _parent(parent)
{
if (parent) {
parent->_childs.insert(row, this);