X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/afca8efa2601d9566c8d34d7b67dfb5abc729956..e57f6215659ee36877c7c36c9e3fcba0ba5d03a0:/src/kitemviews/kitemmodelbase.cpp diff --git a/src/kitemviews/kitemmodelbase.cpp b/src/kitemviews/kitemmodelbase.cpp index 69f62bcb0..9fdecafb8 100644 --- a/src/kitemviews/kitemmodelbase.cpp +++ b/src/kitemviews/kitemmodelbase.cpp @@ -1,129 +1,175 @@ -/*************************************************************************** - * Copyright (C) 2011 by Peter Penz * - * * - * 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 + * + * 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) { } -bool KItemRange::operator == (const KItemRange& other) const +KItemModelBase::KItemModelBase(const QByteArray &sortRole, QObject *parent) + : QObject(parent) + , m_groupedSorting(false) + , m_sortRole(sortRole) + , m_sortOrder(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 &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 &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) { - const QByteArray previous = m_groupRole; - m_groupRole = role; - onGroupRoleChanged(role, previous); - emit groupRoleChanged(role, previous); + if (order != m_sortOrder) { + const Qt::SortOrder previous = m_sortOrder; + m_sortOrder = order; + onSortOrderChanged(order, previous); + Q_EMIT sortOrderChanged(order, previous); } } -QByteArray KItemModelBase::groupRole() const +QString KItemModelBase::roleDescription(const QByteArray &role) const { - return m_groupRole; + return QString::fromLatin1(role); } -bool KItemModelBase::supportsSorting() const +QList> KItemModelBase::groups() const { - return false; + return QList>(); } -void KItemModelBase::setSortRole(const QByteArray& role) +bool KItemModelBase::setExpanded(int index, bool expanded) { - if (supportsSorting() && role != m_sortRole) { - const QByteArray previous = m_sortRole; - m_sortRole = role; - onSortRoleChanged(role, previous); - emit sortRoleChanged(role, previous); - } + Q_UNUSED(index) + Q_UNUSED(expanded) + return false; } -QByteArray KItemModelBase::sortRole() const +bool KItemModelBase::isExpanded(int index) const { - return m_sortRole; + 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& 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(indexes) + return nullptr; +} + +int KItemModelBase::indexForKeyboardSearch(const QString &text, int startFromIndex) const +{ + Q_UNUSED(text) + Q_UNUSED(startFromIndex) return -1; } -void KItemModelBase::onGroupRoleChanged(const QByteArray& current, const QByteArray& previous) +bool KItemModelBase::supportsDropping(int index) const +{ + Q_UNUSED(index) + return false; +} + +bool KItemModelBase::canEnterOnHover(int index) const +{ + Q_UNUSED(index) + return false; +} + +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) +} + +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"