Changeset View
Changeset View
Standalone View
Standalone View
src/platformtheme/kdeplatformfiledialoghelper.cpp
Show First 20 Lines • Show All 125 Lines • ▼ Show 20 Line(s) | |||||
126 | QList<QUrl> KDEPlatformFileDialog::selectedFiles() | 126 | QList<QUrl> KDEPlatformFileDialog::selectedFiles() | ||
127 | { | 127 | { | ||
128 | return m_fileWidget->selectedUrls(); | 128 | return m_fileWidget->selectedUrls(); | ||
129 | } | 129 | } | ||
130 | 130 | | |||
131 | void KDEPlatformFileDialog::selectFile(const QUrl &filename) | 131 | void KDEPlatformFileDialog::selectFile(const QUrl &filename) | ||
132 | { | 132 | { | ||
133 | QUrl dirUrl = filename.adjusted(QUrl::RemoveFilename); | 133 | QUrl dirUrl = filename.adjusted(QUrl::RemoveFilename); | ||
134 | m_fileWidget->setUrl(dirUrl); | | |||
135 | m_fileWidget->setSelectedUrl(filename); | 134 | m_fileWidget->setSelectedUrl(filename); | ||
136 | } | 135 | } | ||
137 | 136 | | |||
138 | void KDEPlatformFileDialog::setViewMode(QFileDialogOptions::ViewMode view) | 137 | void KDEPlatformFileDialog::setViewMode(QFileDialogOptions::ViewMode view) | ||
139 | { | 138 | { | ||
140 | switch (view) { | 139 | switch (view) { | ||
141 | case QFileDialogOptions::ViewMode::Detail: | 140 | case QFileDialogOptions::ViewMode::Detail: | ||
142 | m_fileWidget->setViewMode(KFile::FileView::Detail); | 141 | m_fileWidget->setViewMode(KFile::FileView::Detail); | ||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Line(s) | |||||
218 | 217 | | |||
219 | void KDEPlatformFileDialog::selectNameFilter(const QString &filter) | 218 | void KDEPlatformFileDialog::selectNameFilter(const QString &filter) | ||
220 | { | 219 | { | ||
221 | m_fileWidget->filterWidget()->setCurrentFilter(filter); | 220 | m_fileWidget->filterWidget()->setCurrentFilter(filter); | ||
222 | } | 221 | } | ||
223 | 222 | | |||
224 | void KDEPlatformFileDialog::setDirectory(const QUrl &directory) | 223 | void KDEPlatformFileDialog::setDirectory(const QUrl &directory) | ||
225 | { | 224 | { | ||
226 | if (!directory.isLocalFile()) { | 225 | //passing non-local files as the working directory is not supported. | ||
227 | // Qt can not determine if the remote URL points to a file or a | 226 | //See QFileDialogPrivate::initialSelections | ||
meven: QFileDialogPrivate::initialSelection | |||||
That's not what that method says. It just says it can't know if the initial *selection* is a file or directory. That's unrelated to what is the start directory. QFileDialogPrivate::workingDirectory does support remote dirs. dfaure: That's not what that method says. It just says it can't know if the initial *selection* is a… | |||||
228 | // directory, that is why options()->initialDirectory() always returns | 227 | //Selectingg files should be done through the correct method. | ||
meven: typo Selectingg | |||||
229 | // the full URL. | | |||
230 | KIO::StatJob *job = KIO::stat(directory); | | |||
231 | KJobWidgets::setWindow(job, this); | | |||
232 | if (job->exec()) { | | |||
233 | KIO::UDSEntry entry = job->statResult(); | | |||
234 | if (!entry.isDir()) { | | |||
235 | // this is probably a file remove the file part | | |||
236 | m_fileWidget->setUrl(directory.adjusted(QUrl::RemoveFilename)); | | |||
237 | m_fileWidget->setSelectedUrl(directory); | | |||
238 | } | | |||
239 | else { | | |||
240 | m_fileWidget->setUrl(directory); | | |||
241 | } | | |||
242 | } | | |||
243 | } | | |||
244 | else { | | |||
245 | m_fileWidget->setUrl(directory); | 228 | m_fileWidget->setUrl(directory); | ||
246 | } | 229 | } | ||
247 | } | | |||
248 | 230 | | |||
249 | bool KDEPlatformFileDialogHelper::isSupportedUrl(const QUrl& url) const | 231 | bool KDEPlatformFileDialogHelper::isSupportedUrl(const QUrl& url) const | ||
250 | { | 232 | { | ||
251 | return KProtocolInfo::protocols().contains(url.scheme()); | 233 | return KProtocolInfo::protocols().contains(url.scheme()); | ||
252 | } | 234 | } | ||
253 | 235 | | |||
254 | //////////////////////////////////////////////// | 236 | //////////////////////////////////////////////// | ||
255 | 237 | | |||
▲ Show 20 Lines • Show All 201 Lines • Show Last 20 Lines |
QFileDialogPrivate::initialSelection