summaryrefslogtreecommitdiffstats
path: root/examples/widgets/dialogs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/widgets/dialogs')
-rw-r--r--examples/widgets/dialogs/configdialog/configdialog.cpp124
-rw-r--r--examples/widgets/dialogs/configdialog/configdialog.h79
-rw-r--r--examples/widgets/dialogs/configdialog/configdialog.pro12
-rw-r--r--examples/widgets/dialogs/configdialog/configdialog.qrc7
-rw-r--r--examples/widgets/dialogs/configdialog/images/config.pngbin6758 -> 0 bytes
-rw-r--r--examples/widgets/dialogs/configdialog/images/query.pngbin2116 -> 0 bytes
-rw-r--r--examples/widgets/dialogs/configdialog/images/update.pngbin7890 -> 0 bytes
-rw-r--r--examples/widgets/dialogs/configdialog/main.cpp63
-rw-r--r--examples/widgets/dialogs/configdialog/pages.cpp161
-rw-r--r--examples/widgets/dialogs/configdialog/pages.h74
-rw-r--r--examples/widgets/dialogs/dialogs.pro2
-rw-r--r--examples/widgets/dialogs/findfiles/window.cpp57
-rw-r--r--examples/widgets/dialogs/findfiles/window.h2
13 files changed, 24 insertions, 557 deletions
diff --git a/examples/widgets/dialogs/configdialog/configdialog.cpp b/examples/widgets/dialogs/configdialog/configdialog.cpp
deleted file mode 100644
index 5a0fb1c3bc..0000000000
--- a/examples/widgets/dialogs/configdialog/configdialog.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
-
-#include "configdialog.h"
-#include "pages.h"
-
-ConfigDialog::ConfigDialog()
-{
- contentsWidget = new QListWidget;
- contentsWidget->setViewMode(QListView::IconMode);
- contentsWidget->setIconSize(QSize(96, 84));
- contentsWidget->setMovement(QListView::Static);
- contentsWidget->setMaximumWidth(128);
- contentsWidget->setSpacing(12);
-
- pagesWidget = new QStackedWidget;
- pagesWidget->addWidget(new ConfigurationPage);
- pagesWidget->addWidget(new UpdatePage);
- pagesWidget->addWidget(new QueryPage);
-
- QPushButton *closeButton = new QPushButton(tr("Close"));
-
- createIcons();
- contentsWidget->setCurrentRow(0);
-
- connect(closeButton, &QAbstractButton::clicked, this, &QWidget::close);
-
- QHBoxLayout *horizontalLayout = new QHBoxLayout;
- horizontalLayout->addWidget(contentsWidget);
- horizontalLayout->addWidget(pagesWidget, 1);
-
- QHBoxLayout *buttonsLayout = new QHBoxLayout;
- buttonsLayout->addStretch(1);
- buttonsLayout->addWidget(closeButton);
-
- QVBoxLayout *mainLayout = new QVBoxLayout;
- mainLayout->addLayout(horizontalLayout);
- mainLayout->addStretch(1);
- mainLayout->addSpacing(12);
- mainLayout->addLayout(buttonsLayout);
- setLayout(mainLayout);
-
- setWindowTitle(tr("Config Dialog"));
-}
-
-void ConfigDialog::createIcons()
-{
- QListWidgetItem *configButton = new QListWidgetItem(contentsWidget);
- configButton->setIcon(QIcon(":/images/config.png"));
- configButton->setText(tr("Configuration"));
- configButton->setTextAlignment(Qt::AlignHCenter);
- configButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
-
- QListWidgetItem *updateButton = new QListWidgetItem(contentsWidget);
- updateButton->setIcon(QIcon(":/images/update.png"));
- updateButton->setText(tr("Update"));
- updateButton->setTextAlignment(Qt::AlignHCenter);
- updateButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
-
- QListWidgetItem *queryButton = new QListWidgetItem(contentsWidget);
- queryButton->setIcon(QIcon(":/images/query.png"));
- queryButton->setText(tr("Query"));
- queryButton->setTextAlignment(Qt::AlignHCenter);
- queryButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
-
- connect(contentsWidget, &QListWidget::currentItemChanged, this, &ConfigDialog::changePage);
-}
-
-void ConfigDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous)
-{
- if (!current)
- current = previous;
-
- pagesWidget->setCurrentIndex(contentsWidget->row(current));
-}
diff --git a/examples/widgets/dialogs/configdialog/configdialog.h b/examples/widgets/dialogs/configdialog/configdialog.h
deleted file mode 100644
index c2edd204e6..0000000000
--- a/examples/widgets/dialogs/configdialog/configdialog.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef CONFIGDIALOG_H
-#define CONFIGDIALOG_H
-
-#include <QDialog>
-
-QT_BEGIN_NAMESPACE
-class QListWidget;
-class QListWidgetItem;
-class QStackedWidget;
-QT_END_NAMESPACE
-
-class ConfigDialog : public QDialog
-{
- Q_OBJECT
-
-public:
- ConfigDialog();
-
-public slots:
- void changePage(QListWidgetItem *current, QListWidgetItem *previous);
-
-private:
- void createIcons();
-
- QListWidget *contentsWidget;
- QStackedWidget *pagesWidget;
-};
-
-#endif
diff --git a/examples/widgets/dialogs/configdialog/configdialog.pro b/examples/widgets/dialogs/configdialog/configdialog.pro
deleted file mode 100644
index 8ba55becad..0000000000
--- a/examples/widgets/dialogs/configdialog/configdialog.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-QT += widgets
-
-HEADERS = configdialog.h \
- pages.h
-SOURCES = configdialog.cpp \
- main.cpp \
- pages.cpp
-RESOURCES += configdialog.qrc
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/dialogs/configdialog
-INSTALLS += target
diff --git a/examples/widgets/dialogs/configdialog/configdialog.qrc b/examples/widgets/dialogs/configdialog/configdialog.qrc
deleted file mode 100644
index 31d0d49666..0000000000
--- a/examples/widgets/dialogs/configdialog/configdialog.qrc
+++ /dev/null
@@ -1,7 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>images/config.png</file>
- <file>images/query.png</file>
- <file>images/update.png</file>
-</qresource>
-</RCC>
diff --git a/examples/widgets/dialogs/configdialog/images/config.png b/examples/widgets/dialogs/configdialog/images/config.png
deleted file mode 100644
index 5c14d5f470..0000000000
--- a/examples/widgets/dialogs/configdialog/images/config.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/dialogs/configdialog/images/query.png b/examples/widgets/dialogs/configdialog/images/query.png
deleted file mode 100644
index ea9e291eeb..0000000000
--- a/examples/widgets/dialogs/configdialog/images/query.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/dialogs/configdialog/images/update.png b/examples/widgets/dialogs/configdialog/images/update.png
deleted file mode 100644
index 3cb8ba6c77..0000000000
--- a/examples/widgets/dialogs/configdialog/images/update.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/dialogs/configdialog/main.cpp b/examples/widgets/dialogs/configdialog/main.cpp
deleted file mode 100644
index e73474b866..0000000000
--- a/examples/widgets/dialogs/configdialog/main.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-
-#include "configdialog.h"
-
-int main(int argc, char *argv[])
-{
- Q_INIT_RESOURCE(configdialog);
-
- QApplication app(argc, argv);
- app.setApplicationDisplayName("Qt Example");
- ConfigDialog dialog;
- return dialog.exec();
-}
diff --git a/examples/widgets/dialogs/configdialog/pages.cpp b/examples/widgets/dialogs/configdialog/pages.cpp
deleted file mode 100644
index 0c7762f029..0000000000
--- a/examples/widgets/dialogs/configdialog/pages.cpp
+++ /dev/null
@@ -1,161 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
-
-#include "pages.h"
-
-ConfigurationPage::ConfigurationPage(QWidget *parent)
- : QWidget(parent)
-{
- QGroupBox *configGroup = new QGroupBox(tr("Server configuration"));
-
- QLabel *serverLabel = new QLabel(tr("Server:"));
- QComboBox *serverCombo = new QComboBox;
- serverCombo->addItem(tr("Qt (Australia)"));
- serverCombo->addItem(tr("Qt (Germany)"));
- serverCombo->addItem(tr("Qt (Norway)"));
- serverCombo->addItem(tr("Qt (People's Republic of China)"));
- serverCombo->addItem(tr("Qt (USA)"));
-
- QHBoxLayout *serverLayout = new QHBoxLayout;
- serverLayout->addWidget(serverLabel);
- serverLayout->addWidget(serverCombo);
-
- QVBoxLayout *configLayout = new QVBoxLayout;
- configLayout->addLayout(serverLayout);
- configGroup->setLayout(configLayout);
-
- QVBoxLayout *mainLayout = new QVBoxLayout;
- mainLayout->addWidget(configGroup);
- mainLayout->addStretch(1);
- setLayout(mainLayout);
-}
-
-UpdatePage::UpdatePage(QWidget *parent)
- : QWidget(parent)
-{
- QGroupBox *updateGroup = new QGroupBox(tr("Package selection"));
- QCheckBox *systemCheckBox = new QCheckBox(tr("Update system"));
- QCheckBox *appsCheckBox = new QCheckBox(tr("Update applications"));
- QCheckBox *docsCheckBox = new QCheckBox(tr("Update documentation"));
-
- QGroupBox *packageGroup = new QGroupBox(tr("Existing packages"));
-
- QListWidget *packageList = new QListWidget;
- QListWidgetItem *qtItem = new QListWidgetItem(packageList);
- qtItem->setText(tr("Qt"));
- QListWidgetItem *qsaItem = new QListWidgetItem(packageList);
- qsaItem->setText(tr("QSA"));
- QListWidgetItem *teamBuilderItem = new QListWidgetItem(packageList);
- teamBuilderItem->setText(tr("Teambuilder"));
-
- QPushButton *startUpdateButton = new QPushButton(tr("Start update"));
-
- QVBoxLayout *updateLayout = new QVBoxLayout;
- updateLayout->addWidget(systemCheckBox);
- updateLayout->addWidget(appsCheckBox);
- updateLayout->addWidget(docsCheckBox);
- updateGroup->setLayout(updateLayout);
-
- QVBoxLayout *packageLayout = new QVBoxLayout;
- packageLayout->addWidget(packageList);
- packageGroup->setLayout(packageLayout);
-
- QVBoxLayout *mainLayout = new QVBoxLayout;
- mainLayout->addWidget(updateGroup);
- mainLayout->addWidget(packageGroup);
- mainLayout->addSpacing(12);
- mainLayout->addWidget(startUpdateButton);
- mainLayout->addStretch(1);
- setLayout(mainLayout);
-}
-
-QueryPage::QueryPage(QWidget *parent)
- : QWidget(parent)
-{
- QGroupBox *packagesGroup = new QGroupBox(tr("Look for packages"));
-
- QLabel *nameLabel = new QLabel(tr("Name:"));
- QLineEdit *nameEdit = new QLineEdit;
-
- QLabel *dateLabel = new QLabel(tr("Released after:"));
- QDateTimeEdit *dateEdit = new QDateTimeEdit(QDate::currentDate());
-
- QCheckBox *releasesCheckBox = new QCheckBox(tr("Releases"));
- QCheckBox *upgradesCheckBox = new QCheckBox(tr("Upgrades"));
-
- QSpinBox *hitsSpinBox = new QSpinBox;
- hitsSpinBox->setPrefix(tr("Return up to "));
- hitsSpinBox->setSuffix(tr(" results"));
- hitsSpinBox->setSpecialValueText(tr("Return only the first result"));
- hitsSpinBox->setMinimum(1);
- hitsSpinBox->setMaximum(100);
- hitsSpinBox->setSingleStep(10);
-
- QPushButton *startQueryButton = new QPushButton(tr("Start query"));
-
- QGridLayout *packagesLayout = new QGridLayout;
- packagesLayout->addWidget(nameLabel, 0, 0);
- packagesLayout->addWidget(nameEdit, 0, 1);
- packagesLayout->addWidget(dateLabel, 1, 0);
- packagesLayout->addWidget(dateEdit, 1, 1);
- packagesLayout->addWidget(releasesCheckBox, 2, 0);
- packagesLayout->addWidget(upgradesCheckBox, 3, 0);
- packagesLayout->addWidget(hitsSpinBox, 4, 0, 1, 2);
- packagesGroup->setLayout(packagesLayout);
-
- QVBoxLayout *mainLayout = new QVBoxLayout;
- mainLayout->addWidget(packagesGroup);
- mainLayout->addSpacing(12);
- mainLayout->addWidget(startQueryButton);
- mainLayout->addStretch(1);
- setLayout(mainLayout);
-}
diff --git a/examples/widgets/dialogs/configdialog/pages.h b/examples/widgets/dialogs/configdialog/pages.h
deleted file mode 100644
index beb7f86ae0..0000000000
--- a/examples/widgets/dialogs/configdialog/pages.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef PAGES_H
-#define PAGES_H
-
-#include <QWidget>
-
-class ConfigurationPage : public QWidget
-{
-public:
- ConfigurationPage(QWidget *parent = 0);
-};
-
-class QueryPage : public QWidget
-{
-public:
- QueryPage(QWidget *parent = 0);
-};
-
-class UpdatePage : public QWidget
-{
-public:
- UpdatePage(QWidget *parent = 0);
-};
-
-#endif
diff --git a/examples/widgets/dialogs/dialogs.pro b/examples/widgets/dialogs/dialogs.pro
index 82e814dcb0..753308fc55 100644
--- a/examples/widgets/dialogs/dialogs.pro
+++ b/examples/widgets/dialogs/dialogs.pro
@@ -2,7 +2,6 @@ QT_FOR_CONFIG += widgets
TEMPLATE = subdirs
SUBDIRS = classwizard \
- configdialog \
extension \
findfiles \
licensewizard \
@@ -14,4 +13,3 @@ SUBDIRS = classwizard \
!qtConfig(wizard) {
SUBDIRS -= trivialwizard licensewizard classwizard
}
-wince: SUBDIRS += sipdialog
diff --git a/examples/widgets/dialogs/findfiles/window.cpp b/examples/widgets/dialogs/findfiles/window.cpp
index f2ce853d99..1b16cdcd35 100644
--- a/examples/widgets/dialogs/findfiles/window.cpp
+++ b/examples/widgets/dialogs/findfiles/window.cpp
@@ -74,6 +74,7 @@ static inline void openFile(const QString &fileName)
Window::Window(QWidget *parent)
: QWidget(parent)
{
+ setWindowTitle(tr("Find Files"));
QPushButton *browseButton = new QPushButton(tr("&Browse..."), this);
connect(browseButton, &QAbstractButton::clicked, this, &Window::browse);
findButton = new QPushButton(tr("&Find"), this);
@@ -92,9 +93,7 @@ Window::Window(QWidget *parent)
filesFoundLabel = new QLabel;
createFilesTable();
-//! [0]
-//! [1]
QGridLayout *mainLayout = new QGridLayout(this);
mainLayout->addWidget(new QLabel(tr("Named:")), 0, 0);
mainLayout->addWidget(fileComboBox, 0, 1, 1, 2);
@@ -106,12 +105,13 @@ Window::Window(QWidget *parent)
mainLayout->addWidget(filesTable, 3, 0, 1, 3);
mainLayout->addWidget(filesFoundLabel, 4, 0, 1, 2);
mainLayout->addWidget(findButton, 4, 2);
+//! [0]
- setWindowTitle(tr("Find Files"));
- const QRect screenGeometry = QApplication::desktop()->screenGeometry(this);
- resize(screenGeometry.width() / 2, screenGeometry.height() / 3);
-}
//! [1]
+ connect(new QShortcut(QKeySequence::Quit, this), &QShortcut::activated,
+ qApp, &QApplication::quit);
+//! [1]
+}
//! [2]
void Window::browse()
@@ -133,21 +133,7 @@ static void updateComboBox(QComboBox *comboBox)
comboBox->addItem(comboBox->currentText());
}
-//! [13]
-
-static void findRecursion(const QString &path, const QString &pattern, QStringList *result)
-{
- QDir currentDir(path);
- const QString prefix = path + QLatin1Char('/');
- foreach (const QString &match, currentDir.entryList(QStringList(pattern), QDir::Files | QDir::NoSymLinks))
- result->append(prefix + match);
- foreach (const QString &dir, currentDir.entryList(QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot))
- findRecursion(prefix + dir, pattern, result);
-}
-
-//! [13]
//! [3]
-
void Window::find()
{
filesTable->setRowCount(0);
@@ -155,6 +141,7 @@ void Window::find()
QString fileName = fileComboBox->currentText();
QString text = textComboBox->currentText();
QString path = QDir::cleanPath(directoryComboBox->currentText());
+ currentDir = QDir(path);
//! [3]
updateComboBox(fileComboBox);
@@ -162,12 +149,16 @@ void Window::find()
updateComboBox(directoryComboBox);
//! [4]
-
- currentDir = QDir(path);
+ QStringList filter;
+ if (!fileName.isEmpty())
+ filter << fileName;
+ QDirIterator it(path, filter, QDir::AllEntries | QDir::NoSymLinks | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
QStringList files;
- findRecursion(path, fileName.isEmpty() ? QStringLiteral("*") : fileName, &files);
+ while (it.hasNext())
+ files << it.next();
if (!text.isEmpty())
files = findFiles(files, text);
+ files.sort();
showFiles(files);
}
//! [4]
@@ -225,20 +216,18 @@ QStringList Window::findFiles(const QStringList &files, const QString &text)
//! [7]
//! [8]
-void Window::showFiles(const QStringList &files)
+void Window::showFiles(const QStringList &paths)
{
- for (int i = 0; i < files.size(); ++i) {
- const QString &fileName = files.at(i);
- const QString toolTip = QDir::toNativeSeparators(fileName);
- const QString relativePath = QDir::toNativeSeparators(currentDir.relativeFilePath(fileName));
- const qint64 size = QFileInfo(fileName).size();
+ for (const QString &filePath : paths) {
+ const QString toolTip = QDir::toNativeSeparators(filePath);
+ const QString relativePath = QDir::toNativeSeparators(currentDir.relativeFilePath(filePath));
+ const qint64 size = QFileInfo(filePath).size();
QTableWidgetItem *fileNameItem = new QTableWidgetItem(relativePath);
- fileNameItem->setData(absoluteFileNameRole, QVariant(fileName));
+ fileNameItem->setData(absoluteFileNameRole, QVariant(filePath));
fileNameItem->setToolTip(toolTip);
fileNameItem->setFlags(fileNameItem->flags() ^ Qt::ItemIsEditable);
- QTableWidgetItem *sizeItem = new QTableWidgetItem(tr("%1 KB")
- .arg(int((size + 1023) / 1024)));
- sizeItem->setData(absoluteFileNameRole, QVariant(fileName));
+ QTableWidgetItem *sizeItem = new QTableWidgetItem(QLocale().formattedDataSize(size));
+ sizeItem->setData(absoluteFileNameRole, QVariant(filePath));
sizeItem->setToolTip(toolTip);
sizeItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
sizeItem->setFlags(sizeItem->flags() ^ Qt::ItemIsEditable);
@@ -248,7 +237,7 @@ void Window::showFiles(const QStringList &files)
filesTable->setItem(row, 0, fileNameItem);
filesTable->setItem(row, 1, sizeItem);
}
- filesFoundLabel->setText(tr("%n file(s) found (Double click on a file to open it)", 0, files.size()));
+ filesFoundLabel->setText(tr("%n file(s) found (Double click on a file to open it)", 0, paths.size()));
filesFoundLabel->setWordWrap(true);
}
//! [8]
diff --git a/examples/widgets/dialogs/findfiles/window.h b/examples/widgets/dialogs/findfiles/window.h
index fe217381e2..949df704bb 100644
--- a/examples/widgets/dialogs/findfiles/window.h
+++ b/examples/widgets/dialogs/findfiles/window.h
@@ -79,7 +79,7 @@ private slots:
private:
QStringList findFiles(const QStringList &files, const QString &text);
- void showFiles(const QStringList &files);
+ void showFiles(const QStringList &paths);
QComboBox *createComboBox(const QString &text = QString());
void createFilesTable();