Changeset View
Standalone View
src/filewidgets/kfilewidget.cpp
Show First 20 Lines • Show All 124 Lines • ▼ Show 20 Line(s) | 82 | public: | |||
---|---|---|---|---|---|
125 | void readViewConfig(); | 125 | void readViewConfig(); | ||
126 | void writeViewConfig(); | 126 | void writeViewConfig(); | ||
127 | void setNonExtSelection(); | 127 | void setNonExtSelection(); | ||
128 | void setLocationText(const QUrl &); | 128 | void setLocationText(const QUrl &); | ||
129 | void setLocationText(const QList<QUrl> &); | 129 | void setLocationText(const QList<QUrl> &); | ||
130 | void appendExtension(QUrl &url); | 130 | void appendExtension(QUrl &url); | ||
131 | void updateLocationEditExtension(const QString &); | 131 | void updateLocationEditExtension(const QString &); | ||
132 | void updateFilter(); | 132 | void updateFilter(); | ||
133 | void updateFilterText(); | ||||
133 | QList<QUrl> &parseSelectedUrls(); | 134 | QList<QUrl> &parseSelectedUrls(); | ||
134 | /** | 135 | /** | ||
135 | * Parses the string "line" for files. If line doesn't contain any ", the | 136 | * Parses the string "line" for files. If line doesn't contain any ", the | ||
136 | * whole line will be interpreted as one file. If the number of " is odd, | 137 | * whole line will be interpreted as one file. If the number of " is odd, | ||
137 | * an empty list will be returned. Otherwise, all items enclosed in " " | 138 | * an empty list will be returned. Otherwise, all items enclosed in " " | ||
138 | * will be returned as correct urls. | 139 | * will be returned as correct urls. | ||
139 | */ | 140 | */ | ||
140 | QList<QUrl> tokenize(const QString &line) const; | 141 | QList<QUrl> tokenize(const QString &line) const; | ||
▲ Show 20 Lines • Show All 444 Lines • ▼ Show 20 Line(s) | 415 | #endif | |||
585 | d->locationEdit->setAutoDeleteCompletionObject(true); | 586 | d->locationEdit->setAutoDeleteCompletionObject(true); | ||
586 | connect(fileCompletionObj, SIGNAL(match(QString)), | 587 | connect(fileCompletionObj, SIGNAL(match(QString)), | ||
587 | SLOT(_k_fileCompletion(QString))); | 588 | SLOT(_k_fileCompletion(QString))); | ||
588 | 589 | | |||
589 | connect(d->locationEdit, SIGNAL(returnPressed(QString)), | 590 | connect(d->locationEdit, SIGNAL(returnPressed(QString)), | ||
590 | this, SLOT(_k_locationAccepted(QString))); | 591 | this, SLOT(_k_locationAccepted(QString))); | ||
591 | 592 | | |||
592 | // the Filter label/edit | 593 | // the Filter label/edit | ||
593 | whatsThisText = i18n("<qt>This is the filter to apply to the file list. " | 594 | d->filterLabel = new QLabel(this); | ||
apol: Pass this as parent, I guess when it's added to the layouts somehow it will get reparented, but… | |||||
594 | "File names that do not match the filter will not be shown.<p>" | | |||
595 | "You may select from one of the preset filters in the " | | |||
596 | "drop down menu, or you may enter a custom filter " | | |||
597 | "directly into the text area.</p><p>" | | |||
598 | "Wildcards such as * and ? are allowed.</p></qt>"); | | |||
599 | d->filterLabel = new QLabel(i18n("&Filter:"), this); | | |||
600 | d->filterLabel->setWhatsThis(whatsThisText); | | |||
601 | d->filterWidget = new KFileFilterCombo(this); | 595 | d->filterWidget = new KFileFilterCombo(this); | ||
596 | d->updateFilterText(); | ||||
602 | // Properly let the dialog be resized (to smaller). Otherwise we could have | 597 | // Properly let the dialog be resized (to smaller). Otherwise we could have | ||
603 | // huge dialogs that can't be resized to smaller (it would be as big as the longest | 598 | // huge dialogs that can't be resized to smaller (it would be as big as the longest | ||
604 | // item in this combo box). (ereslibre) | 599 | // item in this combo box). (ereslibre) | ||
605 | d->filterWidget->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength); | 600 | d->filterWidget->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength); | ||
606 | d->filterWidget->setWhatsThis(whatsThisText); | | |||
607 | d->filterLabel->setBuddy(d->filterWidget); | 601 | d->filterLabel->setBuddy(d->filterWidget); | ||
608 | connect(d->filterWidget, SIGNAL(filterChanged()), SLOT(_k_slotFilterChanged())); | 602 | connect(d->filterWidget, SIGNAL(filterChanged()), SLOT(_k_slotFilterChanged())); | ||
609 | 603 | | |||
610 | d->filterDelayTimer.setSingleShot(true); | 604 | d->filterDelayTimer.setSingleShot(true); | ||
611 | d->filterDelayTimer.setInterval(300); | 605 | d->filterDelayTimer.setInterval(300); | ||
612 | connect(d->filterWidget, &QComboBox::editTextChanged, &d->filterDelayTimer, QOverload<>::of(&QTimer::start)); | 606 | connect(d->filterWidget, &QComboBox::editTextChanged, &d->filterDelayTimer, QOverload<>::of(&QTimer::start)); | ||
613 | connect(&d->filterDelayTimer, SIGNAL(timeout()), SLOT(_k_slotFilterChanged())); | 607 | connect(&d->filterDelayTimer, SIGNAL(timeout()), SLOT(_k_slotFilterChanged())); | ||
614 | 608 | | |||
▲ Show 20 Lines • Show All 121 Lines • ▼ Show 20 Line(s) | 726 | { | |||
736 | types.append(QStringLiteral("inode/directory")); | 730 | types.append(QStringLiteral("inode/directory")); | ||
737 | d->ops->clearFilter(); | 731 | d->ops->clearFilter(); | ||
738 | d->ops->setMimeFilter(types); | 732 | d->ops->setMimeFilter(types); | ||
739 | d->hasDefaultFilter = !defaultType.isEmpty(); | 733 | d->hasDefaultFilter = !defaultType.isEmpty(); | ||
740 | d->filterWidget->setEditable(!d->hasDefaultFilter || | 734 | d->filterWidget->setEditable(!d->hasDefaultFilter || | ||
741 | d->operationMode != Saving); | 735 | d->operationMode != Saving); | ||
742 | 736 | | |||
743 | d->updateAutoSelectExtension(); | 737 | d->updateAutoSelectExtension(); | ||
738 | d->updateFilterText(); | ||||
744 | } | 739 | } | ||
apol: Isn't it a bit weird to do this in setMimeFilter? | |||||
I did it in setMimeFilter since that's where it's determined whether or not there's a limited assortment of mimetypes, which is what controls what the string should be. Conditionalizing it based on mode seemed safe enough considering that there's mode-specific code a few lines above, on 741. ngraham: I did it in `setMimeFilter` since that's where it's determined whether or not there's a limited… | |||||
::setOperationMode would need to update that as well, no? Then it would need splitting into a separate function, otherwise apol: ::setOperationMode would need to update that as well, no? Then it would need splitting into a… | |||||
745 | 740 | | |||
746 | void KFileWidget::clearFilter() | 741 | void KFileWidget::clearFilter() | ||
747 | { | 742 | { | ||
748 | d->filterWidget->setFilter(QString()); | 743 | d->filterWidget->setFilter(QString()); | ||
749 | d->ops->clearFilter(); | 744 | d->ops->clearFilter(); | ||
750 | d->hasDefaultFilter = false; | 745 | d->hasDefaultFilter = false; | ||
751 | d->filterWidget->setEditable(true); | 746 | d->filterWidget->setEditable(true); | ||
752 | 747 | | |||
▲ Show 20 Lines • Show All 1337 Lines • ▼ Show 20 Line(s) | 2084 | } else { | |||
2090 | KGuiItem::assign(d->okButton, KStandardGuiItem::ok()); | 2085 | KGuiItem::assign(d->okButton, KStandardGuiItem::ok()); | ||
2091 | } | 2086 | } | ||
2092 | d->updateLocationWhatsThis(); | 2087 | d->updateLocationWhatsThis(); | ||
2093 | d->updateAutoSelectExtension(); | 2088 | d->updateAutoSelectExtension(); | ||
2094 | 2089 | | |||
2095 | if (d->ops) { | 2090 | if (d->ops) { | ||
2096 | d->ops->setIsSaving(mode == Saving); | 2091 | d->ops->setIsSaving(mode == Saving); | ||
2097 | } | 2092 | } | ||
2093 | d->updateFilterText(); | ||||
2098 | } | 2094 | } | ||
2099 | 2095 | | |||
2100 | KFileWidget::OperationMode KFileWidget::operationMode() const | 2096 | KFileWidget::OperationMode KFileWidget::operationMode() const | ||
2101 | { | 2097 | { | ||
2102 | return d->operationMode; | 2098 | return d->operationMode; | ||
2103 | } | 2099 | } | ||
2104 | 2100 | | |||
2105 | void KFileWidgetPrivate::_k_slotAutoSelectExtClicked() | 2101 | void KFileWidgetPrivate::_k_slotAutoSelectExtClicked() | ||
▲ Show 20 Lines • Show All 687 Lines • ▼ Show 20 Line(s) | 2787 | } else { | |||
2793 | if (lastDot > 0) { | 2789 | if (lastDot > 0) { | ||
2794 | locationEdit->lineEdit()->setSelection(0, lastDot); | 2790 | locationEdit->lineEdit()->setSelection(0, lastDot); | ||
2795 | } else { | 2791 | } else { | ||
2796 | locationEdit->lineEdit()->selectAll(); | 2792 | locationEdit->lineEdit()->selectAll(); | ||
2797 | } | 2793 | } | ||
2798 | } | 2794 | } | ||
2799 | } | 2795 | } | ||
2800 | 2796 | | |||
2797 | // Sets the filter text to "File type" if the dialog is saving and a mimetype | ||||
2798 | // filter has been set; otherwise, the text is "Filter:" | ||||
2799 | void KFileWidgetPrivate::updateFilterText() | ||||
2800 | { | ||||
2801 | QString label; | ||||
2802 | QString whatsThisText; | ||||
2803 | | ||||
2804 | if (operationMode == KFileWidget::Saving && filterWidget->isMimeFilter()) { | ||||
2805 | label = i18n("&File type:"); | ||||
2806 | whatsThisText = i18n("<qt>This is the file type selector. It is used to select the format that the file will be saved as.</qt>"); | ||||
why is this limited to the saving mode? you can perfectly use a mimetype filter when opening files pino: why is this limited to the saving mode? you can perfectly use a mimetype filter when opening… | |||||
When opening, the mimetype chooser still has filtering functionality and isn't a drop-down menu combobox like it is when saving. I couldn't come up with an adequate string to communicate both purposes and figured "Filter" was good enough. ngraham: When opening, the mimetype chooser still has filtering functionality and isn't a drop-down menu… | |||||
2807 | } else { | ||||
2808 | label = i18n("&Filter:"); | ||||
2809 | whatsThisText = i18n("<qt>This is the filter to apply to the file list. " | ||||
2810 | "File names that do not match the filter will not be shown.<p>" | ||||
2811 | "You may select from one of the preset filters in the " | ||||
2812 | "drop down menu, or you may enter a custom filter " | ||||
2813 | "directly into the text area.</p><p>" | ||||
2814 | "Wildcards such as * and ? are allowed.</p></qt>"); | ||||
2815 | } | ||||
2816 | | ||||
2817 | if (filterLabel) { | ||||
2818 | filterLabel->setText(label); | ||||
2819 | filterLabel->setWhatsThis(whatsThisText); | ||||
2820 | } | ||||
2821 | if (filterWidget) { | ||||
2822 | filterWidget->setWhatsThis(whatsThisText); | ||||
2823 | } | ||||
2824 | } | ||||
2825 | | ||||
2801 | KToolBar *KFileWidget::toolBar() const | 2826 | KToolBar *KFileWidget::toolBar() const | ||
2802 | { | 2827 | { | ||
2803 | return d->toolbar; | 2828 | return d->toolbar; | ||
2804 | } | 2829 | } | ||
2805 | 2830 | | |||
2806 | void KFileWidget::setCustomWidget(QWidget *widget) | 2831 | void KFileWidget::setCustomWidget(QWidget *widget) | ||
2807 | { | 2832 | { | ||
2808 | delete d->bottomCustomWidget; | 2833 | delete d->bottomCustomWidget; | ||
▲ Show 20 Lines • Show All 115 Lines • Show Last 20 Lines |
Pass this as parent, I guess when it's added to the layouts somehow it will get reparented, but I'd say it's a good practice.