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 964 Lines • ▼ Show 20 Line(s) | 1167 | if (i.isNull()) { | |||
| 1168 | return; | 1169 | return; | ||
| 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 | // accept). This way the user can choose a file and add a "_2" for instance to the filename | | |||
| 1178 | if (operationMode == KFileWidget::Saving) { | 1177 | if (operationMode == KFileWidget::Saving) { | ||
rkflx: Do you mean "override" instead of "trigger" here? | |||||
| 1179 | locationEdit->setFocus(); | 1178 | locationEdit->setFocus(); | ||
| 1180 | } else { | 1179 | } else { | ||
| 1181 | q->slotOk(); | 1180 | q->slotOk(); | ||
| 1182 | } | 1181 | } | ||
| 1183 | } | 1182 | } | ||
ngraham: Unnecessary unrelated whitespace change | |||||
| 1184 | 1183 | | |||
| 1185 | // I know it's slow to always iterate thru the whole filelist | 1184 | // I know it's slow to always iterate thru the whole filelist | ||
| 1186 | // (d->ops->selectedItems()), but what can we do? | 1185 | // (d->ops->selectedItems()), but what can we do? | ||
| 1187 | void KFileWidgetPrivate::multiSelectionChanged() | 1186 | void KFileWidgetPrivate::multiSelectionChanged() | ||
| 1188 | { | 1187 | { | ||
| 1189 | if (locationEdit->hasFocus() && !locationEdit->currentText().isEmpty()) { // don't disturb | 1188 | if (locationEdit->hasFocus() && !locationEdit->currentText().isEmpty()) { // don't disturb | ||
| 1190 | return; | 1189 | return; | ||
| 1191 | } | 1190 | } | ||
| ▲ Show 20 Lines • Show All 648 Lines • ▼ Show 20 Line(s) | |||||
| 1840 | void KFileWidget::showEvent(QShowEvent *event) | 1839 | void KFileWidget::showEvent(QShowEvent *event) | ||
| 1841 | { | 1840 | { | ||
| 1842 | if (!d->hasView) { // delayed view-creation | 1841 | if (!d->hasView) { // delayed view-creation | ||
| 1843 | Q_ASSERT(d); | 1842 | Q_ASSERT(d); | ||
| 1844 | Q_ASSERT(d->ops); | 1843 | Q_ASSERT(d->ops); | ||
| 1845 | d->ops->setView(KFile::Default); | 1844 | d->ops->setView(KFile::Default); | ||
| 1846 | d->ops->view()->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum)); | 1845 | d->ops->view()->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum)); | ||
| 1847 | d->hasView = true; | 1846 | d->hasView = true; | ||
| 1847 | | ||||
| 1848 | 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 | } | 1849 | } | ||
| 1849 | d->ops->clearHistory(); | 1850 | d->ops->clearHistory(); | ||
| 1850 | 1851 | | |||
| 1851 | QWidget::showEvent(event); | 1852 | QWidget::showEvent(event); | ||
| 1852 | } | 1853 | } | ||
| 1853 | 1854 | | |||
| 1854 | bool KFileWidget::eventFilter(QObject *watched, QEvent *event) | 1855 | bool KFileWidget::eventFilter(QObject *watched, QEvent *event) | ||
| 1855 | { | 1856 | { | ||
| ▲ Show 20 Lines • Show All 287 Lines • ▼ Show 20 Line(s) | 2143 | case KIconLoader::SizeEnormous: | |||
| 2143 | iconSizeSlider->setToolTip(i18n("Icon size: %1 pixels (standard size)", value)); | 2144 | iconSizeSlider->setToolTip(i18n("Icon size: %1 pixels (standard size)", value)); | ||
| 2144 | break; | 2145 | break; | ||
| 2145 | default: | 2146 | default: | ||
| 2146 | iconSizeSlider->setToolTip(i18n("Icon size: %1 pixels", value)); | 2147 | iconSizeSlider->setToolTip(i18n("Icon size: %1 pixels", value)); | ||
| 2147 | break; | 2148 | break; | ||
| 2148 | } | 2149 | } | ||
| 2149 | } | 2150 | } | ||
| 2150 | 2151 | | |||
| 2152 | void KFileWidgetPrivate::_k_slotViewDoubleClicked(const QModelIndex &index) | ||||
| 2153 | { | ||||
| 2154 | if (operationMode == KFileWidget::Saving && index.isValid()) { | ||||
| 2155 | q->slotOk(); | ||||
| 2156 | } | ||||
| 2157 | } | ||||
| 2158 | | ||||
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) | 2159 | void KFileWidgetPrivate::_k_slotIconSizeSliderMoved(int _value) | ||
| 2152 | { | 2160 | { | ||
| 2153 | // Force this to be called in case this slot is called first on the | 2161 | // Force this to be called in case this slot is called first on the | ||
| 2154 | // slider move. | 2162 | // slider move. | ||
| 2155 | _k_slotIconSizeChanged(_value); | 2163 | _k_slotIconSizeChanged(_value); | ||
| 2156 | 2164 | | |||
| 2157 | QPoint global(iconSizeSlider->rect().topLeft()); | 2165 | QPoint global(iconSizeSlider->rect().topLeft()); | ||
| 2158 | global.ry() += iconSizeSlider->height() / 2; | 2166 | global.ry() += iconSizeSlider->height() / 2; | ||
| 2159 | QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), iconSizeSlider->mapToGlobal(global)); | 2167 | QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), iconSizeSlider->mapToGlobal(global)); | ||
| 2160 | QApplication::sendEvent(iconSizeSlider, &toolTipEvent); | 2168 | QApplication::sendEvent(iconSizeSlider, &toolTipEvent); | ||
| 2161 | } | 2169 | } | ||
| 2162 | 2170 | | |||
| 2163 | static QString getExtensionFromPatternList(const QStringList &patternList) | 2171 | static QString getExtensionFromPatternList(const QStringList &patternList) | ||
| 2164 | { | 2172 | { | ||
| 2165 | // qDebug(); | 2173 | // qDebug(); | ||
| 2166 | 2174 | | |||
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; | 2175 | QString ret; | ||
| 2168 | // qDebug() << "\tgetExtension " << patternList; | 2176 | // qDebug() << "\tgetExtension " << patternList; | ||
| 2169 | 2177 | | |||
| 2170 | QStringList::ConstIterator patternListEnd = patternList.end(); | 2178 | QStringList::ConstIterator patternListEnd = patternList.end(); | ||
| 2171 | for (QStringList::ConstIterator it = patternList.begin(); | 2179 | for (QStringList::ConstIterator it = patternList.begin(); | ||
| 2172 | it != patternListEnd; | 2180 | it != patternListEnd; | ||
| 2173 | ++it) { | 2181 | ++it) { | ||
| 2174 | // qDebug() << "\t\ttry: \'" << (*it) << "\'"; | 2182 | // qDebug() << "\t\ttry: \'" << (*it) << "\'"; | ||
| ▲ Show 20 Lines • Show All 694 Lines • Show Last 20 Lines | |||||
Do you mean "override" instead of "trigger" here?