Changeset View
Changeset View
Standalone View
Standalone View
libs/widgetutils/tests/KoFileDialogTester.cpp
- This file was moved from libs/widgets/KoFileDialogTester.cpp.
Show All 10 Lines | |||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | * Library General Public License for more details. | 12 | * Library General Public License for more details. | ||
13 | * | 13 | * | ||
14 | * You should have received a copy of the GNU Library General Public License | 14 | * You should have received a copy of the GNU Library General Public License | ||
15 | * along with this library; see the file COPYING.LIB. If not, write to | 15 | * along with this library; see the file COPYING.LIB. If not, write to | ||
16 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | * Boston, MA 02110-1301, USA. | 17 | * Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | #include "KoFileDialogTester.h" | | |||
20 | 19 | | |||
20 | #include "KoFileDialogTester.h" | ||||
21 | #include "ui_KoFileDialogTester.h" | 21 | #include "ui_KoFileDialogTester.h" | ||
22 | 22 | | |||
23 | #include <QApplication> | ||||
23 | #include <QDesktopServices> | 24 | #include <QDesktopServices> | ||
24 | #include <QListWidget> | 25 | #include <QListWidget> | ||
25 | #include <QCheckBox> | 26 | #include <QCheckBox> | ||
26 | #include <QRadioButton> | 27 | #include <QRadioButton> | ||
27 | 28 | | |||
28 | #include <KoFileDialog.h> | 29 | #include <KoFileDialog.h> | ||
29 | 30 | | |||
30 | KoFileDialogTester::KoFileDialogTester(QWidget *parent) : | 31 | KoFileDialogTester::KoFileDialogTester(QWidget *parent) : | ||
Show All 36 Lines | |||||
67 | } | 68 | } | ||
68 | 69 | | |||
69 | 70 | | |||
70 | 71 | | |||
71 | void KoFileDialogTester::testOpenFile() | 72 | void KoFileDialogTester::testOpenFile() | ||
72 | { | 73 | { | ||
73 | ui->listResults->clear(); | 74 | ui->listResults->clear(); | ||
74 | KoFileDialog dlg(this, KoFileDialog::OpenFile, ui->txtUniqueKey->text()); | 75 | KoFileDialog dlg(this, KoFileDialog::OpenFile, ui->txtUniqueKey->text()); | ||
75 | dlg.setCaption(i18n("Testing: OpenFile")); | 76 | dlg.setCaption("Testing: OpenFile"); | ||
76 | dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); | 77 | dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); | ||
77 | if (ui->radioName->isChecked()) { | 78 | if (ui->radioName->isChecked()) { | ||
78 | 79 | | |||
79 | if (ui->chkSetDefaultFilter->isChecked()) { | 80 | if (ui->chkSetDefaultFilter->isChecked()) { | ||
80 | dlg.setNameFilters(m_nameFilters, m_nameFilters.last()); | 81 | dlg.setNameFilters(m_nameFilters, m_nameFilters.last()); | ||
81 | } | 82 | } | ||
82 | else { | 83 | else { | ||
83 | dlg.setNameFilters(m_nameFilters); | 84 | dlg.setNameFilters(m_nameFilters); | ||
Show All 19 Lines | |||||
103 | ui->txtFilter->setText(dlg.selectedNameFilter()); | 104 | ui->txtFilter->setText(dlg.selectedNameFilter()); | ||
104 | 105 | | |||
105 | } | 106 | } | ||
106 | 107 | | |||
107 | void KoFileDialogTester::testOpenFiles() | 108 | void KoFileDialogTester::testOpenFiles() | ||
108 | { | 109 | { | ||
109 | ui->listResults->clear(); | 110 | ui->listResults->clear(); | ||
110 | KoFileDialog dlg(this, KoFileDialog::OpenFiles, ui->txtUniqueKey->text()); | 111 | KoFileDialog dlg(this, KoFileDialog::OpenFiles, ui->txtUniqueKey->text()); | ||
111 | dlg.setCaption(i18n("Testing: OpenFile")); | 112 | dlg.setCaption("Testing: OpenFile"); | ||
112 | dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); | 113 | dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); | ||
113 | if (ui->radioName->isChecked()) { | 114 | if (ui->radioName->isChecked()) { | ||
114 | 115 | | |||
115 | if (ui->chkSetDefaultFilter->isChecked()) { | 116 | if (ui->chkSetDefaultFilter->isChecked()) { | ||
116 | dlg.setNameFilters(m_nameFilters, m_nameFilters.last()); | 117 | dlg.setNameFilters(m_nameFilters, m_nameFilters.last()); | ||
117 | } | 118 | } | ||
118 | else { | 119 | else { | ||
119 | dlg.setNameFilters(m_nameFilters); | 120 | dlg.setNameFilters(m_nameFilters); | ||
Show All 21 Lines | |||||
141 | ui->lblMime->setText(dlg.selectedMimeType()); | 142 | ui->lblMime->setText(dlg.selectedMimeType()); | ||
142 | ui->txtFilter->setText(dlg.selectedNameFilter()); | 143 | ui->txtFilter->setText(dlg.selectedNameFilter()); | ||
143 | } | 144 | } | ||
144 | 145 | | |||
145 | void KoFileDialogTester::testOpenDirectory() | 146 | void KoFileDialogTester::testOpenDirectory() | ||
146 | { | 147 | { | ||
147 | ui->listResults->clear(); | 148 | ui->listResults->clear(); | ||
148 | KoFileDialog dlg(this, KoFileDialog::OpenDirectory, ui->txtUniqueKey->text()); | 149 | KoFileDialog dlg(this, KoFileDialog::OpenDirectory, ui->txtUniqueKey->text()); | ||
149 | dlg.setCaption(i18n("Testing: OpenDirectory")); | 150 | dlg.setCaption("Testing: OpenDirectory"); | ||
150 | dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); | 151 | dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); | ||
151 | if (ui->radioName->isChecked()) { | 152 | if (ui->radioName->isChecked()) { | ||
152 | 153 | | |||
153 | if (ui->chkSetDefaultFilter->isChecked()) { | 154 | if (ui->chkSetDefaultFilter->isChecked()) { | ||
154 | dlg.setNameFilters(m_nameFilters, m_nameFilters.last()); | 155 | dlg.setNameFilters(m_nameFilters, m_nameFilters.last()); | ||
155 | } | 156 | } | ||
156 | else { | 157 | else { | ||
157 | dlg.setNameFilters(m_nameFilters); | 158 | dlg.setNameFilters(m_nameFilters); | ||
Show All 21 Lines | |||||
179 | } | 180 | } | ||
180 | 181 | | |||
181 | 182 | | |||
182 | void KoFileDialogTester::testImportFile() | 183 | void KoFileDialogTester::testImportFile() | ||
183 | { | 184 | { | ||
184 | ui->listResults->clear(); | 185 | ui->listResults->clear(); | ||
185 | 186 | | |||
186 | KoFileDialog dlg(this, KoFileDialog::ImportFile, ui->txtUniqueKey->text()); | 187 | KoFileDialog dlg(this, KoFileDialog::ImportFile, ui->txtUniqueKey->text()); | ||
187 | dlg.setCaption(i18n("Testing: ImportFile")); | 188 | dlg.setCaption("Testing: ImportFile"); | ||
188 | dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); | 189 | dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); | ||
189 | if (ui->radioName->isChecked()) { | 190 | if (ui->radioName->isChecked()) { | ||
190 | 191 | | |||
191 | if (ui->chkSetDefaultFilter->isChecked()) { | 192 | if (ui->chkSetDefaultFilter->isChecked()) { | ||
192 | dlg.setNameFilters(m_nameFilters, m_nameFilters.last()); | 193 | dlg.setNameFilters(m_nameFilters, m_nameFilters.last()); | ||
193 | } | 194 | } | ||
194 | else { | 195 | else { | ||
195 | dlg.setNameFilters(m_nameFilters); | 196 | dlg.setNameFilters(m_nameFilters); | ||
Show All 20 Lines | |||||
216 | ui->lblMime->setText(dlg.selectedMimeType()); | 217 | ui->lblMime->setText(dlg.selectedMimeType()); | ||
217 | ui->txtFilter->setText(dlg.selectedNameFilter()); | 218 | ui->txtFilter->setText(dlg.selectedNameFilter()); | ||
218 | } | 219 | } | ||
219 | 220 | | |||
220 | void KoFileDialogTester::testImportFiles() | 221 | void KoFileDialogTester::testImportFiles() | ||
221 | { | 222 | { | ||
222 | ui->listResults->clear(); | 223 | ui->listResults->clear(); | ||
223 | KoFileDialog dlg(this, KoFileDialog::ImportFiles, ui->txtUniqueKey->text()); | 224 | KoFileDialog dlg(this, KoFileDialog::ImportFiles, ui->txtUniqueKey->text()); | ||
224 | dlg.setCaption(i18n("Testing: ImportFiles")); | 225 | dlg.setCaption("Testing: ImportFiles"); | ||
225 | dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); | 226 | dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); | ||
226 | if (ui->radioName->isChecked()) { | 227 | if (ui->radioName->isChecked()) { | ||
227 | 228 | | |||
228 | if (ui->chkSetDefaultFilter->isChecked()) { | 229 | if (ui->chkSetDefaultFilter->isChecked()) { | ||
229 | dlg.setNameFilters(m_nameFilters, m_nameFilters.last()); | 230 | dlg.setNameFilters(m_nameFilters, m_nameFilters.last()); | ||
230 | } | 231 | } | ||
231 | else { | 232 | else { | ||
232 | dlg.setNameFilters(m_nameFilters); | 233 | dlg.setNameFilters(m_nameFilters); | ||
Show All 21 Lines | |||||
254 | ui->lblMime->setText(dlg.selectedMimeType()); | 255 | ui->lblMime->setText(dlg.selectedMimeType()); | ||
255 | ui->txtFilter->setText(dlg.selectedNameFilter()); | 256 | ui->txtFilter->setText(dlg.selectedNameFilter()); | ||
256 | } | 257 | } | ||
257 | 258 | | |||
258 | void KoFileDialogTester::testImportDirectory() | 259 | void KoFileDialogTester::testImportDirectory() | ||
259 | { | 260 | { | ||
260 | ui->listResults->clear(); | 261 | ui->listResults->clear(); | ||
261 | KoFileDialog dlg(this, KoFileDialog::ImportDirectory, ui->txtUniqueKey->text()); | 262 | KoFileDialog dlg(this, KoFileDialog::ImportDirectory, ui->txtUniqueKey->text()); | ||
262 | dlg.setCaption(i18n("Testing: Import Directory")); | 263 | dlg.setCaption("Testing: Import Directory"); | ||
263 | dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); | 264 | dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); | ||
264 | if (ui->radioName->isChecked()) { | 265 | if (ui->radioName->isChecked()) { | ||
265 | 266 | | |||
266 | if (ui->chkSetDefaultFilter->isChecked()) { | 267 | if (ui->chkSetDefaultFilter->isChecked()) { | ||
267 | dlg.setNameFilters(m_nameFilters, m_nameFilters.last()); | 268 | dlg.setNameFilters(m_nameFilters, m_nameFilters.last()); | ||
268 | } | 269 | } | ||
269 | else { | 270 | else { | ||
270 | dlg.setNameFilters(m_nameFilters); | 271 | dlg.setNameFilters(m_nameFilters); | ||
Show All 20 Lines | |||||
291 | ui->txtFilter->setText(dlg.selectedNameFilter()); | 292 | ui->txtFilter->setText(dlg.selectedNameFilter()); | ||
292 | } | 293 | } | ||
293 | 294 | | |||
294 | void KoFileDialogTester::testSaveFile() | 295 | void KoFileDialogTester::testSaveFile() | ||
295 | { | 296 | { | ||
296 | ui->listResults->clear(); | 297 | ui->listResults->clear(); | ||
297 | 298 | | |||
298 | KoFileDialog dlg(this, KoFileDialog::SaveFile, ui->txtUniqueKey->text()); | 299 | KoFileDialog dlg(this, KoFileDialog::SaveFile, ui->txtUniqueKey->text()); | ||
299 | dlg.setCaption(i18n("Testing: SaveFile")); | 300 | dlg.setCaption("Testing: SaveFile"); | ||
300 | dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); | 301 | dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); | ||
301 | if (ui->radioName->isChecked()) { | 302 | if (ui->radioName->isChecked()) { | ||
302 | if (ui->chkSetDefaultFilter->isChecked()) { | 303 | if (ui->chkSetDefaultFilter->isChecked()) { | ||
303 | dlg.setNameFilters(m_nameFilters, m_nameFilters.last()); | 304 | dlg.setNameFilters(m_nameFilters, m_nameFilters.last()); | ||
304 | } | 305 | } | ||
305 | else { | 306 | else { | ||
306 | dlg.setNameFilters(m_nameFilters); | 307 | dlg.setNameFilters(m_nameFilters); | ||
307 | } | 308 | } | ||
Show All 13 Lines | 321 | if (ui->chkHideNameFilterDetailsOption->isChecked()) { | |||
321 | dlg.setHideNameFilterDetailsOption(); | 322 | dlg.setHideNameFilterDetailsOption(); | ||
322 | } | 323 | } | ||
323 | 324 | | |||
324 | QString url = dlg.filename(); | 325 | QString url = dlg.filename(); | ||
325 | ui->listResults->addItem(url); | 326 | ui->listResults->addItem(url); | ||
326 | ui->lblMime->setText(dlg.selectedMimeType()); | 327 | ui->lblMime->setText(dlg.selectedMimeType()); | ||
327 | ui->txtFilter->setText(dlg.selectedNameFilter()); | 328 | ui->txtFilter->setText(dlg.selectedNameFilter()); | ||
328 | } | 329 | } | ||
330 | | ||||
331 | int main(int argc, char *argv[]) | ||||
332 | { | ||||
333 | QApplication a(argc, argv); | ||||
334 | KoFileDialogTester w; | ||||
335 | w.show(); | ||||
336 | | ||||
337 | return a.exec(); | ||||
338 | } |