diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6ac4464e86..e9079569a5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -18,38 +18,38 @@ add_subdirectory(tests) ########### next target ############### set(dolphinprivate_LIB_SRCS - kitemviews/kfileitemclipboard.cpp kitemviews/kfileitemlistgroupheader.cpp kitemviews/kfileitemlistview.cpp kitemviews/kfileitemlistwidget.cpp kitemviews/kfileitemmodel.cpp - kitemviews/kfileitemmodelsortalgorithm.cpp - kitemviews/kfileitemmodelfilter.cpp kitemviews/kfileitemmodelrolesupdater.cpp kitemviews/kitemlistcontainer.cpp kitemviews/kitemlistcontroller.cpp kitemviews/kitemlistgroupheader.cpp kitemviews/kitemlistheader.cpp - kitemviews/kitemlistheaderwidget.cpp - kitemviews/kitemlistkeyboardsearchmanager.cpp - kitemviews/kitemlistrubberband.cpp kitemviews/kitemlistselectionmanager.cpp - kitemviews/kitemlistselectiontoggle.cpp - kitemviews/kitemlistsizehintresolver.cpp - kitemviews/kitemlistsmoothscroller.cpp kitemviews/kitemliststyleoption.cpp kitemviews/kitemlistview.cpp - kitemviews/kitemlistviewanimation.cpp - kitemviews/kitemlistviewlayouter.cpp kitemviews/kitemlistwidget.cpp kitemviews/kitemmodelbase.cpp - kitemviews/kpixmapmodifier.cpp + kitemviews/private/kfileitemclipboard.cpp + kitemviews/private/kfileitemmodeldirlister.cpp + kitemviews/private/kfileitemmodelsortalgorithm.cpp + kitemviews/private/kfileitemmodelfilter.cpp + kitemviews/private/kitemlistheaderwidget.cpp + kitemviews/private/kitemlistkeyboardsearchmanager.cpp + kitemviews/private/kitemlistrubberband.cpp + kitemviews/private/kitemlistselectiontoggle.cpp + kitemviews/private/kitemlistsizehintresolver.cpp + kitemviews/private/kitemlistsmoothscroller.cpp + kitemviews/private/kitemlistviewanimation.cpp + kitemviews/private/kitemlistviewlayouter.cpp + kitemviews/private/kpixmapmodifier.cpp settings/additionalinfodialog.cpp settings/applyviewpropsjob.cpp settings/viewmodes/viewmodesettings.cpp settings/viewpropertiesdialog.cpp settings/viewpropsprogressinfo.cpp - views/dolphindirlister.cpp views/dolphinfileitemlistwidget.cpp views/dolphinitemlistcontainer.cpp views/dolphinnewfilemenuobserver.cpp @@ -71,7 +71,7 @@ set(dolphinprivate_LIB_SRCS if (Nepomuk_FOUND) set(dolphinprivate_LIB_SRCS ${dolphinprivate_LIB_SRCS} - kitemviews/knepomukrolesprovider.cpp + kitemviews/private/knepomukrolesprovider.cpp ) endif (Nepomuk_FOUND) diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 3aff015c50..22d8af3c3b 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -2088,9 +2088,9 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container) this, SLOT(openNewTab(KUrl))); connect(view, SIGNAL(requestContextMenu(QPoint,KFileItem,KUrl,QList)), this, SLOT(openContextMenu(QPoint,KFileItem,KUrl,QList))); - connect(view, SIGNAL(startedPathLoading(KUrl)), + connect(view, SIGNAL(startedDirLoading(KUrl)), this, SLOT(enableStopAction())); - connect(view, SIGNAL(finishedPathLoading(KUrl)), + connect(view, SIGNAL(finishedDirLoading(KUrl)), this, SLOT(disableStopAction())); connect(view, SIGNAL(goBackRequested()), this, SLOT(goBack())); diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp index 8720e0ce22..bb944bad0b 100644 --- a/src/dolphinpart.cpp +++ b/src/dolphinpart.cpp @@ -45,11 +45,11 @@ #include "views/dolphinviewactionhandler.h" #include "views/dolphinnewfilemenuobserver.h" #include "views/dolphinremoteencoding.h" -#include "views/dolphindirlister.h" #include #include #include +#include K_PLUGIN_FACTORY(DolphinPartFactory, registerPlugin();) K_EXPORT_PLUGIN(DolphinPartFactory("dolphinpart", "dolphin")) @@ -69,8 +69,8 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL m_view->setTabsForFilesEnabled(true); setWidget(m_view); - connect(m_view, SIGNAL(finishedPathLoading(KUrl)), this, SLOT(slotCompleted(KUrl))); - connect(m_view, SIGNAL(pathLoadingProgress(int)), this, SLOT(updateProgress(int))); + connect(m_view, SIGNAL(finishedDirLoading(KUrl)), this, SLOT(slotCompleted(KUrl))); + connect(m_view, SIGNAL(dirLoadingProgress(int)), this, SLOT(updateProgress(int))); connect(m_view, SIGNAL(errorMessage(QString)), this, SLOT(slotErrorMessage(QString))); setXMLFile("dolphinpart.rc"); diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index 1c15c88a99..a6049992f7 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -92,21 +92,20 @@ DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) : connect(m_searchBox, SIGNAL(returnPressed(QString)), this, SLOT(requestFocus())); m_view = new DolphinView(url, this); - connect(m_view, SIGNAL(urlChanged(KUrl)), m_urlNavigator, SLOT(setUrl(KUrl))); - connect(m_view, SIGNAL(writeStateChanged(bool)), this, SIGNAL(writeStateChanged(bool))); - connect(m_view, SIGNAL(requestItemInfo(KFileItem)), this, SLOT(showItemInfo(KFileItem))); - connect(m_view, SIGNAL(errorMessage(QString)), this, SLOT(showErrorMessage(QString))); - connect(m_view, SIGNAL(infoMessage(QString)), this, SLOT(showInfoMessage(QString))); - connect(m_view, SIGNAL(itemActivated(KFileItem)), this, SLOT(slotItemActivated(KFileItem))); - connect(m_view, SIGNAL(redirection(KUrl,KUrl)), this, SLOT(redirect(KUrl,KUrl))); - connect(m_view, SIGNAL(startedPathLoading(KUrl)), this, SLOT(slotStartedPathLoading())); - connect(m_view, SIGNAL(finishedPathLoading(KUrl)), this, SLOT(slotFinishedPathLoading())); - connect(m_view, SIGNAL(itemCountChanged()), this, SLOT(delayedStatusBarUpdate())); - connect(m_view, SIGNAL(pathLoadingProgress(int)), this, SLOT(updateLoadingProgress(int))); - connect(m_view, SIGNAL(sortProgress(int)), this, SLOT(updateSortProgress(int))); - connect(m_view, SIGNAL(infoMessage(QString)), this, SLOT(showInfoMessage(QString))); - connect(m_view, SIGNAL(errorMessage(QString)), this, SLOT(showErrorMessage(QString))); - connect(m_view, SIGNAL(urlIsFileError(KUrl)), this, SLOT(openFile(KUrl))); + connect(m_view, SIGNAL(urlChanged(KUrl)), m_urlNavigator, SLOT(setUrl(KUrl))); + connect(m_view, SIGNAL(writeStateChanged(bool)), this, SIGNAL(writeStateChanged(bool))); + connect(m_view, SIGNAL(requestItemInfo(KFileItem)), this, SLOT(showItemInfo(KFileItem))); + connect(m_view, SIGNAL(errorMessage(QString)), this, SLOT(showErrorMessage(QString))); + connect(m_view, SIGNAL(infoMessage(QString)), this, SLOT(showInfoMessage(QString))); + connect(m_view, SIGNAL(itemActivated(KFileItem)), this, SLOT(slotItemActivated(KFileItem))); + connect(m_view, SIGNAL(redirection(KUrl,KUrl)), this, SLOT(redirect(KUrl,KUrl))); + connect(m_view, SIGNAL(startedDirLoading(KUrl)), this, SLOT(slotStartedDirLoading())); + connect(m_view, SIGNAL(finishedDirLoading(KUrl)), this, SLOT(slotFinishedDirLoading())); + connect(m_view, SIGNAL(itemCountChanged()), this, SLOT(delayedStatusBarUpdate())); + connect(m_view, SIGNAL(dirLoadingProgress(int)), this, SLOT(updateDirLoadingProgress(int))); + connect(m_view, SIGNAL(dirSortingProgress(int)), this, SLOT(updateSortingProgress(int))); + connect(m_view, SIGNAL(infoMessage(QString)), this, SLOT(showInfoMessage(QString))); + connect(m_view, SIGNAL(errorMessage(QString)), this, SLOT(showErrorMessage(QString))); connect(m_view, SIGNAL(selectionChanged(KFileItemList)), this, SLOT(delayedStatusBarUpdate())); connect(m_view, SIGNAL(operationCompletedMessage(QString)), this, SLOT(showOperationCompletedMessage(QString))); connect(m_view, SIGNAL(urlAboutToBeChanged(KUrl)), this, SLOT(slotViewUrlAboutToBeChanged(KUrl))); @@ -333,7 +332,7 @@ void DolphinViewContainer::updateStatusBar() } } -void DolphinViewContainer::updateLoadingProgress(int percent) +void DolphinViewContainer::updateDirLoadingProgress(int percent) { if (m_statusBar->progressText().isEmpty()) { m_statusBar->setProgressText(i18nc("@info:progress", "Loading folder...")); @@ -341,7 +340,7 @@ void DolphinViewContainer::updateLoadingProgress(int percent) m_statusBar->setProgress(percent); } -void DolphinViewContainer::updateSortProgress(int percent) +void DolphinViewContainer::updateSortingProgress(int percent) { if (m_statusBar->progressText().isEmpty()) { m_statusBar->setProgressText(i18nc("@info:progress", "Sorting...")); @@ -349,7 +348,7 @@ void DolphinViewContainer::updateSortProgress(int percent) m_statusBar->setProgress(percent); } -void DolphinViewContainer::slotStartedPathLoading() +void DolphinViewContainer::slotStartedDirLoading() { if (isSearchUrl(url())) { // Search KIO-slaves usually don't provide any progress information. Give @@ -361,18 +360,18 @@ void DolphinViewContainer::slotStartedPathLoading() // Trigger an undetermined progress indication. The progress // information in percent will be triggered by the percent() signal // of the directory lister later. - updateLoadingProgress(-1); + updateDirLoadingProgress(-1); } } -void DolphinViewContainer::slotFinishedPathLoading() +void DolphinViewContainer::slotFinishedDirLoading() { if (!m_statusBar->progressText().isEmpty()) { m_statusBar->setProgressText(QString()); m_statusBar->setProgress(100); } - if (isSearchUrl(url()) && m_view->items().isEmpty()) { + if (isSearchUrl(url()) && m_view->itemsCount() == 0) { // The dir lister has been completed on a Nepomuk-URI and no items have been found. Instead // of showing the default status bar information ("0 items") a more helpful information is given: m_statusBar->setMessage(i18nc("@info:status", "No items found."), DolphinStatusBar::Information); @@ -422,12 +421,6 @@ void DolphinViewContainer::slotItemActivated(const KFileItem& item) item.run(); } -void DolphinViewContainer::openFile(const KUrl& url) -{ - const KFileItem item(KFileItem::Unknown, KFileItem::Unknown, url); - slotItemActivated(item); -} - void DolphinViewContainer::showItemInfo(const KFileItem& item) { if (item.isNull()) { diff --git a/src/dolphinviewcontainer.h b/src/dolphinviewcontainer.h index 734021aa99..de3bd60a64 100644 --- a/src/dolphinviewcontainer.h +++ b/src/dolphinviewcontainer.h @@ -154,21 +154,21 @@ private slots: */ void updateStatusBar(); - void updateLoadingProgress(int percent); + void updateDirLoadingProgress(int percent); - void updateSortProgress(int percent); + void updateSortingProgress(int percent); /** * Updates the statusbar to show an undetermined progress with the correct * context information whether a searching or a directory loading is done. */ - void slotStartedPathLoading(); + void slotStartedDirLoading(); /** * Assures that the viewport position is restored and updates the * statusbar to reflect the current content. */ - void slotFinishedPathLoading(); + void slotFinishedDirLoading(); /** * Handles clicking on an item. If the item is a directory, the @@ -177,13 +177,6 @@ private slots: */ void slotItemActivated(const KFileItem& item); - /** - * Opens a the file \a url by opening the corresponding application. - * Is connected with the signal urlIsFile() from DolphinDirLister and will - * get invoked if the user manually has entered a file into the URL navigator. - */ - void openFile(const KUrl& url); - /** * Shows the information for the item \a item inside the statusbar. If the * item is null, the default statusbar information is shown. diff --git a/src/kitemviews/kfileitemlistview.cpp b/src/kitemviews/kfileitemlistview.cpp index 11760fed1c..6464ec38ac 100644 --- a/src/kitemviews/kfileitemlistview.cpp +++ b/src/kitemviews/kfileitemlistview.cpp @@ -23,9 +23,9 @@ #include "kfileitemmodelrolesupdater.h" #include "kfileitemlistwidget.h" #include "kfileitemmodel.h" -#include "kpixmapmodifier_p.h" #include #include +#include "private/kpixmapmodifier.h" #include #include diff --git a/src/kitemviews/kfileitemlistwidget.cpp b/src/kitemviews/kfileitemlistwidget.cpp index 14ec1ec22f..f3b4da892f 100644 --- a/src/kitemviews/kfileitemlistwidget.cpp +++ b/src/kitemviews/kfileitemlistwidget.cpp @@ -19,10 +19,8 @@ #include "kfileitemlistwidget.h" -#include "kfileitemclipboard_p.h" #include "kfileitemlistview.h" #include "kfileitemmodel.h" -#include "kpixmapmodifier_p.h" #include #include @@ -32,6 +30,9 @@ #include #include +#include "private/kfileitemclipboard.h" +#include "private/kpixmapmodifier.h" + #include #include #include @@ -193,12 +194,15 @@ QRectF KFileItemListWidget::textRect() const QRectF KFileItemListWidget::textFocusRect() const { + // In the compact- and details-layout a larger textRect() is returned to be aligned + // with the iconRect(). This is useful to have a larger selection/hover-area + // when having a quite large icon size but only one line of text. Still the + // focus rectangle should be shown as narrow as possible around the text. + const_cast(this)->triggerCacheRefreshing(); - if (m_layout == CompactLayout) { - // In the compact layout a larger textRect() is returned to be aligned - // with the iconRect(). This is useful to have a larger selection/hover-area - // when having a quite large icon size but only one line of text. Still the - // focus rectangle should be shown as narrow as possible around the text. + + switch (m_layout) { + case CompactLayout: { QRectF rect = m_textRect; const TextInfo* topText = m_textInfo.value(m_sortedVisibleRoles.first()); const TextInfo* bottomText = m_textInfo.value(m_sortedVisibleRoles.last()); @@ -206,6 +210,19 @@ QRectF KFileItemListWidget::textFocusRect() const rect.setBottom(bottomText->pos.y() + bottomText->staticText.size().height()); return rect; } + + case DetailsLayout: { + QRectF rect = m_textRect; + const TextInfo* textInfo = m_textInfo.value(m_sortedVisibleRoles.first()); + rect.setTop(textInfo->pos.y()); + rect.setBottom(textInfo->pos.y() + textInfo->staticText.size().height()); + return rect; + } + + default: + break; + } + return m_textRect; } diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp index 685af89729..409b5cd529 100644 --- a/src/kitemviews/kfileitemmodel.cpp +++ b/src/kitemviews/kfileitemmodel.cpp @@ -19,26 +19,27 @@ #include "kfileitemmodel.h" -#include #include -#include "kfileitemmodelsortalgorithm_p.h" #include #include #include #include +#include "private/kfileitemmodelsortalgorithm.h" +#include "private/kfileitemmodeldirlister.h" + #include #include // #define KFILEITEMMODEL_DEBUG -KFileItemModel::KFileItemModel(KDirLister* dirLister, QObject* parent) : +KFileItemModel::KFileItemModel(QObject* parent) : KItemModelBase("name", parent), - m_dirLister(dirLister), + m_dirLister(0), m_naturalSorting(KGlobalSettings::naturalSorting()), m_sortFoldersFirst(true), m_sortRole(NameRole), - m_sortProgressPercent(-1), + m_sortingProgressPercent(-1), m_roles(), m_caseSensitivity(Qt::CaseInsensitive), m_itemData(), @@ -54,6 +55,22 @@ KFileItemModel::KFileItemModel(KDirLister* dirLister, QObject* parent) : m_expandedUrls(), m_urlsToExpand() { + m_dirLister = new KFileItemModelDirLister(this); + m_dirLister->setAutoUpdate(true); + m_dirLister->setDelayedMimeTypes(true); + + connect(m_dirLister, SIGNAL(started(KUrl)), this, SIGNAL(dirLoadingStarted())); + connect(m_dirLister, SIGNAL(canceled()), this, SLOT(slotCanceled())); + connect(m_dirLister, SIGNAL(completed(KUrl)), this, SLOT(slotCompleted())); + connect(m_dirLister, SIGNAL(newItems(KFileItemList)), this, SLOT(slotNewItems(KFileItemList))); + connect(m_dirLister, SIGNAL(itemsDeleted(KFileItemList)), this, SLOT(slotItemsDeleted(KFileItemList))); + connect(m_dirLister, SIGNAL(refreshItems(QList >)), this, SLOT(slotRefreshItems(QList >))); + connect(m_dirLister, SIGNAL(clear()), this, SLOT(slotClear())); + connect(m_dirLister, SIGNAL(clear(KUrl)), this, SLOT(slotClear(KUrl))); + connect(m_dirLister, SIGNAL(infoMessage(QString)), this, SIGNAL(infoMessage(QString))); + connect(m_dirLister, SIGNAL(errorMessage(QString)), this, SIGNAL(errorMessage(QString))); + connect(m_dirLister, SIGNAL(redirection(KUrl,KUrl)), this, SIGNAL(redirection(KUrl,KUrl))); + // Apply default roles that should be determined resetRoles(); m_requestRole[NameRole] = true; @@ -61,16 +78,6 @@ KFileItemModel::KFileItemModel(KDirLister* dirLister, QObject* parent) : m_roles.insert("name"); m_roles.insert("isDir"); - Q_ASSERT(dirLister); - - connect(dirLister, SIGNAL(canceled()), this, SLOT(slotCanceled())); - connect(dirLister, SIGNAL(completed(KUrl)), this, SLOT(slotCompleted())); - connect(dirLister, SIGNAL(newItems(KFileItemList)), this, SLOT(slotNewItems(KFileItemList))); - connect(dirLister, SIGNAL(itemsDeleted(KFileItemList)), this, SLOT(slotItemsDeleted(KFileItemList))); - connect(dirLister, SIGNAL(refreshItems(QList >)), this, SLOT(slotRefreshItems(QList >))); - connect(dirLister, SIGNAL(clear()), this, SLOT(slotClear())); - connect(dirLister, SIGNAL(clear(KUrl)), this, SLOT(slotClear(KUrl))); - // For slow KIO-slaves like used for searching it makes sense to show results periodically even // before the completed() or canceled() signal has been emitted. m_maximumUpdateIntervalTimer = new QTimer(this); @@ -96,6 +103,21 @@ KFileItemModel::~KFileItemModel() m_itemData.clear(); } +void KFileItemModel::loadDir(const KUrl& url) +{ + m_dirLister->openUrl(url); +} + +void KFileItemModel::refreshDir(const KUrl& url) +{ + m_dirLister->openUrl(url, KDirLister::Reload); +} + +KUrl KFileItemModel::dir() const +{ + return m_dirLister->url(); +} + int KFileItemModel::count() const { return m_itemData.count(); @@ -160,34 +182,26 @@ bool KFileItemModel::sortFoldersFirst() const void KFileItemModel::setShowHiddenFiles(bool show) { - KDirLister* dirLister = m_dirLister.data(); - if (dirLister) { - dirLister->setShowingDotFiles(show); - dirLister->emitChanges(); - if (show) { - slotCompleted(); - } + m_dirLister->setShowingDotFiles(show); + m_dirLister->emitChanges(); + if (show) { + slotCompleted(); } } bool KFileItemModel::showHiddenFiles() const { - const KDirLister* dirLister = m_dirLister.data(); - return dirLister ? dirLister->showingDotFiles() : false; + return m_dirLister->showingDotFiles(); } void KFileItemModel::setShowFoldersOnly(bool enabled) { - KDirLister* dirLister = m_dirLister.data(); - if (dirLister) { - dirLister->setDirOnlyMode(enabled); - } + m_dirLister->setDirOnlyMode(enabled); } bool KFileItemModel::showFoldersOnly() const { - KDirLister* dirLister = m_dirLister.data(); - return dirLister ? dirLister->dirOnlyMode() : false; + return m_dirLister->dirOnlyMode(); } QMimeData* KFileItemModel::createMimeData(const QSet& indexes) const @@ -324,11 +338,7 @@ int KFileItemModel::index(const KUrl& url) const KFileItem KFileItemModel::rootItem() const { - const KDirLister* dirLister = m_dirLister.data(); - if (dirLister) { - return dirLister->rootItem(); - } - return KFileItem(); + return m_dirLister->rootItem(); } void KFileItemModel::clear() @@ -391,21 +401,14 @@ bool KFileItemModel::setExpanded(int index, bool expanded) return false; } - KDirLister* dirLister = m_dirLister.data(); const KUrl url = m_itemData.at(index)->item.url(); if (expanded) { m_expandedUrls.insert(url); - - if (dirLister) { - dirLister->openUrl(url, KDirLister::Keep); - return true; - } + m_dirLister->openUrl(url, KDirLister::Keep); } else { m_expandedUrls.remove(url); + m_dirLister->stop(url); - if (dirLister) { - dirLister->stop(url); - } KFileItemList itemsToRemove; const int expandedParentsCount = data(index)["expandedParentsCount"].toInt(); @@ -415,10 +418,9 @@ bool KFileItemModel::setExpanded(int index, bool expanded) ++index; } removeItems(itemsToRemove); - return true; } - return false; + return true; } bool KFileItemModel::isExpanded(int index) const @@ -460,18 +462,13 @@ void KFileItemModel::restoreExpandedUrls(const QSet& urls) void KFileItemModel::expandParentItems(const KUrl& url) { - const KDirLister* dirLister = m_dirLister.data(); - if (!dirLister) { - return; - } - - const int pos = dirLister->url().path().length(); + const int pos = m_dirLister->url().path().length(); // Assure that each sub-path of the URL that should be // expanded is added to m_urlsToExpand. KDirLister // does not care whether the parent-URL has already been // expanded. - KUrl urlToExpand = dirLister->url(); + KUrl urlToExpand = m_dirLister->url(); const QStringList subDirs = url.path().mid(pos).split(QDir::separator()); for (int i = 0; i < subDirs.count() - 1; ++i) { urlToExpand.addPath(subDirs.at(i)); @@ -537,6 +534,11 @@ QString KFileItemModel::nameFilter() const return m_filter.pattern(); } +void KFileItemModel::cancelDirLoading() +{ + m_dirLister->stop(); +} + QList KFileItemModel::rolesInformation() { static QList rolesInfo; @@ -666,7 +668,7 @@ void KFileItemModel::slotCompleted() m_urlsToExpand.clear(); } - emit loadingCompleted(); + emit dirLoadingCompleted(); } void KFileItemModel::slotCanceled() @@ -1222,8 +1224,8 @@ QHash KFileItemModel::retrieveData(const KFileItem& item) } if (m_requestRole[ExpandedParentsCountRole]) { - if (m_expandedParentsCountRoot == UninitializedExpandedParentsCountRoot && m_dirLister.data()) { - const KUrl rootUrl = m_dirLister.data()->url(); + if (m_expandedParentsCountRoot == UninitializedExpandedParentsCountRoot) { + const KUrl rootUrl = m_dirLister->url(); const QString protocol = rootUrl.protocol(); const bool forceExpandedParentsCountRoot = (protocol == QLatin1String("trash") || protocol == QLatin1String("nepomuk") || @@ -1501,8 +1503,7 @@ QString KFileItemModel::subPath(const KFileItem& item, bool KFileItemModel::useMaximumUpdateInterval() const { - const KDirLister* dirLister = m_dirLister.data(); - return dirLister && !dirLister->url().isLocalFile(); + return !m_dirLister->url().isLocalFile(); } QList > KFileItemModel::nameRoleGroups() const @@ -1847,20 +1848,20 @@ void KFileItemModel::emitSortProgress(int resolvedCount) const int itemCount = count(); if (resolvedCount >= itemCount) { - m_sortProgressPercent = -1; + m_sortingProgressPercent = -1; if (m_resortAllItemsTimer->isActive()) { m_resortAllItemsTimer->stop(); resortAllItems(); } - emit sortProgress(100); + emit dirSortingProgress(100); } else if (itemCount > 0) { resolvedCount = qBound(0, resolvedCount, itemCount); const int progress = resolvedCount * 100 / itemCount; - if (m_sortProgressPercent != progress) { - m_sortProgressPercent = progress; - emit sortProgress(progress); + if (m_sortingProgressPercent != progress) { + m_sortingProgressPercent = progress; + emit dirSortingProgress(progress); } } } diff --git a/src/kitemviews/kfileitemmodel.h b/src/kitemviews/kfileitemmodel.h index eaf35fecd9..05834cd31b 100644 --- a/src/kitemviews/kfileitemmodel.h +++ b/src/kitemviews/kfileitemmodel.h @@ -23,12 +23,12 @@ #include #include #include -#include #include +#include #include -class KDirLister; +class KFileItemModelDirLister; class QTimer; /** @@ -42,24 +42,37 @@ class QTimer; * * Also the recursive expansion of sub-directories is supported by * KFileItemModel::setExpanded(). - * - * TODO: In the longterm instead of passing a KDirLister just an URL should - * be passed and a KDirLister used internally. This solves the following issues: - * - The user of the API does not need to decide whether he listens to KDirLister - * or KFileItemModel. - * - It resolves minor conceptual differences between KDirLister and KFileItemModel. - * E.g. there is no way for KFileItemModel to check whether a completed() signal - * will be emitted after newItems() will be send by KDirLister or not (in the case - * of setShowingDotFiles() no completed() signal will get emitted). */ class LIBDOLPHINPRIVATE_EXPORT KFileItemModel : public KItemModelBase { Q_OBJECT public: - explicit KFileItemModel(KDirLister* dirLister, QObject* parent = 0); + explicit KFileItemModel(QObject* parent = 0); virtual ~KFileItemModel(); + /** + * Loads the directory specified by \a url. The signals + * dirLoadingStarted(), dirLoadingProgress() and dirLoadingCompleted() + * indicate the current state of the loading process. The items + * of the directory are added after the loading has been completed. + */ + void loadDir(const KUrl& url); + + /** + * Throws away all currently loaded items and refreshes the directory + * by reloading all items again. + */ + void refreshDir(const KUrl& url); + + /** + * @return Parent directory of the items that are shown. In case + * if a directory tree is shown, KFileItemModel::dir() returns + * the root-parent of all items. + * @see rootItem() + */ + KUrl dir() const; + virtual int count() const; virtual QHash data(int index) const; virtual bool setData(int index, const QHash& values); @@ -123,7 +136,8 @@ public: int index(const KUrl& url) const; /** - * @return Root item of all items. + * @return Root item of all items representing the item + * for KFileItemModel::dir(). */ KFileItem rootItem() const; @@ -158,6 +172,8 @@ public: void setNameFilter(const QString& nameFilter); QString nameFilter() const; + void cancelDirLoading(); + struct RoleInfo { QByteArray role; QString translation; @@ -175,6 +191,14 @@ public: static QList rolesInformation(); signals: + /** + * Is emitted if the loading of a directory has been started. It is + * assured that a signal dirLoadingCompleted() will be send after + * the loading has been finished. For tracking the loading progress + * the signal dirLoadingProgress() gets emitted in between. + */ + void dirLoadingStarted(); + /** * Is emitted after the loading of a directory has been completed or new * items have been inserted to an already loaded directory. Usually @@ -182,14 +206,38 @@ signals: * (the only exception is loading an empty directory, where only a * loadingCompleted() signal gets emitted). */ - void loadingCompleted(); + void dirLoadingCompleted(); + + /** + * Informs about the progress in percent when loading a directory. It is assured + * that the signal dirLoadingStarted() has been emitted before. + */ + void dirLoadingProgress(int percent); /** * Is emitted if the sort-role gets resolved asynchronously and provides * the progress-information of the sorting in percent. It is assured * that the last sortProgress-signal contains 100 as value. */ - void sortProgress(int percent); + void dirSortingProgress(int percent); + + /** + * Is emitted if an information message (e.g. "Connecting to host...") + * should be shown. + */ + void infoMessage(const QString& message); + + /** + * Is emitted if an error message (e.g. "Unknown location") + * should be shown. + */ + void errorMessage(const QString& message); + + /** + * Is emitted if a redirection from the current URL \a oldUrl + * to the new URL \a newUrl has been done. + */ + void redirection(const KUrl& oldUrl, const KUrl& newUrl); protected: virtual void onGroupedSortingChanged(bool current); @@ -357,13 +405,13 @@ private: static void determineMimeTypes(const KFileItemList& items, int timeout); private: - QWeakPointer m_dirLister; + KFileItemModelDirLister* m_dirLister; bool m_naturalSorting; bool m_sortFoldersFirst; RoleType m_sortRole; - int m_sortProgressPercent; // Value of sortProgress() signal + int m_sortingProgressPercent; // Value of dirSortingProgress() signal QSet m_roles; Qt::CaseSensitivity m_caseSensitivity; diff --git a/src/kitemviews/kfileitemmodelrolesupdater.cpp b/src/kitemviews/kfileitemmodelrolesupdater.cpp index 632df676d4..927407a69d 100644 --- a/src/kitemviews/kfileitemmodelrolesupdater.cpp +++ b/src/kitemviews/kfileitemmodelrolesupdater.cpp @@ -20,7 +20,6 @@ #include "kfileitemmodelrolesupdater.h" #include "kfileitemmodel.h" -#include "kpixmapmodifier_p.h" #include #include @@ -28,14 +27,17 @@ #include #include #include + +#include "private/kpixmapmodifier.h" + #include #include #include #include #ifdef HAVE_NEPOMUK - #include "knepomukrolesprovider_p.h" - #include "knepomukresourcewatcher_p.h" + #include "private/knepomukrolesprovider.h" + #include "private/knepomukresourcewatcher.h" #endif // Required includes for subItemsCount(): @@ -69,7 +71,7 @@ KFileItemModelRolesUpdater::KFileItemModelRolesUpdater(KFileItemModel* model, QO m_previewShown(false), m_enlargeSmallPreviews(true), m_clearPreviews(false), - m_sortProgress(-1), + m_sortingProgress(-1), m_model(model), m_iconSize(), m_firstVisibleIndex(0), @@ -849,7 +851,7 @@ void KFileItemModelRolesUpdater::sortAndResolvePendingRoles() void KFileItemModelRolesUpdater::applySortProgressToModel() { - if (m_sortProgress < 0) { + if (m_sortingProgress < 0) { return; } @@ -861,7 +863,7 @@ void KFileItemModelRolesUpdater::applySortProgressToModel() if (resolvedCount > 0) { m_model->emitSortProgress(resolvedCount); if (resolvedCount == m_model->count()) { - m_sortProgress = -1; + m_sortingProgress = -1; } } } @@ -877,11 +879,11 @@ void KFileItemModelRolesUpdater::updateSortProgress() ? hasUnknownMimeTypes() : m_resolvableRoles.contains(sortRole); - if (m_sortProgress >= 0) { + if (m_sortingProgress >= 0) { // Mark the current sorting as finished m_model->emitSortProgress(m_model->count()); } - m_sortProgress = showProgress ? 0 : -1; + m_sortingProgress = showProgress ? 0 : -1; } bool KFileItemModelRolesUpdater::hasUnknownMimeTypes() const diff --git a/src/kitemviews/kfileitemmodelrolesupdater.h b/src/kitemviews/kfileitemmodelrolesupdater.h index ce8cf1c73e..c520a23e88 100644 --- a/src/kitemviews/kfileitemmodelrolesupdater.h +++ b/src/kitemviews/kfileitemmodelrolesupdater.h @@ -240,7 +240,7 @@ private: // during the roles-updater has been paused by setPaused(). bool m_clearPreviews; - int m_sortProgress; + int m_sortingProgress; KFileItemModel* m_model; QSize m_iconSize; diff --git a/src/kitemviews/kitemlistcontainer.cpp b/src/kitemviews/kitemlistcontainer.cpp index b480b44948..5a485b62c3 100644 --- a/src/kitemviews/kitemlistcontainer.cpp +++ b/src/kitemviews/kitemlistcontainer.cpp @@ -23,10 +23,11 @@ #include "kitemlistcontainer.h" #include "kitemlistcontroller.h" -#include "kitemlistsmoothscroller_p.h" #include "kitemlistview.h" #include "kitemmodelbase.h" +#include "private/kitemlistsmoothscroller.h" + #include #include #include diff --git a/src/kitemviews/kitemlistcontroller.cpp b/src/kitemviews/kitemlistcontroller.cpp index ad08223a40..c0f565b4dd 100644 --- a/src/kitemviews/kitemlistcontroller.cpp +++ b/src/kitemviews/kitemlistcontroller.cpp @@ -23,10 +23,14 @@ #include "kitemlistcontroller.h" +#include +#include + #include "kitemlistview.h" -#include "kitemlistrubberband_p.h" #include "kitemlistselectionmanager.h" -#include "kitemlistkeyboardsearchmanager_p.h" + +#include "private/kitemlistrubberband.h" +#include "private/kitemlistkeyboardsearchmanager.h" #include #include @@ -37,9 +41,6 @@ #include #include -#include -#include - KItemListController::KItemListController(QObject* parent) : QObject(parent), m_singleClickActivation(KGlobalSettings::singleClick()), diff --git a/src/kitemviews/kitemlistheader.cpp b/src/kitemviews/kitemlistheader.cpp index be7a09c8f0..e89ece0a19 100644 --- a/src/kitemviews/kitemlistheader.cpp +++ b/src/kitemviews/kitemlistheader.cpp @@ -18,9 +18,10 @@ ***************************************************************************/ #include "kitemlistheader.h" -#include "kitemlistheaderwidget_p.h" #include "kitemlistview.h" +#include "private/kitemlistheaderwidget.h" + KItemListHeader::~KItemListHeader() { } diff --git a/src/kitemviews/kitemlistkeyboardsearchmanager_p.h b/src/kitemviews/kitemlistkeyboardsearchmanager_p.h deleted file mode 100644 index d6a6686dbc..0000000000 --- a/src/kitemviews/kitemlistkeyboardsearchmanager_p.h +++ /dev/null @@ -1,81 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2011 by Tirtha Chatterjee * - * * - * 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 * - ***************************************************************************/ - -#ifndef KITEMLISTKEYBOARDMANAGER_H -#define KITEMLISTKEYBOARDMANAGER_H - -#include - -#include -#include -#include - -/** - * @brief Controls the keyboard searching ability for a KItemListController. - * - * @see KItemListController - * @see KItemModelBase - */ -class LIBDOLPHINPRIVATE_EXPORT KItemListKeyboardSearchManager : public QObject -{ - Q_OBJECT - -public: - - KItemListKeyboardSearchManager(QObject* parent = 0); - virtual ~KItemListKeyboardSearchManager(); - - /** - * Add \a keys to the text buffer used for searching. - */ - void addKeys(const QString& keys); - - /** - * Sets the delay after which the search is cancelled to \a milliseconds. - * If the time interval between two calls of addKeys(const QString&) is - * larger than this, the second call will start a new search, rather than - * combining the keys received from both calls to a single search string. - */ - void setTimeout(qint64 milliseconds); - qint64 timeout() const; - -signals: - /** - * Is emitted if the current item should be changed corresponding - * to \a text. - * @param searchFromNextItem If true start searching from item next to the - * current item. Otherwise, search from the - * current item. - */ - // TODO: Think about getting rid of the bool parameter - // (see http://doc.qt.nokia.com/qq/qq13-apis.html#thebooleanparametertrap) - void changeCurrentItem(const QString& string, bool searchFromNextItem); - -private: - QString m_searchedString; - QElapsedTimer m_keyboardInputTime; - qint64 m_timeout; -}; - -#endif - - diff --git a/src/kitemviews/kitemlistrubberband_p.h b/src/kitemviews/kitemlistrubberband_p.h deleted file mode 100644 index aea58af46e..0000000000 --- a/src/kitemviews/kitemlistrubberband_p.h +++ /dev/null @@ -1,60 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2011 by Peter Penz * - * * - * 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 KITEMLISTRUBBERBAND_H -#define KITEMLISTRUBBERBAND_H - -#include -#include -#include - -/** - * @brief Manages the rubberband when selecting items. - */ -class LIBDOLPHINPRIVATE_EXPORT KItemListRubberBand : public QObject -{ - Q_OBJECT - -public: - explicit KItemListRubberBand(QObject* parent = 0); - virtual ~KItemListRubberBand(); - - void setStartPosition(const QPointF& pos); - QPointF startPosition() const; - - void setEndPosition(const QPointF& pos); - QPointF endPosition() const; - - void setActive(bool active); - bool isActive() const; - -signals: - void activationChanged(bool active); - void startPositionChanged(const QPointF& current, const QPointF& previous); - void endPositionChanged(const QPointF& current, const QPointF& previous); - -private: - bool m_active; - QPointF m_startPos; - QPointF m_endPos; -}; - -#endif - - diff --git a/src/kitemviews/kitemlistview.cpp b/src/kitemviews/kitemlistview.cpp index 1e68c2bd25..732ed24e48 100644 --- a/src/kitemviews/kitemlistview.cpp +++ b/src/kitemviews/kitemlistview.cpp @@ -24,14 +24,15 @@ #include "kitemlistcontroller.h" #include "kitemlistheader.h" -#include "kitemlistheaderwidget_p.h" -#include "kitemlistrubberband_p.h" #include "kitemlistselectionmanager.h" -#include "kitemlistsizehintresolver_p.h" -#include "kitemlistviewlayouter_p.h" -#include "kitemlistviewanimation_p.h" #include "kitemlistwidget.h" +#include "private/kitemlistheaderwidget.h" +#include "private/kitemlistrubberband.h" +#include "private/kitemlistsizehintresolver.h" +#include "private/kitemlistviewlayouter.h" +#include "private/kitemlistviewanimation.h" + #include #include diff --git a/src/kitemviews/kitemlistview.h b/src/kitemviews/kitemlistview.h index d65ece8e29..a3c11a6bf1 100644 --- a/src/kitemviews/kitemlistview.h +++ b/src/kitemviews/kitemlistview.h @@ -27,9 +27,9 @@ #include #include -#include #include #include +#include #include #include diff --git a/src/kitemviews/kitemlistwidget.cpp b/src/kitemviews/kitemlistwidget.cpp index b703fbfe23..74b96ca1f5 100644 --- a/src/kitemviews/kitemlistwidget.cpp +++ b/src/kitemviews/kitemlistwidget.cpp @@ -22,10 +22,11 @@ #include "kitemlistwidget.h" -#include "kitemlistselectiontoggle_p.h" #include "kitemlistview.h" #include "kitemmodelbase.h" +#include "private/kitemlistselectiontoggle.h" + #include #include diff --git a/src/kitemviews/kfileitemclipboard.cpp b/src/kitemviews/private/kfileitemclipboard.cpp similarity index 97% rename from src/kitemviews/kfileitemclipboard.cpp rename to src/kitemviews/private/kfileitemclipboard.cpp index fb63f95303..6d60856415 100644 --- a/src/kitemviews/kfileitemclipboard.cpp +++ b/src/kitemviews/private/kfileitemclipboard.cpp @@ -17,7 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ -#include "kfileitemclipboard_p.h" +#include "kfileitemclipboard.h" #include #include @@ -73,4 +73,4 @@ KFileItemClipboard::KFileItemClipboard() : this, SLOT(updateCutItems())); } -#include "kfileitemclipboard_p.moc" +#include "kfileitemclipboard.moc" diff --git a/src/kitemviews/kfileitemclipboard_p.h b/src/kitemviews/private/kfileitemclipboard.h similarity index 100% rename from src/kitemviews/kfileitemclipboard_p.h rename to src/kitemviews/private/kfileitemclipboard.h diff --git a/src/views/dolphindirlister.cpp b/src/kitemviews/private/kfileitemmodeldirlister.cpp similarity index 71% rename from src/views/dolphindirlister.cpp rename to src/kitemviews/private/kfileitemmodeldirlister.cpp index b62abe167b..be0f9f77b8 100644 --- a/src/views/dolphindirlister.cpp +++ b/src/kitemviews/private/kfileitemmodeldirlister.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006-2010 by Peter Penz * + * Copyright (C) 2006-2012 by Peter Penz * * * * 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 * @@ -17,32 +17,28 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ -#include "dolphindirlister.h" +#include "kfileitemmodeldirlister.h" #include #include -DolphinDirLister::DolphinDirLister(QObject* parent) : +KFileItemModelDirLister::KFileItemModelDirLister(QObject* parent) : KDirLister(parent) { setAutoErrorHandlingEnabled(false, 0); } -DolphinDirLister::~DolphinDirLister() +KFileItemModelDirLister::~KFileItemModelDirLister() { } -void DolphinDirLister::handleError(KIO::Job* job) +void KFileItemModelDirLister::handleError(KIO::Job* job) { - if (job->error() == KIO::ERR_IS_FILE) { - emit urlIsFileError(url()); + const QString errorString = job->errorString(); + if (errorString.isEmpty()) { + emit errorMessage(i18nc("@info:status", "Unknown error.")); } else { - const QString errorString = job->errorString(); - if (errorString.isEmpty()) { - emit errorMessage(i18nc("@info:status", "Unknown error.")); - } else { - emit errorMessage(errorString); - } + emit errorMessage(errorString); } } -#include "dolphindirlister.moc" +#include "kfileitemmodeldirlister.moc" diff --git a/src/views/dolphindirlister.h b/src/kitemviews/private/kfileitemmodeldirlister.h similarity index 81% rename from src/views/dolphindirlister.h rename to src/kitemviews/private/kfileitemmodeldirlister.h index 0955df2321..1d58347f47 100644 --- a/src/views/dolphindirlister.h +++ b/src/kitemviews/private/kfileitemmodeldirlister.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006-2009 by Peter Penz * + * Copyright (C) 2006-2012 by Peter Penz * * * * 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 * @@ -17,8 +17,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ -#ifndef DOLPHINDIRLISTER_H -#define DOLPHINDIRLISTER_H +#ifndef KFILEITEMMODELDIRLISTER_H +#define KFILEITEMMODELDIRLISTER_H #include #include @@ -26,22 +26,20 @@ /** * @brief Extends the class KDirLister by emitting a signal when an * error occurred instead of showing an error dialog. + * KDirLister::autoErrorHandlingEnabled() is set to false. */ -class LIBDOLPHINPRIVATE_EXPORT DolphinDirLister : public KDirLister +class LIBDOLPHINPRIVATE_EXPORT KFileItemModelDirLister : public KDirLister { Q_OBJECT public: - DolphinDirLister(QObject* parent = 0); - virtual ~DolphinDirLister(); + KFileItemModelDirLister(QObject* parent = 0); + virtual ~KFileItemModelDirLister(); 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); }; diff --git a/src/kitemviews/kfileitemmodelfilter.cpp b/src/kitemviews/private/kfileitemmodelfilter.cpp similarity index 98% rename from src/kitemviews/kfileitemmodelfilter.cpp rename to src/kitemviews/private/kfileitemmodelfilter.cpp index f3f47ba567..816d35634f 100644 --- a/src/kitemviews/kfileitemmodelfilter.cpp +++ b/src/kitemviews/private/kfileitemmodelfilter.cpp @@ -18,7 +18,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ -#include "kfileitemmodelfilter_p.h" +#include "kfileitemmodelfilter.h" #include #include diff --git a/src/kitemviews/kfileitemmodelfilter_p.h b/src/kitemviews/private/kfileitemmodelfilter.h similarity index 100% rename from src/kitemviews/kfileitemmodelfilter_p.h rename to src/kitemviews/private/kfileitemmodelfilter.h diff --git a/src/kitemviews/kfileitemmodelsortalgorithm.cpp b/src/kitemviews/private/kfileitemmodelsortalgorithm.cpp similarity index 99% rename from src/kitemviews/kfileitemmodelsortalgorithm.cpp rename to src/kitemviews/private/kfileitemmodelsortalgorithm.cpp index 4c2f29dee5..e0aac13de3 100644 --- a/src/kitemviews/kfileitemmodelsortalgorithm.cpp +++ b/src/kitemviews/private/kfileitemmodelsortalgorithm.cpp @@ -17,7 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ -#include "kfileitemmodelsortalgorithm_p.h" +#include "kfileitemmodelsortalgorithm.h" void KFileItemModelSortAlgorithm::sort(KFileItemModel* model, QList::iterator begin, diff --git a/src/kitemviews/kfileitemmodelsortalgorithm_p.h b/src/kitemviews/private/kfileitemmodelsortalgorithm.h similarity index 100% rename from src/kitemviews/kfileitemmodelsortalgorithm_p.h rename to src/kitemviews/private/kfileitemmodelsortalgorithm.h diff --git a/src/kitemviews/kitemlistheaderwidget.cpp b/src/kitemviews/private/kitemlistheaderwidget.cpp similarity index 99% rename from src/kitemviews/kitemlistheaderwidget.cpp rename to src/kitemviews/private/kitemlistheaderwidget.cpp index 2105b674c1..576516f252 100644 --- a/src/kitemviews/kitemlistheaderwidget.cpp +++ b/src/kitemviews/private/kitemlistheaderwidget.cpp @@ -17,11 +17,11 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ -#include "kitemlistheaderwidget_p.h" +#include "kitemlistheaderwidget.h" #include #include -#include "kitemmodelbase.h" +#include #include #include @@ -532,4 +532,4 @@ qreal KItemListHeaderWidget::roleXPosition(const QByteArray& role) const return -1; } -#include "kitemlistheaderwidget_p.moc" +#include "kitemlistheaderwidget.moc" diff --git a/src/kitemviews/kitemlistheaderwidget_p.h b/src/kitemviews/private/kitemlistheaderwidget.h similarity index 100% rename from src/kitemviews/kitemlistheaderwidget_p.h rename to src/kitemviews/private/kitemlistheaderwidget.h diff --git a/src/kitemviews/kitemlistkeyboardsearchmanager.cpp b/src/kitemviews/private/kitemlistkeyboardsearchmanager.cpp similarity index 98% rename from src/kitemviews/kitemlistkeyboardsearchmanager.cpp rename to src/kitemviews/private/kitemlistkeyboardsearchmanager.cpp index f4dc1a5474..2f4e93b1d8 100644 --- a/src/kitemviews/kitemlistkeyboardsearchmanager.cpp +++ b/src/kitemviews/private/kitemlistkeyboardsearchmanager.cpp @@ -20,7 +20,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ -#include "kitemlistkeyboardsearchmanager_p.h" +#include "kitemlistkeyboardsearchmanager.h" #include #include diff --git a/src/kitemviews/kitemlistrubberband.cpp b/src/kitemviews/private/kitemlistrubberband.cpp similarity index 97% rename from src/kitemviews/kitemlistrubberband.cpp rename to src/kitemviews/private/kitemlistrubberband.cpp index c1f276cdfe..ae023d2aac 100644 --- a/src/kitemviews/kitemlistrubberband.cpp +++ b/src/kitemviews/private/kitemlistrubberband.cpp @@ -17,7 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ -#include "kitemlistrubberband_p.h" +#include "kitemlistrubberband.h" KItemListRubberBand::KItemListRubberBand(QObject* parent) : QObject(parent), @@ -72,4 +72,4 @@ bool KItemListRubberBand::isActive() const return m_active; } -#include "kitemlistrubberband_p.moc" +#include "kitemlistrubberband.moc" diff --git a/src/kitemviews/kitemlistselectiontoggle.cpp b/src/kitemviews/private/kitemlistselectiontoggle.cpp similarity index 97% rename from src/kitemviews/kitemlistselectiontoggle.cpp rename to src/kitemviews/private/kitemlistselectiontoggle.cpp index 014f65b40d..66da6a727b 100644 --- a/src/kitemviews/kitemlistselectiontoggle.cpp +++ b/src/kitemviews/private/kitemlistselectiontoggle.cpp @@ -17,7 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ -#include "kitemlistselectiontoggle_p.h" +#include "kitemlistselectiontoggle.h" #include #include @@ -103,4 +103,4 @@ void KItemListSelectionToggle::updatePixmap() } } -#include "kitemlistselectiontoggle_p.moc" +#include "kitemlistselectiontoggle.moc" diff --git a/src/kitemviews/kitemlistselectiontoggle_p.h b/src/kitemviews/private/kitemlistselectiontoggle.h similarity index 100% rename from src/kitemviews/kitemlistselectiontoggle_p.h rename to src/kitemviews/private/kitemlistselectiontoggle.h diff --git a/src/kitemviews/kitemlistsizehintresolver.cpp b/src/kitemviews/private/kitemlistsizehintresolver.cpp similarity index 98% rename from src/kitemviews/kitemlistsizehintresolver.cpp rename to src/kitemviews/private/kitemlistsizehintresolver.cpp index 0520fac040..c76ff0f550 100644 --- a/src/kitemviews/kitemlistsizehintresolver.cpp +++ b/src/kitemviews/private/kitemlistsizehintresolver.cpp @@ -17,7 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ -#include "kitemlistsizehintresolver_p.h" +#include "kitemlistsizehintresolver.h" #include #include diff --git a/src/kitemviews/kitemlistsizehintresolver_p.h b/src/kitemviews/private/kitemlistsizehintresolver.h similarity index 100% rename from src/kitemviews/kitemlistsizehintresolver_p.h rename to src/kitemviews/private/kitemlistsizehintresolver.h diff --git a/src/kitemviews/kitemlistsmoothscroller.cpp b/src/kitemviews/private/kitemlistsmoothscroller.cpp similarity index 98% rename from src/kitemviews/kitemlistsmoothscroller.cpp rename to src/kitemviews/private/kitemlistsmoothscroller.cpp index 80f7f28837..6987e1ce13 100644 --- a/src/kitemviews/kitemlistsmoothscroller.cpp +++ b/src/kitemviews/private/kitemlistsmoothscroller.cpp @@ -17,7 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ -#include "kitemlistsmoothscroller_p.h" +#include "kitemlistsmoothscroller.h" #include #include @@ -204,4 +204,4 @@ void KItemListSmoothScroller::handleWheelEvent(QWheelEvent* event) event->accept(); } -#include "kitemlistsmoothscroller_p.moc" +#include "kitemlistsmoothscroller.moc" diff --git a/src/kitemviews/kitemlistsmoothscroller_p.h b/src/kitemviews/private/kitemlistsmoothscroller.h similarity index 100% rename from src/kitemviews/kitemlistsmoothscroller_p.h rename to src/kitemviews/private/kitemlistsmoothscroller.h diff --git a/src/kitemviews/kitemlistviewanimation.cpp b/src/kitemviews/private/kitemlistviewanimation.cpp similarity index 98% rename from src/kitemviews/kitemlistviewanimation.cpp rename to src/kitemviews/private/kitemlistviewanimation.cpp index 9184b7144f..e347c5bb11 100644 --- a/src/kitemviews/kitemlistviewanimation.cpp +++ b/src/kitemviews/private/kitemlistviewanimation.cpp @@ -17,9 +17,9 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ -#include "kitemlistviewanimation_p.h" +#include "kitemlistviewanimation.h" -#include "kitemlistview.h" +#include #include #include @@ -242,4 +242,4 @@ void KItemListViewAnimation::slotFinished() Q_ASSERT(false); } -#include "kitemlistviewanimation_p.moc" +#include "kitemlistviewanimation.moc" diff --git a/src/kitemviews/kitemlistviewanimation_p.h b/src/kitemviews/private/kitemlistviewanimation.h similarity index 100% rename from src/kitemviews/kitemlistviewanimation_p.h rename to src/kitemviews/private/kitemlistviewanimation.h diff --git a/src/kitemviews/kitemlistviewlayouter.cpp b/src/kitemviews/private/kitemlistviewlayouter.cpp similarity index 99% rename from src/kitemviews/kitemlistviewlayouter.cpp rename to src/kitemviews/private/kitemlistviewlayouter.cpp index 405837d238..c15b44e13b 100644 --- a/src/kitemviews/kitemlistviewlayouter.cpp +++ b/src/kitemviews/private/kitemlistviewlayouter.cpp @@ -17,10 +17,10 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ -#include "kitemlistviewlayouter_p.h" +#include "kitemlistviewlayouter.h" -#include "kitemmodelbase.h" -#include "kitemlistsizehintresolver_p.h" +#include +#include "kitemlistsizehintresolver.h" #include @@ -627,4 +627,4 @@ qreal KItemListViewLayouter::minimumGroupHeaderWidth() const return 100; } -#include "kitemlistviewlayouter_p.moc" +#include "kitemlistviewlayouter.moc" diff --git a/src/kitemviews/kitemlistviewlayouter_p.h b/src/kitemviews/private/kitemlistviewlayouter.h similarity index 100% rename from src/kitemviews/kitemlistviewlayouter_p.h rename to src/kitemviews/private/kitemlistviewlayouter.h diff --git a/src/kitemviews/knepomukdatamanagement_export_p.h b/src/kitemviews/private/knepomukdatamanagement_export.h similarity index 100% rename from src/kitemviews/knepomukdatamanagement_export_p.h rename to src/kitemviews/private/knepomukdatamanagement_export.h diff --git a/src/kitemviews/knepomukresourcewatcher_p.h b/src/kitemviews/private/knepomukresourcewatcher.h similarity index 99% rename from src/kitemviews/knepomukresourcewatcher_p.h rename to src/kitemviews/private/knepomukresourcewatcher.h index 9b4b8b71d2..3f6643fc8e 100644 --- a/src/kitemviews/knepomukresourcewatcher_p.h +++ b/src/kitemviews/private/knepomukresourcewatcher.h @@ -29,7 +29,7 @@ #include #include -#include "knepomukdatamanagement_export_p.h" +#include "knepomukdatamanagement_export.h" namespace Nepomuk { diff --git a/src/kitemviews/knepomukrolesprovider.cpp b/src/kitemviews/private/knepomukrolesprovider.cpp similarity index 99% rename from src/kitemviews/knepomukrolesprovider.cpp rename to src/kitemviews/private/knepomukrolesprovider.cpp index 25fb161212..7af887cbfb 100644 --- a/src/kitemviews/knepomukrolesprovider.cpp +++ b/src/kitemviews/private/knepomukrolesprovider.cpp @@ -17,7 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ -#include "knepomukrolesprovider_p.h" +#include "knepomukrolesprovider.h" #include #include diff --git a/src/kitemviews/knepomukrolesprovider_p.h b/src/kitemviews/private/knepomukrolesprovider.h similarity index 100% rename from src/kitemviews/knepomukrolesprovider_p.h rename to src/kitemviews/private/knepomukrolesprovider.h diff --git a/src/kitemviews/kpixmapmodifier.cpp b/src/kitemviews/private/kpixmapmodifier.cpp similarity index 99% rename from src/kitemviews/kpixmapmodifier.cpp rename to src/kitemviews/private/kpixmapmodifier.cpp index 475f36a64f..29aceb66b6 100644 --- a/src/kitemviews/kpixmapmodifier.cpp +++ b/src/kitemviews/private/kpixmapmodifier.cpp @@ -32,7 +32,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "kpixmapmodifier_p.h" +#include "kpixmapmodifier.h" #include #include diff --git a/src/kitemviews/kpixmapmodifier_p.h b/src/kitemviews/private/kpixmapmodifier.h similarity index 100% rename from src/kitemviews/kpixmapmodifier_p.h rename to src/kitemviews/private/kpixmapmodifier.h diff --git a/src/panels/folders/folderspanel.cpp b/src/panels/folders/folderspanel.cpp index 87b0297c27..2f9e1d323c 100644 --- a/src/panels/folders/folderspanel.cpp +++ b/src/panels/folders/folderspanel.cpp @@ -30,7 +30,6 @@ #include #include -#include #include #include @@ -50,7 +49,6 @@ FoldersPanel::FoldersPanel(QWidget* parent) : Panel(parent), m_updateCurrentItem(false), - m_dirLister(0), m_controller(0) { setLayoutDirection(Qt::LeftToRight); @@ -65,9 +63,6 @@ FoldersPanel::~FoldersPanel() m_controller->setView(0); delete view; } - - delete m_dirLister; - m_dirLister = 0; } void FoldersPanel::setShowHiddenFiles(bool show) @@ -116,7 +111,7 @@ bool FoldersPanel::urlChanged() return false; } - if (m_dirLister) { + if (m_controller) { loadTree(url()); } @@ -130,16 +125,10 @@ void FoldersPanel::showEvent(QShowEvent* event) return; } - if (!m_dirLister) { + if (!m_controller) { // Postpone the creating of the dir lister to the first show event. // This assures that no performance and memory overhead is given when the TreeView is not // used at all (see FoldersPanel::setUrl()). - m_dirLister = new KDirLister(); - m_dirLister->setAutoUpdate(true); - m_dirLister->setMainWindow(window()); - m_dirLister->setDelayedMimeTypes(true); - m_dirLister->setAutoErrorHandlingEnabled(false, this); - KFileItemListView* view = new KFileItemListView(); view->setWidgetCreator(new KItemListWidgetCreator()); @@ -158,12 +147,12 @@ void FoldersPanel::showEvent(QShowEvent* event) // opening the folders panel. view->setOpacity(0); - KFileItemModel* model = new KFileItemModel(m_dirLister, this); + KFileItemModel* model = new KFileItemModel(this); model->setShowFoldersOnly(true); model->setShowHiddenFiles(FoldersPanelSettings::hiddenFilesShown()); // Use a QueuedConnection to give the view the possibility to react first on the // finished loading. - connect(model, SIGNAL(loadingCompleted()), this, SLOT(slotLoadingCompleted()), Qt::QueuedConnection); + connect(model, SIGNAL(dirLoadingCompleted()), this, SLOT(slotLoadingCompleted()), Qt::QueuedConnection); KItemListContainer* container = new KItemListContainer(this); m_controller = container->controller(); @@ -305,7 +294,7 @@ void FoldersPanel::startFadeInAnimation() void FoldersPanel::loadTree(const KUrl& url) { - Q_ASSERT(m_dirLister); + Q_ASSERT(m_controller); m_updateCurrentItem = false; @@ -319,13 +308,12 @@ void FoldersPanel::loadTree(const KUrl& url) baseUrl.setPath(QString('/')); } - if (m_dirLister->url() != baseUrl) { + KFileItemModel* model = fileItemModel(); + if (model->dir() != baseUrl) { m_updateCurrentItem = true; - m_dirLister->stop(); - m_dirLister->openUrl(baseUrl, KDirLister::Reload); + model->refreshDir(baseUrl); } - KFileItemModel* model = fileItemModel(); const int index = model->index(url); if (index >= 0) { updateCurrentItem(index); diff --git a/src/panels/folders/folderspanel.h b/src/panels/folders/folderspanel.h index 44acfb88f2..babcde64a4 100644 --- a/src/panels/folders/folderspanel.h +++ b/src/panels/folders/folderspanel.h @@ -23,7 +23,6 @@ #include #include -class KDirLister; class KFileItemModel; class KItemListController; class QGraphicsSceneDragDropEvent; @@ -100,7 +99,6 @@ private: private: bool m_updateCurrentItem; - KDirLister* m_dirLister; KItemListController* m_controller; }; diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 43d1c9bf72..de254f6da9 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -49,7 +49,7 @@ target_link_libraries(kfileitemmodeltest dolphinprivate ${KDE4_KIO_LIBS} ${QT_QT # KItemListKeyboardSearchManagerTest set(kitemlistkeyboardsearchmanagertest_SRCS kitemlistkeyboardsearchmanagertest.cpp - ../kitemviews/kitemlistkeyboardsearchmanager.cpp + ../kitemviews/private/kitemlistkeyboardsearchmanager.cpp ) kde4_add_unit_test(kitemlistkeyboardsearchmanagertest TEST ${kitemlistkeyboardsearchmanagertest_SRCS}) target_link_libraries(kitemlistkeyboardsearchmanagertest ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY}) diff --git a/src/tests/kfileitemmodeltest.cpp b/src/tests/kfileitemmodeltest.cpp index cce92626dd..e96aee6d74 100644 --- a/src/tests/kfileitemmodeltest.cpp +++ b/src/tests/kfileitemmodeltest.cpp @@ -22,6 +22,7 @@ #include #include "kitemviews/kfileitemmodel.h" +#include "kitemviews/private/kfileitemmodeldirlister.h" #include "testdir.h" void myMessageOutput(QtMsgType type, const char* msg) @@ -62,7 +63,7 @@ private slots: void testDefaultGroupedSorting(); void testNewItems(); void testRemoveItems(); - void testLoadingCompleted(); + void testDirLoadingCompleted(); void testSetData(); void testSetDataWithModifiedSortRole_data(); void testSetDataWithModifiedSortRole(); @@ -82,7 +83,6 @@ private: private: KFileItemModel* m_model; - KDirLister* m_dirLister; TestDir* m_testDir; }; @@ -97,9 +97,8 @@ void KFileItemModelTest::init() qRegisterMetaType("KFileItemList"); m_testDir = new TestDir(); - m_dirLister = new KDirLister(); - m_dirLister->setAutoUpdate(false); - m_model = new KFileItemModel(m_dirLister); + m_model = new KFileItemModel(); + m_model->m_dirLister->setAutoUpdate(false); } void KFileItemModelTest::cleanup() @@ -107,9 +106,6 @@ void KFileItemModelTest::cleanup() delete m_model; m_model = 0; - delete m_dirLister; - m_dirLister = 0; - delete m_testDir; m_testDir = 0; } @@ -131,7 +127,7 @@ void KFileItemModelTest::testDefaultSortRole() m_testDir->createFiles(files); - m_dirLister->openUrl(m_testDir->url()); + m_model->loadDir(m_testDir->url()); QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); QCOMPARE(m_model->count(), 3); @@ -151,7 +147,7 @@ void KFileItemModelTest::testNewItems() files << "a.txt" << "b.txt" << "c.txt"; m_testDir->createFiles(files); - m_dirLister->openUrl(m_testDir->url()); + m_model->loadDir(m_testDir->url()); QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); QCOMPARE(m_model->count(), 3); @@ -163,36 +159,36 @@ void KFileItemModelTest::testRemoveItems() { m_testDir->createFile("a.txt"); m_testDir->createFile("b.txt"); - m_dirLister->openUrl(m_testDir->url()); + m_model->loadDir(m_testDir->url()); QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); QCOMPARE(m_model->count(), 2); QVERIFY(isModelConsistent()); m_testDir->removeFile("a.txt"); - m_dirLister->updateDirectory(m_testDir->url()); + m_model->m_dirLister->updateDirectory(m_testDir->url()); QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsRemoved(KItemRangeList)), DefaultTimeout)); QCOMPARE(m_model->count(), 1); QVERIFY(isModelConsistent()); } -void KFileItemModelTest::testLoadingCompleted() +void KFileItemModelTest::testDirLoadingCompleted() { - QSignalSpy loadingCompletedSpy(m_model, SIGNAL(loadingCompleted())); + QSignalSpy loadingCompletedSpy(m_model, SIGNAL(dirLoadingCompleted())); QSignalSpy itemsInsertedSpy(m_model, SIGNAL(itemsInserted(KItemRangeList))); QSignalSpy itemsRemovedSpy(m_model, SIGNAL(itemsRemoved(KItemRangeList))); m_testDir->createFiles(QStringList() << "a.txt" << "b.txt" << "c.txt"); - m_dirLister->openUrl(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(loadingCompleted()), DefaultTimeout)); + m_model->loadDir(m_testDir->url()); + QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(dirLoadingCompleted()), DefaultTimeout)); QCOMPARE(loadingCompletedSpy.count(), 1); QCOMPARE(itemsInsertedSpy.count(), 1); QCOMPARE(itemsRemovedSpy.count(), 0); QCOMPARE(m_model->count(), 3); m_testDir->createFiles(QStringList() << "d.txt" << "e.txt"); - m_dirLister->updateDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(loadingCompleted()), DefaultTimeout)); + m_model->m_dirLister->updateDirectory(m_testDir->url()); + QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(dirLoadingCompleted()), DefaultTimeout)); QCOMPARE(loadingCompletedSpy.count(), 2); QCOMPARE(itemsInsertedSpy.count(), 2); QCOMPARE(itemsRemovedSpy.count(), 0); @@ -200,15 +196,15 @@ void KFileItemModelTest::testLoadingCompleted() m_testDir->removeFile("a.txt"); m_testDir->createFile("f.txt"); - m_dirLister->updateDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(loadingCompleted()), DefaultTimeout)); + m_model->m_dirLister->updateDirectory(m_testDir->url()); + QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(dirLoadingCompleted()), DefaultTimeout)); QCOMPARE(loadingCompletedSpy.count(), 3); QCOMPARE(itemsInsertedSpy.count(), 3); QCOMPARE(itemsRemovedSpy.count(), 1); QCOMPARE(m_model->count(), 5); m_testDir->removeFile("b.txt"); - m_dirLister->updateDirectory(m_testDir->url()); + m_model->m_dirLister->updateDirectory(m_testDir->url()); QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsRemoved(KItemRangeList)), DefaultTimeout)); QCOMPARE(loadingCompletedSpy.count(), 4); QCOMPARE(itemsInsertedSpy.count(), 3); @@ -222,7 +218,7 @@ void KFileItemModelTest::testSetData() { m_testDir->createFile("a.txt"); - m_dirLister->openUrl(m_testDir->url()); + m_model->loadDir(m_testDir->url()); QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); QHash values; @@ -279,7 +275,7 @@ void KFileItemModelTest::testSetDataWithModifiedSortRole() files << "a.txt" << "b.txt" << "c.txt"; m_testDir->createFiles(files); - m_dirLister->openUrl(m_testDir->url()); + m_model->loadDir(m_testDir->url()); QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); // Fill the "rating" role of each file: @@ -331,7 +327,7 @@ void KFileItemModelTest::testModelConsistencyWhenInsertingItems() // KFileItemModel to do a lot of insert operation and hence decrease // the timeout to 1 millisecond. m_testDir->createFile("1"); - m_dirLister->openUrl(m_testDir->url()); + m_model->loadDir(m_testDir->url()); QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); QCOMPARE(m_model->count(), 1); @@ -351,7 +347,7 @@ void KFileItemModelTest::testModelConsistencyWhenInsertingItems() m_testDir->createFile(QString::number(itemName)); } - m_dirLister->updateDirectory(m_testDir->url()); + m_model->m_dirLister->updateDirectory(m_testDir->url()); if (spy.count() == 0) { QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); } @@ -371,7 +367,7 @@ void KFileItemModelTest::testItemRangeConsistencyWhenInsertingItems() // Due to inserting the 3 items one item-range with index == 0 and // count == 3 must be given QSignalSpy spy1(m_model, SIGNAL(itemsInserted(KItemRangeList))); - m_dirLister->openUrl(m_testDir->url()); + m_model->loadDir(m_testDir->url()); QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); QCOMPARE(spy1.count(), 1); @@ -396,7 +392,7 @@ void KFileItemModelTest::testItemRangeConsistencyWhenInsertingItems() m_testDir->createFiles(files); QSignalSpy spy2(m_model, SIGNAL(itemsInserted(KItemRangeList))); - m_dirLister->updateDirectory(m_testDir->url()); + m_model->m_dirLister->updateDirectory(m_testDir->url()); QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); QCOMPARE(spy2.count(), 1); @@ -424,7 +420,7 @@ void KFileItemModelTest::testExpandItems() QSet allFolders; allFolders << KUrl(m_testDir->name() + "a") << KUrl(m_testDir->name() + "a/a") << KUrl(m_testDir->name() + "a/a-1"); - m_dirLister->openUrl(m_testDir->url()); + m_model->loadDir(m_testDir->url()); QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); // So far, the model contains only "a/" @@ -496,9 +492,9 @@ void KFileItemModelTest::testExpandItems() QCOMPARE(m_model->count(), 0); QVERIFY(m_model->expandedUrls().empty()); - m_dirLister->openUrl(m_testDir->url()); + m_model->loadDir(m_testDir->url()); m_model->restoreExpandedUrls(allFolders); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(loadingCompleted()), DefaultTimeout)); + QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(dirLoadingCompleted()), DefaultTimeout)); QCOMPARE(m_model->count(), 5); // 5 items: "a/", "a/a/", "a/a/1", "a/a-1/", "a/a-1/1" QVERIFY(m_model->isExpanded(0)); QVERIFY(m_model->isExpanded(1)); @@ -509,12 +505,12 @@ void KFileItemModelTest::testExpandItems() // Move to a sub folder, then call restoreExpandedFolders() *before* going back. // This is how DolphinView restores the expanded folders when navigating in history. - m_dirLister->openUrl(KUrl(m_testDir->name() + "a/a/")); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(loadingCompleted()), DefaultTimeout)); + m_model->loadDir(KUrl(m_testDir->name() + "a/a/")); + QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(dirLoadingCompleted()), DefaultTimeout)); QCOMPARE(m_model->count(), 1); // 1 item: "1" m_model->restoreExpandedUrls(allFolders); - m_dirLister->openUrl(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(loadingCompleted()), DefaultTimeout)); + m_model->loadDir(m_testDir->url()); + QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(dirLoadingCompleted()), DefaultTimeout)); QCOMPARE(m_model->count(), 5); // 5 items: "a/", "a/a/", "a/a/1", "a/a-1/", "a/a-1/1" QCOMPARE(m_model->expandedUrls(), allFolders); } @@ -537,7 +533,7 @@ void KFileItemModelTest::testExpandParentItems() files << "a 1/b1/c1/file.txt" << "a2/b2/c2/d2/file.txt"; // missing folders are created automatically m_testDir->createFiles(files); - m_dirLister->openUrl(m_testDir->url()); + m_model->loadDir(m_testDir->url()); QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); // So far, the model contains only "a 1/" and "a2/". @@ -546,7 +542,7 @@ void KFileItemModelTest::testExpandParentItems() // Expand the parents of "a2/b2/c2". m_model->expandParentItems(KUrl(m_testDir->name() + "a2/b2/c2")); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(loadingCompleted()), DefaultTimeout)); + QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(dirLoadingCompleted()), DefaultTimeout)); // The model should now contain "a 1/", "a2/", "a2/b2/", and "a2/b2/c2/". // It's important that only the parents of "a1/b1/c1" are expanded. @@ -558,7 +554,7 @@ void KFileItemModelTest::testExpandParentItems() // Expand the parents of "a 1/b1". m_model->expandParentItems(KUrl(m_testDir->name() + "a 1/b1")); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(loadingCompleted()), DefaultTimeout)); + QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(dirLoadingCompleted()), DefaultTimeout)); // The model should now contain "a 1/", "a 1/b1/", "a2/", "a2/b2", and "a2/b2/c2/". // It's important that only the parents of "a 1/b1/" and "a2/b2/c2/" are expanded. @@ -593,7 +589,7 @@ void KFileItemModelTest::testSorting() m_testDir->createFile("e", "An even larger file", now.addDays(-4)); m_testDir->createFile(".f"); - m_dirLister->openUrl(m_testDir->url()); + m_model->loadDir(m_testDir->url()); QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); int index = m_model->index(KUrl(m_testDir->url().url() + "c")); @@ -705,7 +701,7 @@ void KFileItemModelTest::testIndexForKeyboardSearch() files << "a" << "aa" << "Image.jpg" << "Image.png" << "Text" << "Text1" << "Text2" << "Text11"; m_testDir->createFiles(files); - m_dirLister->openUrl(m_testDir->url()); + m_model->loadDir(m_testDir->url()); QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); // Search from index 0 @@ -755,7 +751,7 @@ void KFileItemModelTest::testNameFilter() files << "A1" << "A2" << "Abc" << "Bcd" << "Cde"; m_testDir->createFiles(files); - m_dirLister->openUrl(m_testDir->url()); + m_model->loadDir(m_testDir->url()); QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); m_model->setNameFilter("A"); // Shows A1, A2 and Abc diff --git a/src/tests/kitemlistcontrollertest.cpp b/src/tests/kitemlistcontrollertest.cpp index b446e84776..486ccd46a3 100644 --- a/src/tests/kitemlistcontrollertest.cpp +++ b/src/tests/kitemlistcontrollertest.cpp @@ -21,13 +21,12 @@ #include #include -#include #include "kitemviews/kitemlistcontainer.h" #include "kitemviews/kfileitemlistview.h" #include "kitemviews/kfileitemmodel.h" #include "kitemviews/kitemlistcontroller.h" #include "kitemviews/kitemlistselectionmanager.h" -#include "kitemviews/kitemlistviewlayouter_p.h" +#include "kitemviews/private/kitemlistviewlayouter.h" #include "testdir.h" namespace { @@ -65,7 +64,6 @@ private: KItemListController* m_controller; KItemListSelectionManager* m_selectionManager; KFileItemModel* m_model; - KDirLister* m_dirLister; TestDir* m_testDir; KItemListContainer* m_container; }; @@ -80,8 +78,7 @@ void KItemListControllerTest::initTestCase() qRegisterMetaType >("QSet"); m_testDir = new TestDir(); - m_dirLister = new KDirLister(); - m_model = new KFileItemModel(m_dirLister); + m_model = new KFileItemModel(); m_container = new KItemListContainer(); m_controller = m_container->controller(); m_controller->setSelectionBehavior(KItemListController::MultiSelection); @@ -100,8 +97,8 @@ void KItemListControllerTest::initTestCase() << "e1" << "e2" << "e3" << "e4" << "e5" << "e6" << "e7"; m_testDir->createFiles(files); - m_dirLister->openUrl(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(loadingCompleted()), DefaultTimeout)); + m_model->loadDir(m_testDir->url()); + QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(dirLoadingCompleted()), DefaultTimeout)); m_container->show(); QTest::qWaitForWindowShown(m_container); @@ -119,9 +116,6 @@ void KItemListControllerTest::cleanupTestCase() delete m_model; m_model = 0; - delete m_dirLister; - m_dirLister = 0; - delete m_testDir; m_testDir = 0; } diff --git a/src/tests/kitemlistkeyboardsearchmanagertest.cpp b/src/tests/kitemlistkeyboardsearchmanagertest.cpp index aeca1f7798..cf15324e27 100644 --- a/src/tests/kitemlistkeyboardsearchmanagertest.cpp +++ b/src/tests/kitemlistkeyboardsearchmanagertest.cpp @@ -19,7 +19,7 @@ #include -#include "kitemviews/kitemlistkeyboardsearchmanager_p.h" +#include "kitemviews/private/kitemlistkeyboardsearchmanager.h" class KItemListKeyboardSearchManagerTest : public QObject { diff --git a/src/views/dolphinitemlistcontainer.cpp b/src/views/dolphinitemlistcontainer.cpp index 5b7522f00a..e8c373492a 100644 --- a/src/views/dolphinitemlistcontainer.cpp +++ b/src/views/dolphinitemlistcontainer.cpp @@ -31,7 +31,6 @@ #include #include -#include #include #include @@ -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 c5a30ad74e..f3505b6636 100644 --- a/src/views/dolphinitemlistcontainer.h +++ b/src/views/dolphinitemlistcontainer.h @@ -26,7 +26,6 @@ #include -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 2ffc33e08f..137b73d090 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -35,7 +35,6 @@ #include #include -#include #include #include #include @@ -59,7 +58,6 @@ #include #include -#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 >)), - 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() << "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)), + 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(current)); - connect(current, SIGNAL(loadingCompleted()), this, SLOT(slotLoadingCompleted())); + connect(current, SIGNAL(loadingCompleted()), this, SLOT(slotDirLoadingCompleted())); KFileItemModel* fileItemModel = static_cast(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 b1d057e6f4..9c674d03a5 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; @@ -154,6 +153,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 ac47090690..bbabd2e4e1 100644 --- a/src/views/versioncontrol/versioncontrolobserver.cpp +++ b/src/views/versioncontrol/versioncontrolobserver.cpp @@ -21,7 +21,6 @@ #include "dolphin_versioncontrolsettings.h" -#include #include #include #include @@ -30,6 +29,7 @@ #include "updateitemstatesthread.h" +#include #include #include @@ -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;