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()
//sortGroup->addAction(sortByRating);
//sortGroup->addAction(sortByTags);
- KToggleAction* sortDescending = actionCollection()->add<KToggleAction>("descending");
- sortDescending->setText(i18nc("@action:inmenu Sort", "Descending"));
+ KAction* sortDescending = DolphinView::createSortDescendingAction(actionCollection());
connect(sortDescending, SIGNAL(triggered()), this, SLOT(toggleSortOrder()));
KToggleAction* showInGroups = actionCollection()->add<KToggleAction>("show_in_groups");
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()),
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());
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"
*/
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,
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());
return newDirAction;
}
+KAction* DolphinView::createSortDescendingAction(KActionCollection* collection)
+{
+ KToggleAction* sortDescending = collection->add<KToggleAction>("descending");
+ sortDescending->setText(i18nc("@action:inmenu Sort", "Descending"));
+ return sortDescending;
+}
+
#include "dolphinview.moc"
*/
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
*/
/** 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.