Changeset View
Standalone View
src/filewidgets/kfilewidget.cpp
| Show First 20 Lines • Show All 1148 Lines • ▼ Show 20 Line(s) | 1135 | if (!(ops->mode() & KFile::Files)) { | |||
|---|---|---|---|---|---|
| 1149 | emit q->fileHighlighted(url); | 1149 | emit q->fileHighlighted(url); | ||
| 1150 | } else { | 1150 | } else { | ||
| 1151 | multiSelectionChanged(); | 1151 | multiSelectionChanged(); | ||
| 1152 | emit q->selectionChanged(); | 1152 | emit q->selectionChanged(); | ||
| 1153 | } | 1153 | } | ||
| 1154 | 1154 | | |||
| 1155 | locationEdit->lineEdit()->setModified(false); | 1155 | locationEdit->lineEdit()->setModified(false); | ||
| 1156 | locationEdit->lineEdit()->selectAll(); | 1156 | locationEdit->lineEdit()->selectAll(); | ||
| 1157 | locationEdit->setFocus(); | ||||
| 1157 | } | 1158 | } | ||
| 1158 | 1159 | | |||
| 1159 | void KFileWidgetPrivate::_k_fileSelected(const KFileItem &i) | 1160 | void KFileWidgetPrivate::_k_fileSelected(const KFileItem &i) | ||
| 1160 | { | 1161 | { | ||
| 1161 | if (!i.isNull() && i.isDir()) { | 1162 | if (!i.isNull() && i.isDir()) { | ||
| 1162 | return; | 1163 | return; | ||
| 1163 | } | 1164 | } | ||
| 1164 | 1165 | | |||
| 1165 | if (!(ops->mode() & KFile::Files)) { | 1166 | if (!(ops->mode() & KFile::Files)) { | ||
| 1166 | if (i.isNull()) { | 1167 | if (i.isNull()) { | ||
| 1167 | setLocationText(QUrl()); | 1168 | setLocationText(QUrl()); | ||
| 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) { | | |||
| 1179 | locationEdit->setFocus(); | | |||
| 1180 | } else { | | |||
| 1181 | q->slotOk(); | 1177 | q->slotOk(); | ||
rkflx: Do you mean "override" instead of "trigger" here? | |||||
| 1182 | } | 1178 | } | ||
ngraham: Unnecessary unrelated whitespace change | |||||
| 1183 | } | | |||
| 1184 | 1179 | | |||
| 1185 | // I know it's slow to always iterate thru the whole filelist | 1180 | // I know it's slow to always iterate thru the whole filelist | ||
| 1186 | // (d->ops->selectedItems()), but what can we do? | 1181 | // (d->ops->selectedItems()), but what can we do? | ||
| 1187 | void KFileWidgetPrivate::multiSelectionChanged() | 1182 | void KFileWidgetPrivate::multiSelectionChanged() | ||
| 1188 | { | 1183 | { | ||
| 1189 | if (locationEdit->hasFocus() && !locationEdit->currentText().isEmpty()) { // don't disturb | 1184 | if (locationEdit->hasFocus() && !locationEdit->currentText().isEmpty()) { // don't disturb | ||
| 1190 | return; | 1185 | return; | ||
| 1191 | } | 1186 | } | ||
| ▲ Show 20 Lines • Show All 649 Lines • ▼ Show 20 Line(s) | |||||
| 1841 | { | 1836 | { | ||
| 1842 | if (!d->hasView) { // delayed view-creation | 1837 | if (!d->hasView) { // delayed view-creation | ||
| 1843 | Q_ASSERT(d); | 1838 | Q_ASSERT(d); | ||
| 1844 | Q_ASSERT(d->ops); | 1839 | Q_ASSERT(d->ops); | ||
| 1845 | d->ops->setView(KFile::Default); | 1840 | d->ops->setView(KFile::Default); | ||
| 1846 | d->ops->view()->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum)); | 1841 | d->ops->view()->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum)); | ||
| 1847 | d->hasView = true; | 1842 | d->hasView = true; | ||
| 1848 | } | 1843 | } | ||
| 1849 | d->ops->clearHistory(); | 1844 | d->ops->clearHistory(); | ||
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… | |||||
| 1850 | 1845 | | |||
| 1851 | QWidget::showEvent(event); | 1846 | QWidget::showEvent(event); | ||
| 1852 | } | 1847 | } | ||
| 1853 | 1848 | | |||
| 1854 | bool KFileWidget::eventFilter(QObject *watched, QEvent *event) | 1849 | bool KFileWidget::eventFilter(QObject *watched, QEvent *event) | ||
| 1855 | { | 1850 | { | ||
| 1856 | const bool res = QWidget::eventFilter(watched, event); | 1851 | const bool res = QWidget::eventFilter(watched, event); | ||
| 1857 | 1852 | | |||
| ▲ Show 20 Lines • Show All 285 Lines • ▼ Show 20 Line(s) | 2137 | case KIconLoader::SizeEnormous: | |||
| 2143 | iconSizeSlider->setToolTip(i18n("Icon size: %1 pixels (standard size)", value)); | 2138 | iconSizeSlider->setToolTip(i18n("Icon size: %1 pixels (standard size)", value)); | ||
| 2144 | break; | 2139 | break; | ||
| 2145 | default: | 2140 | default: | ||
| 2146 | iconSizeSlider->setToolTip(i18n("Icon size: %1 pixels", value)); | 2141 | iconSizeSlider->setToolTip(i18n("Icon size: %1 pixels", value)); | ||
| 2147 | break; | 2142 | break; | ||
| 2148 | } | 2143 | } | ||
| 2149 | } | 2144 | } | ||
| 2150 | 2145 | | |||
| 2151 | void KFileWidgetPrivate::_k_slotIconSizeSliderMoved(int _value) | 2146 | void KFileWidgetPrivate::_k_slotIconSizeSliderMoved(int _value) | ||
| 2152 | { | 2147 | { | ||
| 2153 | // Force this to be called in case this slot is called first on the | 2148 | // Force this to be called in case this slot is called first on the | ||
| 2154 | // slider move. | 2149 | // slider move. | ||
| 2155 | _k_slotIconSizeChanged(_value); | 2150 | _k_slotIconSizeChanged(_value); | ||
| 2156 | 2151 | | |||
| 2157 | QPoint global(iconSizeSlider->rect().topLeft()); | 2152 | QPoint global(iconSizeSlider->rect().topLeft()); | ||
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… | |||||
| 2158 | global.ry() += iconSizeSlider->height() / 2; | 2153 | global.ry() += iconSizeSlider->height() / 2; | ||
| 2159 | QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), iconSizeSlider->mapToGlobal(global)); | 2154 | QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), iconSizeSlider->mapToGlobal(global)); | ||
| 2160 | QApplication::sendEvent(iconSizeSlider, &toolTipEvent); | 2155 | QApplication::sendEvent(iconSizeSlider, &toolTipEvent); | ||
| 2161 | } | 2156 | } | ||
| 2162 | 2157 | | |||
| 2163 | static QString getExtensionFromPatternList(const QStringList &patternList) | 2158 | static QString getExtensionFromPatternList(const QStringList &patternList) | ||
| 2164 | { | 2159 | { | ||
| 2165 | // qDebug(); | 2160 | // qDebug(); | ||
| 2166 | 2161 | | |||
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; | 2162 | QString ret; | ||
| 2168 | // qDebug() << "\tgetExtension " << patternList; | 2163 | // qDebug() << "\tgetExtension " << patternList; | ||
| 2169 | 2164 | | |||
| 2170 | QStringList::ConstIterator patternListEnd = patternList.end(); | 2165 | QStringList::ConstIterator patternListEnd = patternList.end(); | ||
| 2171 | for (QStringList::ConstIterator it = patternList.begin(); | 2166 | for (QStringList::ConstIterator it = patternList.begin(); | ||
| 2172 | it != patternListEnd; | 2167 | it != patternListEnd; | ||
| 2173 | ++it) { | 2168 | ++it) { | ||
| 2174 | // qDebug() << "\t\ttry: \'" << (*it) << "\'"; | 2169 | // qDebug() << "\t\ttry: \'" << (*it) << "\'"; | ||
| ▲ Show 20 Lines • Show All 694 Lines • Show Last 20 Lines | |||||
Do you mean "override" instead of "trigger" here?