[calligra] libs/widgets: Finish the file dialog tester applet
Boudewijn Rempt
boud at valdyas.org
Wed May 21 09:23:57 BST 2014
Git commit e1435c52f3cae09b0bb55affa8c468fce907cf01 by Boudewijn Rempt.
Committed on 21/05/2014 at 08:19.
Pushed by rempt into branch 'master'.
Finish the file dialog tester applet
This allows us to exercise the KoFileDialog abstraction in all
permutations. Use this to check that:
* the filename is returned with the correct extension
* the last visited directory is used when opening the file dialog
* the correct filter is set
It needs to be run on Windows, OSX, Gnome and KDE. On Windows, we use
the static methods to get the native file dialogs, on OSX, we use the
non-static QFileDialog methods to get the native file dialogs.
On X11, we make sure we get the (superior) KDE dialogs when running in
KDE, but elsewhere, we use the native Qt dialog, not the GTK dialog.
CCMAIL:calligra-devel at kde.org
M +12 -1 libs/widgets/CMakeLists.txt
A +588 -0 libs/widgets/KoFileDialogTester.cpp [License: LGPL (v2+)]
A +53 -0 libs/widgets/KoFileDialogTester.h [License: LGPL (v2+)]
R +158 -51 libs/widgets/KoFileDialogTester.ui [from: libs/widgets/tests/filedialogtester/KoFileDialogTester.ui - 050% similarity]
R +0 -0 libs/widgets/main.cpp [from: libs/widgets/tests/filedialogtester/main.cpp - 100% similarity]
D +0 -15 libs/widgets/tests/filedialogtester/CMakeLists.txt
D +0 -66 libs/widgets/tests/filedialogtester/KoFileDialogTester.cpp
D +0 -35 libs/widgets/tests/filedialogtester/KoFileDialogTester.h
http://commits.kde.org/calligra/e1435c52f3cae09b0bb55affa8c468fce907cf01
diff --git a/libs/widgets/CMakeLists.txt b/libs/widgets/CMakeLists.txt
index b824a62..7d4b5c5 100644
--- a/libs/widgets/CMakeLists.txt
+++ b/libs/widgets/CMakeLists.txt
@@ -67,7 +67,7 @@ set(kowidgets_LIB_SRCS
KoViewItemContextBar.cpp
KoContextBarButton.cpp
KoResourceFiltering.cpp
-
+
KoResourceModelBase.cpp
)
@@ -142,3 +142,14 @@ install( FILES
DESTINATION
${INCLUDE_INSTALL_DIR}/calligra
COMPONENT Devel)
+
+set(filedialogtester_SRCS
+ KoFileDialogTester.cpp
+ main.cpp
+)
+kde4_add_ui_files(filedialogtester_SRCS
+ KoFileDialogTester.ui
+)
+
+kde4_add_executable(filedialogtester ${filedialogtester_SRCS})
+target_link_libraries(filedialogtester kowidgets)
\ No newline at end of file
diff --git a/libs/widgets/KoFileDialogTester.cpp b/libs/widgets/KoFileDialogTester.cpp
new file mode 100644
index 0000000..3b682bc
--- /dev/null
+++ b/libs/widgets/KoFileDialogTester.cpp
@@ -0,0 +1,588 @@
+/* This file is part of the KDE project
+ * Copyright (C) Boudewijn Rempt <boud at valdyas.org>, (C) 2014
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+#include "KoFileDialogTester.h"
+
+#include "ui_KoFileDialogTester.h"
+
+#include <QDesktopServices>
+#include <QListWidget>
+#include <QCheckBox>
+#include <QRadioButton>
+
+#include <KoFileDialog.h>
+
+KoFileDialogTester::KoFileDialogTester(QWidget *parent) :
+ QWidget(parent),
+ ui(new Ui::KoFileDialogTester)
+{
+ ui->setupUi(this);
+
+ connect(ui->bnOpenFile, SIGNAL(clicked()), SLOT(testOpenFile()));
+ connect(ui->bnOpenFiles, SIGNAL(clicked()), SLOT(testOpenFiles()));
+ connect(ui->bnOpenDirectory, SIGNAL(clicked()), SLOT(testOpenDirectory()));
+ connect(ui->bnOpenDirectories, SIGNAL(clicked()), SLOT(testOpenDirectories()));
+ connect(ui->bnImportFile, SIGNAL(clicked()), SLOT(testImportFile()));
+ connect(ui->bnImportFiles, SIGNAL(clicked()), SLOT(testImportFiles()));
+ connect(ui->bnImportDirectory, SIGNAL(clicked()), SLOT(testImportDirectory()));
+ connect(ui->bnImportDirectories, SIGNAL(clicked()), SLOT(testImportDirectories()));
+ connect(ui->bnSaveFile, SIGNAL(clicked()), SLOT(testSaveFile()));
+ connect(ui->bnSaveFiles, SIGNAL(clicked()), SLOT(testSaveFiles()));
+}
+
+KoFileDialogTester::~KoFileDialogTester()
+{
+ delete ui;
+}
+
+
+
+void KoFileDialogTester::testOpenFile()
+{
+ ui->listResults->clear();
+ KoFileDialog dlg(this, KoFileDialog::OpenFile, ui->txtUniqueKey->text());
+ dlg.setCaption(i18n("Testing: OpenFile"));
+ dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation));
+ if (ui->radioName->isChecked()) {
+
+ QStringList nameFilters;
+ nameFilters << "Documents (*.odt *doc *.txt)"
+ << "Images (*.png *jpg)"
+ << "Presentations (*.ppt *.odp)"
+ ;
+
+ if (ui->chkSetDefaultFilter->isChecked()) {
+ dlg.setNameFilters(nameFilters, nameFilters.last());
+ }
+ else {
+ dlg.setNameFilters(nameFilters);
+ }
+ }
+ else {
+ QStringList mimeFilter = QStringList()
+ << "application/x-krita" << "image/x-exr" << "image/openraster" << "image/x-tga" << "image/vnd.adobe.photoshop"
+ << "image/x-xcf" << "image/x-portable-pixmap" << "image/x-portable-graymap"
+ << "image/x-portable-bitmap" << "image/png" << "image/jp2"
+ << "image/tiff" << "application/vnd.oasis.opendocument.graphics"
+ << "application/pdf" << "image/jpeg" << "image/bmp" << "image/x-xpixmap"
+ << "image/gif" << "image/x-xbitmap" << "application/x-krita-flipbook"
+ << "image/x-adobe-dng" << "image/x-xfig" << "image/svg+xml" << "image/svg+xml-compressed"
+ << "image/x-eps" << "image/eps" << "application/eps" << "application/x-eps" << "application/postscript"
+ << "image/x-wmf" << "application/x-karbon";
+
+ if (ui->chkSetDefaultFilter->isChecked()) {
+ dlg.setMimeTypeFilters(mimeFilter, mimeFilter[4]);
+ }
+ else {
+ dlg.setMimeTypeFilters(mimeFilter);
+ }
+
+ }
+
+ if (ui->chkHideNameFilterDetailsOption->isChecked()) {
+ dlg.setHideNameFilterDetailsOption();
+ }
+
+ QString url = dlg.url();
+ ui->listResults->addItem(url);
+
+ ui->txtFilter->setText(dlg.selectedNameFilter());
+
+}
+
+void KoFileDialogTester::testOpenFiles()
+{
+ ui->listResults->clear();
+ KoFileDialog dlg(this, KoFileDialog::OpenFiles, ui->txtUniqueKey->text());
+ dlg.setCaption(i18n("Testing: OpenFile"));
+ dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation));
+ if (ui->radioName->isChecked()) {
+
+ QStringList nameFilters;
+ nameFilters << "Documents (*.odt *doc *.txt)"
+ << "Images (*.png *jpg)"
+ << "Presentations (*.ppt *.odp)"
+ ;
+
+ if (ui->chkSetDefaultFilter->isChecked()) {
+ dlg.setNameFilters(nameFilters, nameFilters.last());
+ }
+ else {
+ dlg.setNameFilters(nameFilters);
+ }
+
+ }
+ else {
+ QStringList mimeFilter = QStringList()
+ << "application/x-krita" << "image/x-exr" << "image/openraster" << "image/x-tga" << "image/vnd.adobe.photoshop"
+ << "image/x-xcf" << "image/x-portable-pixmap" << "image/x-portable-graymap"
+ << "image/x-portable-bitmap" << "image/png" << "image/jp2"
+ << "image/tiff" << "application/vnd.oasis.opendocument.graphics"
+ << "application/pdf" << "image/jpeg" << "image/bmp" << "image/x-xpixmap"
+ << "image/gif" << "image/x-xbitmap" << "application/x-krita-flipbook"
+ << "image/x-adobe-dng" << "image/x-xfig" << "image/svg+xml" << "image/svg+xml-compressed"
+ << "image/x-eps" << "image/eps" << "application/eps" << "application/x-eps" << "application/postscript"
+ << "image/x-wmf" << "application/x-karbon";
+
+ if (ui->chkSetDefaultFilter->isChecked()) {
+ dlg.setMimeTypeFilters(mimeFilter, mimeFilter[4]);
+ }
+ else {
+ dlg.setMimeTypeFilters(mimeFilter);
+ }
+
+ }
+
+ if (ui->chkHideNameFilterDetailsOption->isChecked()) {
+ dlg.setHideNameFilterDetailsOption();
+ }
+
+ QStringList urls = dlg.urls();
+ foreach(const QString &url, urls) {
+ ui->listResults->addItem(url);
+ }
+
+ ui->txtFilter->setText(dlg.selectedNameFilter());
+}
+
+void KoFileDialogTester::testOpenDirectory()
+{
+ ui->listResults->clear();
+ KoFileDialog dlg(this, KoFileDialog::OpenDirectory, ui->txtUniqueKey->text());
+ dlg.setCaption(i18n("Testing: OpenDirectory"));
+ dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation));
+ if (ui->radioName->isChecked()) {
+
+ QStringList nameFilters;
+ nameFilters << "Documents (*.odt *doc *.txt)"
+ << "Images (*.png *jpg)"
+ << "Presentations (*.ppt *.odp)"
+ ;
+
+ if (ui->chkSetDefaultFilter->isChecked()) {
+ dlg.setNameFilters(nameFilters, nameFilters.last());
+ }
+ else {
+ dlg.setNameFilters(nameFilters);
+ }
+
+ }
+ else {
+ QStringList mimeFilter = QStringList()
+ << "application/x-krita" << "image/x-exr" << "image/openraster" << "image/x-tga" << "image/vnd.adobe.photoshop"
+ << "image/x-xcf" << "image/x-portable-pixmap" << "image/x-portable-graymap"
+ << "image/x-portable-bitmap" << "image/png" << "image/jp2"
+ << "image/tiff" << "application/vnd.oasis.opendocument.graphics"
+ << "application/pdf" << "image/jpeg" << "image/bmp" << "image/x-xpixmap"
+ << "image/gif" << "image/x-xbitmap" << "application/x-krita-flipbook"
+ << "image/x-adobe-dng" << "image/x-xfig" << "image/svg+xml" << "image/svg+xml-compressed"
+ << "image/x-eps" << "image/eps" << "application/eps" << "application/x-eps" << "application/postscript"
+ << "image/x-wmf" << "application/x-karbon";
+
+ if (ui->chkSetDefaultFilter->isChecked()) {
+ dlg.setMimeTypeFilters(mimeFilter, mimeFilter[4]);
+ }
+ else {
+ dlg.setMimeTypeFilters(mimeFilter);
+ }
+
+ }
+
+ if (ui->chkHideNameFilterDetailsOption->isChecked()) {
+ dlg.setHideNameFilterDetailsOption();
+ }
+
+ QString url = dlg.url();
+ ui->listResults->addItem(url);
+
+ ui->txtFilter->setText(dlg.selectedNameFilter());
+}
+
+void KoFileDialogTester::testOpenDirectories()
+{
+ ui->listResults->clear();
+ KoFileDialog dlg(this, KoFileDialog::OpenDirectories, ui->txtUniqueKey->text());
+ dlg.setCaption(i18n("Testing: OpenDirectories"));
+ dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation));
+ if (ui->radioName->isChecked()) {
+
+ QStringList nameFilters;
+ nameFilters << "Documents (*.odt *doc *.txt)"
+ << "Images (*.png *jpg)"
+ << "Presentations (*.ppt *.odp)"
+ ;
+ if (ui->chkSetDefaultFilter->isChecked()) {
+ dlg.setNameFilters(nameFilters, nameFilters.last());
+ }
+ else {
+ dlg.setNameFilters(nameFilters);
+ }
+
+ }
+ else {
+ QStringList mimeFilter = QStringList()
+ << "application/x-krita" << "image/x-exr" << "image/openraster" << "image/x-tga" << "image/vnd.adobe.photoshop"
+ << "image/x-xcf" << "image/x-portable-pixmap" << "image/x-portable-graymap"
+ << "image/x-portable-bitmap" << "image/png" << "image/jp2"
+ << "image/tiff" << "application/vnd.oasis.opendocument.graphics"
+ << "application/pdf" << "image/jpeg" << "image/bmp" << "image/x-xpixmap"
+ << "image/gif" << "image/x-xbitmap" << "application/x-krita-flipbook"
+ << "image/x-adobe-dng" << "image/x-xfig" << "image/svg+xml" << "image/svg+xml-compressed"
+ << "image/x-eps" << "image/eps" << "application/eps" << "application/x-eps" << "application/postscript"
+ << "image/x-wmf" << "application/x-karbon";
+
+ if (ui->chkSetDefaultFilter->isChecked()) {
+ dlg.setMimeTypeFilters(mimeFilter, mimeFilter[4]);
+ }
+ else {
+ dlg.setMimeTypeFilters(mimeFilter);
+ }
+
+ }
+
+ if (ui->chkHideNameFilterDetailsOption->isChecked()) {
+ dlg.setHideNameFilterDetailsOption();
+ }
+
+ QStringList urls = dlg.urls(); foreach(const QString &url, urls) {
+ ui->listResults->addItem(url);
+ }
+
+ ui->txtFilter->setText(dlg.selectedNameFilter());
+}
+
+void KoFileDialogTester::testImportFile()
+{
+ ui->listResults->clear();
+
+ KoFileDialog dlg(this, KoFileDialog::ImportFile, ui->txtUniqueKey->text());
+ dlg.setCaption(i18n("Testing: ImportFile"));
+ dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation));
+ if (ui->radioName->isChecked()) {
+
+ QStringList nameFilters;
+ nameFilters << "Documents (*.odt *doc *.txt)"
+ << "Images (*.png *jpg)"
+ << "Presentations (*.ppt *.odp)"
+ ;
+
+ if (ui->chkSetDefaultFilter->isChecked()) {
+ dlg.setNameFilters(nameFilters, nameFilters.last());
+ }
+ else {
+ dlg.setNameFilters(nameFilters);
+ }
+
+ }
+ else {
+ QStringList mimeFilter = QStringList()
+ << "application/x-krita" << "image/x-exr" << "image/openraster" << "image/x-tga" << "image/vnd.adobe.photoshop"
+ << "image/x-xcf" << "image/x-portable-pixmap" << "image/x-portable-graymap"
+ << "image/x-portable-bitmap" << "image/png" << "image/jp2"
+ << "image/tiff" << "application/vnd.oasis.opendocument.graphics"
+ << "application/pdf" << "image/jpeg" << "image/bmp" << "image/x-xpixmap"
+ << "image/gif" << "image/x-xbitmap" << "application/x-krita-flipbook"
+ << "image/x-adobe-dng" << "image/x-xfig" << "image/svg+xml" << "image/svg+xml-compressed"
+ << "image/x-eps" << "image/eps" << "application/eps" << "application/x-eps" << "application/postscript"
+ << "image/x-wmf" << "application/x-karbon";
+
+ if (ui->chkSetDefaultFilter->isChecked()) {
+ dlg.setMimeTypeFilters(mimeFilter, mimeFilter[4]);
+ }
+ else {
+ dlg.setMimeTypeFilters(mimeFilter);
+ }
+
+ }
+
+ if (ui->chkHideNameFilterDetailsOption->isChecked()) {
+ dlg.setHideNameFilterDetailsOption();
+ }
+
+ QString url = dlg.url();
+ ui->listResults->addItem(url);
+
+ ui->txtFilter->setText(dlg.selectedNameFilter());
+}
+
+void KoFileDialogTester::testImportFiles()
+{
+ ui->listResults->clear();
+ KoFileDialog dlg(this, KoFileDialog::ImportFiles, ui->txtUniqueKey->text());
+ dlg.setCaption(i18n("Testing: ImportFiles"));
+ dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation));
+ if (ui->radioName->isChecked()) {
+
+ QStringList nameFilters;
+ nameFilters << "Documents (*.odt *doc *.txt)"
+ << "Images (*.png *jpg)"
+ << "Presentations (*.ppt *.odp)"
+ ;
+ if (ui->chkSetDefaultFilter->isChecked()) {
+ dlg.setNameFilters(nameFilters, nameFilters.last());
+ }
+ else {
+ dlg.setNameFilters(nameFilters);
+ }
+
+ }
+ else {
+ QStringList mimeFilter = QStringList()
+ << "application/x-krita" << "image/x-exr" << "image/openraster" << "image/x-tga" << "image/vnd.adobe.photoshop"
+ << "image/x-xcf" << "image/x-portable-pixmap" << "image/x-portable-graymap"
+ << "image/x-portable-bitmap" << "image/png" << "image/jp2"
+ << "image/tiff" << "application/vnd.oasis.opendocument.graphics"
+ << "application/pdf" << "image/jpeg" << "image/bmp" << "image/x-xpixmap"
+ << "image/gif" << "image/x-xbitmap" << "application/x-krita-flipbook"
+ << "image/x-adobe-dng" << "image/x-xfig" << "image/svg+xml" << "image/svg+xml-compressed"
+ << "image/x-eps" << "image/eps" << "application/eps" << "application/x-eps" << "application/postscript"
+ << "image/x-wmf" << "application/x-karbon";
+
+ if (ui->chkSetDefaultFilter->isChecked()) {
+ dlg.setMimeTypeFilters(mimeFilter, mimeFilter[4]);
+ }
+ else {
+ dlg.setMimeTypeFilters(mimeFilter);
+ }
+
+ }
+
+ if (ui->chkHideNameFilterDetailsOption->isChecked()) {
+ dlg.setHideNameFilterDetailsOption();
+ }
+
+ QStringList urls = dlg.urls(); foreach(const QString &url, urls) {
+ ui->listResults->addItem(url);
+ }
+
+ ui->txtFilter->setText(dlg.selectedNameFilter());
+}
+
+void KoFileDialogTester::testImportDirectory()
+{
+ ui->listResults->clear();
+ KoFileDialog dlg(this, KoFileDialog::ImportDirectory, ui->txtUniqueKey->text());
+ dlg.setCaption(i18n("Testing: Import Directory"));
+ dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation));
+ if (ui->radioName->isChecked()) {
+
+ QStringList nameFilters;
+ nameFilters << "Documents (*.odt *doc *.txt)"
+ << "Images (*.png *jpg)"
+ << "Presentations (*.ppt *.odp)"
+ ;
+
+ if (ui->chkSetDefaultFilter->isChecked()) {
+ dlg.setNameFilters(nameFilters, nameFilters.last());
+ }
+ else {
+ dlg.setNameFilters(nameFilters);
+ }
+
+ }
+ else {
+ QStringList mimeFilter = QStringList()
+ << "application/x-krita" << "image/x-exr" << "image/openraster" << "image/x-tga" << "image/vnd.adobe.photoshop"
+ << "image/x-xcf" << "image/x-portable-pixmap" << "image/x-portable-graymap"
+ << "image/x-portable-bitmap" << "image/png" << "image/jp2"
+ << "image/tiff" << "application/vnd.oasis.opendocument.graphics"
+ << "application/pdf" << "image/jpeg" << "image/bmp" << "image/x-xpixmap"
+ << "image/gif" << "image/x-xbitmap" << "application/x-krita-flipbook"
+ << "image/x-adobe-dng" << "image/x-xfig" << "image/svg+xml" << "image/svg+xml-compressed"
+ << "image/x-eps" << "image/eps" << "application/eps" << "application/x-eps" << "application/postscript"
+ << "image/x-wmf" << "application/x-karbon";
+
+ if (ui->chkSetDefaultFilter->isChecked()) {
+ dlg.setMimeTypeFilters(mimeFilter, mimeFilter[4]);
+ }
+ else {
+ dlg.setMimeTypeFilters(mimeFilter);
+ }
+
+ }
+
+ if (ui->chkHideNameFilterDetailsOption->isChecked()) {
+ dlg.setHideNameFilterDetailsOption();
+ }
+
+ QString url = dlg.url();
+ ui->listResults->addItem(url);
+
+ ui->txtFilter->setText(dlg.selectedNameFilter());
+}
+
+void KoFileDialogTester::testImportDirectories()
+{
+ ui->listResults->clear();
+ KoFileDialog dlg(this, KoFileDialog::ImportDirectories, ui->txtUniqueKey->text());
+ dlg.setCaption(i18n("Testing: ImportDirectories"));
+ dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation));
+ if (ui->radioName->isChecked()) {
+
+ QStringList nameFilters;
+ nameFilters << "Documents (*.odt *doc *.txt)"
+ << "Images (*.png *jpg)"
+ << "Presentations (*.ppt *.odp)"
+ ;
+
+ if (ui->chkSetDefaultFilter->isChecked()) {
+ dlg.setNameFilters(nameFilters, nameFilters.last());
+ }
+ else {
+ dlg.setNameFilters(nameFilters);
+ }
+
+ }
+ else {
+ QStringList mimeFilter = QStringList()
+ << "application/x-krita" << "image/x-exr" << "image/openraster" << "image/x-tga" << "image/vnd.adobe.photoshop"
+ << "image/x-xcf" << "image/x-portable-pixmap" << "image/x-portable-graymap"
+ << "image/x-portable-bitmap" << "image/png" << "image/jp2"
+ << "image/tiff" << "application/vnd.oasis.opendocument.graphics"
+ << "application/pdf" << "image/jpeg" << "image/bmp" << "image/x-xpixmap"
+ << "image/gif" << "image/x-xbitmap" << "application/x-krita-flipbook"
+ << "image/x-adobe-dng" << "image/x-xfig" << "image/svg+xml" << "image/svg+xml-compressed"
+ << "image/x-eps" << "image/eps" << "application/eps" << "application/x-eps" << "application/postscript"
+ << "image/x-wmf" << "application/x-karbon";
+
+ if (ui->chkSetDefaultFilter->isChecked()) {
+ dlg.setMimeTypeFilters(mimeFilter, mimeFilter[4]);
+ }
+ else {
+ dlg.setMimeTypeFilters(mimeFilter);
+ }
+
+ }
+
+ if (ui->chkHideNameFilterDetailsOption->isChecked()) {
+ dlg.setHideNameFilterDetailsOption();
+ }
+
+ QString url = dlg.url();
+ ui->listResults->addItem(url);
+
+ ui->txtFilter->setText(dlg.selectedNameFilter());
+}
+
+void KoFileDialogTester::testSaveFile()
+{
+ ui->listResults->clear();
+
+ KoFileDialog dlg(this, KoFileDialog::SaveFile, ui->txtUniqueKey->text());
+ dlg.setCaption(i18n("Testing: SaveFile"));
+ dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation));
+ if (ui->radioName->isChecked()) {
+
+ QStringList nameFilters;
+ nameFilters << "Documents (*.odt *doc *.txt)"
+ << "Images (*.png *jpg)"
+ << "Presentations (*.ppt *.odp)"
+ ;
+
+ if (ui->chkSetDefaultFilter->isChecked()) {
+ dlg.setNameFilters(nameFilters, nameFilters.last());
+ }
+ else {
+ dlg.setNameFilters(nameFilters);
+ }
+
+ }
+ else {
+ QStringList mimeFilter = QStringList()
+ << "application/x-krita" << "image/x-exr" << "image/openraster" << "image/x-tga" << "image/vnd.adobe.photoshop"
+ << "image/x-xcf" << "image/x-portable-pixmap" << "image/x-portable-graymap"
+ << "image/x-portable-bitmap" << "image/png" << "image/jp2"
+ << "image/tiff" << "application/vnd.oasis.opendocument.graphics"
+ << "application/pdf" << "image/jpeg" << "image/bmp" << "image/x-xpixmap"
+ << "image/gif" << "image/x-xbitmap" << "application/x-krita-flipbook"
+ << "image/x-adobe-dng" << "image/x-xfig" << "image/svg+xml" << "image/svg+xml-compressed"
+ << "image/x-eps" << "image/eps" << "application/eps" << "application/x-eps" << "application/postscript"
+ << "image/x-wmf" << "application/x-karbon";
+
+ if (ui->chkSetDefaultFilter->isChecked()) {
+ dlg.setMimeTypeFilters(mimeFilter, mimeFilter[4]);
+ }
+ else {
+ dlg.setMimeTypeFilters(mimeFilter);
+ }
+
+ }
+
+ if (ui->chkHideNameFilterDetailsOption->isChecked()) {
+ dlg.setHideNameFilterDetailsOption();
+ }
+
+ QString url = dlg.url();
+ ui->listResults->addItem(url);
+
+ ui->txtFilter->setText(dlg.selectedNameFilter());
+}
+
+void KoFileDialogTester::testSaveFiles()
+{
+ ui->listResults->clear();
+
+ KoFileDialog dlg(this, KoFileDialog::SaveFiles, ui->txtUniqueKey->text());
+ dlg.setCaption(i18n("Testing: SaveFiles"));
+ dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation));
+ if (ui->radioName->isChecked()) {
+
+ QStringList nameFilters;
+ nameFilters << "Documents (*.odt *doc *.txt)"
+ << "Images (*.png *jpg)"
+ << "Presentations (*.ppt *.odp)"
+ ;
+
+ if (ui->chkSetDefaultFilter->isChecked()) {
+ dlg.setNameFilters(nameFilters, nameFilters.last());
+ }
+ else {
+ dlg.setNameFilters(nameFilters);
+ }
+
+ }
+ else {
+ QStringList mimeFilter = QStringList()
+ << "application/x-krita" << "image/x-exr" << "image/openraster" << "image/x-tga" << "image/vnd.adobe.photoshop"
+ << "image/x-xcf" << "image/x-portable-pixmap" << "image/x-portable-graymap"
+ << "image/x-portable-bitmap" << "image/png" << "image/jp2"
+ << "image/tiff" << "application/vnd.oasis.opendocument.graphics"
+ << "application/pdf" << "image/jpeg" << "image/bmp" << "image/x-xpixmap"
+ << "image/gif" << "image/x-xbitmap" << "application/x-krita-flipbook"
+ << "image/x-adobe-dng" << "image/x-xfig" << "image/svg+xml" << "image/svg+xml-compressed"
+ << "image/x-eps" << "image/eps" << "application/eps" << "application/x-eps" << "application/postscript"
+ << "image/x-wmf" << "application/x-karbon";
+
+ if (ui->chkSetDefaultFilter->isChecked()) {
+ dlg.setMimeTypeFilters(mimeFilter, mimeFilter[4]);
+ }
+ else {
+ dlg.setMimeTypeFilters(mimeFilter);
+ }
+ }
+
+ if (ui->chkHideNameFilterDetailsOption->isChecked()) {
+ dlg.setHideNameFilterDetailsOption();
+ }
+
+ QString url = dlg.url();
+ ui->listResults->addItem(url);
+
+ ui->txtFilter->setText(dlg.selectedNameFilter());
+
+}
diff --git a/libs/widgets/KoFileDialogTester.h b/libs/widgets/KoFileDialogTester.h
new file mode 100644
index 0000000..6071e76
--- /dev/null
+++ b/libs/widgets/KoFileDialogTester.h
@@ -0,0 +1,53 @@
+/* This file is part of the KDE project
+ * Copyright (C) Boudewijn Rempt <boud at valdyas.org>, (C) 2014
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+#ifndef KOFILEDIALOGTESTER_H
+#define KOFILEDIALOGTESTER_H
+
+#include <QWidget>
+
+namespace Ui {
+class KoFileDialogTester;
+}
+
+class KoFileDialogTester : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit KoFileDialogTester(QWidget *parent = 0);
+ ~KoFileDialogTester();
+
+private slots:
+
+ void testOpenFile();
+ void testOpenFiles();
+ void testOpenDirectory();
+ void testOpenDirectories();
+ void testImportFile();
+ void testImportFiles();
+ void testImportDirectory();
+ void testImportDirectories();
+ void testSaveFile();
+ void testSaveFiles();
+
+private:
+ Ui::KoFileDialogTester *ui;
+};
+
+#endif // KOFILEDIALOGTESTER_H
diff --git a/libs/widgets/tests/filedialogtester/KoFileDialogTester.ui b/libs/widgets/KoFileDialogTester.ui
similarity index 50%
rename from libs/widgets/tests/filedialogtester/KoFileDialogTester.ui
rename to libs/widgets/KoFileDialogTester.ui
index 4579ff7..01afd2e 100644
--- a/libs/widgets/tests/filedialogtester/KoFileDialogTester.ui
+++ b/libs/widgets/KoFileDialogTester.ui
@@ -6,34 +6,139 @@
<rect>
<x>0</x>
<y>0</y>
- <width>694</width>
- <height>501</height>
+ <width>332</width>
+ <height>282</height>
</rect>
</property>
<property name="windowTitle">
<string>KoFileDialogTester</string>
</property>
<layout class="QGridLayout" name="gridLayout">
- <item row="8" column="0">
- <widget class="QPushButton" name="bnImportDirectories">
+ <item row="0" column="0">
+ <widget class="QPushButton" name="bnOpenFile">
<property name="text">
- <string>Import Directories</string>
+ <string>Open File</string>
</property>
</widget>
</item>
- <item row="4" column="0">
+ <item row="0" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Unique key:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="txtUniqueKey">
+ <property name="text">
+ <string>blablabla</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="0">
+ <widget class="QPushButton" name="bnOpenFiles">
+ <property name="text">
+ <string>Open Files</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" rowspan="4">
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string>Filter Type</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QRadioButton" name="radioMime">
+ <property name="text">
+ <string>Mime</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="radioName">
+ <property name="text">
+ <string>Named</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="chkHideNameFilterDetailsOption">
+ <property name="text">
+ <string>hide name filter details option</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="chkSetDefaultFilter">
+ <property name="text">
+ <string>Set default filter</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="2" column="0">
+ <widget class="QPushButton" name="bnOpenDirectory">
+ <property name="text">
+ <string>Open Directory</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
<widget class="QPushButton" name="bnOpenDirectories">
<property name="text">
<string>Open Directories</string>
</property>
</widget>
</item>
- <item row="11" column="0">
+ <item row="4" column="0">
+ <widget class="QPushButton" name="bnImportFile">
+ <property name="text">
+ <string>Import File</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0">
+ <widget class="QPushButton" name="bnImportFiles">
+ <property name="text">
+ <string>Import Files</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="text">
- <string>Output:</string>
+ <string>Filter:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
@@ -41,9 +146,9 @@
</widget>
</item>
<item>
- <widget class="QLabel" name="txtResult">
+ <widget class="QLabel" name="txtFilter">
<property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -58,83 +163,85 @@
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
- <bool>true</bool>
+ <bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
- <item row="5" column="0">
- <widget class="QPushButton" name="bnImportFile">
- <property name="text">
- <string>Import File</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QPushButton" name="bnOpenFile">
- <property name="text">
- <string>Open File</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QPushButton" name="bnOpenFiles">
+ <item row="6" column="0">
+ <widget class="QPushButton" name="bnImportDirectory">
<property name="text">
- <string>Open Files</string>
+ <string>Import Directory</string>
</property>
</widget>
</item>
- <item row="0" column="0">
- <layout class="QHBoxLayout" name="horizontalLayout">
+ <item row="6" column="1" rowspan="4">
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
- <widget class="QLabel" name="label">
+ <widget class="QLabel" name="label_3">
<property name="text">
- <string>Unique key (should make the file dialog remember the last location):</string>
+ <string>Results:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item>
- <widget class="QLineEdit" name="txtUniqueKey"/>
+ <widget class="QListWidget" name="listResults"/>
</item>
</layout>
</item>
- <item row="3" column="0">
- <widget class="QPushButton" name="bnOpenDirectory">
- <property name="text">
- <string>Open Directory</string>
- </property>
- </widget>
- </item>
- <item row="6" column="0">
- <widget class="QPushButton" name="bnImportFiles">
- <property name="text">
- <string>Import Files</string>
- </property>
- </widget>
- </item>
<item row="7" column="0">
- <widget class="QPushButton" name="bnImportDirectory">
+ <widget class="QPushButton" name="bnImportDirectories">
<property name="text">
- <string>Import Directory</string>
+ <string>Import Directories</string>
</property>
</widget>
</item>
- <item row="9" column="0">
+ <item row="8" column="0">
<widget class="QPushButton" name="bnSaveFile">
<property name="text">
<string>Save File</string>
</property>
</widget>
</item>
- <item row="10" column="0">
+ <item row="9" column="0">
<widget class="QPushButton" name="bnSaveFiles">
<property name="text">
<string>Save Files</string>
</property>
</widget>
</item>
+ <item row="10" column="1">
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
</layout>
+ <zorder>bnImportDirectories</zorder>
+ <zorder>bnOpenDirectories</zorder>
+ <zorder>bnImportFile</zorder>
+ <zorder>bnOpenFile</zorder>
+ <zorder>bnOpenFiles</zorder>
+ <zorder>bnOpenDirectory</zorder>
+ <zorder>bnImportFiles</zorder>
+ <zorder>bnImportDirectory</zorder>
+ <zorder>bnSaveFile</zorder>
+ <zorder>bnSaveFiles</zorder>
+ <zorder>groupBox</zorder>
+ <zorder>horizontalLayoutWidget</zorder>
+ <zorder>verticalSpacer</zorder>
+ <zorder>horizontalSpacer</zorder>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
diff --git a/libs/widgets/tests/filedialogtester/main.cpp b/libs/widgets/main.cpp
similarity index 100%
rename from libs/widgets/tests/filedialogtester/main.cpp
rename to libs/widgets/main.cpp
diff --git a/libs/widgets/tests/filedialogtester/CMakeLists.txt b/libs/widgets/tests/filedialogtester/CMakeLists.txt
deleted file mode 100644
index d805f58..0000000
--- a/libs/widgets/tests/filedialogtester/CMakeLists.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-include_directories(
- ${KOMAIN_INCLUDES}
-)
-set(filedialogtester_SRCS
- KoFileDialogTester.cpp
- main.cpp
-)
-kde4_add_ui_files(filedialogtester_SRCS
- KoFileDialogTester.ui
-)
-
-kde4_add_executable(filedialogtester ${filedialogtester_SRCS})
-target_link_libraries(filedialogtester kowidgets)
-install(TARGETS filedialogtester ${INSTALL_TARGETS_DEFAULT_ARGS})
-
diff --git a/libs/widgets/tests/filedialogtester/KoFileDialogTester.cpp b/libs/widgets/tests/filedialogtester/KoFileDialogTester.cpp
deleted file mode 100644
index c031741..0000000
--- a/libs/widgets/tests/filedialogtester/KoFileDialogTester.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-#include "KoFileDialogTester.h"
-#include "ui_KoFileDialogTester.h"
-
-KoFileDialogTester::KoFileDialogTester(QWidget *parent) :
- QWidget(parent),
- ui(new Ui::KoFileDialogTester)
-{
- ui->setupUi(this);
-}
-
-KoFileDialogTester::~KoFileDialogTester()
-{
- delete ui;
-}
-
-
-
-void KoFileDialogTester::testOpenFile()
-{
-
-}
-
-void KoFileDialogTester::testOpenFiles()
-{
-
-}
-
-void KoFileDialogTester::testOpenDirectory()
-{
-
-}
-
-void KoFileDialogTester::testOpenDirectories()
-{
-
-}
-
-void KoFileDialogTester::testImportFile()
-{
-
-}
-
-void KoFileDialogTester::testImportFiles()
-{
-
-}
-
-void KoFileDialogTester::testImportDirectory()
-{
-
-}
-
-void KoFileDialogTester::testImportDirectories()
-{
-
-}
-
-void KoFileDialogTester::testSaveFile()
-{
-
-}
-
-void KoFileDialogTester::testSaveFiles()
-{
-
-}
diff --git a/libs/widgets/tests/filedialogtester/KoFileDialogTester.h b/libs/widgets/tests/filedialogtester/KoFileDialogTester.h
deleted file mode 100644
index 4f5bf61..0000000
--- a/libs/widgets/tests/filedialogtester/KoFileDialogTester.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef KOFILEDIALOGTESTER_H
-#define KOFILEDIALOGTESTER_H
-
-#include <QWidget>
-
-namespace Ui {
-class KoFileDialogTester;
-}
-
-class KoFileDialogTester : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit KoFileDialogTester(QWidget *parent = 0);
- ~KoFileDialogTester();
-
-private slots:
-
- void testOpenFile();
- void testOpenFiles();
- void testOpenDirectory();
- void testOpenDirectories();
- void testImportFile();
- void testImportFiles();
- void testImportDirectory();
- void testImportDirectories();
- void testSaveFile();
- void testSaveFiles();
-
-private:
- Ui::KoFileDialogTester *ui;
-};
-
-#endif // KOFILEDIALOGTESTER_H
More information about the calligra-devel
mailing list