Fix some naming inconsistencies regarding the usage of 'dir' vs.
'directory' vs. 'folder'.
this, SLOT(openNewTab(KUrl)));
connect(view, SIGNAL(requestContextMenu(QPoint,KFileItem,KUrl,QList<QAction*>)),
this, SLOT(openContextMenu(QPoint,KFileItem,KUrl,QList<QAction*>)));
- connect(view, SIGNAL(dirLoadingStarted()),
+ connect(view, SIGNAL(directoryLoadingStarted()),
this, SLOT(enableStopAction()));
- connect(view, SIGNAL(dirLoadingCompleted()),
+ connect(view, SIGNAL(directoryLoadingCompleted()),
this, SLOT(disableStopAction()));
connect(view, SIGNAL(goBackRequested()),
this, SLOT(goBack()));
setWidget(m_view);
connect(m_view, SIGNAL(finishedDirLoading(KUrl)), this, SLOT(slotCompleted(KUrl)));
- connect(m_view, SIGNAL(dirLoadingProgress(int)), this, SLOT(updateProgress(int)));
+ connect(m_view, SIGNAL(directoryLoadingProgress(int)), this, SLOT(updateProgress(int)));
connect(m_view, SIGNAL(errorMessage(QString)), this, SLOT(slotErrorMessage(QString)));
setXMLFile("dolphinpart.rc");
connect(m_view, SIGNAL(modeChanged(DolphinView::Mode,DolphinView::Mode)),
this, SIGNAL(viewModeChanged())); // relay signal
connect(m_view, SIGNAL(redirection(KUrl,KUrl)),
- this, SLOT(slotRedirection(KUrl,KUrl)));
+ this, SLOT(slotDirectoryRedirection(KUrl,KUrl)));
// Watch for changes that should result in updates to the
// status bar text.
actionGroups);
}
-void DolphinPart::slotRedirection(const KUrl& oldUrl, const KUrl& newUrl)
+void DolphinPart::slotDirectoryRedirection(const KUrl& oldUrl, const KUrl& newUrl)
{
//kDebug() << oldUrl << newUrl << "currentUrl=" << url();
if (oldUrl.equals(url(), KUrl::CompareWithoutTrailingSlash /* #207572 */)) {
* Testcase 1: fish://localhost
* Testcase 2: showing a directory that is being renamed by another window (#180156)
*/
- void slotRedirection(const KUrl& oldUrl, const KUrl& newUrl);
+ void slotDirectoryRedirection(const KUrl& oldUrl, const KUrl& newUrl);
/**
* Updates the state of the 'Edit' menu actions and emits
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(dirLoadingStarted()), this, SLOT(slotDirLoadingStarted()));
- connect(m_view, SIGNAL(dirLoadingCompleted()), this, SLOT(slotDirLoadingCompleted()));
+ connect(m_view, SIGNAL(directoryLoadingStarted()), this, SLOT(slotDirectoryLoadingStarted()));
+ connect(m_view, SIGNAL(directoryLoadingCompleted()), this, SLOT(slotDirectoryLoadingCompleted()));
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(directoryLoadingProgress(int)), this, SLOT(updateDirectoryLoadingProgress(int)));
+ connect(m_view, SIGNAL(directorySortingProgress(int)), this, SLOT(updateDirectorySortingProgress(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()));
}
}
-void DolphinViewContainer::updateDirLoadingProgress(int percent)
+void DolphinViewContainer::updateDirectoryLoadingProgress(int percent)
{
if (m_statusBar->progressText().isEmpty()) {
m_statusBar->setProgressText(i18nc("@info:progress", "Loading folder..."));
m_statusBar->setProgress(percent);
}
-void DolphinViewContainer::updateSortingProgress(int percent)
+void DolphinViewContainer::updateDirectorySortingProgress(int percent)
{
if (m_statusBar->progressText().isEmpty()) {
m_statusBar->setProgressText(i18nc("@info:progress", "Sorting..."));
m_statusBar->setProgress(percent);
}
-void DolphinViewContainer::slotDirLoadingStarted()
+void DolphinViewContainer::slotDirectoryLoadingStarted()
{
if (isSearchUrl(url())) {
// Search KIO-slaves usually don't provide any progress information. Give
// Trigger an undetermined progress indication. The progress
// information in percent will be triggered by the percent() signal
// of the directory lister later.
- updateDirLoadingProgress(-1);
+ updateDirectoryLoadingProgress(-1);
}
}
-void DolphinViewContainer::slotDirLoadingCompleted()
+void DolphinViewContainer::slotDirectoryLoadingCompleted()
{
if (!m_statusBar->progressText().isEmpty()) {
m_statusBar->setProgressText(QString());
*/
void updateStatusBar();
- void updateDirLoadingProgress(int percent);
+ void updateDirectoryLoadingProgress(int percent);
- void updateSortingProgress(int percent);
+ void updateDirectorySortingProgress(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 slotDirLoadingStarted();
+ void slotDirectoryLoadingStarted();
/**
* Assures that the viewport position is restored and updates the
* statusbar to reflect the current content.
*/
- void slotDirLoadingCompleted();
+ void slotDirectoryLoadingCompleted();
/**
* Handles clicking on an item. If the item is a directory, the
KItemModelBase("name", parent),
m_dirLister(0),
m_naturalSorting(KGlobalSettings::naturalSorting()),
- m_sortFoldersFirst(true),
+ m_sortDirsFirst(true),
m_sortRole(NameRole),
m_sortingProgressPercent(-1),
m_roles(),
m_pendingItemsToInsert(),
m_groups(),
m_expandedParentsCountRoot(UninitializedExpandedParentsCountRoot),
- m_expandedUrls(),
+ m_expandedDirs(),
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(started(KUrl)), this, SIGNAL(directoryLoadingStarted()));
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(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)));
+ connect(m_dirLister, SIGNAL(redirection(KUrl,KUrl)), this, SIGNAL(directoryRedirection(KUrl,KUrl)));
// Apply default roles that should be determined
resetRoles();
m_itemData.clear();
}
-void KFileItemModel::loadDir(const KUrl& url)
+void KFileItemModel::loadDirectory(const KUrl& url)
{
m_dirLister->openUrl(url);
}
-void KFileItemModel::refreshDir(const KUrl& url)
+void KFileItemModel::refreshDirectory(const KUrl& url)
{
m_dirLister->openUrl(url, KDirLister::Reload);
}
-KUrl KFileItemModel::dir() const
+KUrl KFileItemModel::directory() const
{
return m_dirLister->url();
}
+void KFileItemModel::cancelDirectoryLoading()
+{
+ m_dirLister->stop();
+}
+
int KFileItemModel::count() const
{
return m_itemData.count();
return true;
}
-void KFileItemModel::setSortFoldersFirst(bool foldersFirst)
+void KFileItemModel::setSortDirectoriesFirst(bool dirsFirst)
{
- if (foldersFirst != m_sortFoldersFirst) {
- m_sortFoldersFirst = foldersFirst;
+ if (dirsFirst != m_sortDirsFirst) {
+ m_sortDirsFirst = dirsFirst;
resortAllItems();
}
}
-bool KFileItemModel::sortFoldersFirst() const
+bool KFileItemModel::sortDirectoriesFirst() const
{
- return m_sortFoldersFirst;
+ return m_sortDirsFirst;
}
void KFileItemModel::setShowHiddenFiles(bool show)
return m_dirLister->showingDotFiles();
}
-void KFileItemModel::setShowFoldersOnly(bool enabled)
+void KFileItemModel::setShowDirectoriesOnly(bool enabled)
{
m_dirLister->setDirOnlyMode(enabled);
}
-bool KFileItemModel::showFoldersOnly() const
+bool KFileItemModel::showDirectoriesOnly() const
{
return m_dirLister->dirOnlyMode();
}
const KUrl url = m_itemData.at(index)->item.url();
if (expanded) {
- m_expandedUrls.insert(url);
+ m_expandedDirs.insert(url);
m_dirLister->openUrl(url, KDirLister::Keep);
} else {
- m_expandedUrls.remove(url);
+ m_expandedDirs.remove(url);
m_dirLister->stop(url);
return 0;
}
-QSet<KUrl> KFileItemModel::expandedUrls() const
+QSet<KUrl> KFileItemModel::expandedDirectories() const
{
- return m_expandedUrls;
+ return m_expandedDirs;
}
-void KFileItemModel::restoreExpandedUrls(const QSet<KUrl>& urls)
+void KFileItemModel::restoreExpandedDirectories(const QSet<KUrl>& urls)
{
m_urlsToExpand = urls;
}
-void KFileItemModel::expandParentItems(const KUrl& url)
+void KFileItemModel::expandParentDirectories(const KUrl& url)
{
const int pos = m_dirLister->url().path().length();
return m_filter.pattern();
}
-void KFileItemModel::cancelDirLoading()
-{
- m_dirLister->stop();
-}
-
QList<KFileItemModel::RoleInfo> KFileItemModel::rolesInformation()
{
static QList<RoleInfo> rolesInfo;
m_urlsToExpand.clear();
}
- emit dirLoadingCompleted();
+ emit directoryLoadingCompleted();
}
void KFileItemModel::slotCanceled()
emit itemsRemoved(KItemRangeList() << KItemRange(0, removedCount));
}
- m_expandedUrls.clear();
+ m_expandedDirs.clear();
}
void KFileItemModel::slotClear(const KUrl& url)
removeItems(expandedItems);
m_expandedParentsCountRoot = UninitializedExpandedParentsCountRoot;
- m_expandedUrls.clear();
+ m_expandedDirs.clear();
}
void KFileItemModel::resetRoles()
}
}
- if (m_sortFoldersFirst || m_sortRole == SizeRole) {
+ if (m_sortDirsFirst || m_sortRole == SizeRole) {
const bool isDirA = a->item.isDir();
const bool isDirB = b->item.isDir();
if (isDirA && !isDirB) {
bool isDirB = true;
const QString subPathB = subPath(b->item, pathB, index, &isDirB);
- if (m_sortFoldersFirst || m_sortRole == SizeRole) {
+ if (m_sortDirsFirst || m_sortRole == SizeRole) {
if (isDirA && !isDirB) {
return (sortOrder() == Qt::AscendingOrder) ? -1 : +1;
} else if (!isDirA && isDirB) {
resortAllItems();
}
- emit dirSortingProgress(100);
+ emit directorySortingProgress(100);
} else if (itemCount > 0) {
resolvedCount = qBound(0, resolvedCount, itemCount);
const int progress = resolvedCount * 100 / itemCount;
if (m_sortingProgressPercent != progress) {
m_sortingProgressPercent = progress;
- emit dirSortingProgress(progress);
+ emit directorySortingProgress(progress);
}
}
}
/**
* @brief KItemModelBase implementation for KFileItems.
*
- * KFileItemModel is connected with one KDirLister. Each time the KDirLister
- * emits new items, removes items or changes items the model gets synchronized.
+ * Allows to load items of a directory. Sorting and grouping of
+ * items are supported. Roles that are not part of KFileItem can
+ * be added with KFileItemModel::setData().
*
- * KFileItemModel supports sorting and grouping of items. Additional roles that
- * are not part of KFileItem can be added with KFileItemModel::setData().
- *
- * Also the recursive expansion of sub-directories is supported by
+ * Recursive expansion of sub-directories is supported by
* KFileItemModel::setExpanded().
*/
class LIBDOLPHINPRIVATE_EXPORT KFileItemModel : public KItemModelBase
/**
* Loads the directory specified by \a url. The signals
- * dirLoadingStarted(), dirLoadingProgress() and dirLoadingCompleted()
+ * directoryLoadingStarted(), directoryLoadingProgress() and directoryLoadingCompleted()
* 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);
+ void loadDirectory(const KUrl& url);
/**
* Throws away all currently loaded items and refreshes the directory
* by reloading all items again.
*/
- void refreshDir(const KUrl& url);
+ void refreshDirectory(const KUrl& url);
/**
* @return Parent directory of the items that are shown. In case
* the root-parent of all items.
* @see rootItem()
*/
- KUrl dir() const;
+ KUrl directory() const;
+
+ /**
+ * Cancels the loading of a directory which has been started by either
+ * loadDirectory() or refreshDirectory().
+ */
+ void cancelDirectoryLoading();
virtual int count() const;
virtual QHash<QByteArray, QVariant> data(int index) const;
virtual bool setData(int index, const QHash<QByteArray, QVariant>& values);
/**
- * Sets a separate sorting with folders first (true) or a mixed sorting of files and folders (false).
+ * Sets a separate sorting with directories first (true) or a mixed
+ * sorting of files and directories (false).
*/
- void setSortFoldersFirst(bool foldersFirst);
- bool sortFoldersFirst() const;
+ void setSortDirectoriesFirst(bool dirsFirst);
+ bool sortDirectoriesFirst() const;
void setShowHiddenFiles(bool show);
bool showHiddenFiles() const;
/**
- * If set to true, only folders are shown as items of the model. Files
+ * If set to true, only directories are shown as items of the model. Files
* are ignored.
*/
- void setShowFoldersOnly(bool enabled);
- bool showFoldersOnly() const;
+ void setShowDirectoriesOnly(bool enabled);
+ bool showDirectoriesOnly() const;
/** @reimp */
virtual QMimeData* createMimeData(const QSet<int>& indexes) const;
*/
void clear();
- // TODO: "name" + "isDir" is default in ctor
+ /**
+ * Sets the roles that should be shown for each item.
+ */
void setRoles(const QSet<QByteArray>& roles);
QSet<QByteArray> roles() const;
virtual bool isExpandable(int index) const;
virtual int expandedParentsCount(int index) const;
- QSet<KUrl> expandedUrls() const;
+ QSet<KUrl> expandedDirectories() const;
/**
- * Marks the URLs in \a urls as subfolders which were expanded previously.
- * They are re-expanded one by one each time the KDirLister's completed() signal is received.
- * Note that a manual triggering of the KDirLister is required.
+ * Marks the URLs in \a urls as sub-directories which were expanded previously.
+ * After calling loadDirectory() or refreshDirectory() the marked sub-directories
+ * will be expanded step-by-step.
*/
- void restoreExpandedUrls(const QSet<KUrl>& urls);
+ void restoreExpandedDirectories(const QSet<KUrl>& urls);
/**
- * Expands all parent-items of \a url.
+ * Expands all parent-directories of the item \a url.
*/
- void expandParentItems(const KUrl& url);
+ void expandParentDirectories(const KUrl& url);
void setNameFilter(const QString& nameFilter);
QString nameFilter() const;
- void cancelDirLoading();
-
struct RoleInfo
{ QByteArray role;
QString translation;
signals:
/**
* Is emitted if the loading of a directory has been started. It is
- * assured that a signal dirLoadingCompleted() will be send after
+ * assured that a signal directoryLoadingCompleted() will be send after
* the loading has been finished. For tracking the loading progress
- * the signal dirLoadingProgress() gets emitted in between.
+ * the signal directoryLoadingProgress() gets emitted in between.
*/
- void dirLoadingStarted();
+ void directoryLoadingStarted();
/**
* Is emitted after the loading of a directory has been completed or new
* (the only exception is loading an empty directory, where only a
* loadingCompleted() signal gets emitted).
*/
- void dirLoadingCompleted();
+ void directoryLoadingCompleted();
/**
* Informs about the progress in percent when loading a directory. It is assured
- * that the signal dirLoadingStarted() has been emitted before.
+ * that the signal directoryLoadingStarted() has been emitted before.
*/
- void dirLoadingProgress(int percent);
+ void directoryLoadingProgress(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 dirSortingProgress(int percent);
+ void directorySortingProgress(int percent);
/**
* Is emitted if an information message (e.g. "Connecting to host...")
* 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);
+ void directoryRedirection(const KUrl& oldUrl, const KUrl& newUrl);
protected:
virtual void onGroupedSortingChanged(bool current);
KFileItemModelDirLister* m_dirLister;
bool m_naturalSorting;
- bool m_sortFoldersFirst;
+ bool m_sortDirsFirst;
RoleType m_sortRole;
- int m_sortingProgressPercent; // Value of dirSortingProgress() signal
+ int m_sortingProgressPercent; // Value of directorySortingProgress() signal
QSet<QByteArray> m_roles;
Qt::CaseSensitivity m_caseSensitivity;
};
mutable int m_expandedParentsCountRoot;
- // Stores the URLs of the expanded folders.
- QSet<KUrl> m_expandedUrls;
+ // Stores the URLs of the expanded directories.
+ QSet<KUrl> m_expandedDirs;
// URLs that must be expanded. The expanding is initially triggered in setExpanded()
// and done step after step in slotCompleted().
int KFileItemModelRolesUpdater::subItemsCount(const QString& path) const
{
const bool countHiddenFiles = m_model->showHiddenFiles();
- const bool showFoldersOnly = m_model->showFoldersOnly();
+ const bool showFoldersOnly = m_model->showDirectoriesOnly();
#ifdef Q_WS_WIN
QDir dir(path);
view->setOpacity(0);
KFileItemModel* model = new KFileItemModel(this);
- model->setShowFoldersOnly(true);
+ model->setShowDirectoriesOnly(true);
model->setShowHiddenFiles(FoldersPanelSettings::hiddenFilesShown());
// Use a QueuedConnection to give the view the possibility to react first on the
// finished loading.
- connect(model, SIGNAL(dirLoadingCompleted()), this, SLOT(slotLoadingCompleted()), Qt::QueuedConnection);
+ connect(model, SIGNAL(directoryLoadingCompleted()), this, SLOT(slotLoadingCompleted()), Qt::QueuedConnection);
KItemListContainer* container = new KItemListContainer(this);
m_controller = container->controller();
}
KFileItemModel* model = fileItemModel();
- if (model->dir() != baseUrl) {
+ if (model->directory() != baseUrl) {
m_updateCurrentItem = true;
- model->refreshDir(baseUrl);
+ model->refreshDirectory(baseUrl);
}
const int index = model->index(url);
updateCurrentItem(index);
} else {
m_updateCurrentItem = true;
- model->expandParentItems(url);
+ model->expandParentDirectories(url);
// slotLoadingCompleted() will be invoked after the model has
// expanded the url
}
m_testDir->createFiles(files);
- m_model->loadDir(m_testDir->url());
+ m_model->loadDirectory(m_testDir->url());
QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
QCOMPARE(m_model->count(), 3);
files << "a.txt" << "b.txt" << "c.txt";
m_testDir->createFiles(files);
- m_model->loadDir(m_testDir->url());
+ m_model->loadDirectory(m_testDir->url());
QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
QCOMPARE(m_model->count(), 3);
{
m_testDir->createFile("a.txt");
m_testDir->createFile("b.txt");
- m_model->loadDir(m_testDir->url());
+ m_model->loadDirectory(m_testDir->url());
QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
QCOMPARE(m_model->count(), 2);
QVERIFY(isModelConsistent());
void KFileItemModelTest::testDirLoadingCompleted()
{
- QSignalSpy loadingCompletedSpy(m_model, SIGNAL(dirLoadingCompleted()));
+ QSignalSpy loadingCompletedSpy(m_model, SIGNAL(directoryLoadingCompleted()));
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_model->loadDir(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(dirLoadingCompleted()), DefaultTimeout));
+ m_model->loadDirectory(m_testDir->url());
+ QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(directoryLoadingCompleted()), DefaultTimeout));
QCOMPARE(loadingCompletedSpy.count(), 1);
QCOMPARE(itemsInsertedSpy.count(), 1);
QCOMPARE(itemsRemovedSpy.count(), 0);
m_testDir->createFiles(QStringList() << "d.txt" << "e.txt");
m_model->m_dirLister->updateDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(dirLoadingCompleted()), DefaultTimeout));
+ QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(directoryLoadingCompleted()), DefaultTimeout));
QCOMPARE(loadingCompletedSpy.count(), 2);
QCOMPARE(itemsInsertedSpy.count(), 2);
QCOMPARE(itemsRemovedSpy.count(), 0);
m_testDir->removeFile("a.txt");
m_testDir->createFile("f.txt");
m_model->m_dirLister->updateDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(dirLoadingCompleted()), DefaultTimeout));
+ QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(directoryLoadingCompleted()), DefaultTimeout));
QCOMPARE(loadingCompletedSpy.count(), 3);
QCOMPARE(itemsInsertedSpy.count(), 3);
QCOMPARE(itemsRemovedSpy.count(), 1);
{
m_testDir->createFile("a.txt");
- m_model->loadDir(m_testDir->url());
+ m_model->loadDirectory(m_testDir->url());
QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
QHash<QByteArray, QVariant> values;
files << "a.txt" << "b.txt" << "c.txt";
m_testDir->createFiles(files);
- m_model->loadDir(m_testDir->url());
+ m_model->loadDirectory(m_testDir->url());
QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
// Fill the "rating" role of each file:
// KFileItemModel to do a lot of insert operation and hence decrease
// the timeout to 1 millisecond.
m_testDir->createFile("1");
- m_model->loadDir(m_testDir->url());
+ m_model->loadDirectory(m_testDir->url());
QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
QCOMPARE(m_model->count(), 1);
// 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_model->loadDir(m_testDir->url());
+ m_model->loadDirectory(m_testDir->url());
QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
QCOMPARE(spy1.count(), 1);
QSet<KUrl> allFolders;
allFolders << KUrl(m_testDir->name() + "a") << KUrl(m_testDir->name() + "a/a") << KUrl(m_testDir->name() + "a/a-1");
- m_model->loadDir(m_testDir->url());
+ m_model->loadDirectory(m_testDir->url());
QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
// So far, the model contains only "a/"
QCOMPARE(m_model->count(), 1);
QVERIFY(m_model->isExpandable(0));
QVERIFY(!m_model->isExpanded(0));
- QVERIFY(m_model->expandedUrls().empty());
+ QVERIFY(m_model->expandedDirectories().empty());
QSignalSpy spyInserted(m_model, SIGNAL(itemsInserted(KItemRangeList)));
QVERIFY(m_model->isExpanded(0));
QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
QCOMPARE(m_model->count(), 3); // 3 items: "a/", "a/a/", "a/a-1/"
- QCOMPARE(m_model->expandedUrls(), QSet<KUrl>() << KUrl(m_testDir->name() + "a"));
+ QCOMPARE(m_model->expandedDirectories(), QSet<KUrl>() << KUrl(m_testDir->name() + "a"));
QCOMPARE(spyInserted.count(), 1);
KItemRangeList itemRangeList = spyInserted.takeFirst().at(0).value<KItemRangeList>();
QVERIFY(m_model->isExpanded(1));
QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
QCOMPARE(m_model->count(), 4); // 4 items: "a/", "a/a/", "a/a/1", "a/a-1/"
- QCOMPARE(m_model->expandedUrls(), QSet<KUrl>() << KUrl(m_testDir->name() + "a") << KUrl(m_testDir->name() + "a/a"));
+ QCOMPARE(m_model->expandedDirectories(), QSet<KUrl>() << KUrl(m_testDir->name() + "a") << KUrl(m_testDir->name() + "a/a"));
QCOMPARE(spyInserted.count(), 1);
itemRangeList = spyInserted.takeFirst().at(0).value<KItemRangeList>();
QVERIFY(m_model->isExpanded(3));
QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), 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);
+ QCOMPARE(m_model->expandedDirectories(), allFolders);
QCOMPARE(spyInserted.count(), 1);
itemRangeList = spyInserted.takeFirst().at(0).value<KItemRangeList>();
m_model->setExpanded(0, false);
QVERIFY(!m_model->isExpanded(0));
QCOMPARE(m_model->count(), 1);
- QVERIFY(!m_model->expandedUrls().contains(KUrl(m_testDir->name() + "a"))); // TODO: Make sure that child URLs are also removed
+ QVERIFY(!m_model->expandedDirectories().contains(KUrl(m_testDir->name() + "a"))); // TODO: Make sure that child URLs are also removed
QCOMPARE(spyRemoved.count(), 1);
itemRangeList = spyRemoved.takeFirst().at(0).value<KItemRangeList>();
// Clear the model, reload the folder and try to restore the expanded folders.
m_model->clear();
QCOMPARE(m_model->count(), 0);
- QVERIFY(m_model->expandedUrls().empty());
+ QVERIFY(m_model->expandedDirectories().empty());
- m_model->loadDir(m_testDir->url());
- m_model->restoreExpandedUrls(allFolders);
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(dirLoadingCompleted()), DefaultTimeout));
+ m_model->loadDirectory(m_testDir->url());
+ m_model->restoreExpandedDirectories(allFolders);
+ QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(directoryLoadingCompleted()), 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));
QVERIFY(!m_model->isExpanded(2));
QVERIFY(m_model->isExpanded(3));
QVERIFY(!m_model->isExpanded(4));
- QCOMPARE(m_model->expandedUrls(), allFolders);
+ QCOMPARE(m_model->expandedDirectories(), allFolders);
// Move to a sub folder, then call restoreExpandedFolders() *before* going back.
// This is how DolphinView restores the expanded folders when navigating in history.
- m_model->loadDir(KUrl(m_testDir->name() + "a/a/"));
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(dirLoadingCompleted()), DefaultTimeout));
+ m_model->loadDirectory(KUrl(m_testDir->name() + "a/a/"));
+ QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(directoryLoadingCompleted()), DefaultTimeout));
QCOMPARE(m_model->count(), 1); // 1 item: "1"
- m_model->restoreExpandedUrls(allFolders);
- m_model->loadDir(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(dirLoadingCompleted()), DefaultTimeout));
+ m_model->restoreExpandedDirectories(allFolders);
+ m_model->loadDirectory(m_testDir->url());
+ QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(directoryLoadingCompleted()), 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);
+ QCOMPARE(m_model->expandedDirectories(), allFolders);
}
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_model->loadDir(m_testDir->url());
+ m_model->loadDirectory(m_testDir->url());
QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
// So far, the model contains only "a 1/" and "a2/".
QCOMPARE(m_model->count(), 2);
- QVERIFY(m_model->expandedUrls().empty());
+ QVERIFY(m_model->expandedDirectories().empty());
// Expand the parents of "a2/b2/c2".
- m_model->expandParentItems(KUrl(m_testDir->name() + "a2/b2/c2"));
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(dirLoadingCompleted()), DefaultTimeout));
+ m_model->expandParentDirectories(KUrl(m_testDir->name() + "a2/b2/c2"));
+ QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(directoryLoadingCompleted()), 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.
QVERIFY(!m_model->isExpanded(3));
// Expand the parents of "a 1/b1".
- m_model->expandParentItems(KUrl(m_testDir->name() + "a 1/b1"));
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(dirLoadingCompleted()), DefaultTimeout));
+ m_model->expandParentDirectories(KUrl(m_testDir->name() + "a 1/b1"));
+ QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(directoryLoadingCompleted()), 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.
m_testDir->createFile("e", "An even larger file", now.addDays(-4));
m_testDir->createFile(".f");
- m_model->loadDir(m_testDir->url());
+ m_model->loadDirectory(m_testDir->url());
QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
int index = m_model->index(KUrl(m_testDir->url().url() + "c"));
// Default: Sort by Name, ascending
QCOMPARE(m_model->sortRole(), QByteArray("name"));
QCOMPARE(m_model->sortOrder(), Qt::AscendingOrder);
- QVERIFY(m_model->sortFoldersFirst());
+ QVERIFY(m_model->sortDirectoriesFirst());
QVERIFY(!m_model->showHiddenFiles());
QCOMPARE(itemsInModel(), QStringList() << "c" << "c-2" << "c-3" << "c-1" << "a" << "b" << "d" << "e");
QSignalSpy spyItemsMoved(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)));
// Sort by Name, ascending, 'Sort Folders First' disabled
- m_model->setSortFoldersFirst(false);
+ m_model->setSortDirectoriesFirst(false);
QCOMPARE(m_model->sortRole(), QByteArray("name"));
QCOMPARE(m_model->sortOrder(), Qt::AscendingOrder);
QCOMPARE(itemsInModel(), QStringList() << "a" << "b" << "c" << "c-1" << "c-2" << "c-3" << "d" << "e");
QCOMPARE(spyItemsMoved.takeFirst().at(1).value<QList<int> >(), QList<int>() << 2 << 4 << 5 << 3 << 0 << 1 << 6 << 7);
// Sort by Name, descending
- m_model->setSortFoldersFirst(true);
+ m_model->setSortDirectoriesFirst(true);
m_model->setSortOrder(Qt::DescendingOrder);
QCOMPARE(m_model->sortRole(), QByteArray("name"));
QCOMPARE(m_model->sortOrder(), Qt::DescendingOrder);
QCOMPARE(spyItemsMoved.takeFirst().at(1).value<QList<int> >(), QList<int>() << 0 << 1 << 2 << 3 << 7 << 6 << 5 << 4);
// Sort by Date, descending
- m_model->setSortFoldersFirst(true);
+ m_model->setSortDirectoriesFirst(true);
m_model->setSortRole("date");
QCOMPARE(m_model->sortRole(), QByteArray("date"));
QCOMPARE(m_model->sortOrder(), Qt::DescendingOrder);
QCOMPARE(spyItemsMoved.takeFirst().at(1).value<QList<int> >(), QList<int>() << 0 << 1 << 2 << 3 << 7 << 6 << 5 << 4);
// Sort by Date, ascending, 'Sort Folders First' disabled
- m_model->setSortFoldersFirst(false);
+ m_model->setSortDirectoriesFirst(false);
QCOMPARE(m_model->sortRole(), QByteArray("date"));
QCOMPARE(m_model->sortOrder(), Qt::AscendingOrder);
- QVERIFY(!m_model->sortFoldersFirst());
+ QVERIFY(!m_model->sortDirectoriesFirst());
QCOMPARE(itemsInModel(), QStringList() << "e" << "a" << "c" << "c-1" << "c-2" << "c-3" << "d" << "b");
QCOMPARE(spyItemsMoved.count(), 1);
QCOMPARE(spyItemsMoved.takeFirst().at(1).value<QList<int> >(), QList<int>() << 2 << 4 << 5 << 3 << 0 << 1 << 6 << 7);
// Sort by Name, ascending, 'Sort Folders First' disabled
m_model->setSortRole("name");
QCOMPARE(m_model->sortOrder(), Qt::AscendingOrder);
- QVERIFY(!m_model->sortFoldersFirst());
+ QVERIFY(!m_model->sortDirectoriesFirst());
QCOMPARE(itemsInModel(), QStringList() << "a" << "b" << "c" << "c-1" << "c-2" << "c-3" << "d" << "e");
QCOMPARE(spyItemsMoved.count(), 1);
QCOMPARE(spyItemsMoved.takeFirst().at(1).value<QList<int> >(), QList<int>() << 7 << 0 << 2 << 3 << 4 << 5 << 6 << 1);
m_model->setSortRole("size");
QCOMPARE(m_model->sortRole(), QByteArray("size"));
QCOMPARE(m_model->sortOrder(), Qt::AscendingOrder);
- QVERIFY(!m_model->sortFoldersFirst());
+ QVERIFY(!m_model->sortDirectoriesFirst());
QCOMPARE(itemsInModel(), QStringList() << "c" << "c-2" << "c-3" << "c-1" << "a" << "b" << "e" << "d");
QCOMPARE(spyItemsMoved.count(), 1);
QCOMPARE(spyItemsMoved.takeFirst().at(1).value<QList<int> >(), QList<int>() << 4 << 5 << 0 << 3 << 1 << 2 << 7 << 6);
// Internal note: Check comment in KFileItemModel::resortAllItems() for details.
// In 'Sort by Size' mode, folders are always first -> changing 'Sort Folders First' does not resort the model
- m_model->setSortFoldersFirst(true);
+ m_model->setSortDirectoriesFirst(true);
QCOMPARE(m_model->sortRole(), QByteArray("size"));
QCOMPARE(m_model->sortOrder(), Qt::AscendingOrder);
- QVERIFY(m_model->sortFoldersFirst());
+ QVERIFY(m_model->sortDirectoriesFirst());
QCOMPARE(itemsInModel(), QStringList() << "c" << "a" << "b" << "e" << "d");
QCOMPARE(spyItemsMoved.count(), 0);
m_model->setSortOrder(Qt::DescendingOrder);
QCOMPARE(m_model->sortRole(), QByteArray("size"));
QCOMPARE(m_model->sortOrder(), Qt::DescendingOrder);
- QVERIFY(m_model->sortFoldersFirst());
+ QVERIFY(m_model->sortDirectoriesFirst());
QCOMPARE(itemsInModel(), QStringList() << "c" << "d" << "e" << "b" << "a");
QCOMPARE(spyItemsMoved.count(), 1);
QCOMPARE(spyItemsMoved.takeFirst().at(1).value<QList<int> >(), QList<int>() << 0 << 4 << 3 << 2 << 1);
files << "a" << "aa" << "Image.jpg" << "Image.png" << "Text" << "Text1" << "Text2" << "Text11";
m_testDir->createFiles(files);
- m_model->loadDir(m_testDir->url());
+ m_model->loadDirectory(m_testDir->url());
QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
// Search from index 0
files << "A1" << "A2" << "Abc" << "Bcd" << "Cde";
m_testDir->createFiles(files);
- m_model->loadDir(m_testDir->url());
+ m_model->loadDirectory(m_testDir->url());
QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
m_model->setNameFilter("A"); // Shows A1, A2 and Abc
<< "e1" << "e2" << "e3" << "e4" << "e5" << "e6" << "e7";
m_testDir->createFiles(files);
- m_model->loadDir(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(dirLoadingCompleted()), DefaultTimeout));
+ m_model->loadDirectory(m_testDir->url());
+ QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(directoryLoadingCompleted()), DefaultTimeout));
m_container->show();
QTest::qWaitForWindowShown(m_container);
connect(controller, SIGNAL(modelChanged(KItemModelBase*,KItemModelBase*)), this, SLOT(slotModelChanged(KItemModelBase*,KItemModelBase*)));
KFileItemModel* model = fileItemModel();
- 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(directoryLoadingStarted()), this, SLOT(slotDirectoryLoadingStarted()));
+ connect(model, SIGNAL(directoryLoadingCompleted()), this, SLOT(slotDirectoryLoadingCompleted()));
+ connect(model, SIGNAL(directoryLoadingProgress(int)), this, SIGNAL(directoryLoadingProgress(int)));
+ connect(model, SIGNAL(directorySortingProgress(int)), this, SIGNAL(directorySortingProgress(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)));
+ 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(directoryRedirection(KUrl,KUrl)), this, SLOT(slotDirectoryRedirection(KUrl,KUrl)));
KItemListView* view = controller->view();
view->installEventFilter(this);
bool DolphinView::sortFoldersFirst() const
{
KFileItemModel* model = fileItemModel();
- return model->sortFoldersFirst();
+ return model->sortDirectoriesFirst();
}
void DolphinView::setVisibleRoles(const QList<QByteArray>& roles)
void DolphinView::stopLoading()
{
- fileItemModel()->cancelDirLoading();
+ fileItemModel()->cancelDirectoryLoading();
}
void DolphinView::readSettings()
void DolphinView::slotModelChanged(KItemModelBase* current, KItemModelBase* previous)
{
if (previous != 0) {
- disconnect(previous, SIGNAL(dirLoadingCompleted()), this, SLOT(slotDirLoadingCompleted()));
+ disconnect(previous, SIGNAL(directoryLoadingCompleted()), this, SLOT(slotDirectoryLoadingCompleted()));
}
Q_ASSERT(qobject_cast<KFileItemModel*>(current));
- connect(current, SIGNAL(loadingCompleted()), this, SLOT(slotDirLoadingCompleted()));
+ connect(current, SIGNAL(loadingCompleted()), this, SLOT(slotDirectoryLoadingCompleted()));
KFileItemModel* fileItemModel = static_cast<KFileItemModel*>(current);
m_versionControlObserver->setModel(fileItemModel);
props.setSortFoldersFirst(foldersFirst);
KFileItemModel* model = fileItemModel();
- model->setSortFoldersFirst(foldersFirst);
+ model->setSortDirectoriesFirst(foldersFirst);
emit sortFoldersFirstChanged(foldersFirst);
}
// Restore expanded folders (only relevant for the details view - will be ignored by the view in other view modes)
QSet<KUrl> urls;
stream >> urls;
- fileItemModel()->restoreExpandedUrls(urls);
+ fileItemModel()->restoreExpandedDirectories(urls);
}
void DolphinView::saveState(QDataStream& stream)
stream << QPoint(x, y);
// Save expanded folders (only relevant for the details view - the set will be empty in other view modes)
- stream << fileItemModel()->expandedUrls();
+ stream << fileItemModel()->expandedDirectories();
}
KFileItem DolphinView::rootItem() const
m_createdItemUrl = KUrl();
}
-void DolphinView::slotRedirection(const KUrl& oldUrl, const KUrl& newUrl)
+void DolphinView::slotDirectoryRedirection(const KUrl& oldUrl, const KUrl& newUrl)
{
if (oldUrl.equals(url(), KUrl::CompareWithoutTrailingSlash)) {
emit redirection(oldUrl, newUrl);
}
}
-void DolphinView::slotDirLoadingStarted()
+void DolphinView::slotDirectoryLoadingStarted()
{
// Disable the writestate temporary until it can be determined in a fast way
// in DolphinView::slotLoadingCompleted()
emit writeStateChanged(m_isFolderWritable);
}
- emit dirLoadingStarted();
+ emit directoryLoadingStarted();
}
-void DolphinView::slotDirLoadingCompleted()
+void DolphinView::slotDirectoryLoadingCompleted()
{
// Update the view-state. This has to be done asynchronously
// because the view might not be in its final state yet.
QTimer::singleShot(0, this, SLOT(updateViewState()));
- emit dirLoadingCompleted();
+ emit directoryLoadingCompleted();
updateWritableState();
}
KFileItemModel* model = fileItemModel();
if (reload) {
- model->refreshDir(url);
+ model->refreshDirectory(url);
} else {
- model->loadDir(url);
+ model->loadDirectory(url);
}
}
}
const bool sortFoldersFirst = props.sortFoldersFirst();
- if (sortFoldersFirst != model->sortFoldersFirst()) {
- model->setSortFoldersFirst(sortFoldersFirst);
+ if (sortFoldersFirst != model->sortDirectoriesFirst()) {
+ model->setSortDirectoriesFirst(sortFoldersFirst);
emit sortFoldersFirstChanged(sortFoldersFirst);
}
* it is assured that the view contains already the correct root
* URL and property settings.
*/
- void dirLoadingStarted();
+ void directoryLoadingStarted();
/**
* Is emitted after the directory triggered by DolphinView::setUrl()
* has been loaded.
*/
- void dirLoadingCompleted();
+ void directoryLoadingCompleted();
/**
* Is emitted after DolphinView::setUrl() has been invoked and provides
* the information how much percent of the current directory have been loaded.
*/
- void dirLoadingProgress(int percent);
+ void directoryLoadingProgress(int percent);
/**
* Is emitted if the sorting is done asynchronously and provides the
* progress information of the sorting.
*/
- void dirSortingProgress(int percent);
+ void directorySortingProgress(int percent);
/**
* Emitted when the file-item-model emits redirection.
* Invoked when the file item model has started the loading
* of the directory specified by DolphinView::url().
*/
- void slotDirLoadingStarted();
+ void slotDirectoryLoadingStarted();
/**
* 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 slotDirLoadingCompleted();
+ void slotDirectoryLoadingCompleted();
/**
* Is invoked when items of KFileItemModel have been changed.
* Called when a redirection happens.
* Testcase: fish://localhost
*/
- void slotRedirection(const KUrl& oldUrl, const KUrl& newUrl);
+ void slotDirectoryRedirection(const KUrl& oldUrl, const KUrl& newUrl);
/**
* Applies the state that has been restored by restoreViewState()