1.1 --- a/mapeditor.cpp Thu Mar 24 20:48:58 2005 +0000
1.2 +++ b/mapeditor.cpp Thu Mar 24 21:10:38 2005 +0000
1.3 @@ -99,6 +99,7 @@
1.4 extern QActionGroup* actionGroupModModes;
1.5 extern QAction* actionModModeColor;
1.6 extern QAction* actionModModeLink;
1.7 +extern QAction* actionModModeCopy;
1.8
1.9 extern QActionGroup *actionGroupFormatFrameTypes;
1.10 extern QAction *actionFormatFrameNone;
1.11 @@ -155,27 +156,27 @@
1.12 FlagObj *fo = new FlagObj (mapCanvas);
1.13 fo->load(QPixmap(flag_note_xpm));
1.14 fo->setName("note");
1.15 - fo->setToolTip(tr("Note"));
1.16 + fo->setToolTip(tr("Note","Systemflag"));
1.17 systemFlagsDefault->addFlag (fo); // makes deep copy
1.18
1.19 fo->load(QPixmap(flag_url_xpm));
1.20 fo->setName("url");
1.21 - fo->setToolTip(tr("WWW Document (external)"));
1.22 + fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1.23 systemFlagsDefault->addFlag (fo);
1.24
1.25 fo->load(QPixmap(flag_vymlink_xpm));
1.26 fo->setName("vymLink");
1.27 - fo->setToolTip(tr("Link to another vym map"));
1.28 + fo->setToolTip(tr("Link to another vym map","Systemflag"));
1.29 systemFlagsDefault->addFlag (fo);
1.30
1.31 fo->load(QPixmap(flag_scrolled_right_xpm));
1.32 fo->setName("scrolledright");
1.33 - fo->setToolTip(tr("subtree is scrolled"));
1.34 + fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1.35 systemFlagsDefault->addFlag (fo);
1.36
1.37 fo->load(QPixmap(flag_tmpUnscrolled_right_xpm));
1.38 fo->setName("tmpUnscrolledright");
1.39 - fo->setToolTip(tr("subtree is temporary scrolled"));
1.40 + fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1.41 systemFlagsDefault->addFlag (fo);
1.42 delete (fo);
1.43 }
1.44 @@ -188,82 +189,82 @@
1.45 FlagObj *fo = new FlagObj (mapCanvas);
1.46 fo->load(QPixmap(flag_exclamationmark_xpm));
1.47 fo->setName("exclamationmark");
1.48 - fo->setToolTip(tr("Take care!"));
1.49 + fo->setToolTip(tr("Take care!","Standardflag"));
1.50 standardFlagsDefault->addFlag (fo); // makes deep copy
1.51
1.52 fo->load(QPixmap(flag_questionmark_xpm));
1.53 fo->setName("questionmark");
1.54 - fo->setToolTip(tr("Really?"));
1.55 + fo->setToolTip(tr("Really?","Standardflag"));
1.56 standardFlagsDefault->addFlag (fo);
1.57
1.58 fo->load(QPixmap(flag_hook_green_xpm));
1.59 fo->setName("hook-green");
1.60 - fo->setToolTip(tr("ok!"));
1.61 + fo->setToolTip(tr("ok!","Standardflag"));
1.62 standardFlagsDefault->addFlag (fo);
1.63
1.64 fo->load(QPixmap(flag_cross_red_xpm));
1.65 fo->setName("cross-red");
1.66 - fo->setToolTip(tr("Not ok!"));
1.67 + fo->setToolTip(tr("Not ok!","Standardflag"));
1.68 standardFlagsDefault->addFlag (fo);
1.69
1.70 fo->load(QPixmap(flag_stopsign_xpm));
1.71 fo->setName("stopsign");
1.72 - fo->setToolTip(tr("This won't work!"));
1.73 + fo->setToolTip(tr("This won't work!","Standardflag"));
1.74 standardFlagsDefault->addFlag (fo);
1.75
1.76 fo->load(QPixmap(flag_smiley_good_xpm));
1.77 fo->setName("smiley-good");
1.78 - fo->setToolTip(tr("Good"));
1.79 + fo->setToolTip(tr("Good","Standardflag"));
1.80 standardFlagsDefault->addFlag (fo);
1.81
1.82 fo->load(QPixmap(flag_smiley_sad_xpm));
1.83 fo->setName("smiley-sad");
1.84 - fo->setToolTip(tr("Bad"));
1.85 + fo->setToolTip(tr("Bad","Standardflag"));
1.86 standardFlagsDefault->addFlag (fo);
1.87
1.88 fo->load(QPixmap(flag_clock_xpm));
1.89 fo->setName("clock");
1.90 - fo->setToolTip(tr("Time critical"));
1.91 + fo->setToolTip(tr("Time critical","Standardflag"));
1.92 standardFlagsDefault->addFlag (fo);
1.93
1.94 fo->load(QPixmap(flag_lamp_xpm));
1.95 fo->setName("lamp");
1.96 - fo->setToolTip(tr("Idea!"));
1.97 + fo->setToolTip(tr("Idea!","Standardflag"));
1.98 standardFlagsDefault->addFlag (fo);
1.99
1.100 fo->load(QPixmap(flag_arrow_up_xpm));
1.101 fo->setName("arrow-up");
1.102 - fo->setToolTip(tr("Important"));
1.103 + fo->setToolTip(tr("Important","Standardflag"));
1.104 standardFlagsDefault->addFlag (fo);
1.105
1.106 fo->load(QPixmap(flag_arrow_down_xpm));
1.107 fo->setName("arrow-down");
1.108 - fo->setToolTip(tr("Unimportant"));
1.109 + fo->setToolTip(tr("Unimportant","Standardflag"));
1.110 standardFlagsDefault->addFlag (fo);
1.111
1.112 fo->load(QPixmap(flag_thumb_up_xpm));
1.113 fo->setName("thumb-up");
1.114 - fo->setToolTip(tr("I like this"));
1.115 + fo->setToolTip(tr("I like this","Standardflag"));
1.116 standardFlagsDefault->addFlag (fo);
1.117
1.118 fo->load(QPixmap(flag_thumb_down_xpm));
1.119 fo->setName("thumb-down");
1.120 - fo->setToolTip(tr("I do not like this"));
1.121 + fo->setToolTip(tr("I do not like this","Standardflag"));
1.122 standardFlagsDefault->addFlag (fo);
1.123
1.124 fo->load(QPixmap(flag_heart_xpm));
1.125 fo->setName("heart");
1.126 - fo->setToolTip(tr("I just love... "));
1.127 + fo->setToolTip(tr("I just love... ","Standardflag"));
1.128 standardFlagsDefault->addFlag (fo);
1.129
1.130 fo->load(QPixmap(flag_flash_xpm));
1.131 fo->setName("flash");
1.132 - fo->setToolTip(tr("Dangerous"));
1.133 + fo->setToolTip(tr("Dangerous","Standardflag"));
1.134 standardFlagsDefault->addFlag (fo);
1.135
1.136 fo->load(QPixmap(flag_lifebelt_xpm));
1.137 fo->setName("lifebelt");
1.138 - fo->setToolTip(tr("This will help"));
1.139 + fo->setToolTip(tr("This will help","Standardflag"));
1.140 standardFlagsDefault->addFlag (fo);
1.141 delete (fo);
1.142
1.143 @@ -272,7 +273,7 @@
1.144 mapCenter = new MapCenterObj(mapCanvas);
1.145 mapCenter->setVisibility (true);
1.146 mapCenter->setMapEditor (this);
1.147 - mapCenter->setHeading (tr("New Map"));
1.148 + mapCenter->setHeading (tr("New Map","Heading of mapcenter in new map"));
1.149
1.150 printer=NULL;
1.151
1.152 @@ -308,6 +309,7 @@
1.153
1.154 pickingColor=false;
1.155 drawingLink=false;
1.156 + copyingObj=false;
1.157
1.158 editingBO=NULL;
1.159 selection=NULL;
1.160 @@ -1319,11 +1321,10 @@
1.161 saveState(PartOfMap,selection);
1.162
1.163 ensureSelectionVisible();
1.164 - BranchObj *bo=(BranchObj*)(selection);
1.165 editingBO=(BranchObj*)(selection);
1.166 - QPoint p = worldMatrix().map(QPoint (bo->x(),bo->y()));
1.167 + QPoint p = worldMatrix().map(QPoint (editingBO->x(),editingBO->y()));
1.168 lineedit->setGeometry(p.x()-contentsX(),p.y()-contentsY(),200,25);
1.169 - QString s=bo->getHeading();
1.170 + QString s=editingBO->getHeading();
1.171 lineedit->setText(s);
1.172 lineedit->setCursorPosition(1);
1.173 if (actionSettingsAutoselectText->isOn() && !s.isEmpty() && actionSettingsPasteNewHeading->isOn() )
1.174 @@ -2688,6 +2689,39 @@
1.175 void MapEditor::testFunction()
1.176 {
1.177 cout << "MapEditor::testFunction() called\n";
1.178 + if (selection &&
1.179 + (typeid(*selection) == typeid(BranchObj) ||
1.180 + typeid(*selection) == typeid(MapCenterObj) ) )
1.181 + {
1.182 + BranchObj *bo=(BranchObj*)(selection);
1.183 + QPoint p = worldMatrix().map(QPoint (bo->x(),bo->y()));
1.184 + // lineedit->setGeometry(p.x()-contentsX(),p.y()-contentsY(),200,25);
1.185 + QPopupMenu *popupLinks=new QPopupMenu (this);
1.186 + if (bo->countLinks()==0)
1.187 + {
1.188 + popupLinks->clear();
1.189 + popupLinks->insertItem ("No link available");
1.190 +
1.191 + } else
1.192 + {
1.193 + BranchObj *bot;
1.194 + QString s;
1.195 + popupLinks->clear();
1.196 + for (int i=0; i<=bo->countLinks();i++)
1.197 + {
1.198 + bot=bo->linkTargetAt(i);
1.199 + if (bot)
1.200 + {
1.201 + s=bot->getHeading();
1.202 + if (s.length()>25)
1.203 + s=s.left(25)+"...";
1.204 + popupLinks->insertItem (s);
1.205 + }
1.206 + }
1.207 + }
1.208 + popupLinks->exec();
1.209 +
1.210 + }
1.211 }
1.212
1.213 void MapEditor::ensureSelectionVisible()
1.214 @@ -2809,6 +2843,7 @@
1.215 selection->select();
1.216
1.217 adjustCanvasSize();
1.218 +
1.219 }
1.220
1.221 // Check, if systemFlag clicked
1.222 @@ -2837,17 +2872,36 @@
1.223 // Left Button Move Branches
1.224 if (e->button() == QMouseEvent::LeftButton )
1.225 {
1.226 + // If modMode==copy, then we want to "move" the _new_ object around
1.227 + // then we need the offset from p to the _old_ selection, because of tmp
1.228 + if (actionModModeCopy->isOn() &&
1.229 + e->state() & QMouseEvent::ControlButton)
1.230 + {
1.231 + if (typeid(*selection)==typeid(BranchObj) )
1.232 + {
1.233 + copyingObj=true;
1.234 + movingObj_start.setX( p.x() - selection->x() );
1.235 + movingObj_start.setY( p.y() - selection->y() );
1.236 + mapCenter->addBranch ((BranchObj*)(selection));
1.237 + unselect();
1.238 + selection=mapCenter->getLastBranch();
1.239 + selection->select();
1.240 + selection->setParObjTmp ((BranchObj*)(selection),p,1);
1.241 + selection->updateLink();
1.242 + }
1.243 + } else
1.244 + {
1.245 + movingObj_start.setX( p.x() - selection->x() );
1.246 + movingObj_start.setY( p.y() - selection->y() );
1.247 + }
1.248 +
1.249 movingObj=selection;
1.250 - movingObj_start.setX( p.x() - selection->x() );
1.251 - movingObj_start.setY( p.y() - selection->y() );
1.252 } else
1.253 // Middle Button Toggle Scroll
1.254 // (On Mac OS X this won't work, but we still have
1.255 // a button in the toolbar)
1.256 if (e->button() == QMouseEvent::MidButton )
1.257 - {
1.258 toggleScroll();
1.259 - }
1.260 updateActions();
1.261 } else
1.262 { // No MapObj found, we are on the Canvas itself
1.263 @@ -2972,12 +3026,15 @@
1.264 lmosel->setParObjTmp (lmo,p,0);
1.265 } else
1.266 {
1.267 + lmosel->unsetParObjTmp();
1.268 + /*
1.269 if (lmo &&(lmo==selection))
1.270 // Could link to myself (happens sometimes...)
1.271 lmosel->unsetParObjTmp();
1.272 if (!lmo)
1.273 // no Obj under selection, go back to original Parent
1.274 lmosel->unsetParObjTmp();
1.275 + */
1.276 }
1.277 } // depth>0
1.278
1.279 @@ -3078,8 +3135,24 @@
1.280 // Reset the temporary drawn link to the original one
1.281 ((LinkableMapObj*)(selection))->unsetParObjTmp();
1.282
1.283 - if (dst )
1.284 - {
1.285 +
1.286 + if (!dst )
1.287 + {
1.288 + if (copyingObj)
1.289 + {
1.290 + // remove the current selection, if we have no destination
1.291 + selection->unselect();
1.292 + ((BranchObj*)(selection->getParObj()))->removeBranch ((BranchObj*)(selection));
1.293 + if (selectionLast)
1.294 + {
1.295 + selection=selectionLast;
1.296 + selectionLast=NULL;
1.297 + selection->select();
1.298 + }
1.299 + copyingObj=false;
1.300 + }
1.301 + } else
1.302 + {
1.303 setChanged();
1.304 saveState();
1.305 // TODO we also could check, if dest and src are on same branch,
1.306 @@ -3095,21 +3168,21 @@
1.307 );
1.308 //if (selection) selection->select();
1.309 } else
1.310 - if (e->state() & QMouseEvent::ControlButton)
1.311 - {
1.312 - ((BranchObj*)(selection))->moveBranchTo
1.313 - (
1.314 - (BranchObj*)(dst),
1.315 - ((BranchObj*)(dst))->getNum()+1
1.316 - );
1.317 - //if (selection) selection->select();
1.318 - } else
1.319 - {
1.320 - ((BranchObj*)(selection))->moveBranchTo ((BranchObj*)(dst),-1);
1.321 - if (dst->getDepth()==0)
1.322 - ((BranchObj*)(selection))->move (savePos);
1.323 - }
1.324 - }
1.325 + if (e->state() & QMouseEvent::ControlButton)
1.326 + {
1.327 + ((BranchObj*)(selection))->moveBranchTo
1.328 + (
1.329 + (BranchObj*)(dst),
1.330 + ((BranchObj*)(dst))->getNum()+1
1.331 + );
1.332 + //if (selection) selection->select();
1.333 + } else
1.334 + {
1.335 + ((BranchObj*)(selection))->moveBranchTo ((BranchObj*)(dst),-1);
1.336 + if (dst->getDepth()==0)
1.337 + ((BranchObj*)(selection))->move (savePos);
1.338 + }
1.339 + }
1.340 // Draw the original link, before selection was moved around
1.341 mapCenter->reposition();
1.342 }