# HG changeset patch # User insilmaril # Date 1128943225 0 # Node ID 325958acb69b3bc937dc3b36fc4931758b545233 # Parent 4244bcd9e6ea73a1384b7ceb3bec8f33ef1ac902 New mechanism for clipboard diff -r 4244bcd9e6ea -r 325958acb69b branchobj.cpp --- a/branchobj.cpp Thu Sep 22 12:56:05 2005 +0000 +++ b/branchobj.cpp Mon Oct 10 11:20:25 2005 +0000 @@ -569,18 +569,17 @@ void BranchObj::positionBBox() { - // TODO testing (optimization) - /* + /*// TODO testing (optimization) QString h=getHeading(); if (!h.isEmpty()) cout << "BO::positionBBox("<positionBBox(); - systemFlags->positionBBox(); - standardFlags->positionBBox(); + // Position contents by moving OO + OrnamentedObj::move (absPos.x(),absPos.y()); + // It seems that setting x,y also affects width,height int w_old=bbox.width(); int h_old=bbox.height(); @@ -654,6 +653,11 @@ void BranchObj::setHeading(QString s) { +/* FIXME testing only + cout << "BO::setHeading ("<setColor (color); t->setZ(Z_TEXT); t->setText(s); + t->setTextFlags(Qt::AlignLeft); t->show(); return t; } diff -r 4244bcd9e6ea -r 325958acb69b linkablemapobj.cpp --- a/linkablemapobj.cpp Thu Sep 22 12:56:05 2005 +0000 +++ b/linkablemapobj.cpp Mon Oct 10 11:20:25 2005 +0000 @@ -653,7 +653,7 @@ void LinkableMapObj::alignRelativeTo (QPoint ref) { - // TODO testing, seems not to be used right now... + // FIXME testing, seems not to be used right now... cout << "LMO::alignRelTo ref="<setIcon (QPixmap (vym_editor_xpm)); if (textEditor->showWithMain()) textEditor->show(); - clipboardME = new MapEditor(); - clipboardME->resize (800,600); - clipboardME->setCaption("VYM - clipboard"); - clipboardME->hide(); - - // Initialize mainwindow after Mapeditors (because of Flags) + // Initialize mainwindow Main m; //m.resize(m.sizeHint()); m.setIcon (QPixmap (vym_logo_xpm)); diff -r 4244bcd9e6ea -r 325958acb69b mainwindow.cpp --- a/mainwindow.cpp Thu Sep 22 12:56:05 2005 +0000 +++ b/mainwindow.cpp Mon Oct 10 11:20:25 2005 +0000 @@ -19,6 +19,7 @@ #include #include +#include "misc.h" #include "version.h" #include "aboutdialog.h" @@ -43,10 +44,29 @@ #include "icons/modelink.xpm" #include "icons/modecopy.xpm" //#include "icons/vym-48x48.xpm" + +#include "icons/flag-questionmark.xpm" +#include "icons/flag-exclamationmark.xpm" +#include "icons/flag-hook-green.xpm" +#include "icons/flag-cross-red.xpm" +#include "icons/flag-stopsign.xpm" +#include "icons/flag-smiley-good.xpm" +#include "icons/flag-smiley-sad.xpm" +#include "icons/flag-clock.xpm" +#include "icons/flag-lamp.xpm" +#include "icons/flag-arrow-up.xpm" +#include "icons/flag-arrow-down.xpm" +#include "icons/flag-thumb-up.xpm" +#include "icons/flag-thumb-down.xpm" +#include "icons/flag-heart.xpm" +#include "icons/flag-flash.xpm" +#include "icons/flag-lifebelt.xpm" + #include "icons/flag-note.xpm" #include "icons/flag-url.xpm" #include "icons/flag-vymlink.xpm" #include "icons/flag-scrolled-right.xpm" +#include "icons/flag-tmpUnscrolled-right.xpm" #include "flagrowobj.h" #include "texteditor.h" @@ -61,9 +81,12 @@ extern TextEditor *textEditor; extern Main *mainWindow; extern QString tmpVymDir; +extern QString clipboardDir; +extern bool clipboardEmpty; extern int statusbarTime; extern MapEditor *clipboardME; extern FlagRowObj* standardFlagsDefault; +extern FlagRowObj* systemFlagsDefault; extern QPtrList actionListBranches; @@ -172,11 +195,17 @@ // Create unique temporary directory tmpVymDir=makeUniqueDir ("/tmp/vym-XXXXXX"); - // TODO Create direcctory for clipboard + // Create direcctory for clipboard + clipboardDir=tmpVymDir+"/clipboard"; + QDir d(clipboardDir); + d.mkdir (clipboardDir,true); + makeSubDirs (clipboardDir); + clipboardEmpty=true; + // 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 ); + // QTime t = QTime::currentTime(); // set random seed + // srand( t.hour()*12+t.minute()*60+t.second()*60 ); // Initialize some settings, which are platform dependant @@ -246,8 +275,6 @@ connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag())); updateGeometry(); - - // Creating the default map into first tab is done in main.cpp now... } Main::~Main() @@ -792,6 +819,134 @@ // Flag Actions void Main::setupFlagActions() { + // Create System Flags + systemFlagsDefault = new FlagRowObj (); + systemFlagsDefault->setVisibility (false); + systemFlagsDefault->setName ("systemFlagsDef"); + + FlagObj *fo = new FlagObj (); + fo->load(QPixmap(flag_note_xpm)); + fo->setName("note"); + fo->setToolTip(tr("Note","Systemflag")); + systemFlagsDefault->addFlag (fo); // makes deep copy + + fo->load(QPixmap(flag_url_xpm)); + fo->setName("url"); + fo->setToolTip(tr("WWW Document (external)","Systemflag")); + systemFlagsDefault->addFlag (fo); + + fo->load(QPixmap(flag_vymlink_xpm)); + fo->setName("vymLink"); + fo->setToolTip(tr("Link to another vym map","Systemflag")); + systemFlagsDefault->addFlag (fo); + + fo->load(QPixmap(flag_scrolled_right_xpm)); + fo->setName("scrolledright"); + fo->setToolTip(tr("subtree is scrolled","Systemflag")); + systemFlagsDefault->addFlag (fo); + + fo->load(QPixmap(flag_tmpUnscrolled_right_xpm)); + fo->setName("tmpUnscrolledright"); + fo->setToolTip(tr("subtree is temporary scrolled","Systemflag")); + systemFlagsDefault->addFlag (fo); + + // Create Standard Flags + standardFlagsDefault = new FlagRowObj (); + standardFlagsDefault->setVisibility (false); + standardFlagsDefault->setName ("standardFlagsDef"); + + fo->load(QPixmap(flag_exclamationmark_xpm)); + fo->setName ("exclamationmark"); + fo->setGroup("standard-mark"); + fo->setToolTip(tr("Take care!","Standardflag")); + standardFlagsDefault->addFlag (fo); // makes deep copy + + fo->load(QPixmap(flag_questionmark_xpm)); + fo->setName("questionmark"); + fo->setGroup("standard-mark"); + fo->setToolTip(tr("Really?","Standardflag")); + standardFlagsDefault->addFlag (fo); + + fo->load(QPixmap(flag_hook_green_xpm)); + fo->setName("hook-green"); + fo->setGroup("standard-hook"); + fo->setToolTip(tr("ok!","Standardflag")); + standardFlagsDefault->addFlag (fo); + + fo->load(QPixmap(flag_cross_red_xpm)); + fo->setName("cross-red"); + fo->setGroup("standard-hook"); + fo->setToolTip(tr("Not ok!","Standardflag")); + standardFlagsDefault->addFlag (fo); + + fo->load(QPixmap(flag_stopsign_xpm)); + fo->setName("stopsign"); + fo->setToolTip(tr("This won't work!","Standardflag")); + standardFlagsDefault->addFlag (fo); + + fo->load(QPixmap(flag_smiley_good_xpm)); + fo->setName("smiley-good"); + fo->setGroup("standard-smiley"); + fo->setToolTip(tr("Good","Standardflag")); + standardFlagsDefault->addFlag (fo); + + fo->load(QPixmap(flag_smiley_sad_xpm)); + fo->setName("smiley-sad"); + fo->setGroup("standard-smiley"); + fo->setToolTip(tr("Bad","Standardflag")); + standardFlagsDefault->addFlag (fo); + + fo->load(QPixmap(flag_clock_xpm)); + fo->setName("clock"); + fo->setToolTip(tr("Time critical","Standardflag")); + standardFlagsDefault->addFlag (fo); + + fo->load(QPixmap(flag_lamp_xpm)); + fo->setName("lamp"); + fo->setToolTip(tr("Idea!","Standardflag")); + standardFlagsDefault->addFlag (fo); + + fo->load(QPixmap(flag_arrow_up_xpm)); + fo->setName("arrow-up"); + fo->setGroup("standard-arrow"); + fo->setToolTip(tr("Important","Standardflag")); + standardFlagsDefault->addFlag (fo); + + fo->load(QPixmap(flag_arrow_down_xpm)); + fo->setName("arrow-down"); + fo->setGroup("standard-arrow"); + fo->setToolTip(tr("Unimportant","Standardflag")); + standardFlagsDefault->addFlag (fo); + + fo->load(QPixmap(flag_thumb_up_xpm)); + fo->setName("thumb-up"); + fo->setGroup("standard-thumb"); + fo->setToolTip(tr("I like this","Standardflag")); + standardFlagsDefault->addFlag (fo); + + fo->load(QPixmap(flag_thumb_down_xpm)); + fo->setName("thumb-down"); + fo->setGroup("standard-thumb"); + fo->setToolTip(tr("I like this","Standardflag")); + fo->setToolTip(tr("I do not like this","Standardflag")); + standardFlagsDefault->addFlag (fo); + + fo->load(QPixmap(flag_heart_xpm)); + fo->setName("heart"); + fo->setToolTip(tr("I just love... ","Standardflag")); + standardFlagsDefault->addFlag (fo); + + fo->load(QPixmap(flag_flash_xpm)); + fo->setName("flash"); + fo->setToolTip(tr("Dangerous","Standardflag")); + standardFlagsDefault->addFlag (fo); + + fo->load(QPixmap(flag_lifebelt_xpm)); + fo->setName("lifebelt"); + fo->setToolTip(tr("This will help","Standardflag")); + standardFlagsDefault->addFlag (fo); + delete (fo); + standardFlagsDefault->makeToolbar(this, "Standard Flags"); } @@ -860,10 +1015,6 @@ a = new QAction( tr( "Test Flag" ), QPixmap(), tr( "test flag" ), 0, this, "flag" ); connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) ); a->addTo( menu ); - - a = new QAction( tr( "Show Clipboard" ), QPixmap(), tr( "Show clipboard" ), 0, this, "clipboard" ); - connect( a, SIGNAL( activated() ), this, SLOT( testShowClipboard() ) ); - a->addTo( menu ); } // Help Actions @@ -1159,7 +1310,8 @@ tabWidget->addTab (medit,fn); tabWidget->showPage(medit); medit->viewport()->setFocus(); - medit->select("mc:"); + // For the very first map we do not have flagrows yet... + medit->select("mc:"); } void Main::fileLoad(QString fn, const LoadMode &lmode) @@ -2361,11 +2513,6 @@ currentMapEditor()->testFunction(); } -void Main::testShowClipboard() -{ - clipboardME->show(); -} - void Main::helpDoc() { QString docpath; diff -r 4244bcd9e6ea -r 325958acb69b mainwindow.h --- a/mainwindow.h Thu Sep 22 12:56:05 2005 +0000 +++ b/mainwindow.h Mon Oct 10 11:20:25 2005 +0000 @@ -162,7 +162,6 @@ void standardFlagChanged(); void testFunction(); - void testShowClipboard(); void helpDoc(); void helpAbout(); diff -r 4244bcd9e6ea -r 325958acb69b mapcenterobj.cpp --- a/mapcenterobj.cpp Thu Sep 22 12:56:05 2005 +0000 +++ b/mapcenterobj.cpp Mon Oct 10 11:20:25 2005 +0000 @@ -33,7 +33,6 @@ { BranchObj::init(); orientation=OrientUndef; - absPos=QPoint (canvas->width()/2, canvas->height()/2); // FIXME this should be done in TextObj later... //QFont font ("Sans Serif,16,-1,5,50,0,0,0,0,0"); @@ -41,9 +40,7 @@ depth=0; setDefAttr(MovedBranch); - frame->setFrameType (Rectangle); - move (absPos.x(), absPos.y() ); } void MapCenterObj::move (double x, double y) @@ -54,7 +51,8 @@ void MapCenterObj::moveBy (double x, double y) { - BranchObj::moveBy(x,y); + //BranchObj::moveBy(x,y); + move (x+absPos.x(),y+absPos.y() ); positionBBox(); } @@ -144,9 +142,6 @@ s+=standardFlags->saveToDir(tmpdir+"/flags", "/standardFlag-", verbose); s=s+valueElement("heading", getHeading(),a); - // Reset the counters before saving - FloatImageObj (canvas).resetSaveCounter(); - // add link to file in s if (!note.isEmpty() ) s+=note.saveToDir(); @@ -159,7 +154,7 @@ // Save FloatImages FloatImageObj *fio; for (fio=floatimage.first(); fio; fio=floatimage.next() ) - s+=fio->saveToDir (tmpdir,prefix); + s+=fio->saveToDir (tmpdir,prefix,offset); // Save XLinks XLinkObj *xlo; diff -r 4244bcd9e6ea -r 325958acb69b mapeditor.cpp --- a/mapeditor.cpp Thu Sep 22 12:56:05 2005 +0000 +++ b/mapeditor.cpp Mon Oct 10 11:20:25 2005 +0000 @@ -37,35 +37,15 @@ #include "editxlinkdialog.h" #include "settings.h" -#include "icons/flag-note.xpm" -#include "icons/flag-url.xpm" -#include "icons/flag-vymlink.xpm" -#include "icons/flag-scrolled-right.xpm" -#include "icons/flag-tmpUnscrolled-right.xpm" -#include "icons/flag-questionmark.xpm" -#include "icons/flag-exclamationmark.xpm" -#include "icons/flag-hook-green.xpm" -#include "icons/flag-cross-red.xpm" -#include "icons/flag-stopsign.xpm" -#include "icons/flag-smiley-good.xpm" -#include "icons/flag-smiley-sad.xpm" -#include "icons/flag-clock.xpm" -#include "icons/flag-lamp.xpm" -#include "icons/flag-arrow-up.xpm" -#include "icons/flag-arrow-down.xpm" -#include "icons/flag-thumb-up.xpm" -#include "icons/flag-thumb-down.xpm" -#include "icons/flag-heart.xpm" -#include "icons/flag-flash.xpm" -#include "icons/flag-lifebelt.xpm" extern TextEditor *textEditor; extern int statusbarTime; extern Main *mainWindow; extern QString tmpVymDir; +extern QString clipboardDir; +extern bool clipboardEmpty; extern FlagRowObj *systemFlagsDefault; extern FlagRowObj *standardFlagsDefault; -extern MapEditor *clipboardME; extern QPtrList actionListBranches; @@ -155,6 +135,7 @@ mapCanvas = new QCanvas(1000,800); mapCanvas->setAdvancePeriod(30); + mapCanvas->setBackgroundColor (white); setCanvas (mapCanvas); @@ -162,147 +143,11 @@ setVScrollBarMode ( QScrollView::AlwaysOn ); setHScrollBarMode ( QScrollView::AlwaysOn ); - // Now create the _global_ system flags _once_: - // (Later all OrnamentedObj copy from this - // and set their own canvas) - if (!systemFlagsDefault) - { - systemFlagsDefault = new FlagRowObj (mapCanvas); - systemFlagsDefault->setVisibility (false); - systemFlagsDefault->setName ("systemFlagsDef"); - - FlagObj *fo = new FlagObj (mapCanvas); - fo->load(QPixmap(flag_note_xpm)); - fo->setName("note"); - fo->setToolTip(tr("Note","Systemflag")); - systemFlagsDefault->addFlag (fo); // makes deep copy - - fo->load(QPixmap(flag_url_xpm)); - fo->setName("url"); - fo->setToolTip(tr("WWW Document (external)","Systemflag")); - systemFlagsDefault->addFlag (fo); - - fo->load(QPixmap(flag_vymlink_xpm)); - fo->setName("vymLink"); - fo->setToolTip(tr("Link to another vym map","Systemflag")); - systemFlagsDefault->addFlag (fo); - - fo->load(QPixmap(flag_scrolled_right_xpm)); - fo->setName("scrolledright"); - fo->setToolTip(tr("subtree is scrolled","Systemflag")); - systemFlagsDefault->addFlag (fo); - - fo->load(QPixmap(flag_tmpUnscrolled_right_xpm)); - fo->setName("tmpUnscrolledright"); - fo->setToolTip(tr("subtree is temporary scrolled","Systemflag")); - systemFlagsDefault->addFlag (fo); - delete (fo); - } - if (!standardFlagsDefault) - { - standardFlagsDefault = new FlagRowObj (mapCanvas); - standardFlagsDefault->setVisibility (false); - standardFlagsDefault->setName ("standardFlagsDef"); - - FlagObj *fo = new FlagObj (mapCanvas); - fo->load(QPixmap(flag_exclamationmark_xpm)); - fo->setName ("exclamationmark"); - fo->setGroup("standard-mark"); - fo->setToolTip(tr("Take care!","Standardflag")); - standardFlagsDefault->addFlag (fo); // makes deep copy - - fo->load(QPixmap(flag_questionmark_xpm)); - fo->setName("questionmark"); - fo->setGroup("standard-mark"); - fo->setToolTip(tr("Really?","Standardflag")); - standardFlagsDefault->addFlag (fo); - - fo->load(QPixmap(flag_hook_green_xpm)); - fo->setName("hook-green"); - fo->setGroup("standard-hook"); - fo->setToolTip(tr("ok!","Standardflag")); - standardFlagsDefault->addFlag (fo); - - fo->load(QPixmap(flag_cross_red_xpm)); - fo->setName("cross-red"); - fo->setGroup("standard-hook"); - fo->setToolTip(tr("Not ok!","Standardflag")); - standardFlagsDefault->addFlag (fo); - - fo->load(QPixmap(flag_stopsign_xpm)); - fo->setName("stopsign"); - fo->setToolTip(tr("This won't work!","Standardflag")); - standardFlagsDefault->addFlag (fo); - - fo->load(QPixmap(flag_smiley_good_xpm)); - fo->setName("smiley-good"); - fo->setGroup("standard-smiley"); - fo->setToolTip(tr("Good","Standardflag")); - standardFlagsDefault->addFlag (fo); - - fo->load(QPixmap(flag_smiley_sad_xpm)); - fo->setName("smiley-sad"); - fo->setGroup("standard-smiley"); - fo->setToolTip(tr("Bad","Standardflag")); - standardFlagsDefault->addFlag (fo); - - fo->load(QPixmap(flag_clock_xpm)); - fo->setName("clock"); - fo->setToolTip(tr("Time critical","Standardflag")); - standardFlagsDefault->addFlag (fo); - - fo->load(QPixmap(flag_lamp_xpm)); - fo->setName("lamp"); - fo->setToolTip(tr("Idea!","Standardflag")); - standardFlagsDefault->addFlag (fo); - - fo->load(QPixmap(flag_arrow_up_xpm)); - fo->setName("arrow-up"); - fo->setGroup("standard-arrow"); - fo->setToolTip(tr("Important","Standardflag")); - standardFlagsDefault->addFlag (fo); - - fo->load(QPixmap(flag_arrow_down_xpm)); - fo->setName("arrow-down"); - fo->setGroup("standard-arrow"); - fo->setToolTip(tr("Unimportant","Standardflag")); - standardFlagsDefault->addFlag (fo); - - fo->load(QPixmap(flag_thumb_up_xpm)); - fo->setName("thumb-up"); - fo->setGroup("standard-thumb"); - fo->setToolTip(tr("I like this","Standardflag")); - standardFlagsDefault->addFlag (fo); - - fo->load(QPixmap(flag_thumb_down_xpm)); - fo->setName("thumb-down"); - fo->setGroup("standard-thumb"); - fo->setToolTip(tr("I like this","Standardflag")); - fo->setToolTip(tr("I do not like this","Standardflag")); - standardFlagsDefault->addFlag (fo); - - fo->load(QPixmap(flag_heart_xpm)); - fo->setName("heart"); - fo->setToolTip(tr("I just love... ","Standardflag")); - standardFlagsDefault->addFlag (fo); - - fo->load(QPixmap(flag_flash_xpm)); - fo->setName("flash"); - fo->setToolTip(tr("Dangerous","Standardflag")); - standardFlagsDefault->addFlag (fo); - - fo->load(QPixmap(flag_lifebelt_xpm)); - fo->setName("lifebelt"); - fo->setToolTip(tr("This will help","Standardflag")); - standardFlagsDefault->addFlag (fo); - delete (fo); - - } - mapCenter = new MapCenterObj(mapCanvas); mapCenter->setVisibility (true); mapCenter->setMapEditor (this); mapCenter->setHeading (tr("New Map","Heading of mapcenter in new map")); + mapCenter->move(mapCanvas->width()/2-mapCenter->width()/2,mapCanvas->height()/2-mapCenter->width()/2); printer=NULL; @@ -315,7 +160,6 @@ defXLinkColor=QColor (180,180,180); linkcolorhint=DefaultColor; linkstyle=StylePolyParabel; - mapCanvas->setBackgroundColor (white); // Create bitmap cursors, patform dependant #if defined(Q_OS_MACX) @@ -468,6 +312,7 @@ mapCanvas->resize (cw,ch); if ( (dx!=0) || (dy!=0) ) { + cout << "ME:: canvas="<moveAllBy(dx,dy); mapCenter->reposition(); @@ -495,16 +340,6 @@ removeDir (QDir(tmpMapDir)); } - -void MapEditor::makeSubDirs(const QString &s) -{ - QDir d(s); - d.mkdir(s); - d.mkdir ("images"); - d.mkdir ("flags"); -} - - QString MapEditor::saveToDir(const QString &tmpdir, const QString &prefix, bool writeflags, const QPoint &offset, LinkableMapObj *saveSelection) { // tmpdir temporary directory to which data will be written @@ -512,8 +347,6 @@ // writeflags Only write flags for "real" save of map, not undo // offset offset of bbox of whole map in canvas. // Needed for XML export - // completeMap if false, only vympart will be written, without - // mapcenter // Save Header QString ls; @@ -555,6 +388,9 @@ // Find the used flags while traversing the tree standardFlagsDefault->resetUsedCounter(); + // Reset the counters before saving + FloatImageObj (mapCanvas).resetSaveCounter(); + // Build xml recursivly if (!saveSelection) s+=mapCenter->saveToDir(tmpdir,prefix,writeflags,offset); @@ -562,8 +398,10 @@ { if ( typeid(*saveSelection) == typeid(BranchObj) ) s+=((BranchObj*)(saveSelection))->saveToDir(tmpdir,prefix,offset); - else - if (selection && typeid(*selection)==typeid(BranchObj)) + else if ( typeid(*saveSelection) == typeid(FloatImageObj) ) + s+=((FloatImageObj*)(saveSelection))->saveToDir(tmpdir,prefix,offset); + + else if (selection && typeid(*selection)==typeid(BranchObj)) // This is used if selected branch is saved from mainwindow s+=((BranchObj*)selection)->saveToDir(tmpdir,prefix,offset); } @@ -921,7 +759,7 @@ return destPath; } -int MapEditor::load (QString &fname, const LoadMode &lmode) +int MapEditor::load (QString fname, LoadMode lmode) { // Finish open lineEdits if (lineedit) finishedLineEditNoSave(); @@ -1394,59 +1232,27 @@ if (selection) { - if (typeid(*selection) == typeid(BranchObj) ) + // write to directory + QString clipfile="part"; + QString saveFile=saveToDir (fileDir,clipfile+"-",true,QPoint(),selection); + QFile file; + + file.setName ( clipboardDir + "/"+clipfile+".xml"); + if ( !file.open( IO_WriteOnly ) ) { - BranchObj* to; - BranchObj* from; - clipboardME->clear(); - clipboardME->getMapCenter()->addBranch(); - to=clipboardME->getMapCenter()->getLastBranch(); - if (to) - { - from=(BranchObj*)selection; - to->copy(from); - - // keep position relative to parent - to->move2RelPos ( from->getRelPos()); - - // select data in clipboard - // clipboardME->select ("bo:0"); - - // repositioning makes testing nicer, - // but is not needed usually: - if (clipboardME->isVisible()) - clipboardME->getMapCenter()->reposition(); - else - clipboardME->hide(); - } - } - /* FIXME rewrite this using import/export - Currently there is a bug which would erase note, if - branchobj in clipboard is selected... - if (typeid(*selection) == typeid(FloatImageObj) ) - { - FloatImageObj* to; - FloatImageObj* from; - clipboardME->clear(); - clipboardME->getMapCenter()->addFloatImage(); - to=clipboardME->getMapCenter()->getLastFloatImage(); - if (to) - { - from=(FloatImageObj*)selection; - to->copy(from); - - // select data in clipboard - clipboardME->select ("fi:0"); - - // repositioning makes testing nicer, - // but is not needed usually: - if (clipboardME->isVisible()) - clipboardME->getMapCenter()->reposition(); - else - clipboardME->hide(); - } - } - */ + // This should neverever happen + QMessageBox::critical (0,tr("Critical Export Error"),tr("MapEditor::exportXML couldn't open %1").arg(file.name())); + return; + } + + // Write it finally, and write in UTF8, no matter what + QTextStream ts( &file ); + ts.setEncoding (QTextStream::UnicodeUTF8); + ts << saveFile; + file.close(); + + clipboardEmpty=false; + updateActions(); } } @@ -1618,74 +1424,30 @@ } } -LinkableMapObj* MapEditor::pasteNoSave() +void MapEditor::pasteNoSave() { // Finish open lineEdits if (lineedit) finishedLineEditNoSave(); - clipboardME->select ("bo:0"); - LinkableMapObj *fromLMO=clipboardME->getSelection(); - LinkableMapObj *returnLMO=NULL; - - if (selection && fromLMO) - { - if (typeid(*fromLMO) == typeid(BranchObj) ) - { - if (typeid(*selection) == typeid(MapCenterObj)) - { - returnLMO=mapCenter->addBranch( (BranchObj*)(fromLMO) ); - ((BranchObj*)(returnLMO))->move2RelPos(normalise(fromLMO->getRelPos() ) ); - } - if (typeid(*selection) == typeid(BranchObj)) - returnLMO=((BranchObj*)selection)->addBranch((BranchObj*)(fromLMO) ); - } - - if (typeid(*fromLMO) == typeid(FloatImageObj) && - (typeid(*selection) == typeid (BranchObj) || - typeid(*selection)==typeid(MapCenterObj)) ) - returnLMO=((BranchObj*) selection)->addFloatImage ((FloatImageObj*)(fromLMO)); - - } - return returnLMO; + load (clipboardDir+"/part.xml",ImportAdd); } void MapEditor::cutNoSave() { - // Finish open lineEdits - if (lineedit) finishedLineEditNoSave(); - - BranchObj* bo; - BranchObj* par; - if (selection != NULL) { - if (typeid(*selection) == typeid(BranchObj) ) - { - bo=(BranchObj*)selection; - par=(BranchObj*)(bo->getParObj()); - bo->unselect(); - selection=NULL; - par->removeBranch(bo); - selection=par; - selection->select(); - } - if (typeid(*selection) == typeid(FloatImageObj) ) - { - FloatImageObj* fio=(FloatImageObj*)selection; - par=(BranchObj*)(fio->getParObj()); - fio->unselect(); - selection=NULL; - par->removeFloatImage(fio); - selection=par; - selection->select(); - } - } + copy(); + deleteSelection(); } void MapEditor::paste() { - saveState(selection); - pasteNoSave(); - mapCenter->reposition(); - adjustCanvasSize(); + if (selection && (typeid(*selection) == typeid(BranchObj) || + typeid(*selection) == typeid(MapCenterObj))) + { + saveState(selection); + pasteNoSave(); + mapCenter->reposition(); + adjustCanvasSize(); + } } void MapEditor::cut() @@ -2807,7 +2569,7 @@ actionEditCopy->setEnabled (true); actionEditCut->setEnabled (true); - if (clipboardME->getMapCenter()->countBranches()>0 || clipboardME->getMapCenter()->countFloatImages()>0) + if (!clipboardEmpty) actionEditPaste->setEnabled (true); else actionEditPaste->setEnabled (false); @@ -3247,8 +3009,7 @@ void MapEditor::testFunction() { cout << "MapEditor::testFunction() called\n"; - QDir d("/fasl"); - removeDir (d); + load (clipboardDir+"/part.xml",ImportAdd); } void MapEditor::ensureSelectionVisible() @@ -3681,7 +3442,7 @@ bs->moveBranchTo ( (BranchObj*)(dst->getParObj()), ((BranchObj*)(dst))->getNum()); } else if (e->state() & QMouseEvent::ControlButton) - { + { bs->moveBranchTo ( (BranchObj*)(dst->getParObj()), ((BranchObj*)(dst))->getNum()+1); } else { @@ -3731,9 +3492,6 @@ void MapEditor::resizeEvent (QResizeEvent* e) { QCanvasView::resizeEvent( e ); - - QString s=""; - if (!fileName.isEmpty()) s=fileName; adjustCanvasSize(); } diff -r 4244bcd9e6ea -r 325958acb69b mapeditor.h --- a/mapeditor.h Thu Sep 22 12:56:05 2005 +0000 +++ b/mapeditor.h Mon Oct 10 11:20:25 2005 +0000 @@ -31,8 +31,6 @@ private: void makeTmpDirs(); // create temporary directories void delTmpDirs(); // delete temporary directories - void makeSubDirs(const QString&); - // create subdirs in dir QString saveToDir(const QString&,const QString &,bool, const QPoint &,LinkableMapObj*); void saveState(); // save actual state to backup void saveState(LinkableMapObj *); @@ -61,7 +59,7 @@ QString getFileName (); // e.g. "map.xml" QString getMapName (); // e.g. "map" QString getDestPath (); // e.g. "/home/tux/map.vym" - int load (QString&, const LoadMode &); // newmap, import/replace selection + int load (QString, LoadMode ); // newmap, import/replace selection public: int save(const SaveMode &); // Save map void setZipped(bool); // save map zipped @@ -82,7 +80,7 @@ void undo(); // undo last action private: void undoXML(const QString &, const QString &); - LinkableMapObj* pasteNoSave(); // paste clipboard to branch + void pasteNoSave(); // paste clipboard to branch void cutNoSave(); // cut to clipboard public: void paste(); // paste clipboard to branch and backup diff -r 4244bcd9e6ea -r 325958acb69b mapobj.cpp --- a/mapobj.cpp Thu Sep 22 12:56:05 2005 +0000 +++ b/mapobj.cpp Mon Oct 10 11:20:25 2005 +0000 @@ -6,9 +6,8 @@ ///////////////////////////////////////////////////////////////// MapObj::MapObj () { - // TODO not used any longer... - cout << "Const MapObj (): Please set canvas somehow!!!\n"; - // canvas=actMapEditor->getCanvas(); + //qWarning ( "Const MapObj (): Please set canvas somehow!!!"); + canvas=NULL; init (); } @@ -94,7 +93,7 @@ { if (p.x() >= bbox.left() && p.x() <= bbox.right() && p.y() <= bbox.bottom() && p.y() >= bbox.top() ) - return true; + return true; return false; } diff -r 4244bcd9e6ea -r 325958acb69b misc.cpp --- a/misc.cpp Thu Sep 22 12:56:05 2005 +0000 +++ b/misc.cpp Mon Oct 10 11:20:25 2005 +0000 @@ -184,6 +184,14 @@ qWarning ("removeDir("+d.path()+") failed!"); } +void makeSubDirs (const QString &s) +{ + QDir d(s); + d.mkdir(s); + d.mkdir ("images"); + d.mkdir ("flags"); +} + // returns masked "<" ">" "&" QString quotemeta(const QString &s) { diff -r 4244bcd9e6ea -r 325958acb69b misc.h --- a/misc.h Thu Sep 22 12:56:05 2005 +0000 +++ b/misc.h Mon Oct 10 11:20:25 2005 +0000 @@ -19,6 +19,7 @@ QString convertToRel (const QString &,const QString &); QString makeUniqueDir (QString); void removeDir(QDir); +void makeSubDirs (const QString &); QString quotemeta(const QString&); int max (int,int); class BranchObj; diff -r 4244bcd9e6ea -r 325958acb69b tex/vym.changelog --- a/tex/vym.changelog Thu Sep 22 12:56:05 2005 +0000 +++ b/tex/vym.changelog Mon Oct 10 11:20:25 2005 +0000 @@ -1,3 +1,16 @@ +------------------------------------------------------------------- +Mon Oct 10 13:18:29 CEST 2005 - uwedr + +- Bugfix: Copy/Paste was currently not possible for images. Now + completly rewrote mechanism. Instead of invisible map now XML import + is used (Multiple clipboards should be not difficult now) + +------------------------------------------------------------------- +Mon Oct 3 10:33:09 CEST 2005 - uwe + +- Bugfix: Added small fix from Khaled Ahmed needed for display of + arabic languages + ------------------------------------------------------------------- Mon Sep 12 21:39:38 CEST 2005 - uwedr @@ -26,10 +39,10 @@ Tue Aug 30 13:38:31 CEST 2005 - uwedr - Bugfix: Fixed pasting vymlinks: Pasting a branch to a target in - another map caused vym to go in an endless loop, if the vymlink of the + another map caused vym to go into an endless loop, if the vymlink of the branch pointed to the new map. -- Bugfix: Invisible floatimages (which have a scrolled parent) can - no longer can be selected +- Bugfix: Invisible floatimages (which have a scrolled parent) no longer + can be selected ------------------------------------------------------------------- Fri Aug 19 09:12:49 CEST 2005 - uwedr diff -r 4244bcd9e6ea -r 325958acb69b version.h --- a/version.h Thu Sep 22 12:56:05 2005 +0000 +++ b/version.h Mon Oct 10 11:20:25 2005 +0000 @@ -2,6 +2,6 @@ #define VERSION_H #define __VYM_VERSION__ "1.7.5" -#define __BUILD_DATE__ "September 22, 2005" +#define __BUILD_DATE__ "October 10, 2005" #endif diff -r 4244bcd9e6ea -r 325958acb69b xml.cpp --- a/xml.cpp Thu Sep 22 12:56:05 2005 +0000 +++ b/xml.cpp Mon Oct 10 11:20:25 2005 +0000 @@ -176,11 +176,10 @@ lastBranch->addFloatImage(); lastFloat=lastBranch->getLastFloatImage(); if (!readFloatImageAttr(atts)) return false; - } else if ( eName == "branch" && state == StateMap) + } else if ( (eName == "branch"||eName=="floatimage") && state == StateMap) { // This is used in vymparts, which have no mapcenter! isVymPart=true; - state=StateBranch; LinkableMapObj* lmo=me->getSelection(); if (!lmo) { @@ -194,17 +193,26 @@ || (typeid(*lmo) == typeid(MapCenterObj) ) ) { lastBranch=(BranchObj*)(lmo); - if (loadMode==ImportAdd) + if (eName=="branch") { - lastBranch->addBranch(); - lastBranch=lastBranch->getLastBranch(); - - } else - lastBranch->clear(); - } else - return false; - branchDepth=1; - readBranchAttr (atts); + state=StateBranch; + if (loadMode==ImportAdd) + { + lastBranch->addBranch(); + lastBranch=lastBranch->getLastBranch(); + + } else + lastBranch->clear(); + branchDepth=1; + readBranchAttr (atts); + } else if (eName=="floatimage") + { + state=StateFloatImage; + lastBranch->addFloatImage(); + lastFloat=lastBranch->getLastFloatImage(); + if (!readFloatImageAttr(atts)) return false; + } else return false; + } else return false; } else if ( eName == "branch" && state == StateMapCenter) { state=StateBranch; @@ -279,6 +287,7 @@ case StateMapCenterHeading: state=StateMapCenter; return true; case StateMapCenterNote: state=StateMapCenter; return true; case StateMapCenterFloatImage: state=StateMapCenter; return true; + case StateFloatImage: state=StateMap; return true; case StateBranch: if (branchDepth>1) { diff -r 4244bcd9e6ea -r 325958acb69b xml.h --- a/xml.h Thu Sep 22 12:56:05 2005 +0000 +++ b/xml.h Mon Oct 10 11:20:25 2005 +0000 @@ -16,7 +16,7 @@ ~mapBuilderHandler(); QString errorProtocol(); bool startDocument(); - QString mapBuilderHandler::parseHREF(QString); + QString parseHREF(QString); bool startElement ( const QString&, const QString&, const QString& eName, const QXmlAttributes& atts ); bool endElement ( const QString&, const QString&, const QString& ); @@ -40,6 +40,7 @@ { StateInit, StateMap, StateMapSelect, StateMapSetting, + StateFloatImage, StateMapCenter, StateMapCenterStandardFlag, StateMapCenterHeading, StateMapCenterNote, StateMapCenterFloatImage,