| 1481 | } |
| 1482 | |
| 1483 | void |
| 1484 | SequenceFileDialog::openSelectedFiles() |
| 1485 | { |
| 1486 | QString str = _selectionLineEdit->text(); |
| 1487 | |
| 1488 | if (_dialogMode != eFileDialogModeDir) { |
| 1489 | if ( !isDirectory(str) ) { |
| 1490 | if (_dialogMode == eFileDialogModeOpen) { |
| 1491 | std::string pattern = selectedFiles(); |
| 1492 | if ( !pattern.empty() ) { |
| 1493 | teardownPreview(); |
| 1494 | QDialog::accept(); |
| 1495 | } |
| 1496 | } else { |
| 1497 | ///check if str contains already the selected file extension, otherwise append it |
| 1498 | { |
| 1499 | QString ext = _fileExtensionCombo->getCurrentIndexText(); |
| 1500 | if ( ext != QString::fromUtf8("*") ) { |
| 1501 | int lastSepPos = str.lastIndexOf( QLatin1Char('/') ); |
| 1502 | if (lastSepPos == -1) { |
| 1503 | lastSepPos = str.lastIndexOf( QString::fromUtf8("//") ); |
| 1504 | } |
| 1505 | int lastDotPos = str.lastIndexOf( QLatin1Char('.') ); |
| 1506 | if (lastDotPos < lastSepPos) { |
| 1507 | str.append( QLatin1Char('.') + ext); |
| 1508 | _selectionLineEdit->blockSignals(true); |
| 1509 | _selectionLineEdit->setText(str); |
| 1510 | _selectionLineEdit->blockSignals(false); |
| 1511 | } |
| 1512 | } |
| 1513 | } |
| 1514 | |
| 1515 | SequenceParsing::SequenceFromPattern sequence; |
| 1516 | FileSystemModel::filesListFromPattern(str.toStdString(), &sequence); |
| 1517 | if (sequence.size() > 0) { |
| 1518 | QString text; |
| 1519 | if (sequence.size() == 1) { |
| 1520 | std::map<int, std::string> & views = sequence.begin()->second; |
| 1521 | assert( !views.empty() ); |
| 1522 | |
| 1523 | text = tr("The file %1 already exists.\nWould you like to replace it?").arg( QString::fromUtf8( views.begin()->second.c_str() ) ); |
| 1524 | } else { |
| 1525 | text = tr("The sequence %1 already exists.\nWould you like to replace it?").arg(str); |
| 1526 | } |
| 1527 | |
| 1528 | QMessageBox ques(QMessageBox::Question, tr("Existing file"), text, QMessageBox::Yes | QMessageBox::No, |
| 1529 | this, Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint | Qt::WindowStaysOnTopHint); |
| 1530 | Gui::setQMessageBoxAppropriateFont(&ques); |
| 1531 | ques.setDefaultButton(QMessageBox::Yes); |
| 1532 | ques.setWindowFlags(ques.windowFlags() | Qt::WindowStaysOnTopHint); |
| 1533 | QMessageBox::StandardButton ret = QMessageBox::No; |
| 1534 | if ( ques.exec() ) { |
| 1535 | ret = ques.standardButton( ques.clickedButton() ); |
| 1536 | } |
| 1537 | |
| 1538 | |
| 1539 | if (ret != QMessageBox::Yes) { |
| 1540 | return; |
nothing calls this directly
no test coverage detected