Changeset 105 in tspsg-svn for trunk/src/mainwindow.cpp


Ignore:
Timestamp:
Apr 20, 2010, 5:51:04 PM (15 years ago)
Author:
laleppa
Message:

+ Added support for opening the file when it is dragged and dropped on the main TSPSG window.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/mainwindow.cpp

    r104 r105  
    3838        loadLanguage();
    3939        setupUi();
     40        setAcceptDrops(true);
    4041
    4142        initDocStyleSheet();
     
    734735}
    735736
     737void MainWindow::dragEnterEvent(QDragEnterEvent *ev)
     738{
     739        if (ev->mimeData()->hasUrls() && (ev->mimeData()->urls().count() == 1)) {
     740QFileInfo fi(ev->mimeData()->urls().first().toLocalFile());
     741                if ((fi.suffix() == "tspt") || (fi.suffix() == "zkt"))
     742                        ev->acceptProposedAction();
     743        }
     744}
     745
     746void MainWindow::dropEvent(QDropEvent *ev)
     747{
     748        if (maybeSave() && tspmodel->loadTask(ev->mimeData()->urls().first().toLocalFile())) {
     749                setFileName(ev->mimeData()->urls().first().toLocalFile());
     750                tabWidget->setCurrentIndex(0);
     751                setWindowModified(false);
     752                solutionText->clear();
     753                toggleSolutionActions(false);
     754
     755                ev->acceptProposedAction();
     756        }
     757}
     758
    736759bool MainWindow::hasUpdater() const
    737760{
Note: See TracChangeset for help on using the changeset viewer.