1.1 --- a/mainwindow.cpp Mon Nov 20 12:12:00 2006 +0000
1.2 +++ b/mainwindow.cpp Mon Nov 20 12:12:02 2006 +0000
1.3 @@ -2,13 +2,7 @@
1.4
1.5 #include <QtGui>
1.6
1.7 -#include <q3filedialog.h>
1.8 -#include <Q3StrList>
1.9 -#include <Q3PtrList>
1.10 -
1.11 #include <iostream>
1.12 -#include <cstdlib>
1.13 -#include <typeinfo>
1.14
1.15 #include "aboutdialog.h"
1.16 #include "exportoofiledialog.h"
1.17 @@ -24,7 +18,6 @@
1.18 #include "process.h"
1.19 #include "settings.h"
1.20 #include "texteditor.h"
1.21 -#include "version.h"
1.22
1.23 extern TextEditor *textEditor;
1.24 extern Main *mainWindow;
1.25 @@ -34,6 +27,9 @@
1.26 extern int statusbarTime;
1.27 extern FlagRowObj* standardFlagsDefault;
1.28 extern FlagRowObj* systemFlagsDefault;
1.29 +extern QString vymName;
1.30 +extern QString vymVersion;
1.31 +extern QString vymBuildDate;
1.32
1.33 QMenu* branchContextMenu;
1.34 QMenu* branchAddContextMenu;
1.35 @@ -94,11 +90,9 @@
1.36
1.37 procBrowser=NULL;
1.38
1.39 - // FIXME not used currently
1.40 - // Set random seed (random used for object IDs)
1.41 - // QTime t = QTime::currentTime(); // set random seed
1.42 - // srand( t.hour()*12+t.minute()*60+t.second()*60 );
1.43 -
1.44 + // Initialize history window;
1.45 + historyWindow=new HistoryWindow();
1.46 + // FIXME historyWindow.setStepsTotal(stepsTotal);
1.47
1.48 // Initialize some settings, which are platform dependant
1.49 QString p,s;
1.50 @@ -178,8 +172,8 @@
1.51
1.52 settings.setValue ("/mainwindow/state",saveState(0));
1.53
1.54 - settings.setValue( "/version/version", __VYM_VERSION );
1.55 - settings.setValue( "/version/builddate", __BUILD_DATE );
1.56 + settings.setValue( "/version/version", vymVersion );
1.57 + settings.setValue( "/version/builddate", vymBuildDate );
1.58
1.59 settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoSelectHeading->isOn() );
1.60 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
1.61 @@ -188,8 +182,9 @@
1.62 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
1.63 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
1.64
1.65 - // To make the texteditor save its settings, call the destructor
1.66 + // call the destructors
1.67 delete (textEditor);
1.68 + delete historyWindow;
1.69
1.70 // Remove temporary directory
1.71 removeDir (QDir(tmpVymDir));
1.72 @@ -348,8 +343,8 @@
1.73 fileMenu->addAction (a);
1.74 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
1.75
1.76 - a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+__VYM, this);
1.77 - a->setStatusTip ( tr( "Exit")+" "+__VYM );
1.78 + a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
1.79 + a->setStatusTip ( tr( "Exit")+" "+vymName );
1.80 a->setShortcut (Qt::CTRL + Qt::Key_Q );
1.81 fileMenu->addAction (a);
1.82 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
1.83 @@ -942,10 +937,11 @@
1.84 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1.85 actionViewToggleNoteEditor=a;
1.86
1.87 - a = new QAction( tr( "Show history window","View action" ),this );
1.88 + a = new QAction(QPixmap(iconPath+"history.png"), tr( "Show history window","View action" ),this );
1.89 a->setStatusTip ( tr( "Show history window" ));
1.90 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1.91 a->setToggleAction(false);
1.92 + a->addTo( tb );
1.93 viewMenu->addAction (a);
1.94 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1.95 actionViewToggleHistoryWindow=a;
1.96 @@ -1408,7 +1404,7 @@
1.97 helpMenu->addAction (a);
1.98
1.99 a = new QAction( tr( "About VYM","Help action" ), this);
1.100 - a->setStatusTip( tr( "About VYM")+" "__VYM);
1.101 + a->setStatusTip( tr( "About VYM")+vymName);
1.102 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1.103 helpMenu->addAction (a);
1.104
1.105 @@ -1559,7 +1555,7 @@
1.106 if (eList.first() =="..") eList.pop_front(); // remove "."
1.107 if (!eList.isEmpty())
1.108 {
1.109 - QMessageBox mb( __VYM,
1.110 + QMessageBox mb( vymName,
1.111 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?","write directory").arg(dir),
1.112 QMessageBox::Warning,
1.113 QMessageBox::Yes ,
1.114 @@ -1583,9 +1579,9 @@
1.115
1.116 QString Main::browseDirectory (const QString &caption)
1.117 {
1.118 - Q3FileDialog fd(this,caption);
1.119 - fd.setMode (Q3FileDialog::DirectoryOnly);
1.120 - fd.setCaption(__VYM " - "+caption);
1.121 + QFileDialog fd(this,caption);
1.122 + fd.setMode (QFileDialog::DirectoryOnly);
1.123 + fd.setCaption(vymName+ " - "+caption);
1.124 fd.show();
1.125
1.126 if ( fd.exec() == QDialog::Accepted )
1.127 @@ -1602,15 +1598,6 @@
1.128 return NULL;
1.129 }
1.130
1.131 -//TODO not used now, maybe use this for overview window later
1.132 -void Main::newView()
1.133 -{
1.134 - // Open a new view... have it delete when closed.
1.135 - Main *m = new Main(0, 0, Qt::WDestructiveClose);
1.136 - qApp->setMainWidget(m);
1.137 - m->show();
1.138 - qApp->setMainWidget(0);
1.139 -}
1.140
1.141 void Main::editorChanged(QWidget *)
1.142 {
1.143 @@ -1663,7 +1650,7 @@
1.144 if (me->getFilePath() == fn)
1.145 {
1.146 // Already there, ask for confirmation
1.147 - QMessageBox mb( __VYM,
1.148 + QMessageBox mb( vymName,
1.149 tr("The map %1\nis already opened."
1.150 "Opening the same map in multiple editors may lead \n"
1.151 "to confusion when finishing working with vym."
1.152 @@ -1711,7 +1698,7 @@
1.153 // from command line
1.154 if (!QFile(fn).exists() )
1.155 {
1.156 - QMessageBox mb( __VYM,
1.157 + QMessageBox mb( vymName,
1.158 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1.159 QMessageBox::Question,
1.160 QMessageBox::Yes ,
1.161 @@ -1853,13 +1840,13 @@
1.162 switch (lmode)
1.163 {
1.164 case NewMap:
1.165 - fd->setCaption(__VYM " - " +tr("Load vym map"));
1.166 + fd->setCaption(vymName+ " - " +tr("Load vym map"));
1.167 break;
1.168 case ImportAdd:
1.169 - fd->setCaption(__VYM " - " +tr("Import: Add vym map to selection"));
1.170 + fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1.171 break;
1.172 case ImportReplace:
1.173 - fd->setCaption(__VYM " - " +tr("Import: Replace selection with vym map"));
1.174 + fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1.175 break;
1.176 }
1.177 fd->show();
1.178 @@ -1937,7 +1924,7 @@
1.179 // Look, if we should zip the data:
1.180 if (!saveZipped)
1.181 {
1.182 - QMessageBox mb( __VYM,
1.183 + QMessageBox mb( vymName,
1.184 tr("The map %1\ndid not use the compressed "
1.185 "vym file format.\nWriting it uncompressed will also write images \n"
1.186 "and flags and thus may overwrite files in the "
1.187 @@ -2041,7 +2028,7 @@
1.188 // Check for existing file
1.189 if (QFile (fn).exists())
1.190 {
1.191 - QMessageBox mb( __VYM,
1.192 + QMessageBox mb( vymName,
1.193 tr("The file %1\nexists already. Do you want to").arg(fn),
1.194 QMessageBox::Warning,
1.195 QMessageBox::Yes | QMessageBox::Default,
1.196 @@ -2239,7 +2226,7 @@
1.197 ExportASCII ex;
1.198 ex.setMapCenter(me->getMapCenter());
1.199 ex.addFilter ("TXT (*.txt)");
1.200 - ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
1.201 + ex.setCaption(vymName+ " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
1.202 if (ex.execDialog() )
1.203 {
1.204 me->setExportMode(true);
1.205 @@ -2257,7 +2244,7 @@
1.206 ExportLaTeX ex;
1.207 ex.setMapCenter(me->getMapCenter());
1.208 ex.addFilter ("Tex (*.tex)");
1.209 - ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
1.210 + ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
1.211 if (ex.execDialog() )
1.212 {
1.213 me->setExportMode(true);
1.214 @@ -2285,7 +2272,7 @@
1.215 if (me)
1.216 {
1.217 ex.setMapCenter (me->getMapCenter() );
1.218 - ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
1.219 + ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
1.220 ex.addFilter ("Taskjuggler (*.tjp)");
1.221 if (ex.execDialog() )
1.222 {
1.223 @@ -2298,13 +2285,13 @@
1.224
1.225 void Main::fileExportOOPresentation()
1.226 {
1.227 - ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
1.228 + ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
1.229 // TODO add preview in dialog
1.230 //ImagePreview *p =new ImagePreview (fd);
1.231 //fd->setContentsPreviewEnabled( TRUE );
1.232 //fd->setContentsPreview( p, p );
1.233 //fd->setPreviewMode( QFileDialog::Contents );
1.234 - fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
1.235 + fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
1.236 fd->setDir (QDir().current());
1.237 if (fd->foundConfig())
1.238 {
1.239 @@ -2334,7 +2321,7 @@
1.240 {
1.241 if (currentMapEditor()->hasChanged())
1.242 {
1.243 - QMessageBox mb( __VYM,
1.244 + QMessageBox mb( vymName,
1.245 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
1.246 QMessageBox::Warning,
1.247 QMessageBox::Yes | QMessageBox::Default,
1.248 @@ -2383,7 +2370,7 @@
1.249 if (me->isUnsaved())
1.250 {
1.251 tabWidget->setCurrentPage(i);
1.252 - QMessageBox mb( __VYM,
1.253 + QMessageBox mb( vymName,
1.254 tr("This map is not saved yet. Do you want to"),
1.255 QMessageBox::Warning,
1.256 QMessageBox::Yes | QMessageBox::Default,
1.257 @@ -2423,6 +2410,12 @@
1.258 currentMapEditor()->redo();
1.259 }
1.260
1.261 +void Main::gotoHistoryStep (int i)
1.262 +{
1.263 + if (currentMapEditor())
1.264 + currentMapEditor()->gotoHistoryStep (i);
1.265 +}
1.266 +
1.267 void Main::editCopy()
1.268 {
1.269 if (currentMapEditor())
1.270 @@ -3142,8 +3135,16 @@
1.271
1.272 void Main::windowToggleHistory()
1.273 {
1.274 - if (currentMapEditor())
1.275 - currentMapEditor()->toggleHistoryWindow();
1.276 + if (historyWindow->isVisible())
1.277 + historyWindow->hide();
1.278 + else
1.279 + historyWindow->show();
1.280 +
1.281 +}
1.282 +
1.283 +void Main::updateHistory(SimpleSettings &undoSet)
1.284 +{
1.285 + historyWindow->update (undoSet);
1.286 }
1.287
1.288 void Main::updateNoteFlag()
1.289 @@ -3410,7 +3411,7 @@
1.290 if (!currentMapEditor()) return;
1.291 bool ok;
1.292 QString com = QInputDialog::getText(
1.293 - __VYM, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
1.294 + vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
1.295 if (ok) currentMapEditor()->parseAtom(com);
1.296 }
1.297