KItemViews: Internal directory restructuration

- Move all private headers from the kitemviews-directory into
the 'private' subdirectory.

- Get rid of DolphinDirLister and just use a directory-lister
  internally in KFileItemModel.

- Minor interface-cleanups for signals
This commit is contained in:
Peter Penz 2012-04-11 16:06:18 +02:00
parent d9dbd3398a
commit 6c3d9acbc2
58 changed files with 404 additions and 510 deletions

View file

@ -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)

View file

@ -2088,9 +2088,9 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container)
this, SLOT(openNewTab(KUrl)));
connect(view, SIGNAL(requestContextMenu(QPoint,KFileItem,KUrl,QList<QAction*>)),
this, SLOT(openContextMenu(QPoint,KFileItem,KUrl,QList<QAction*>)));
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()));

View file

@ -45,11 +45,11 @@
#include "views/dolphinviewactionhandler.h"
#include "views/dolphinnewfilemenuobserver.h"
#include "views/dolphinremoteencoding.h"
#include "views/dolphindirlister.h"
#include <QActionGroup>
#include <QApplication>
#include <QClipboard>
#include <QDir>
K_PLUGIN_FACTORY(DolphinPartFactory, registerPlugin<DolphinPart>();)
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");

View file

@ -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()) {

View file

@ -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.

View file

@ -23,9 +23,9 @@
#include "kfileitemmodelrolesupdater.h"
#include "kfileitemlistwidget.h"
#include "kfileitemmodel.h"
#include "kpixmapmodifier_p.h"
#include <KLocale>
#include <KStringHandler>
#include "private/kpixmapmodifier.h"
#include <KDebug>
#include <KIcon>

View file

@ -19,10 +19,8 @@
#include "kfileitemlistwidget.h"
#include "kfileitemclipboard_p.h"
#include "kfileitemlistview.h"
#include "kfileitemmodel.h"
#include "kpixmapmodifier_p.h"
#include <KIcon>
#include <KIconEffect>
@ -32,6 +30,9 @@
#include <KStringHandler>
#include <KDebug>
#include "private/kfileitemclipboard.h"
#include "private/kpixmapmodifier.h"
#include <QFontMetricsF>
#include <QGraphicsSceneResizeEvent>
#include <QPainter>
@ -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<KFileItemListWidget*>(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;
}

View file

@ -19,26 +19,27 @@
#include "kfileitemmodel.h"
#include <KDirLister>
#include <KDirModel>
#include "kfileitemmodelsortalgorithm_p.h"
#include <KGlobalSettings>
#include <KLocale>
#include <KStringHandler>
#include <KDebug>
#include "private/kfileitemmodelsortalgorithm.h"
#include "private/kfileitemmodeldirlister.h"
#include <QMimeData>
#include <QTimer>
// #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<QPair<KFileItem,KFileItem> >)), this, SLOT(slotRefreshItems(QList<QPair<KFileItem,KFileItem> >)));
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<QPair<KFileItem,KFileItem> >)), this, SLOT(slotRefreshItems(QList<QPair<KFileItem,KFileItem> >)));
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<int>& 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<KUrl>& 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::RoleInfo> KFileItemModel::rolesInformation()
{
static QList<RoleInfo> rolesInfo;
@ -666,7 +668,7 @@ void KFileItemModel::slotCompleted()
m_urlsToExpand.clear();
}
emit loadingCompleted();
emit dirLoadingCompleted();
}
void KFileItemModel::slotCanceled()
@ -1222,8 +1224,8 @@ QHash<QByteArray, QVariant> 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<QPair<int, QVariant> > 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);
}
}
}

View file

