From 5f1935561fd785d07951937c4e087125c3199a59 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sat, 9 Sep 2023 22:10:13 +0300 Subject: [PATCH] plasma: remove unused dirmodel import Signed-off-by: Ivailo Monev --- plasma/declarativeimports/CMakeLists.txt | 1 - .../dirmodel/CMakeLists.txt | 18 -- .../declarativeimports/dirmodel/dirmodel.cpp | 177 ------------------ plasma/declarativeimports/dirmodel/dirmodel.h | 85 --------- .../dirmodel/dirmodelplugin.cpp | 33 ---- .../dirmodel/dirmodelplugin.h | 36 ---- plasma/declarativeimports/dirmodel/qmldir | 2 - 7 files changed, 352 deletions(-) delete mode 100644 plasma/declarativeimports/dirmodel/CMakeLists.txt delete mode 100644 plasma/declarativeimports/dirmodel/dirmodel.cpp delete mode 100644 plasma/declarativeimports/dirmodel/dirmodel.h delete mode 100644 plasma/declarativeimports/dirmodel/dirmodelplugin.cpp delete mode 100644 plasma/declarativeimports/dirmodel/dirmodelplugin.h delete mode 100644 plasma/declarativeimports/dirmodel/qmldir diff --git a/plasma/declarativeimports/CMakeLists.txt b/plasma/declarativeimports/CMakeLists.txt index e4d767b5..71dc2820 100644 --- a/plasma/declarativeimports/CMakeLists.txt +++ b/plasma/declarativeimports/CMakeLists.txt @@ -1,5 +1,4 @@ add_subdirectory(core) -add_subdirectory(dirmodel) add_subdirectory(draganddrop) add_subdirectory(graphicslayouts) add_subdirectory(graphicswidgets) diff --git a/plasma/declarativeimports/dirmodel/CMakeLists.txt b/plasma/declarativeimports/dirmodel/CMakeLists.txt deleted file mode 100644 index 5d4a439d..00000000 --- a/plasma/declarativeimports/dirmodel/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -project(dirmodel) - -set(dirmodel_SRCS - dirmodel.cpp - dirmodelplugin.cpp -) - -add_library(dirmodelplugin SHARED ${dirmodel_SRCS}) -target_link_libraries(dirmodelplugin - ${QT_QTCORE_LIBRARY} - ${QT_QTDECLARATIVE_LIBRARY} - KDE4::kio -) - -install(TARGETS dirmodelplugin DESTINATION ${KDE4_IMPORTS_INSTALL_DIR}/org/kde/dirmodel) -install(FILES qmldir DESTINATION ${KDE4_IMPORTS_INSTALL_DIR}/org/kde/dirmodel) - -#add_subdirectory(test) diff --git a/plasma/declarativeimports/dirmodel/dirmodel.cpp b/plasma/declarativeimports/dirmodel/dirmodel.cpp deleted file mode 100644 index a56d5112..00000000 --- a/plasma/declarativeimports/dirmodel/dirmodel.cpp +++ /dev/null @@ -1,177 +0,0 @@ -/* - Copyright (C) 20111 Marco Martin - - 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. - -*/ - -#include "dirmodel.h" - -#include -#include -#include -#include - -DirModel::DirModel(QObject *parent) - : KDirModel(parent), - m_screenshotSize(180, 120) -{ - //TODO: configurable mime filter - //dirLister()->setMimeFilter(m_mimeTypes); - - QHashroleNames; - roleNames[Qt::DisplayRole] = "display"; - roleNames[Qt::DecorationRole] = "decoration"; - roleNames[UrlRole] = "url"; - roleNames[MimeTypeRole] = "mimeType"; - roleNames[Thumbnail] = "thumbnail"; - setRoleNames(roleNames); - - m_previewTimer = new QTimer(this); - m_previewTimer->setSingleShot(true); - connect(m_previewTimer, SIGNAL(timeout()), - this, SLOT(delayedPreview())); - - connect(this, SIGNAL(rowsInserted(QModelIndex,int,int)), - this, SIGNAL(countChanged())); - connect(this, SIGNAL(rowsRemoved(QModelIndex,int,int)), - this, SIGNAL(countChanged())); - connect(this, SIGNAL(modelReset()), - this, SIGNAL(countChanged())); -} - -DirModel::~DirModel() -{ -} - -QString DirModel::url() const -{ - return dirLister()->url().prettyUrl(); -} - -void DirModel::setUrl(const QString& url) -{ - if (url.isEmpty()) { - return; - } - if (dirLister()->url().path() == url) { - dirLister()->updateDirectory(); - return; - } - - beginResetModel(); - dirLister()->openUrl(url); - endResetModel(); - emit urlChanged(); -} - -int DirModel::indexForUrl(const QString &url) const -{ - QModelIndex index = KDirModel::indexForUrl(KUrl(url)); - return index.row(); -} - -QVariantMap DirModel::get(int i) const -{ - QModelIndex modelIndex = index(i, 0); - - KFileItem item = itemForIndex(modelIndex); - QString url = item.url().prettyUrl(); - QString mimeType = item.mimetype(); - - QVariantMap ret; - ret.insert("url", QVariant(url)); - ret.insert("mimeType", QVariant(mimeType)); - - return ret; -} - -QVariant DirModel::data(const QModelIndex &index, int role) const -{ - if (!index.isValid()) { - return QVariant(); - } - - switch (role) { - case UrlRole: { - KFileItem item = itemForIndex(index); - return item.url().prettyUrl(); - } - case MimeTypeRole: { - KFileItem item = itemForIndex(index); - return item.mimetype(); - } - case Thumbnail: { - KFileItem item = itemForIndex(index); - - m_previewTimer->start(100); - const_cast(this)->m_filesToPreview[item.url()] = QPersistentModelIndex(index); - } - default: - return KDirModel::data(index, role); - } -} - -void DirModel::delayedPreview() -{ - QHash::const_iterator i = m_filesToPreview.constBegin(); - - KFileItemList list; - - while (i != m_filesToPreview.constEnd()) { - KUrl file = i.key(); - QPersistentModelIndex index = i.value(); - - - if (!m_previewJobs.contains(file) && file.isValid()) { - list.append(KFileItem(file, QString(), 0)); - m_previewJobs.insert(file, QPersistentModelIndex(index)); - } - - ++i; - } - - if (list.size() > 0) { - KIO::PreviewJob* job = KIO::filePreview(list, m_screenshotSize); - job->setIgnoreMaximumSize(true); - kDebug() << "Created job" << job; - connect(job, SIGNAL(gotPreview(KFileItem,QPixmap)), - this, SLOT(showPreview(KFileItem,QPixmap))); - connect(job, SIGNAL(failed(KFileItem)), - this, SLOT(previewFailed(KFileItem))); - } - - m_filesToPreview.clear(); -} - -void DirModel::showPreview(const KFileItem &item, const QPixmap &preview) -{ - QPersistentModelIndex index = m_previewJobs.value(item.url()); - m_previewJobs.remove(item.url()); - - if (!index.isValid()) { - return; - } - - //kDebug() << "preview size:" << preview.size(); - emit dataChanged(index, index); -} - -void DirModel::previewFailed(const KFileItem &item) -{ - m_previewJobs.remove(item.url()); -} - -#include "moc_dirmodel.cpp" diff --git a/plasma/declarativeimports/dirmodel/dirmodel.h b/plasma/declarativeimports/dirmodel/dirmodel.h deleted file mode 100644 index 3ccb833d..00000000 --- a/plasma/declarativeimports/dirmodel/dirmodel.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - Copyright (C) 20111 Marco Martin - - 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. - -*/ - -#ifndef DIRMODEL_H -#define DIRMODEL_H - -#include -#include - -#include - -/** - * This class provides a QML binding to KDirModel - * Provides an easy way to navigate a filesystem from within QML - * - * @author Marco Martin - */ -class DirModel : public KDirModel -{ - Q_OBJECT - - /** - * @property string The url we want to browse. it may be an absolute path or a correct url of any protocol KIO supports - */ - Q_PROPERTY(QString url READ url WRITE setUrl NOTIFY urlChanged) - - /** - * @property count Total number of rows - */ - Q_PROPERTY(int count READ count NOTIFY countChanged) - -public: - enum Roles { - UrlRole = Qt::UserRole + 1, - MimeTypeRole = Qt::UserRole + 2, - Thumbnail = Qt::UserRole + 3 - }; - - DirModel(QObject* parent=0); - virtual ~DirModel(); - - void setUrl(const QString& url); - QString url() const; - - QVariant data(const QModelIndex &index, int role) const; - int count() const {return rowCount();} - - Q_INVOKABLE int indexForUrl(const QString &url) const; - - Q_INVOKABLE QVariantMap get(int index) const; - -protected Q_SLOTS: - void showPreview(const KFileItem &item, const QPixmap &preview); - void previewFailed(const KFileItem &item); - void delayedPreview(); - -Q_SIGNALS: - void countChanged(); - void urlChanged(); - -private: - //previews - QTimer *m_previewTimer; - QHash m_filesToPreview; - QSize m_screenshotSize; - QHash m_previewJobs; -}; - -#endif // DIRMODEL_H diff --git a/plasma/declarativeimports/dirmodel/dirmodelplugin.cpp b/plasma/declarativeimports/dirmodel/dirmodelplugin.cpp deleted file mode 100644 index 6d216185..00000000 --- a/plasma/declarativeimports/dirmodel/dirmodelplugin.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2012 by Marco Martin - - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2, 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 Library General Public License for more details - * - * You should have received a copy of the GNU Library 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. - */ - -#include "dirmodelplugin.h" - -#include - -#include "dirmodel.h" - -void DirModelPlugin::registerTypes(const char *uri) -{ - Q_ASSERT(uri == QLatin1String("org.kde.dirmodel")); - qmlRegisterType(uri, 0, 1, "DirModel"); -} - -#include "moc_dirmodelplugin.cpp" - diff --git a/plasma/declarativeimports/dirmodel/dirmodelplugin.h b/plasma/declarativeimports/dirmodel/dirmodelplugin.h deleted file mode 100644 index 8d069914..00000000 --- a/plasma/declarativeimports/dirmodel/dirmodelplugin.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2012 by Marco Martin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2, 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 Library General Public License for more details - * - * You should have received a copy of the GNU Library 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. - */ - -#ifndef DIRMODELPLUGIN_H -#define DIRMODELPLUGIN_H - -#include - - -class DirModelPlugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT - -public: - void registerTypes(const char *uri); -}; - -Q_EXPORT_PLUGIN(DirModelPlugin) - -#endif diff --git a/plasma/declarativeimports/dirmodel/qmldir b/plasma/declarativeimports/dirmodel/qmldir deleted file mode 100644 index 2f26e171..00000000 --- a/plasma/declarativeimports/dirmodel/qmldir +++ /dev/null @@ -1,2 +0,0 @@ -plugin dirmodelplugin -