]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinpart.cpp
Make sort/descending available in dolphinpart
[dolphin.git] / src / dolphinpart.cpp
index 155884bfab5907c166ad6d93d82a90748993017f..e7c919ad8457bd128ca1a9099635a7b75a0e402a 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <kactioncollection.h>
 #include <kdirlister.h>
+#include <kiconloader.h>
 #include <kmessagebox.h>
 #include <kparts/genericfactory.h>
 #include <ktoggleaction.h>
@@ -47,6 +48,9 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QStringLi
     setComponentData( DolphinPartFactory::componentData() );
     m_extension = new DolphinPartBrowserExtension(this);
 
+    // make sure that other apps using this part find Dolphin's view-file-columns icons
+    KIconLoader::global()->addAppDir("dolphin");
+
     m_dirLister = new KDirLister;
     m_dirLister->setAutoUpdate(true);
     m_dirLister->setMainWindow(parentWidget->topLevelWidget());
@@ -89,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()),
@@ -140,16 +146,18 @@ 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);
+    // 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());
+    connect(newDirAction, SIGNAL(triggered()), SLOT(createDir()));
+
     QActionGroup* goActionGroup = new QActionGroup(this);
     connect(goActionGroup, SIGNAL(triggered(QAction*)),
             this, SLOT(slotGoTriggered(QAction*)));
@@ -410,11 +418,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();
@@ -432,4 +435,16 @@ void DolphinPart::slotProperties()
     }
 }
 
+void DolphinPart::createDir()
+{
+    KonqOperations::newDir(m_view, url());
+}
+
+void DolphinPart::slotSortOrderChanged(Qt::SortOrder order)
+{
+    KToggleAction* descending = static_cast<KToggleAction*>(actionCollection()->action("descending"));
+    const bool sortDescending = (order == Qt::DescendingOrder);
+    descending->setChecked(sortDescending);
+}
+
 #include "dolphinpart.moc"