From a91bb8b0dba763c3537fbf9216df10662c2fc69e Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Fri, 18 Jan 2008 20:13:14 +0000 Subject: Backport: * Always take the root of an URL as root for the treeview (using a matching Places-URL leads to serious usability issues - see bug #150941 for details). * Don't reset the horizontal scrollbar position when expanding/reloading the tree. BUG: 150941 svn path=/branches/KDE/4.0/kdebase/apps/; revision=763173 --- src/treeviewsidebarpage.cpp | 31 +++++++++++++++++-------------- src/treeviewsidebarpage.h | 2 +- 2 files changed, 18 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/treeviewsidebarpage.cpp b/src/treeviewsidebarpage.cpp index 3196fe7bd..7fa56566a 100644 --- a/src/treeviewsidebarpage.cpp +++ b/src/treeviewsidebarpage.cpp @@ -34,10 +34,12 @@ #include #include #include +#include TreeViewSidebarPage::TreeViewSidebarPage(QWidget* parent) : SidebarPage(parent), m_setLeafVisible(false), + m_horizontalPos(0), m_dirLister(0), m_dolphinModel(0), m_proxyModel(0), @@ -216,20 +218,16 @@ void TreeViewSidebarPage::loadTree(const KUrl& url) Q_ASSERT(m_dirLister != 0); m_leafDir = url; - // adjust the root of the tree to the base place - KFilePlacesModel* placesModel = DolphinSettings::instance().placesModel(); - KUrl baseUrl = placesModel->url(placesModel->closestItem(url)); - if (!baseUrl.isValid()) { - // it's possible that no closest item is available and hence an - // empty URL is returned - if (url.isLocalFile()) { - // use the root directory as base for local URLs - baseUrl = KUrl("file:///"); - } else { - // clear the path for non-local URLs and use it as base - baseUrl = url; - baseUrl.setPath(QString()); - } + m_horizontalPos = m_treeView->horizontalScrollBar()->value(); + + KUrl baseUrl = url; + if (url.isLocalFile()) { + // use the root directory as base for local URLs + baseUrl = KUrl("file:///"); + } else { + // clear the path for non-local URLs and use it as base + baseUrl = url; + baseUrl.setPath(QString()); } if (m_dirLister->url() != baseUrl) { @@ -244,6 +242,9 @@ void TreeViewSidebarPage::selectLeafDirectory() { const QModelIndex dirIndex = m_dolphinModel->indexForUrl(m_leafDir); const QModelIndex proxyIndex = m_proxyModel->mapFromSource(dirIndex); + if (!proxyIndex.isValid()) { + return; + } if (m_setLeafVisible) { m_treeView->scrollTo(proxyIndex); @@ -252,6 +253,8 @@ void TreeViewSidebarPage::selectLeafDirectory() QItemSelectionModel* selModel = m_treeView->selectionModel(); selModel->setCurrentIndex(proxyIndex, QItemSelectionModel::Select); + + m_treeView->horizontalScrollBar()->setValue(m_horizontalPos); } #include "treeviewsidebarpage.moc" diff --git a/src/treeviewsidebarpage.h b/src/treeviewsidebarpage.h index d0c3850e9..9ff37ed06 100644 --- a/src/treeviewsidebarpage.h +++ b/src/treeviewsidebarpage.h @@ -116,7 +116,7 @@ private: private: bool m_setLeafVisible; - bool m_dirListerCompleted; + int m_horizontalPos; KDirLister* m_dirLister; DolphinModel* m_dolphinModel; DolphinSortFilterProxyModel* m_proxyModel; -- cgit v1.3 From e91a0ff774c1c2b16eafd93860f69ef9e1526165 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Fri, 18 Jan 2008 20:21:20 +0000 Subject: Backport: show the correct meta information in the information sidebar also for non-local files BUG: 155534 svn path=/branches/KDE/4.0/kdebase/apps/; revision=763175 --- src/infosidebarpage.cpp | 23 +++++++++++++++++------ src/infosidebarpage.h | 5 +++-- 2 files changed, 20 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/infosidebarpage.cpp b/src/infosidebarpage.cpp index 7b0d2d40c..bcb28aa19 100644 --- a/src/infosidebarpage.cpp +++ b/src/infosidebarpage.cpp @@ -48,7 +48,9 @@ InfoSidebarPage::InfoSidebarPage(QWidget* parent) : SidebarPage(parent), m_pendingPreview(false), - m_timer(0), + m_shownUrl(), + m_urlCandidate(), + m_fileItem(), m_preview(0), m_nameLabel(0), m_infoLabel(0), @@ -136,10 +138,13 @@ void InfoSidebarPage::requestDelayedItemInfo(const KFileItem& item) { cancelRequest(); + m_fileItem = KFileItem(); + if (!item.isNull() && (selection().size() <= 1)) { const KUrl url = item.url(); if (!url.isEmpty()) { m_urlCandidate = url; + m_fileItem = item; m_timer->start(TimerDelay); } } @@ -283,16 +288,21 @@ void InfoSidebarPage::showMetaInfo() const KFileItemList& selectedItems = selection(); if (selectedItems.size() <= 1) { - KFileItem fileItem(S_IFDIR, KFileItem::Unknown, m_shownUrl); - fileItem.refresh(); + KFileItem fileItem; + if (m_fileItem.isNull()) { + // no pending request is ongoing + fileItem = KFileItem(KFileItem::Unknown, KFileItem::Unknown, m_shownUrl); + fileItem.refresh(); + } else { + fileItem = m_fileItem; + } if (fileItem.isDir()) { addInfoLine(text, i18nc("@label", "Type:"), i18nc("@label", "Folder")); } else { addInfoLine(text, i18nc("@label", "Type:"), fileItem.mimeComment()); - QString sizeText(KIO::convertSize(fileItem.size())); - addInfoLine(text, i18nc("@label", "Size:"), sizeText); + addInfoLine(text, i18nc("@label", "Size:"), KIO::convertSize(fileItem.size())); addInfoLine(text, i18nc("@label", "Modified:"), fileItem.timeString()); // TODO: See convertMetaInfo below, find a way to display only interesting information @@ -335,8 +345,9 @@ void InfoSidebarPage::showMetaInfo() foreach (const KFileItem& item, selectedItems) { // Only count the size of files, not dirs; to match what // DolphinViewContainer::selectionStatusBarText does. - if (!item.isDir() && !item.isLink()) + if (!item.isDir() && !item.isLink()) { totalSize += item.size(); + } } addInfoLine(text, i18nc("@label", "Total size:"), KIO::convertSize(totalSize)); } diff --git a/src/infosidebarpage.h b/src/infosidebarpage.h index ef014b316..6012e883c 100644 --- a/src/infosidebarpage.h +++ b/src/infosidebarpage.h @@ -139,8 +139,9 @@ private: private: bool m_pendingPreview; QTimer* m_timer; - KUrl m_shownUrl; - KUrl m_urlCandidate; + KUrl m_shownUrl; // URL that is shown as info + KUrl m_urlCandidate; // URL candidate that will replace m_shownURL after a delay + KFileItem m_fileItem; // file item for m_shownUrl if available (otherwise null) PixmapViewer* m_preview; QLabel* m_nameLabel; -- cgit v1.3 From ef2c04a11834bba405281dae61c2c03507738716 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Fri, 18 Jan 2008 20:28:42 +0000 Subject: updated version number of Dolphin for the KDE 4.0.1 release svn path=/branches/KDE/4.0/kdebase/apps/; revision=763180 --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 803f7677b..a7857272a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -33,7 +33,7 @@ int main(int argc, char **argv) { KAboutData about("dolphin", 0, ki18nc("@title", "Dolphin"), - "1.0", + "1.0.1", ki18nc("@title", "File Manager"), KAboutData::License_GPL, ki18nc("@info:credit", "(C) 2006, 2007 Peter Penz")); -- cgit v1.3 From 418eed751192d4dcf1b537a74863920d592bea10 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Sat, 19 Jan 2008 18:20:24 +0000 Subject: Backport: treeview: prevent that when expanding a subtree that the selected item gets hidden by the (maybe) appearing horizontal scrollbar svn path=/branches/KDE/4.0/kdebase/apps/; revision=763550 --- src/treeviewsidebarpage.cpp | 16 +++++++++++++++- src/treeviewsidebarpage.h | 5 +++++ 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/treeviewsidebarpage.cpp b/src/treeviewsidebarpage.cpp index 7fa56566a..14c877728 100644 --- a/src/treeviewsidebarpage.cpp +++ b/src/treeviewsidebarpage.cpp @@ -35,6 +35,7 @@ #include #include #include +#include TreeViewSidebarPage::TreeViewSidebarPage(QWidget* parent) : SidebarPage(parent), @@ -213,6 +214,15 @@ void TreeViewSidebarPage::loadSubTree() } } +void TreeViewSidebarPage::scrollToLeaf() +{ + const QModelIndex dirIndex = m_dolphinModel->indexForUrl(m_leafDir); + const QModelIndex proxyIndex = m_proxyModel->mapFromSource(dirIndex); + if (proxyIndex.isValid()) { + m_treeView->scrollTo(proxyIndex); + } +} + void TreeViewSidebarPage::loadTree(const KUrl& url) { Q_ASSERT(m_dirLister != 0); @@ -247,7 +257,11 @@ void TreeViewSidebarPage::selectLeafDirectory() } if (m_setLeafVisible) { - m_treeView->scrollTo(proxyIndex); + // Invoke m_treeView->scrollTo(proxyIndex) asynchronously by + // scrollToLeaf(). This assures that the scrolling is done after + // the horizontal scrollbar gets visible (otherwise the scrollbar + // might hide the leaf). + QTimer::singleShot(100, this, SLOT(scrollToLeaf())); m_setLeafVisible = false; } diff --git a/src/treeviewsidebarpage.h b/src/treeviewsidebarpage.h index 9ff37ed06..a389077a9 100644 --- a/src/treeviewsidebarpage.h +++ b/src/treeviewsidebarpage.h @@ -99,6 +99,11 @@ private slots: */ void loadSubTree(); + /** + * Assures that the leaf folder gets visible. + */ + void scrollToLeaf(); + private: /** * Initializes the base URL of the tree and expands all -- cgit v1.3 From f9aeb825c605ec4ca8b95aae0be1b441ca8ceb91 Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 21 Jan 2008 16:12:25 +0000 Subject: merge -c764347 by Peter, needed for dolphinpart bugfixing svn path=/branches/KDE/4.0/kdebase/apps/; revision=764379 --- src/dolphinpart.cpp | 16 ++-------------- src/dolphinpart.h | 5 ----- src/dolphinview.cpp | 18 +++++++++++++++++- src/dolphinview.h | 28 ++++++++++++++++++---------- src/dolphinviewcontainer.cpp | 3 ++- 5 files changed, 39 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp index d26f14061..235f176cd 100644 --- a/src/dolphinpart.cpp +++ b/src/dolphinpart.cpp @@ -70,7 +70,8 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QStringLi KUrl(), m_dirLister, m_dolphinModel, - m_proxyModel); + m_proxyModel, + actionCollection()); setWidget(m_view); setXMLFile("dolphinpart.rc"); @@ -144,14 +145,6 @@ void DolphinPart::createActions() propertiesAction->setShortcut(Qt::ALT+Qt::Key_Return); connect(propertiesAction, SIGNAL(triggered()), SLOT(slotProperties())); - // This action doesn't appear in the GUI, it's for the shortcut only. - // KNewMenu takes care of the GUI stuff. - KAction* newDirAction = actionCollection()->addAction( "create_dir" ); - newDirAction->setText( i18n("Create Folder..." ) ); - connect(newDirAction, SIGNAL(triggered()), SLOT(slotNewDir())); - newDirAction->setShortcut(Qt::Key_F10); - widget()->addAction(newDirAction); - // Go menu QActionGroup* goActionGroup = new QActionGroup(this); @@ -414,11 +407,6 @@ void DolphinPart::slotTrashActivated(Qt::MouseButtons, Qt::KeyboardModifiers mod m_view->trashSelectedItems(); } -void DolphinPart::slotNewDir() -{ - KonqOperations::newDir(widget(), url()); -} - void DolphinPart::slotEditMimeType() { const KFileItemList items = m_view->selectedItems(); diff --git a/src/dolphinpart.h b/src/dolphinpart.h index 300924a8d..3e3c73f66 100644 --- a/src/dolphinpart.h +++ b/src/dolphinpart.h @@ -115,11 +115,6 @@ private Q_SLOTS: */ void slotTrashActivated(Qt::MouseButtons, Qt::KeyboardModifiers); - /** - * Connected to the key shortcut for "new directory" (F10) - */ - void slotNewDir(); - /** * Connected to all "Go" menu actions provided by DolphinPart */ diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index ddb7185f0..4a1fbb927 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -61,7 +61,8 @@ DolphinView::DolphinView(QWidget* parent, const KUrl& url, KDirLister* dirLister, DolphinModel* dolphinModel, - DolphinSortFilterProxyModel* proxyModel) : + DolphinSortFilterProxyModel* proxyModel, + KActionCollection* actionCollection) : QWidget(parent), m_active(true), m_showPreview(false), @@ -127,6 +128,16 @@ DolphinView::DolphinView(QWidget* parent, applyViewProperties(url); m_topLayout->addWidget(itemView()); + + Q_ASSERT(actionCollection != 0); + if (actionCollection->action("create_dir") == 0) { + // This action doesn't appear in the GUI, it's for the shortcut only. + // KNewMenu takes care of the GUI stuff. + KAction* newDirAction = actionCollection->addAction("create_dir"); + newDirAction->setText(i18n("Create Folder...")); + connect(newDirAction, SIGNAL(triggered()), SLOT(createDir())); + newDirAction->setShortcut(Qt::Key_F10); + } } DolphinView::~DolphinView() @@ -1138,6 +1149,11 @@ void DolphinView::slotPreviewJobFinished(KJob* job) m_previewJob = 0; } +void DolphinView::createDir() +{ + KonqOperations::newDir(this, url()); +} + void DolphinView::cutSelectedItems() { QMimeData* mimeData = new QMimeData(); diff --git a/src/dolphinview.h b/src/dolphinview.h index 60e29b4d5..485748751 100644 --- a/src/dolphinview.h +++ b/src/dolphinview.h @@ -119,21 +119,23 @@ public: }; /** - * @param parent Parent widget of the view. - * @param url Specifies the content which should be shown. - * @param dirLister Used directory lister. The lister is not owned - * by the view and won't get deleted. - * @param dolphinModel Used directory model. The model is not owned - * by the view and won't get deleted. - * @param proxyModel Used proxy model which specifies the sorting. The - * model is not owned by the view and won't get - * deleted. + * @param parent Parent widget of the view. + * @param url Specifies the content which should be shown. + * @param dirLister Used directory lister. The lister is not owned + * by the view and won't get deleted. + * @param dolphinModel Used directory model. The model is not owned + * by the view and won't get deleted. + * @param proxyModel Used proxy model which specifies the sorting. The + * model is not owned by the view and won't get + * deleted. + * @param actionCollection Action collection which contains the menu actions. */ DolphinView(QWidget* parent, const KUrl& url, KDirLister* dirLister, DolphinModel* dolphinModel, - DolphinSortFilterProxyModel* proxyModel); + DolphinSortFilterProxyModel* proxyModel, + KActionCollection* actionCollection); virtual ~DolphinView(); @@ -616,6 +618,12 @@ private slots: */ void slotPreviewJobFinished(KJob* job); + /** + * Opens the dialog for creating a directory. Is connected + * with the key shortcut for "new directory" (F10). + */ + void createDir(); + private: void loadDirectory(const KUrl& url, bool reload = false); diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index a1846dc75..b9caa7b8e 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -115,7 +115,8 @@ DolphinViewContainer::DolphinViewContainer(DolphinMainWindow* mainWindow, url, m_dirLister, m_dolphinModel, - m_proxyModel); + m_proxyModel, + mainWindow->actionCollection()); connect(m_view, SIGNAL(urlChanged(const KUrl&)), m_urlNavigator, SLOT(setUrl(const KUrl&))); connect(m_view, SIGNAL(requestContextMenu(KFileItem, const KUrl&)), -- cgit v1.3 From c00478bbc1001d10dcfc04e9b0ea251620837e85 Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 21 Jan 2008 19:08:52 +0000 Subject: Revert the moving of the action to the DolphinView instance, this doesn't work with splitted views. (Each view would need its own action collection, but then DolphinView would have to become a KXMLGUIClient, and the GUI would flicker when switching views). Instead, use the same solution as the other shared actions: static method in DolphinView (for now), slot in the mainwindow (and for the more complex actions than this one, shared code in DolphinView) svn path=/branches/KDE/4.0/kdebase/apps/; revision=764429 --- src/dolphinmainwindow.cpp | 10 ++++++++++ src/dolphinmainwindow.h | 6 ++++++ src/dolphinpart.cpp | 11 +++++++++-- src/dolphinpart.h | 6 ++++++ src/dolphinview.cpp | 32 +++++++++++++------------------- src/dolphinview.h | 16 +++++++--------- src/dolphinviewcontainer.cpp | 3 +-- 7 files changed, 52 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 2048de1a5..1da9377c7 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -60,6 +60,7 @@ #include #include #include +#include #include #include #include @@ -422,6 +423,12 @@ void DolphinMainWindow::readProperties(const KConfigGroup& group) } } +void DolphinMainWindow::createDir() +{ + const KUrl& url = m_activeViewContainer->view()->url(); + KonqOperations::newDir(this, url); +} + void DolphinMainWindow::updateNewMenu() { m_newMenu->slotCheckUpToDate(); @@ -985,6 +992,9 @@ void DolphinMainWindow::setupActions() connect(menu, SIGNAL(aboutToShow()), this, SLOT(updateNewMenu())); + KAction* newDirAction = DolphinView::createNewDirAction(actionCollection()); + connect(newDirAction, SIGNAL(triggered()), SLOT(createDir())); + KAction* newWindow = actionCollection()->addAction("new_window"); newWindow->setIcon(KIcon("window-new")); newWindow->setText(i18nc("@action:inmenu File", "New &Window")); diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h index f757520c3..e99add896 100644 --- a/src/dolphinmainwindow.h +++ b/src/dolphinmainwindow.h @@ -163,6 +163,12 @@ protected: virtual void readProperties(const KConfigGroup& group); private slots: + /** + * Opens the dialog for creating a directory. Is connected + * with the key shortcut for "new directory" (F10). + */ + void createDir(); + /** Updates the 'Create New...' sub menu. */ void updateNewMenu(); diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp index 235f176cd..2c4c1eaa3 100644 --- a/src/dolphinpart.cpp +++ b/src/dolphinpart.cpp @@ -70,8 +70,7 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QStringLi KUrl(), m_dirLister, m_dolphinModel, - m_proxyModel, - actionCollection()); + m_proxyModel); setWidget(m_view); setXMLFile("dolphinpart.rc"); @@ -147,6 +146,9 @@ void DolphinPart::createActions() // Go menu + KAction* newDirAction = DolphinView::createNewDirAction(actionCollection()); + connect(newDirAction, SIGNAL(triggered()), SLOT(createDir())); + QActionGroup* goActionGroup = new QActionGroup(this); connect(goActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(slotGoTriggered(QAction*))); @@ -424,4 +426,9 @@ void DolphinPart::slotProperties() } } +void DolphinPart::createDir() +{ + KonqOperations::newDir(m_view, url()); +} + #include "dolphinpart.moc" diff --git a/src/dolphinpart.h b/src/dolphinpart.h index 3e3c73f66..04161b6be 100644 --- a/src/dolphinpart.h +++ b/src/dolphinpart.h @@ -130,6 +130,12 @@ private Q_SLOTS: */ void slotProperties(); + /** + * Opens the dialog for creating a directory. Is connected + * with the key shortcut for "new directory" (F10). + */ + void createDir(); + private: void createActions(); void createGoAction(const char* name, const char* iconName, diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index 4a1fbb927..138971360 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -19,8 +19,6 @@ ***************************************************************************/ #include "dolphinview.h" -#include -#include #include #include @@ -30,6 +28,7 @@ #include #include +#include #include #include #include @@ -43,6 +42,7 @@ #include #include #include +#include #include #include "dolphindropcontroller.h" @@ -61,8 +61,7 @@ DolphinView::DolphinView(QWidget* parent, const KUrl& url, KDirLister* dirLister, DolphinModel* dolphinModel, - DolphinSortFilterProxyModel* proxyModel, - KActionCollection* actionCollection) : + DolphinSortFilterProxyModel* proxyModel) : QWidget(parent), m_active(true), m_showPreview(false), @@ -128,16 +127,6 @@ DolphinView::DolphinView(QWidget* parent, applyViewProperties(url); m_topLayout->addWidget(itemView()); - - Q_ASSERT(actionCollection != 0); - if (actionCollection->action("create_dir") == 0) { - // This action doesn't appear in the GUI, it's for the shortcut only. - // KNewMenu takes care of the GUI stuff. - KAction* newDirAction = actionCollection->addAction("create_dir"); - newDirAction->setText(i18n("Create Folder...")); - connect(newDirAction, SIGNAL(triggered()), SLOT(createDir())); - newDirAction->setShortcut(Qt::Key_F10); - } } DolphinView::~DolphinView() @@ -1149,11 +1138,6 @@ void DolphinView::slotPreviewJobFinished(KJob* job) m_previewJob = 0; } -void DolphinView::createDir() -{ - KonqOperations::newDir(this, url()); -} - void DolphinView::cutSelectedItems() { QMimeData* mimeData = new QMimeData(); @@ -1263,4 +1247,14 @@ KAction* DolphinView::createDeleteAction(KActionCollection* collection) return deleteAction; } +KAction* DolphinView::createNewDirAction(KActionCollection* collection) +{ + // This action doesn't appear in the GUI, it's for the shortcut only. + // KNewMenu takes care of the GUI stuff. + KAction* newDirAction = collection->addAction("create_dir"); + newDirAction->setText(i18n("Create Folder...")); + newDirAction->setShortcut(Qt::Key_F10); + return newDirAction; +} + #include "dolphinview.moc" diff --git a/src/dolphinview.h b/src/dolphinview.h index 485748751..8076a62f0 100644 --- a/src/dolphinview.h +++ b/src/dolphinview.h @@ -128,14 +128,12 @@ public: * @param proxyModel Used proxy model which specifies the sorting. The * model is not owned by the view and won't get * deleted. - * @param actionCollection Action collection which contains the menu actions. */ DolphinView(QWidget* parent, const KUrl& url, KDirLister* dirLister, DolphinModel* dolphinModel, - DolphinSortFilterProxyModel* proxyModel, - KActionCollection* actionCollection); + DolphinSortFilterProxyModel* proxyModel); virtual ~DolphinView(); @@ -364,6 +362,12 @@ public: */ static KAction* createDeleteAction(KActionCollection* collection); + /** + * Creates the "new directory" action. + * This code is here to share it between the mainwindow and the part + */ + static KAction* createNewDirAction(KActionCollection* collection); + /** * Returns the action name corresponding to the current view mode */ @@ -618,12 +622,6 @@ private slots: */ void slotPreviewJobFinished(KJob* job); - /** - * Opens the dialog for creating a directory. Is connected - * with the key shortcut for "new directory" (F10). - */ - void createDir(); - private: void loadDirectory(const KUrl& url, bool reload = false); diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index b9caa7b8e..a1846dc75 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -115,8 +115,7 @@ DolphinViewContainer::DolphinViewContainer(DolphinMainWindow* mainWindow, url, m_dirLister, m_dolphinModel, - m_proxyModel, - mainWindow->actionCollection()); + m_proxyModel); connect(m_view, SIGNAL(urlChanged(const KUrl&)), m_urlNavigator, SLOT(setUrl(const KUrl&))); connect(m_view, SIGNAL(requestContextMenu(KFileItem, const KUrl&)), -- cgit v1.3 From af333d9c7a8f344ed7f2a5cae02b383a5d0ee792 Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 21 Jan 2008 19:42:16 +0000 Subject: Make sort/descending available in dolphinpart svn path=/branches/KDE/4.0/kdebase/apps/; revision=764444 --- src/dolphinmainwindow.cpp | 9 ++------- src/dolphinpart.cpp | 16 ++++++++++++++++ src/dolphinpart.h | 3 +++ src/dolphinview.cpp | 15 +++++++++++++++ src/dolphinview.h | 9 +++++++++ 5 files changed, 45 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 1da9377c7..407ec16b4 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -650,11 +650,7 @@ void DolphinMainWindow::sortByTags() void DolphinMainWindow::toggleSortOrder() { - DolphinView* view = m_activeViewContainer->view(); - const Qt::SortOrder order = (view->sortOrder() == Qt::AscendingOrder) ? - Qt::DescendingOrder : - Qt::AscendingOrder; - view->setSortOrder(order); + m_activeViewContainer->view()->toggleSortOrder(); } void DolphinMainWindow::toggleSortCategorization() @@ -1126,8 +1122,7 @@ void DolphinMainWindow::setupActions() //sortGroup->addAction(sortByRating); //sortGroup->addAction(sortByTags); - KToggleAction* sortDescending = actionCollection()->add("descending"); - sortDescending->setText(i18nc("@action:inmenu Sort", "Descending")); + KAction* sortDescending = DolphinView::createSortDescendingAction(actionCollection()); connect(sortDescending, SIGNAL(triggered()), this, SLOT(toggleSortOrder())); KToggleAction* showInGroups = actionCollection()->add("show_in_groups"); diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp index 2c4c1eaa3..e7c919ad8 100644 --- a/src/dolphinpart.cpp +++ b/src/dolphinpart.cpp @@ -93,6 +93,8 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QStringLi this, SLOT(slotUrlChanged(KUrl))); connect(m_view, SIGNAL(modeChanged()), this, SLOT(updateViewActions())); + connect(m_view, SIGNAL(sortOrderChanged(Qt::SortOrder)), + this, SLOT(slotSortOrderChanged(Qt::SortOrder))); QClipboard* clipboard = QApplication::clipboard(); connect(clipboard, SIGNAL(dataChanged()), @@ -144,6 +146,13 @@ void DolphinPart::createActions() propertiesAction->setShortcut(Qt::ALT+Qt::Key_Return); connect(propertiesAction, SIGNAL(triggered()), SLOT(slotProperties())); + // View menu + + // TODO sort_by_* + + KAction* sortDescending = DolphinView::createSortDescendingAction(actionCollection()); + connect(sortDescending, SIGNAL(triggered()), m_view, SLOT(toggleSortOrder())); + // Go menu KAction* newDirAction = DolphinView::createNewDirAction(actionCollection()); @@ -431,4 +440,11 @@ void DolphinPart::createDir() KonqOperations::newDir(m_view, url()); } +void DolphinPart::slotSortOrderChanged(Qt::SortOrder order) +{ + KToggleAction* descending = static_cast(actionCollection()->action("descending")); + const bool sortDescending = (order == Qt::DescendingOrder); + descending->setChecked(sortDescending); +} + #include "dolphinpart.moc" diff --git a/src/dolphinpart.h b/src/dolphinpart.h index 04161b6be..883cf9456 100644 --- a/src/dolphinpart.h +++ b/src/dolphinpart.h @@ -136,6 +136,9 @@ private Q_SLOTS: */ void createDir(); + /** Updates the state of the 'Sort Ascending/Descending' action. */ + void slotSortOrderChanged(Qt::SortOrder); + private: void createActions(); void createGoAction(const char* name, const char* iconName, diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index 138971360..cccbd36b9 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -794,6 +794,14 @@ void DolphinView::updateSortOrder(Qt::SortOrder order) emit sortOrderChanged(order); } +void DolphinView::toggleSortOrder() +{ + const Qt::SortOrder order = (sortOrder() == Qt::AscendingOrder) ? + Qt::DescendingOrder : + Qt::AscendingOrder; + setSortOrder(order); +} + void DolphinView::updateAdditionalInfo(const KFileItemDelegate::InformationList& info) { ViewProperties props(viewPropertiesUrl()); @@ -1257,4 +1265,11 @@ KAction* DolphinView::createNewDirAction(KActionCollection* collection) return newDirAction; } +KAction* DolphinView::createSortDescendingAction(KActionCollection* collection) +{ + KToggleAction* sortDescending = collection->add("descending"); + sortDescending->setText(i18nc("@action:inmenu Sort", "Descending")); + return sortDescending; +} + #include "dolphinview.moc" diff --git a/src/dolphinview.h b/src/dolphinview.h index 8076a62f0..80430ca77 100644 --- a/src/dolphinview.h +++ b/src/dolphinview.h @@ -368,6 +368,12 @@ public: */ static KAction* createNewDirAction(KActionCollection* collection); + /** + * Creates the "sort descending" action. + * This code is here to share it between the mainwindow and the part + */ + static KAction* createSortDescendingAction(KActionCollection* collection); + /** * Returns the action name corresponding to the current view mode */ @@ -423,6 +429,9 @@ public slots: /** Pastes the clipboard data to this view. */ void paste(); + /** Switches between an ascending and descending sorting order. */ + void toggleSortOrder(); + signals: /** * Is emitted if the view has been activated by e. g. a mouse click. -- cgit v1.3 From d34f1d1b466a8163a2274fa6763e1049233f00bb Mon Sep 17 00:00:00 2001 From: David Faure Date: Tue, 22 Jan 2008 00:39:52 +0000 Subject: Use a QActionGroup and save 6 slots (and the duplication of the action names in the code). svn path=/branches/KDE/4.0/kdebase/apps/; revision=764537 --- src/dolphinmainwindow.cpp | 63 ++++++----------------------------------------- src/dolphinmainwindow.h | 30 ++++------------------ src/dolphinview.cpp | 37 ++++++++++++++++++++++++++++ src/dolphinview.h | 7 ++++++ 4 files changed, 56 insertions(+), 81 deletions(-) (limited to 'src') diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 407ec16b4..ce13796ac 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -660,36 +660,6 @@ void DolphinMainWindow::toggleSortCategorization() view->setCategorizedSorting(!categorizedSorting); } -void DolphinMainWindow::toggleSizeInfo() -{ - toggleAdditionalInfo("show_size_info", KFileItemDelegate::Size); -} - -void DolphinMainWindow::toggleDateInfo() -{ - toggleAdditionalInfo("show_date_info", KFileItemDelegate::ModificationTime); -} - -void DolphinMainWindow::togglePermissionsInfo() -{ - toggleAdditionalInfo("show_permissions_info", KFileItemDelegate::Permissions); -} - -void DolphinMainWindow::toggleOwnerInfo() -{ - toggleAdditionalInfo("show_owner_info", KFileItemDelegate::Owner); -} - -void DolphinMainWindow::toggleGroupInfo() -{ - toggleAdditionalInfo("show_group_info", KFileItemDelegate::OwnerAndGroup); -} - -void DolphinMainWindow::toggleMimeInfo() -{ - toggleAdditionalInfo("show_mime_info", KFileItemDelegate::FriendlyMimeType); -} - void DolphinMainWindow::toggleSplitView() { if (m_viewContainer[SecondaryView] == 0) { @@ -1129,29 +1099,8 @@ void DolphinMainWindow::setupActions() showInGroups->setText(i18nc("@action:inmenu View", "Show in Groups")); connect(showInGroups, SIGNAL(triggered()), this, SLOT(toggleSortCategorization())); - KToggleAction* showSizeInfo = actionCollection()->add("show_size_info"); - showSizeInfo->setText(i18nc("@action:inmenu Additional information", "Size")); - connect(showSizeInfo, SIGNAL(triggered()), this, SLOT(toggleSizeInfo())); - - KToggleAction* showDateInfo = actionCollection()->add("show_date_info"); - showDateInfo->setText(i18nc("@action:inmenu Additional information", "Date")); - connect(showDateInfo, SIGNAL(triggered()), this, SLOT(toggleDateInfo())); - - KToggleAction* showPermissionsInfo = actionCollection()->add("show_permissions_info"); - showPermissionsInfo->setText(i18nc("@action:inmenu Additional information", "Permissions")); - connect(showPermissionsInfo, SIGNAL(triggered()), this, SLOT(togglePermissionsInfo())); - - KToggleAction* showOwnerInfo = actionCollection()->add("show_owner_info"); - showOwnerInfo->setText(i18nc("@action:inmenu Additional information", "Owner")); - connect(showOwnerInfo, SIGNAL(triggered()), this, SLOT(toggleOwnerInfo())); - - KToggleAction* showGroupInfo = actionCollection()->add("show_group_info"); - showGroupInfo->setText(i18nc("@action:inmenu Additional information", "Group")); - connect(showGroupInfo, SIGNAL(triggered()), this, SLOT(toggleGroupInfo())); - - KToggleAction* showMimeInfo = actionCollection()->add("show_mime_info"); - showMimeInfo->setText(i18nc("@action:inmenu Additional information", "Type")); - connect(showMimeInfo, SIGNAL(triggered()), this, SLOT(toggleMimeInfo())); + QActionGroup* showInformationActionGroup = DolphinView::createAdditionalInformationActionGroup(actionCollection()); + connect(showInformationActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(toggleAdditionalInfo(QAction*))); KToggleAction* showPreview = actionCollection()->add("show_preview"); showPreview->setText(i18nc("@action:intoolbar", "Preview")); @@ -1472,15 +1421,17 @@ void DolphinMainWindow::updateSplitAction() } } -void DolphinMainWindow::toggleAdditionalInfo(const char* actionName, - KFileItemDelegate::Information info) +void DolphinMainWindow::toggleAdditionalInfo(QAction* action) { clearStatusBar(); + const KFileItemDelegate::Information info = + static_cast(action->data().toInt()); + DolphinView* view = m_activeViewContainer->view(); KFileItemDelegate::InformationList list = view->additionalInfo(); - const bool show = actionCollection()->action(actionName)->isChecked(); + const bool show = action->isChecked(); const int index = list.indexOf(info); const bool containsInfo = (index >= 0); diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h index e99add896..ab96cd155 100644 --- a/src/dolphinmainwindow.h +++ b/src/dolphinmainwindow.h @@ -273,23 +273,11 @@ private slots: /** Switches between sorting by categories or not. */ void toggleSortCategorization(); - /** Switches between showing the size as additional information for the item or not. */ - void toggleSizeInfo(); - - /** Switchtes between showing the date as additional information for the item or not. */ - void toggleDateInfo(); - - /** Switchtes between showing the permissions as additional information for the item or not. */ - void togglePermissionsInfo(); - - /** Switchtes between showing the owner as additional information for the item or not. */ - void toggleOwnerInfo(); - - /** Switchtes between showing the group as additional information for the item or not. */ - void toggleGroupInfo(); - - /** Switches between showing the MIME type as additional information for the item or not. */ - void toggleMimeInfo(); + /** + * Applies \a info dependent from the current checked state of the action + * \a actionName to the file item delegate. + */ + void toggleAdditionalInfo(QAction* action); /** * Switches between one and two views: @@ -453,14 +441,6 @@ private: */ void updateSplitAction(); - /** - * Helper method for the slots toggleDateInfo(), toggleSizeInfo() - * and toggleMimeInfo(). Applies \a info dependent from the current - * checked state of the action \a actionName to the file item delegate. - */ - void toggleAdditionalInfo(const char* actionName, - KFileItemDelegate::Information info); - private: /** * DolphinMainWindow supports up to two views beside each other. diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index cccbd36b9..de57aa00d 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -1272,4 +1272,41 @@ KAction* DolphinView::createSortDescendingAction(KActionCollection* collection) return sortDescending; } +QActionGroup* DolphinView::createAdditionalInformationActionGroup(KActionCollection* collection) +{ + QActionGroup* showInformationGroup = new QActionGroup(collection); + + KToggleAction* showSizeInfo = collection->add("show_size_info"); + showSizeInfo->setText(i18nc("@action:inmenu Additional information", "Size")); + showSizeInfo->setData(KFileItemDelegate::Size); + showSizeInfo->setActionGroup(showInformationGroup); + + KToggleAction* showDateInfo = collection->add("show_date_info"); + showDateInfo->setText(i18nc("@action:inmenu Additional information", "Date")); + showDateInfo->setData(KFileItemDelegate::ModificationTime); + showDateInfo->setActionGroup(showInformationGroup); + + KToggleAction* showPermissionsInfo = collection->add("show_permissions_info"); + showPermissionsInfo->setText(i18nc("@action:inmenu Additional information", "Permissions")); + showPermissionsInfo->setData(KFileItemDelegate::Permissions); + showPermissionsInfo->setActionGroup(showInformationGroup); + + KToggleAction* showOwnerInfo = collection->add("show_owner_info"); + showOwnerInfo->setText(i18nc("@action:inmenu Additional information", "Owner")); + showOwnerInfo->setData(KFileItemDelegate::Owner); + showOwnerInfo->setActionGroup(showInformationGroup); + + KToggleAction* showGroupInfo = collection->add("show_group_info"); + showGroupInfo->setText(i18nc("@action:inmenu Additional information", "Group")); + showGroupInfo->setData(KFileItemDelegate::OwnerAndGroup); + showGroupInfo->setActionGroup(showInformationGroup); + + KToggleAction* showMimeInfo = collection->add("show_mime_info"); + showMimeInfo->setText(i18nc("@action:inmenu Additional information", "Type")); + showMimeInfo->setData(KFileItemDelegate::FriendlyMimeType); + showMimeInfo->setActionGroup(showInformationGroup); + + return showInformationGroup; +} + #include "dolphinview.moc" diff --git a/src/dolphinview.h b/src/dolphinview.h index 80430ca77..e69f0bbc6 100644 --- a/src/dolphinview.h +++ b/src/dolphinview.h @@ -38,6 +38,7 @@ #include #include +class QActionGroup; class KAction; class KToggleAction; class DolphinController; @@ -374,6 +375,12 @@ public: */ static KAction* createSortDescendingAction(KActionCollection* collection); + /** + * Creates an action group with all the "show additional information" actions in it. + * This code is here to share it between the mainwindow and the part + */ + static QActionGroup* createAdditionalInformationActionGroup(KActionCollection* collection); + /** * Returns the action name corresponding to the current view mode */ -- cgit v1.3 From cde816c4f5b3ff547124910185b7be76763c2e34 Mon Sep 17 00:00:00 2001 From: David Faure Date: Tue, 22 Jan 2008 00:43:51 +0000 Subject: restore previous behavior: additional info actions are not mutually exclusive. (although requesting size and type at the same time doesn't show the type...) svn path=/branches/KDE/4.0/kdebase/apps/; revision=764538 --- src/dolphinview.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index de57aa00d..575af51bd 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -1275,6 +1275,7 @@ KAction* DolphinView::createSortDescendingAction(KActionCollection* collection) QActionGroup* DolphinView::createAdditionalInformationActionGroup(KActionCollection* collection) { QActionGroup* showInformationGroup = new QActionGroup(collection); + showInformationGroup->setExclusive(false); KToggleAction* showSizeInfo = collection->add("show_size_info"); showSizeInfo->setText(i18nc("@action:inmenu Additional information", "Size")); -- cgit v1.3 From 13706a2952a7e8b9af6a9cf33d43200c3d360c41 Mon Sep 17 00:00:00 2001 From: David Faure Date: Tue, 22 Jan 2008 01:22:56 +0000 Subject: Move the code handling the additional-info-actions to DolphinView; simplify signal from DolphinView (it has the info anyway). The fact that the last additional-info doesn't show up in the icon view is in fact a KFileItemDelegate bug, not a bug in this code :) svn path=/branches/KDE/4.0/kdebase/apps/; revision=764544 --- src/dolphindetailsview.cpp | 2 +- src/dolphiniconsview.cpp | 11 ++++--- src/dolphiniconsview.h | 2 +- src/dolphinmainwindow.cpp | 82 +++++----------------------------------------- src/dolphinmainwindow.h | 6 ++-- src/dolphinview.cpp | 80 +++++++++++++++++++++++++++++++++++++++++--- src/dolphinview.h | 15 +++++++-- 7 files changed, 108 insertions(+), 90 deletions(-) (limited to 'src') diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp index 4fdb76e1a..2861c134f 100644 --- a/src/dolphindetailsview.cpp +++ b/src/dolphindetailsview.cpp @@ -101,7 +101,7 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr this, SLOT(zoomIn())); connect(controller, SIGNAL(zoomOut()), this, SLOT(zoomOut())); - connect(controller->dolphinView(), SIGNAL(additionalInfoChanged(const KFileItemDelegate::InformationList&)), + connect(controller->dolphinView(), SIGNAL(additionalInfoChanged()), this, SLOT(updateColumnVisibility())); // apply the details mode settings to the widget diff --git a/src/dolphiniconsview.cpp b/src/dolphiniconsview.cpp index 553cdcfe6..d3d485f1a 100644 --- a/src/dolphiniconsview.cpp +++ b/src/dolphiniconsview.cpp @@ -78,8 +78,8 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle const DolphinView* view = controller->dolphinView(); connect(view, SIGNAL(showPreviewChanged()), this, SLOT(slotShowPreviewChanged())); - connect(view, SIGNAL(additionalInfoChanged(const KFileItemDelegate::InformationList&)), - this, SLOT(slotAdditionalInfoChanged(const KFileItemDelegate::InformationList&))); + connect(view, SIGNAL(additionalInfoChanged()), + this, SLOT(slotAdditionalInfoChanged())); connect(this, SIGNAL(entered(const QModelIndex&)), this, SLOT(slotEntered(const QModelIndex&))); @@ -301,10 +301,11 @@ void DolphinIconsView::slotShowPreviewChanged() updateGridSize(view->showPreview(), additionalInfoCount()); } -void DolphinIconsView::slotAdditionalInfoChanged(const KFileItemDelegate::InformationList& info) +void DolphinIconsView::slotAdditionalInfoChanged() { - const bool showPreview = m_controller->dolphinView()->showPreview(); - updateGridSize(showPreview, info.count()); + const DolphinView* view = m_controller->dolphinView(); + const bool showPreview = view->showPreview(); + updateGridSize(showPreview, view->additionalInfo().count()); } void DolphinIconsView::zoomIn() diff --git a/src/dolphiniconsview.h b/src/dolphiniconsview.h index 06c417868..af65bbda8 100644 --- a/src/dolphiniconsview.h +++ b/src/dolphiniconsview.h @@ -67,7 +67,7 @@ private slots: void triggerItem(const QModelIndex& index); void slotEntered(const QModelIndex& index); void slotShowPreviewChanged(); - void slotAdditionalInfoChanged(const KFileItemDelegate::InformationList& info); + void slotAdditionalInfoChanged(); void zoomIn(); void zoomOut(); diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index ce13796ac..44a44efa2 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -256,58 +256,10 @@ void DolphinMainWindow::slotSortOrderChanged(Qt::SortOrder order) descending->setChecked(sortDescending); } -void DolphinMainWindow::slotAdditionalInfoChanged(KFileItemDelegate::InformationList list) -{ - QAction* showSizeInfo = actionCollection()->action("show_size_info"); - QAction* showDateInfo = actionCollection()->action("show_date_info"); - QAction* showPermissionsInfo = actionCollection()->action("show_permissions_info"); - QAction* showOwnerInfo = actionCollection()->action("show_owner_info"); - QAction* showGroupInfo = actionCollection()->action("show_group_info"); - QAction* showMimeInfo = actionCollection()->action("show_mime_info"); - - showSizeInfo->setChecked(false); - showDateInfo->setChecked(false); - showPermissionsInfo->setChecked(false); - showOwnerInfo->setChecked(false); - showGroupInfo->setChecked(false); - showMimeInfo->setChecked(false); - - const DolphinView* view = m_activeViewContainer->view(); - - const bool enable = (view->mode() == DolphinView::DetailsView) || - (view->mode() == DolphinView::IconsView); - - showSizeInfo->setEnabled(enable); - showDateInfo->setEnabled(enable); - showPermissionsInfo->setEnabled(enable); - showOwnerInfo->setEnabled(enable); - showGroupInfo->setEnabled(enable); - showMimeInfo->setEnabled(enable); - - foreach (KFileItemDelegate::Information info, list) { - switch (info) { - case KFileItemDelegate::Size: - showSizeInfo->setChecked(true); - break; - case KFileItemDelegate::ModificationTime: - showDateInfo->setChecked(true); - break; - case KFileItemDelegate::Permissions: - showPermissionsInfo->setChecked(true); - break; - case KFileItemDelegate::Owner: - showOwnerInfo->setChecked(true); - break; - case KFileItemDelegate::OwnerAndGroup: - showGroupInfo->setChecked(true); - break; - case KFileItemDelegate::FriendlyMimeType: - showMimeInfo->setChecked(true); - break; - default: - break; - } - } +void DolphinMainWindow::slotAdditionalInfoChanged() +{ + DolphinView* view = m_activeViewContainer->view(); + view->updateAdditionalInfoActions(actionCollection()); } void DolphinMainWindow::slotSelectionChanged(const KFileItemList& selection) @@ -1333,7 +1285,7 @@ void DolphinMainWindow::updateViewActions() slotSortingChanged(view->sorting()); slotSortOrderChanged(view->sortOrder()); slotCategorizedSortingChanged(); - slotAdditionalInfoChanged(view->additionalInfo()); + slotAdditionalInfoChanged(); KToggleAction* showFilterBarAction = static_cast(actionCollection()->action("show_filter_bar")); @@ -1386,8 +1338,8 @@ void DolphinMainWindow::connectViewSignals(int viewIndex) this, SLOT(slotSortingChanged(DolphinView::Sorting))); connect(view, SIGNAL(sortOrderChanged(Qt::SortOrder)), this, SLOT(slotSortOrderChanged(Qt::SortOrder))); - connect(view, SIGNAL(additionalInfoChanged(KFileItemDelegate::InformationList)), - this, SLOT(slotAdditionalInfoChanged(KFileItemDelegate::InformationList))); + connect(view, SIGNAL(additionalInfoChanged()), + this, SLOT(slotAdditionalInfoChanged())); connect(view, SIGNAL(selectionChanged(KFileItemList)), this, SLOT(slotSelectionChanged(KFileItemList))); connect(view, SIGNAL(requestItemInfo(KFileItem)), @@ -1424,25 +1376,7 @@ void DolphinMainWindow::updateSplitAction() void DolphinMainWindow::toggleAdditionalInfo(QAction* action) { clearStatusBar(); - - const KFileItemDelegate::Information info = - static_cast(action->data().toInt()); - - DolphinView* view = m_activeViewContainer->view(); - KFileItemDelegate::InformationList list = view->additionalInfo(); - - const bool show = action->isChecked(); - - const int index = list.indexOf(info); - const bool containsInfo = (index >= 0); - if (show && !containsInfo) { - list.append(info); - view->setAdditionalInfo(list); - } else if (!show && containsInfo) { - list.removeAt(index); - view->setAdditionalInfo(list); - Q_ASSERT(list.indexOf(info) < 0); - } + m_activeViewContainer->view()->toggleAdditionalInfo(action); } DolphinMainWindow::UndoUiInterface::UndoUiInterface(DolphinMainWindow* mainWin) : diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h index ab96cd155..444a4a946 100644 --- a/src/dolphinmainwindow.h +++ b/src/dolphinmainwindow.h @@ -274,8 +274,8 @@ private slots: void toggleSortCategorization(); /** - * Applies \a info dependent from the current checked state of the action - * \a actionName to the file item delegate. + * Switches on or off the displaying of additional information + * as specified by \a action. */ void toggleAdditionalInfo(QAction* action); @@ -376,7 +376,7 @@ private slots: void slotSortOrderChanged(Qt::SortOrder order); /** Updates the state of the 'Additional Information' actions. */ - void slotAdditionalInfoChanged(KFileItemDelegate::InformationList info); + void slotAdditionalInfoChanged(); /** * Updates the state of the 'Edit' menu actions and emits diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index 575af51bd..4aeabb265 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -215,7 +215,7 @@ void DolphinView::setMode(Mode mode) // additional information manually const KFileItemDelegate::InformationList infoList = props.additionalInfo(); m_fileItemDelegate->setShowInformation(infoList); - emit additionalInfoChanged(infoList); + emit additionalInfoChanged(); // Not all view modes support categorized sorting. Adjust the sorting model // if changing the view mode results in a change of the categorized sorting @@ -467,7 +467,7 @@ void DolphinView::setAdditionalInfo(KFileItemDelegate::InformationList info) props.setAdditionalInfo(info); m_fileItemDelegate->setShowInformation(info); - emit additionalInfoChanged(info); + emit additionalInfoChanged(); if (itemView() != m_detailsView) { // the details view requires no reloading of the directory, as it maps @@ -708,7 +708,7 @@ void DolphinView::applyViewProperties(const KUrl& url) KFileItemDelegate::InformationList info = props.additionalInfo(); if (info != m_fileItemDelegate->showInformation()) { m_fileItemDelegate->setShowInformation(info); - emit additionalInfoChanged(info); + emit additionalInfoChanged(); } const bool showPreview = props.showPreview(); @@ -810,8 +810,80 @@ void DolphinView::updateAdditionalInfo(const KFileItemDelegate::InformationList& m_fileItemDelegate->setShowInformation(info); - emit additionalInfoChanged(info); + emit additionalInfoChanged(); // will call updateAdditionalInfoActions just below +} + +void DolphinView::updateAdditionalInfoActions(KActionCollection* collection) +{ + const bool enable = (m_mode == DolphinView::DetailsView) || + (m_mode == DolphinView::IconsView); + + QAction* showSizeInfo = collection->action("show_size_info"); + QAction* showDateInfo = collection->action("show_date_info"); + QAction* showPermissionsInfo = collection->action("show_permissions_info"); + QAction* showOwnerInfo = collection->action("show_owner_info"); + QAction* showGroupInfo = collection->action("show_group_info"); + QAction* showMimeInfo = collection->action("show_mime_info"); + + showSizeInfo->setChecked(false); + showDateInfo->setChecked(false); + showPermissionsInfo->setChecked(false); + showOwnerInfo->setChecked(false); + showGroupInfo->setChecked(false); + showMimeInfo->setChecked(false); + + showSizeInfo->setEnabled(enable); + showDateInfo->setEnabled(enable); + showPermissionsInfo->setEnabled(enable); + showOwnerInfo->setEnabled(enable); + showGroupInfo->setEnabled(enable); + showMimeInfo->setEnabled(enable); + + foreach (KFileItemDelegate::Information info, m_fileItemDelegate->showInformation()) { + switch (info) { + case KFileItemDelegate::Size: + showSizeInfo->setChecked(true); + break; + case KFileItemDelegate::ModificationTime: + showDateInfo->setChecked(true); + break; + case KFileItemDelegate::Permissions: + showPermissionsInfo->setChecked(true); + break; + case KFileItemDelegate::Owner: + showOwnerInfo->setChecked(true); + break; + case KFileItemDelegate::OwnerAndGroup: + showGroupInfo->setChecked(true); + break; + case KFileItemDelegate::FriendlyMimeType: + showMimeInfo->setChecked(true); + break; + default: + break; + } + } +} + +void DolphinView::toggleAdditionalInfo(QAction* action) +{ + const KFileItemDelegate::Information info = + static_cast(action->data().toInt()); + + KFileItemDelegate::InformationList list = additionalInfo(); + const bool show = action->isChecked(); + + const int index = list.indexOf(info); + const bool containsInfo = (index >= 0); + if (show && !containsInfo) { + list.append(info); + setAdditionalInfo(list); + } else if (!show && containsInfo) { + list.removeAt(index); + setAdditionalInfo(list); + Q_ASSERT(list.indexOf(info) < 0); + } } void DolphinView::emitContentsMoved() diff --git a/src/dolphinview.h b/src/dolphinview.h index e69f0bbc6..a85c184ef 100644 --- a/src/dolphinview.h +++ b/src/dolphinview.h @@ -381,6 +381,11 @@ public: */ static QActionGroup* createAdditionalInformationActionGroup(KActionCollection* collection); + /** + * Updates the state of the 'Additional Information' actions in \a collection. + */ + void updateAdditionalInfoActions(KActionCollection* collection); + /** * Returns the action name corresponding to the current view mode */ @@ -439,6 +444,12 @@ public slots: /** Switches between an ascending and descending sorting order. */ void toggleSortOrder(); + /** + * Switches on or off the displaying of additional information + * as specified by \a action. + */ + void toggleAdditionalInfo(QAction* action); + signals: /** * Is emitted if the view has been activated by e. g. a mouse click. @@ -474,8 +485,8 @@ signals: /** Is emitted if the sort order (ascending or descending) has been changed. */ void sortOrderChanged(Qt::SortOrder order); - /** Is emitted if the additional information for an item has been changed. */ - void additionalInfoChanged(const KFileItemDelegate::InformationList& info); + /** Is emitted if the additional information shown for this view has been changed. */ + void additionalInfoChanged(); /** * Is emitted if information of an item is requested to be shown e. g. in the sidebar. -- cgit v1.3 From e6dcf5e8ffd8c4fe9a011aba92783d6ad1a7a63c Mon Sep 17 00:00:00 2001 From: David Faure Date: Tue, 22 Jan 2008 01:36:28 +0000 Subject: And finally: provide those "additional info" actions in the part too. svn path=/branches/KDE/4.0/kdebase/apps/; revision=764549 --- src/dolphinpart.cpp | 10 ++++++++++ src/dolphinpart.h | 3 +++ 2 files changed, 13 insertions(+) (limited to 'src') diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp index e7c919ad8..f144109cb 100644 --- a/src/dolphinpart.cpp +++ b/src/dolphinpart.cpp @@ -95,6 +95,8 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QStringLi this, SLOT(updateViewActions())); connect(m_view, SIGNAL(sortOrderChanged(Qt::SortOrder)), this, SLOT(slotSortOrderChanged(Qt::SortOrder))); + connect(m_view, SIGNAL(additionalInfoChanged()), + this, SLOT(slotAdditionalInfoChanged())); QClipboard* clipboard = QApplication::clipboard(); connect(clipboard, SIGNAL(dataChanged()), @@ -153,6 +155,9 @@ void DolphinPart::createActions() KAction* sortDescending = DolphinView::createSortDescendingAction(actionCollection()); connect(sortDescending, SIGNAL(triggered()), m_view, SLOT(toggleSortOrder())); + QActionGroup* showInformationActionGroup = DolphinView::createAdditionalInformationActionGroup(actionCollection()); + connect(showInformationActionGroup, SIGNAL(triggered(QAction*)), m_view, SLOT(toggleAdditionalInfo(QAction*))); + // Go menu KAction* newDirAction = DolphinView::createNewDirAction(actionCollection()); @@ -447,4 +452,9 @@ void DolphinPart::slotSortOrderChanged(Qt::SortOrder order) descending->setChecked(sortDescending); } +void DolphinPart::slotAdditionalInfoChanged() +{ + m_view->updateAdditionalInfoActions(actionCollection()); +} + #include "dolphinpart.moc" diff --git a/src/dolphinpart.h b/src/dolphinpart.h index 883cf9456..3d9ec0306 100644 --- a/src/dolphinpart.h +++ b/src/dolphinpart.h @@ -139,6 +139,9 @@ private Q_SLOTS: /** Updates the state of the 'Sort Ascending/Descending' action. */ void slotSortOrderChanged(Qt::SortOrder); + /** Updates the state of the 'Additional Information' actions. */ + void slotAdditionalInfoChanged(); + private: void createActions(); void createGoAction(const char* name, const char* iconName, -- cgit v1.3 From 9eb63ebe4f1235e5d11f12018b353c32dac5f651 Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Tue, 22 Jan 2008 06:18:46 +0000 Subject: SVN_SILENT made messages (.desktop file) svn path=/branches/KDE/4.0/kdebase/apps/; revision=764609 --- src/dolphin.desktop | 1 + src/dolphinpart.desktop | 1 + 2 files changed, 2 insertions(+) (limited to 'src') diff --git a/src/dolphin.desktop b/src/dolphin.desktop index cb80c824a..5b446866d 100644 --- a/src/dolphin.desktop +++ b/src/dolphin.desktop @@ -19,6 +19,7 @@ GenericName[bg]=Файлов браузър GenericName[ca]=Gestor de fitxers GenericName[cs]=Správce souborů GenericName[csb]=Menadżer lopków +GenericName[da]=Filhåndtering GenericName[de]=Dateimanager GenericName[el]=Διαχειριστής αρχείων GenericName[eo]=Dosieradministrilo diff --git a/src/dolphinpart.desktop b/src/dolphinpart.desktop index 9f5e6bad5..cac16122c 100644 --- a/src/dolphinpart.desktop +++ b/src/dolphinpart.desktop @@ -6,6 +6,7 @@ Name[be]=Dolphin Name[ca]=Part del Dolphin Name[cs]=Komponenta Dolphinu Name[csb]=Dolphin - kòmpònenta +Name[da]=Dolphin-Part Name[de]=Dolphin-Komponente Name[el]=Τμήμα Dolphin Name[eo]=Komponanto de Dolphin -- cgit v1.3 From 87b59ecda385d6cce9dcc51c1eb4006d4da5e930 Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Tue, 22 Jan 2008 17:52:12 +0000 Subject: Fix restore from session management. svn path=/branches/KDE/4.0/kdebase/apps/; revision=764841 --- src/main.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index a7857272a..3cc7c000b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -91,6 +91,7 @@ int main(int argc, char **argv) } ++n; } + app.exec(); } else { app.exec(); } -- cgit v1.3 From c624666b53b678de541ca2946565eaecefb52a4c Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Tue, 22 Jan 2008 18:06:28 +0000 Subject: - fix session restore - newInstance() from KUniqueApplication is actually harmful here svn path=/branches/KDE/4.0/kdebase/apps/; revision=764846 --- src/dolphinapplication.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/dolphinapplication.cpp b/src/dolphinapplication.cpp index ea18db132..4bec27492 100644 --- a/src/dolphinapplication.cpp +++ b/src/dolphinapplication.cpp @@ -73,21 +73,21 @@ void DolphinApplication::refreshMainWindows() int DolphinApplication::newInstance() { - int exitValue = KUniqueApplication::newInstance(); - KCmdLineArgs::setCwd(QDir::currentPath().toUtf8()); KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); + static bool first = true; if (args->count() > 0) { for (int i = 0; i < args->count(); ++i) { openWindow(args->url(i)); } - } else { + } else if( !first || !isSessionRestored()) { openWindow(KUrl()); } + first = false; args->clear(); - return exitValue; + return 0; } int DolphinApplication::openWindow(const KUrl& url) -- cgit v1.3 From 3b30141f6926ae064c52d5571d58484d2f9ef4c0 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Wed, 23 Jan 2008 06:44:47 +0000 Subject: Backport: allow opening directories/trash from the desktop (fixes #156192) svn path=/branches/KDE/4.0/kdebase/apps/; revision=765101 --- src/dolphin.desktop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/dolphin.desktop b/src/dolphin.desktop index 5b446866d..8b695a58e 100644 --- a/src/dolphin.desktop +++ b/src/dolphin.desktop @@ -7,7 +7,7 @@ Name[pa]=ਡਾਲਫਿਨ Name[sr]=Делфин Name[ta]=டால்பின் Name[x-test]=xxDolphinxx -Exec=dolphin %i -caption "%c" +Exec=dolphin %i -caption "%c" "%u" Icon=system-file-manager Type=Application X-DocPath=dolphin/dolphin.html -- cgit v1.3 From eca778ce68dcff65962edba88cd9f61d36824ee0 Mon Sep 17 00:00:00 2001 From: David Faure Date: Wed, 23 Jan 2008 15:38:29 +0000 Subject: Fix memory leak using K_GLOBAL_STATIC svn path=/branches/KDE/4.0/kdebase/apps/; revision=765228 --- src/dolphinsettings.cpp | 13 ++++++++----- src/dolphinsettings.h | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/dolphinsettings.cpp b/src/dolphinsettings.cpp index 04284c22a..5b91001ef 100644 --- a/src/dolphinsettings.cpp +++ b/src/dolphinsettings.cpp @@ -30,13 +30,16 @@ #include "dolphin_generalsettings.h" #include "dolphin_iconsmodesettings.h" +class DolphinSettingsSingleton +{ +public: + DolphinSettings instance; +}; +K_GLOBAL_STATIC(DolphinSettingsSingleton, s_settings) + DolphinSettings& DolphinSettings::instance() { - static DolphinSettings* instance = 0; - if (instance == 0) { - instance = new DolphinSettings(); - } - return *instance; + return s_settings->instance; } void DolphinSettings::save() diff --git a/src/dolphinsettings.h b/src/dolphinsettings.h index dc1b0a840..71c2007f5 100644 --- a/src/dolphinsettings.h +++ b/src/dolphinsettings.h @@ -71,6 +71,7 @@ public: protected: DolphinSettings(); virtual ~DolphinSettings(); + friend class DolphinSettingsSingleton; private: GeneralSettings* m_generalSettings; -- cgit v1.3 From ada662a0f109e93459256dcb39f0fbb76008f8b6 Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Thu, 24 Jan 2008 08:58:55 +0000 Subject: SVN_SILENT made messages (.desktop file) svn path=/branches/KDE/4.0/kdebase/apps/; revision=765555 --- src/dolphin.desktop | 1 + src/dolphinpart.desktop | 1 + 2 files changed, 2 insertions(+) (limited to 'src') diff --git a/src/dolphin.desktop b/src/dolphin.desktop index 8b695a58e..fdb42ecda 100644 --- a/src/dolphin.desktop +++ b/src/dolphin.desktop @@ -61,6 +61,7 @@ GenericName[sr@latin]=Menadžer fajlova GenericName[sv]=Filhanterare GenericName[tg]=Мудири файл GenericName[th]=เครื่องมือจัดการแฟ้ม +GenericName[tr]=Dosya Yöneticisi GenericName[uk]=Менеджер файлів GenericName[vi]=Bộ quản lý tập tin GenericName[wa]=Manaedjeu di fitchîs diff --git a/src/dolphinpart.desktop b/src/dolphinpart.desktop index cac16122c..d506a65c6 100644 --- a/src/dolphinpart.desktop +++ b/src/dolphinpart.desktop @@ -43,6 +43,7 @@ Name[sr]=Делфин део Name[sr@latin]=Dolphin deo Name[sv]=Dolphin-delprogram Name[tg]=Қисми Dolphin +Name[tr]=Dolphin Parçacığı Name[uk]=Компонент Дельфіна Name[wa]=Pårt di Dolphin Name[x-test]=xxDolphin Partxx -- cgit v1.3 From 03bf5aa54372024eee5758ced0fb9abe7a058b9f Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Thu, 24 Jan 2008 16:39:03 +0000 Subject: Backport: use 2 textlines per default in the icon-mode as discussed with David and Fredrik svn path=/branches/KDE/4.0/kdebase/apps/; revision=765736 --- src/dolphin_iconsmodesettings.kcfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/dolphin_iconsmodesettings.kcfg b/src/dolphin_iconsmodesettings.kcfg index fa1467b19..4d20c8876 100644 --- a/src/dolphin_iconsmodesettings.kcfg +++ b/src/dolphin_iconsmodesettings.kcfg @@ -52,7 +52,7 @@ - 1 + 2 -- cgit v1.3 From 2209fd6d98f7ecd40c093030c40c22491f2a9383 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Fri, 25 Jan 2008 18:28:50 +0000 Subject: Backport for #156586: don't try changing the directory within the terminal on non-local URLs svn path=/branches/KDE/4.0/kdebase/apps/; revision=766395 --- src/terminalsidebarpage.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/terminalsidebarpage.cpp b/src/terminalsidebarpage.cpp index 4a82599f0..4749e7714 100644 --- a/src/terminalsidebarpage.cpp +++ b/src/terminalsidebarpage.cpp @@ -50,11 +50,13 @@ QSize TerminalSidebarPage::sizeHint() const void TerminalSidebarPage::setUrl(const KUrl& url) { - if (!SidebarPage::url().equals(url, KUrl::CompareWithoutTrailingSlash)) { - SidebarPage::setUrl(url); - if ((m_terminal != 0) && isVisible()) { - m_terminal->sendInput("cd " + KShell::quoteArg(url.path()) + '\n'); - } + if (!url.isValid() || (url == SidebarPage::url())) { + return; + } + + SidebarPage::setUrl(url); + if ((m_terminal != 0) && isVisible() && url.isLocalFile()) { + m_terminal->sendInput("cd " + KShell::quoteArg(url.path()) + '\n'); } } -- cgit v1.3 From 83f2397774dc110f7e006f450777088810908b12 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Fri, 25 Jan 2008 19:16:55 +0000 Subject: Backport for #156375: don't add a place having an empty name svn path=/branches/KDE/4.0/kdebase/apps/; revision=766407 --- src/dolphincontextmenu.cpp | 13 +++++++++++-- src/dolphincontextmenu.h | 5 +++++ 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp index d7953df4f..601e5f141 100644 --- a/src/dolphincontextmenu.cpp +++ b/src/dolphincontextmenu.cpp @@ -198,7 +198,7 @@ void DolphinContextMenu::openItemContextMenu() if ((addToPlacesAction != 0) && (activatedAction == addToPlacesAction)) { const KUrl selectedUrl(m_fileInfo.url()); if (selectedUrl.isValid()) { - DolphinSettings::instance().placesModel()->addPlace(selectedUrl.fileName(), + DolphinSettings::instance().placesModel()->addPlace(placesName(selectedUrl), selectedUrl); } } else if (openWithActions.contains(activatedAction)) { @@ -266,7 +266,7 @@ void DolphinContextMenu::openViewportContextMenu() } else if (action == addToPlacesAction) { const KUrl& url = m_mainWindow->activeViewContainer()->url(); if (url.isValid()) { - DolphinSettings::instance().placesModel()->addPlace(url.fileName(), url); + DolphinSettings::instance().placesModel()->addPlace(placesName(url), url); } } @@ -406,4 +406,13 @@ void DolphinContextMenu::addShowMenubarAction(KMenu* menu) } } +QString DolphinContextMenu::placesName(const KUrl& url) const +{ + QString name = url.fileName(); + if (name.isEmpty()) { + name = url.host(); + } + return name; +} + #include "dolphincontextmenu.moc" diff --git a/src/dolphincontextmenu.h b/src/dolphincontextmenu.h index c90999252..a7cd9c01d 100644 --- a/src/dolphincontextmenu.h +++ b/src/dolphincontextmenu.h @@ -103,6 +103,11 @@ private: */ void addShowMenubarAction(KMenu* menu); + /** + * Returns a name for adding the URL \a url to the Places panel. + */ + QString placesName(const KUrl& url) const; + private: struct Entry { -- cgit v1.3 From cdc40d4398510878e5ff5926be3f87e6ac5108c9 Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 28 Jan 2008 11:33:49 +0000 Subject: Centralize three more actions so that they are available in DolphinPart: 'Show preview' 'Show hidden files' 'Categorized sorting' Found a way of sharing the actions with even less code duplication, discussed it with Peter, but this will be for after 4.0.1 svn path=/branches/KDE/4.0/kdebase/apps/; revision=767566 --- src/dolphinmainwindow.cpp | 78 ++++++++++++++++------------------------------- src/dolphinmainwindow.h | 14 ++++----- src/dolphinpart.cpp | 38 ++++++++++++++++++++++- src/dolphinpart.h | 9 ++++++ src/dolphinview.cpp | 23 ++++++++++++++ src/dolphinview.h | 74 +++++++++++++++++++++++++++++--------------- 6 files changed, 150 insertions(+), 86 deletions(-) (limited to 'src') diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 44a44efa2..2ed59279f 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -191,16 +191,14 @@ void DolphinMainWindow::slotShowPreviewChanged() void DolphinMainWindow::slotShowHiddenFilesChanged() { - KToggleAction* showHiddenFilesAction = - static_cast(actionCollection()->action("show_hidden_files")); + QAction* showHiddenFilesAction = actionCollection()->action("show_hidden_files"); const DolphinView* view = m_activeViewContainer->view(); showHiddenFilesAction->setChecked(view->showHiddenFiles()); } void DolphinMainWindow::slotCategorizedSortingChanged() { - KToggleAction* showInGroupsAction = - static_cast(actionCollection()->action("show_in_groups")); + QAction* showInGroupsAction = actionCollection()->action("show_in_groups"); const DolphinView* view = m_activeViewContainer->view(); showInGroupsAction->setChecked(view->categorizedSorting()); showInGroupsAction->setEnabled(view->supportsCategorizedSorting()); @@ -244,14 +242,13 @@ void DolphinMainWindow::slotSortingChanged(DolphinView::Sorting sorting) } if (action != 0) { - KToggleAction* toggleAction = static_cast(action); - toggleAction->setChecked(true); + action->setChecked(true); } } void DolphinMainWindow::slotSortOrderChanged(Qt::SortOrder order) { - KToggleAction* descending = static_cast(actionCollection()->action("descending")); + QAction* descending = actionCollection()->action("descending"); const bool sortDescending = (order == Qt::DescendingOrder); descending->setChecked(sortDescending); } @@ -297,8 +294,7 @@ void DolphinMainWindow::slotHistoryChanged() void DolphinMainWindow::updateFilterBarAction(bool show) { - KToggleAction* showFilterBarAction = - static_cast(actionCollection()->action("show_filter_bar")); + QAction* showFilterBarAction = actionCollection()->action("show_filter_bar"); showFilterBarAction->setChecked(show); } @@ -605,11 +601,10 @@ void DolphinMainWindow::toggleSortOrder() m_activeViewContainer->view()->toggleSortOrder(); } -void DolphinMainWindow::toggleSortCategorization() +void DolphinMainWindow::toggleSortCategorization(bool categorizedSorting) { DolphinView* view = m_activeViewContainer->view(); - const bool categorizedSorting = view->categorizedSorting(); - view->setCategorizedSorting(!categorizedSorting); + view->setCategorizedSorting(categorizedSorting); } void DolphinMainWindow::toggleSplitView() @@ -657,31 +652,20 @@ void DolphinMainWindow::stopLoading() { } -void DolphinMainWindow::togglePreview() +void DolphinMainWindow::togglePreview(bool show) { clearStatusBar(); - - const KToggleAction* showPreviewAction = - static_cast(actionCollection()->action("show_preview")); - const bool show = showPreviewAction->isChecked(); m_activeViewContainer->view()->setShowPreview(show); } -void DolphinMainWindow::toggleShowHiddenFiles() +void DolphinMainWindow::toggleShowHiddenFiles(bool show) { clearStatusBar(); - - const KToggleAction* showHiddenFilesAction = - static_cast(actionCollection()->action("show_hidden_files")); - const bool show = showHiddenFilesAction->isChecked(); m_activeViewContainer->view()->setShowHiddenFiles(show); } -void DolphinMainWindow::toggleFilterBarVisibility() +void DolphinMainWindow::toggleFilterBarVisibility(bool show) { - const KToggleAction* showFilterBarAction = - static_cast(actionCollection()->action("show_filter_bar")); - const bool show = showFilterBarAction->isChecked(); m_activeViewContainer->showFilterBar(show); } @@ -701,11 +685,9 @@ void DolphinMainWindow::toggleEditLocation() { clearStatusBar(); - KToggleAction* action = static_cast(actionCollection()->action("editable_location")); - - bool editOrBrowse = action->isChecked(); + QAction* action = actionCollection()->action("editable_location"); KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator(); - urlNavigator->setUrlEditable(editOrBrowse); + urlNavigator->setUrlEditable(action->isChecked()); } void DolphinMainWindow::editLocation() @@ -979,6 +961,8 @@ void DolphinMainWindow::setupActions() viewModeGroup->addAction(columnView); connect(viewModeGroup, SIGNAL(triggered(QAction*)), this, SLOT(setViewMode(QAction*))); + // TODO use a QActionGroup + KToggleAction* sortByName = actionCollection()->add("sort_by_name"); sortByName->setText(i18nc("@action:inmenu Sort By", "Name")); connect(sortByName, SIGNAL(triggered()), this, SLOT(sortByName())); @@ -1047,22 +1031,17 @@ void DolphinMainWindow::setupActions() KAction* sortDescending = DolphinView::createSortDescendingAction(actionCollection()); connect(sortDescending, SIGNAL(triggered()), this, SLOT(toggleSortOrder())); - KToggleAction* showInGroups = actionCollection()->add("show_in_groups"); - showInGroups->setText(i18nc("@action:inmenu View", "Show in Groups")); - connect(showInGroups, SIGNAL(triggered()), this, SLOT(toggleSortCategorization())); + KAction* showInGroups = DolphinView::createShowInGroupsAction(actionCollection()); + connect(showInGroups, SIGNAL(triggered(bool)), this, SLOT(toggleSortCategorization(bool))); QActionGroup* showInformationActionGroup = DolphinView::createAdditionalInformationActionGroup(actionCollection()); connect(showInformationActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(toggleAdditionalInfo(QAction*))); - KToggleAction* showPreview = actionCollection()->add("show_preview"); - showPreview->setText(i18nc("@action:intoolbar", "Preview")); - showPreview->setIcon(KIcon("view-preview")); - connect(showPreview, SIGNAL(triggered()), this, SLOT(togglePreview())); + KAction* showPreview = DolphinView::createShowPreviewAction(actionCollection()); + connect(showPreview, SIGNAL(triggered(bool)), this, SLOT(togglePreview(bool))); - KToggleAction* showHiddenFiles = actionCollection()->add("show_hidden_files"); - showHiddenFiles->setText(i18nc("@action:inmenu View", "Show Hidden Files")); - showHiddenFiles->setShortcut(Qt::ALT | Qt::Key_Period); - connect(showHiddenFiles, SIGNAL(triggered()), this, SLOT(toggleShowHiddenFiles())); + KAction* showHiddenFiles = DolphinView::createShowHiddenFilesAction(actionCollection()); + connect(showHiddenFiles, SIGNAL(triggered(bool)), this, SLOT(toggleShowHiddenFiles(bool))); KAction* split = actionCollection()->addAction("split_view"); split->setShortcut(Qt::Key_F3); @@ -1117,7 +1096,7 @@ void DolphinMainWindow::setupActions() KToggleAction* showFilterBar = actionCollection()->add("show_filter_bar"); showFilterBar->setText(i18nc("@action:inmenu Tools", "Show Filter Bar")); showFilterBar->setShortcut(Qt::CTRL | Qt::Key_I); - connect(showFilterBar, SIGNAL(triggered()), this, SLOT(toggleFilterBarVisibility())); + connect(showFilterBar, SIGNAL(triggered(bool)), this, SLOT(toggleFilterBarVisibility(bool))); KAction* compareFiles = actionCollection()->addAction("compare_files"); compareFiles->setText(i18nc("@action:inmenu Tools", "Compare Files")); @@ -1278,8 +1257,7 @@ void DolphinMainWindow::updateViewActions() QAction* action = actionCollection()->action(view->currentViewModeActionName()); if (action != 0) { - KToggleAction* toggleAction = static_cast(action); - toggleAction->setChecked(true); + action->setChecked(true); } slotSortingChanged(view->sorting()); @@ -1287,22 +1265,18 @@ void DolphinMainWindow::updateViewActions() slotCategorizedSortingChanged(); slotAdditionalInfoChanged(); - KToggleAction* showFilterBarAction = - static_cast(actionCollection()->action("show_filter_bar")); + QAction* showFilterBarAction = actionCollection()->action("show_filter_bar"); showFilterBarAction->setChecked(m_activeViewContainer->isFilterBarVisible()); - KToggleAction* showPreviewAction = - static_cast(actionCollection()->action("show_preview")); + QAction* showPreviewAction = actionCollection()->action("show_preview"); showPreviewAction->setChecked(view->showPreview()); - KToggleAction* showHiddenFilesAction = - static_cast(actionCollection()->action("show_hidden_files")); + QAction* showHiddenFilesAction = actionCollection()->action("show_hidden_files"); showHiddenFilesAction->setChecked(view->showHiddenFiles()); updateSplitAction(); - KToggleAction* editableLocactionAction = - static_cast(actionCollection()->action("editable_location")); + QAction* editableLocactionAction = actionCollection()->action("editable_location"); const KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator(); editableLocactionAction->setChecked(urlNavigator->isUrlEditable()); } diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h index 444a4a946..37cdcb43e 100644 --- a/src/dolphinmainwindow.h +++ b/src/dolphinmainwindow.h @@ -271,7 +271,7 @@ private slots: void toggleSortOrder(); /** Switches between sorting by categories or not. */ - void toggleSortCategorization(); + void toggleSortCategorization(bool); /** * Switches on or off the displaying of additional information @@ -293,19 +293,17 @@ private slots: void stopLoading(); /** Switches between showing a preview of the file content and showing the icon. */ - void togglePreview(); + void togglePreview(bool); /** - * Switches between showing and hiding of hidden marked files dependent - * from the current state of the 'Show Hidden Files' menu toggle action. + * Switches between showing and hiding of hidden marked files */ - void toggleShowHiddenFiles(); + void toggleShowHiddenFiles(bool); /** - * Toggles between showing and hiding of the filter bar dependent - * from the current state of the 'Show Filter Bar' menu toggle action. + * Toggles between showing and hiding of the filter bar */ - void toggleFilterBarVisibility(); + void toggleFilterBarVisibility(bool show); /** Increases the size of the current set view mode. */ void zoomIn(); diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp index f144109cb..4d2eebcc6 100644 --- a/src/dolphinpart.cpp +++ b/src/dolphinpart.cpp @@ -93,6 +93,13 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QStringLi this, SLOT(slotUrlChanged(KUrl))); connect(m_view, SIGNAL(modeChanged()), this, SLOT(updateViewActions())); + connect(m_view, SIGNAL(showPreviewChanged()), + this, SLOT(slotShowPreviewChanged())); + connect(m_view, SIGNAL(showHiddenFilesChanged()), + this, SLOT(slotShowHiddenFilesChanged())); + connect(m_view, SIGNAL(categorizedSortingChanged()), + this, SLOT(slotCategorizedSortingChanged())); + // TODO slotSortingChanged connect(m_view, SIGNAL(sortOrderChanged(Qt::SortOrder)), this, SLOT(slotSortOrderChanged(Qt::SortOrder))); connect(m_view, SIGNAL(additionalInfoChanged()), @@ -110,7 +117,6 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QStringLi // [Q_PROPERTY introspection?] // TODO sort_by_* actions - // TODO show_*_info actions // TODO there was a "always open a new window" (when clicking on a directory) setting in konqueror // (sort of spacial navigation) @@ -158,6 +164,15 @@ void DolphinPart::createActions() QActionGroup* showInformationActionGroup = DolphinView::createAdditionalInformationActionGroup(actionCollection()); connect(showInformationActionGroup, SIGNAL(triggered(QAction*)), m_view, SLOT(toggleAdditionalInfo(QAction*))); + KAction* showPreview = DolphinView::createShowPreviewAction(actionCollection()); + connect(showPreview, SIGNAL(triggered(bool)), m_view, SLOT(setShowPreview(bool))); + + KAction* showInGroups = DolphinView::createShowInGroupsAction(actionCollection()); + connect(showInGroups, SIGNAL(triggered(bool)), m_view, SLOT(setCategorizedSorting(bool))); + + KAction* showHiddenFiles = DolphinView::createShowHiddenFilesAction(actionCollection()); + connect(showHiddenFiles, SIGNAL(triggered(bool)), m_view, SLOT(setShowHiddenFiles(bool))); + // Go menu KAction* newDirAction = DolphinView::createNewDirAction(actionCollection()); @@ -457,4 +472,25 @@ void DolphinPart::slotAdditionalInfoChanged() m_view->updateAdditionalInfoActions(actionCollection()); } +void DolphinPart::slotShowPreviewChanged() +{ + updateViewActions(); // see DolphinMainWindow +} + +void DolphinPart::slotShowHiddenFilesChanged() +{ + QAction* showHiddenFilesAction = actionCollection()->action("show_hidden_files"); + showHiddenFilesAction->setChecked(m_view->showHiddenFiles()); +} + +void DolphinPart::slotCategorizedSortingChanged() +{ + // Duplicated from DolphinMainWindow too. + QAction* showInGroupsAction = actionCollection()->action("show_in_groups"); + showInGroupsAction->setChecked(m_view->categorizedSorting()); + showInGroupsAction->setEnabled(m_view->supportsCategorizedSorting()); +} + +// TODO a DolphinViewActionHandler for reducing the duplication in the action handling + #include "dolphinpart.moc" diff --git a/src/dolphinpart.h b/src/dolphinpart.h index 3d9ec0306..797c34d71 100644 --- a/src/dolphinpart.h +++ b/src/dolphinpart.h @@ -136,6 +136,15 @@ private Q_SLOTS: */ void createDir(); + /** Updates the state of the 'Show preview' menu action. */ + void slotShowPreviewChanged(); + + /** Updates the state of the 'Show hidden files' menu action. */ + void slotShowHiddenFilesChanged(); + + /** Updates the state of the 'Categorized sorting' menu action. */ + void slotCategorizedSortingChanged(); + /** Updates the state of the 'Sort Ascending/Descending' action. */ void slotSortOrderChanged(Qt::SortOrder); diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index 4aeabb265..530508fb7 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -1344,6 +1344,29 @@ KAction* DolphinView::createSortDescendingAction(KActionCollection* collection) return sortDescending; } +KAction* DolphinView::createShowPreviewAction(KActionCollection* collection) +{ + KToggleAction* showPreview = collection->add("show_preview"); + showPreview->setText(i18nc("@action:intoolbar", "Preview")); + showPreview->setIcon(KIcon("view-preview")); + return showPreview; +} + +KAction* DolphinView::createShowInGroupsAction(KActionCollection* collection) +{ + KToggleAction* showInGroups = collection->add("show_in_groups"); + showInGroups->setText(i18nc("@action:inmenu View", "Show in Groups")); + return showInGroups; +} + +KAction* DolphinView::createShowHiddenFilesAction(KActionCollection* collection) +{ + KToggleAction* showHiddenFiles = collection->add("show_hidden_files"); + showHiddenFiles->setText(i18nc("@action:inmenu View", "Show Hidden Files")); + showHiddenFiles->setShortcut(Qt::ALT | Qt::Key_Period); + return showHiddenFiles; +} + QActionGroup* DolphinView::createAdditionalInformationActionGroup(KActionCollection* collection) { QActionGroup* showInformationGroup = new QActionGroup(collection); diff --git a/src/dolphinview.h b/src/dolphinview.h index a85c184ef..0c0bbcd2e 100644 --- a/src/dolphinview.h +++ b/src/dolphinview.h @@ -166,39 +166,18 @@ public: * Changes the view mode for the current directory to \a mode. * If the view properties should be remembered for each directory * (GeneralSettings::globalViewProps() returns false), then the - * changed view mode will be be stored automatically. + * changed view mode will be stored automatically. */ void setMode(Mode mode); Mode mode() const; - /** - * Turns on the file preview for the all files of the current directory, - * if \a show is true. - * If the view properties should be remembered for each directory - * (GeneralSettings::globalViewProps() returns false), then the - * preview setting will be be stored automatically. - */ - void setShowPreview(bool show); + /** See setShowPreview */ bool showPreview() const; - /** - * Shows all hidden files of the current directory, - * if \a show is true. - * If the view properties should be remembered for each directory - * (GeneralSettings::globalViewProps() returns false), then the - * show hidden file setting will be be stored automatically. - */ - void setShowHiddenFiles(bool show); + /** See setShowHiddenFiles */ bool showHiddenFiles() const; - /** - * Summarizes all sorted items by their category \a categorized - * is true. - * If the view properties should be remembered for each directory - * (GeneralSettings::globalViewProps() returns false), then the - * categorized sorting setting will be be stored automatically. - */ - void setCategorizedSorting(bool categorized); + /** See setCategorizedSorting */ bool categorizedSorting() const; /** @@ -381,6 +360,24 @@ public: */ static QActionGroup* createAdditionalInformationActionGroup(KActionCollection* collection); + /** + * Creates the "show preview" action. + * This code is here to share it between the mainwindow and the part + */ + static KAction* createShowPreviewAction(KActionCollection* collection); + + /** + * Creates the "show in groups" action. + * This code is here to share it between the mainwindow and the part + */ + static KAction* createShowInGroupsAction(KActionCollection* collection); + + /** + * Creates the "show hidden files" action. + * This code is here to share it between the mainwindow and the part + */ + static KAction* createShowHiddenFilesAction(KActionCollection* collection); + /** * Updates the state of the 'Additional Information' actions in \a collection. */ @@ -441,6 +438,33 @@ public slots: /** Pastes the clipboard data to this view. */ void paste(); + /** + * Turns on the file preview for the all files of the current directory, + * if \a show is true. + * If the view properties should be remembered for each directory + * (GeneralSettings::globalViewProps() returns false), then the + * preview setting will be stored automatically. + */ + void setShowPreview(bool show); + + /** + * Shows all hidden files of the current directory, + * if \a show is true. + * If the view properties should be remembered for each directory + * (GeneralSettings::globalViewProps() returns false), then the + * show hidden file setting will be stored automatically. + */ + void setShowHiddenFiles(bool show); + + /** + * Summarizes all sorted items by their category \a categorized + * is true. + * If the view properties should be remembered for each directory + * (GeneralSettings::globalViewProps() returns false), then the + * categorized sorting setting will be stored automatically. + */ + void setCategorizedSorting(bool categorized); + /** Switches between an ascending and descending sorting order. */ void toggleSortOrder(); -- cgit v1.3 From cec2a40f8b020f487a964e387281cc10ce9fb4ee Mon Sep 17 00:00:00 2001 From: Rafael Fernández López Date: Fri, 1 Feb 2008 08:26:29 +0000 Subject: Backport. Show the vertical scrollbar only when necessary. svn path=/branches/KDE/4.0/kdebase/apps/; revision=769333 --- src/dolphincolumnwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/dolphincolumnwidget.cpp b/src/dolphincolumnwidget.cpp index fcda0676a..7cff99398 100644 --- a/src/dolphincolumnwidget.cpp +++ b/src/dolphincolumnwidget.cpp @@ -63,7 +63,7 @@ DolphinColumnWidget::DolphinColumnWidget(QWidget* parent, setMouseTracking(true); viewport()->setAttribute(Qt::WA_Hover); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); + setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); setSelectionBehavior(SelectItems); setSelectionMode(QAbstractItemView::ExtendedSelection); setDragDropMode(QAbstractItemView::DragDrop); -- cgit v1.3 From 99a10f551dc171bf32c402326ab94c3608d0312a Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Sat, 2 Feb 2008 07:15:28 +0000 Subject: SVN_SILENT made messages (.desktop file) svn path=/branches/KDE/4.0/kdebase/apps/; revision=769836 --- src/dolphin.desktop | 1 - src/dolphinpart.desktop | 1 - 2 files changed, 2 deletions(-) (limited to 'src') diff --git a/src/dolphin.desktop b/src/dolphin.desktop index fdb42ecda..7bd80e9ab 100644 --- a/src/dolphin.desktop +++ b/src/dolphin.desktop @@ -22,7 +22,6 @@ GenericName[csb]=Menadżer lopków GenericName[da]=Filhåndtering GenericName[de]=Dateimanager GenericName[el]=Διαχειριστής αρχείων -GenericName[eo]=Dosieradministrilo GenericName[es]=Gestor de archivos GenericName[et]=Failihaldur GenericName[eu]=Fitxategi kudeatzailea diff --git a/src/dolphinpart.desktop b/src/dolphinpart.desktop index d506a65c6..a8b9217cc 100644 --- a/src/dolphinpart.desktop +++ b/src/dolphinpart.desktop @@ -9,7 +9,6 @@ Name[csb]=Dolphin - kòmpònenta Name[da]=Dolphin-Part Name[de]=Dolphin-Komponente Name[el]=Τμήμα Dolphin -Name[eo]=Komponanto de Dolphin Name[es]=Part Dolphin Name[et]=Dolphini komponent Name[fi]=Dolphin osa -- cgit v1.3 From 45a1074b0a38f38cfebde8bb65d5a6520b2db3e8 Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 11 Feb 2008 12:34:48 +0000 Subject: Factorize all the view-related action handling to DolphinViewActionHandler, to remove code duplication between mainwindow and part, and to remove my code-splitting with the static createFooAction methods in the view. svn path=/branches/KDE/4.0/kdebase/apps/; revision=773570 --- src/CMakeLists.txt | 1 + src/dolphinmainwindow.cpp | 200 +++------------------------ src/dolphinmainwindow.h | 63 +-------- src/dolphinpart.cpp | 103 ++------------ src/dolphinpart.h | 28 +--- src/dolphinview.cpp | 106 +-------------- src/dolphinview.h | 54 -------- src/dolphinviewactionhandler.cpp | 286 +++++++++++++++++++++++++++++++++++++++ src/dolphinviewactionhandler.h | 165 ++++++++++++++++++++++ 9 files changed, 488 insertions(+), 518 deletions(-) create mode 100644 src/dolphinviewactionhandler.cpp create mode 100644 src/dolphinviewactionhandler.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f9902dc66..b2cdfd582 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -25,6 +25,7 @@ set(dolphinprivate_LIB_SRCS dolphinsortfilterproxymodel.cpp renamedialog.cpp dolphinview.cpp + dolphinviewactionhandler.cpp ratingpainter.cpp dolphindropcontroller.cpp ) diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 2ed59279f..c1d6cef39 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -20,6 +20,7 @@ ***************************************************************************/ #include "dolphinmainwindow.h" +#include "dolphinviewactionhandler.h" #include "dolphindropcontroller.h" #include @@ -60,7 +61,6 @@ #include #include #include -#include #include #include #include @@ -182,28 +182,6 @@ void DolphinMainWindow::slotViewModeChanged() updateViewActions(); } -void DolphinMainWindow::slotShowPreviewChanged() -{ - // It is not enough to update the 'Show Preview' action, also - // the 'Zoom In' and 'Zoom Out' actions must be adapted. - updateViewActions(); -} - -void DolphinMainWindow::slotShowHiddenFilesChanged() -{ - QAction* showHiddenFilesAction = actionCollection()->action("show_hidden_files"); - const DolphinView* view = m_activeViewContainer->view(); - showHiddenFilesAction->setChecked(view->showHiddenFiles()); -} - -void DolphinMainWindow::slotCategorizedSortingChanged() -{ - QAction* showInGroupsAction = actionCollection()->action("show_in_groups"); - const DolphinView* view = m_activeViewContainer->view(); - showInGroupsAction->setChecked(view->categorizedSorting()); - showInGroupsAction->setEnabled(view->supportsCategorizedSorting()); -} - void DolphinMainWindow::slotSortingChanged(DolphinView::Sorting sorting) { QAction* action = 0; @@ -246,19 +224,6 @@ void DolphinMainWindow::slotSortingChanged(DolphinView::Sorting sorting) } } -void DolphinMainWindow::slotSortOrderChanged(Qt::SortOrder order) -{ - QAction* descending = actionCollection()->action("descending"); - const bool sortDescending = (order == Qt::DescendingOrder); - descending->setChecked(sortDescending); -} - -void DolphinMainWindow::slotAdditionalInfoChanged() -{ - DolphinView* view = m_activeViewContainer->view(); - view->updateAdditionalInfoActions(actionCollection()); -} - void DolphinMainWindow::slotSelectionChanged(const KFileItemList& selection) { updateEditActions(); @@ -371,43 +336,12 @@ void DolphinMainWindow::readProperties(const KConfigGroup& group) } } -void DolphinMainWindow::createDir() -{ - const KUrl& url = m_activeViewContainer->view()->url(); - KonqOperations::newDir(this, url); -} - void DolphinMainWindow::updateNewMenu() { m_newMenu->slotCheckUpToDate(); m_newMenu->setPopupFiles(activeViewContainer()->url()); } -void DolphinMainWindow::rename() -{ - clearStatusBar(); - m_activeViewContainer->view()->renameSelectedItems(); -} - -void DolphinMainWindow::moveToTrash() -{ - clearStatusBar(); - - DolphinView* view = m_activeViewContainer->view(); - - if (QApplication::keyboardModifiers() & Qt::ShiftModifier) { - view->deleteSelectedItems(); - } else { - view->trashSelectedItems(); - } -} - -void DolphinMainWindow::deleteItems() -{ - clearStatusBar(); - m_activeViewContainer->view()->deleteSelectedItems(); -} - void DolphinMainWindow::properties() { const KFileItemList list = m_activeViewContainer->view()->selectedItems(); @@ -596,17 +530,6 @@ void DolphinMainWindow::sortByTags() #endif } -void DolphinMainWindow::toggleSortOrder() -{ - m_activeViewContainer->view()->toggleSortOrder(); -} - -void DolphinMainWindow::toggleSortCategorization(bool categorizedSorting) -{ - DolphinView* view = m_activeViewContainer->view(); - view->setCategorizedSorting(categorizedSorting); -} - void DolphinMainWindow::toggleSplitView() { if (m_viewContainer[SecondaryView] == 0) { @@ -639,7 +562,7 @@ void DolphinMainWindow::toggleSplitView() setActiveViewContainer(m_viewContainer[PrimaryView]); updateViewActions(); - emit activeViewChanged(); + emit activeViewChanged(); // TODO unused; remove? } void DolphinMainWindow::reloadView() @@ -652,35 +575,11 @@ void DolphinMainWindow::stopLoading() { } -void DolphinMainWindow::togglePreview(bool show) -{ - clearStatusBar(); - m_activeViewContainer->view()->setShowPreview(show); -} - -void DolphinMainWindow::toggleShowHiddenFiles(bool show) -{ - clearStatusBar(); - m_activeViewContainer->view()->setShowHiddenFiles(show); -} - void DolphinMainWindow::toggleFilterBarVisibility(bool show) { m_activeViewContainer->showFilterBar(show); } -void DolphinMainWindow::zoomIn() -{ - m_activeViewContainer->view()->zoomIn(); - updateViewActions(); -} - -void DolphinMainWindow::zoomOut() -{ - m_activeViewContainer->view()->zoomOut(); - updateViewActions(); -} - void DolphinMainWindow::toggleEditLocation() { clearStatusBar(); @@ -820,6 +719,8 @@ void DolphinMainWindow::init() const KUrl& homeUrl = settings.generalSettings()->homeUrl(); setCaption(homeUrl.fileName()); + m_actionHandler = new DolphinViewActionHandler(actionCollection(), this); + connect(m_actionHandler, SIGNAL(actionBeingHandled()), SLOT(clearStatusBar())); ViewProperties props(homeUrl); m_viewContainer[PrimaryView] = new DolphinViewContainer(this, m_splitter, @@ -827,8 +728,10 @@ void DolphinMainWindow::init() m_activeViewContainer = m_viewContainer[PrimaryView]; connectViewSignals(PrimaryView); - m_viewContainer[PrimaryView]->view()->reload(); + DolphinView* view = m_viewContainer[PrimaryView]->view(); + view->reload(); m_viewContainer[PrimaryView]->show(); + m_actionHandler->setCurrentView(view); setCentralWidget(m_splitter); setupDockWidgets(); @@ -858,16 +761,16 @@ void DolphinMainWindow::init() emit urlChanged(homeUrl); } -void DolphinMainWindow::setActiveViewContainer(DolphinViewContainer* view) +void DolphinMainWindow::setActiveViewContainer(DolphinViewContainer* viewContainer) { - Q_ASSERT(view != 0); - Q_ASSERT((view == m_viewContainer[PrimaryView]) || (view == m_viewContainer[SecondaryView])); - if (m_activeViewContainer == view) { + Q_ASSERT(viewContainer != 0); + Q_ASSERT((viewContainer == m_viewContainer[PrimaryView]) || (viewContainer == m_viewContainer[SecondaryView])); + if (m_activeViewContainer == viewContainer) { return; } m_activeViewContainer->setActive(false); - m_activeViewContainer = view; + m_activeViewContainer = viewContainer; m_activeViewContainer->setActive(true); updateHistory(); @@ -878,7 +781,9 @@ void DolphinMainWindow::setActiveViewContainer(DolphinViewContainer* view) const KUrl& url = m_activeViewContainer->url(); setCaption(url.fileName()); - emit activeViewChanged(); + m_actionHandler->setCurrentView(viewContainer->view()); + + emit activeViewChanged(); // TODO unused; remove? emit urlChanged(url); } @@ -892,24 +797,12 @@ void DolphinMainWindow::setupActions() connect(menu, SIGNAL(aboutToShow()), this, SLOT(updateNewMenu())); - KAction* newDirAction = DolphinView::createNewDirAction(actionCollection()); - connect(newDirAction, SIGNAL(triggered()), SLOT(createDir())); - KAction* newWindow = actionCollection()->addAction("new_window"); newWindow->setIcon(KIcon("window-new")); newWindow->setText(i18nc("@action:inmenu File", "New &Window")); newWindow->setShortcut(Qt::CTRL | Qt::Key_N); connect(newWindow, SIGNAL(triggered()), this, SLOT(openNewMainWindow())); - KAction* rename = DolphinView::createRenameAction(actionCollection()); - connect(rename, SIGNAL(triggered()), this, SLOT(rename())); - - KAction* moveToTrash = DolphinView::createMoveToTrashAction(actionCollection()); - connect(moveToTrash, SIGNAL(triggered()), this, SLOT(moveToTrash())); - - KAction* deleteAction = DolphinView::createDeleteAction(actionCollection()); - connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteItems())); - KAction* properties = actionCollection()->addAction("properties"); properties->setText(i18nc("@action:inmenu File", "Properties")); properties->setShortcut(Qt::ALT | Qt::Key_Return); @@ -942,14 +835,6 @@ void DolphinMainWindow::setupActions() connect(invertSelection, SIGNAL(triggered()), this, SLOT(invertSelection())); // setup 'View' menu - KStandardAction::zoomIn(this, - SLOT(zoomIn()), - actionCollection()); - - KStandardAction::zoomOut(this, - SLOT(zoomOut()), - actionCollection()); - KToggleAction* iconsView = DolphinView::iconsModeAction(actionCollection()); KToggleAction* detailsView = DolphinView::detailsModeAction(actionCollection()); @@ -961,6 +846,9 @@ void DolphinMainWindow::setupActions() viewModeGroup->addAction(columnView); connect(viewModeGroup, SIGNAL(triggered(QAction*)), this, SLOT(setViewMode(QAction*))); + //QActionGroup* sortActionGroup = DolphinView::createSortActionGroup(actionCollection()); + //connect(sortActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(sortActionGroupTriggered(QAction*))); + // TODO use a QActionGroup KToggleAction* sortByName = actionCollection()->add("sort_by_name"); @@ -1028,21 +916,6 @@ void DolphinMainWindow::setupActions() //sortGroup->addAction(sortByRating); //sortGroup->addAction(sortByTags); - KAction* sortDescending = DolphinView::createSortDescendingAction(actionCollection()); - connect(sortDescending, SIGNAL(triggered()), this, SLOT(toggleSortOrder())); - - KAction* showInGroups = DolphinView::createShowInGroupsAction(actionCollection()); - connect(showInGroups, SIGNAL(triggered(bool)), this, SLOT(toggleSortCategorization(bool))); - - QActionGroup* showInformationActionGroup = DolphinView::createAdditionalInformationActionGroup(actionCollection()); - connect(showInformationActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(toggleAdditionalInfo(QAction*))); - - KAction* showPreview = DolphinView::createShowPreviewAction(actionCollection()); - connect(showPreview, SIGNAL(triggered(bool)), this, SLOT(togglePreview(bool))); - - KAction* showHiddenFiles = DolphinView::createShowHiddenFilesAction(actionCollection()); - connect(showHiddenFiles, SIGNAL(triggered(bool)), this, SLOT(toggleShowHiddenFiles(bool))); - KAction* split = actionCollection()->addAction("split_view"); split->setShortcut(Qt::Key_F3); updateSplitAction(); @@ -1244,36 +1117,19 @@ void DolphinMainWindow::updateEditActions() void DolphinMainWindow::updateViewActions() { - const DolphinView* view = m_activeViewContainer->view(); - QAction* zoomInAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::ZoomIn)); - if (zoomInAction != 0) { - zoomInAction->setEnabled(view->isZoomInPossible()); - } - - QAction* zoomOutAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::ZoomOut)); - if (zoomOutAction != 0) { - zoomOutAction->setEnabled(view->isZoomOutPossible()); - } + m_actionHandler->updateViewActions(); + const DolphinView* view = m_activeViewContainer->view(); QAction* action = actionCollection()->action(view->currentViewModeActionName()); if (action != 0) { action->setChecked(true); } slotSortingChanged(view->sorting()); - slotSortOrderChanged(view->sortOrder()); - slotCategorizedSortingChanged(); - slotAdditionalInfoChanged(); QAction* showFilterBarAction = actionCollection()->action("show_filter_bar"); showFilterBarAction->setChecked(m_activeViewContainer->isFilterBarVisible()); - QAction* showPreviewAction = actionCollection()->action("show_preview"); - showPreviewAction->setChecked(view->showPreview()); - - QAction* showHiddenFilesAction = actionCollection()->action("show_hidden_files"); - showHiddenFilesAction->setChecked(view->showHiddenFiles()); - updateSplitAction(); QAction* editableLocactionAction = actionCollection()->action("editable_location"); @@ -1302,18 +1158,8 @@ void DolphinMainWindow::connectViewSignals(int viewIndex) DolphinView* view = container->view(); connect(view, SIGNAL(modeChanged()), this, SLOT(slotViewModeChanged())); - connect(view, SIGNAL(showPreviewChanged()), - this, SLOT(slotShowPreviewChanged())); - connect(view, SIGNAL(showHiddenFilesChanged()), - this, SLOT(slotShowHiddenFilesChanged())); - connect(view, SIGNAL(categorizedSortingChanged()), - this, SLOT(slotCategorizedSortingChanged())); connect(view, SIGNAL(sortingChanged(DolphinView::Sorting)), this, SLOT(slotSortingChanged(DolphinView::Sorting))); - connect(view, SIGNAL(sortOrderChanged(Qt::SortOrder)), - this, SLOT(slotSortOrderChanged(Qt::SortOrder))); - connect(view, SIGNAL(additionalInfoChanged()), - this, SLOT(slotAdditionalInfoChanged())); connect(view, SIGNAL(selectionChanged(KFileItemList)), this, SLOT(slotSelectionChanged(KFileItemList))); connect(view, SIGNAL(requestItemInfo(KFileItem)), @@ -1347,12 +1193,6 @@ void DolphinMainWindow::updateSplitAction() } } -void DolphinMainWindow::toggleAdditionalInfo(QAction* action) -{ - clearStatusBar(); - m_activeViewContainer->view()->toggleAdditionalInfo(action); -} - DolphinMainWindow::UndoUiInterface::UndoUiInterface(DolphinMainWindow* mainWin) : KonqFileUndoManager::UiInterface(mainWin), m_mainWin(mainWin) diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h index 37cdcb43e..b1694c323 100644 --- a/src/dolphinmainwindow.h +++ b/src/dolphinmainwindow.h @@ -34,6 +34,7 @@ #include +class DolphinViewActionHandler; class DolphinApplication; class DolphinViewContainer; class KNewMenu; @@ -163,27 +164,11 @@ protected: virtual void readProperties(const KConfigGroup& group); private slots: - /** - * Opens the dialog for creating a directory. Is connected - * with the key shortcut for "new directory" (F10). - */ - void createDir(); + void clearStatusBar(); /** Updates the 'Create New...' sub menu. */ void updateNewMenu(); - /** - * Let the user input a name for the selected item(s) and trigger - * a renaming afterwards. - */ - void rename(); - - /** Moves the selected items of the active view to the trash. */ - void moveToTrash(); - - /** Deletes the selected items of the active view. */ - void deleteItems(); - /** * Opens the properties window for the selected items of the * active view. The properties windows shows information @@ -267,18 +252,6 @@ private slots: /** The sorting of the current view should be done by tags. */ void sortByTags(); - /** Switches between an ascending and descending sorting order. */ - void toggleSortOrder(); - - /** Switches between sorting by categories or not. */ - void toggleSortCategorization(bool); - - /** - * Switches on or off the displaying of additional information - * as specified by \a action. - */ - void toggleAdditionalInfo(QAction* action); - /** * Switches between one and two views: * If one view is visible, it will get split into two views. @@ -292,25 +265,11 @@ private slots: /** Stops the loading process for the current active view. */ void stopLoading(); - /** Switches between showing a preview of the file content and showing the icon. */ - void togglePreview(bool); - - /** - * Switches between showing and hiding of hidden marked files - */ - void toggleShowHiddenFiles(bool); - /** * Toggles between showing and hiding of the filter bar */ void toggleFilterBarVisibility(bool show); - /** Increases the size of the current set view mode. */ - void zoomIn(); - - /** Decreases the size of the current set view mode. */ - void zoomOut(); - /** * Toggles between edit and brose mode of the navigation bar. */ @@ -358,24 +317,9 @@ private slots: /** Updates the state of all 'View' menu actions. */ void slotViewModeChanged(); - /** Updates the state of the 'Show preview' menu action. */ - void slotShowPreviewChanged(); - - /** Updates the state of the 'Show hidden files' menu action. */ - void slotShowHiddenFilesChanged(); - - /** Updates the state of the 'Categorized sorting' menu action. */ - void slotCategorizedSortingChanged(); - /** Updates the state of the 'Sort by' actions. */ void slotSortingChanged(DolphinView::Sorting sorting); - /** Updates the state of the 'Sort Ascending/Descending' action. */ - void slotSortOrderChanged(Qt::SortOrder order); - - /** Updates the state of the 'Additional Information' actions. */ - void slotAdditionalInfoChanged(); - /** * Updates the state of the 'Edit' menu actions and emits * the signal selectionChanged(). @@ -421,7 +365,6 @@ private: void updateEditActions(); void updateViewActions(); void updateGoActions(); - void clearStatusBar(); /** * Connects the signals from the created DolphinView with @@ -473,6 +416,8 @@ private: DolphinViewContainer* m_viewContainer[SecondaryView + 1]; + DolphinViewActionHandler* m_actionHandler; + /// remember pending undo operations until they are finished QList m_undoCommandTypes; }; diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp index 4d2eebcc6..b6f2698c3 100644 --- a/src/dolphinpart.cpp +++ b/src/dolphinpart.cpp @@ -18,14 +18,15 @@ */ #include "dolphinpart.h" -#include -#include +#include "dolphinviewactionhandler.h" #include "dolphinsortfilterproxymodel.h" #include "dolphinview.h" #include "dolphinmodel.h" #include +#include +#include #include #include #include @@ -93,17 +94,10 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QStringLi this, SLOT(slotUrlChanged(KUrl))); connect(m_view, SIGNAL(modeChanged()), this, SLOT(updateViewActions())); - connect(m_view, SIGNAL(showPreviewChanged()), - this, SLOT(slotShowPreviewChanged())); - connect(m_view, SIGNAL(showHiddenFilesChanged()), - this, SLOT(slotShowHiddenFilesChanged())); - connect(m_view, SIGNAL(categorizedSortingChanged()), - this, SLOT(slotCategorizedSortingChanged())); // TODO slotSortingChanged - connect(m_view, SIGNAL(sortOrderChanged(Qt::SortOrder)), - this, SLOT(slotSortOrderChanged(Qt::SortOrder))); - connect(m_view, SIGNAL(additionalInfoChanged()), - this, SLOT(slotAdditionalInfoChanged())); + + m_actionHandler = new DolphinViewActionHandler(actionCollection(), this); + m_actionHandler->setCurrentView(m_view); QClipboard* clipboard = QApplication::clipboard(); connect(clipboard, SIGNAL(dataChanged()), @@ -135,16 +129,6 @@ void DolphinPart::createActions() viewModeActions->addAction(DolphinView::columnsModeAction(actionCollection())); connect(viewModeActions, SIGNAL(triggered(QAction*)), this, SLOT(slotViewModeActionTriggered(QAction*))); - KAction* renameAction = DolphinView::createRenameAction(actionCollection()); - connect(renameAction, SIGNAL(triggered()), m_view, SLOT(renameSelectedItems())); - - KAction* moveToTrashAction = DolphinView::createMoveToTrashAction(actionCollection()); - connect(moveToTrashAction, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), - this, SLOT(slotTrashActivated(Qt::MouseButtons, Qt::KeyboardModifiers))); - - KAction* deleteAction = DolphinView::createDeleteAction(actionCollection()); - connect(deleteAction, SIGNAL(triggered()), m_view, SLOT(deleteSelectedItems())); - KAction *editMimeTypeAction = actionCollection()->addAction( "editMimeType" ); editMimeTypeAction->setText( i18nc("@action:inmenu Edit", "&Edit File Type..." ) ); connect(editMimeTypeAction, SIGNAL(triggered()), SLOT(slotEditMimeType())); @@ -154,30 +138,10 @@ void DolphinPart::createActions() propertiesAction->setShortcut(Qt::ALT+Qt::Key_Return); connect(propertiesAction, SIGNAL(triggered()), SLOT(slotProperties())); - // View menu - - // TODO sort_by_* - - KAction* sortDescending = DolphinView::createSortDescendingAction(actionCollection()); - connect(sortDescending, SIGNAL(triggered()), m_view, SLOT(toggleSortOrder())); - - QActionGroup* showInformationActionGroup = DolphinView::createAdditionalInformationActionGroup(actionCollection()); - connect(showInformationActionGroup, SIGNAL(triggered(QAction*)), m_view, SLOT(toggleAdditionalInfo(QAction*))); - - KAction* showPreview = DolphinView::createShowPreviewAction(actionCollection()); - connect(showPreview, SIGNAL(triggered(bool)), m_view, SLOT(setShowPreview(bool))); - - KAction* showInGroups = DolphinView::createShowInGroupsAction(actionCollection()); - connect(showInGroups, SIGNAL(triggered(bool)), m_view, SLOT(setCategorizedSorting(bool))); - - KAction* showHiddenFiles = DolphinView::createShowHiddenFilesAction(actionCollection()); - connect(showHiddenFiles, SIGNAL(triggered(bool)), m_view, SLOT(setShowHiddenFiles(bool))); + // View menu: all done by DolphinViewActionHandler // Go menu - KAction* newDirAction = DolphinView::createNewDirAction(actionCollection()); - connect(newDirAction, SIGNAL(triggered()), SLOT(createDir())); - QActionGroup* goActionGroup = new QActionGroup(this); connect(goActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(slotGoTriggered(QAction*))); @@ -248,10 +212,10 @@ void DolphinPart::updatePasteAction() void DolphinPart::updateViewActions() { + m_actionHandler->updateViewActions(); QAction* action = actionCollection()->action(m_view->currentViewModeActionName()); if (action != 0) { - KToggleAction* toggleAction = static_cast(action); - toggleAction->setChecked(true); + action->setChecked(true); } } @@ -427,17 +391,6 @@ void DolphinPartBrowserExtension::paste() //// -void DolphinPart::slotTrashActivated(Qt::MouseButtons, Qt::KeyboardModifiers modifiers) -{ - // Note: kde3's konq_mainwindow.cpp used to check - // reason == KAction::PopupMenuActivation && ... - // but this isn't supported anymore - if (modifiers & Qt::ShiftModifier) - m_view->deleteSelectedItems(); - else - m_view->trashSelectedItems(); -} - void DolphinPart::slotEditMimeType() { const KFileItemList items = m_view->selectedItems(); @@ -455,42 +408,4 @@ void DolphinPart::slotProperties() } } -void DolphinPart::createDir() -{ - KonqOperations::newDir(m_view, url()); -} - -void DolphinPart::slotSortOrderChanged(Qt::SortOrder order) -{ - KToggleAction* descending = static_cast(actionCollection()->action("descending")); - const bool sortDescending = (order == Qt::DescendingOrder); - descending->setChecked(sortDescending); -} - -void DolphinPart::slotAdditionalInfoChanged() -{ - m_view->updateAdditionalInfoActions(actionCollection()); -} - -void DolphinPart::slotShowPreviewChanged() -{ - updateViewActions(); // see DolphinMainWindow -} - -void DolphinPart::slotShowHiddenFilesChanged() -{ - QAction* showHiddenFilesAction = actionCollection()->action("show_hidden_files"); - showHiddenFilesAction->setChecked(m_view->showHiddenFiles()); -} - -void DolphinPart::slotCategorizedSortingChanged() -{ - // Duplicated from DolphinMainWindow too. - QAction* showInGroupsAction = actionCollection()->action("show_in_groups"); - showInGroupsAction->setChecked(m_view->categorizedSorting()); - showInGroupsAction->setEnabled(m_view->supportsCategorizedSorting()); -} - -// TODO a DolphinViewActionHandler for reducing the duplication in the action handling - #include "dolphinpart.moc" diff --git a/src/dolphinpart.h b/src/dolphinpart.h index 797c34d71..795a7b194 100644 --- a/src/dolphinpart.h +++ b/src/dolphinpart.h @@ -22,6 +22,7 @@ #include #include +class DolphinViewActionHandler; class QActionGroup; class KAction; class KFileItemList; @@ -110,11 +111,6 @@ private Q_SLOTS: */ void updatePasteAction(); - /** - * Connected to the "move_to_trash" action; adds "shift means del" handling. - */ - void slotTrashActivated(Qt::MouseButtons, Qt::KeyboardModifiers); - /** * Connected to all "Go" menu actions provided by DolphinPart */ @@ -130,27 +126,6 @@ private Q_SLOTS: */ void slotProperties(); - /** - * Opens the dialog for creating a directory. Is connected - * with the key shortcut for "new directory" (F10). - */ - void createDir(); - - /** Updates the state of the 'Show preview' menu action. */ - void slotShowPreviewChanged(); - - /** Updates the state of the 'Show hidden files' menu action. */ - void slotShowHiddenFilesChanged(); - - /** Updates the state of the 'Categorized sorting' menu action. */ - void slotCategorizedSortingChanged(); - - /** Updates the state of the 'Sort Ascending/Descending' action. */ - void slotSortOrderChanged(Qt::SortOrder); - - /** Updates the state of the 'Additional Information' actions. */ - void slotAdditionalInfoChanged(); - private: void createActions(); void createGoAction(const char* name, const char* iconName, @@ -159,6 +134,7 @@ private: private: DolphinView* m_view; + DolphinViewActionHandler* m_actionHandler; KDirLister* m_dirLister; DolphinModel* m_dolphinModel; DolphinSortFilterProxyModel* m_proxyModel; diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index 530508fb7..7979b06c3 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -810,7 +810,7 @@ void DolphinView::updateAdditionalInfo(const KFileItemDelegate::InformationList& m_fileItemDelegate->setShowInformation(info); - emit additionalInfoChanged(); // will call updateAdditionalInfoActions just below + emit additionalInfoChanged(); } void DolphinView::updateAdditionalInfoActions(KActionCollection* collection) @@ -1301,108 +1301,4 @@ QPair DolphinView::pasteInfo() const return ret; } -KAction* DolphinView::createRenameAction(KActionCollection* collection) -{ - KAction* rename = collection->addAction("rename"); - rename->setText(i18nc("@action:inmenu File", "Rename...")); - rename->setShortcut(Qt::Key_F2); - return rename; -} - -KAction* DolphinView::createMoveToTrashAction(KActionCollection* collection) -{ - KAction* moveToTrash = collection->addAction("move_to_trash"); - moveToTrash->setText(i18nc("@action:inmenu File", "Move to Trash")); - moveToTrash->setIcon(KIcon("user-trash")); - moveToTrash->setShortcut(QKeySequence::Delete); - return moveToTrash; -} - -KAction* DolphinView::createDeleteAction(KActionCollection* collection) -{ - KAction* deleteAction = collection->addAction("delete"); - deleteAction->setIcon(KIcon("edit-delete")); - deleteAction->setText(i18nc("@action:inmenu File", "Delete")); - deleteAction->setShortcut(Qt::SHIFT | Qt::Key_Delete); - return deleteAction; -} - -KAction* DolphinView::createNewDirAction(KActionCollection* collection) -{ - // This action doesn't appear in the GUI, it's for the shortcut only. - // KNewMenu takes care of the GUI stuff. - KAction* newDirAction = collection->addAction("create_dir"); - newDirAction->setText(i18n("Create Folder...")); - newDirAction->setShortcut(Qt::Key_F10); - return newDirAction; -} - -KAction* DolphinView::createSortDescendingAction(KActionCollection* collection) -{ - KToggleAction* sortDescending = collection->add("descending"); - sortDescending->setText(i18nc("@action:inmenu Sort", "Descending")); - return sortDescending; -} - -KAction* DolphinView::createShowPreviewAction(KActionCollection* collection) -{ - KToggleAction* showPreview = collection->add("show_preview"); - showPreview->setText(i18nc("@action:intoolbar", "Preview")); - showPreview->setIcon(KIcon("view-preview")); - return showPreview; -} - -KAction* DolphinView::createShowInGroupsAction(KActionCollection* collection) -{ - KToggleAction* showInGroups = collection->add("show_in_groups"); - showInGroups->setText(i18nc("@action:inmenu View", "Show in Groups")); - return showInGroups; -} - -KAction* DolphinView::createShowHiddenFilesAction(KActionCollection* collection) -{ - KToggleAction* showHiddenFiles = collection->add("show_hidden_files"); - showHiddenFiles->setText(i18nc("@action:inmenu View", "Show Hidden Files")); - showHiddenFiles->setShortcut(Qt::ALT | Qt::Key_Period); - return showHiddenFiles; -} - -QActionGroup* DolphinView::createAdditionalInformationActionGroup(KActionCollection* collection) -{ - QActionGroup* showInformationGroup = new QActionGroup(collection); - showInformationGroup->setExclusive(false); - - KToggleAction* showSizeInfo = collection->add("show_size_info"); - showSizeInfo->setText(i18nc("@action:inmenu Additional information", "Size")); - showSizeInfo->setData(KFileItemDelegate::Size); - showSizeInfo->setActionGroup(showInformationGroup); - - KToggleAction* showDateInfo = collection->add("show_date_info"); - showDateInfo->setText(i18nc("@action:inmenu Additional information", "Date")); - showDateInfo->setData(KFileItemDelegate::ModificationTime); - showDateInfo->setActionGroup(showInformationGroup); - - KToggleAction* showPermissionsInfo = collection->add("show_permissions_info"); - showPermissionsInfo->setText(i18nc("@action:inmenu Additional information", "Permissions")); - showPermissionsInfo->setData(KFileItemDelegate::Permissions); - showPermissionsInfo->setActionGroup(showInformationGroup); - - KToggleAction* showOwnerInfo = collection->add("show_owner_info"); - showOwnerInfo->setText(i18nc("@action:inmenu Additional information", "Owner")); - showOwnerInfo->setData(KFileItemDelegate::Owner); - showOwnerInfo->setActionGroup(showInformationGroup); - - KToggleAction* showGroupInfo = collection->add("show_group_info"); - showGroupInfo->setText(i18nc("@action:inmenu Additional information", "Group")); - showGroupInfo->setData(KFileItemDelegate::OwnerAndGroup); - showGroupInfo->setActionGroup(showInformationGroup); - - KToggleAction* showMimeInfo = collection->add("show_mime_info"); - showMimeInfo->setText(i18nc("@action:inmenu Additional information", "Type")); - showMimeInfo->setData(KFileItemDelegate::FriendlyMimeType); - showMimeInfo->setActionGroup(showInformationGroup); - - return showInformationGroup; -} - #include "dolphinview.moc" diff --git a/src/dolphinview.h b/src/dolphinview.h index 0c0bbcd2e..6f0289f62 100644 --- a/src/dolphinview.h +++ b/src/dolphinview.h @@ -324,60 +324,6 @@ public: */ static KToggleAction* columnsModeAction(KActionCollection* collection); - /** - * Creates the rename action. - * This code is here to share it between the mainwindow and the part - */ - static KAction* createRenameAction(KActionCollection* collection); - - /** - * Creates the "move to trash" action. - * This code is here to share it between the mainwindow and the part - */ - static KAction* createMoveToTrashAction(KActionCollection* collection); - - /** - * Creates the delete action. - * This code is here to share it between the mainwindow and the part - */ - static KAction* createDeleteAction(KActionCollection* collection); - - /** - * Creates the "new directory" action. - * This code is here to share it between the mainwindow and the part - */ - static KAction* createNewDirAction(KActionCollection* collection); - - /** - * Creates the "sort descending" action. - * This code is here to share it between the mainwindow and the part - */ - static KAction* createSortDescendingAction(KActionCollection* collection); - - /** - * Creates an action group with all the "show additional information" actions in it. - * This code is here to share it between the mainwindow and the part - */ - static QActionGroup* createAdditionalInformationActionGroup(KActionCollection* collection); - - /** - * Creates the "show preview" action. - * This code is here to share it between the mainwindow and the part - */ - static KAction* createShowPreviewAction(KActionCollection* collection); - - /** - * Creates the "show in groups" action. - * This code is here to share it between the mainwindow and the part - */ - static KAction* createShowInGroupsAction(KActionCollection* collection); - - /** - * Creates the "show hidden files" action. - * This code is here to share it between the mainwindow and the part - */ - static KAction* createShowHiddenFilesAction(KActionCollection* collection); - /** * Updates the state of the 'Additional Information' actions in \a collection. */ diff --git a/src/dolphinviewactionhandler.cpp b/src/dolphinviewactionhandler.cpp new file mode 100644 index 000000000..6cd539d36 --- /dev/null +++ b/src/dolphinviewactionhandler.cpp @@ -0,0 +1,286 @@ +/*************************************************************************** + * Copyright (C) 2008 by David Faure * + * * + * 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 * + ***************************************************************************/ + +#include "dolphinviewactionhandler.h" + +#include "dolphinview.h" + +#include + +#include +#include +#include +#include + +DolphinViewActionHandler::DolphinViewActionHandler(KActionCollection* collection, QObject* parent) + : QObject(parent), + m_actionCollection(collection), + m_currentView(0) +{ + Q_ASSERT(m_actionCollection); + createActions(); +} + +void DolphinViewActionHandler::setCurrentView(DolphinView* view) +{ + Q_ASSERT(view); + + if (m_currentView) + disconnect(m_currentView, 0, this, 0); + + m_currentView = view; + + connect(view, SIGNAL(showPreviewChanged()), + this, SLOT(slotShowPreviewChanged())); + connect(view, SIGNAL(sortOrderChanged(Qt::SortOrder)), + this, SLOT(slotSortOrderChanged(Qt::SortOrder))); + connect(view, SIGNAL(additionalInfoChanged()), + this, SLOT(slotAdditionalInfoChanged())); + connect(view, SIGNAL(categorizedSortingChanged()), + this, SLOT(slotCategorizedSortingChanged())); + connect(view, SIGNAL(showHiddenFilesChanged()), + this, SLOT(slotShowHiddenFilesChanged())); +} + +void DolphinViewActionHandler::createActions() +{ + // This action doesn't appear in the GUI, it's for the shortcut only. + // KNewMenu takes care of the GUI stuff. + KAction* newDirAction = m_actionCollection->addAction("create_dir"); + newDirAction->setText(i18n("Create Folder...")); + newDirAction->setShortcut(Qt::Key_F10); + connect(newDirAction, SIGNAL(triggered()), SLOT(slotCreateDir())); + + // Edit menu + + KAction* rename = m_actionCollection->addAction("rename"); + rename->setText(i18nc("@action:inmenu File", "Rename...")); + rename->setShortcut(Qt::Key_F2); + connect(rename, SIGNAL(triggered()), this, SLOT(slotRename())); + + KAction* moveToTrash = m_actionCollection->addAction("move_to_trash"); + moveToTrash->setText(i18nc("@action:inmenu File", "Move to Trash")); + moveToTrash->setIcon(KIcon("user-trash")); + moveToTrash->setShortcut(QKeySequence::Delete); + connect(moveToTrash, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), + this, SLOT(slotTrashActivated(Qt::MouseButtons, Qt::KeyboardModifiers))); + + KAction* deleteAction = m_actionCollection->addAction("delete"); + deleteAction->setIcon(KIcon("edit-delete")); + deleteAction->setText(i18nc("@action:inmenu File", "Delete")); + deleteAction->setShortcut(Qt::SHIFT | Qt::Key_Delete); + connect(deleteAction, SIGNAL(triggered()), this, SLOT(slotDeleteItems())); + + // View menu + + KStandardAction::zoomIn(this, + SLOT(zoomIn()), + m_actionCollection); + + KStandardAction::zoomOut(this, + SLOT(zoomOut()), + m_actionCollection); + + KToggleAction* showPreview = m_actionCollection->add("show_preview"); + showPreview->setText(i18nc("@action:intoolbar", "Preview")); + showPreview->setIcon(KIcon("view-preview")); + connect(showPreview, SIGNAL(triggered(bool)), this, SLOT(togglePreview(bool))); + + KToggleAction* sortDescending = m_actionCollection->add("descending"); + sortDescending->setText(i18nc("@action:inmenu Sort", "Descending")); + connect(sortDescending, SIGNAL(triggered()), this, SLOT(toggleSortOrder())); + + QActionGroup* showInformationActionGroup = createAdditionalInformationActionGroup(); + connect(showInformationActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(toggleAdditionalInfo(QAction*))); + + KToggleAction* showInGroups = m_actionCollection->add("show_in_groups"); + showInGroups->setText(i18nc("@action:inmenu View", "Show in Groups")); + connect(showInGroups, SIGNAL(triggered(bool)), this, SLOT(toggleSortCategorization(bool))); + + KToggleAction* showHiddenFiles = m_actionCollection->add("show_hidden_files"); + showHiddenFiles->setText(i18nc("@action:inmenu View", "Show Hidden Files")); + showHiddenFiles->setShortcut(Qt::ALT | Qt::Key_Period); + connect(showHiddenFiles, SIGNAL(triggered(bool)), this, SLOT(toggleShowHiddenFiles(bool))); + +} + +QActionGroup* DolphinViewActionHandler::createAdditionalInformationActionGroup() +{ + QActionGroup* showInformationGroup = new QActionGroup(m_actionCollection); + showInformationGroup->setExclusive(false); + + KToggleAction* showSizeInfo = m_actionCollection->add("show_size_info"); + showSizeInfo->setText(i18nc("@action:inmenu Additional information", "Size")); + showSizeInfo->setData(KFileItemDelegate::Size); + showSizeInfo->setActionGroup(showInformationGroup); + + KToggleAction* showDateInfo = m_actionCollection->add("show_date_info"); + showDateInfo->setText(i18nc("@action:inmenu Additional information", "Date")); + showDateInfo->setData(KFileItemDelegate::ModificationTime); + showDateInfo->setActionGroup(showInformationGroup); + + KToggleAction* showPermissionsInfo = m_actionCollection->add("show_permissions_info"); + showPermissionsInfo->setText(i18nc("@action:inmenu Additional information", "Permissions")); + showPermissionsInfo->setData(KFileItemDelegate::Permissions); + showPermissionsInfo->setActionGroup(showInformationGroup); + + KToggleAction* showOwnerInfo = m_actionCollection->add("show_owner_info"); + showOwnerInfo->setText(i18nc("@action:inmenu Additional information", "Owner")); + showOwnerInfo->setData(KFileItemDelegate::Owner); + showOwnerInfo->setActionGroup(showInformationGroup); + + KToggleAction* showGroupInfo = m_actionCollection->add("show_group_info"); + showGroupInfo->setText(i18nc("@action:inmenu Additional information", "Group")); + showGroupInfo->setData(KFileItemDelegate::OwnerAndGroup); + showGroupInfo->setActionGroup(showInformationGroup); + + KToggleAction* showMimeInfo = m_actionCollection->add("show_mime_info"); + showMimeInfo->setText(i18nc("@action:inmenu Additional information", "Type")); + showMimeInfo->setData(KFileItemDelegate::FriendlyMimeType); + showMimeInfo->setActionGroup(showInformationGroup); + + return showInformationGroup; +} + +void DolphinViewActionHandler::slotCreateDir() +{ + Q_ASSERT(m_currentView); + KonqOperations::newDir(m_currentView, m_currentView->url()); +} + +void DolphinViewActionHandler::slotRename() +{ + emit actionBeingHandled(); + m_currentView->renameSelectedItems(); +} + +void DolphinViewActionHandler::slotTrashActivated(Qt::MouseButtons, Qt::KeyboardModifiers modifiers) +{ + emit actionBeingHandled(); + // Note: kde3's konq_mainwindow.cpp used to check + // reason == KAction::PopupMenuActivation && ... + // but this isn't supported anymore + if (modifiers & Qt::ShiftModifier) + m_currentView->deleteSelectedItems(); + else + m_currentView->trashSelectedItems(); +} + +void DolphinViewActionHandler::slotDeleteItems() +{ + emit actionBeingHandled(); + m_currentView->deleteSelectedItems(); +} + +void DolphinViewActionHandler::togglePreview(bool show) +{ + emit actionBeingHandled(); + m_currentView->setShowPreview(show); +} + +void DolphinViewActionHandler::slotShowPreviewChanged() +{ + // It is not enough to update the 'Show Preview' action, also + // the 'Zoom In' and 'Zoom Out' actions must be adapted. + updateViewActions(); +} + +void DolphinViewActionHandler::updateViewActions() +{ + QAction* zoomInAction = m_actionCollection->action(KStandardAction::stdName(KStandardAction::ZoomIn)); + if (zoomInAction != 0) { + zoomInAction->setEnabled(m_currentView->isZoomInPossible()); + } + + QAction* zoomOutAction = m_actionCollection->action(KStandardAction::stdName(KStandardAction::ZoomOut)); + if (zoomOutAction != 0) { + zoomOutAction->setEnabled(m_currentView->isZoomOutPossible()); + } + + QAction* showPreviewAction = m_actionCollection->action("show_preview"); + showPreviewAction->setChecked(m_currentView->showPreview()); + + slotSortOrderChanged(m_currentView->sortOrder()); + slotAdditionalInfoChanged(); + slotCategorizedSortingChanged(); + + QAction* showHiddenFilesAction = m_actionCollection->action("show_hidden_files"); + showHiddenFilesAction->setChecked(m_currentView->showHiddenFiles()); + +} + +void DolphinViewActionHandler::zoomIn() +{ + m_currentView->zoomIn(); + updateViewActions(); +} + +void DolphinViewActionHandler::zoomOut() +{ + m_currentView->zoomOut(); + updateViewActions(); +} + +void DolphinViewActionHandler::toggleSortOrder() +{ + m_currentView->toggleSortOrder(); +} + +void DolphinViewActionHandler::slotSortOrderChanged(Qt::SortOrder order) +{ + QAction* descending = m_actionCollection->action("descending"); + const bool sortDescending = (order == Qt::DescendingOrder); + descending->setChecked(sortDescending); +} + +void DolphinViewActionHandler::toggleAdditionalInfo(QAction* action) +{ + emit actionBeingHandled(); + m_currentView->toggleAdditionalInfo(action); +} + +void DolphinViewActionHandler::slotAdditionalInfoChanged() +{ + m_currentView->updateAdditionalInfoActions(m_actionCollection); +} + +void DolphinViewActionHandler::toggleSortCategorization(bool categorizedSorting) +{ + m_currentView->setCategorizedSorting(categorizedSorting); +} + +void DolphinViewActionHandler::slotCategorizedSortingChanged() +{ + QAction* showInGroupsAction = m_actionCollection->action("show_in_groups"); + showInGroupsAction->setChecked(m_currentView->categorizedSorting()); + showInGroupsAction->setEnabled(m_currentView->supportsCategorizedSorting()); +} + +void DolphinViewActionHandler::toggleShowHiddenFiles(bool show) +{ + emit actionBeingHandled(); + m_currentView->setShowHiddenFiles(show); +} + +void DolphinViewActionHandler::slotShowHiddenFilesChanged() +{ + QAction* showHiddenFilesAction = m_actionCollection->action("show_hidden_files"); + showHiddenFilesAction->setChecked(m_currentView->showHiddenFiles()); +} + diff --git a/src/dolphinviewactionhandler.h b/src/dolphinviewactionhandler.h new file mode 100644 index 000000000..a11d19bb1 --- /dev/null +++ b/src/dolphinviewactionhandler.h @@ -0,0 +1,165 @@ +/*************************************************************************** + * Copyright (C) 2008 by David Faure * + * * + * 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 DOLPHINVIEWACTIONHANDLER_H +#define DOLPHINVIEWACTIONHANDLER_H + +#include "libdolphin_export.h" +#include +class QAction; +class QActionGroup; +class DolphinView; +class KActionCollection; + +/** + * @short Handles all actions for DolphinView + * + * The action handler owns all the actions and slots related to DolphinView, + * but can the view that is acts upon can be switched to another one + * (this is used in the case of split views). + * + * The purpose of this class is also to share this code between DolphinMainWindow + * and DolphinPart. + * + * @see DolphinView + * @see DolphinMainWindow + * @see DolphinPart + */ +class LIBDOLPHINPRIVATE_EXPORT DolphinViewActionHandler : public QObject +{ + Q_OBJECT + +public: + explicit DolphinViewActionHandler(KActionCollection* collection, QObject* parent); + + /** + * Sets the view that this action handler should work on. + */ + void setCurrentView(DolphinView* view); + + /** + * Update all actions in the 'View' menu, i.e. those that depend on the + * settings in the current view. + */ + void updateViewActions(); + +Q_SIGNALS: + /** + * Emitted by DolphinViewActionHandler when the user triggered an action. + * This is only used for clearining the statusbar in DolphinMainWindow. + */ + void actionBeingHandled(); + +private Q_SLOTS: + /** + * Opens the dialog for creating a directory. Is connected + * with the key shortcut for "new directory" (F10). + */ + void slotCreateDir(); + + /** + * Let the user input a name for the selected item(s) and trigger + * a renaming afterwards. + */ + void slotRename(); + + /** + * Moves the selected items of the active view to the trash. + * This methods adds "shift means del" handling. + */ + void slotTrashActivated(Qt::MouseButtons, Qt::KeyboardModifiers); + + /** + * Deletes the selected items of the active view. + */ + void slotDeleteItems(); + + /** + * Switches between showing a preview of the file content and showing the icon. + */ + void togglePreview(bool); + + /** Updates the state of the 'Show preview' menu action. */ + void slotShowPreviewChanged(); + + /** Increases the size of the current set view mode. */ + void zoomIn(); + + /** Decreases the size of the current set view mode. */ + void zoomOut(); + + /** Switches between an ascending and descending sorting order. */ + void toggleSortOrder(); + + /** + * Updates the state of the 'Sort Ascending/Descending' action. + */ + void slotSortOrderChanged(Qt::SortOrder order); + + /** + * Switches on or off the displaying of additional information + * as specified by \a action. + */ + void toggleAdditionalInfo(QAction* action); + + /** + * Updates the state of the 'Additional Information' actions. + */ + void slotAdditionalInfoChanged(); + + /** + * Switches between sorting by categories or not. + */ + void toggleSortCategorization(bool); + + /** + * Updates the state of the 'Categorized sorting' menu action. + */ + void slotCategorizedSortingChanged(); + + /** + * Switches between showing and hiding of hidden marked files + */ + void toggleShowHiddenFiles(bool); + + /** + * Updates the state of the 'Show hidden files' menu action. + */ + void slotShowHiddenFilesChanged(); + +private: + /** + * Create all the actions. + * This is called only once (by the constructor) + */ + void createActions(); + /** + * Creates an action group with all the "show additional information" actions in it. + * Helper method for createActions(); + */ + QActionGroup* createAdditionalInformationActionGroup(); + + KActionCollection* m_actionCollection; + DolphinView* m_currentView; +}; + + +#endif /* DOLPHINVIEWACTIONHANDLER_H */ + -- cgit v1.3