# HG changeset patch # User insilmaril # Date 1164024722 0 # Node ID 53efc2562a7d6979851aca6d1baffa32e1b6c507 # Parent 7c3ee77f4449733c12136136f0aa64a3b7c5110f historywindow moved to mainwindow. Started to get rid of Q3PtrList finally diff -r 7c3ee77f4449 -r 53efc2562a7d aboutdialog.cpp --- a/aboutdialog.cpp Mon Nov 20 12:12:00 2006 +0000 +++ b/aboutdialog.cpp Mon Nov 20 12:12:02 2006 +0000 @@ -3,12 +3,13 @@ #include <QFrame> #include "aboutdialog.h" -#include "version.h" #include "settings.h" extern Settings settings; extern QString iconPath; +extern QString vymVersion; +extern QString vymBuildDate; AboutDialog::AboutDialog( QWidget *parent, const char *name) : QDialog( parent, name) @@ -24,7 +25,7 @@ "<h3><center>VYM - View Your Mind </h3>" "<p align=\"center\"> A tool to put the things you have got in your mind into a map.</p>" "<p align=\"center\"> (c) by Uwe Drechsel (<a href=\"mailto:vym@InSilmaril.de\">vym@InSilmaril.de</a>)</p>" - "<p align=\"center\"> Version " __VYM_VERSION" - " __BUILD_DATE"</p>" + "<p align=\"center\"> Version " +vymVersion+" - " +vymBuildDate+"</p>" "<ul>" "<li> Contact</li>" "<ul>" diff -r 7c3ee77f4449 -r 53efc2562a7d branchobj.cpp --- a/branchobj.cpp Mon Nov 20 12:12:00 2006 +0000 +++ b/branchobj.cpp Mon Nov 20 12:12:02 2006 +0000 @@ -86,7 +86,6 @@ void BranchObj::init () { branch.setAutoDelete (false); - floatimage.setAutoDelete (true); xlink.setAutoDelete (false); if (parObj) @@ -118,10 +117,8 @@ // Those will get a deep copy, too addBranch(b); - FloatImageObj *fi; - for (fi=other->floatimage.first(); fi;fi=other->floatimage.next() ) - addFloatImage (fi); - + for (int i=0; i<other->floatimage.size(); ++i) + addFloatImage (other->floatimage.at(i)); scrolled=other->scrolled; tmpUnscrolled=other->tmpUnscrolled; setVisibility (other->visible); @@ -133,7 +130,9 @@ void BranchObj::clear() { - floatimage.clear(); + while (!floatimage.isEmpty()) + delete floatimage.takeFirst(); + while (!xlink.isEmpty()) deleteXLink (xlink.first() ); @@ -166,7 +165,7 @@ int BranchObj::getFloatImageNum(FloatImageObj *fio) { - return floatimage.findRef (fio); + return floatimage.indexOf(fio); } int BranchObj::countBranches() @@ -366,9 +365,8 @@ BranchObj* b; for (b=branch.first(); b;b=branch.next() ) b->setVisibility (v,toDepth); - FloatImageObj *fio; - for (fio=floatimage.first(); fio; fio=floatimage.next()) - fio->setVisibility (v); + for (int i=0; i<floatimage.size(); ++i) + floatimage.at(i)->setVisibility (v); XLinkObj* xlo; for (xlo=xlink.first(); xlo;xlo=xlink.next() ) xlo->setVisibility (); @@ -535,18 +533,16 @@ void BranchObj::positionContents() { - FloatImageObj *fio; - for (fio=floatimage.first(); fio; fio=floatimage.next() ) - fio->reposition(); + for (int i=0; i<floatimage.size(); ++i ) + floatimage.at(i)->reposition(); OrnamentedObj::positionContents(); } void BranchObj::move (double x, double y) { OrnamentedObj::move (x,y); - FloatImageObj *fio; - for (fio=floatimage.first(); fio; fio=floatimage.next() ) - fio->reposition(); + for (int i=0; i<floatimage.size(); ++i ) + floatimage.at(i)->reposition(); positionBBox(); } @@ -614,22 +610,21 @@ // Floatimages QPoint rp; - FloatImageObj *foi; topPad=botPad=leftPad=rightPad=0; if (includeImagesVer || includeImagesHor) { if (countFloatImages()>0) { - for (foi=floatimage.first(); foi; foi=floatimage.next() ) + for (int i=0; i<floatimage.size(); ++i ) { - rp=foi->getRelPos(); + rp=floatimage.at(i)->getRelPos(); if (includeImagesVer) { if (rp.y() < 0) topPad=max (topPad,-rp.y()-h); - if (rp.y()+foi->height() > 0) - botPad=max (botPad,rp.y()+foi->height()); + if (rp.y()+floatimage.at(i)->height() > 0) + botPad=max (botPad,rp.y()+floatimage.at(i)->height()); } if (includeImagesHor) { @@ -637,14 +632,14 @@ { if (-rp.x()-w > 0) leftPad=max (leftPad,-rp.x()-w); - if (rp.x()+foi->width() > 0) - rightPad=max (rightPad,rp.x()+foi->width()); + if (rp.x()+floatimage.at(i)->width() > 0) + rightPad=max (rightPad,rp.x()+floatimage.at(i)->width()); } else { if (rp.x()< 0) leftPad=max (leftPad,-rp.x()); - if (rp.x()+foi->width() > w) - rightPad=max (rightPad,rp.x()+foi->width()-w); + if (rp.x()+floatimage.at(i)->width() > w) + rightPad=max (rightPad,rp.x()+floatimage.at(i)->width()-w); } } } @@ -691,13 +686,12 @@ return this; // Search float images - FloatImageObj *foi; - for (foi=floatimage.first(); foi; foi=floatimage.next() ) - if (foi->inBox(p) && - (foi != excludeLMO) && - foi->getParObj()!= excludeLMO && - foi->isVisibleObj() - ) return foi; + for (int i=0; i<floatimage.size(); ++i ) + if (floatimage.at(i)->inBox(p) && + (floatimage.at(i) != excludeLMO) && + floatimage.at(i)->getParObj()!= excludeLMO && + floatimage.at(i)->isVisibleObj() + ) return floatimage.at(i); return NULL; } @@ -803,9 +797,8 @@ s+=standardFlags->saveToDir(tmpdir,prefix,0); // Save FloatImages - FloatImageObj *fio; - for (fio=floatimage.first(); fio; fio=floatimage.next() ) - s+=fio->saveToDir (tmpdir,prefix); + for (int i=0; i<floatimage.size(); ++i) + s+=floatimage.at(i)->saveToDir (tmpdir,prefix); // save note if (!note.isEmpty() ) @@ -971,7 +964,8 @@ void BranchObj::removeFloatImage (FloatImageObj *fio) { - floatimage.remove (fio); + int i=floatimage.indexOf (fio); + if (i!=-1) floatimage.takeAt (i); calcBBoxSize(); positionBBox(); requestReposition(); @@ -1379,10 +1373,9 @@ if (!b->isHidden()) r=addBBox(b->getTotalBBox(),r); - FloatImageObj* fio; - for (fio=floatimage.first();fio ;fio=floatimage.next() ) - if (!fio->isHidden()) - r=addBBox(fio->getTotalBBox(),r); + for (int i=0; i<floatimage.size(); ++i) + if (!floatimage.at(i)->isHidden()) + r=addBBox(floatimage.at(i)->getTotalBBox(),r); return r; } diff -r 7c3ee77f4449 -r 53efc2562a7d branchobj.h --- a/branchobj.h Mon Nov 20 12:12:00 2006 +0000 +++ b/branchobj.h Mon Nov 20 12:12:02 2006 +0000 @@ -128,7 +128,7 @@ static BranchObj* itLast; // iterator for first(), next() static BranchObj* itFirst; // first iterator for first(), next() BranchObjPtrList branch; // all child branches - Q3PtrList<FloatImageObj> floatimage; // child images + QList<FloatImageObj*> floatimage;// child images Q3PtrList<XLinkObj> xlink; // xlinks to other branches public: float angle; // used in mainbranch to reorder mainbranches diff -r 7c3ee77f4449 -r 53efc2562a7d demos/todo.vym Binary file demos/todo.vym has changed diff -r 7c3ee77f4449 -r 53efc2562a7d exports.cpp --- a/exports.cpp Mon Nov 20 12:12:00 2006 +0000 +++ b/exports.cpp Mon Nov 20 12:12:02 2006 +0000 @@ -1,8 +1,3 @@ -//#include <q3filedialog.h> -//#include <QMessageBox> -//#include <QProcess> -//#include <QTextStream> - #include "exports.h" #include "file.h" #include "linkablemapobj.h" @@ -13,7 +8,7 @@ extern Main *mainWindow; extern QDir vymBaseDir; - +extern QString vymName; ExportBase::ExportBase() { @@ -70,7 +65,7 @@ { if (QFile (fd->selectedFile()).exists() ) { - QMessageBox mb( __VYM, + QMessageBox mb( vymName, QObject::tr("The file %1 exists already.\nDo you want to overwrite it?").arg(fd->selectedFile()), QMessageBox::Warning, QMessageBox::Yes | QMessageBox::Default, diff -r 7c3ee77f4449 -r 53efc2562a7d historywindow.cpp --- a/historywindow.cpp Mon Nov 20 12:12:00 2006 +0000 +++ b/historywindow.cpp Mon Nov 20 12:12:02 2006 +0000 @@ -1,7 +1,10 @@ #include "historywindow.h" -#include "mapeditor.h" +#include "mainwindow.h" + extern QString iconPath; +extern Settings settings; +extern Main *mainWindow; HistoryWindow::HistoryWindow (QWidget *parent):QDialog (parent) { @@ -29,8 +32,25 @@ connect ( ui.undoButton, SIGNAL (clicked()), this, SLOT (undo())); connect ( ui.redoButton, SIGNAL (clicked()), this, SLOT (redo())); connect ( ui.historyTable, SIGNAL (itemSelectionChanged()), this, SLOT (select())); + + // Load Settings + resize (settings.value ( "/historywindow/geometry/size", QSize(450,600)).toSize()); + move (settings.value ( "/historywindow/geometry/pos", QPoint (250,50)).toPoint()); + +/* + if (settings.value ( "/historywindow/showWithMain",false).toBool()) + setShowWithMain(true); + else + setShowWithMain(false); +*/ } +HistoryWindow::~HistoryWindow() +{ + settings.setValue( "/historywindow/geometry/size", size() ); + settings.setValue( "/historywindow/geometry/pos", pos() ); + //settings.setValue( "/historywindow/showWithMain",showWithMain()); +} void HistoryWindow::clearRow(int row) { @@ -122,11 +142,6 @@ ui.historyTable->resizeColumnsToContents(); } -void HistoryWindow::setME (MapEditor *me) -{ - mapEditor=me; -} - void HistoryWindow::setStepsTotal (int st) { // Number of steps + "current" bar @@ -136,15 +151,15 @@ void HistoryWindow::undo() { - mapEditor->undo(); + mainWindow->editUndo(); } void HistoryWindow::redo() { - mapEditor->redo(); + mainWindow->editRedo(); } void HistoryWindow::select() { - mapEditor->gotoStep (ui.historyTable->row (ui.historyTable->selectedItems().first())); + mainWindow->gotoHistoryStep (ui.historyTable->row (ui.historyTable->selectedItems().first())); } diff -r 7c3ee77f4449 -r 53efc2562a7d historywindow.h --- a/historywindow.h Mon Nov 20 12:12:00 2006 +0000 +++ b/historywindow.h Mon Nov 20 12:12:02 2006 +0000 @@ -5,8 +5,6 @@ #include "ui_historywindow.h" -class MapEditor; - ///////////////////////////////////////////////////////////////////////////// class HistoryWindow:public QDialog { @@ -14,8 +12,8 @@ public: HistoryWindow(QWidget* parent = 0); + ~HistoryWindow(); void update (SimpleSettings &); - void setME (MapEditor *); void setStepsTotal (int); private slots: @@ -27,7 +25,6 @@ void clearRow (int); void updateRow (int, int, SimpleSettings &); Ui::HistoryWindow ui; - MapEditor *mapEditor; }; diff -r 7c3ee77f4449 -r 53efc2562a7d linkablemapobj.cpp --- a/linkablemapobj.cpp Mon Nov 20 12:12:00 2006 +0000 +++ b/linkablemapobj.cpp Mon Nov 20 12:12:02 2006 +0000 @@ -4,7 +4,6 @@ #include "branchobj.h" #include "mapeditor.h" -#include "version.h" //Added by qt3to4: #include <Q3PointArray> diff -r 7c3ee77f4449 -r 53efc2562a7d main.cpp --- a/main.cpp Mon Nov 20 12:12:00 2006 +0000 +++ b/main.cpp Mon Nov 20 12:12:02 2006 +0000 @@ -1,14 +1,18 @@ #include <QApplication> #include <q3network.h> +#include "flagrowobj.h" +#include "mainwindow.h" +#include "options.h" #include "settings.h" -#include "options.h" -#include "mainwindow.h" -#include "flagrowobj.h" +#include "version.h" // Global variables TextEditor *textEditor; // used in Constr. of LinkableMapObj // initialized in mainwindow +QString vymName(__VYM_NAME); +QString vymVersion(__VYM_VERSION); +QString vymBuildDate(__VYM_BUILD_DATE); Main *mainWindow; // used in BranchObj::select() QString tmpVymDir; // All temp files go there, created in mainwindow @@ -60,7 +64,7 @@ { cout << "vym version "<<__VYM_VERSION <<" (c) 2004-2006 Uwe Drechsel - " - <<__BUILD_DATE<<endl; + <<__VYM_BUILD_DATE<<endl; return 0; } 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 <QtGui> -#include <q3filedialog.h> -#include <Q3StrList> -#include <Q3PtrList> - #include <iostream> -#include <cstdlib> -#include <typeinfo> #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); } diff -r 7c3ee77f4449 -r 53efc2562a7d mainwindow.h --- a/mainwindow.h Mon Nov 20 12:12:00 2006 +0000 +++ b/mainwindow.h Mon Nov 20 12:12:02 2006 +0000 @@ -5,6 +5,7 @@ #include "file.h" #include "findwindow.h" +#include "historywindow.h" #include "mapeditor.h" #include "texteditor.h" #include "xml.h" @@ -47,7 +48,6 @@ MapEditor* currentMapEditor() const; private slots: - void newView(); void editorChanged(QWidget*); ErrorCode fileLoad(QString ,const LoadMode &); @@ -75,8 +75,11 @@ void filePrint(); void fileExitVYM(); +public slots: void editUndo(); void editRedo(); + void gotoHistoryStep (int); +private slots: void editCopy(); void editPaste(); void editCut(); @@ -159,6 +162,7 @@ void windowToggleNoteEditor(); void windowToggleHistory(); + void updateHistory(SimpleSettings &); void updateNoteFlag(); void updateActions(); ModMode getModMode(); @@ -191,6 +195,8 @@ QLineEdit *lineedit; // to enter headings of branches QString prevSelection; + HistoryWindow *historyWindow; + Q3PtrList <QAction> actionListBranches; QColor currentColor; diff -r 7c3ee77f4449 -r 53efc2562a7d mapcenterobj.cpp --- a/mapcenterobj.cpp Mon Nov 20 12:12:00 2006 +0000 +++ b/mapcenterobj.cpp Mon Nov 20 12:12:02 2006 +0000 @@ -2,7 +2,6 @@ #include "mapcenterobj.h" #include "floatimageobj.h" -#include "mapeditor.h" ///////////////////////////////////////////////////////////////// // MapCenterObj @@ -92,8 +91,8 @@ b->setOrientation(); } - FloatObj *fo; - for (fo=floatimage.first(); fo; fo=floatimage.next() ) fo->setRelPos(); + for (int i=0; i<floatimage.size(); ++i) + floatimage.at(i)->setRelPos(); if (repositionRequest) reposition(); } @@ -113,9 +112,8 @@ if (inBox (p) && (this != excludeLMO) ) return this; // Search float images - FloatImageObj *foi; - for (foi=floatimage.first(); foi; foi=floatimage.next() ) - if (foi->inBox(p) && (foi != excludeLMO) && foi->getParObj()!= excludeLMO) return foi; + for (int i=0; i<floatimage.size(); ++i) + if (floatimage.at(i)->inBox(p) && (floatimage.at(i) != excludeLMO) && floatimage.at(i)->getParObj()!= excludeLMO) return floatimage.at(i); // nothing found return NULL; @@ -168,9 +166,8 @@ s+=bo->saveToDir(tmpdir,prefix, offset); // Save FloatImages - FloatImageObj *fio; - for (fio=floatimage.first(); fio; fio=floatimage.next() ) - s+=fio->saveToDir (tmpdir,prefix); + for (int i=0; i<floatimage.size(); ++i) + s+=floatimage.at(i)->saveToDir (tmpdir,prefix); // Save XLinks XLinkObj *xlo; diff -r 7c3ee77f4449 -r 53efc2562a7d mapcenterobj.h --- a/mapcenterobj.h Mon Nov 20 12:12:00 2006 +0000 +++ b/mapcenterobj.h Mon Nov 20 12:12:02 2006 +0000 @@ -5,8 +5,6 @@ #include <QDate> #include "branchobj.h" -#include "xlinkobj.h" -#include "version.h" ///////////////////////////////////////////////////////////////////////////// class MapCenterObj:public BranchObj { diff -r 7c3ee77f4449 -r 53efc2562a7d mapeditor.cpp --- a/mapeditor.cpp Mon Nov 20 12:12:00 2006 +0000 +++ b/mapeditor.cpp Mon Nov 20 12:12:02 2006 +0000 @@ -46,6 +46,9 @@ extern Settings settings; extern ImageIO imageIO; +extern QString vymName; +extern QString vymVersion; + extern QString iconPath; extern QDir vymBaseDir; extern QDir lastImageDir; @@ -87,16 +90,10 @@ linkstyle=StylePolyParabel; // Create bitmap cursors, platform dependant - // FIXME should now work also on Mac... - //#if defined(Q_OS_MACX) - // HandOpenCursor=QCursor ( QPixmap(iconPath+"cursorhandopen16.png"),1,1 ); - // PickColorCursor=QCursor ( QPixmap (iconPath+"cursorcolorpicker16.png"), 1,15 ); - //#else - HandOpenCursor=QCursor (QPixmap(iconPath+"cursorhandopen.png"),1,1); - PickColorCursor=QCursor ( QPixmap(iconPath+"cursorcolorpicker.png"), 5,27 ); - CopyCursor=QCursor ( QPixmap(iconPath+"cursorcopy.png"), 5,5 ); - XLinkCursor=QCursor ( QPixmap(iconPath+"cursorxlink.png"), 5,27 ); - //#endif + HandOpenCursor=QCursor (QPixmap(iconPath+"cursorhandopen.png"),1,1); + PickColorCursor=QCursor ( QPixmap(iconPath+"cursorcolorpicker.png"), 5,27 ); + CopyCursor=QCursor ( QPixmap(iconPath+"cursorcopy.png"), 1,1 ); + XLinkCursor=QCursor ( QPixmap(iconPath+"cursorxlink.png"), 1,7 ); setFocusPolicy (Qt::StrongFocus); @@ -146,10 +143,6 @@ mapCenter->reposition(); // for positioning heading - // Initialize history window; - historyWindow.setME(this); - historyWindow.setStepsTotal(stepsTotal); - historyWindow.update (undoSet); } MapEditor::~MapEditor() @@ -299,7 +292,7 @@ if (linkcolorhint==HeadingColor) colhint=attribut("linkColorHint","HeadingColor"); - QString mapAttr=attribut("version",__VYM_VERSION); + QString mapAttr=attribut("version",vymVersion); if (!saveSel || saveSel==mapCenter) mapAttr+= attribut("author",mapCenter->getAuthor()) + attribut("comment",mapCenter->getComment()) + @@ -487,7 +480,7 @@ undoSet.setEntry (QString("/history/step-%1/redoCommand").arg(curStep),redoCom); undoSet.setEntry (QString("/history/step-%1/redoSelection").arg(curStep),redoSelection); undoSet.setEntry (QString("/history/step-%1/comment").arg(curStep),comment); - undoSet.setEntry (QString("/history/version"),__VYM_VERSION); + undoSet.setEntry (QString("/history/version"),vymVersion); undoSet.writeSettings(histPath); /* TODO remove after testing @@ -506,7 +499,7 @@ if (saveSel) cout << " saveSel="<<saveSel->getSelectString().ascii()<<endl; cout << " ---------------------------"<<endl; - historyWindow.update (undoSet); + mainWindow->updateHistory (undoSet); setChanged(); updateActions(); } @@ -962,14 +955,6 @@ } } -void MapEditor::toggleHistoryWindow() -{ - if (historyWindow.isVisible()) - historyWindow.hide(); - else - historyWindow.show(); -} - bool MapEditor::isDefault() { @@ -1033,9 +1018,6 @@ // Forget the .vym (or .xml) for name of map mapName=fileName.left(fileName.findRev(".",-1,true) ); - - // Adjust history window - historyWindow.setCaption (__VYM " - " +tr("History for ")+fileName); } } @@ -1493,7 +1475,7 @@ if (!checkVersion(version)) QMessageBox::warning(0,tr("Warning"), - tr("Version %1 of saved undo/redo data\ndoes not match current vym version %2.").arg(version).arg(__VYM_VERSION)); + tr("Version %1 of saved undo/redo data\ndoes not match current vym version %2.").arg(version).arg(vymVersion)); // Find out current undo directory @@ -1514,7 +1496,6 @@ cout << " ---------------------------"<<endl<<endl; // select object before redo - // FIXME better give up if no selection there... if (!redoSelection.isEmpty()) select (redoSelection); @@ -1529,16 +1510,16 @@ undoSet.setEntry ("/history/curStep",QString::number(curStep)); undoSet.writeSettings(histPath); - historyWindow.update (undoSet); + mainWindow->updateHistory (undoSet); updateActions(); /* TODO remove testing -*/ cout << "ME::redo() end\n"; cout << " undosAvail="<<undosAvail<<endl; cout << " redosAvail="<<redosAvail<<endl; cout << " curStep="<<curStep<<endl; cout << " ---------------------------"<<endl<<endl; + */ } @@ -1572,7 +1553,7 @@ if (!checkVersion(version)) QMessageBox::warning(0,tr("Warning"), - tr("Version %1 of saved undo/redo data\ndoes not match current vym version %2.").arg(version).arg(__VYM_VERSION)); + tr("Version %1 of saved undo/redo data\ndoes not match current vym version %2.").arg(version).arg(vymVersion)); // Find out current undo directory QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(curStep)); @@ -1605,19 +1586,19 @@ blockSaveState=false; /* TODO remove testing -*/ cout << "ME::undo() end\n"; cout << " undosAvail="<<undosAvail<<endl; cout << " redosAvail="<<redosAvail<<endl; cout << " curStep="<<curStep<<endl; cout << " ---------------------------"<<endl<<endl; +*/ undoSet.setEntry ("/history/undosAvail",QString::number(undosAvail)); undoSet.setEntry ("/history/redosAvail",QString::number(redosAvail)); undoSet.setEntry ("/history/curStep",QString::number(curStep)); undoSet.writeSettings(histPath); - historyWindow.update (undoSet); + mainWindow->updateHistory (undoSet); updateActions(); } @@ -1629,14 +1610,12 @@ return false; } -void MapEditor::gotoStep (int i) +void MapEditor::gotoHistoryStep (int i) { // Restore variables int undosAvail=undoSet.readNumEntry (QString("/history/undosAvail")); int redosAvail=undoSet.readNumEntry (QString("/history/redosAvail")); - cout << "ME::goto "<<i<<endl; - if (i<0) i=undosAvail+redosAvail; // Clicking above current step makes us undo things @@ -2759,11 +2738,13 @@ typeid(*selection) == typeid(MapCenterObj)) ) { BranchObj *bo=(BranchObj*)selection; - Q3FileDialog *fd=new Q3FileDialog( this,__VYM " - " +tr("Link to another map")); - fd->addFilter (QString (tr("vym map") + " (*.vym)")); - fd->setCaption(__VYM " - " +tr("Link to another map")); + QStringList filters; + filters <<"VYM map (*.vym)"; + QFileDialog *fd=new QFileDialog( this,vymName+" - " +tr("Link to another map")); + fd->setFilters (filters); + fd->setCaption(vymName+" - " +tr("Link to another map")); if (! bo->getVymLink().isEmpty() ) - fd->setSelection( bo->getVymLink() ); + fd->selectFile( bo->getVymLink() ); fd->show(); QString fn; @@ -3163,7 +3144,7 @@ fd->setContentsPreviewEnabled( TRUE ); fd->setContentsPreview( p, p ); fd->setPreviewMode( Q3FileDialog::Contents ); - fd->setCaption(__VYM " - " +tr("Load image")); + fd->setCaption(vymName+" - " +tr("Load image")); fd->setDir (lastImageDir); fd->show(); @@ -3210,7 +3191,7 @@ FloatImageObj *fio=((FloatImageObj*)selection); QFileDialog *fd=new QFileDialog( this); fd->setFilters (imageIO.getFilters()); - fd->setCaption(__VYM " - " +tr("Save image")); + fd->setCaption(vymName+" - " +tr("Save image")); fd->setFileMode( QFileDialog::AnyFile ); fd->setDirectory (lastImageDir); // fd->setSelection (fio->getOriginalFilename()); @@ -3221,7 +3202,7 @@ { if (QFile (fd->selectedFile()).exists() ) { - QMessageBox mb( __VYM, + QMessageBox mb( vymName, tr("The file %1 exists already.\n" "Do you want to overwrite it?").arg(fd->selectedFile()), QMessageBox::Warning, @@ -3344,10 +3325,12 @@ (typeid(*selection) == typeid(BranchObj)) || (typeid(*selection) == typeid(MapCenterObj)) ) { - Q3FileDialog *fd=new Q3FileDialog( this,__VYM " - " +tr("Choose directory structure to import")); - fd->setMode (Q3FileDialog::DirectoryOnly); - fd->addFilter (QString (tr("vym map") + " (*.vym)")); - fd->setCaption(__VYM " - " +tr("Choose directory structure to import")); + QStringList filters; + filters <<"VYM map (*.vym)"; + QFileDialog *fd=new QFileDialog( this,vymName+ " - " +tr("Choose directory structure to import")); + fd->setMode (QFileDialog::DirectoryOnly); + fd->setFilters (filters); + fd->setCaption(vymName+" - " +tr("Choose directory structure to import")); fd->show(); QString fn; diff -r 7c3ee77f4449 -r 53efc2562a7d mapeditor.h --- a/mapeditor.h Mon Nov 20 12:12:00 2006 +0000 +++ b/mapeditor.h Mon Nov 20 12:12:02 2006 +0000 @@ -6,7 +6,6 @@ #include "mapcenterobj.h" #include "file.h" -#include "historywindow.h" #include "misc.h" #include "selection.h" #include "settings.h" @@ -79,7 +78,7 @@ bool isRedoAvailable(); void undo(); // undo last action bool isUndoAvailable(); - void gotoStep (int);// goto a step in history + void gotoHistoryStep (int);// goto a step in history private: void addMapReplaceInt(const QString & undoSel, const QString & path); void addMapInsertInt (const QString & path, int pos); @@ -261,9 +260,6 @@ Q3UrlOperator *urlOperator; QDataStream *imageData; QBuffer *imageBuffer; - - HistoryWindow historyWindow; - }; #endif diff -r 7c3ee77f4449 -r 53efc2562a7d texteditor.cpp --- a/texteditor.cpp Mon Nov 20 12:12:00 2006 +0000 +++ b/texteditor.cpp Mon Nov 20 12:12:02 2006 +0000 @@ -5,14 +5,16 @@ #include <typeinfo> #include "noteobj.h" +#include "settings.h" #include "version.h" extern int statusbarTime; -extern QSettings settings; +extern Settings settings; extern QAction *actionViewToggleNoteEditor; extern QString iconPath; +extern QString vymName; using namespace std; @@ -35,7 +37,7 @@ connect (e, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); setCentralWidget( e ); statusBar()->message( tr("Ready","Statusbar message"), statusbarTime); - setCaption(__VYM " - " +tr ("Note Editor","Window caption")); + setCaption(vymName +" - " +tr ("Note Editor","Window caption")); connect(e, SIGNAL(currentCharFormatChanged(const QTextCharFormat &)), @@ -454,7 +456,7 @@ { if (e->text().length()) { - QMessageBox mb( __VYM " - " +tr("Note Editor"), + QMessageBox mb( vymName + " - " +tr("Note Editor"), "Loading will overwrite the existing note", QMessageBox::Warning, QMessageBox::Yes | QMessageBox::Default, @@ -558,7 +560,7 @@ QFile file (fn); if (file.exists()) { - QMessageBox mb( __VYM, + QMessageBox mb( vymName, tr("The file %1\nexists already.\nDo you want to overwrite it?","dialog 'save note as'").arg(fn), QMessageBox::Warning, QMessageBox::Yes | QMessageBox::Default, @@ -633,7 +635,7 @@ QFile file (fn); if (file.exists()) { - QMessageBox mb( __VYM, + QMessageBox mb( vymName, tr("The file %1\nexists already.\nDo you want to overwrite it?","dialog 'save note as'").arg(fn), QMessageBox::Warning, QMessageBox::Yes | QMessageBox::Default, diff -r 7c3ee77f4449 -r 53efc2562a7d version.cpp --- a/version.cpp Mon Nov 20 12:12:00 2006 +0000 +++ b/version.cpp Mon Nov 20 12:12:02 2006 +0000 @@ -32,4 +32,4 @@ return false; return true; -} \ No newline at end of file +} diff -r 7c3ee77f4449 -r 53efc2562a7d version.h --- a/version.h Mon Nov 20 12:12:00 2006 +0000 +++ b/version.h Mon Nov 20 12:12:02 2006 +0000 @@ -3,9 +3,9 @@ #include <QString> -#define __VYM "VYM" +#define __VYM_NAME "VYM" #define __VYM_VERSION "1.8.59" -#define __BUILD_DATE "November 16, 2006" +#define __VYM_BUILD_DATE "November 20, 2006" bool checkVersion(const QString &); diff -r 7c3ee77f4449 -r 53efc2562a7d xml.cpp --- a/xml.cpp Mon Nov 20 12:12:00 2006 +0000 +++ b/xml.cpp Mon Nov 20 12:12:02 2006 +0000 @@ -3,14 +3,12 @@ #include <qmessagebox.h> #include <qcolor.h> #include <q3stylesheet.h> -//Added by qt3to4: #include <QTextStream> #include <iostream> #include "misc.h" #include "settings.h" #include "linkablemapobj.h" - #include "version.h" static BranchObj *lastBranch; @@ -18,6 +16,7 @@ static OrnamentedObj *lastOO; extern Settings settings; +extern QString vymVersion; mapBuilderHandler::mapBuilderHandler() {} @@ -67,7 +66,7 @@ "<h3>Map is newer than VYM</h3>" "<p>The map you are just trying to load was " "saved using vym " +atts.value("version")+". " - "The version of this vym is " __VYM_VERSION + "The version of this vym is " + vymVersion + ". If you run into problems after pressing " "the ok-button below, updating vym should help."); else