diff -r 7c3ee77f4449 -r 53efc2562a7d mainwindow.cpp --- a/mainwindow.cpp Mon Nov 20 12:12:00 2006 +0000 +++ b/mainwindow.cpp Mon Nov 20 12:12:02 2006 +0000 @@ -2,13 +2,7 @@ #include -#include -#include -#include - #include -#include -#include #include "aboutdialog.h" #include "exportoofiledialog.h" @@ -24,7 +18,6 @@ #include "process.h" #include "settings.h" #include "texteditor.h" -#include "version.h" extern TextEditor *textEditor; extern Main *mainWindow; @@ -34,6 +27,9 @@ extern int statusbarTime; extern FlagRowObj* standardFlagsDefault; extern FlagRowObj* systemFlagsDefault; +extern QString vymName; +extern QString vymVersion; +extern QString vymBuildDate; QMenu* branchContextMenu; QMenu* branchAddContextMenu; @@ -94,11 +90,9 @@ procBrowser=NULL; - // FIXME not used currently - // Set random seed (random used for object IDs) - // QTime t = QTime::currentTime(); // set random seed - // srand( t.hour()*12+t.minute()*60+t.second()*60 ); - + // Initialize history window; + historyWindow=new HistoryWindow(); + // FIXME historyWindow.setStepsTotal(stepsTotal); // Initialize some settings, which are platform dependant QString p,s; @@ -178,8 +172,8 @@ settings.setValue ("/mainwindow/state",saveState(0)); - settings.setValue( "/version/version", __VYM_VERSION ); - settings.setValue( "/version/builddate", __BUILD_DATE ); + settings.setValue( "/version/version", vymVersion ); + settings.setValue( "/version/builddate", vymBuildDate ); settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoSelectHeading->isOn() ); settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() ); @@ -188,8 +182,9 @@ settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() ); settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() ); - // To make the texteditor save its settings, call the destructor + // call the destructors delete (textEditor); + delete historyWindow; // Remove temporary directory removeDir (QDir(tmpVymDir)); @@ -348,8 +343,8 @@ fileMenu->addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) ); - a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+__VYM, this); - a->setStatusTip ( tr( "Exit")+" "+__VYM ); + a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this); + a->setStatusTip ( tr( "Exit")+" "+vymName ); a->setShortcut (Qt::CTRL + Qt::Key_Q ); fileMenu->addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) ); @@ -942,10 +937,11 @@ connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) ); actionViewToggleNoteEditor=a; - a = new QAction( tr( "Show history window","View action" ),this ); + a = new QAction(QPixmap(iconPath+"history.png"), tr( "Show history window","View action" ),this ); a->setStatusTip ( tr( "Show history window" )); a->setShortcut ( Qt::CTRL + Qt::Key_H ); a->setToggleAction(false); + a->addTo( tb ); viewMenu->addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) ); actionViewToggleHistoryWindow=a; @@ -1408,7 +1404,7 @@ helpMenu->addAction (a); a = new QAction( tr( "About VYM","Help action" ), this); - a->setStatusTip( tr( "About VYM")+" "__VYM); + a->setStatusTip( tr( "About VYM")+vymName); connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) ); helpMenu->addAction (a); @@ -1559,7 +1555,7 @@ if (eList.first() =="..") eList.pop_front(); // remove "." if (!eList.isEmpty()) { - QMessageBox mb( __VYM, + QMessageBox mb( vymName, tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?","write directory").arg(dir), QMessageBox::Warning, QMessageBox::Yes , @@ -1583,9 +1579,9 @@ QString Main::browseDirectory (const QString &caption) { - Q3FileDialog fd(this,caption); - fd.setMode (Q3FileDialog::DirectoryOnly); - fd.setCaption(__VYM " - "+caption); + QFileDialog fd(this,caption); + fd.setMode (QFileDialog::DirectoryOnly); + fd.setCaption(vymName+ " - "+caption); fd.show(); if ( fd.exec() == QDialog::Accepted ) @@ -1602,15 +1598,6 @@ return NULL; } -//TODO not used now, maybe use this for overview window later -void Main::newView() -{ - // Open a new view... have it delete when closed. - Main *m = new Main(0, 0, Qt::WDestructiveClose); - qApp->setMainWidget(m); - m->show(); - qApp->setMainWidget(0); -} void Main::editorChanged(QWidget *) { @@ -1663,7 +1650,7 @@ if (me->getFilePath() == fn) { // Already there, ask for confirmation - QMessageBox mb( __VYM, + QMessageBox mb( vymName, tr("The map %1\nis already opened." "Opening the same map in multiple editors may lead \n" "to confusion when finishing working with vym." @@ -1711,7 +1698,7 @@ // from command line if (!QFile(fn).exists() ) { - QMessageBox mb( __VYM, + QMessageBox mb( vymName, tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn), QMessageBox::Question, QMessageBox::Yes , @@ -1853,13 +1840,13 @@ switch (lmode) { case NewMap: - fd->setCaption(__VYM " - " +tr("Load vym map")); + fd->setCaption(vymName+ " - " +tr("Load vym map")); break; case ImportAdd: - fd->setCaption(__VYM " - " +tr("Import: Add vym map to selection")); + fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection")); break; case ImportReplace: - fd->setCaption(__VYM " - " +tr("Import: Replace selection with vym map")); + fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map")); break; } fd->show(); @@ -1937,7 +1924,7 @@ // Look, if we should zip the data: if (!saveZipped) { - QMessageBox mb( __VYM, + QMessageBox mb( vymName, tr("The map %1\ndid not use the compressed " "vym file format.\nWriting it uncompressed will also write images \n" "and flags and thus may overwrite files in the " @@ -2041,7 +2028,7 @@ // Check for existing file if (QFile (fn).exists()) { - QMessageBox mb( __VYM, + QMessageBox mb( vymName, tr("The file %1\nexists already. Do you want to").arg(fn), QMessageBox::Warning, QMessageBox::Yes | QMessageBox::Default, @@ -2239,7 +2226,7 @@ ExportASCII ex; ex.setMapCenter(me->getMapCenter()); ex.addFilter ("TXT (*.txt)"); - ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)")); + ex.setCaption(vymName+ " -" +tr("Export as ASCII")+" "+tr("(still experimental)")); if (ex.execDialog() ) { me->setExportMode(true); @@ -2257,7 +2244,7 @@ ExportLaTeX ex; ex.setMapCenter(me->getMapCenter()); ex.addFilter ("Tex (*.tex)"); - ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)")); + ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)")); if (ex.execDialog() ) { me->setExportMode(true); @@ -2285,7 +2272,7 @@ if (me) { ex.setMapCenter (me->getMapCenter() ); - ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)")); + ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)")); ex.addFilter ("Taskjuggler (*.tjp)"); if (ex.execDialog() ) { @@ -2298,13 +2285,13 @@ void Main::fileExportOOPresentation() { - ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office"); + ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office"); // TODO add preview in dialog //ImagePreview *p =new ImagePreview (fd); //fd->setContentsPreviewEnabled( TRUE ); //fd->setContentsPreview( p, p ); //fd->setPreviewMode( QFileDialog::Contents ); - fd->setCaption(__VYM " - " +tr("Export to")+" Open Office"); + fd->setCaption(vymName+" - " +tr("Export to")+" Open Office"); fd->setDir (QDir().current()); if (fd->foundConfig()) { @@ -2334,7 +2321,7 @@ { if (currentMapEditor()->hasChanged()) { - QMessageBox mb( __VYM, + QMessageBox mb( vymName, tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()), QMessageBox::Warning, QMessageBox::Yes | QMessageBox::Default, @@ -2383,7 +2370,7 @@ if (me->isUnsaved()) { tabWidget->setCurrentPage(i); - QMessageBox mb( __VYM, + QMessageBox mb( vymName, tr("This map is not saved yet. Do you want to"), QMessageBox::Warning, QMessageBox::Yes | QMessageBox::Default, @@ -2423,6 +2410,12 @@ currentMapEditor()->redo(); } +void Main::gotoHistoryStep (int i) +{ + if (currentMapEditor()) + currentMapEditor()->gotoHistoryStep (i); +} + void Main::editCopy() { if (currentMapEditor()) @@ -3142,8 +3135,16 @@ void Main::windowToggleHistory() { - if (currentMapEditor()) - currentMapEditor()->toggleHistoryWindow(); + if (historyWindow->isVisible()) + historyWindow->hide(); + else + historyWindow->show(); + +} + +void Main::updateHistory(SimpleSettings &undoSet) +{ + historyWindow->update (undoSet); } void Main::updateNoteFlag() @@ -3410,7 +3411,7 @@ if (!currentMapEditor()) return; bool ok; QString com = QInputDialog::getText( - __VYM, "Enter Command:", QLineEdit::Normal,"command", &ok, this ); + vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this ); if (ok) currentMapEditor()->parseAtom(com); }