@ -23,12 +23,12 @@
#include <libdolphin_export.h>
#include <KFileItemList>
#include <KUrl>
#include <kitemviews/kfileitemmodelfilter_p.h>
#include <kitemviews/kitemmodelbase.h>
#include <kitemviews/private/kfileitemmodelfilter.h>
#include <QHash>
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<QByteArray, QVariant> data(int index) const;
virtual bool setData(int index, const QHash<QByteArray, QVariant>& 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<RoleInfo> 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<KDirLister> 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<QByteArray> m_roles;
Qt::CaseSensitivity m_caseSensitivity;

View file

@ -20,7 +20,6 @@
#include "kfileitemmodelrolesupdater.h"
#include "kfileitemmodel.h"
#include "kpixmapmodifier_p.h"
#include <KConfig>
#include <KConfigGroup>
@ -28,14 +27,17 @@
#include <KFileItem>
#include <KGlobal>
#include <KIO/PreviewJob>
#include "private/kpixmapmodifier.h"
#include <QPainter>
#include <QPixmap>
#include <QElapsedTimer>
#include <QTimer>
#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

View file

@ -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;

View file

@ -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 <QApplication>
#include <QGraphicsScene>
#include <QGraphicsView>

View file

@ -23,10 +23,14 @@
#include "kitemlistcontroller.h"
#include <KGlobalSettings>
#include <KDebug>
#include "kitemlistview.h"
#include "kitemlistrubberband_p.h"
#include "kitemlistselectionmanager.h"
#include "kitemlistkeyboardsearchmanager_p.h"
#include "private/kitemlistrubberband.h"
#include "private/kitemlistkeyboardsearchmanager.h"
#include <QApplication>
#include <QDrag>
@ -37,9 +41,6 @@
#include <QMimeData>
#include <QTimer>
#include <KGlobalSettings>
#include <KDebug>
KItemListController::KItemListController(QObject* parent) :
QObject(parent),
m_singleClickActivation(KGlobalSettings::singleClick()),

View file

@ -18,9 +18,10 @@
***************************************************************************/
#include "kitemlistheader.h"
#include "kitemlistheaderwidget_p.h"
#include "kitemlistview.h"
#include "private/kitemlistheaderwidget.h"
KItemListHeader::~KItemListHeader()
{
}

View file

@ -1,81 +0,0 @@
/***************************************************************************
* Copyright (C) 2011 by Tirtha Chatterjee <tirtha.p.chatterjee@gmail.com> *
* *
* Based on the Itemviews NG project from Trolltech Labs: *
* http://qt.gitorious.org/qt-labs/itemviews-ng *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#ifndef KITEMLISTKEYBOARDMANAGER_H
#define KITEMLISTKEYBOARDMANAGER_H
#include <libdolphin_export.h>
#include <QObject>
#include <QString>
#include <QElapsedTimer>
/**
* @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

View file

@ -1,60 +0,0 @@
/***************************************************************************
* Copyright (C) 2011 by Peter Penz <peter.penz19@gmail.com> *
* *
* 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 <libdolphin_export.h>
#include <QObject>
#include <QPointF>
/**
* @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

View file

@ -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 <KDebug>
#include <QCursor>

View file

@ -27,9 +27,9 @@
#include <kitemviews/kitemlistgroupheader.h>
#include <kitemviews/kitemliststyleoption.h>
#include <kitemviews/kitemlistviewanimation_p.h>
#include <kitemviews/kitemlistwidget.h>
#include <kitemviews/kitemmodelbase.h>
#include <kitemviews/private/kitemlistviewanimation.h>
#include <QGraphicsWidget>
#include <QSet>

View file

@ -22,10 +22,11 @@
#include "kitemlistwidget.h"
#include "kitemlistselectiontoggle_p.h"
#include "kitemlistview.h"
#include "kitemmodelbase.h"
#include "private/kitemlistselectiontoggle.h"
#include <KDebug>
#include <KGlobalSettings>

View file

@ -17,7 +17,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#include "kfileitemclipboard_p.h"
#include "kfileitemclipboard.h"
#include <KGlobal>
#include <QApplication>
@ -73,4 +73,4 @@ KFileItemClipboard::KFileItemClipboard() :
this, SLOT(updateCutItems()));
}
#include "kfileitemclipboard_p.moc"
#include "kfileitemclipboard.moc"

View file

@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2006-2010 by Peter Penz <peter.penz19@gmail.com> *
* Copyright (C) 2006-2012 by Peter Penz <peter.penz19@gmail.com> *
* *
* 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 <KLocale>
#include <KIO/JobClasses>
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"

View file

@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2006-2009 by Peter Penz <peter.penz19@gmail.com> *
* Copyright (C) 2006-2012 by Peter Penz <peter.penz19@gmail.com> *
* *
* 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 <libdolphin_export.h>
#include <KDirLister>
@ -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);
};

View file

@ -18,7 +18,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#include "kfileitemmodelfilter_p.h"
#include "kfileitemmodelfilter.h"
#include <KFileItem>
#include <QRegExp>

View file

@ -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<KFileItemModel::ItemData*>::iterator begin,

View file

@ -17,11 +17,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#include "kitemlistheaderwidget_p.h"
#include "kitemlistheaderwidget.h"
#include <KAction>
#include <KMenu>
#include "kitemmodelbase.h"
#include <kitemviews/kitemmodelbase.h>
#include <QApplication>
#include <QGraphicsSceneHoverEvent>
@ -532,4 +532,4 @@ qreal KItemListHeaderWidget::roleXPosition(const QByteArray& role) const
return -1;
}
#include "kitemlistheaderwidget_p.moc"
#include "kitemlistheaderwidget.moc"

View file

@ -20,7 +20,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#include "kitemlistkeyboardsearchmanager_p.h"
#include "kitemlistkeyboardsearchmanager.h"
#include <QApplication>
#include <QElapsedTimer>

View file

@ -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"

View file

@ -17,7 +17,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#include "kitemlistselectiontoggle_p.h"
#include "kitemlistselectiontoggle.h"
#include <KIconEffect>
#include <KIconLoader>
@ -103,4 +103,4 @@ void KItemListSelectionToggle::updatePixmap()
}
}
#include "kitemlistselectiontoggle_p.moc"
#include "kitemlistselectiontoggle.moc"

View file

@ -17,7 +17,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#include "kitemlistsizehintresolver_p.h"
#include "kitemlistsizehintresolver.h"
#include <kitemviews/kitemlistview.h>
#include <KDebug>

View file

@ -17,7 +17,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#include "kitemlistsmoothscroller_p.h"
#include "kitemlistsmoothscroller.h"
#include <KGlobalSettings>
#include <QEvent>
@ -204,4 +204,4 @@ void KItemListSmoothScroller::handleWheelEvent(QWheelEvent* event)
event->accept();
}
#include "kitemlistsmoothscroller_p.moc"
#include "kitemlistsmoothscroller.moc"

View file

@ -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 <kitemviews/kitemlistview.h>
#include <KDebug>
#include <KGlobalSettings>
@ -242,4 +242,4 @@ void KItemListViewAnimation::slotFinished()
Q_ASSERT(false);
}
#include "kitemlistviewanimation_p.moc"
#include "kitemlistviewanimation.moc"

View file

@ -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 <kitemviews/kitemmodelbase.h>
#include "kitemlistsizehintresolver.h"
#include <KDebug>
@ -627,4 +627,4 @@ qreal KItemListViewLayouter::minimumGroupHeaderWidth() const
return 100;
}
#include "kitemlistviewlayouter_p.moc"
#include "kitemlistviewlayouter.moc"

View file

@ -29,7 +29,7 @@
#include <QtDBus/QDBusVariant>
#include <QtCore/QVariant>
#include "knepomukdatamanagement_export_p.h"
#include "knepomukdatamanagement_export.h"
namespace Nepomuk {

View file

@ -17,7 +17,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#include "knepomukrolesprovider_p.h"
#include "knepomukrolesprovider.h"
#include <KDebug>
#include <KGlobal>

View file

@ -32,7 +32,7 @@
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "kpixmapmodifier_p.h"
#include "kpixmapmodifier.h"
#include <QImage>
#include <QPainter>

View file

@ -30,7 +30,6 @@
#include <kitemviews/kitemlistcontroller.h>
#include <kitemviews/kfileitemmodel.h>
#include <KDirLister>
#include <KFileItem>
#include <konq_operations.h>
@ -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<KFileItemListWidget>());
@ -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);

View file

@ -23,7 +23,6 @@
#include <KUrl>
#include <panels/panel.h>
class KDirLister;
class KFileItemModel;
class KItemListController;
class QGraphicsSceneDragDropEvent;
@ -100,7 +99,6 @@ private:
private:
bool m_updateCurrentItem;
KDirLister* m_dirLister;
KItemListController* m_controller;
};

View file

@ -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})

View file

@ -22,6 +22,7 @@
#include <KDirLister>
#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>("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<QByteArray, QVariant> 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<KUrl> 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

View file

@ -21,13 +21,12 @@
#include <qtestmouse.h>
#include <qtestkeyboard.h>
#include <KDirLister>
#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<int> >("QSet<int>");
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;
}

View file

@ -19,7 +19,7 @@
#include <qtest_kde.h>
#include "kitemviews/kitemlistkeyboardsearchmanager_p.h"
#include "kitemviews/private/kitemlistkeyboardsearchmanager.h"
class KItemListKeyboardSearchManagerTest : public QObject
{

View file

@ -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);

View file

@ -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();

View file

@ -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();

View file

@ -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;

View file

@ -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;