Changeset View
Standalone View
src/filewidgets/kfilewidget.cpp
Show First 20 Lines • Show All 187 Lines • ▼ Show 20 Line(s) | 82 | public: | |||
---|---|---|---|---|---|
188 | void _k_toggleBookmarks(bool); | 188 | void _k_toggleBookmarks(bool); | ||
189 | void _k_slotAutoSelectExtClicked(); | 189 | void _k_slotAutoSelectExtClicked(); | ||
190 | void _k_placesViewSplitterMoved(int, int); | 190 | void _k_placesViewSplitterMoved(int, int); | ||
191 | void _k_activateUrlNavigator(); | 191 | void _k_activateUrlNavigator(); | ||
192 | void _k_zoomOutIconsSize(); | 192 | void _k_zoomOutIconsSize(); | ||
193 | void _k_zoomInIconsSize(); | 193 | void _k_zoomInIconsSize(); | ||
194 | void _k_slotIconSizeSliderMoved(int); | 194 | void _k_slotIconSizeSliderMoved(int); | ||
195 | void _k_slotIconSizeChanged(int); | 195 | void _k_slotIconSizeChanged(int); | ||
196 | void _k_slotViewDoubleClicked(const QModelIndex&); | ||||
196 | 197 | | |||
197 | void addToRecentDocuments(); | 198 | void addToRecentDocuments(); | ||
198 | 199 | | |||
199 | QString locationEditCurrentText() const; | 200 | QString locationEditCurrentText() const; | ||
200 | 201 | | |||
201 | /** | 202 | /** | ||
202 | * KIO::NetAccess::mostLocalUrl local replacement. | 203 | * KIO::NetAccess::mostLocalUrl local replacement. | ||
203 | * This method won't show any progress dialogs for stating, since | 204 | * This method won't show any progress dialogs for stating, since | ||
▲ Show 20 Lines • Show All 965 Lines • ▼ Show 20 Line(s) | 1166 | if (!(ops->mode() & KFile::Files)) { | |||
1169 | } | 1170 | } | ||
1170 | setLocationText(i.url()); | 1171 | setLocationText(i.url()); | ||
1171 | } else { | 1172 | } else { | ||
1172 | multiSelectionChanged(); | 1173 | multiSelectionChanged(); | ||
1173 | emit q->selectionChanged(); | 1174 | emit q->selectionChanged(); | ||
1174 | } | 1175 | } | ||
1175 | 1176 | | |||
1176 | // if we are saving, let another chance to the user before accepting the dialog (or trying to | 1177 | // if we are saving, let another chance to the user before accepting the dialog (or trying to | ||
1177 | // accept). This way the user can choose a file and add a "_2" for instance to the filename | 1178 | // accept). This way the user can choose a file and add a "_2" for instance to the filename. | ||
1179 | // Double clicking however will trigger this, regardless of single/double click mouse setting, | ||||
rkflx: Do you mean "override" instead of "trigger" here? | |||||
1180 | // see: _k_slotViewDoubleClicked | ||||
1178 | if (operationMode == KFileWidget::Saving) { | 1181 | if (operationMode == KFileWidget::Saving) { | ||
1179 | locationEdit->setFocus(); | 1182 | locationEdit->setFocus(); | ||
1180 | } else { | 1183 | } else { | ||
1181 | q->slotOk(); | 1184 | q->slotOk(); | ||
1182 | } | 1185 | } | ||
1183 | } | 1186 | } | ||
ngraham: Unnecessary unrelated whitespace change | |||||
1184 | 1187 | | |||
1185 | // I know it's slow to always iterate thru the whole filelist | 1188 | // I know it's slow to always iterate thru the whole filelist | ||
1186 | // (d->ops->selectedItems()), but what can we do? | 1189 | // (d->ops->selectedItems()), but what can we do? | ||
1187 | void KFileWidgetPrivate::multiSelectionChanged() | 1190 | void KFileWidgetPrivate::multiSelectionChanged() | ||
1188 | { | 1191 | { | ||
1189 | if (locationEdit->hasFocus() && !locationEdit->currentText().isEmpty()) { // don't disturb | 1192 | if (locationEdit->hasFocus() && !locationEdit->currentText().isEmpty()) { // don't disturb | ||
1190 | return; | 1193 | return; | ||
1191 | } | 1194 | } | ||
▲ Show 20 Lines • Show All 648 Lines • ▼ Show 20 Line(s) | |||||
1840 | void KFileWidget::showEvent(QShowEvent *event) | 1843 | void KFileWidget::showEvent(QShowEvent *event) | ||
1841 | { | 1844 | { | ||
1842 | if (!d->hasView) { // delayed view-creation | 1845 | if (!d->hasView) { // delayed view-creation | ||
1843 | Q_ASSERT(d); | 1846 | Q_ASSERT(d); | ||
1844 | Q_ASSERT(d->ops); | 1847 | Q_ASSERT(d->ops); | ||
1845 | d->ops->setView(KFile::Default); | 1848 | d->ops->setView(KFile::Default); | ||
1846 | d->ops->view()->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum)); | 1849 | d->ops->view()->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum)); | ||
1847 | d->hasView = true; | 1850 | d->hasView = true; | ||
1851 | | ||||
1852 | connect(d->ops->view(), SIGNAL(doubleClicked(QModelIndex)), this, SLOT(_k_slotViewDoubleClicked(QModelIndex))); | ||||
Let's use new-style signal/slot syntax for new code. See https://wiki.qt.io/New_Signal_Slot_Syntax ngraham: Let's use new-style signal/slot syntax for new code. See https://wiki.qt. | |||||
Is this even possible without a lot of refactoring (which would be out-of-scope for this patch)? rkflx: Is this even possible without a lot of refactoring (which would be out-of-scope for this patch)? | |||||
ngraham: Not for everything, just this one. | |||||
rkflx: Well, how should that line look like then? | |||||
I'm having a lot of trouble finding the correct syntax... anemeth: I'm having a lot of trouble finding the correct syntax...
And the compiler is giving me 100… | |||||
Hmm, you're right, I can't get it to work without a lot of refactoring either. Let's leave this alone for now and do the connect syntax porting later. ngraham: Hmm, you're right, I can't get it to work without a lot of refactoring either. Let's leave this… | |||||
1848 | } | 1853 | } | ||
1849 | d->ops->clearHistory(); | 1854 | d->ops->clearHistory(); | ||
1850 | 1855 | | |||
1851 | QWidget::showEvent(event); | 1856 | QWidget::showEvent(event); | ||
1852 | } | 1857 | } | ||
1853 | 1858 | | |||
1854 | bool KFileWidget::eventFilter(QObject *watched, QEvent *event) | 1859 | bool KFileWidget::eventFilter(QObject *watched, QEvent *event) | ||
1855 | { | 1860 | { | ||
▲ Show 20 Lines • Show All 287 Lines • ▼ Show 20 Line(s) | 2147 | case KIconLoader::SizeEnormous: | |||
2143 | iconSizeSlider->setToolTip(i18n("Icon size: %1 pixels (standard size)", value)); | 2148 | iconSizeSlider->setToolTip(i18n("Icon size: %1 pixels (standard size)", value)); | ||
2144 | break; | 2149 | break; | ||
2145 | default: | 2150 | default: | ||
2146 | iconSizeSlider->setToolTip(i18n("Icon size: %1 pixels", value)); | 2151 | iconSizeSlider->setToolTip(i18n("Icon size: %1 pixels", value)); | ||
2147 | break; | 2152 | break; | ||
2148 | } | 2153 | } | ||
2149 | } | 2154 | } | ||
2150 | 2155 | | |||
2156 | void KFileWidgetPrivate::_k_slotViewDoubleClicked(const QModelIndex &index) | ||||
2157 | { | ||||
2158 | if (operationMode == KFileWidget::Saving && index.isValid()) { | ||||
2159 | q->slotOk(); | ||||
2160 | } | ||||
2161 | } | ||||
2162 | | ||||
I'd move that right under :_k_slotIconSizeSliderMoved, to keep ordering at least somewhat consistent with the declaration. rkflx: I'd move that right under `:_k_slotIconSizeSliderMoved`, to keep ordering at least somewhat… | |||||
2151 | void KFileWidgetPrivate::_k_slotIconSizeSliderMoved(int _value) | 2163 | void KFileWidgetPrivate::_k_slotIconSizeSliderMoved(int _value) | ||
2152 | { | 2164 | { | ||
2153 | // Force this to be called in case this slot is called first on the | 2165 | // Force this to be called in case this slot is called first on the | ||
2154 | // slider move. | 2166 | // slider move. | ||
2155 | _k_slotIconSizeChanged(_value); | 2167 | _k_slotIconSizeChanged(_value); | ||
2156 | 2168 | | |||
2157 | QPoint global(iconSizeSlider->rect().topLeft()); | 2169 | QPoint global(iconSizeSlider->rect().topLeft()); | ||
2158 | global.ry() += iconSizeSlider->height() / 2; | 2170 | global.ry() += iconSizeSlider->height() / 2; | ||
2159 | QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), iconSizeSlider->mapToGlobal(global)); | 2171 | QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), iconSizeSlider->mapToGlobal(global)); | ||
2160 | QApplication::sendEvent(iconSizeSlider, &toolTipEvent); | 2172 | QApplication::sendEvent(iconSizeSlider, &toolTipEvent); | ||
2161 | } | 2173 | } | ||
2162 | 2174 | | |||
2163 | static QString getExtensionFromPatternList(const QStringList &patternList) | 2175 | static QString getExtensionFromPatternList(const QStringList &patternList) | ||
2164 | { | 2176 | { | ||
2165 | // qDebug(); | 2177 | // qDebug(); | ||
2166 | 2178 | | |||
I find inf as a variable name slightly too cryptic. But actually I'd just write this inline and go without QFileInfo and the QUrl conversion altogether, because KFileItem should already provide what is needed: && ops->selectedItems().first().isFile() rkflx: I find `inf` as a variable name slightly too cryptic.
But actually I'd just write this inline… | |||||
2167 | QString ret; | 2179 | QString ret; | ||
2168 | // qDebug() << "\tgetExtension " << patternList; | 2180 | // qDebug() << "\tgetExtension " << patternList; | ||
2169 | 2181 | | |||
2170 | QStringList::ConstIterator patternListEnd = patternList.end(); | 2182 | QStringList::ConstIterator patternListEnd = patternList.end(); | ||
2171 | for (QStringList::ConstIterator it = patternList.begin(); | 2183 | for (QStringList::ConstIterator it = patternList.begin(); | ||
2172 | it != patternListEnd; | 2184 | it != patternListEnd; | ||
2173 | ++it) { | 2185 | ++it) { | ||
2174 | // qDebug() << "\t\ttry: \'" << (*it) << "\'"; | 2186 | // qDebug() << "\t\ttry: \'" << (*it) << "\'"; | ||
▲ Show 20 Lines • Show All 694 Lines • Show Last 20 Lines |
Do you mean "override" instead of "trigger" here?