Changeset View
Changeset View
Standalone View
Standalone View
src/platformtheme/kdeplatformfiledialoghelper.cpp
Show All 25 Lines | |||||
26 | #include <kfilefiltercombo.h> | 26 | #include <kfilefiltercombo.h> | ||
27 | #include <kfilewidget.h> | 27 | #include <kfilewidget.h> | ||
28 | #include <klocalizedstring.h> | 28 | #include <klocalizedstring.h> | ||
29 | #include <kdiroperator.h> | 29 | #include <kdiroperator.h> | ||
30 | #include <KUrlComboBox> | 30 | #include <KUrlComboBox> | ||
31 | #include <KSharedConfig> | 31 | #include <KSharedConfig> | ||
32 | #include <KWindowConfig> | 32 | #include <KWindowConfig> | ||
33 | #include <KProtocolInfo> | 33 | #include <KProtocolInfo> | ||
34 | #include <QMimeDatabase> | ||||
34 | #include <QVBoxLayout> | 35 | #include <QVBoxLayout> | ||
35 | #include <QDialogButtonBox> | 36 | #include <QDialogButtonBox> | ||
36 | #include <QPushButton> | 37 | #include <QPushButton> | ||
37 | #include <QWindow> | 38 | #include <QWindow> | ||
38 | 39 | | |||
39 | #include <KIO/StatJob> | 40 | #include <KIO/StatJob> | ||
40 | #include <KJobWidgets> | 41 | #include <KJobWidgets> | ||
41 | 42 | | |||
▲ Show 20 Lines • Show All 129 Lines • ▼ Show 20 Line(s) | 171 | if (label == QFileDialogOptions::Accept) { // OK button | |||
171 | m_fileWidget->okButton()->setText(text); | 172 | m_fileWidget->okButton()->setText(text); | ||
172 | } else if (label == QFileDialogOptions::Reject) { // Cancel button | 173 | } else if (label == QFileDialogOptions::Reject) { // Cancel button | ||
173 | m_fileWidget->cancelButton()->setText(text); | 174 | m_fileWidget->cancelButton()->setText(text); | ||
174 | } else if (label == QFileDialogOptions::LookIn) { // Location label | 175 | } else if (label == QFileDialogOptions::LookIn) { // Location label | ||
175 | m_fileWidget->setLocationLabel(text); | 176 | m_fileWidget->setLocationLabel(text); | ||
176 | } | 177 | } | ||
177 | } | 178 | } | ||
178 | 179 | | |||
180 | QString KDEPlatformFileDialog::selectedMimeTypeFilter() | ||||
181 | { | ||||
182 | if (m_fileWidget->filterWidget()->isMimeFilter()) { | ||||
dfaure: Are you sure this ASSERT is wanted? See next comment. | |||||
183 | const auto mimeTypeFromFilter = QMimeDatabase().mimeTypeForName(m_fileWidget->filterWidget()->currentFilter()); | ||||
184 | // If one does not call selectMimeTypeFilter(), KFileFilterCombo::currentFilter() returns invalid mimeTypes, | ||||
185 | // such as "application/json application/zip". | ||||
186 | if (mimeTypeFromFilter.isValid()) { | ||||
187 | return mimeTypeFromFilter.name(); | ||||
188 | } | ||||
189 | } | ||||
190 | | ||||
191 | if (selectedFiles().isEmpty()) { | ||||
192 | return QString(); | ||||
193 | } | ||||
194 | | ||||
195 | // Works for both KFile::File and KFile::Files modes. | ||||
196 | return QMimeDatabase().mimeTypeForUrl(selectedFiles().at(0)).name(); | ||||
197 | } | ||||
198 | | ||||
179 | QString KDEPlatformFileDialog::selectedNameFilter() | 199 | QString KDEPlatformFileDialog::selectedNameFilter() | ||
180 | { | 200 | { | ||
181 | return m_fileWidget->filterWidget()->currentFilter(); | 201 | return m_fileWidget->filterWidget()->currentFilter(); | ||
182 | } | 202 | } | ||
183 | 203 | | |||
204 | void KDEPlatformFileDialog::selectMimeTypeFilter(const QString &filter) | ||||
205 | { | ||||
206 | m_fileWidget->filterWidget()->setCurrentFilter(filter); | ||||
207 | } | ||||
208 | | ||||
184 | void KDEPlatformFileDialog::selectNameFilter(const QString &filter) | 209 | void KDEPlatformFileDialog::selectNameFilter(const QString &filter) | ||
185 | { | 210 | { | ||
186 | m_fileWidget->filterWidget()->setCurrentFilter(filter); | 211 | m_fileWidget->filterWidget()->setCurrentFilter(filter); | ||
187 | } | 212 | } | ||
188 | 213 | | |||
189 | void KDEPlatformFileDialog::setDirectory(const QUrl &directory) | 214 | void KDEPlatformFileDialog::setDirectory(const QUrl &directory) | ||
190 | { | 215 | { | ||
191 | if (!directory.isLocalFile()) { | 216 | if (!directory.isLocalFile()) { | ||
▲ Show 20 Lines • Show All 151 Lines • ▼ Show 20 Line(s) | 357 | { | |||
343 | return true; | 368 | return true; | ||
344 | } | 369 | } | ||
345 | 370 | | |||
346 | QList<QUrl> KDEPlatformFileDialogHelper::selectedFiles() const | 371 | QList<QUrl> KDEPlatformFileDialogHelper::selectedFiles() const | ||
347 | { | 372 | { | ||
348 | return m_dialog->selectedFiles(); | 373 | return m_dialog->selectedFiles(); | ||
349 | } | 374 | } | ||
350 | 375 | | |||
376 | #if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0) | ||||
377 | QString KDEPlatformFileDialogHelper::selectedMimeTypeFilter() const | ||||
378 | { | ||||
379 | return m_dialog->selectedMimeTypeFilter(); | ||||
380 | } | ||||
381 | | ||||
382 | void KDEPlatformFileDialogHelper::selectMimeTypeFilter(const QString &filter) | ||||
383 | { | ||||
384 | m_dialog->selectMimeTypeFilter(filter); | ||||
385 | } | ||||
386 | #endif | ||||
387 | | ||||
351 | QString KDEPlatformFileDialogHelper::selectedNameFilter() const | 388 | QString KDEPlatformFileDialogHelper::selectedNameFilter() const | ||
352 | { | 389 | { | ||
353 | return kde2QtFilter(options()->nameFilters(), m_dialog->selectedNameFilter()); | 390 | return kde2QtFilter(options()->nameFilters(), m_dialog->selectedNameFilter()); | ||
354 | } | 391 | } | ||
355 | 392 | | |||
356 | QUrl KDEPlatformFileDialogHelper::directory() const | 393 | QUrl KDEPlatformFileDialogHelper::directory() const | ||
357 | { | 394 | { | ||
358 | return m_dialog->directory(); | 395 | return m_dialog->directory(); | ||
Show All 32 Lines |
Are you sure this ASSERT is wanted? See next comment.