1.1 --- a/mainwindow.cpp Wed Oct 18 10:45:00 2006 +0000
1.2 +++ b/mainwindow.cpp Tue Oct 24 15:36:38 2006 +0000
1.3 @@ -70,6 +70,9 @@
1.4 move (settings.value( "/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
1.5
1.6
1.7 + // Sometimes we may need to remember old selections
1.8 + prevSelection="";
1.9 +
1.10 // Create unique temporary directory
1.11 bool ok;
1.12 tmpVymDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1.13 @@ -480,16 +483,16 @@
1.14 a->setShortcut (Qt::ALT + Qt::Key_Insert );
1.15 a->setShortcutContext (Qt::WindowShortcut);
1.16 addAction (a);
1.17 - connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchHere() ) );
1.18 + connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
1.19 a->setEnabled (false);
1.20 actionListBranches.append(a);
1.21 - actionEditAddBranchHere=a;
1.22 + actionEditAddBranchBefore=a;
1.23 a = new QAction(tr( "Add branch (insert)" ),this);
1.24 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
1.25 a->setShortcut ( Qt::ALT + Qt::Key_A );
1.26 a->setShortcutContext (Qt::WindowShortcut);
1.27 addAction (a);
1.28 - connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchHere() ) );
1.29 + connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
1.30 actionListBranches.append(a);
1.31
1.32 // Add branch above
1.33 @@ -1437,7 +1440,7 @@
1.34 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1.35 branchAddContextMenu->addAction (actionEditPaste );
1.36 branchAddContextMenu->addAction ( actionEditAddBranch );
1.37 - branchAddContextMenu->addAction ( actionEditAddBranchHere );
1.38 + branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1.39 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1.40 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1.41 branchAddContextMenu->addSeparator();
1.42 @@ -2607,24 +2610,33 @@
1.43 currentMapEditor()->editFATE2URL();
1.44 }
1.45
1.46 +void Main::editHeadingFinished()
1.47 +{
1.48 + // only called from editHeading(), so there is a currentME
1.49 + MapEditor *me=currentMapEditor();
1.50 +
1.51 +#if defined(Q_OS_MACX)
1.52 +#else
1.53 + me->setHeading(lineedit->text());
1.54 +
1.55 + lineedit->releaseKeyboard();
1.56 + lineedit->hide();
1.57 + setFocus();
1.58 +#endif
1.59 + if (!prevSelection.isEmpty()) me->select(prevSelection);
1.60 + prevSelection="";
1.61 +}
1.62 +
1.63 void Main::editHeading()
1.64 {
1.65 - if (lineedit->isVisible())
1.66 + if (currentMapEditor())
1.67 {
1.68 - if (currentMapEditor())
1.69 - {
1.70 - MapEditor *me=currentMapEditor();
1.71 - QString oldSel=me->getSelectString();
1.72 - if (me->select (editSel))
1.73 - me->setHeading(lineedit->text());
1.74 - me->select (oldSel);
1.75 - }
1.76 - lineedit->releaseKeyboard();
1.77 - lineedit->hide();
1.78 - setFocus();
1.79 - } else
1.80 - {
1.81 - if (currentMapEditor())
1.82 + MapEditor *me=currentMapEditor();
1.83 + QString oldSel=me->getSelectString();
1.84 +
1.85 + if (lineedit->isVisible())
1.86 + editHeadingFinished();
1.87 + else
1.88 {
1.89 bool ok;
1.90 QPoint p;
1.91 @@ -2637,30 +2649,30 @@
1.92 QDialog *d =new QDialog(NULL);
1.93 QLineEdit *le=new QLineEdit (d);
1.94 d->setWindowFlags (Qt::FramelessWindowHint);
1.95 - d->setGeometry(p.x(),p.y(),200,25);
1.96 - le->resize (d->size());
1.97 + d->setGeometry(p.x(),p.y(),230,25);
1.98 + le->resize (d->width()-10,d->height());
1.99 le->setText (s);
1.100 le->selectAll();
1.101 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
1.102 d->activateWindow();
1.103 d->exec();
1.104 currentMapEditor()->setHeading (le->text());
1.105 + delete (le);
1.106 + delete (d);
1.107 + editHeadingFinished();
1.108 #else
1.109 p = currentMapEditor()->mapTo(this, currentMapEditor()->worldMatrix().map( p));
1.110 - lineedit->setGeometry(p.x(),p.y(),200,25);
1.111 + lineedit->setGeometry(p.x(),p.y(),230,25);
1.112 lineedit->setText(s);
1.113 lineedit->setCursorPosition(1);
1.114 lineedit->selectAll();
1.115 lineedit->show();
1.116 lineedit->grabKeyboard();
1.117 lineedit->setFocus();
1.118 -
1.119 - editSel=currentMapEditor()->getSelectString();
1.120 #endif
1.121 -
1.122 }
1.123 }
1.124 - }
1.125 + } // currentMapEditor()
1.126 }
1.127
1.128 void Main::openVymLinks(const QStringList &vl)
1.129 @@ -2764,34 +2776,95 @@
1.130 void Main::editUnScrollAll()
1.131 {
1.132 if (currentMapEditor())
1.133 + currentMapEditor()->unScrollAll();
1.134 +}
1.135 +
1.136 +void Main::editNewBranch()
1.137 +{
1.138 + MapEditor *me=currentMapEditor();
1.139 + if (!lineedit->isVisible() && me)
1.140 {
1.141 - currentMapEditor()->unScrollAll();
1.142 + BranchObj *bo=(BranchObj*)me->getSelection();
1.143 + BranchObj *newbo=me->addNewBranch(0);
1.144 +
1.145 + if (newbo)
1.146 + me->select (newbo->getSelectString());
1.147 + else
1.148 + return;
1.149 +
1.150 + if (actionSettingsAutoEdit->isOn())
1.151 + {
1.152 + if (!actionSettingsAutoSelectHeading->isOn())
1.153 + prevSelection=bo->getSelectString();
1.154 + editHeading();
1.155 + }
1.156 }
1.157 }
1.158
1.159 -void Main::editNewBranch()
1.160 +void Main::editNewBranchBefore()
1.161 {
1.162 -
1.163 - if (!lineedit->isVisible() && currentMapEditor())
1.164 - currentMapEditor()->addNewBranch(0);
1.165 -}
1.166 -
1.167 -void Main::editNewBranchHere()
1.168 -{
1.169 - if (currentMapEditor())
1.170 - currentMapEditor()->addNewBranchHere();
1.171 + MapEditor *me=currentMapEditor();
1.172 + if (!lineedit->isVisible() && me)
1.173 + {
1.174 + BranchObj *bo=(BranchObj*)me->getSelection();
1.175 + BranchObj *newbo=me->addNewBranchBefore();
1.176 +
1.177 + if (newbo)
1.178 + me->select (newbo->getSelectString());
1.179 + else
1.180 + return;
1.181 +
1.182 + if (actionSettingsAutoEdit->isOn())
1.183 + {
1.184 + if (!actionSettingsAutoSelectHeading->isOn())
1.185 + prevSelection=bo->getSelectString();
1.186 + editHeading();
1.187 + }
1.188 + }
1.189 }
1.190
1.191 void Main::editNewBranchAbove()
1.192 {
1.193 - if (currentMapEditor())
1.194 - currentMapEditor()->addNewBranch(-1);
1.195 + MapEditor *me=currentMapEditor();
1.196 + if (!lineedit->isVisible() && me)
1.197 + {
1.198 + BranchObj *bo=(BranchObj*)me->getSelection();
1.199 + BranchObj *newbo=me->addNewBranch (-1);
1.200 +
1.201 + if (newbo)
1.202 + me->select (newbo->getSelectString());
1.203 + else
1.204 + return;
1.205 +
1.206 + if (actionSettingsAutoEdit->isOn())
1.207 + {
1.208 + if (!actionSettingsAutoSelectHeading->isOn())
1.209 + prevSelection=bo->getSelectString();
1.210 + editHeading();
1.211 + }
1.212 + }
1.213 }
1.214
1.215 void Main::editNewBranchBelow()
1.216 {
1.217 - if (currentMapEditor())
1.218 - currentMapEditor()->addNewBranch(1);
1.219 + MapEditor *me=currentMapEditor();
1.220 + if (!lineedit->isVisible() && me)
1.221 + {
1.222 + BranchObj *bo=(BranchObj*)me->getSelection();
1.223 + BranchObj *newbo=me->addNewBranch (1);
1.224 +
1.225 + if (newbo)
1.226 + me->select (newbo->getSelectString());
1.227 + else
1.228 + return;
1.229 +
1.230 + if (actionSettingsAutoEdit->isOn())
1.231 + {
1.232 + if (!actionSettingsAutoSelectHeading->isOn())
1.233 + prevSelection=bo->getSelectString();
1.234 + editHeading();
1.235 + }
1.236 + }
1.237 }
1.238
1.239 void Main::editImportAdd()