┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2012-04-11 21:52:15 +0200
committerPeter Penz <[email protected]>2012-04-11 21:53:45 +0200
commit40c71d5ce0f6978ce48eb67fd73ed211bab4e887 (patch)
tree92f118d9f937dc94e0ea6f7c5ae0a6d19a900db5 /src/kitemviews
parentff0a86288e14f811a353f05e21898eef223525d2 (diff)
KFileItemModel: interface cleanups
Fix some naming inconsistencies regarding the usage of 'dir' vs. 'directory' vs. 'folder'.
Diffstat (limited to 'src/kitemviews')
-rw-r--r--src/kitemviews/kfileitemmodel.cpp64
-rw-r--r--src/kitemviews/kfileitemmodel.h81
-rw-r--r--src/kitemviews/kfileitemmodelrolesupdater.cpp2
3 files changed, 76 insertions, 71 deletions
diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp
index 409b5cd52..8b6522c07 100644
--- a/src/kitemviews/kfileitemmodel.cpp
+++ b/src/kitemviews/kfileitemmodel.cpp
@@ -37,7 +37,7 @@ KFileItemModel::KFileItemModel(QObject* parent) :
KItemModelBase("name", parent),
m_dirLister(0),
m_naturalSorting(KGlobalSettings::naturalSorting()),
- m_sortFoldersFirst(true),
+ m_sortDirsFirst(true),
m_sortRole(NameRole),
m_sortingProgressPercent(-1),
m_roles(),
@@ -52,14 +52,14 @@ KFileItemModel::KFileItemModel(QObject* parent) :
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)));
@@ -69,7 +69,7 @@ KFileItemModel::KFileItemModel(QObject* parent) :
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();
@@ -103,21 +103,26 @@ KFileItemModel::~KFileItemModel()
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();
@@ -167,17 +172,17 @@ bool KFileItemModel::setData(int index, const QHash<QByteArray, QVariant>& value
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)
@@ -194,12 +199,12 @@ bool KFileItemModel::showHiddenFiles() const
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();
}
@@ -403,10 +408,10 @@ bool KFileItemModel::setExpanded(int index, bool expanded)
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);
@@ -450,17 +455,17 @@ int KFileItemModel::expandedParentsCount(int index) const
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();
@@ -534,11 +539,6 @@ QString KFileItemModel::nameFilter() const
return m_filter.pattern();
}
-void KFileItemModel::cancelDirLoading()
-{
- m_dirLister->stop();
-}
-
QList<KFileItemModel::RoleInfo> KFileItemModel::rolesInformation()
{
static QList<RoleInfo> rolesInfo;
@@ -668,7 +668,7 @@ void KFileItemModel::slotCompleted()
m_urlsToExpand.clear();
}
- emit dirLoadingCompleted();
+ emit directoryLoadingCompleted();
}
void KFileItemModel::slotCanceled()
@@ -853,7 +853,7 @@ void KFileItemModel::slotClear()
emit itemsRemoved(KItemRangeList() << KItemRange(0, removedCount));
}
- m_expandedUrls.clear();
+ m_expandedDirs.clear();
}
void KFileItemModel::slotClear(const KUrl& url)
@@ -1089,7 +1089,7 @@ void KFileItemModel::removeExpandedItems()
removeItems(expandedItems);
m_expandedParentsCountRoot = UninitializedExpandedParentsCountRoot;
- m_expandedUrls.clear();
+ m_expandedDirs.clear();
}
void KFileItemModel::resetRoles()
@@ -1271,7 +1271,7 @@ bool KFileItemModel::lessThan(const ItemData* a, const ItemData* b) const
}
}
- 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) {
@@ -1459,7 +1459,7 @@ int KFileItemModel::expandedParentsCountCompare(const ItemData* a, const ItemDat
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) {
@@ -1854,14 +1854,14 @@ void KFileItemModel::emitSortProgress(int resolvedCount)
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);
}
}
}
diff --git a/src/kitemviews/kfileitemmodel.h b/src/kitemviews/kfileitemmodel.h
index 05834cd31..b29c76c92 100644
--- a/src/kitemviews/kfileitemmodel.h
+++ b/src/kitemviews/kfileitemmodel.h
@@ -34,13 +34,11 @@ class QTimer;
/**
* @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
@@ -53,17 +51,17 @@ public:
/**
* 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
@@ -71,27 +69,34 @@ public:
* 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;
@@ -146,7 +151,9 @@ public:
*/
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;
@@ -155,25 +162,23 @@ public:
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;
@@ -193,11 +198,11 @@ public:
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
@@ -206,20 +211,20 @@ signals:
* (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...")
@@ -237,7 +242,7 @@ signals:
* 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);
@@ -408,10 +413,10 @@ private:
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;
@@ -445,8 +450,8 @@ private:
};
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().
diff --git a/src/kitemviews/kfileitemmodelrolesupdater.cpp b/src/kitemviews/kfileitemmodelrolesupdater.cpp
index 927407a69..942db2bbd 100644
--- a/src/kitemviews/kfileitemmodelrolesupdater.cpp
+++ b/src/kitemviews/kfileitemmodelrolesupdater.cpp
@@ -1040,7 +1040,7 @@ KFileItemList KFileItemModelRolesUpdater::sortedItems(const QSet<KFileItem>& ite
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);