Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qquickfiledialogimpl.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
6
7#include <QtCore/qloggingcategory.h>
8#include <QtGui/private/qguiapplication_p.h>
9#include <QtGui/qpa/qplatformtheme.h>
10#include <QtQml/qqmlinfo.h>
11#include <QtQml/qqmlfile.h>
12#include <QtQuick/private/qquickitemview_p_p.h>
13#include <QtQuickTemplates2/private/qquickdialogbuttonbox_p_p.h>
14#include <QtQuickTemplates2/private/qquickpopupitem_p_p.h>
15#include <QtQuickControls2Impl/private/qquickplatformtheme_p.h>
16#include <QtQuickDialogs2Utils/private/qquickfilenamefilter_p.h>
17
20
22
23Q_LOGGING_CATEGORY(lcCurrentFolder, "qt.quick.dialogs.quickfiledialogimpl.currentFolder")
24Q_LOGGING_CATEGORY(lcSelectedFile, "qt.quick.dialogs.quickfiledialogimpl.selectedFile")
25Q_LOGGING_CATEGORY(lcUpdateSelectedFile, "qt.quick.dialogs.quickfiledialogimpl.updateSelectedFile")
26Q_LOGGING_CATEGORY(lcOptions, "qt.quick.dialogs.quickfiledialogimpl.options")
27Q_LOGGING_CATEGORY(lcNameFilters, "qt.quick.dialogs.quickfiledialogimpl.namefilters")
28Q_LOGGING_CATEGORY(lcAttachedNameFilters, "qt.quick.dialogs.quickfiledialogimplattached.namefilters")
29Q_LOGGING_CATEGORY(lcAttachedCurrentIndex, "qt.quick.dialogs.quickfiledialogimplattached.currentIndex")
30
32{
33}
34
36{
38 if (filters == nameFilters)
39 return;
40
42 emit q->nameFiltersChanged();
43}
44
46{
49 if (!attached)
50 return;
51
52 auto openButton = attached->buttonBox()->standardButton(QPlatformDialogHelper::Open);
53 if (!openButton) {
54 qmlWarning(q).nospace() << "Can't update Open button's enabled state because it wasn't found";
55 return;
56 }
57
58 openButton->setEnabled(!selectedFile.isEmpty() && attached->breadcrumbBar()
59 && !attached->breadcrumbBar()->textField()->isVisible());
60}
61
70{
73 if (!attached || !attached->fileDialogListView())
74 return;
75
76 qCDebug(lcUpdateSelectedFile) << "updateSelectedFile called with oldFolderPath" << oldFolderPath;
77
78 QString newSelectedFilePath;
79 int newSelectedFileIndex = -1;
81 if (!oldFolderPath.isEmpty() && !newFolderPath.isEmpty()) {
82 // TODO: Add another platform theme hint for this behavior too, as e.g. macOS
83 // doesn't do it this way.
84 // If the user went up a directory (or several), we should set
85 // selectedFile to be the directory that we were in (or
86 // its closest ancestor that is a child of the new directory).
87 // E.g. if oldFolderPath is /foo/bar/baz/abc/xyz, and newFolderPath is /foo/bar,
88 // then we want to set selectedFile to be /foo/bar/baz.
89 const int indexOfFolder = oldFolderPath.indexOf(newFolderPath);
90 if (indexOfFolder != -1) {
91 // [folder]
92 // [ oldFolderPath ]
93 // /foo/bar/baz/abc/xyz
94 // [rel...Paths]
95 QStringList relativePaths = oldFolderPath.mid(indexOfFolder + newFolderPath.size()).split(QLatin1Char('/'), Qt::SkipEmptyParts);
96 newSelectedFilePath = newFolderPath + QLatin1Char('/') + relativePaths.first();
97
98 // Now find the index of that directory so that we can set the ListView's currentIndex to it.
99 const QDir newFolderDir(newFolderPath);
100 // Just to be safe...
101 if (!newFolderDir.exists()) {
102 qmlWarning(q) << "Directory" << newSelectedFilePath << "doesn't exist; can't get a file entry list for it";
103 return;
104 }
105
106 const QFileInfoList filesInNewDir = fileList(newFolderDir);
107 const QFileInfo newSelectedFileInfo(newSelectedFilePath);
108 newSelectedFileIndex = filesInNewDir.indexOf(newSelectedFileInfo);
109 }
110 }
111
112 static const bool preselectFirstFile = []() {
113 const QVariant envVar = qEnvironmentVariable("QT_QUICK_DIALOGS_PRESELECT_FIRST_FILE");
114 if (envVar.isValid() && envVar.canConvert<bool>())
115 return envVar.toBool();
118 }();
119
120 if (preselectFirstFile && newSelectedFilePath.isEmpty()) {
121 // When entering into a directory that isn't a parent of the old one, the first
122 // file delegate should be selected.
123 // TODO: is there a cheaper way to do this? QDirIterator doesn't support sorting,
124 // so we can't use that. QQuickFolderListModel uses threads to fetch its data,
125 // so should be considered asynchronous. We might be able to use it, but it would
126 // complicate the code even more...
127 const QDir newFolderDir(newFolderPath);
128 if (newFolderDir.exists()) {
129 if (!cachedFileList.isEmpty()) {
130 newSelectedFilePath = cachedFileList.first().absoluteFilePath();
131 newSelectedFileIndex = 0;
132 }
133 }
134 }
135
136 const QUrl newSelectedFileUrl = QUrl::fromLocalFile(newSelectedFilePath);
137 qCDebug(lcUpdateSelectedFile).nospace() << "updateSelectedFile is setting selectedFile to " << newSelectedFileUrl
138 << ", newSelectedFileIndex is " << newSelectedFileIndex;
139 q->setSelectedFile(newSelectedFileUrl);
140 // If the index is -1, there are no files in the directory, and so fileDialogListView's
141 // currentIndex will already be -1.
142 if (newSelectedFileIndex != -1)
143 tryUpdateFileDialogListViewCurrentIndex(newSelectedFileIndex);
144}
145
147{
148 QDir::SortFlags sortFlags = QDir::IgnoreCase;
150 sortFlags.setFlag(QDir::DirsFirst);
151 return sortFlags;
152}
153
155{
157}
158
160{
161 qCDebug(lcSelectedFile) << "setting fileDialogListView's currentIndex to" << newCurrentIndex;
162
163 // We block signals from ListView because we don't want fileDialogListViewCurrentIndexChanged
164 // to be called, as the file it gets from the delegate will not be up-to-date (but most
165 // importantly because we already just set the selected file).
167 const QSignalBlocker blocker(attached->fileDialogListView());
168 attached->fileDialogListView()->setCurrentIndex(newCurrentIndex);
170 if (QQuickItem *currentItem = attached->fileDialogListView()->currentItem())
171 currentItem->forceActiveFocus();
172}
173
181{
182 qCDebug(lcSelectedFile) << "tryUpdateFileDialogListViewCurrentIndex called with newCurrentIndex" << newCurrentIndex;
184 Q_ASSERT(attached);
185 Q_ASSERT(attached->fileDialogListView());
186
187 // We were likely trying to set an index for a file that the ListView hadn't loaded yet.
188 // We need to wait until the ListView has loaded all expected items, but since we have no
189 // efficient way of verifying that, we just check that the count is as expected.
190 if (newCurrentIndex != -1 && newCurrentIndex >= attached->fileDialogListView()->count()) {
191 qCDebug(lcSelectedFile) << "- trying to set currentIndex to" << newCurrentIndex
192 << "but fileDialogListView only has" << attached->fileDialogListView()->count()
193 << "items; setting pendingCurrentIndexToSet to" << newCurrentIndex;
194 pendingCurrentIndexToSet = newCurrentIndex;
197 return;
198 }
199
200 setFileDialogListViewCurrentIndex(newCurrentIndex);
201}
202
204{
206 qCDebug(lcSelectedFile) << "fileDialogListView count changed to" << attached->fileDialogListView()->count();
207
208 if (pendingCurrentIndexToSet != -1 && pendingCurrentIndexToSet < attached->fileDialogListView()->count()) {
209 // The view now has all of the items we expect it to, so we can set
210 // its currentIndex back to the selected file.
211 qCDebug(lcSelectedFile) << "- ListView has expected count;"
212 << "applying pending fileDialogListView currentIndex" << pendingCurrentIndexToSet;
213
218 qCDebug(lcSelectedFile) << "- reset pendingCurrentIndexToSet to -1";
219 } else {
220 qCDebug(lcSelectedFile) << "- ListView doesn't yet have expected count of" << cachedFileList.size();
221 }
222}
223
225{
226 // Let handleClick take care of calling accept().
227}
228
230{
233 // The "Open" button was clicked, so we need to set the file to the current file, if any.
234 const QFileInfo fileInfo(selectedFile.toLocalFile());
235 if (fileInfo.isDir()) {
236 // If it's a directory, navigate to it.
237 q->setCurrentFolder(selectedFile);
238 // Don't call accept(), because selecting a folder != accepting the dialog.
239 } else {
240 // Otherwise it's a file, so select it and close the dialog.
241 q->setSelectedFile(selectedFile);
242 q->accept();
244 emit q->fileSelected(selectedFile);
245 }
246 }
247}
248
251{
252}
253
255{
256 return new QQuickFileDialogImplAttached(object);
257}
258
260{
261 Q_D(const QQuickFileDialogImpl);
262 return d->currentFolder;
263}
264
265void QQuickFileDialogImpl::setCurrentFolder(const QUrl &currentFolder, SetReason setReason)
266{
268 qCDebug(lcCurrentFolder).nospace() << "setCurrentFolder called with " << currentFolder
269 << " (old currentFolder is " << d->currentFolder << ")";
270
271 // As we would otherwise get the file list from scratch in a couple of places,
272 // just get it once and cache it.
273 // We need to cache it before the equality check, otherwise opening the dialog
274 // several times in the same directory wouldn't update the cache.
275 if (!currentFolder.isEmpty())
276 d->cachedFileList = d->fileList(QQmlFile::urlToLocalFileOrQrc(currentFolder));
277 else
278 d->cachedFileList.clear();
279 qCDebug(lcCurrentFolder) << "- cachedFileList size is now " << d->cachedFileList.size();
280
281 if (currentFolder == d->currentFolder)
282 return;
283
284 const QString oldFolderPath = QQmlFile::urlToLocalFileOrQrc(d->currentFolder);
285
286 d->currentFolder = currentFolder;
287 // Don't update the selectedFile if it's an Internal set, as that
288 // means that the user just set selectedFile, and we're being called as a result of that.
289 if (setReason == SetReason::External) {
290 // Since the directory changed, the old file can no longer be selected.
291 d->updateSelectedFile(oldFolderPath);
292 }
293 emit currentFolderChanged(d->currentFolder);
294}
295
297{
298 Q_D(const QQuickFileDialogImpl);
299 return d->selectedFile;
300}
301
310{
311 qCDebug(lcSelectedFile) << "setSelectedFile called with" << selectedFile;
313 if (selectedFile == d->selectedFile)
314 return;
315
316 d->selectedFile = selectedFile;
317 d->updateEnabled();
318 emit selectedFileChanged(d->selectedFile);
319}
320
328{
330 const QUrl fileDirUrl = QUrl::fromLocalFile(QFileInfo(file.toLocalFile()).dir().absolutePath());
331 const bool currentFolderChanged = d->currentFolder != fileDirUrl;
332 qCDebug(lcSelectedFile) << "setting initial currentFolder to" << fileDirUrl << "and selectedFile to" << file;
335 d->setCurrentIndexToInitiallySelectedFile = true;
336
337 // If the currentFolder didn't change, the FolderListModel won't change and
338 // neither will the ListView. This means that setFileDialogListViewCurrentIndex
339 // will never get called and the currentIndex will not reflect selectedFile.
340 // We need to account for that here.
342 const QFileInfo newSelectedFileInfo(d->selectedFile.toLocalFile());
343 const int indexOfSelectedFileInFileDialogListView = d->cachedFileList.indexOf(newSelectedFileInfo);
344 d->tryUpdateFileDialogListViewCurrentIndex(indexOfSelectedFileInFileDialogListView);
345 }
346}
347
349{
350 Q_D(const QQuickFileDialogImpl);
351 return d->options;
352}
353
355{
356 qCDebug(lcOptions).nospace() << "setOptions called with:"
357 << " acceptMode=" << options->acceptMode()
358 << " fileMode=" << options->fileMode()
359 << " initialDirectory=" << options->initialDirectory()
360 << " nameFilters=" << options->nameFilters()
361 << " initiallySelectedNameFilter=" << options->initiallySelectedNameFilter();
362
364 d->options = options;
365
366 if (d->options) {
367 d->selectedNameFilter->setOptions(options);
368 d->setNameFilters(options->nameFilters());
369
370 if (auto attached = d->attachedOrWarn()) {
371 const bool isSaveMode = d->options->fileMode() == QFileDialogOptions::AnyFile;
372 attached->fileNameLabel()->setVisible(isSaveMode);
373 attached->fileNameTextField()->setVisible(isSaveMode);
374 }
375 }
376}
377
384{
385 Q_D(const QQuickFileDialogImpl);
386 return d->options ? d->options->nameFilters() : QStringList();
387}
388
390{
392 d->setNameFilters(QStringList());
393}
394
396{
397 Q_D(const QQuickFileDialogImpl);
398 if (!d->selectedNameFilter) {
399 QQuickFileDialogImpl *that = const_cast<QQuickFileDialogImpl *>(this);
400 d->selectedNameFilter = new QQuickFileNameFilter(that);
401 if (d->options)
402 d->selectedNameFilter->setOptions(d->options);
403 }
404 return d->selectedNameFilter;
405}
406
415{
417 d->acceptLabel = label;
418 QQuickFileDialogImplAttached *attached = d->attachedOrWarn();
419 if (!attached)
420 return;
421
422 auto acceptButton = attached->buttonBox()->standardButton(QPlatformDialogHelper::Open);
423 if (!acceptButton) {
424 qmlWarning(this).nospace() << "Can't set accept label to " << label
425 << "; failed to find Open button in DialogButtonBox of " << this;
426 return;
427 }
428
429 acceptButton->setText(!label.isEmpty()
431}
432
434{
436 d->rejectLabel = label;
437 QQuickFileDialogImplAttached *attached = d->attachedOrWarn();
438 if (!attached)
439 return;
440
441 auto rejectButton = attached->buttonBox()->standardButton(QPlatformDialogHelper::Cancel);
442 if (!rejectButton) {
443 qmlWarning(this).nospace() << "Can't set reject label to " << label
444 << "; failed to find Open button in DialogButtonBox of " << this;
445 return;
446 }
447
448 rejectButton->setText(!label.isEmpty()
450}
451
453{
454 qCDebug(lcNameFilters) << "selectNameFilter called with" << filter;
456 d->selectedNameFilter->update(filter);
458}
459
461{
462 return selectedFile().fileName();
463}
465{
466 const QString previous = selectedFile().fileName();
467 if (previous == fileName)
468 return;
469
471}
472
474{
477
478 // Find the right-most button and set its key navigation so that
479 // tab moves focus to the breadcrumb bar's up button. I tried
480 // doing this via KeyNavigation on the DialogButtonBox in QML,
481 // but it didn't work (probably because it's not the right item).
482 QQuickFileDialogImplAttached *attached = d->attachedOrWarn();
483 if (!attached)
484 return;
485
486 const int buttonCount = attached->buttonBox()->count();
487 if (buttonCount == 0)
488 return;
489
490 QQuickAbstractButton *rightMostButton = qobject_cast<QQuickAbstractButton *>(
491 attached->buttonBox()->itemAt(buttonCount - 1));
492 if (!rightMostButton) {
493 qmlWarning(this) << "Can't find right-most button in DialogButtonBox";
494 return;
495 }
496
497 auto keyNavigationAttached = QQuickKeyNavigationAttached::qmlAttachedProperties(rightMostButton);
498 if (!keyNavigationAttached) {
499 qmlWarning(this) << "Can't create attached KeyNavigation object on" << QDebug::toString(rightMostButton);
500 return;
501 }
502
503 keyNavigationAttached->setTab(attached->breadcrumbBar()->upButton());
504}
505
507{
510
511 if (change != QQuickItem::ItemVisibleHasChanged || !isComponentComplete() || !data.boolValue)
512 return;
513
514 QQuickFileDialogImplAttached *attached = d->attachedOrWarn();
515 if (!attached)
516 return;
517
519 d->updateEnabled();
520}
521
523{
526 qmlAttachedPropertiesObject<QQuickFileDialogImpl>(q, false));
527 if (!attached)
528 qmlWarning(q) << "Expected FileDialogImpl attached object to be present on" << this;
529 return attached;
530}
531
532void QQuickFileDialogImplAttachedPrivate::nameFiltersComboBoxItemActivated(int index)
533{
534 qCDebug(lcAttachedNameFilters) << "nameFiltersComboBoxItemActivated called with" << index;
535 auto fileDialogImpl = qobject_cast<QQuickFileDialogImpl*>(parent);
536 if (!fileDialogImpl)
537 return;
538
539 fileDialogImpl->selectNameFilter(nameFiltersComboBox->textAt(index));
540}
541
542void QQuickFileDialogImplAttachedPrivate::fileDialogListViewCurrentIndexChanged()
543{
544 auto fileDialogImpl = qobject_cast<QQuickFileDialogImpl*>(parent);
545 if (!fileDialogImpl)
546 return;
547
548 auto fileDialogDelegate = qobject_cast<QQuickFileDialogDelegate*>(fileDialogListView->currentItem());
549 if (!fileDialogDelegate)
550 return;
551
553 qCDebug(lcAttachedCurrentIndex).nospace() << "fileDialogListView currentIndex changed to " << fileDialogListView->currentIndex()
554 << " with moveReason " << moveReason
555 << "; the file at that index is " << fileDialogDelegate->file();
556
557 // Only update selectedFile if the currentIndex changed as a result of user interaction;
558 // things like model changes (i.e. QQuickItemViewPrivate::applyModelChanges() calling
559 // QQuickItemViewPrivate::updateCurrent as a result of us changing the directory on the FolderListModel)
560 // shouldn't cause the selectedFile to change.
561 auto fileDialogImplPrivate = QQuickFileDialogImplPrivate::get(fileDialogImpl);
562 if (moveReason != QQuickItemViewPrivate::Other) {
563 fileDialogImpl->setSelectedFile(fileDialogDelegate->file());
564 } else if (fileDialogImplPrivate->setCurrentIndexToInitiallySelectedFile) {
565 // When setting selectedFile before opening the FileDialog,
566 // we need to ensure that the currentIndex is correct, because the initial change
567 // in directory will cause the underyling FolderListModel to change its folder property,
568 // which in turn resets the fileDialogListView's currentIndex to 0.
569 const QFileInfo newSelectedFileInfo(fileDialogImplPrivate->selectedFile.toLocalFile());
570 const int indexOfSelectedFileInFileDialogListView = fileDialogImplPrivate->cachedFileList.indexOf(newSelectedFileInfo);
571 fileDialogImplPrivate->tryUpdateFileDialogListViewCurrentIndex(indexOfSelectedFileInFileDialogListView);
572 fileDialogImplPrivate->setCurrentIndexToInitiallySelectedFile = false;
573 }
574}
575
576void QQuickFileDialogImplAttachedPrivate::fileNameChangedByUser()
577{
578 auto fileDialogImpl = qobject_cast<QQuickFileDialogImpl *>(parent);
579 if (!fileDialogImpl)
580 return;
581
582 fileDialogImpl->setFileName(fileNameTextField->text());
583}
584
587{
588 if (!qobject_cast<QQuickFileDialogImpl*>(parent)) {
589 qmlWarning(this) << "FileDialogImpl attached properties should only be "
590 << "accessed through the root FileDialogImpl instance";
591 }
592}
593
595{
597 return d->buttonBox;
598}
599
601{
603 if (buttonBox == d->buttonBox)
604 return;
605
606 if (d->buttonBox) {
607 QQuickFileDialogImpl *fileDialogImpl = qobject_cast<QQuickFileDialogImpl*>(parent());
608 if (fileDialogImpl) {
609 auto dialogPrivate = QQuickDialogPrivate::get(fileDialogImpl);
611 dialogPrivate, &QQuickDialogPrivate::handleAccept);
613 dialogPrivate, &QQuickDialogPrivate::handleReject);
615 dialogPrivate, &QQuickDialogPrivate::handleClick);
616 }
617 }
618
619 d->buttonBox = buttonBox;
620
621 if (buttonBox) {
622 QQuickFileDialogImpl *fileDialogImpl = qobject_cast<QQuickFileDialogImpl*>(parent());
623 if (fileDialogImpl) {
624 auto dialogPrivate = QQuickDialogPrivate::get(fileDialogImpl);
626 dialogPrivate, &QQuickDialogPrivate::handleAccept);
628 dialogPrivate, &QQuickDialogPrivate::handleReject);
630 dialogPrivate, &QQuickDialogPrivate::handleClick);
631 }
632 }
633
635}
636
638{
640 return d->nameFiltersComboBox;
641}
642
644{
646 if (nameFiltersComboBox == d->nameFiltersComboBox)
647 return;
648
649 d->nameFiltersComboBox = nameFiltersComboBox;
650
652 d, &QQuickFileDialogImplAttachedPrivate::nameFiltersComboBoxItemActivated);
653
655}
656
658{
660 return d->nameFiltersComboBox ? d->nameFiltersComboBox->currentText() : QString();
661}
662
664{
666 qCDebug(lcAttachedNameFilters) << "selectNameFilter called with" << filter;
667 if (!d->nameFiltersComboBox)
668 return;
669
670 const int indexInComboBox = d->nameFiltersComboBox->find(filter);
671 if (indexInComboBox == -1)
672 return;
673
674 qCDebug(lcAttachedNameFilters) << "setting ComboBox's currentIndex to" << indexInComboBox;
675 d->nameFiltersComboBox->setCurrentIndex(indexInComboBox);
676}
677
679{
681 return d->fileDialogListView;
682}
683
685{
687 if (fileDialogListView == d->fileDialogListView)
688 return;
689
690 d->fileDialogListView = fileDialogListView;
691
693 d, &QQuickFileDialogImplAttachedPrivate::fileDialogListViewCurrentIndexChanged);
694
696}
697
699{
701 return d->breadcrumbBar;
702}
703
705{
707 if (breadcrumbBar == d->breadcrumbBar)
708 return;
709
710 d->breadcrumbBar = breadcrumbBar;
712}
713
715{
717 return d->fileNameLabel;
718}
719
721{
723 if (fileNameLabel == d->fileNameLabel)
724 return;
725
726 d->fileNameLabel = fileNameLabel;
727
729}
730
732{
734 return d->fileNameTextField;
735}
736
738{
740 if (fileNameTextField == d->fileNameTextField)
741 return;
742
743 if (d->fileNameTextField)
744 QObjectPrivate::disconnect(d->fileNameTextField, &QQuickTextField::editingFinished,
745 d, &QQuickFileDialogImplAttachedPrivate::fileNameChangedByUser);
746
747 d->fileNameTextField = fileNameTextField;
748
749 if (d->fileNameTextField)
750 QObjectPrivate::connect(d->fileNameTextField, &QQuickTextField::editingFinished,
751 d, &QQuickFileDialogImplAttachedPrivate::fileNameChangedByUser);
752
754}
755
757
758#include "moc_qquickfiledialogimpl_p.cpp"
\inmodule QtCore
Definition qdir.h:19
QString absolutePath() const
Returns the absolute path (a path that starts with "/" or with a drive specification),...
Definition qdir.cpp:667
bool exists() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qdir.cpp:1715
@ IgnoreCase
Definition qdir.h:57
@ DirsFirst
Definition qdir.h:55
@ Files
Definition qdir.h:22
@ NoDotAndDotDot
Definition qdir.h:43
@ Dirs
Definition qdir.h:21
QString initiallySelectedNameFilter() const
AcceptMode acceptMode() const
QStringList nameFilters() const
\inmodule QtCore \reentrant
Definition qfileinfo.h:22
QString absoluteFilePath() const
Returns an absolute path including the file name.
bool isDir() const
Returns true if this object points to a directory or to a symbolic link to a directory.
QDir dir() const
Returns the path of the object's parent directory as a QDir object.
static QPlatformTheme * platformTheme()
qsizetype size() const noexcept
Definition qlist.h:386
bool isEmpty() const noexcept
Definition qlist.h:390
T & first()
Definition qlist.h:628
QObject * parent
Definition qobject.h:61
static QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiverPrivate, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
Definition qobject_p.h:298
static bool disconnect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiverPrivate, Func2 slot)
Definition qobject_p.h:327
\inmodule QtCore
Definition qobject.h:90
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:311
virtual QVariant themeHint(ThemeHint hint) const
static QString urlToLocalFileOrQrc(const QString &)
If url is a local file returns a path suitable for passing to QFile.
Definition qqmlfile.cpp:643
virtual void componentComplete()=0
Invoked after the root component that caused this instantiation has completed construction.
void activated(int index)
Q_INVOKABLE QString textAt(int index) const
\qmlmethod string QtQuick.Controls::ComboBox::textAt(int index)
Q_INVOKABLE QQuickItem * itemAt(int index) const
\qmlmethod Item QtQuick.Controls::Container::itemAt(int index)
static QString buttonText(QPlatformDialogHelper::StandardButton standardButton)
void clicked(QQuickAbstractButton *button)
Q_INVOKABLE QQuickAbstractButton * standardButton(QPlatformDialogHelper::StandardButton button) const
\qmlmethod AbstractButton QtQuick.Controls::DialogButtonBox::standardButton(StandardButton button)
virtual void handleClick(QQuickAbstractButton *button)
static QQuickDialogPrivate * get(QQuickDialog *dialog)
virtual void handleAccept()
static QPlatformDialogHelper::ButtonRole buttonRole(QQuickAbstractButton *button)
Popup dialog with standard buttons and a title, used for short-term interaction with the user.
virtual void handleReject()
QPointer< QQuickTextField > fileNameTextField
QPointer< QQuickListView > fileDialogListView
QPointer< QQuickComboBox > nameFiltersComboBox
void setNameFiltersComboBox(QQuickComboBox *nameFiltersComboBox)
QQuickFolderBreadcrumbBar * breadcrumbBar
QQuickFileDialogImplAttached(QObject *parent=nullptr)
void setFileNameTextField(QQuickTextField *fileNameTextField)
void setFileNameLabel(QQuickLabel *fileNameLabel)
void setButtonBox(QQuickDialogButtonBox *buttonBox)
void setBreadcrumbBar(QQuickFolderBreadcrumbBar *breadcrumbBar)
void setFileDialogListView(QQuickListView *fileDialogListView)
void selectNameFilter(const QString &filter)
static QDir::SortFlags fileListSortFlags()
static QQuickFileDialogImplPrivate * get(QQuickFileDialogImpl *dialog)
QQuickFileDialogImplAttached * attachedOrWarn()
void setFileDialogListViewCurrentIndex(int newCurrentIndex)
void updateSelectedFile(const QString &oldFolderPath)
void handleClick(QQuickAbstractButton *button) override
static QFileInfoList fileList(const QDir &dir)
void tryUpdateFileDialogListViewCurrentIndex(int newCurrentIndex)
void setNameFilters(const QStringList &filters)
void setRejectLabel(const QString &label)
void setSelectedFile(const QUrl &file)
void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &data) override
void setAcceptLabel(const QString &label)
void filterSelected(const QString &filter)
void setFileName(const QString &fileName)
void setOptions(const QSharedPointer< QFileDialogOptions > &options)
void selectedFileChanged(const QUrl &selectedFileUrl)
void setCurrentFolder(const QUrl &currentFolder, SetReason setReason=SetReason::External)
void componentComplete() override
Invoked after the root component that caused this instantiation has completed construction.
QQuickFileDialogImpl(QObject *parent=nullptr)
void selectNameFilter(const QString &filter)
QQuickFileNameFilter * selectedNameFilter
static QQuickFileDialogImplAttached * qmlAttachedProperties(QObject *object)
QSharedPointer< QFileDialogOptions > options() const
void setInitialCurrentFolderAndSelectedFile(const QUrl &file)
void currentFolderChanged(const QUrl &folderUrl)
static QQuickItemViewPrivate * get(QQuickItemView *o)
Q_INVOKABLE void positionViewAtIndex(int index, int mode)
QQuickItem * currentItem
void currentIndexChanged()
void countChanged()
void setCurrentIndex(int idx)
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:64
bool isVisible() const
Q_INVOKABLE void forceActiveFocus()
\qmlmethod point QtQuick::Item::mapToItem(Item item, real x, real y) \qmlmethod point QtQuick::Item::...
ItemChange
Used in conjunction with QQuickItem::itemChange() to notify the item about certain types of changes.
Definition qquickitem.h:143
@ ItemVisibleHasChanged
Definition qquickitem.h:147
static QQuickKeyNavigationAttached * qmlAttachedProperties(QObject *)
static QVariant getThemeHint(QPlatformTheme::ThemeHint themeHint)
virtual void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &data)
bool isComponentComplete() const
\inmodule QtCore
Exception-safe wrapper around QObject::blockSignals().
Definition qobject.h:443
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
QStringList split(const QString &sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Splits the string into substrings wherever sep occurs, and returns the list of those strings.
Definition qstring.cpp:7956
qsizetype size() const
Returns the number of characters in this string.
Definition qstring.h:182
QString mid(qsizetype position, qsizetype n=-1) const
Returns a string that contains n characters of this string, starting at the specified position index.
Definition qstring.cpp:5204
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:1083
static QString static QString qsizetype indexOf(QChar c, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition qstring.cpp:4420
\inmodule QtCore
Definition qurl.h:94
static QUrl fromLocalFile(const QString &localfile)
Returns a QUrl representation of localFile, interpreted as a local file.
Definition qurl.cpp:3354
QString fileName(ComponentFormattingOptions options=FullyDecoded) const
Definition qurl.cpp:2494
bool isValid() const
Returns true if the URL is non-empty and valid; otherwise returns false.
Definition qurl.cpp:1874
bool isEmpty() const
Returns true if the URL has no data; otherwise returns false.
Definition qurl.cpp:1888
QString toLocalFile() const
Returns the path of this URL formatted as a local file path.
Definition qurl.cpp:3411
\inmodule QtCore
Definition qvariant.h:64
bool isValid() const
Returns true if the storage type of this variant is not QMetaType::UnknownType; otherwise returns fal...
Definition qvariant.h:707
bool toBool() const
Returns the variant as a bool if the variant has userType() Bool.
bool canConvert(QMetaType targetType) const
Definition qvariant.h:342
QPushButton * button
[2]
Combined button and popup list for selecting options.
ConnectionType
@ UniqueConnection
@ DirectConnection
@ SkipEmptyParts
Definition qnamespace.h:127
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
GLuint index
[2]
GLenum GLenum GLsizei count
GLuint GLsizei const GLchar * label
[43]
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLsizei const GLchar *const * path
Q_QML_EXPORT QQmlInfo qmlWarning(const QObject *me)
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
QString qEnvironmentVariable(const char *varName, const QString &defaultValue)
#define emit
QFile file
[0]
QString dir
[11]
const QStringList filters({"Image files (*.png *.xpm *.jpg)", "Text files (*.txt)", "Any files (*)" })
[6]
\inmodule QtCore \reentrant
Definition qchar.h:17
qsizetype indexOf(const AT &t, qsizetype from=0) const noexcept
Definition qlist.h:955
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent
QT_BEGIN_NAMESPACE bool toBool(const QString &str)
Definition utils.h:14
\inmodule QtQuick
Definition qquickitem.h:158