diff options
Diffstat (limited to 'src/views')
| -rw-r--r-- | src/views/dolphindirlister.cpp | 48 | ||||
| -rw-r--r-- | src/views/dolphindirlister.h | 49 | ||||
| -rw-r--r-- | src/views/dolphinitemlistcontainer.cpp | 6 | ||||
| -rw-r--r-- | src/views/dolphinitemlistcontainer.h | 4 | ||||
| -rw-r--r-- | src/views/dolphinview.cpp | 105 | ||||
| -rw-r--r-- | src/views/dolphinview.h | 46 | ||||
| -rw-r--r-- | src/views/versioncontrol/versioncontrolobserver.cpp | 3 |
7 files changed, 85 insertions, 176 deletions
diff --git a/src/views/dolphindirlister.cpp b/src/views/dolphindirlister.cpp deleted file mode 100644 index b62abe167..000000000 --- a/src/views/dolphindirlister.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2010 by Peter Penz <[email protected]> * - * * - * 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 "dolphindirlister.h" -#include <KLocale> -#include <KIO/JobClasses> - -DolphinDirLister::DolphinDirLister(QObject* parent) : - KDirLister(parent) -{ - setAutoErrorHandlingEnabled(false, 0); -} - -DolphinDirLister::~DolphinDirLister() -{ -} - -void DolphinDirLister::handleError(KIO::Job* job) -{ - if (job->error() == KIO::ERR_IS_FILE) { - emit urlIsFileError(url()); - } else { - const QString errorString = job->errorString(); - if (errorString.isEmpty()) { - emit errorMessage(i18nc("@info:status", "Unknown error.")); - } else { - emit errorMessage(errorString); - } - } -} - -#include "dolphindirlister.moc" diff --git a/src/views/dolphindirlister.h b/src/views/dolphindirlister.h deleted file mode 100644 index 0955df232..000000000 --- a/src/views/dolphindirlister.h +++ /dev/null @@ -1,49 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2009 by Peter Penz <[email protected]> * - * * - * 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 DOLPHINDIRLISTER_H -#define DOLPHINDIRLISTER_H - -#include <libdolphin_export.h> -#include <KDirLister> - -/** - * @brief Extends the class KDirLister by emitting a signal when an - * error occurred instead of showing an error dialog. - */ -class LIBDOLPHINPRIVATE_EXPORT DolphinDirLister : public KDirLister -{ - Q_OBJECT - -public: - DolphinDirLister(QObject* parent = 0); - virtual ~DolphinDirLister(); - -signals: - /** Is emitted whenever an error has occurred. */ - void errorMessage(const QString& msg); - - /** Is emitted when the URL of the directory lister represents a file. */ - void urlIsFileError(const KUrl& url); - -protected: - virtual void handleError(KIO::Job* job); -}; - -#endif diff --git a/src/views/dolphinitemlistcontainer.cpp b/src/views/dolphinitemlistcontainer.cpp index 5b7522f00..e8c373492 100644 --- a/src/views/dolphinitemlistcontainer.cpp +++ b/src/views/dolphinitemlistcontainer.cpp @@ -31,7 +31,6 @@ #include <kitemviews/kitemlistcontroller.h> #include <kitemviews/kitemliststyleoption.h> -#include <KDirLister> #include <KGlobalSettings> #include <views/viewmodecontroller.h> @@ -39,13 +38,12 @@ #include "zoomlevelinfo.h" -DolphinItemListContainer::DolphinItemListContainer(KDirLister* dirLister, - QWidget* parent) : +DolphinItemListContainer::DolphinItemListContainer(QWidget* parent) : KItemListContainer(parent), m_zoomLevel(0), m_fileItemListView(0) { - controller()->setModel(new KFileItemModel(dirLister, this)); + controller()->setModel(new KFileItemModel(this)); m_fileItemListView = new KFileItemListView(); controller()->setView(m_fileItemListView); diff --git a/src/views/dolphinitemlistcontainer.h b/src/views/dolphinitemlistcontainer.h index c5a30ad74..f3505b663 100644 --- a/src/views/dolphinitemlistcontainer.h +++ b/src/views/dolphinitemlistcontainer.h @@ -26,7 +26,6 @@ #include <libdolphin_export.h> -class KDirLister; class KFileItemListView; /** @@ -44,8 +43,7 @@ class LIBDOLPHINPRIVATE_EXPORT DolphinItemListContainer : public KItemListContai Q_OBJECT public: - explicit DolphinItemListContainer(KDirLister* dirLister, - QWidget* parent = 0); + explicit DolphinItemListContainer(QWidget* parent = 0); virtual ~DolphinItemListContainer(); diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 2ffc33e08..137b73d09 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -35,7 +35,6 @@ #include <KActionCollection> #include <KColorScheme> -#include <KDirLister> #include <KDirModel> #include <KIconEffect> #include <KFileItem> @@ -59,7 +58,6 @@ #include <KToggleAction> #include <KUrl> -#include "dolphindirlister.h" #include "dolphinnewfilemenuobserver.h" #include "dolphin_detailsmodesettings.h" #include "dolphin_generalsettings.h" @@ -91,7 +89,6 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) : m_mode(DolphinView::IconsView), m_visibleRoles(), m_topLayout(0), - m_dirLister(0), m_container(0), m_toolTipManager(0), m_selectionChangedTimer(0), @@ -117,24 +114,7 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) : connect(m_selectionChangedTimer, SIGNAL(timeout()), this, SLOT(emitSelectionChangedSignal())); - m_dirLister = new DolphinDirLister(this); - m_dirLister->setAutoUpdate(true); - m_dirLister->setDelayedMimeTypes(true); - - connect(m_dirLister, SIGNAL(redirection(KUrl,KUrl)), this, SLOT(slotRedirection(KUrl,KUrl))); - connect(m_dirLister, SIGNAL(started(KUrl)), this, SLOT(slotDirListerStarted(KUrl))); - connect(m_dirLister, SIGNAL(refreshItems(QList<QPair<KFileItem,KFileItem> >)), - this, SLOT(slotRefreshItems())); - - connect(m_dirLister, SIGNAL(clear()), this, SIGNAL(itemCountChanged())); - connect(m_dirLister, SIGNAL(newItems(KFileItemList)), this, SIGNAL(itemCountChanged())); - connect(m_dirLister, SIGNAL(infoMessage(QString)), this, SIGNAL(infoMessage(QString))); - connect(m_dirLister, SIGNAL(errorMessage(QString)), this, SIGNAL(infoMessage(QString))); - connect(m_dirLister, SIGNAL(percent(int)), this, SIGNAL(pathLoadingProgress(int))); - connect(m_dirLister, SIGNAL(urlIsFileError(KUrl)), this, SIGNAL(urlIsFileError(KUrl))); - connect(m_dirLister, SIGNAL(itemsDeleted(KFileItemList)), this, SIGNAL(itemCountChanged())); - - m_container = new DolphinItemListContainer(m_dirLister, this); + m_container = new DolphinItemListContainer(this); m_container->setVisibleRoles(QList<QByteArray>() << "name"); m_container->installEventFilter(this); setFocusProxy(m_container); @@ -156,10 +136,17 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) : connect(controller, SIGNAL(modelChanged(KItemModelBase*,KItemModelBase*)), this, SLOT(slotModelChanged(KItemModelBase*,KItemModelBase*))); KFileItemModel* model = fileItemModel(); - if (model) { - connect(model, SIGNAL(loadingCompleted()), this, SLOT(slotLoadingCompleted())); - connect(model, SIGNAL(sortProgress(int)), this, SIGNAL(sortProgress(int))); - } + connect(model, SIGNAL(dirLoadingStarted()), this, SLOT(slotDirLoadingStarted())); + connect(model, SIGNAL(dirLoadingCompleted()), this, SLOT(slotDirLoadingCompleted())); + connect(model, SIGNAL(dirLoadingProgress(int)), this, SIGNAL(dirLoadingProgress(int))); + connect(model, SIGNAL(dirSortingProgress(int)), this, SIGNAL(dirSortingProgress(int))); + connect(model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)), + this, SLOT(slotItemsChanged())); + connect(model, SIGNAL(itemsRemoved(KItemRangeList)), this, SIGNAL(itemCountChanged())); + connect(model, SIGNAL(itemsInserted(KItemRangeList)), this, SIGNAL(itemCountChanged())); + connect(model, SIGNAL(infoMessage(QString)), this, SIGNAL(infoMessage(QString))); + connect(model, SIGNAL(errorMessage(QString)), this, SIGNAL(errorMessage(QString))); + connect(model, SIGNAL(redirection(KUrl,KUrl)), this, SLOT(slotRedirection(KUrl,KUrl))); KItemListView* view = controller->view(); view->installEventFilter(this); @@ -269,7 +256,8 @@ bool DolphinView::previewsShown() const void DolphinView::setHiddenFilesShown(bool show) { - if (m_dirLister->showingDotFiles() == show) { + KFileItemModel* model = fileItemModel(); + if (model->showHiddenFiles() == show) { return; } @@ -280,13 +268,13 @@ void DolphinView::setHiddenFilesShown(bool show) ViewProperties props(url()); props.setHiddenFilesShown(show); - fileItemModel()->setShowHiddenFiles(show); + model->setShowHiddenFiles(show); emit hiddenFilesShownChanged(show); } bool DolphinView::hiddenFilesShown() const { - return m_dirLister->showingDotFiles(); + return fileItemModel()->showHiddenFiles(); } void DolphinView::setGroupedSorting(bool grouped) @@ -311,7 +299,21 @@ bool DolphinView::groupedSorting() const KFileItemList DolphinView::items() const { - return m_dirLister->items(); + KFileItemList list; + const KFileItemModel* model = fileItemModel(); + const int itemCount = model->count(); + list.reserve(itemCount); + + for (int i = 0; i < itemCount; ++i) { + list.append(model->fileItem(i)); + } + + return list; +} + +int DolphinView::itemsCount() const +{ + return fileItemModel()->count(); } KFileItemList DolphinView::selectedItems() const @@ -455,7 +457,7 @@ void DolphinView::reload() void DolphinView::stopLoading() { - m_dirLister->stop(); + fileItemModel()->cancelDirLoading(); } void DolphinView::readSettings() @@ -492,7 +494,10 @@ void DolphinView::calculateItemCount(int& fileCount, int& folderCount, KIO::filesize_t& totalFileSize) const { - foreach (const KFileItem& item, m_dirLister->items()) { + const KFileItemModel* model = fileItemModel(); + const int itemCount = model->count(); + for (int i = 0; i < itemCount; ++i) { + const KFileItem item = model->fileItem(i); if (item.isDir()) { ++folderCount; } else { @@ -628,8 +633,9 @@ void DolphinView::renameSelectedItems() dialog->activateWindow(); //} - // assure that the current index remains visible when KDirLister - // will notify the view about changed items + // Assure that the current index remains visible when KFileItemModel + // will notify the view about changed items (which might result in + // a changed sorting). m_assureVisibleCurrentIndex = true; } @@ -979,11 +985,11 @@ void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* even void DolphinView::slotModelChanged(KItemModelBase* current, KItemModelBase* previous) { if (previous != 0) { - disconnect(previous, SIGNAL(loadingCompleted()), this, SLOT(slotLoadingCompleted())); + disconnect(previous, SIGNAL(dirLoadingCompleted()), this, SLOT(slotDirLoadingCompleted())); } Q_ASSERT(qobject_cast<KFileItemModel*>(current)); - connect(current, SIGNAL(loadingCompleted()), this, SLOT(slotLoadingCompleted())); + connect(current, SIGNAL(loadingCompleted()), this, SLOT(slotDirLoadingCompleted())); KFileItemModel* fileItemModel = static_cast<KFileItemModel*>(current); m_versionControlObserver->setModel(fileItemModel); @@ -1121,7 +1127,7 @@ bool DolphinView::hasSelection() const KFileItem DolphinView::rootItem() const { - return m_dirLister->rootItem(); + return fileItemModel()->rootItem(); } void DolphinView::observeCreatedItem(const KUrl& url) @@ -1222,7 +1228,7 @@ void DolphinView::slotDeleteFileFinished(KJob* job) } } -void DolphinView::slotDirListerStarted(const KUrl& url) +void DolphinView::slotDirLoadingStarted() { // Disable the writestate temporary until it can be determined in a fast way // in DolphinView::slotLoadingCompleted() @@ -1231,29 +1237,23 @@ void DolphinView::slotDirListerStarted(const KUrl& url) emit writeStateChanged(m_isFolderWritable); } - emit startedPathLoading(url); + emit startedDirLoading(url()); } -void DolphinView::slotLoadingCompleted() +void DolphinView::slotDirLoadingCompleted() { // Update the view-state. This has to be done using a Qt::QueuedConnection // because the view might not be in its final state yet. QTimer::singleShot(0, this, SLOT(updateViewState())); - emit finishedPathLoading(url()); + emit finishedDirLoading(url()); updateWritableState(); } -void DolphinView::slotRefreshItems() +void DolphinView::slotItemsChanged() { - if (m_assureVisibleCurrentIndex) { - m_assureVisibleCurrentIndex = false; - //QAbstractItemView* view = m_viewAccessor.itemView(); - //if (view) { - // m_viewAccessor.itemView()->scrollTo(m_viewAccessor.itemView()->currentIndex()); - //} - } + m_assureVisibleCurrentIndex = false; } void DolphinView::slotSortOrderChangedByHeader(Qt::SortOrder current, Qt::SortOrder previous) @@ -1311,7 +1311,12 @@ void DolphinView::loadDirectory(const KUrl& url, bool reload) return; } - m_dirLister->openUrl(url, reload ? KDirLister::Reload : KDirLister::NoFlags); + KFileItemModel* model = fileItemModel(); + if (reload) { + model->refreshDir(url); + } else { + model->loadDir(url); + } } void DolphinView::applyViewProperties() @@ -1465,7 +1470,7 @@ void DolphinView::updateWritableState() const bool wasFolderWritable = m_isFolderWritable; m_isFolderWritable = true; - const KFileItem item = m_dirLister->rootItem(); + const KFileItem item = fileItemModel()->rootItem(); if (!item.isNull()) { KFileItemListProperties capabilities(KFileItemList() << item); m_isFolderWritable = capabilities.supportsWriting(); diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h index b1d057e6f..9c674d03a 100644 --- a/src/views/dolphinview.h +++ b/src/views/dolphinview.h @@ -39,7 +39,6 @@ typedef KIO::FileUndoManager::CommandType CommandType; -class DolphinDirLister; class DolphinItemListContainer; class KAction; class KActionCollection; @@ -155,6 +154,12 @@ public: KFileItemList items() const; /** + * @return The number of items. itemsCount() is faster in comparison + * to items().count(). + */ + int itemsCount() const; + + /** * Returns the selected items. The list is empty if no item has been * selected. */ @@ -474,25 +479,29 @@ signals: /** * Is emitted after DolphinView::setUrl() has been invoked and - * the path \a url is currently loaded. If this signal is emitted, + * the directory \a url is currently loaded. If this signal is emitted, * it is assured that the view contains already the correct root * URL and property settings. */ - void startedPathLoading(const KUrl& url); + void startedDirLoading(const KUrl& url); /** - * Is emitted after the path triggered by DolphinView::setUrl() + * Is emitted after the directory triggered by DolphinView::setUrl() * has been loaded. */ - void finishedPathLoading(const KUrl& url); + void finishedDirLoading(const KUrl& url); /** * Is emitted after DolphinView::setUrl() has been invoked and provides - * the information how much percent of the current path have been loaded. + * the information how much percent of the current directory have been loaded. */ - void pathLoadingProgress(int percent); + void dirLoadingProgress(int percent); - void sortProgress(int percent); + /** + * Is emitted if the sorting is done asynchronously and provides the + * progress information of the sorting. + */ + void dirSortingProgress(int percent); /** * Is emitted if the DolphinView::setUrl() is invoked but the URL is not @@ -501,7 +510,7 @@ signals: void urlIsFileError(const KUrl& file); /** - * Emitted when KDirLister emits redirection. + * Emitted when the file-item-model emits redirection. * Testcase: fish://localhost */ void redirection(const KUrl& oldUrl, const KUrl& newUrl); @@ -606,23 +615,21 @@ private slots: void slotDeleteFileFinished(KJob* job); /** - * Invoked when the directory lister has been started the - * loading of \a url. + * Invoked when the file item model has started the loading + * of the directory specified by DolphinView::url(). */ - void slotDirListerStarted(const KUrl& url); + void slotDirLoadingStarted(); /** - * Invoked when the file item model indicates that the directory lister has completed the loading - * of items, and that expanded folders have been restored (if the view mode is 'Details', and the - * view state is restored after navigating back or forward in history). Assures that pasted items - * and renamed items get seleced. + * Invoked when the file item model indicates that the loading of a directory has + * been completed. Assures that pasted items and renamed items get seleced. */ - void slotLoadingCompleted(); + void slotDirLoadingCompleted(); /** - * Is invoked when the KDirLister indicates refreshed items. + * Is invoked when items of KFileItemModel have been changed. */ - void slotRefreshItems(); + void slotItemsChanged(); /** * Is invoked when the sort order has been changed by the user by clicking @@ -730,7 +737,6 @@ private: QVBoxLayout* m_topLayout; - DolphinDirLister* m_dirLister; DolphinItemListContainer* m_container; ToolTipManager* m_toolTipManager; diff --git a/src/views/versioncontrol/versioncontrolobserver.cpp b/src/views/versioncontrol/versioncontrolobserver.cpp index ac4709069..bbabd2e4e 100644 --- a/src/views/versioncontrol/versioncontrolobserver.cpp +++ b/src/views/versioncontrol/versioncontrolobserver.cpp @@ -21,7 +21,6 @@ #include "dolphin_versioncontrolsettings.h" -#include <KDirLister> #include <KLocale> #include <KService> #include <KServiceTypeTrader> @@ -30,6 +29,7 @@ #include "updateitemstatesthread.h" +#include <QFile> #include <QMutexLocker> #include <QTimer> @@ -298,7 +298,6 @@ KVersionControlPlugin* VersionControlObserver::searchPlugin(const KUrl& director // Verify whether the current directory contains revision information // like .svn, .git, ... foreach (KVersionControlPlugin* plugin, plugins) { - // Use the KDirLister cache to check for .svn, .git, ... files const QString fileName = directory.path(KUrl::AddTrailingSlash) + plugin->fileName(); if (QFile::exists(fileName)) { return plugin; |
