-/***************************************************************************
- * Copyright (C) 2011 by Peter Penz <peter.penz19@gmail.com> *
- * *
- * Based on the Itemviews NG project from Trolltech Labs: *
- * http://qt.gitorious.org/qt-labs/itemviews-ng *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
- ***************************************************************************/
+/*
+ * SPDX-FileCopyrightText: 2011 Peter Penz <peter.penz19@gmail.com>
+ *
+ * Based on the Itemviews NG project from Trolltech Labs
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
#include "kitemmodelbase.h"
-KItemRange::KItemRange(int index, int count) :
- index(index),
- count(count)
+KItemModelBase::KItemModelBase(QObject *parent)
+ : QObject(parent)
+ , m_groupedSorting(false)
+ , m_sortRole()
+ , m_sortOrder(Qt::AscendingOrder)
+ , m_groupRole()
+ , m_groupOrder(Qt::AscendingOrder)
{
}
-bool KItemRange::operator == (const KItemRange& other) const
+KItemModelBase::KItemModelBase(const QByteArray &sortRole, const QByteArray &groupRole, QObject *parent)
+ : QObject(parent)
+ , m_groupedSorting(false)
+ , m_sortRole(sortRole)
+ , m_sortOrder(Qt::AscendingOrder)
+ , m_groupRole(groupRole)
+ , m_groupOrder(Qt::AscendingOrder)
{
- return index == other.index && count == other.count;
}
-KItemModelBase::KItemModelBase(QObject* parent) :
- QObject(parent),
- m_groupRole(),
- m_sortRole()
+KItemModelBase::~KItemModelBase()
{
}
-KItemModelBase::KItemModelBase(const QByteArray& groupRole, const QByteArray& sortRole, QObject* parent) :
- QObject(parent),
- m_groupRole(groupRole),
- m_sortRole(sortRole)
+bool KItemModelBase::setData(int index, const QHash<QByteArray, QVariant> &values)
{
+ Q_UNUSED(index)
+ Q_UNUSED(values)
+ return false;
}
-KItemModelBase::~KItemModelBase()
+void KItemModelBase::setGroupedSorting(bool grouped)
{
+ if (m_groupedSorting != grouped) {
+ m_groupedSorting = grouped;
+ onGroupedSortingChanged(grouped);
+ Q_EMIT groupedSortingChanged(grouped);
+ }
}
-bool KItemModelBase::setData(int index, const QHash<QByteArray, QVariant> &values)
+bool KItemModelBase::groupedSorting() const
{
- Q_UNUSED(index);
- Q_UNUSED(values);
- return false;
+ return m_groupedSorting;
}
-bool KItemModelBase::supportsGrouping() const
+void KItemModelBase::setSortRole(const QByteArray &role, bool resortItems)
{
- return false;
+ if (role != m_sortRole) {
+ const QByteArray previous = m_sortRole;
+ m_sortRole = role;
+ onSortRoleChanged(role, previous, resortItems);
+ Q_EMIT sortRoleChanged(role, previous);
+ }
+}
+
+QByteArray KItemModelBase::sortRole() const
+{
+ return m_sortRole;
}
-void KItemModelBase::setGroupRole(const QByteArray& role)
+void KItemModelBase::setSortOrder(Qt::SortOrder order)
{
- if (supportsGrouping() && role != m_groupRole) {
+ if (order != m_sortOrder) {
+ const Qt::SortOrder previous = m_sortOrder;
+ m_sortOrder = order;
+ onSortOrderChanged(order, previous);
+ Q_EMIT sortOrderChanged(order, previous);
+ }
+}
+
+void KItemModelBase::setGroupRole(const QByteArray &role, bool regroupItems)
+{
+ if (role != m_groupRole) {
const QByteArray previous = m_groupRole;
m_groupRole = role;
- onGroupRoleChanged(role, previous);
- emit groupRoleChanged(role, previous);
+ onGroupRoleChanged(role, previous, regroupItems);
+ Q_EMIT groupRoleChanged(role, previous);
}
}
return m_groupRole;
}
-bool KItemModelBase::supportsSorting() const
+void KItemModelBase::setGroupOrder(Qt::SortOrder order)
{
- return false;
+ if (order != m_groupOrder) {
+ const Qt::SortOrder previous = m_groupOrder;
+ m_groupOrder = order;
+ onGroupOrderChanged(order, previous);
+ Q_EMIT groupOrderChanged(order, previous);
+ }
}
-void KItemModelBase::setSortRole(const QByteArray& role)
+QString KItemModelBase::roleDescription(const QByteArray &role) const
{
- if (supportsSorting() && role != m_sortRole) {
- const QByteArray previous = m_sortRole;
- m_sortRole = role;
- onSortRoleChanged(role, previous);
- emit sortRoleChanged(role, previous);
- }
+ return QString::fromLatin1(role);
}
-QByteArray KItemModelBase::sortRole() const
+QList<QPair<int, QVariant>> KItemModelBase::groups() const
{
- return m_sortRole;
+ return QList<QPair<int, QVariant>>();
+}
+
+bool KItemModelBase::setExpanded(int index, bool expanded)
+{
+ Q_UNUSED(index)
+ Q_UNUSED(expanded)
+ return false;
+}
+
+bool KItemModelBase::isExpanded(int index) const
+{
+ Q_UNUSED(index)
+ return false;
}
-QString KItemModelBase::roleDescription(const QByteArray& role) const
+bool KItemModelBase::isExpandable(int index) const
{
- return role;
+ Q_UNUSED(index)
+ return false;
}
-QMimeData* KItemModelBase::createMimeData(const QSet<int>& indexes) const
+int KItemModelBase::expandedParentsCount(int index) const
{
- Q_UNUSED(indexes);
+ Q_UNUSED(index)
return 0;
}
-int KItemModelBase::indexForKeyboardSearch(const QString& text, int startFromIndex) const
+QMimeData *KItemModelBase::createMimeData(const KItemSet &indexes) const
{
- Q_UNUSED(text);
- Q_UNUSED(startFromIndex);
+ Q_UNUSED(indexes)
+ return nullptr;
+}
+
+int KItemModelBase::indexForKeyboardSearch(const QString &text, int startFromIndex) const
+{
+ Q_UNUSED(text)
+ Q_UNUSED(startFromIndex)
return -1;
}
bool KItemModelBase::supportsDropping(int index) const
{
- Q_UNUSED(index);
+ Q_UNUSED(index)
+ return false;
+}
+
+bool KItemModelBase::canEnterOnHover(int index) const
+{
+ Q_UNUSED(index)
return false;
}
-void KItemModelBase::onGroupRoleChanged(const QByteArray& current, const QByteArray& previous)
+QString KItemModelBase::blacklistItemDropEventMimeType() const
+{
+ return QStringLiteral("application/x-dolphin-blacklist-drop");
+}
+
+void KItemModelBase::onGroupedSortingChanged(bool current)
+{
+ Q_UNUSED(current)
+}
+
+void KItemModelBase::onSortRoleChanged(const QByteArray ¤t, const QByteArray &previous, bool resortItems)
+{
+ Q_UNUSED(current)
+ Q_UNUSED(previous)
+ Q_UNUSED(resortItems)
+}
+
+void KItemModelBase::onSortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous)
+{
+ Q_UNUSED(current)
+ Q_UNUSED(previous)
+}
+
+void KItemModelBase::onGroupRoleChanged(const QByteArray ¤t, const QByteArray &previous, bool resortItems)
+{
+ Q_UNUSED(current)
+ Q_UNUSED(previous)
+ Q_UNUSED(resortItems)
+}
+
+void KItemModelBase::onGroupOrderChanged(Qt::SortOrder current, Qt::SortOrder previous)
+{
+ Q_UNUSED(current)
+ Q_UNUSED(previous)
+}
+
+QUrl KItemModelBase::url(int index) const
+{
+ return data(index).value("url").toUrl();
+}
+
+bool KItemModelBase::isDir(int index) const
{
- Q_UNUSED(current);
- Q_UNUSED(previous);
+ return data(index).value("isDir").toBool();
}
-void KItemModelBase::onSortRoleChanged(const QByteArray& current, const QByteArray& previous)
+QUrl KItemModelBase::directory() const
{
- Q_UNUSED(current);
- Q_UNUSED(previous);
+ return QUrl();
}
-#include "kitemmodelbase.moc"
+#include "moc_kitemmodelbase.cpp"