┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2012-04-11 16:42:46 +0200
committerPeter Penz <[email protected]>2012-04-11 16:43:11 +0200
commitb28a5a6248059566e16c9fcf887b5545034ba52f (patch)
tree0e0d81cf4727c479f44649ae3c02de598800698a
parent6c3d9acbc22ea9463ba40ef84c9e8c8419dfacf3 (diff)
Minor API-cleanups for DolphinView
-rw-r--r--src/dolphinmainwindow.cpp4
-rw-r--r--src/dolphinpart.cpp4
-rw-r--r--src/dolphinviewcontainer.cpp8
-rw-r--r--src/dolphinviewcontainer.h4
-rw-r--r--src/views/dolphinview.cpp49
-rw-r--r--src/views/dolphinview.h51
6 files changed, 46 insertions, 74 deletions
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp
index 22d8af3c3..9b2a1cea8 100644
--- a/src/dolphinmainwindow.cpp
+++ b/src/dolphinmainwindow.cpp
@@ -2088,9 +2088,9 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container)
this, SLOT(openNewTab(KUrl)));
connect(view, SIGNAL(requestContextMenu(QPoint,KFileItem,KUrl,QList<QAction*>)),
this, SLOT(openContextMenu(QPoint,KFileItem,KUrl,QList<QAction*>)));
- connect(view, SIGNAL(startedDirLoading(KUrl)),
+ connect(view, SIGNAL(dirLoadingStarted()),
this, SLOT(enableStopAction()));
- connect(view, SIGNAL(finishedDirLoading(KUrl)),
+ connect(view, SIGNAL(dirLoadingCompleted()),
this, SLOT(disableStopAction()));
connect(view, SIGNAL(goBackRequested()),
this, SLOT(goBack()));
diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp
index bb944bad0..4f89709d3 100644
--- a/src/dolphinpart.cpp
+++ b/src/dolphinpart.cpp
@@ -477,7 +477,7 @@ void DolphinPart::openSelectionDialog(const QString& title, const QString& text,
if (okClicked && !pattern.isEmpty()) {
QRegExp patternRegExp(pattern, Qt::CaseSensitive, QRegExp::Wildcard);
- m_view->setItemSelectionEnabled(patternRegExp, selectItems);
+ m_view->selectItems(patternRegExp, selectItems);
}
}
@@ -608,7 +608,7 @@ DolphinPart* DolphinPartFileInfoExtension::part() const
bool DolphinPartFileInfoExtension::hasSelection() const
{
- return part()->view()->hasSelection();
+ return part()->view()->selectedItemsCount() > 0;
}
KParts::FileInfoExtension::QueryModes DolphinPartFileInfoExtension::supportedQueryModes() const
diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp
index a6049992f..7b9152d1e 100644
--- a/src/dolphinviewcontainer.cpp
+++ b/src/dolphinviewcontainer.cpp
@@ -99,8 +99,8 @@ DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) :
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(dirLoadingStarted()), this, SLOT(slotDirLoadingStarted()));
+ connect(m_view, SIGNAL(dirLoadingCompleted()), this, SLOT(slotDirLoadingCompleted()));
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)));
@@ -348,7 +348,7 @@ void DolphinViewContainer::updateSortingProgress(int percent)
m_statusBar->setProgress(percent);
}
-void DolphinViewContainer::slotStartedDirLoading()
+void DolphinViewContainer::slotDirLoadingStarted()
{
if (isSearchUrl(url())) {
// Search KIO-slaves usually don't provide any progress information. Give
@@ -364,7 +364,7 @@ void DolphinViewContainer::slotStartedDirLoading()
}
}
-void DolphinViewContainer::slotFinishedDirLoading()
+void DolphinViewContainer::slotDirLoadingCompleted()
{
if (!m_statusBar->progressText().isEmpty()) {
m_statusBar->setProgressText(QString());
diff --git a/src/dolphinviewcontainer.h b/src/dolphinviewcontainer.h
index de3bd60a6..a853671db 100644
--- a/src/dolphinviewcontainer.h
+++ b/src/dolphinviewcontainer.h
@@ -162,13 +162,13 @@ private slots:
* Updates the statusbar to show an undetermined progress with the correct
* context information whether a searching or a directory loading is done.
*/
- void slotStartedDirLoading();
+ void slotDirLoadingStarted();
/**
* Assures that the viewport position is restored and updates the
* statusbar to reflect the current content.
*/
- void slotFinishedDirLoading();
+ void slotDirLoadingCompleted();
/**
* Handles clicking on an item. If the item is a directory, the
diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp
index 137b73d09..8171751e4 100644
--- a/src/views/dolphinview.cpp
+++ b/src/views/dolphinview.cpp
@@ -347,7 +347,7 @@ void DolphinView::markUrlAsCurrent(const KUrl& url)
m_currentItemUrl = url;
}
-void DolphinView::setItemSelectionEnabled(const QRegExp& pattern, bool enabled)
+void DolphinView::selectItems(const QRegExp& pattern, bool enabled)
{
const KItemListSelectionManager::SelectionMode mode = enabled
? KItemListSelectionManager::Select
@@ -490,23 +490,6 @@ QString DolphinView::nameFilter() const
return fileItemModel()->nameFilter();
}
-void DolphinView::calculateItemCount(int& fileCount,
- int& folderCount,
- KIO::filesize_t& totalFileSize) const
-{
- 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 {
- ++fileCount;
- totalFileSize += item.size();
- }
- }
-}
-
QString DolphinView::statusBarText() const
{
QString summary;
@@ -517,7 +500,7 @@ QString DolphinView::statusBarText() const
int fileCount = 0;
KIO::filesize_t totalFileSize = 0;
- if (hasSelection()) {
+ if (m_container->controller()->selectionManager()->hasSelection()) {
// Give a summary of the status of the selected files
const KFileItemList list = selectedItems();
foreach (const KFileItem& item, list) {
@@ -1120,11 +1103,6 @@ void DolphinView::saveState(QDataStream& stream)
stream << fileItemModel()->expandedUrls();
}
-bool DolphinView::hasSelection() const
-{
- return m_container->controller()->selectionManager()->hasSelection();
-}
-
KFileItem DolphinView::rootItem() const
{
return fileItemModel()->rootItem();
@@ -1209,6 +1187,23 @@ void DolphinView::hideToolTip()
}
}
+void DolphinView::calculateItemCount(int& fileCount,
+ int& folderCount,
+ KIO::filesize_t& totalFileSize) const
+{
+ 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 {
+ ++fileCount;
+ totalFileSize += item.size();
+ }
+ }
+}
+
void DolphinView::showHoverInformation(const KFileItem& item)
{
emit requestItemInfo(item);
@@ -1237,16 +1232,16 @@ void DolphinView::slotDirLoadingStarted()
emit writeStateChanged(m_isFolderWritable);
}
- emit startedDirLoading(url());
+ emit dirLoadingStarted();
}
void DolphinView::slotDirLoadingCompleted()
{
- // Update the view-state. This has to be done using a Qt::QueuedConnection
+ // 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 finishedDirLoading(url());
+ emit dirLoadingCompleted();
updateWritableState();
}
diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h
index 9c674d03a..b181ea3ab 100644
--- a/src/views/dolphinview.h
+++ b/src/views/dolphinview.h
@@ -189,7 +189,7 @@ public:
* All items that match to the pattern \a pattern will get selected
* if \a enabled is true and deselected if \a enabled is false.
*/
- void setItemSelectionEnabled(const QRegExp& pattern, bool enabled);
+ void selectItems(const QRegExp& pattern, bool enabled);
/**
* Sets the zoom level to \a level. It is assured that the used
@@ -199,18 +199,6 @@ public:
void setZoomLevel(int level);
int zoomLevel() const;
- /**
- * Returns true, if zooming in is possible. If false is returned,
- * the maximum zooming level has been reached.
- */
- bool isZoomInPossible() const;
-
- /**
- * Returns true, if zooming out is possible. If false is returned,
- * the minimum zooming level has been reached.
- */
- bool isZoomOutPossible() const;
-
void setSortRole(const QByteArray& role);
QByteArray sortRole() const;
@@ -227,9 +215,7 @@ public:
/** Returns the additional information which should be shown for the items. */
QList<QByteArray> visibleRoles() const;
- /** Reloads the current directory. */
void reload();
-
void stopLoading();
/**
@@ -251,16 +237,6 @@ public:
QString nameFilter() const;
/**
- * Calculates the number of currently shown files into
- * \a fileCount and the number of folders into \a folderCount.
- * The size of all files is written into \a totalFileSize.
- * It is recommend using this method instead of asking the
- * directory lister or the model directly, as it takes
- * filtering and hierarchical previews into account.
- */
- void calculateItemCount(int& fileCount, int& folderCount, KIO::filesize_t& totalFileSize) const;
-
- /**
* Returns a textual representation of the state of the current
* folder or selected items, suitable for use in the status bar.
*/
@@ -304,9 +280,6 @@ public:
*/
void saveState(QDataStream& stream);
- /** Returns true, if at least one item is selected. */
- bool hasSelection() const;
-
/**
* Returns the root item which represents the current URL.
*/
@@ -479,17 +452,17 @@ signals:
/**
* Is emitted after DolphinView::setUrl() has been invoked and
- * the directory \a url is currently loaded. If this signal is emitted,
+ * the current directory is loaded. If this signal is emitted,
* it is assured that the view contains already the correct root
* URL and property settings.
*/
- void startedDirLoading(const KUrl& url);
+ void dirLoadingStarted();
/**
* Is emitted after the directory triggered by DolphinView::setUrl()
* has been loaded.
*/
- void finishedDirLoading(const KUrl& url);
+ void dirLoadingCompleted();
/**
* Is emitted after DolphinView::setUrl() has been invoked and provides
@@ -504,12 +477,6 @@ signals:
void dirSortingProgress(int percent);
/**
- * Is emitted if the DolphinView::setUrl() is invoked but the URL is not
- * a directory.
- */
- void urlIsFileError(const KUrl& file);
-
- /**
* Emitted when the file-item-model emits redirection.
* Testcase: fish://localhost
*/
@@ -679,6 +646,16 @@ private slots:
void hideToolTip();
+ /**
+ * Calculates the number of currently shown files into
+ * \a fileCount and the number of folders into \a folderCount.
+ * The size of all files is written into \a totalFileSize.
+ * It is recommend using this method instead of asking the
+ * directory lister or the model directly, as it takes
+ * filtering and hierarchical previews into account.
+ */
+ void calculateItemCount(int& fileCount, int& folderCount, KIO::filesize_t& totalFileSize) const;
+
private:
KFileItemModel* fileItemModel() const;