Changeset View
Changeset View
Standalone View
Standalone View
src/filewidgets/kdiroperator.cpp
Show First 20 Lines • Show All 1131 Lines • ▼ Show 20 Line(s) | 1104 | { | |||
---|---|---|---|---|---|
1132 | if (treeView != nullptr) { | 1132 | if (treeView != nullptr) { | ||
1133 | QHeaderView *headerView = treeView->header(); | 1133 | QHeaderView *headerView = treeView->header(); | ||
1134 | headerView->blockSignals(true); | 1134 | headerView->blockSignals(true); | ||
1135 | headerView->setSortIndicator(sortColumn(), sortOrder()); | 1135 | headerView->setSortIndicator(sortColumn(), sortOrder()); | ||
1136 | headerView->blockSignals(false); | 1136 | headerView->blockSignals(false); | ||
1137 | } | 1137 | } | ||
1138 | 1138 | | |||
1139 | _k_assureVisibleSelection(); | 1139 | _k_assureVisibleSelection(); | ||
1140 | _k_synchronizeSortingState(sortColumn(), sortOrder()); | ||||
1140 | } | 1141 | } | ||
1141 | 1142 | | |||
1142 | // Protected | 1143 | // Protected | ||
1143 | void KDirOperator::pathChanged() | 1144 | void KDirOperator::pathChanged() | ||
1144 | { | 1145 | { | ||
1145 | if (d->itemView == nullptr) { | 1146 | if (d->itemView == nullptr) { | ||
1146 | return; | 1147 | return; | ||
1147 | } | 1148 | } | ||
▲ Show 20 Lines • Show All 823 Lines • ▼ Show 20 Line(s) | 1920 | { | |||
1971 | KToggleAction *byDateAction = new KToggleAction(i18n("Sort by Date"), this); | 1972 | KToggleAction *byDateAction = new KToggleAction(i18n("Sort by Date"), this); | ||
1972 | d->actionCollection->addAction(QStringLiteral("by date"), byDateAction); | 1973 | d->actionCollection->addAction(QStringLiteral("by date"), byDateAction); | ||
1973 | connect(byDateAction, SIGNAL(triggered(bool)), this, SLOT(_k_slotSortByDate())); | 1974 | connect(byDateAction, SIGNAL(triggered(bool)), this, SLOT(_k_slotSortByDate())); | ||
1974 | 1975 | | |||
1975 | KToggleAction *byTypeAction = new KToggleAction(i18n("Sort by Type"), this); | 1976 | KToggleAction *byTypeAction = new KToggleAction(i18n("Sort by Type"), this); | ||
1976 | d->actionCollection->addAction(QStringLiteral("by type"), byTypeAction); | 1977 | d->actionCollection->addAction(QStringLiteral("by type"), byTypeAction); | ||
1977 | connect(byTypeAction, SIGNAL(triggered(bool)), this, SLOT(_k_slotSortByType())); | 1978 | connect(byTypeAction, SIGNAL(triggered(bool)), this, SLOT(_k_slotSortByType())); | ||
1978 | 1979 | | |||
1980 | /* | ||||
1979 | KToggleAction *descendingAction = new KToggleAction(i18n("Descending"), this); | 1981 | KToggleAction *descendingAction = new KToggleAction(i18n("Descending"), this); | ||
nicolasfella: Remove commented code | |||||
meven: Thanks ;) | |||||
1980 | d->actionCollection->addAction(QStringLiteral("descending"), descendingAction); | 1982 | d->actionCollection->addAction(QStringLiteral("descending"), descendingAction); | ||
1981 | connect(descendingAction, SIGNAL(triggered(bool)), this, SLOT(_k_slotSortReversed(bool))); | 1983 | connect(descendingAction, SIGNAL(triggered(bool)), this, SLOT(_k_slotSortReversed(bool))); | ||
1984 | */ | ||||
Why change this? kdiroperator should definitely be ported to use the new connect syntax, but it should be done all at once in its own patch, not one at a time. ngraham: Why change this? kdiroperator should definitely be ported to use the new connect syntax, but it… | |||||
_k_slotSortReversed parameter means whether or not the sorting is reversed. A closure was the simple course of action to implement this, and could be reused as is for the ascending action as well. meven: _k_slotSortReversed parameter means whether or not the sorting is reversed.
Before this change… | |||||
1985 | QActionGroup* sortOrderGroup = new QActionGroup(this); | ||||
1986 | sortOrderGroup->setExclusive(true); | ||||
1987 | | ||||
1988 | KToggleAction* ascendingAction = new KToggleAction(i18n("Ascending"), this); | ||||
1989 | d->actionCollection->addAction(QStringLiteral("ascending"), ascendingAction); | ||||
1990 | ascendingAction->setActionGroup(sortOrderGroup); | ||||
1991 | connect(ascendingAction, &QAction::triggered, this, [this]() { | ||||
1992 | this->d->_k_slotSortReversed(false); | ||||
1993 | }); | ||||
1994 | | ||||
1995 | KToggleAction* descendingAction = new KToggleAction(i18n("Descending"), this); | ||||
1996 | d->actionCollection->addAction(QStringLiteral("descending"), descendingAction); | ||||
1997 | descendingAction->setActionGroup(sortOrderGroup); | ||||
1998 | connect(descendingAction, &QAction::triggered, this, [this]() { | ||||
1999 | this->d->_k_slotSortReversed(true); | ||||
2000 | }); | ||||
1982 | 2001 | | |||
1983 | KToggleAction *dirsFirstAction = new KToggleAction(i18n("Folders First"), this); | 2002 | KToggleAction *dirsFirstAction = new KToggleAction(i18n("Folders First"), this); | ||
1984 | d->actionCollection->addAction(QStringLiteral("dirs first"), dirsFirstAction); | 2003 | d->actionCollection->addAction(QStringLiteral("dirs first"), dirsFirstAction); | ||
1985 | connect(dirsFirstAction, SIGNAL(triggered(bool)), this, SLOT(_k_slotToggleDirsFirst())); | 2004 | connect(dirsFirstAction, SIGNAL(triggered(bool)), this, SLOT(_k_slotToggleDirsFirst())); | ||
1986 | 2005 | | |||
1987 | // View modes that match those of Dolphin | 2006 | // View modes that match those of Dolphin | ||
1988 | KToggleAction *iconsViewAction = new KToggleAction(i18n("Icons View"), this); | 2007 | KToggleAction *iconsViewAction = new KToggleAction(i18n("Icons View"), this); | ||
1989 | iconsViewAction->setIcon(QIcon::fromTheme(QStringLiteral("view-list-icons"))); | 2008 | iconsViewAction->setIcon(QIcon::fromTheme(QStringLiteral("view-list-icons"))); | ||
▲ Show 20 Lines • Show All 129 Lines • ▼ Show 20 Line(s) | 2137 | { | |||
2119 | // first fill the submenus (sort and view) | 2138 | // first fill the submenus (sort and view) | ||
2120 | KActionMenu *sortMenu = static_cast<KActionMenu *>(d->actionCollection->action(QStringLiteral("sorting menu"))); | 2139 | KActionMenu *sortMenu = static_cast<KActionMenu *>(d->actionCollection->action(QStringLiteral("sorting menu"))); | ||
2121 | sortMenu->menu()->clear(); | 2140 | sortMenu->menu()->clear(); | ||
2122 | sortMenu->addAction(d->actionCollection->action(QStringLiteral("by name"))); | 2141 | sortMenu->addAction(d->actionCollection->action(QStringLiteral("by name"))); | ||
2123 | sortMenu->addAction(d->actionCollection->action(QStringLiteral("by size"))); | 2142 | sortMenu->addAction(d->actionCollection->action(QStringLiteral("by size"))); | ||
2124 | sortMenu->addAction(d->actionCollection->action(QStringLiteral("by date"))); | 2143 | sortMenu->addAction(d->actionCollection->action(QStringLiteral("by date"))); | ||
2125 | sortMenu->addAction(d->actionCollection->action(QStringLiteral("by type"))); | 2144 | sortMenu->addAction(d->actionCollection->action(QStringLiteral("by type"))); | ||
2126 | sortMenu->addSeparator(); | 2145 | sortMenu->addSeparator(); | ||
2146 | sortMenu->addAction(d->actionCollection->action(QStringLiteral("ascending"))); | ||||
2127 | sortMenu->addAction(d->actionCollection->action(QStringLiteral("descending"))); | 2147 | sortMenu->addAction(d->actionCollection->action(QStringLiteral("descending"))); | ||
2148 | sortMenu->addSeparator(); | ||||
2128 | sortMenu->addAction(d->actionCollection->action(QStringLiteral("dirs first"))); | 2149 | sortMenu->addAction(d->actionCollection->action(QStringLiteral("dirs first"))); | ||
2129 | 2150 | | |||
2130 | // now plug everything into the popupmenu | 2151 | // now plug everything into the popupmenu | ||
2131 | d->actionMenu->menu()->clear(); | 2152 | d->actionMenu->menu()->clear(); | ||
2132 | if (whichActions & NavActions) { | 2153 | if (whichActions & NavActions) { | ||
2133 | d->actionMenu->addAction(d->actionCollection->action(QStringLiteral("up"))); | 2154 | d->actionMenu->addAction(d->actionCollection->action(QStringLiteral("up"))); | ||
2134 | d->actionMenu->addAction(d->actionCollection->action(QStringLiteral("back"))); | 2155 | d->actionMenu->addAction(d->actionCollection->action(QStringLiteral("back"))); | ||
2135 | d->actionMenu->addAction(d->actionCollection->action(QStringLiteral("forward"))); | 2156 | d->actionMenu->addAction(d->actionCollection->action(QStringLiteral("forward"))); | ||
Show All 32 Lines | |||||
2168 | if (whichActions & FileActions) { | 2189 | if (whichActions & FileActions) { | ||
2169 | d->actionMenu->addAction(d->actionCollection->action(QStringLiteral("file manager"))); | 2190 | d->actionMenu->addAction(d->actionCollection->action(QStringLiteral("file manager"))); | ||
2170 | d->actionMenu->addAction(d->actionCollection->action(QStringLiteral("properties"))); | 2191 | d->actionMenu->addAction(d->actionCollection->action(QStringLiteral("properties"))); | ||
2171 | } | 2192 | } | ||
2172 | } | 2193 | } | ||
2173 | 2194 | | |||
2174 | void KDirOperator::updateSortActions() | 2195 | void KDirOperator::updateSortActions() | ||
2175 | { | 2196 | { | ||
2197 | QAction *ascending = d->actionCollection->action(QStringLiteral("ascending")); | ||||
2198 | QAction *descending = d->actionCollection->action(QStringLiteral("descending")); | ||||
2199 | | ||||
2176 | if (KFile::isSortByName(d->sorting)) { | 2200 | if (KFile::isSortByName(d->sorting)) { | ||
2177 | d->actionCollection->action(QStringLiteral("by name"))->setChecked(true); | 2201 | d->actionCollection->action(QStringLiteral("by name"))->setChecked(true); | ||
2202 | descending->setText(i18nc("Sort descending", "Z-A")); | ||||
2203 | ascending->setText(i18nc("Sort ascending", "A-Z")); | ||||
2178 | } else if (KFile::isSortByDate(d->sorting)) { | 2204 | } else if (KFile::isSortByDate(d->sorting)) { | ||
2179 | d->actionCollection->action(QStringLiteral("by date"))->setChecked(true); | 2205 | d->actionCollection->action(QStringLiteral("by date"))->setChecked(true); | ||
2206 | descending->setText(i18nc("Sort descending", "Newest first")); | ||||
2207 | ascending->setText(i18nc("Sort ascending", "Oldest first")); | ||||
2180 | } else if (KFile::isSortBySize(d->sorting)) { | 2208 | } else if (KFile::isSortBySize(d->sorting)) { | ||
2181 | d->actionCollection->action(QStringLiteral("by size"))->setChecked(true); | 2209 | d->actionCollection->action(QStringLiteral("by size"))->setChecked(true); | ||
2210 | descending->setText(i18nc("Sort descending", "Largest first")); | ||||
2211 | ascending->setText(i18nc("Sort ascending", "Smallest first")); | ||||
2182 | } else if (KFile::isSortByType(d->sorting)) { | 2212 | } else if (KFile::isSortByType(d->sorting)) { | ||
2183 | d->actionCollection->action(QStringLiteral("by type"))->setChecked(true); | 2213 | d->actionCollection->action(QStringLiteral("by type"))->setChecked(true); | ||
2214 | descending->setText(i18nc("Sort descending", "Z-A")); | ||||
2215 | ascending->setText(i18nc("Sort ascending", "A-Z")); | ||||
2184 | } | 2216 | } | ||
2185 | d->actionCollection->action(QStringLiteral("descending"))->setChecked(d->sorting & QDir::Reversed); | 2217 | ascending->setChecked(!(d->sorting & QDir::Reversed)); | ||
2218 | descending->setChecked(d->sorting & QDir::Reversed); | ||||
2186 | d->actionCollection->action(QStringLiteral("dirs first"))->setChecked(d->sorting & QDir::DirsFirst); | 2219 | d->actionCollection->action(QStringLiteral("dirs first"))->setChecked(d->sorting & QDir::DirsFirst); | ||
2187 | } | 2220 | } | ||
2188 | 2221 | | |||
2189 | void KDirOperator::updateViewActions() | 2222 | void KDirOperator::updateViewActions() | ||
2190 | { | 2223 | { | ||
2191 | KFile::FileView fv = static_cast<KFile::FileView>(d->viewKind); | 2224 | KFile::FileView fv = static_cast<KFile::FileView>(d->viewKind); | ||
2192 | 2225 | | |||
2193 | //QAction *separateDirs = d->actionCollection->action("separate dirs"); | 2226 | //QAction *separateDirs = d->actionCollection->action("separate dirs"); | ||
▲ Show 20 Lines • Show All 578 Lines • Show Last 20 Lines |
Remove commented code