# HG changeset patch # User insilmaril # Date 1118089662 0 # Node ID 67a91e28b30f32a7553ec45151c8ea942712b4bc # Parent 270593ab83b25c23a1ddf4a8e24b0f43f53f2948 1.6.8 started API to speedup undos diff -r 270593ab83b2 -r 67a91e28b30f api.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/api.cpp Mon Jun 06 20:27:42 2005 +0000 @@ -0,0 +1,38 @@ +#include "api.h" + +#include + +void API::parseCommand (const QString &s,QString &command,QString +¶m) +{ + param=""; + command=""; + QRegExp re; + int pos; + + // Get command + re.setPattern ("(.*)\\s"); + re.setMinimal (false); + pos=re.search (s); + if (pos>=0) + command=re.cap(1); + + // Get parameters + re.setPattern ("\\((.*)\\)"); + pos=re.search (s); + if (pos>=0) + param=re.cap (1); +} + +void API::getString (const QString &s, QString &rs) +{ + // return the string in s, this could be also stored in + // a variable later + QRegExp re("\"(.*)\""); + int pos=re.search (s); + if (pos>=0) + rs=re.cap (1); + else + rs=""; + +} \ No newline at end of file diff -r 270593ab83b2 -r 67a91e28b30f api.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/api.h Mon Jun 06 20:27:42 2005 +0000 @@ -0,0 +1,13 @@ +#ifndef API_H +#define API_H + +#include + +class API +{ +public: + void parseCommand (const QString&, QString &, QString &); + void getString (const QString&, QString &); +}; + +#endif diff -r 270593ab83b2 -r 67a91e28b30f demos/todo.vym Binary file demos/todo.vym has changed diff -r 270593ab83b2 -r 67a91e28b30f mainwindow.cpp --- a/mainwindow.cpp Mon May 30 05:39:10 2005 +0000 +++ b/mainwindow.cpp Mon Jun 06 20:27:42 2005 +0000 @@ -927,13 +927,13 @@ // This will be populated "on demand" in MapEditor::updateActions branchContextMenu->insertSeparator(); branchLinksContextMenu =new QPopupMenu (this); - branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu); - connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) ); - branchLinksContextMenuDup =new QPopupMenu (this); branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup); connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) ); + branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu); + connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) ); + // Context menu for floatimage floatimageContextMenu =new QPopupMenu (this); saveImageFormatMenu=new QPopupMenu (this); diff -r 270593ab83b2 -r 67a91e28b30f mapeditor.cpp --- a/mapeditor.cpp Mon May 30 05:39:10 2005 +0000 +++ b/mapeditor.cpp Mon Jun 06 20:27:42 2005 +0000 @@ -22,6 +22,7 @@ #include "version.h" +#include "api.h" #include "xml.h" #include "texteditor.h" #include "linkablemapobj.h" @@ -571,6 +572,11 @@ void MapEditor::saveState(const SaveMode &mode, LinkableMapObj *part) { + saveState (mode,part,""); +} + +void MapEditor::saveState(const SaveMode &mode, LinkableMapObj *part, const QString &undoCom) +{ // all binary data is saved in bakMapDir (created in Constructor) // the xml data itself is kept in memory in backupXML // @@ -580,11 +586,20 @@ if (mode==PartOfMap && part && (typeid(*part) == typeid (BranchObj) ) ) { - // Writing a vympart only is useful for BranchObj - undoSelection=part; - backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),PartOfMap); + // So far we only test undoCommands for BranchObjs + undoCommand=undoCom; + if (undoCommand!="") + { + undoSelection=part; + } else + { + // Writing a vympart only is useful for BranchObj + undoSelection=part; + backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),PartOfMap); + } } else { + undoCommand=""; undoSelection=NULL; backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),CompleteMap); } @@ -1105,37 +1120,50 @@ selection=NULL; } - mapBuilderHandler handler; - QXmlInputSource source; - source.setData(backupXML); - QXmlSimpleReader reader; - reader.setContentHandler( &handler ); - reader.setErrorHandler( &handler ); - handler.setMapEditor( this ); - handler.setTmpDir ( bakMapDir ); // needed to load files with rel. path - if (undoSelection) + if (undoCommand!="" && undoSelection) { + // We don't need to parse XML backup, but + // do the undoCommand selection=undoSelection; selection->select(); - handler.setLoadMode (ImportReplace); - - } else + parseTest (undoCommand); + + } else { - mapCenter->clear(); - handler.setLoadMode (NewMap); - } - blockreposition=true; - bool ok = reader.parse( source ); - blockreposition=false; - if ( ok ) - mapCenter->reposition(); - - else - { - // This should never ever happen - QMessageBox::critical( 0, tr( "Critical Parse Error by reading backupFile" ), - tr( handler.errorProtocol() )+" in "+backupXML ); - } + // We need to parse saved XML data + mapBuilderHandler handler; + QXmlInputSource source; + source.setData(backupXML); + QXmlSimpleReader reader; + reader.setContentHandler( &handler ); + reader.setErrorHandler( &handler ); + handler.setMapEditor( this ); + handler.setTmpDir ( bakMapDir ); // needed to load files with rel. path + if (undoSelection) + { + selection=undoSelection; + selection->select(); + handler.setLoadMode (ImportReplace); + + } else + { + mapCenter->clear(); + handler.setLoadMode (NewMap); + } + blockreposition=true; + bool ok = reader.parse( source ); + blockreposition=false; + if ( ok ) + mapCenter->reposition(); + + else + { + // This should never ever happen + QMessageBox::critical( 0, tr( "Critical Parse Error by reading backupFile" ), + tr( handler.errorProtocol() )+" in "+backupXML ); + } + } // restoring saved version + // Undo not longer available now actionEditUndo->setEnabled (false); undoSelection=false; @@ -1307,7 +1335,7 @@ if (typeid(*selection) == typeid(BranchObj) ) { setChanged(); - saveState(PartOfMap,selection->getParObj()); + saveState(PartOfMap,selection,"moveBranchDown ()"); bo=(BranchObj*)(selection); par=(BranchObj*)(bo->getParObj()); selection->unselect(); @@ -1328,7 +1356,7 @@ if (typeid(*selection) == typeid(BranchObj) ) { setChanged(); - saveState(PartOfMap,selection->getParObj()); + saveState(PartOfMap,selection,"moveBranchUp ()"); bo=(BranchObj*)(selection); par=(BranchObj*)(bo->getParObj()); selection->unselect(); @@ -2779,9 +2807,32 @@ } } +#include "api.h" + void MapEditor::testFunction() { cout << "MapEditor::testFunction() called\n"; + if (selection && + (typeid(*selection) == typeid(BranchObj)) ) + { + QString s=((BranchObj*)(selection))->getHeading(); + parseTest (s); + } +} + +void MapEditor::parseTest(const QString &s) +{ + API api; + QString c,p,p0; + api.parseCommand (s,c,p); + if (c==QString("moveBranchUp")) + moveBranchUp(); + else if (c=="moveBranchDown") + moveBranchDown(); + else if (c=="select") + select (p); + else + cout << "Don't know about command \""< ~/.qt/vymrc + +\section{\vym on Mac OS X} +\subsection{Overview} +Basically there are two ways to run \vym on Macs: +\subsubsection{QT Mac Edition:} + \vym here provides the well known Mac look and feel. \vym is + available as zipped Mac OS X application. It has been compiled and + tested in Mac~OS~10.3, but should also work on Tiger. It is using + the Mac version of Trolltechs QT library. +\subsubsection{X11} + \vym can also be run using the Linux version, but then menus and + handling will also be those of the Linux version e.g. The menu bar + will look different. + +%TODO Concept on Mac context menu, shortcuts... + \section{History of \vym} \subsection{Future} There are lots of features which might find their way into \vym. @@ -729,7 +759,7 @@ 1.6.5 & - & removing a branch and keeping its childs & 2005-05-19 \\ & - & removing childs of a branch & \\ & - & insert branch and make selection its child& \\ - & - & restructured branch context menu & \\ + & - & restructured branch context menu in a basic version (straight line) & 2005-04-15\\ & - & New shortcuts for use on Mac OS X & \\ & - & Importing directories generates vymlinks now & \\ diff -r 270593ab83b2 -r 67a91e28b30f version.h --- a/version.h Mon May 30 05:39:10 2005 +0000 +++ b/version.h Mon Jun 06 20:27:42 2005 +0000 @@ -1,7 +1,7 @@ #ifndef VERSION_H #define VERSION_H -#define __VYM_VERSION__ "1.6.7" -#define __BUILD_DATE__ "May 27, 2005" +#define __VYM_VERSION__ "1.6.8" +#define __BUILD_DATE__ "June 06, 2005" #endif diff -r 270593ab83b2 -r 67a91e28b30f vym.pro --- a/vym.pro Mon May 30 05:39:10 2005 +0000 +++ b/vym.pro Mon Jun 06 20:27:42 2005 +0000 @@ -3,7 +3,8 @@ CONFIG += qt warn_on release -HEADERS += branchobj.h \ +HEADERS += api.h \ + branchobj.h \ exports.h \ findwindow.h \ flagobj.h \ @@ -30,7 +31,8 @@ settings.h \ options.h -SOURCES += branchobj.cpp \ +SOURCES += api.cpp \ + branchobj.cpp \ exports.cpp \ findwindow.cpp \ flagobj.cpp \