4#define QT_NO_URL_CAST_FROM_STRING
7#include <private/qwidgetitemdata_p.h>
11#include <private/qapplication_p.h>
12#include <private/qguiapplication_p.h>
15#include <qactiongroup.h>
17#if QT_CONFIG(shortcut)
18# include <qshortcut.h>
24#if QT_CONFIG(messagebox)
28#if QT_CONFIG(settings)
32#if QT_CONFIG(mimetype)
35#if QT_CONFIG(regularexpression)
40#include "ui_qfiledialog.h"
44#elif defined(Q_OS_WIN)
45# include <QtCore/qt_windows.h>
48#include <private/qwasmlocalfileaccess_p.h>
322#if QT_CONFIG(shortcut)
323# include <qshortcut.h>
356 args.caption = caption;
369 setOptions(
args.options);
370 selectFile(
args.selection);
378#if QT_CONFIG(settings)
401 if (!
d->nativeDialogInUse)
402 d->qFileDialogUi->sidebar->setUrls(urls);
412 return (
d->nativeDialogInUse ? QList<QUrl>() :
d->qFileDialogUi->sidebar->urls());
430 stream.setVersion(QDataStream::Qt_5_0);
434 if (
d->usingWidgets()) {
435 stream <<
d->qFileDialogUi->splitter->saveState();
436 stream <<
d->qFileDialogUi->sidebar->urls();
442 stream << *lastVisitedDir();
443 if (
d->usingWidgets())
444 stream <<
d->qFileDialogUi->treeView->header()->saveState();
465 stream.setVersion(QDataStream::Qt_5_0);
469 QUrl currentDirectory;
483 QString currentDirectoryString;
484 stream >> currentDirectoryString;
487 stream >> currentDirectory;
492 setDirectoryUrl(lastVisitedDir()->isEmpty() ? currentDirectory : *lastVisitedDir());
495 if (!
d->usingWidgets())
498 return d->restoreWidgetState(
history, -1);
508 d->retranslateWindowTitle();
509 d->retranslateStrings();
520 currentHistoryLocation(-1),
524 useDefaultCaption(true),
548 fileDialogHelper->setOptions(
options);
582 q->setWindowTitle(QFileDialog::tr(
"Find Directory"));
584 q->setWindowTitle(QFileDialog::tr(
"Open"));
586 q->setWindowTitle(QFileDialog::tr(
"Save As"));
593 *lastVisitedDir() =
dir;
607 switch (q_func()->fileMode()) {
628 if (saveAsOnFolder) {
634 switch (
q->fileMode()) {
641 QFileDialog::tr(
"&Open") :
642 QFileDialog::tr(
"&Save"));
665#if QT_CONFIG(proxymodel)
667 abstractModel = proxyModel;
670 for (
int i = 1;
i < total; ++
i) {
690 if (
files.size() == 1)
707 return strcmp(QFileDialog::staticMetaObject.
className(),
q->metaObject()->className()) == 0;
734 const QFileDialog::Options previousOptions =
options();
735 if (!(previousOptions &
option) != !on)
780 d->options->setOptions(QFileDialogOptions::FileDialogOptions(
int(
options)));
783 d->nativeDialogInUse =
false;
787 if (
d->usingWidgets()) {
792 d->model->setReadOnly(ro);
793 d->qFileDialogUi->newFolderButton->setEnabled(!ro);
794 d->renameAction->setEnabled(!ro);
795 d->deleteAction->setEnabled(!ro);
823 return QFileDialog::Options(
int(
d->options->options()));
841 d->signalToDisconnectOnClose =
signal;
842 d->receiverToDisconnectOnClose = receiver;
843 d->memberToDisconnectOnClose = member;
873#if QT_CONFIG(fscompleter)
881#if QT_CONFIG(fscompleter)
883 if (proxyModel !=
nullptr)
944 if (!
d->usingWidgets()) {
945 d->setDirectory_sys(newDirUrl);
948 if (
d->rootPath() == newDirectory)
951 if (!
d->nativeDialogInUse) {
953 if (root !=
d->rootIndex()) {
954#if QT_CONFIG(fscompleter)
956 d->completer->setCompletionPrefix(newDirectory);
958 d->completer->setCompletionPrefix(newDirectory + u
'/');
960 d->setRootIndex(root);
962 d->qFileDialogUi->listView->selectionModel()->clear();
972 if (
d->nativeDialogInUse) {
1005 if (
d->nativeDialogInUse)
1010 qWarning(
"Non-native QFileDialog supports only local files");
1021 if (
d->nativeDialogInUse)
1022 return d->directory_sys();
1031#if defined(Q_OS_WIN)
1035#elif defined(Q_OS_MACOS)
1057 ||
path.at(0) == u
'/'
1076 if (!
d->usingWidgets()) {
1079 url =
d->options->initialDirectory();
1081 if (!
path.endsWith(u
'/'))
1087 d->selectFile_sys(
url);
1088 d->options->setInitiallySelectedFiles(QList<QUrl>() <<
url);
1096 if (
d->model->rootPath() != filenamePath)
1101 d->qFileDialogUi->listView->selectionModel()->clear();
1102 if (!
isVisible() || !
d->lineEdit()->hasFocus())
1120 if (
d->nativeDialogInUse)
1121 d->selectFile_sys(
url);
1125 qWarning(
"Non-native QFileDialog supports only local files");
1131#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) && !defined(Q_OS_WASM)
1134 long bufSize = ::sysconf(_SC_GETPW_R_SIZE_MAX);
1139# if defined(Q_OS_SOLARIS) && (_POSIX_C_SOURCE - 0 < 199506L)
1140 tmpPw = getpwnam_r(userName.
constData(), &pw,
buf.data(),
buf.size());
1142 err = getpwnam_r(userName.
constData(), &pw,
buf.data(),
buf.size(), &tmpPw);
1148 passwd *pw = getpwnam(userName.
constData());
1157 if (!
path.startsWith(u
'~'))
1160 if (
path.size() == 1)
1168#if defined(Q_OS_VXWORKS) || defined(Q_OS_INTEGRITY)
1173 const qsizetype userNameLen = sepIndex != -1 ? sepIndex - strlen(
"~")
1176 QString homePath = homeDirFromPasswdEntry(
path, userName);
1179 return homePath + sv.
sliced(sepIndex);
1198 files << qt_tildeExpansion(editText);
1207 for (
int i=0;
i<tokens.size(); ++
i) {
1242 files.reserve(typedFilesList.size());
1253 for (
int i=0;
i<filesToFix.size(); ++
i) {
1258 if (!defaultSuffix.
isEmpty() && !
info.isDir() && !
info.fileName().contains(u
'.'))
1259 name += u
'.' + defaultSuffix;
1261 if (
info.isAbsolute()) {
1268 if (!
path.endsWith(u
'/'))
1280 urls.reserve(urlsToFix.size());
1284 if (!defaultSuffix.
isEmpty()) {
1287 if (idx != (urlPath.size() - 1) && !
QStringView{urlPath}.
mid(idx + 1).contains(u
'.'))
1308 const QList<QUrl> userSelectedFiles =
d->userSelectedFiles();
1309 files.reserve(userSelectedFiles.size());
1310 for (
const QUrl &
file : userSelectedFiles)
1313 if (
files.isEmpty() &&
d->usingWidgets()) {
1332 if (
d->nativeDialogInUse) {
1333 return d->userSelectedFiles();
1337 urls.reserve(selectedFileList.size());
1388#if QT_CONFIG(regularexpression)
1391 strippedFilters.reserve(
filters.size());
1395 if (
match.hasMatch())
1396 filterName =
match.captured(1);
1397 strippedFilters.append(filterName.simplified());
1399 return strippedFilters;
1429 cleanedFilters.reserve(
filters.size());
1431 cleanedFilters <<
filter.simplified();
1433 d->options->setNameFilters(cleanedFilters);
1435 if (!
d->usingWidgets())
1438 d->qFileDialogUi->fileTypeCombo->clear();
1439 if (cleanedFilters.isEmpty())
1445 d->qFileDialogUi->fileTypeCombo->addItems(cleanedFilters);
1447 d->useNameFilter(0);
1458 return d_func()->options->nameFilters();
1472 d->options->setInitiallySelectedNameFilter(
filter);
1473 if (!
d->usingWidgets()) {
1474 d->selectNameFilter_sys(
filter);
1481 i =
d->qFileDialogUi->fileTypeCombo->findText(
filters.first());
1483 i =
d->qFileDialogUi->fileTypeCombo->findText(
filter);
1486 d->qFileDialogUi->fileTypeCombo->setCurrentIndex(
i);
1487 d->useNameFilter(
d->qFileDialogUi->fileTypeCombo->currentIndex());
1501 if (!
d->usingWidgets())
1502 return d->selectedNameFilter_sys();
1504 return d->qFileDialogUi->fileTypeCombo->currentText();
1517 if (
d->usingWidgets())
1518 return d->model->filter();
1519 return d->options->filter();
1535 if (!
d->usingWidgets()) {
1544#if QT_CONFIG(mimetype)
1550 if (
mime.isValid()) {
1551 if (
mime.isDefault()) {
1552 return QFileDialog::tr(
"All files (*)");
1554 const QString patterns =
mime.globPatterns().join(u
' ');
1555 return mime.comment() +
" ("_L1 + patterns + u
')';
1588 d->options->setMimeTypeFilters(
filters);
1599 return d_func()->options->mimeTypeFilters();
1608void QFileDialog::selectMimeTypeFilter(
const QString &
filter)
1611 d->options->setInitiallySelectedMimeTypeFilter(
filter);
1615 if (!
d->usingWidgets()) {
1616 d->selectMimeTypeFilter_sys(
filter);
1617 if (
d->selectedMimeTypeFilter_sys().isEmpty() && !filterForMime.isEmpty()) {
1620 }
else if (!filterForMime.isEmpty()) {
1635 if (!
d->usingWidgets())
1636 mimeTypeFilter =
d->selectedMimeTypeFilter_sys();
1638#if QT_CONFIG(mimetype)
1639 if (mimeTypeFilter.isNull() && !
d->options->mimeTypeFilters().isEmpty()) {
1641 const auto mimeTypes =
d->options->mimeTypeFilters();
1642 for (
const auto &
mimeType: mimeTypes) {
1646 if (
filter == nameFilter) {
1654 return mimeTypeFilter;
1670 if (!
d->usingWidgets())
1673 d->showDetailsView();
1681 if (!
d->usingWidgets())
1705 if (!
d->usingWidgets())
1708 d->retranslateWindowTitle();
1716 d->qFileDialogUi->listView->setSelectionMode(selectionMode);
1717 d->qFileDialogUi->treeView->setSelectionMode(selectionMode);
1719 d->model->setFilter(
d->filterForMode(
filter()));
1722 d->qFileDialogUi->fileTypeCombo->clear();
1723 d->qFileDialogUi->fileTypeCombo->addItem(
tr(
"Directories"));
1724 d->qFileDialogUi->fileTypeCombo->setEnabled(
false);
1726 d->updateFileNameLabel();
1727 d->updateOkButtonText();
1729 d->updateOkButton();
1735 return static_cast<FileMode>(
d->options->fileMode());
1754 if (!
d->usingWidgets())
1759 d->updateOkButton();
1761 d->qFileDialogUi->lookInCombo->setEditable(
false);
1763 d->retranslateWindowTitle();
1782 d->options->setSupportedSchemes(schemes);
1787 return d_func()->options->supportedSchemes();
1812#if defined(Q_OS_UNIX)
1814#elif defined(Q_OS_WIN)
1817 if (::GetVolumeInformation(
reinterpret_cast<const wchar_t *
>(drive.
utf16()), NULL, 0, NULL, &
maxLength, NULL, NULL, 0) ==
false)
1843 if (idx.isValid() && !
qFileDialogUi->listView->selectionModel()->isSelected(idx))
1852 return static_cast<AcceptMode>(
d->options->acceptMode());
1869 d->options->setDefaultSuffix(suffix);
1875 return d->options->defaultSuffix();
1885 if (
d->usingWidgets())
1886 d->qFileDialogUi->lookInCombo->setHistory(
paths);
1910 if (!
d->usingWidgets())
1912 QStringList currentHistory =
d->qFileDialogUi->lookInCombo->history();
1915 if (!currentHistory.contains(newHistory))
1916 currentHistory << newHistory;
1917 return currentHistory;
1941 if (!
d->usingWidgets())
1943 d->qFileDialogUi->listView->setItemDelegate(delegate);
1944 d->qFileDialogUi->treeView->setItemDelegate(delegate);
1953 if (!
d->usingWidgets())
1955 return d->qFileDialogUi->listView->itemDelegate();
1964 if (!
d->usingWidgets())
1966 d->model->setIconProvider(provider);
1968 d->qFileDialogUi->sidebar->setUrls(
d->qFileDialogUi->sidebar->urls());
1979 return d->model->iconProvider();
2029 if (!
d->usingWidgets())
2034 return d->qFileDialogUi->lookInLabel->
text();
2036 return d->qFileDialogUi->fileNameLabel->text();
2038 return d->qFileDialogUi->fileTypeLabel->text();
2111 selectedFilter,
options, schemes);
2112 if (selectedUrl.isLocalFile() || selectedUrl.isEmpty())
2113 return selectedUrl.toLocalFile();
2115 return selectedUrl.toString();
2155 args.caption = caption;
2162 if (selectedFilter && !selectedFilter->isEmpty())
2270 args.caption = caption;
2277 if (selectedFilter && !selectedFilter->isEmpty())
2284 return QList<QUrl>();
2310 auto openFileImpl = std::make_shared<std::function<
void(
void)>>();
2313 *openFileImpl = [=]()
mutable {
2316 fileOpenCompleted(
fileName, fileContent);
2317 openFileImpl.reset();
2320 auto acceptFile = [&](uint64_t
size,
const std::string
name) ->
char * {
2321 const uint64_t twoGB = 1ULL << 31;
2326 fileContent.resize(
size);
2327 return fileContent.data();
2330 fileOpenCompleted(
fileName, fileContent);
2331 openFileImpl.reset();
2349 fileContent = selectedFile.
readAll();
2351 fileOpenCompleted(
fileName, fileContent);
2392 selectedFile.
write(fileContent);
2459 selectedFilter,
options, schemes);
2460 if (selectedUrl.isLocalFile() || selectedUrl.isEmpty())
2461 return selectedUrl.toLocalFile();
2463 return selectedUrl.toString();
2503 args.caption = caption;
2511 if (selectedFilter && !selectedFilter->isEmpty())
2571 const QUrl selectedUrl =
2573 if (selectedUrl.isLocalFile() || selectedUrl.isEmpty())
2574 return selectedUrl.toLocalFile();
2576 return selectedUrl.toString();
2614 args.caption = caption;
2632 if (!pathInfo.exists() || !pathInfo.isDir())
2653 const QUrl lastVisited = *lastVisitedDir();
2654 if (lastVisited !=
url)
2684 if (
d->receiverToDisconnectOnClose) {
2686 d->receiverToDisconnectOnClose,
d->memberToDisconnectOnClose);
2687 d->receiverToDisconnectOnClose =
nullptr;
2689 d->memberToDisconnectOnClose.clear();
2690 d->signalToDisconnectOnClose.clear();
2695#if QT_CONFIG(messagebox)
2697 const QString msg = QFileDialog::tr(
"%1 already exists.\nDo you want to replace it?").
arg(
fileName);
2699 const auto res = B::warning(
q,
q->windowTitle(), msg, B::Yes | B::No, B::No);
2700 return res == B::Yes;
2707#if QT_CONFIG(messagebox)
2710 ? QFileDialog::tr(
"%1\nDirectory not found.\n"
2711 "Please verify the correct directory name was given.")
2713 "correct file name was given.");
2725 if (!
d->usingWidgets()) {
2729 d->emitUrlsSelected(urls);
2730 if (urls.size() == 1)
2731 d->emitUrlSelected(urls.first());
2737 if (
files.isEmpty())
2739 QString lineEditText =
d->lineEdit()->text();
2742 if (lineEditText ==
".."_L1) {
2743 d->navigateToParent();
2745 d->lineEdit()->selectAll();
2756 if (!
info.exists()) {
2761 d->emitFilesSelected(
files);
2775 if (!
info.exists()) {
2776 const long maxNameLength =
d->maxNameLength(
info.path());
2777 if (maxNameLength >= 0 &&
info.fileName().size() > maxNameLength)
2786 if (
d->itemAlreadyExists(
info.fileName())) {
2800 if (!
info.exists()) {
2806 d->lineEdit()->clear();
2810 d->emitFilesSelected(
files);
2816#if QT_CONFIG(settings)
2817void QFileDialogPrivate::saveSettings()
2830 historyUrls.reserve(history.size());
2835 const QMetaEnum &viewModeMeta =
q->metaObject()->enumerator(
q->metaObject()->indexOfEnumerator(
"ViewMode"));
2840bool QFileDialogPrivate::restoreFromSettings()
2848 q->setDirectoryUrl(lastVisitedDir()->isEmpty() ?
settings.
value(
"lastVisited").
toUrl() : *lastVisitedDir());
2851 const QMetaEnum &viewModeMeta =
q->metaObject()->enumerator(
q->metaObject()->indexOfEnumerator(
"ViewMode"));
2853 int viewMode = viewModeMeta.
keyToValue(viewModeStr.constData(), &
ok);
2866 for (
const QString &urlStr : urlStrings) {
2879 if (splitterPosition >= 0) {
2880 QList<int> splitterSizes;
2881 splitterSizes.append(splitterPosition);
2882 splitterSizes.append(
qFileDialogUi->splitter->widget(1)->sizeHint().width());
2897 static const int MaxHistorySize = 5;
2898 if (history.size() > MaxHistorySize)
2899 history.erase(history.begin(), history.end() - MaxHistorySize);
2900 q->setHistory(history);
2906 QList<QAction*>
actions = headerView->actions();
2908#if QT_CONFIG(proxymodel)
2910 abstractModel = proxyModel;
2913 for (
int i = 1;
i < total; ++
i)
2930 q->setWindowTitle(
args.caption);
2939 q->setNameFilter(
args.filter);
2941 const bool dontStoreDir = !
args.directory.isValid() && !lastVisitedDir()->isValid();
2942 q->setDirectoryUrl(
args.directory);
2944 lastVisitedDir()->
clear();
2945 if (
args.directory.isLocalFile())
2946 q->selectFile(
args.selection);
2948 q->selectUrl(
args.directory);
2950#if QT_CONFIG(settings)
2953 if (!restoreFromSettings()) {
2959#if defined(Q_EMBEDDED_SMALLSCREEN)
2966 const QSize sizeHint =
q->sizeHint();
2968 q->resize(sizeHint);
2986 Qt::WindowStates preState =
q->windowState();
2996 model->d_func()->disableRecursiveSort =
true;
3008 QList<QUrl> initialBookmarks;
3009 initialBookmarks <<
QUrl(
"file:"_L1)
3029#ifndef QT_NO_SHORTCUT
3032#if QT_CONFIG(fscompleter)
3061#ifndef QT_NO_SHORTCUT
3071 treeHeader->resizeSection(0, fm.horizontalAdvance(
"wwwwwwwwwwwwwwwwwwwwwwwwww"_L1));
3072 treeHeader->resizeSection(1, fm.horizontalAdvance(
"128.88 GB"_L1));
3073 treeHeader->resizeSection(2, fm.horizontalAdvance(
"mp3Folder"_L1));
3074 treeHeader->resizeSection(3, fm.horizontalAdvance(
"10/29/81 02:02PM"_L1));
3078 showActionGroup->setExclusive(
false);
3083#if QT_CONFIG(proxymodel)
3085 abstractModel = proxyModel;
3087 for (
int i = 1;
i < abstractModel->columnCount(
QModelIndex()); ++
i) {
3094 QScopedPointer<QItemSelectionModel> selModel(
qFileDialogUi->treeView->selectionModel());
3101#ifndef QT_NO_SHORTCUT
3118#if QT_CONFIG(settings)
3121 if (!restoreFromSettings()) {
3131 q->setOptions(
static_cast<QFileDialog::Options
>(
static_cast<int>(
options->
options())));
3135#if QT_CONFIG(mimetype)
3146 if (initiallySelectedFiles.size() == 1)
3147 q->selectFile(initiallySelectedFiles.first().fileName());
3148 for (
const QUrl &
url : initiallySelectedFiles)
3153 q->resize(preSize.isValid() ? preSize :
q->sizeHint());
3154 q->setWindowState(preState);
3160 QActionGroup *actionGroup = qobject_cast<QActionGroup*>(
q->sender());
3165#if QT_CONFIG(proxymodel)
3181 if (!
d->usingWidgets())
3183 if ((!proxyModel && !
d->proxyModel)
3184 || (proxyModel ==
d->proxyModel))
3195 if (proxyModel !=
nullptr) {
3197 d->proxyModel = proxyModel;
3199 d->qFileDialogUi->listView->setModel(
d->proxyModel);
3200 d->qFileDialogUi->treeView->setModel(
d->proxyModel);
3201#if QT_CONFIG(fscompleter)
3202 d->completer->setModel(
d->proxyModel);
3203 d->completer->proxyModel =
d->proxyModel;
3208 d->proxyModel =
nullptr;
3209 d->qFileDialogUi->listView->setModel(
d->model);
3210 d->qFileDialogUi->treeView->setModel(
d->model);
3211#if QT_CONFIG(fscompleter)
3212 d->completer->setModel(
d->model);
3213 d->completer->sourceModel =
d->model;
3214 d->completer->proxyModel =
nullptr;
3219 QScopedPointer<QItemSelectionModel> selModel(
d->qFileDialogUi->treeView->selectionModel());
3220 d->qFileDialogUi->treeView->setSelectionModel(
d->qFileDialogUi->listView->selectionModel());
3222 d->setRootIndex(idx);
3240 return d->proxyModel;
3306#ifndef QT_NO_SHORTCUT
3311 q->addAction(goHomeAction);
3316 goToParent->setObjectName(
"qt_goto_parent_action"_L1);
3317#ifndef QT_NO_SHORTCUT
3322 q->addAction(goToParent);
3360 item.selection.clear();
3361 const auto selectedIndexes =
qFileDialogUi->listView->selectionModel()->selectedRows();
3362 for (
const auto &
index : selectedIndexes)
3397 q->setDirectory(historyItem.path);
3401 if (std::any_of(historyItem.selection.cbegin(), historyItem.selection.cend(),
3403 historyItem.selection.clear();
3410 auto selectionModel =
view->selectionModel();
3413 selectionModel->select(historyItem.selection.constFirst(),
3415 auto it = historyItem.selection.
cbegin() + 1;
3416 const auto end = historyItem.selection.cend();
3418 selectionModel->select(*
it,
flags);
3420 view->scrollTo(historyItem.selection.constFirst());
3464 newDirectory =
dir.absolutePath();
3466 q->setDirectory(newDirectory);
3467 emit q->directoryEntered(newDirectory);
3480 QString newFolderString = QFileDialog::tr(
"New Folder");
3481 QString folderName = newFolderString;
3492 if (!
index.isValid())
3496 if (
index.isValid()) {
3544 if (
index.isValid()) {
3601 if (!
index.isValid())
3608#if QT_CONFIG(messagebox)
3611 QFileDialog::tr(
"'%1' is write protected.\nDo you want to delete it anyway?")
3616 QFileDialog::tr(
"Are you sure you want to delete '%1'?")
3622 if (!
index.isValid())
3632#if QT_CONFIG(messagebox)
3634 QFileDialog::tr(
"Could not delete directory."));
3646 qFileDialogUi->listView->selectionModel()->clearSelection();
3651 if (multipleFiles.size() > 0) {
3653 QList<QModelIndex> newFiles;
3654 for (
const auto &
file : multipleFiles) {
3656 if (oldFiles.removeAll(idx) == 0)
3657 newFiles.append(idx);
3659 for (
const auto &newFile : std::as_const(newFiles))
3663 for (
const auto &oldFile : std::as_const(oldFiles))
3681 bool enableButton =
true;
3682 bool isOpenDirectory =
false;
3687 if (lineEditText.startsWith(
"//"_L1) || lineEditText.startsWith(u
'\\')) {
3693 if (
files.isEmpty()) {
3694 enableButton =
false;
3695 }
else if (lineEditText ==
".."_L1) {
3696 isOpenDirectory =
true;
3705 enableButton =
false;
3715 fileDir =
info.canonicalFilePath();
3720 if (lineEditText.contains(
".."_L1)) {
3721 fileDir =
info.canonicalFilePath();
3725 if (fileDir ==
q->directory().canonicalPath() &&
fileName.isEmpty()) {
3726 enableButton =
false;
3730 isOpenDirectory =
true;
3731 enableButton =
true;
3747 enableButton =
false;
3751 isOpenDirectory =
true;
3788 q->setDirectory(
path);
3815 #if QT_CONFIG(messagebox)
3822 if (!
index.isValid())
3825 path2 =
index.data(UrlRole).toUrl().toLocalFile();
3834#if QT_CONFIG(messagebox)
3836 QString message = QFileDialog::tr(
"%1\nDirectory not found.\nPlease verify the "
3837 "correct directory name was given.");
3852 if (
index == nameFilters.size()) {
3854 nameFilters.append(comboModel->index(comboModel->rowCount() - 1, 0).data().toString());
3861 QString newNameFilterExtension;
3862 if (newNameFilters.size() > 0)
3867 if (!fileNameExtension.isEmpty() && !newNameFilterExtension.isEmpty()) {
3868 const qsizetype fileNameExtensionLength = fileNameExtension.
size();
3870 fileNameExtensionLength, newNameFilterExtension);
3892 for (
const auto &
index : indexes) {
3895 allFiles.append(
index.data().toString());
3897 if (allFiles.size() > 1)
3899 allFiles.replace(
i,
QString(u
'"' + allFiles.at(
i) + u
'"'));
3902 QString finalFiles = allFiles.join(u
' ');
3917 QDir::Filters dirFilters =
q->filter();
3919 q->setFilter(dirFilters);
3933 ||
qFileDialogUi->treeView->selectionModel()->hasSelection()
3951 if (
file.isLocalFile())
3952 emit q->fileSelected(
file.toLocalFile());
3961 if (
file.isLocalFile())
3962 localFiles.append(
file.toLocalFile());
3963 if (!localFiles.isEmpty())
3964 emit q->filesSelected(localFiles);
3971 if (
file.isLocalFile())
3972 emit q->currentChanged(
file.toLocalFile());
3995#if QT_CONFIG(shortcut)
4002 switch (
event->key()) {
4007#ifdef QT_KEYPAD_NAVIGATION
4008 if (QApplicationPrivate::keypadNavigationEnabled())
4026 if (
string.
size() > 1 &&
string.startsWith(u
'$')) {
4030 if (
string.
size() > 2 &&
string.startsWith(u
'%') &&
string.endsWith(u
'%')) {
4047 if (
model()->rowCount() > 1)
4050 urlModel->
setUrls(QList<QUrl>());
4066 for (
int i = 0;
i < m_history.size(); ++
i) {
4068 if (!urls.contains(
path))
4071 if (urls.size() > 0) {
4075 model()->
setData(idx, QFileDialog::tr(
"Recent Places"));
4078 Qt::ItemFlags
flags =
m->flags(idx);
4082 urlModel->
addUrls(urls, -1,
false);
4117#if QT_CONFIG(draganddrop)
4118 setDragDropMode(QAbstractItemView::InternalMove);
4130#ifdef QT_KEYPAD_NAVIGATION
4154#if QT_CONFIG(draganddrop)
4155 setDragDropMode(QAbstractItemView::InternalMove);
4161#ifdef QT_KEYPAD_NAVIGATION
4186#ifdef QT_KEYPAD_NAVIGATION
4193#if QT_CONFIG(shortcut)
4197#if QT_CONFIG(shortcut)
4203#if QT_CONFIG(fscompleter)
4212 QString currentLocation = dirModel->rootPath();
4214 if (!currentLocation.
isEmpty() &&
path.startsWith(currentLocation)) {
4215#if defined(Q_OS_UNIX)
4217 return path.remove(0, currentLocation.
size());
4219 if (currentLocation.
endsWith(u
'/'))
4220 return path.remove(0, currentLocation.
size());
4222 return path.remove(0, currentLocation.
size()+1);
4234#if defined(Q_OS_WIN)
4235 if (pathCopy ==
"\\"_L1 || pathCopy ==
"\\\\"_L1)
4237 QString doubleSlash(
"\\\\"_L1);
4238 if (pathCopy.startsWith(doubleSlash))
4239 pathCopy = pathCopy.mid(2);
4241 doubleSlash.clear();
4242#elif defined(Q_OS_UNIX)
4244 QString tildeExpanded = qt_tildeExpansion(pathCopy);
4245 if (tildeExpanded != pathCopy) {
4251 dirModel->
fetchMore(dirModel->index(tildeExpanded));
4253 pathCopy = std::move(tildeExpanded);
4257#if defined(Q_OS_WIN)
4259 if (!doubleSlash.isEmpty() && !parts.isEmpty())
4260 parts[0].prepend(doubleSlash);
4261 if (pathCopy.endsWith(
sep))
4265 if (pathCopy[0] ==
sep)
4269#if defined(Q_OS_WIN)
4270 bool startsFromRoot = !parts.isEmpty() && parts[0].endsWith(u
':');
4272 bool startsFromRoot = pathCopy[0] ==
sep;
4274 if (parts.size() == 1 || (parts.size() > 1 && !startsFromRoot)) {
4281#if defined(Q_OS_WIN)
4282 if (currentLocation.
endsWith(u
':'))
4287 while (!currentLocationList.isEmpty() && parts.size() > 0 && parts.at(0) ==
".."_L1) {
4288 parts.removeFirst();
4289 currentLocationList.removeLast();
4291 if (!currentLocationList.isEmpty() && currentLocationList.constLast().isEmpty())
4292 currentLocationList.removeLast();
4293 return currentLocationList + parts;
4304#include "moc_qfiledialog.cpp"
@ DontUseCustomDirectoryIcons
virtual void setOptions(Options)
Sets options that affect the icon provider.
virtual Options options() const
Returns all the options that affect the icon provider.
The QAbstractItemDelegate class is used to display and edit data items from a model.
virtual Q_INVOKABLE bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
Sets the role data for the item at index to value.
void rowsInserted(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted after rows have been inserted into the model.
virtual Q_INVOKABLE QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const =0
Returns the index of the item in the model specified by the given row, column and parent index.
The QAbstractItemView class provides the basic functionality for item view classes.
SelectionMode
This enum indicates how the view responds to user selections:
void activated(const QModelIndex &index)
This signal is emitted when the item specified by index is activated by the user.
void setEditTriggers(EditTriggers triggers)
void setTextElideMode(Qt::TextElideMode mode)
void setSelectionBehavior(QAbstractItemView::SelectionBehavior behavior)
void keyPressEvent(QKeyEvent *event) override
This function is called with the given event when a key event is sent to the widget.
void edit(const QModelIndex &index)
Starts editing the item corresponding to the given index if it is editable.
virtual int sizeHintForRow(int row) const
Returns the height size hint for the specified row or -1 if there is no model.
The QAbstractProxyModel class provides a base class for proxy item models that can do sorting,...
QAbstractItemModel * sourceModel
the source model of this proxy model.
virtual void setSourceModel(QAbstractItemModel *sourceModel)
Sets the given sourceModel to be processed by the proxy model.
The QActionGroup class groups actions together.
QList< QAction * > actions() const
Returns the list of this groups's actions.
void triggered(QAction *)
The QAction class provides an abstraction for user commands that can be added to different user inter...
void triggered(bool checked=false)
This signal is emitted when an action is activated by the user; for example, when the user clicks a m...
void setText(const QString &text)
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
QByteArray sliced(qsizetype pos) const &
virtual void initStyleOption(QStyleOptionComboBox *option) const
Initialize option with the values from this QComboBox.
@ AdjustToContentsOnFirstShow
void activated(int index)
This signal is sent when the user chooses an item in the combobox.
void textActivated(const QString &)
virtual void setModel(QAbstractItemModel *model)
Sets the model to be model.
QAbstractItemModel * model() const
Returns the model used by the combobox.
virtual void showPopup()
Displays the list of items in the combobox.
void setCurrentIndex(int index)
QString completionPrefix
the completion prefix used to provide completions.
void setModel(QAbstractItemModel *c)
Sets the model which provides completions to model.
static bool testAttribute(Qt::ApplicationAttribute attribute)
Returns true if attribute attribute is set; otherwise returns false.
\inmodule QtCore\reentrant
bool setNativeDialogVisible(bool visible)
virtual void setVisible(bool visible)
The QDialog class is the base class of dialog windows.
virtual void reject()
Hides the modal dialog and sets the result code to Rejected.
virtual int exec()
Shows the dialog as a \l{QDialog::Modal Dialogs}{modal dialog}, blocking until the user closes it.
DialogCode
The value returned by a modal dialog.
virtual void done(int)
Closes the dialog and sets its result code to r.
void setVisible(bool visible) override
\reimp
virtual void accept()
Hides the modal dialog and sets the result code to Accepted.
static bool isRelativePath(const QString &path)
Returns true if path is relative; returns false if it is absolute.
static QDir current()
Returns the application's current directory.
static QChar separator()
Returns the native directory separator: "/" under Unix and "\\" under Windows.
static QString cleanPath(const QString &path)
Returns path with directory separators normalized (that is, platform-native separators converted to "...
static QString toNativeSeparators(const QString &pathName)
static QString homePath()
Returns the absolute path of the user's home directory.
bool isEmpty(Filters filters=Filters(AllEntries|NoDotAndDotDot)) const
Returns whether the directory is empty.
static QString currentPath()
Returns the absolute path of the application's current directory.
static QString rootPath()
Returns the absolute path of the root directory.
Type type() const
Returns the event type.
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
QCompleter that can deal with QFileSystemModel.
QStringList splitPath(const QString &path) const override
Splits the given path into strings that are used to match at each level in the model().
QString pathFromIndex(const QModelIndex &index) const override
Returns the path for the given index.
QAbstractProxyModel * proxyModel
QFileSystemModel * sourceModel
void setHistory(const QStringList &paths)
void setFileDialogPrivate(QFileDialogPrivate *d_pointer)
void showPopup() override
Displays the list of items in the combobox.
void paintEvent(QPaintEvent *) override
\reimp
void keyPressEvent(QKeyEvent *e) override
FIXME: this is a hack to avoid propagating key press events to the dialog and from there to the "Ok" ...
void setFileDialogPrivate(QFileDialogPrivate *d_pointer)
QSize sizeHint() const override
void keyPressEvent(QKeyEvent *e) override
QStringList mimeTypeFilters() const
QList< QUrl > initiallySelectedFiles() const
void setHistory(const QStringList &paths)
bool isLabelExplicitlySet(DialogLabel label)
QDir::Filters filter() const
QString initiallySelectedNameFilter() const
void setWindowTitle(const QString &)
QString labelText(DialogLabel label) const
void setNameFilters(const QStringList &filters)
AcceptMode acceptMode() const
QString defaultSuffix() const
void setInitiallySelectedNameFilter(const QString &)
QList< QUrl > sidebarUrls() const
bool useDefaultNameFilters() const
QUrl initialDirectory() const
@ DontUseCustomDirectoryIcons
QStringList nameFilters() const
ViewMode viewMode() const
FileDialogOptions options() const
QStringList history() const
FileMode fileMode() const
void setSidebarUrls(const QList< QUrl > &urls)
static QString defaultNameFilterString()
void setInitiallySelectedFiles(const QList< QUrl > &)
void nativeCurrentChanged(const QUrl &file)
QModelIndex select(const QModelIndex &index) const
QModelIndex mapFromSource(const QModelIndex &index) const
void emitFilesSelected(const QStringList &files)
void nativeEnterDirectory(const QUrl &directory)
static void setLastVisitedDirectory(const QUrl &dir)
void navigate(HistoryItem &)
QList< QPersistentModelIndex > PersistentModelIndexList
void setLabelTextControl(QFileDialog::DialogLabel label, const QString &text)
QString getEnvironmentVariable(const QString &string)
static long maxNameLength(const QString &path)
bool removeDirectory(const QString &path)
QAbstractItemView * currentView() const
QScopedPointer< Ui_QFileDialog > qFileDialogUi
void updateFileTypeLabel()
void fileRenamed(const QString &path, const QString &oldName, const QString &newName)
void pathChanged(const QString &)
void retranslateStrings()
QAction * showHiddenAction
void emitUrlSelected(const QUrl &file)
void goToDirectory(const QString &)
void enterDirectory(const QModelIndex &index)
void retranslateWindowTitle()
QList< QUrl > sidebarUrls
static QString toInternal(const QString &path)
QLineEdit * lineEdit() const
void updateCancelButtonText()
QStringList typedFiles() const
QList< QUrl > selectedFiles_sys() const
void emitUrlsSelected(const QList< QUrl > &files)
QFileIconProvider defaultIconProvider
QAction * newFolderAction
void showHeader(QAction *)
QList< HistoryItem > currentHistory
void useNameFilter(int index)
virtual void helperPrepareShow(QPlatformDialogHelper *) override
void setRootIndex(const QModelIndex &index) const
void setVisible(bool visible) override
QList< QUrl > userSelectedFiles() const
QList< QUrl > addDefaultSuffixToUrls(const QList< QUrl > &urlsToFix) const
bool restoreWidgetState(QStringList &history, int splitterPosition)
QModelIndex rootIndex() const
QModelIndex mapToSource(const QModelIndex &index) const
int currentHistoryLocation
void updateFileNameLabel()
void currentChanged(const QModelIndex &index)
void showContextMenu(const QPoint &position)
bool canBeNativeDialog() const override
void updateOkButtonText(bool saveAsOnFolder=false)
QPlatformFileDialogHelper * platformFileDialogHelper() const
bool itemViewKeyboardEvent(QKeyEvent *event)
void init(const QFileDialogArgs &args)
void goToUrl(const QUrl &url)
virtual void initHelper(QPlatformDialogHelper *) override
virtual void helperDone(QDialog::DialogCode, QPlatformDialogHelper *) override
QSharedPointer< QFileDialogOptions > options
void autoCompleteFileName(const QString &)
void saveHistorySelection()
void rowsInserted(const QModelIndex &parent)
QStringList addDefaultSuffixToFiles(const QStringList &filesToFix) const
bool usingWidgets() const
void keyPressEvent(QKeyEvent *e) override
QSize sizeHint() const override
void setFileDialogPrivate(QFileDialogPrivate *d_pointer)
The QFileDialog class provides a dialog that allows users to select files or directories.
QList< QUrl > sidebarUrls() const
Options options
The various options that affect the look and feel of the dialog.
void setFilter(QDir::Filters filters)
FileMode
This enum is used to indicate what the user may select in the file dialog; that is,...
static QString getExistingDirectory(QWidget *parent=nullptr, const QString &caption=QString(), const QString &dir=QString(), Options options=ShowDirsOnly)
This is a convenience static function that returns an existing directory selected by the user.
static QList< QUrl > getOpenFileUrls(QWidget *parent=nullptr, const QString &caption=QString(), const QUrl &dir=QUrl(), const QString &filter=QString(), QString *selectedFilter=nullptr, Options options=Options(), const QStringList &supportedSchemes=QStringList())
This is a convenience static function that returns one or more existing files selected by the user.
bool restoreState(const QByteArray &state)
~QFileDialog()
Destroys the file dialog.
QString selectedNameFilter() const
void selectFile(const QString &filename)
Selects the given filename in the file dialog.
QFileDialog(QWidget *parent, Qt::WindowFlags f)
bool testOption(Option option) const
QStringList nameFilters() const
static QString getSaveFileName(QWidget *parent=nullptr, const QString &caption=QString(), const QString &dir=QString(), const QString &filter=QString(), QString *selectedFilter=nullptr, Options options=Options())
This is a convenience static function that returns a file name selected by the user.
void setDefaultSuffix(const QString &suffix)
void filesSelected(const QStringList &files)
When the selection changes for local operations and the dialog is accepted, this signal is emitted wi...
void setSupportedSchemes(const QStringList &schemes)
static QUrl getExistingDirectoryUrl(QWidget *parent=nullptr, const QString &caption=QString(), const QUrl &dir=QUrl(), Options options=ShowDirsOnly, const QStringList &supportedSchemes=QStringList())
This is a convenience static function that returns an existing directory selected by the user.
void setNameFilters(const QStringList &filters)
static QString getOpenFileName(QWidget *parent=nullptr, const QString &caption=QString(), const QString &dir=QString(), const QString &filter=QString(), QString *selectedFilter=nullptr, Options options=Options())
This is a convenience static function that returns an existing file selected by the user.
AcceptMode acceptMode
The accept mode of the dialog.
void done(int result) override
\reimp
QUrl directoryUrl() const
Returns the url of the directory currently being displayed in the dialog.
void fileSelected(const QString &file)
When the selection changes for local operations and the dialog is accepted, this signal is emitted wi...
void setViewMode(ViewMode mode)
void filterSelected(const QString &filter)
FileMode fileMode
The file mode of the dialog.
QStringList selectedFiles() const
Returns a list of strings containing the absolute paths of the selected files in the dialog.
void setAcceptMode(AcceptMode mode)
void selectNameFilter(const QString &filter)
QStringList supportedSchemes
The URL schemes that the file dialog should allow navigating to.
void setHistory(const QStringList &paths)
Sets the browsing history of the filedialog to contain the given paths.
@ DontUseCustomDirectoryIcons
QDir directory() const
Returns the directory currently being displayed in the dialog.
ViewMode viewMode
The way files and directories are displayed in the dialog.
static void saveFileContent(const QByteArray &fileContent, const QString &fileNameHint, QWidget *parent=nullptr)
This is a convenience static function that saves fileContent to a file, using a file name and locatio...
void setDirectory(const QString &directory)
Sets the file dialog's current directory.
static QUrl getOpenFileUrl(QWidget *parent=nullptr, const QString &caption=QString(), const QUrl &dir=QUrl(), const QString &filter=QString(), QString *selectedFilter=nullptr, Options options=Options(), const QStringList &supportedSchemes=QStringList())
This is a convenience static function that returns an existing file selected by the user.
void selectUrl(const QUrl &url)
Selects the given url in the file dialog.
void setFileMode(FileMode mode)
void setNameFilter(const QString &filter)
DialogLabel
\value LookIn \value FileName \value FileType \value Accept \value Reject
QByteArray saveState() const
QStringList history() const
Returns the browsing history of the filedialog as a list of paths.
AcceptMode
\value AcceptOpen \value AcceptSave
void setLabelText(DialogLabel label, const QString &text)
Sets the text shown in the filedialog in the specified label.
void setVisible(bool visible) override
\reimp
void accept() override
\reimp
static QUrl getSaveFileUrl(QWidget *parent=nullptr, const QString &caption=QString(), const QUrl &dir=QUrl(), const QString &filter=QString(), QString *selectedFilter=nullptr, Options options=Options(), const QStringList &supportedSchemes=QStringList())
This is a convenience static function that returns a file selected by the user.
void setSidebarUrls(const QList< QUrl > &urls)
QAbstractItemDelegate * itemDelegate() const
Returns the item delegate used to render the items in the views in the filedialog.
void changeEvent(QEvent *e) override
\reimp
static QStringList getOpenFileNames(QWidget *parent=nullptr, const QString &caption=QString(), const QString &dir=QString(), const QString &filter=QString(), QString *selectedFilter=nullptr, Options options=Options())
This is a convenience static function that returns one or more existing files selected by the user.
static void getOpenFileContent(const QString &nameFilter, const std::function< void(const QString &, const QByteArray &)> &fileContentsReady, QWidget *parent=nullptr)
This is a convenience static function that returns the content of a file selected by the user.
QList< QUrl > selectedUrls() const
Returns a list of urls containing the selected files in the dialog.
QString selectedMimeTypeFilter() const
QString defaultSuffix
Suffix added to the filename if no other suffix was specified.
void setItemDelegate(QAbstractItemDelegate *delegate)
Sets the item delegate used to render items in the views in the file dialog to the given delegate.
QString labelText(DialogLabel label) const
Returns the text shown in the filedialog in the specified label.
void setDirectoryUrl(const QUrl &directory)
Sets the file dialog's current directory url.
void setOption(Option option, bool on=true)
void setOptions(Options options)
QAbstractFileIconProvider * iconProvider() const
Returns the icon provider used by the filedialog.
ViewMode
This enum describes the view mode of the file dialog; that is, what information about each file is di...
void setIconProvider(QAbstractFileIconProvider *provider)
Sets the icon provider used by the filedialog to the specified provider.
QDir::Filters filter() const
QString suffix() const
Returns the suffix (extension) of the file.
bool isDir() const
Returns true if this object points to a directory or to a symbolic link to a directory.
bool isAbsolute() const
Returns true if the file system entry's path is absolute, otherwise returns false (that is,...
bool exists() const
Returns true if the file system entry this QFileInfo refers to exists; otherwise returns false.
The QFileSystemModel class provides a data model for the local filesystem.
QModelIndex mkdir(const QModelIndex &parent, const QString &name)
Create a directory with the name in the parent model index.
QDir rootDirectory() const
The currently set directory.
void setNameFilterDisables(bool enable)
void fileRenamed(const QString &path, const QString &oldName, const QString &newName)
This signal is emitted whenever a file with the oldName is successfully renamed to newName.
void rootPathChanged(const QString &newPath)
This signal is emitted whenever the root path has been changed to a newPath.
QString rootPath() const
The currently set root path.
QFileInfo fileInfo(const QModelIndex &index) const
Returns the QFileInfo for the item stored in the model under the given index.
void setIconProvider(QAbstractFileIconProvider *provider)
Sets the provider of file icons for the directory model.
QVariant myComputer(int role=Qt::DisplayRole) const
Returns the data stored under the given role for the item "My Computer".
void fetchMore(const QModelIndex &parent) override
\reimp
void setReadOnly(bool enable)
void setNameFilters(const QStringList &filters)
Sets the name filters to apply against the existing files.
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
\reimp
void setFilter(QDir::Filters filters)
Sets the directory model's filter to that specified by filters.
bool remove(const QModelIndex &index)
Removes the model item index from the file system model and {deletes the corresponding file from the ...
bool isDir(const QModelIndex &index) const
Returns true if the model item index represents a directory; otherwise returns false.
QFILE_MAYBE_NODISCARD bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
static QByteArray encodeName(const QString &fileName)
Converts fileName to an 8-bit encoding that you can use in native APIs.
static QString decodeName(const QByteArray &localFileName)
This does the reverse of QFile::encodeName() using localFileName.
bool exists() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
\reentrant \inmodule QtGui
QString elidedText(const QString &text, Qt::TextElideMode mode, int width, int flags=0) const
static Qt::KeyboardModifiers keyboardModifiers()
Returns the current state of the modifier keys on the keyboard.
QByteArray readAll()
Reads all remaining data from the device, and returns it as a byte array.
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
This signal is emitted whenever the selection changes.
void currentChanged(const QModelIndex ¤t, const QModelIndex &previous)
This signal is emitted whenever the current item changes.
The QKeyEvent class describes a key event.
int key() const
Returns the code of the key that was pressed or released.
The QLineEdit widget is a one-line text editor.
void returnPressed()
This signal is emitted when the Return or Enter key is used.
void selectAll()
Selects all the text (highlights it) and moves the cursor to the end.
void clear()
Clears the contents of the line edit.
void textChanged(const QString &)
This signal is emitted whenever the text changes.
void setText(const QString &)
QString text
The line edit's text.
void keyPressEvent(QKeyEvent *) override
Converts the given key press event into a line edit action.
void setWrapping(bool enable)
void setResizeMode(ResizeMode mode)
qsizetype size() const noexcept
bool isEmpty() const noexcept
const_reference at(qsizetype i) const noexcept
T value(qsizetype i) const
const_reverse_iterator crbegin() const noexcept
void append(parameter_type t)
const_reverse_iterator crend() const noexcept
The QMessageBox class provides a modal dialog for informing the user or for asking the user a questio...
static StandardButton warning(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
QMimeType mimeTypeForName(const QString &nameOrAlias) const
Returns a MIME type for nameOrAlias or an invalid one if none found.
QVariant data(int role=Qt::DisplayRole) const
Returns the data for the given role for the item referred to by the index.
constexpr int row() const noexcept
Returns the row this model index refers to.
QModelIndex parent() const
Returns the parent of the model index, or QModelIndex() if it has no parent.
constexpr const QAbstractItemModel * model() const noexcept
Returns a pointer to the model containing the item that this index refers to.
constexpr int column() const noexcept
Returns the column this model index refers to.
constexpr bool isValid() const noexcept
Returns {true} if this model index is valid; otherwise returns {false}.
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)
static bool disconnect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiverPrivate, Func2 slot)
QObject * parent() const
Returns a pointer to the parent object.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
void setParent(QObject *parent)
Makes the object a child of parent.
Q_WEAK_OVERLOAD void setObjectName(const QString &name)
Sets the object's name to name.
The QPaintEvent class contains event parameters for paint events.
void setPen(const QColor &color)
This is an overloaded member function, provided for convenience. It differs from the above function o...
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
\inmodule QtCore \reentrant
bool isNull() const noexcept
Returns true if this object refers to \nullptr.
void reset(T *other=nullptr) noexcept(noexcept(Cleanup::cleanup(std::declval< T * >())))
Deletes the existing object it is pointing to (if any), and sets its pointer to other.
const_iterator cbegin() const noexcept
void setValue(QAnyStringView key, const QVariant &value)
Sets the value of setting key to value.
QVariant value(QAnyStringView key, const QVariant &defaultValue) const
Returns the value for setting key.
QStringList childGroups() const
Returns a list of all key top-level groups that contain keys that can be read using the QSettings obj...
void beginGroup(QAnyStringView prefix)
Appends prefix to the current group.
The QShortcut class is used to create keyboard shortcuts.
void activated()
This signal is emitted when the user types the shortcut's key sequence.
Exception-safe wrapper around QObject::blockSignals().
constexpr int width() const noexcept
Returns the width.
constexpr bool isValid() const noexcept
Returns true if both the width and height is equal to or greater than 0; otherwise returns false.
The QStandardItemModel class provides a generic model for storing custom data.
constexpr QStringView mid(qsizetype pos, qsizetype n=-1) const noexcept
Returns the substring of length length starting at position start in this object.
\macro QT_RESTRICTED_CAST_FROM_ASCII
QString left(qsizetype n) const &
QByteArray toLatin1() const &
qsizetype lastIndexOf(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
QString sliced(qsizetype pos) const &
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
const ushort * utf16() const
Returns the QString as a '\0\'-terminated array of unsigned shorts.
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.
static QString fromStdString(const std::string &s)
QString mid(qsizetype position, qsizetype n=-1) const &
static QString fromLocal8Bit(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
qsizetype size() const noexcept
Returns the number of characters in this string.
std::string toStdString() const
Returns a std::string object with the data contained in this QString.
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
QChar * data()
Returns a pointer to the data stored in the QString.
bool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString & append(QChar c)
\variable QStyleOptionToolButton::features
The QStylePainter class is a convenience class for drawing QStyle elements inside a widget.
virtual QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget=nullptr) const =0
Returns the rectangle containing the specified subControl of the given complex control (with the styl...
@ SH_ItemView_ActivateItemOnSingleClick
@ SP_FileDialogDetailedView
void setItemsExpandable(bool enable)
QHeaderView * header() const
Returns the header for the tree view.
void keyPressEvent(QKeyEvent *event) override
\reimp
void setRootIsDecorated(bool show)
void setSortingEnabled(bool enable)
void setUrls(const QList< QUrl > &list)
void addUrls(const QList< QUrl > &urls, int row=-1, bool move=true)
Add urls list into the list at row.
void setFileSystemModel(QFileSystemModel *model)
QFileSystemModel to get index's from, clears existing rows.
static QUrl fromLocalFile(const QString &localfile)
Returns a QUrl representation of localFile, interpreted as a local file.
static QList< QUrl > fromStringList(const QStringList &uris, ParsingMode mode=TolerantMode)
QString fileName(ComponentFormattingOptions options=FullyDecoded) const
static QStringList toStringList(const QList< QUrl > &uris, FormattingOptions options=FormattingOptions(PrettyDecoded))
bool isValid() const
Returns true if the URL is non-empty and valid; otherwise returns false.
bool isEmpty() const
Returns true if the URL has no data; otherwise returns false.
void setPath(const QString &path, ParsingMode mode=DecodedMode)
Sets the path of the URL to path.
QString toString(FormattingOptions options=FormattingOptions(PrettyDecoded)) const
Returns a string representation of the URL.
QString toLocalFile() const
Returns the path of this URL formatted as a local file path.
QString path(ComponentFormattingOptions options=FullyDecoded) const
Returns the path of the URL.
int toInt(bool *ok=nullptr) const
Returns the variant as an int if the variant has userType() \l QMetaType::Int, \l QMetaType::Bool,...
QString toString() const
Returns the variant as a QString if the variant has a userType() including, but not limited to:
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has userType() \l QMetaType::QByteArray or \l QMet...
QStringList toStringList() const
Returns the variant as a QStringList if the variant has userType() \l QMetaType::QStringList,...
QUrl toUrl() const
Returns the variant as a QUrl if the variant has userType() \l QMetaType::QUrl; otherwise returns an ...
QSet< QString >::iterator it
Combined button and popup list for selecting options.
void saveFile(const QByteArray &data, const std::string &fileNameHint)
void openFile(const std::string &accept, const std::function< void(bool fileSelected)> &fileDialogClosed, const std::function< char *(uint64_t size, const std::string &name)> &acceptFile, const std::function< void()> &fileDataReady)
@ NavigationModeKeypadDirectional
@ AA_DontUseNativeDialogs
QList< QString > QStringList
Constructs a string list that contains the given string, str.
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
static QUrl _qt_get_directory(const QUrl &url, const QFileInfo &local)
static const qint32 QFileDialogMagic
QStringList qt_strip_filters(const QStringList &filters)
QStringList qt_make_filter_list(const QString &filter)
static QString fileFromPath(const QString &rootPath, QString path)
static bool isCaseSensitiveFileSystem(const QString &path)
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
GLsizei const GLfloat * v
[13]
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLsizei const GLuint * paths
GLuint GLsizei const GLchar * label
[43]
GLenum GLuint GLenum GLsizei const GLchar * buf
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
GLuint GLsizei const GLchar * message
GLfloat GLfloat GLfloat GLfloat h
GLdouble GLdouble GLdouble GLdouble q
GLsizei const GLchar *const * path
GLsizei const GLchar *const * string
[0]
static QT_BEGIN_NAMESPACE bool isRelative(const QString &path)
static QString absolutePath(const QString &path)
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
static constexpr QChar sep
#define QStringLiteral(str)
#define QT_BEGIN_INCLUDE_NAMESPACE
#define Q_AUTOTEST_EXPORT
#define QT_END_INCLUDE_NAMESPACE
#define QT_CONFIG(feature)
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
static bool match(const uchar *found, uint foundLen, const char *target, uint targetLen)
const char className[16]
[1]
QSqlQueryModel * model
[16]
if(qFloatDistance(a, b)<(1<< 7))
[0]
QSettings settings("MySoft", "Star Runner")
[0]
QUrl url("example.com")
[constructor-url-reference]
application x qt windows mime
[2]
myObject disconnect()
[26]
XML files xml auto fileContentReady
[14]
QFileDialog dialog(this)
[1]
dialog setFileMode(QFileDialog::AnyFile)
const QStringList filters({"Image files (*.png *.xpm *.jpg)", "Text files (*.txt)", "Any files (*)" })
[6]
QCompleter * completer
[0]
char * toString(const MyType &t)
[31]
QFileDialogArgs(const QUrl &url={})
qsizetype indexOf(const AT &t, qsizetype from=0) const noexcept