Mercurial > hg > svgui
comparison widgets/InteractiveFileFinder.cpp @ 1417:2487521e857b
Merge
author | Chris Cannam |
---|---|
date | Wed, 23 Jan 2019 14:44:16 +0000 |
parents | c8a6fd3f9dff |
children | 70e93f996da6 |
comparison
equal
deleted
inserted
replaced
1416:d794630429a7 | 1417:2487521e857b |
---|---|
34 InteractiveFileFinder::m_instance; | 34 InteractiveFileFinder::m_instance; |
35 | 35 |
36 InteractiveFileFinder::InteractiveFileFinder() : | 36 InteractiveFileFinder::InteractiveFileFinder() : |
37 m_sessionExtension("sv"), | 37 m_sessionExtension("sv"), |
38 m_lastLocatedLocation(""), | 38 m_lastLocatedLocation(""), |
39 m_parent(0) | 39 m_parent(nullptr) |
40 { | 40 { |
41 FileFinder::registerFileFinder(this); | 41 FileFinder::registerFileFinder(this); |
42 } | 42 } |
43 | 43 |
44 InteractiveFileFinder::~InteractiveFileFinder() | 44 InteractiveFileFinder::~InteractiveFileFinder() |
191 | 191 |
192 QFileInfo fi(path); | 192 QFileInfo fi(path); |
193 | 193 |
194 if (!fi.exists()) { | 194 if (!fi.exists()) { |
195 | 195 |
196 QMessageBox::critical(0, tr("File does not exist"), | 196 QMessageBox::critical(nullptr, tr("File does not exist"), |
197 tr("<b>File not found</b><p>File \"%1\" does not exist").arg(path)); | 197 tr("<b>File not found</b><p>File \"%1\" does not exist").arg(path)); |
198 path = ""; | 198 path = ""; |
199 | 199 |
200 } else if (!fi.isReadable()) { | 200 } else if (!fi.isReadable()) { |
201 | 201 |
202 QMessageBox::critical(0, tr("File is not readable"), | 202 QMessageBox::critical(nullptr, tr("File is not readable"), |
203 tr("<b>File is not readable</b><p>File \"%1\" can not be read").arg(path)); | 203 tr("<b>File is not readable</b><p>File \"%1\" can not be read").arg(path)); |
204 path = ""; | 204 path = ""; |
205 | 205 |
206 } else if (fi.isDir()) { | 206 } else if (fi.isDir()) { |
207 | 207 |
208 QMessageBox::critical(0, tr("Directory selected"), | 208 QMessageBox::critical(nullptr, tr("Directory selected"), |
209 tr("<b>Directory selected</b><p>File \"%1\" is a directory").arg(path)); | 209 tr("<b>Directory selected</b><p>File \"%1\" is a directory").arg(path)); |
210 path = ""; | 210 path = ""; |
211 | 211 |
212 } else if (!fi.isFile()) { | 212 } else if (!fi.isFile()) { |
213 | 213 |
214 QMessageBox::critical(0, tr("Non-file selected"), | 214 QMessageBox::critical(nullptr, tr("Non-file selected"), |
215 tr("<b>Not a file</b><p>Path \"%1\" is not a file").arg(path)); | 215 tr("<b>Not a file</b><p>Path \"%1\" is not a file").arg(path)); |
216 path = ""; | 216 path = ""; |
217 | 217 |
218 } else if (fi.size() == 0) { | 218 } else if (fi.size() == 0) { |
219 | 219 |
220 QMessageBox::critical(0, tr("File is empty"), | 220 QMessageBox::critical(nullptr, tr("File is empty"), |
221 tr("<b>File is empty</b><p>File \"%1\" is empty").arg(path)); | 221 tr("<b>File is empty</b><p>File \"%1\" is empty").arg(path)); |
222 path = ""; | 222 path = ""; |
223 } | 223 } |
224 } | 224 } |
225 | 225 |
403 fi = QFileInfo(path); | 403 fi = QFileInfo(path); |
404 } | 404 } |
405 } | 405 } |
406 | 406 |
407 if (fi.isDir()) { | 407 if (fi.isDir()) { |
408 QMessageBox::critical(0, tr("Directory selected"), | 408 QMessageBox::critical(nullptr, tr("Directory selected"), |
409 tr("<b>Directory selected</b><p>File \"%1\" is a directory").arg(path)); | 409 tr("<b>Directory selected</b><p>File \"%1\" is a directory").arg(path)); |
410 continue; | 410 continue; |
411 } | 411 } |
412 | 412 |
413 if (fi.exists()) { | 413 if (fi.exists()) { |
414 if (QMessageBox::question(0, tr("File exists"), | 414 if (QMessageBox::question(nullptr, tr("File exists"), |
415 tr("<b>File exists</b><p>The file \"%1\" already exists.\nDo you want to overwrite it?").arg(path), | 415 tr("<b>File exists</b><p>The file \"%1\" already exists.\nDo you want to overwrite it?").arg(path), |
416 QMessageBox::Ok, | 416 QMessageBox::Ok, |
417 QMessageBox::Cancel) != QMessageBox::Ok) { | 417 QMessageBox::Cancel) != QMessageBox::Ok) { |
418 continue; | 418 continue; |
419 } | 419 } |
573 bool done = false; | 573 bool done = false; |
574 | 574 |
575 while (!done) { | 575 while (!done) { |
576 | 576 |
577 int rv = QMessageBox::question | 577 int rv = QMessageBox::question |
578 (0, | 578 (nullptr, |
579 tr("Failed to open file"), | 579 tr("Failed to open file"), |
580 question.arg(thing), | 580 question.arg(thing), |
581 tr("Locate file..."), | 581 tr("Locate file..."), |
582 tr("Use URL..."), | 582 tr("Use URL..."), |
583 tr("Cancel"), | 583 tr("Cancel"), |
597 | 597 |
598 case 1: // Use URL | 598 case 1: // Use URL |
599 { | 599 { |
600 bool ok = false; | 600 bool ok = false; |
601 path = QInputDialog::getText | 601 path = QInputDialog::getText |
602 (0, tr("Use URL"), | 602 (nullptr, tr("Use URL"), |
603 tr("Please enter the URL to use for this file:"), | 603 tr("Please enter the URL to use for this file:"), |
604 QLineEdit::Normal, "", &ok); | 604 QLineEdit::Normal, "", &ok); |
605 | 605 |
606 if (ok && path != "") { | 606 if (ok && path != "") { |
607 if (FileSource(path).isAvailable()) { | 607 if (FileSource(path).isAvailable()) { |
608 done = true; | 608 done = true; |
609 } else { | 609 } else { |
610 QMessageBox::critical | 610 QMessageBox::critical |
611 (0, tr("Failed to open location"), | 611 (nullptr, tr("Failed to open location"), |
612 tr("<b>Failed to open location</b><p>URL \"%1\" could not be opened").arg(path)); | 612 tr("<b>Failed to open location</b><p>URL \"%1\" could not be opened").arg(path)); |
613 path = ""; | 613 path = ""; |
614 } | 614 } |
615 } | 615 } |
616 break; | 616 break; |