summaryrefslogtreecommitdiffstats
path: root/src/widgets/dialogs/qfiledialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/dialogs/qfiledialog.cpp')
-rw-r--r--src/widgets/dialogs/qfiledialog.cpp69
1 files changed, 32 insertions, 37 deletions
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index 966d86b089..05fbd072ec 100644
--- a/src/widgets/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
@@ -193,7 +193,7 @@ Q_GLOBAL_STATIC(QUrl, lastVisitedDir)
\value DontConfirmOverwrite Don't ask for confirmation if an
existing file is selected. By default confirmation is requested.
- Note: This opption is not supported on macOS when using the
+ Note: This option is not supported on macOS when using the
native file dialog.
\value DontUseNativeDialog Don't use the native file dialog. By
@@ -652,7 +652,7 @@ void QFileDialogPrivate::retranslateStrings()
if (proxyModel)
abstractModel = proxyModel;
#endif
- int total = qMin(abstractModel->columnCount(QModelIndex()), actions.count() + 1);
+ int total = qMin(abstractModel->columnCount(QModelIndex()), actions.size() + 1);
for (int i = 1; i < total; ++i) {
actions.at(i - 1)->setText(QFileDialog::tr("Show ") + abstractModel->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString());
}
@@ -673,7 +673,7 @@ void QFileDialogPrivate::emitFilesSelected(const QStringList &files)
{
Q_Q(QFileDialog);
emit q->filesSelected(files);
- if (files.count() == 1)
+ if (files.size() == 1)
emit q->fileSelected(files.first());
}
@@ -1357,7 +1357,7 @@ QStringList qt_strip_filters(const QStringList &filters)
#if QT_CONFIG(regularexpression)
QStringList strippedFilters;
static const QRegularExpression r(QString::fromLatin1(QPlatformFileDialogHelper::filterRegExp));
- const int numFilters = filters.count();
+ const int numFilters = filters.size();
strippedFilters.reserve(numFilters);
for (int i = 0; i < numFilters; ++i) {
QString filterName;
@@ -1396,7 +1396,7 @@ void QFileDialog::setNameFilters(const QStringList &filters)
{
Q_D(QFileDialog);
QStringList cleanedFilters;
- const int numFilters = filters.count();
+ const int numFilters = filters.size();
cleanedFilters.reserve(numFilters);
for (int i = 0; i < numFilters; ++i) {
cleanedFilters << filters[i].simplified();
@@ -2304,20 +2304,15 @@ void QFileDialog::getOpenFileContent(const QString &nameFilter, const std::funct
openFileImpl.reset();
};
- auto qtFilterStringToWebAcceptString = [](const QString &qtString) {
- // The Qt and Web name filter string formats are similar, but
- // not identical.
- return qtString.toStdString(); // ### TODO
- };
-
- QWasmLocalFileAccess::openFile(qtFilterStringToWebAcceptString(nameFilter), fileDialogClosed, acceptFile, fileContentReady);
+ QWasmLocalFileAccess::openFile(nameFilter.toStdString(), fileDialogClosed,
+ acceptFile, fileContentReady);
};
(*openFileImpl)();
#else
QFileDialog *dialog = new QFileDialog();
dialog->setFileMode(QFileDialog::ExistingFile);
- dialog->selectNameFilter(nameFilter);
+ dialog->setNameFilter(nameFilter);
auto fileSelected = [=](const QString &fileName) {
QByteArray fileContent;
@@ -2686,7 +2681,7 @@ void QFileDialog::accept()
if (urls.isEmpty())
return;
d->_q_emitUrlsSelected(urls);
- if (urls.count() == 1)
+ if (urls.size() == 1)
d->_q_emitUrlSelected(urls.first());
QDialog::accept();
return;
@@ -2736,7 +2731,7 @@ void QFileDialog::accept()
if (!info.exists()) {
int maxNameLength = d->maxNameLength(info.path());
- if (maxNameLength >= 0 && info.fileName().length() > maxNameLength)
+ if (maxNameLength >= 0 && info.fileName().size() > maxNameLength)
return;
}
@@ -2857,8 +2852,8 @@ bool QFileDialogPrivate::restoreWidgetState(QStringList &history, int splitterPo
if (!qFileDialogUi->splitter->restoreState(splitterState))
return false;
QList<int> list = qFileDialogUi->splitter->sizes();
- if (list.count() >= 2 && (list.at(0) == 0 || list.at(1) == 0)) {
- for (int i = 0; i < list.count(); ++i)
+ if (list.size() >= 2 && (list.at(0) == 0 || list.at(1) == 0)) {
+ for (int i = 0; i < list.size(); ++i)
list[i] = qFileDialogUi->splitter->widget(i)->sizeHint().width();
qFileDialogUi->splitter->setSizes(list);
}
@@ -2881,7 +2876,7 @@ bool QFileDialogPrivate::restoreWidgetState(QStringList &history, int splitterPo
if (proxyModel)
abstractModel = proxyModel;
#endif
- int total = qMin(abstractModel->columnCount(QModelIndex()), actions.count() + 1);
+ int total = qMin(abstractModel->columnCount(QModelIndex()), actions.size() + 1);
for (int i = 1; i < total; ++i)
actions.at(i - 1)->setChecked(!headerView->isSectionHidden(i));
@@ -3337,7 +3332,7 @@ void QFileDialogPrivate::_q_pathChanged(const QString &newPath)
if (currentHistoryLocation < 0 || currentHistory.value(currentHistoryLocation).path != newNativePath) {
if (currentHistoryLocation >= 0)
saveHistorySelection();
- while (currentHistoryLocation >= 0 && currentHistoryLocation + 1 < currentHistory.count()) {
+ while (currentHistoryLocation >= 0 && currentHistoryLocation + 1 < currentHistory.size()) {
currentHistory.removeLast();
}
currentHistory.append({newNativePath, PersistentModelIndexList()});
@@ -3543,7 +3538,7 @@ void QFileDialogPrivate::_q_deleteCurrent()
return;
QModelIndexList list = qFileDialogUi->listView->selectionModel()->selectedRows();
- for (int i = list.count() - 1; i >= 0; --i) {
+ for (int i = list.size() - 1; i >= 0; --i) {
QPersistentModelIndex index = list.at(i);
if (index == qFileDialogUi->listView->rootIndex())
continue;
@@ -3599,7 +3594,7 @@ void QFileDialogPrivate::_q_autoCompleteFileName(const QString &text)
}
const QStringList multipleFiles = typedFiles();
- if (multipleFiles.count() > 0) {
+ if (multipleFiles.size() > 0) {
QModelIndexList oldFiles = qFileDialogUi->listView->selectionModel()->selectedRows();
QList<QModelIndex> newFiles;
for (const auto &file : multipleFiles) {
@@ -3607,11 +3602,11 @@ void QFileDialogPrivate::_q_autoCompleteFileName(const QString &text)
if (oldFiles.removeAll(idx) == 0)
newFiles.append(idx);
}
- for (const auto &newFile : qAsConst(newFiles))
+ for (const auto &newFile : std::as_const(newFiles))
select(newFile);
if (lineEdit()->hasFocus()) {
auto *sm = qFileDialogUi->listView->selectionModel();
- for (const auto &oldFile : qAsConst(oldFiles))
+ for (const auto &oldFile : std::as_const(oldFiles))
sm->select(oldFile, QItemSelectionModel::Toggle | QItemSelectionModel::Rows);
}
}
@@ -3666,7 +3661,7 @@ void QFileDialogPrivate::_q_updateOkButton()
fileDir = info.canonicalFilePath();
} else {
fileDir = fn.mid(0, fn.lastIndexOf(u'/'));
- fileName = fn.mid(fileDir.length() + 1);
+ fileName = fn.mid(fileDir.size() + 1);
}
if (lineEditText.contains(".."_L1)) {
fileDir = info.canonicalFilePath();
@@ -3684,7 +3679,7 @@ void QFileDialogPrivate::_q_updateOkButton()
}
if (!idx.isValid()) {
int maxLength = maxNameLength(fileDir);
- enableButton = maxLength < 0 || fileName.length() <= maxLength;
+ enableButton = maxLength < 0 || fileName.size() <= maxLength;
}
break;
}
@@ -3807,14 +3802,14 @@ void QFileDialogPrivate::_q_useNameFilter(int index)
QStringList newNameFilters = QPlatformFileDialogHelper::cleanFilterList(nameFilter);
if (q_func()->acceptMode() == QFileDialog::AcceptSave) {
QString newNameFilterExtension;
- if (newNameFilters.count() > 0)
+ if (newNameFilters.size() > 0)
newNameFilterExtension = QFileInfo(newNameFilters.at(0)).suffix();
QString fileName = lineEdit()->text();
const QString fileNameExtension = QFileInfo(fileName).suffix();
if (!fileNameExtension.isEmpty() && !newNameFilterExtension.isEmpty()) {
- const int fileNameExtensionLength = fileNameExtension.length();
- fileName.replace(fileName.length() - fileNameExtensionLength,
+ const int fileNameExtensionLength = fileNameExtension.size();
+ fileName.replace(fileName.size() - fileNameExtensionLength,
fileNameExtensionLength, newNameFilterExtension);
qFileDialogUi->listView->clearSelection();
lineEdit()->setText(fileName);
@@ -3842,8 +3837,8 @@ void QFileDialogPrivate::_q_selectionChanged()
continue;
allFiles.append(index.data().toString());
}
- if (allFiles.count() > 1)
- for (qsizetype i = 0; i < allFiles.count(); ++i) {
+ if (allFiles.size() > 1)
+ for (qsizetype i = 0; i < allFiles.size(); ++i) {
allFiles.replace(i, QString(u'"' + allFiles.at(i) + u'"'));
}
@@ -4011,12 +4006,12 @@ void QFileDialogComboBox::showPopup()
// append history
QList<QUrl> urls;
- for (int i = 0; i < m_history.count(); ++i) {
+ for (int i = 0; i < m_history.size(); ++i) {
QUrl path = QUrl::fromLocalFile(m_history.at(i));
if (!urls.contains(path))
urls.prepend(path);
}
- if (urls.count() > 0) {
+ if (urls.size() > 0) {
model()->insertRow(model()->rowCount());
idx = model()->index(model()->rowCount()-1, 0);
// ### TODO maybe add a horizontal line before this
@@ -4162,12 +4157,12 @@ QString QFSCompleter::pathFromIndex(const QModelIndex &index) const
if (!currentLocation.isEmpty() && path.startsWith(currentLocation)) {
#if defined(Q_OS_UNIX)
if (currentLocation == QDir::separator())
- return path.mid(currentLocation.length());
+ return path.mid(currentLocation.size());
#endif
if (currentLocation.endsWith(u'/'))
- return path.mid(currentLocation.length());
+ return path.mid(currentLocation.size());
else
- return path.mid(currentLocation.length()+1);
+ return path.mid(currentLocation.size()+1);
}
return index.data(QFileSystemModel::FilePathRole).toString();
}
@@ -4219,7 +4214,7 @@ QStringList QFSCompleter::splitPath(const QString &path) const
#else
bool startsFromRoot = pathCopy[0] == sep;
#endif
- if (parts.count() == 1 || (parts.count() > 1 && !startsFromRoot)) {
+ if (parts.size() == 1 || (parts.size() > 1 && !startsFromRoot)) {
const QFileSystemModel *dirModel;
if (proxyModel)
dirModel = qobject_cast<const QFileSystemModel *>(proxyModel->sourceModel());
@@ -4232,7 +4227,7 @@ QStringList QFSCompleter::splitPath(const QString &path) const
#endif
if (currentLocation.contains(sep) && path != currentLocation) {
QStringList currentLocationList = splitPath(currentLocation);
- while (!currentLocationList.isEmpty() && parts.count() > 0 && parts.at(0) == ".."_L1) {
+ while (!currentLocationList.isEmpty() && parts.size() > 0 && parts.at(0) == ".."_L1) {
parts.removeFirst();
currentLocationList.removeLast();
}