diff options
Diffstat (limited to 'src/views')
| -rw-r--r-- | src/views/dolphinitemlistview.cpp | 21 | ||||
| -rw-r--r-- | src/views/dolphinitemlistview.h | 1 | ||||
| -rw-r--r-- | src/views/dolphinnewfilemenuobserver.cpp | 10 | ||||
| -rw-r--r-- | src/views/dolphinnewfilemenuobserver.h | 7 | ||||
| -rw-r--r-- | src/views/dolphinview.cpp | 46 | ||||
| -rw-r--r-- | src/views/dolphinview.h | 9 |
6 files changed, 46 insertions, 48 deletions
diff --git a/src/views/dolphinitemlistview.cpp b/src/views/dolphinitemlistview.cpp index 039b5f230..4799d7679 100644 --- a/src/views/dolphinitemlistview.cpp +++ b/src/views/dolphinitemlistview.cpp @@ -89,10 +89,7 @@ void DolphinItemListView::readSettings() beginTransaction(); setEnabledSelectionToggles(GeneralSettings::showSelectionToggle()); - - const bool expandableFolders = (itemLayout() == KFileItemListView::DetailsLayout) && - DetailsModeSettings::expandableFolders(); - setSupportsItemExpanding(expandableFolders); + setSupportsItemExpanding(itemLayoutSupportsItemExpanding(itemLayout())); updateFont(); updateGridSize(); @@ -119,19 +116,19 @@ KItemListWidgetCreatorBase* DolphinItemListView::defaultWidgetCreator() const return new KItemListWidgetCreator<DolphinFileItemListWidget>(); } -void DolphinItemListView::onItemLayoutChanged(ItemLayout current, ItemLayout previous) +bool DolphinItemListView::itemLayoutSupportsItemExpanding(ItemLayout layout) const { - Q_UNUSED(previous); + return layout == DetailsLayout && DetailsModeSettings::expandableFolders(); +} - if (current == DetailsLayout) { - setSupportsItemExpanding(DetailsModeSettings::expandableFolders()); - setHeaderVisible(true); - } else { - setHeaderVisible(false); - } +void DolphinItemListView::onItemLayoutChanged(ItemLayout current, ItemLayout previous) +{ + setHeaderVisible(current == DetailsLayout); updateFont(); updateGridSize(); + + KFileItemListView::onItemLayoutChanged(current, previous); } void DolphinItemListView::onPreviewsShownChanged(bool shown) diff --git a/src/views/dolphinitemlistview.h b/src/views/dolphinitemlistview.h index c2d86cc5e..18bb284ac 100644 --- a/src/views/dolphinitemlistview.h +++ b/src/views/dolphinitemlistview.h @@ -50,6 +50,7 @@ public: protected: virtual KItemListWidgetCreatorBase* defaultWidgetCreator() const; + virtual bool itemLayoutSupportsItemExpanding(ItemLayout layout) const; virtual void onItemLayoutChanged(ItemLayout current, ItemLayout previous); virtual void onPreviewsShownChanged(bool shown); virtual void onVisibleRolesChanged(const QList<QByteArray>& current, diff --git a/src/views/dolphinnewfilemenuobserver.cpp b/src/views/dolphinnewfilemenuobserver.cpp index 1cb5739d7..7669f1561 100644 --- a/src/views/dolphinnewfilemenuobserver.cpp +++ b/src/views/dolphinnewfilemenuobserver.cpp @@ -20,7 +20,7 @@ #include "dolphinnewfilemenuobserver.h" #include <KGlobal> -#include <KNewFileMenu> +#include "dolphinnewfilemenu.h" class DolphinNewFileMenuObserverSingleton { @@ -34,20 +34,24 @@ DolphinNewFileMenuObserver& DolphinNewFileMenuObserver::instance() return s_DolphinNewFileMenuObserver->instance; } -void DolphinNewFileMenuObserver::attach(const KNewFileMenu* menu) +void DolphinNewFileMenuObserver::attach(const DolphinNewFileMenu* menu) { connect(menu, SIGNAL(fileCreated(KUrl)), this, SIGNAL(itemCreated(KUrl))); connect(menu, SIGNAL(directoryCreated(KUrl)), this, SIGNAL(itemCreated(KUrl))); + connect(menu, SIGNAL(errorMessage(QString)), + this, SIGNAL(errorMessage(QString))); } -void DolphinNewFileMenuObserver::detach(const KNewFileMenu* menu) +void DolphinNewFileMenuObserver::detach(const DolphinNewFileMenu* menu) { disconnect(menu, SIGNAL(fileCreated(KUrl)), this, SIGNAL(itemCreated(KUrl))); disconnect(menu, SIGNAL(directoryCreated(KUrl)), this, SIGNAL(itemCreated(KUrl))); + disconnect(menu, SIGNAL(errorMessage(QString)), + this, SIGNAL(errorMessage(QString))); } DolphinNewFileMenuObserver::DolphinNewFileMenuObserver() : diff --git a/src/views/dolphinnewfilemenuobserver.h b/src/views/dolphinnewfilemenuobserver.h index 726122cbc..239476eb9 100644 --- a/src/views/dolphinnewfilemenuobserver.h +++ b/src/views/dolphinnewfilemenuobserver.h @@ -24,7 +24,7 @@ #include "libdolphin_export.h" -class KNewFileMenu; +class DolphinNewFileMenu; class KUrl; /** @@ -40,11 +40,12 @@ class LIBDOLPHINPRIVATE_EXPORT DolphinNewFileMenuObserver : public QObject public: static DolphinNewFileMenuObserver& instance(); - void attach(const KNewFileMenu* menu); - void detach(const KNewFileMenu* menu); + void attach(const DolphinNewFileMenu* menu); + void detach(const DolphinNewFileMenu* menu); signals: void itemCreated(const KUrl& url); + void errorMessage(const QString& error); private: DolphinNewFileMenuObserver(); diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 20bc9f522..d0a85b3e2 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -145,7 +145,7 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) : controller->setSelectionBehavior(KItemListController::MultiSelection); connect(controller, SIGNAL(itemActivated(int)), this, SLOT(slotItemActivated(int))); - connect(controller, SIGNAL(itemsActivated(QSet<int>)), this, SLOT(slotItemsActivated(QSet<int>))); + connect(controller, SIGNAL(itemsActivated(KItemSet)), this, SLOT(slotItemsActivated(KItemSet))); connect(controller, SIGNAL(itemMiddleClicked(int)), this, SLOT(slotItemMiddleClicked(int))); connect(controller, SIGNAL(itemContextMenuRequested(int,QPointF)), this, SLOT(slotItemContextMenuRequested(int,QPointF))); connect(controller, SIGNAL(viewContextMenuRequested(QPointF)), this, SLOT(slotViewContextMenuRequested(QPointF))); @@ -154,6 +154,7 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) : connect(controller, SIGNAL(itemHovered(int)), this, SLOT(slotItemHovered(int))); connect(controller, SIGNAL(itemUnhovered(int)), this, SLOT(slotItemUnhovered(int))); connect(controller, SIGNAL(itemDropEvent(int,QGraphicsSceneDragDropEvent*)), this, SLOT(slotItemDropEvent(int,QGraphicsSceneDragDropEvent*))); + connect(controller, SIGNAL(escapePressed()), this, SLOT(stopLoading())); connect(controller, SIGNAL(modelChanged(KItemModelBase*,KItemModelBase*)), this, SLOT(slotModelChanged(KItemModelBase*,KItemModelBase*))); connect(m_model, SIGNAL(directoryLoadingStarted()), this, SLOT(slotDirectoryLoadingStarted())); @@ -183,8 +184,8 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) : this, SLOT(slotHeaderColumnWidthChanged(QByteArray,qreal,qreal))); KItemListSelectionManager* selectionManager = controller->selectionManager(); - connect(selectionManager, SIGNAL(selectionChanged(QSet<int>,QSet<int>)), - this, SLOT(slotSelectionChanged(QSet<int>,QSet<int>))); + connect(selectionManager, SIGNAL(selectionChanged(KItemSet,KItemSet)), + this, SLOT(slotSelectionChanged(KItemSet,KItemSet))); m_toolTipManager = new ToolTipManager(this); @@ -349,14 +350,9 @@ int DolphinView::itemsCount() const KFileItemList DolphinView::selectedItems() const { const KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager(); - QList<int> selectedIndexes = selectionManager->selectedItems().toList(); - - qSort(selectedIndexes); KFileItemList selectedItems; - QListIterator<int> it(selectedIndexes); - while (it.hasNext()) { - const int index = it.next(); + foreach (int index, selectionManager->selectedItems()) { selectedItems.append(m_model->fileItem(index)); } return selectedItems; @@ -389,9 +385,9 @@ void DolphinView::selectItems(const QRegExp& pattern, bool enabled) for (int index = 0; index < m_model->count(); index++) { const KFileItem item = m_model->fileItem(index); if (pattern.exactMatch(item.text())) { - // An alternative approach would be to store the matching items in a QSet<int> and + // An alternative approach would be to store the matching items in a KItemSet and // select them in one go after the loop, but we'd need a new function - // KItemListSelectionManager::setSelected(QSet<int>, SelectionMode mode) + // KItemListSelectionManager::setSelected(KItemSet, SelectionMode mode) // for that. selectionManager->setSelected(index, 1, mode); } @@ -485,11 +481,6 @@ void DolphinView::reload() restoreState(restoreStream); } -void DolphinView::stopLoading() -{ - m_model->cancelDirectoryLoading(); -} - void DolphinView::readSettings() { const int oldZoomLevel = m_view->zoomLevel(); @@ -556,8 +547,8 @@ QString DolphinView::statusBarText() const } if (folderCount + fileCount == 1) { - // If only one item is selected, show the filename - filesText = i18nc("@info:status", "<filename>%1</filename> selected", list.first().text()); + // If only one item is selected, show info about it + return list.first().getStatusBarInfo(); } else { // At least 2 items are selected foldersText = i18ncp("@info:status", "1 Folder selected", "%1 Folders selected", folderCount); @@ -724,6 +715,11 @@ void DolphinView::pasteIntoFolder() } } +void DolphinView::stopLoading() +{ + m_model->cancelDirectoryLoading(); +} + bool DolphinView::eventFilter(QObject* watched, QEvent* event) { switch (event->type()) { @@ -802,7 +798,7 @@ void DolphinView::slotItemActivated(int index) } } -void DolphinView::slotItemsActivated(const QSet<int>& indexes) +void DolphinView::slotItemsActivated(const KItemSet& indexes) { Q_ASSERT(indexes.count() >= 2); @@ -817,9 +813,7 @@ void DolphinView::slotItemsActivated(const QSet<int>& indexes) KFileItemList items; items.reserve(indexes.count()); - QSetIterator<int> it(indexes); - while (it.hasNext()) { - const int index = it.next(); + foreach (int index, indexes) { KFileItem item = m_model->fileItem(index); const KUrl& url = openItemAsFolderUrl(item); @@ -1103,7 +1097,7 @@ void DolphinView::slotAboutToCreate(const KUrl::List& urls) } } -void DolphinView::slotSelectionChanged(const QSet<int>& current, const QSet<int>& previous) +void DolphinView::slotSelectionChanged(const KItemSet& current, const KItemSet& previous) { const int currentCount = current.count(); const int previousCount = previous.count(); @@ -1322,7 +1316,7 @@ void DolphinView::updateViewState() m_clearSelectionBeforeSelectingNewItems = false; } - QSet<int> selectedItems = selectionManager->selectedItems(); + KItemSet selectedItems = selectionManager->selectedItems(); QList<KUrl>::iterator it = m_selectedUrls.begin(); while (it != m_selectedUrls.end()) { @@ -1658,7 +1652,7 @@ KUrl::List DolphinView::simplifiedSelectedUrls() const QMimeData* DolphinView::selectionMimeData() const { const KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager(); - const QSet<int> selectedIndexes = selectionManager->selectedItems(); + const KItemSet selectedIndexes = selectionManager->selectedItems(); return m_model->createMimeData(selectedIndexes); } @@ -1666,7 +1660,7 @@ QMimeData* DolphinView::selectionMimeData() const void DolphinView::updateWritableState() { const bool wasFolderWritable = m_isFolderWritable; - m_isFolderWritable = true; + m_isFolderWritable = false; const KFileItem item = m_model->rootItem(); if (!item.isNull()) { diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h index 86bc5c159..b43957f22 100644 --- a/src/views/dolphinview.h +++ b/src/views/dolphinview.h @@ -34,7 +34,6 @@ #include <QBoxLayout> #include <QKeyEvent> #include <QLinkedList> -#include <QSet> #include <QWidget> typedef KIO::FileUndoManager::CommandType CommandType; @@ -45,6 +44,7 @@ class KActionCollection; class KFileItemModel; class KItemListContainer; class KItemModelBase; +class KItemSet; class KUrl; class ToolTipManager; class VersionControlObserver; @@ -217,7 +217,6 @@ public: QList<QByteArray> visibleRoles() const; void reload(); - void stopLoading(); /** * Refreshes the view to get synchronized with the settings (e.g. icons size, @@ -369,6 +368,8 @@ public slots: */ void pasteIntoFolder(); + void stopLoading(); + /** Activates the view if the item list container gets focus. */ virtual bool eventFilter(QObject* watched, QEvent* event); @@ -562,7 +563,7 @@ private slots: void activate(); void slotItemActivated(int index); - void slotItemsActivated(const QSet<int>& indexes); + void slotItemsActivated(const KItemSet& indexes); void slotItemMiddleClicked(int index); void slotItemContextMenuRequested(int index, const QPointF& pos); void slotViewContextMenuRequested(const QPointF& pos); @@ -586,7 +587,7 @@ private slots: * the signal is emitted only after no selection change has been done * within a small delay. */ - void slotSelectionChanged(const QSet<int>& current, const QSet<int>& previous); + void slotSelectionChanged(const KItemSet& current, const KItemSet& previous); /** * Is called by emitDelayedSelectionChangedSignal() and emits the |
