insilmaril@650
|
1 |
#include <QApplication>
|
insilmaril@687
|
2 |
#include <typeinfo>
|
insilmaril@650
|
3 |
|
insilmaril@721
|
4 |
#include "vymmodel.h"
|
insilmaril@721
|
5 |
|
insilmaril@721
|
6 |
#include "editxlinkdialog.h"
|
insilmaril@721
|
7 |
#include "exports.h"
|
insilmaril@721
|
8 |
#include "exportxhtmldialog.h"
|
insilmaril@721
|
9 |
#include "file.h"
|
insilmaril@650
|
10 |
#include "geometry.h" // for addBBox
|
insilmaril@721
|
11 |
#include "mainwindow.h"
|
insilmaril@721
|
12 |
#include "mapcenterobj.h"
|
insilmaril@721
|
13 |
#include "misc.h"
|
insilmaril@721
|
14 |
#include "parser.h"
|
insilmaril@721
|
15 |
#include "selection.h"
|
insilmaril@721
|
16 |
|
insilmaril@721
|
17 |
|
insilmaril@721
|
18 |
#include "warningdialog.h"
|
insilmaril@721
|
19 |
#include "xml-freemind.h"
|
insilmaril@726
|
20 |
#include "xmlobj.h"
|
insilmaril@721
|
21 |
#include "xml-vym.h"
|
insilmaril@721
|
22 |
|
insilmaril@721
|
23 |
|
insilmaril@721
|
24 |
extern bool debug;
|
insilmaril@721
|
25 |
extern Main *mainWindow;
|
insilmaril@696
|
26 |
extern Settings settings;
|
insilmaril@721
|
27 |
extern QString tmpVymDir;
|
insilmaril@721
|
28 |
|
insilmaril@721
|
29 |
extern TextEditor *textEditor;
|
insilmaril@721
|
30 |
|
insilmaril@721
|
31 |
|
insilmaril@721
|
32 |
extern QString clipboardDir;
|
insilmaril@721
|
33 |
extern QString clipboardFile;
|
insilmaril@721
|
34 |
extern bool clipboardEmpty;
|
insilmaril@721
|
35 |
|
insilmaril@721
|
36 |
extern ImageIO imageIO;
|
insilmaril@721
|
37 |
|
insilmaril@721
|
38 |
extern QString vymName;
|
insilmaril@721
|
39 |
extern QString vymVersion;
|
insilmaril@721
|
40 |
extern QDir vymBaseDir;
|
insilmaril@721
|
41 |
|
insilmaril@721
|
42 |
extern QDir lastImageDir;
|
insilmaril@721
|
43 |
extern QDir lastFileDir;
|
insilmaril@721
|
44 |
|
insilmaril@721
|
45 |
extern FlagRowObj *standardFlagsDefault;
|
insilmaril@721
|
46 |
|
insilmaril@721
|
47 |
extern Settings settings;
|
insilmaril@721
|
48 |
|
insilmaril@721
|
49 |
|
insilmaril@721
|
50 |
|
insilmaril@721
|
51 |
int VymModel::mapNum=0; // make instance
|
insilmaril@696
|
52 |
|
insilmaril@650
|
53 |
VymModel::VymModel()
|
insilmaril@650
|
54 |
{
|
insilmaril@650
|
55 |
// cout << "Const VymModel\n";
|
insilmaril@721
|
56 |
init();
|
insilmaril@650
|
57 |
}
|
insilmaril@650
|
58 |
|
insilmaril@650
|
59 |
|
insilmaril@650
|
60 |
VymModel::~VymModel()
|
insilmaril@650
|
61 |
{
|
insilmaril@650
|
62 |
// cout << "Destr VymModel\n";
|
insilmaril@721
|
63 |
autosaveTimer->stop();
|
insilmaril@721
|
64 |
fileChangedTimer->stop();
|
insilmaril@721
|
65 |
clear();
|
insilmaril@650
|
66 |
}
|
insilmaril@650
|
67 |
|
insilmaril@650
|
68 |
void VymModel::clear()
|
insilmaril@650
|
69 |
{
|
insilmaril@727
|
70 |
cout << "VymModel::clear rows="<<rowCount(index(rootItem))<<endl;
|
insilmaril@721
|
71 |
selection.clear();
|
insilmaril@721
|
72 |
|
insilmaril@727
|
73 |
// Remove stuff
|
insilmaril@727
|
74 |
while (!mapCenters.isEmpty()) // FIXME VM needs to be in treemodel only...
|
insilmaril@665
|
75 |
delete mapCenters.takeFirst();
|
insilmaril@727
|
76 |
|
insilmaril@727
|
77 |
QModelIndex ri=index(rootItem);
|
insilmaril@727
|
78 |
removeRows (0, rowCount(ri),ri);
|
insilmaril@650
|
79 |
}
|
insilmaril@650
|
80 |
|
insilmaril@650
|
81 |
void VymModel::init ()
|
insilmaril@650
|
82 |
{
|
insilmaril@721
|
83 |
// We should have at least one map center to start with
|
insilmaril@727
|
84 |
// addMapCenter(); FIXME VM create this in MapEditor as long as model is part of that
|
insilmaril@727
|
85 |
|
insilmaril@727
|
86 |
// No MapEditor yet
|
insilmaril@727
|
87 |
mapEditor=NULL;
|
insilmaril@721
|
88 |
|
insilmaril@728
|
89 |
// Also no scene yet (should not be needed anyway) FIXME VM
|
insilmaril@728
|
90 |
mapScene=NULL;
|
insilmaril@728
|
91 |
|
insilmaril@721
|
92 |
// History
|
insilmaril@721
|
93 |
mapNum++;
|
insilmaril@721
|
94 |
mapChanged=false;
|
insilmaril@721
|
95 |
mapDefault=true;
|
insilmaril@721
|
96 |
mapUnsaved=false;
|
insilmaril@721
|
97 |
|
insilmaril@721
|
98 |
curStep=0;
|
insilmaril@721
|
99 |
redosAvail=0;
|
insilmaril@721
|
100 |
undosAvail=0;
|
insilmaril@721
|
101 |
|
insilmaril@721
|
102 |
stepsTotal=settings.readNumEntry("/history/stepsTotal",100);
|
insilmaril@721
|
103 |
undoSet.setEntry ("/history/stepsTotal",QString::number(stepsTotal));
|
insilmaril@721
|
104 |
mainWindow->updateHistory (undoSet);
|
insilmaril@721
|
105 |
|
insilmaril@721
|
106 |
// Create tmp dirs
|
insilmaril@721
|
107 |
makeTmpDirectories();
|
insilmaril@721
|
108 |
|
insilmaril@721
|
109 |
// Files
|
insilmaril@721
|
110 |
zipped=true;
|
insilmaril@721
|
111 |
filePath="";
|
insilmaril@721
|
112 |
fileName=tr("unnamed");
|
insilmaril@721
|
113 |
mapName="";
|
insilmaril@721
|
114 |
blockReposition=false;
|
insilmaril@721
|
115 |
blockSaveState=false;
|
insilmaril@721
|
116 |
|
insilmaril@721
|
117 |
autosaveTimer=new QTimer (this);
|
insilmaril@721
|
118 |
connect(autosaveTimer, SIGNAL(timeout()), this, SLOT(autosave()));
|
insilmaril@721
|
119 |
|
insilmaril@721
|
120 |
fileChangedTimer=new QTimer (this);
|
insilmaril@721
|
121 |
fileChangedTimer->start(3000);
|
insilmaril@721
|
122 |
connect(fileChangedTimer, SIGNAL(timeout()), this, SLOT(fileChanged()));
|
insilmaril@721
|
123 |
|
insilmaril@721
|
124 |
|
insilmaril@721
|
125 |
// selections
|
insilmaril@728
|
126 |
selModel=NULL;
|
insilmaril@721
|
127 |
selection.setModel (this);
|
insilmaril@721
|
128 |
selection.unselect();
|
insilmaril@721
|
129 |
|
insilmaril@721
|
130 |
// find routine
|
insilmaril@721
|
131 |
itFind=NULL;
|
insilmaril@721
|
132 |
EOFind=false;
|
insilmaril@696
|
133 |
|
insilmaril@696
|
134 |
// animations
|
insilmaril@696
|
135 |
animationUse=settings.readBoolEntry("/animation/use",false);
|
insilmaril@696
|
136 |
animationTicks=settings.readNumEntry("/animation/ticks",10);
|
insilmaril@696
|
137 |
animationInterval=settings.readNumEntry("/animation/interval",50);
|
insilmaril@696
|
138 |
animObjList.clear();
|
insilmaril@696
|
139 |
animationTimer=new QTimer (this);
|
insilmaril@696
|
140 |
connect(animationTimer, SIGNAL(timeout()), this, SLOT(animate()));
|
insilmaril@696
|
141 |
|
insilmaril@721
|
142 |
// View - map
|
insilmaril@721
|
143 |
defLinkColor=QColor (0,0,255);
|
insilmaril@721
|
144 |
defXLinkColor=QColor (180,180,180);
|
insilmaril@721
|
145 |
linkcolorhint=LinkableMapObj::DefaultColor;
|
insilmaril@721
|
146 |
linkstyle=LinkableMapObj::PolyParabel;
|
insilmaril@721
|
147 |
defXLinkWidth=1;
|
insilmaril@721
|
148 |
defXLinkColor=QColor (230,230,230);
|
insilmaril@721
|
149 |
|
insilmaril@721
|
150 |
hidemode=HideNone;
|
insilmaril@721
|
151 |
|
insilmaril@721
|
152 |
|
insilmaril@721
|
153 |
|
insilmaril@721
|
154 |
// Network
|
insilmaril@721
|
155 |
netstate=Offline;
|
insilmaril@721
|
156 |
|
insilmaril@721
|
157 |
// Create MapCenter
|
insilmaril@727
|
158 |
// addMapCenter(); FIXME VM create this in MapEditor until BO and MCO are independent of scene
|
insilmaril@721
|
159 |
|
insilmaril@650
|
160 |
}
|
insilmaril@650
|
161 |
|
insilmaril@721
|
162 |
void VymModel::makeTmpDirectories()
|
insilmaril@721
|
163 |
{
|
insilmaril@721
|
164 |
// Create unique temporary directories
|
insilmaril@721
|
165 |
tmpMapDir = tmpVymDir+QString("/model-%1").arg(mapNum);
|
insilmaril@721
|
166 |
histPath = tmpMapDir+"/history";
|
insilmaril@721
|
167 |
QDir d;
|
insilmaril@721
|
168 |
d.mkdir (tmpMapDir);
|
insilmaril@721
|
169 |
}
|
insilmaril@721
|
170 |
|
insilmaril@721
|
171 |
|
insilmaril@727
|
172 |
MapEditor* VymModel::getMapEditor() // FIXME VM better return favourite editor here
|
insilmaril@650
|
173 |
{
|
insilmaril@650
|
174 |
return mapEditor;
|
insilmaril@650
|
175 |
}
|
insilmaril@650
|
176 |
|
insilmaril@721
|
177 |
bool VymModel::isRepositionBlocked()
|
insilmaril@650
|
178 |
{
|
insilmaril@721
|
179 |
return blockReposition;
|
insilmaril@650
|
180 |
}
|
insilmaril@650
|
181 |
|
insilmaril@721
|
182 |
void VymModel::updateActions() // FIXME maybe don't update if blockReposition is set
|
insilmaril@650
|
183 |
{
|
insilmaril@721
|
184 |
// Tell mainwindow to update states of actions
|
insilmaril@721
|
185 |
mainWindow->updateActions();
|
insilmaril@650
|
186 |
}
|
insilmaril@650
|
187 |
|
insilmaril@721
|
188 |
|
insilmaril@721
|
189 |
|
insilmaril@721
|
190 |
QString VymModel::saveToDir(const QString &tmpdir, const QString &prefix, bool writeflags, const QPointF &offset, LinkableMapObj *saveSel)
|
insilmaril@650
|
191 |
{
|
insilmaril@721
|
192 |
// tmpdir temporary directory to which data will be written
|
insilmaril@721
|
193 |
// prefix mapname, which will be appended to images etc.
|
insilmaril@721
|
194 |
// writeflags Only write flags for "real" save of map, not undo
|
insilmaril@721
|
195 |
// offset offset of bbox of whole map in scene.
|
insilmaril@721
|
196 |
// Needed for XML export
|
insilmaril@721
|
197 |
|
insilmaril@726
|
198 |
|
insilmaril@726
|
199 |
XMLObj xml;
|
insilmaril@726
|
200 |
|
insilmaril@721
|
201 |
// Save Header
|
insilmaril@721
|
202 |
QString ls;
|
insilmaril@721
|
203 |
switch (linkstyle)
|
insilmaril@721
|
204 |
{
|
insilmaril@721
|
205 |
case LinkableMapObj::Line:
|
insilmaril@721
|
206 |
ls="StyleLine";
|
insilmaril@721
|
207 |
break;
|
insilmaril@721
|
208 |
case LinkableMapObj::Parabel:
|
insilmaril@721
|
209 |
ls="StyleParabel";
|
insilmaril@721
|
210 |
break;
|
insilmaril@721
|
211 |
case LinkableMapObj::PolyLine:
|
insilmaril@721
|
212 |
ls="StylePolyLine";
|
insilmaril@721
|
213 |
break;
|
insilmaril@721
|
214 |
default:
|
insilmaril@721
|
215 |
ls="StylePolyParabel";
|
insilmaril@721
|
216 |
break;
|
insilmaril@721
|
217 |
}
|
insilmaril@721
|
218 |
|
insilmaril@721
|
219 |
QString s="<?xml version=\"1.0\" encoding=\"utf-8\"?><!DOCTYPE vymmap>\n";
|
insilmaril@721
|
220 |
QString colhint="";
|
insilmaril@721
|
221 |
if (linkcolorhint==LinkableMapObj::HeadingColor)
|
insilmaril@726
|
222 |
colhint=xml.attribut("linkColorHint","HeadingColor");
|
insilmaril@726
|
223 |
|
insilmaril@726
|
224 |
QString mapAttr=xml.attribut("version",vymVersion);
|
insilmaril@721
|
225 |
if (!saveSel)
|
insilmaril@726
|
226 |
mapAttr+= xml.attribut("author",author) +
|
insilmaril@726
|
227 |
xml.attribut("comment",comment) +
|
insilmaril@726
|
228 |
xml.attribut("date",getDate()) +
|
insilmaril@726
|
229 |
xml.attribut("backgroundColor", mapScene->backgroundBrush().color().name() ) +
|
insilmaril@728
|
230 |
xml.attribut("selectionColor", mapEditor->getSelectionColor().name() ) +
|
insilmaril@726
|
231 |
xml.attribut("linkStyle", ls ) +
|
insilmaril@726
|
232 |
xml.attribut("linkColor", defLinkColor.name() ) +
|
insilmaril@726
|
233 |
xml.attribut("defXLinkColor", defXLinkColor.name() ) +
|
insilmaril@726
|
234 |
xml.attribut("defXLinkWidth", QString().setNum(defXLinkWidth,10) ) +
|
insilmaril@721
|
235 |
colhint;
|
insilmaril@726
|
236 |
s+=xml.beginElement("vymmap",mapAttr);
|
insilmaril@726
|
237 |
xml.incIndent();
|
insilmaril@721
|
238 |
|
insilmaril@721
|
239 |
// Find the used flags while traversing the tree
|
insilmaril@721
|
240 |
standardFlagsDefault->resetUsedCounter();
|
insilmaril@721
|
241 |
|
insilmaril@721
|
242 |
// Reset the counters before saving
|
insilmaril@721
|
243 |
// TODO constr. of FIO creates lots of objects, better do this in some other way...
|
insilmaril@721
|
244 |
FloatImageObj (mapScene).resetSaveCounter();
|
insilmaril@721
|
245 |
|
insilmaril@721
|
246 |
// Build xml recursivly
|
insilmaril@721
|
247 |
if (!saveSel || typeid (*saveSel) == typeid (MapCenterObj))
|
insilmaril@721
|
248 |
// Save complete map, if saveSel not set
|
insilmaril@721
|
249 |
s+=saveToDir(tmpdir,prefix,writeflags,offset);
|
insilmaril@721
|
250 |
else
|
insilmaril@721
|
251 |
{
|
insilmaril@721
|
252 |
if ( typeid(*saveSel) == typeid(BranchObj) )
|
insilmaril@721
|
253 |
// Save Subtree
|
insilmaril@721
|
254 |
s+=((BranchObj*)(saveSel))->saveToDir(tmpdir,prefix,offset);
|
insilmaril@721
|
255 |
else if ( typeid(*saveSel) == typeid(FloatImageObj) )
|
insilmaril@721
|
256 |
// Save image
|
insilmaril@721
|
257 |
s+=((FloatImageObj*)(saveSel))->saveToDir(tmpdir,prefix);
|
insilmaril@721
|
258 |
}
|
insilmaril@721
|
259 |
|
insilmaril@721
|
260 |
// Save local settings
|
insilmaril@721
|
261 |
s+=settings.getDataXML (destPath);
|
insilmaril@721
|
262 |
|
insilmaril@721
|
263 |
// Save selection
|
insilmaril@721
|
264 |
if (!selection.isEmpty() && !saveSel )
|
insilmaril@726
|
265 |
s+=xml.valueElement("select",selection.getSelectString());
|
insilmaril@726
|
266 |
|
insilmaril@726
|
267 |
xml.decIndent();
|
insilmaril@726
|
268 |
s+=xml.endElement("vymmap");
|
insilmaril@721
|
269 |
|
insilmaril@721
|
270 |
if (writeflags)
|
insilmaril@721
|
271 |
standardFlagsDefault->saveToDir (tmpdir+"/flags/","",writeflags);
|
insilmaril@721
|
272 |
return s;
|
insilmaril@650
|
273 |
}
|
insilmaril@650
|
274 |
|
insilmaril@721
|
275 |
void VymModel::setFilePath(QString fpath, QString destname)
|
insilmaril@650
|
276 |
{
|
insilmaril@721
|
277 |
if (fpath.isEmpty() || fpath=="")
|
insilmaril@721
|
278 |
{
|
insilmaril@721
|
279 |
filePath="";
|
insilmaril@721
|
280 |
fileName="";
|
insilmaril@721
|
281 |
destPath="";
|
insilmaril@721
|
282 |
} else
|
insilmaril@721
|
283 |
{
|
insilmaril@721
|
284 |
filePath=fpath; // becomes absolute path
|
insilmaril@721
|
285 |
fileName=fpath; // gets stripped of path
|
insilmaril@721
|
286 |
destPath=destname; // needed for vymlinks and during load to reset fileChangedTime
|
insilmaril@721
|
287 |
|
insilmaril@721
|
288 |
// If fpath is not an absolute path, complete it
|
insilmaril@721
|
289 |
filePath=QDir(fpath).absPath();
|
insilmaril@721
|
290 |
fileDir=filePath.left (1+filePath.findRev ("/"));
|
insilmaril@721
|
291 |
|
insilmaril@721
|
292 |
// Set short name, too. Search from behind:
|
insilmaril@721
|
293 |
int i=fileName.findRev("/");
|
insilmaril@721
|
294 |
if (i>=0) fileName=fileName.remove (0,i+1);
|
insilmaril@721
|
295 |
|
insilmaril@721
|
296 |
// Forget the .vym (or .xml) for name of map
|
insilmaril@721
|
297 |
mapName=fileName.left(fileName.findRev(".",-1,true) );
|
insilmaril@721
|
298 |
}
|
insilmaril@650
|
299 |
}
|
insilmaril@650
|
300 |
|
insilmaril@721
|
301 |
void VymModel::setFilePath(QString fpath)
|
insilmaril@650
|
302 |
{
|
insilmaril@721
|
303 |
setFilePath (fpath,fpath);
|
insilmaril@650
|
304 |
}
|
insilmaril@650
|
305 |
|
insilmaril@721
|
306 |
QString VymModel::getFilePath()
|
insilmaril@650
|
307 |
{
|
insilmaril@721
|
308 |
return filePath;
|
insilmaril@650
|
309 |
}
|
insilmaril@650
|
310 |
|
insilmaril@721
|
311 |
QString VymModel::getFileName()
|
insilmaril@650
|
312 |
{
|
insilmaril@721
|
313 |
return fileName;
|
insilmaril@650
|
314 |
}
|
insilmaril@650
|
315 |
|
insilmaril@721
|
316 |
QString VymModel::getMapName()
|
insilmaril@721
|
317 |
{
|
insilmaril@721
|
318 |
return mapName;
|
insilmaril@721
|
319 |
}
|
insilmaril@721
|
320 |
|
insilmaril@721
|
321 |
QString VymModel::getDestPath()
|
insilmaril@721
|
322 |
{
|
insilmaril@721
|
323 |
return destPath;
|
insilmaril@721
|
324 |
}
|
insilmaril@721
|
325 |
|
insilmaril@721
|
326 |
ErrorCode VymModel::load (QString fname, const LoadMode &lmode, const FileType &ftype)
|
insilmaril@721
|
327 |
{
|
insilmaril@721
|
328 |
ErrorCode err=success;
|
insilmaril@721
|
329 |
|
insilmaril@721
|
330 |
parseBaseHandler *handler;
|
insilmaril@721
|
331 |
fileType=ftype;
|
insilmaril@721
|
332 |
switch (fileType)
|
insilmaril@721
|
333 |
{
|
insilmaril@721
|
334 |
case VymMap: handler=new parseVYMHandler; break;
|
insilmaril@721
|
335 |
case FreemindMap : handler=new parseFreemindHandler; break;
|
insilmaril@721
|
336 |
default:
|
insilmaril@721
|
337 |
QMessageBox::critical( 0, tr( "Critical Parse Error" ),
|
insilmaril@721
|
338 |
"Unknown FileType in VymModel::load()");
|
insilmaril@721
|
339 |
return aborted;
|
insilmaril@721
|
340 |
}
|
insilmaril@729
|
341 |
|
insilmaril@729
|
342 |
bool zipped_org=zipped;
|
insilmaril@729
|
343 |
|
insilmaril@721
|
344 |
if (lmode==NewMap)
|
insilmaril@721
|
345 |
{
|
insilmaril@721
|
346 |
selection.clear();
|
insilmaril@727
|
347 |
// FIXME VM not needed??? model->setMapEditor(this);
|
insilmaril@721
|
348 |
// (map state is set later at end of load...)
|
insilmaril@721
|
349 |
} else
|
insilmaril@721
|
350 |
{
|
insilmaril@721
|
351 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
352 |
if (!bo) return aborted;
|
insilmaril@721
|
353 |
if (lmode==ImportAdd)
|
insilmaril@721
|
354 |
saveStateChangingPart(
|
insilmaril@721
|
355 |
bo,
|
insilmaril@721
|
356 |
bo,
|
insilmaril@721
|
357 |
QString("addMapInsert (%1)").arg(fname),
|
insilmaril@721
|
358 |
QString("Add map %1 to %2").arg(fname).arg(getObjectName(bo)));
|
insilmaril@721
|
359 |
else
|
insilmaril@721
|
360 |
saveStateChangingPart(
|
insilmaril@721
|
361 |
bo,
|
insilmaril@721
|
362 |
bo,
|
insilmaril@721
|
363 |
QString("addMapReplace(%1)").arg(fname),
|
insilmaril@721
|
364 |
QString("Add map %1 to %2").arg(fname).arg(getObjectName(bo)));
|
insilmaril@721
|
365 |
}
|
insilmaril@721
|
366 |
|
insilmaril@721
|
367 |
|
insilmaril@721
|
368 |
// Create temporary directory for packing
|
insilmaril@721
|
369 |
bool ok;
|
insilmaril@721
|
370 |
QString tmpZipDir=makeTmpDir (ok,"vym-pack");
|
insilmaril@721
|
371 |
if (!ok)
|
insilmaril@721
|
372 |
{
|
insilmaril@721
|
373 |
QMessageBox::critical( 0, tr( "Critical Load Error" ),
|
insilmaril@721
|
374 |
tr("Couldn't create temporary directory before load\n"));
|
insilmaril@721
|
375 |
return aborted;
|
insilmaril@721
|
376 |
}
|
insilmaril@721
|
377 |
|
insilmaril@721
|
378 |
// Try to unzip file
|
insilmaril@721
|
379 |
err=unzipDir (tmpZipDir,fname);
|
insilmaril@721
|
380 |
QString xmlfile;
|
insilmaril@721
|
381 |
if (err==nozip)
|
insilmaril@721
|
382 |
{
|
insilmaril@721
|
383 |
xmlfile=fname;
|
insilmaril@721
|
384 |
zipped=false;
|
insilmaril@721
|
385 |
} else
|
insilmaril@721
|
386 |
{
|
insilmaril@721
|
387 |
zipped=true;
|
insilmaril@721
|
388 |
|
insilmaril@721
|
389 |
// Look for mapname.xml
|
insilmaril@721
|
390 |
xmlfile= fname.left(fname.findRev(".",-1,true));
|
insilmaril@721
|
391 |
xmlfile=xmlfile.section( '/', -1 );
|
insilmaril@721
|
392 |
QFile mfile( tmpZipDir + "/" + xmlfile + ".xml");
|
insilmaril@721
|
393 |
if (!mfile.exists() )
|
insilmaril@721
|
394 |
{
|
insilmaril@721
|
395 |
// mapname.xml does not exist, well,
|
insilmaril@721
|
396 |
// maybe someone renamed the mapname.vym file...
|
insilmaril@721
|
397 |
// Try to find any .xml in the toplevel
|
insilmaril@721
|
398 |
// directory of the .vym file
|
insilmaril@721
|
399 |
QStringList flist=QDir (tmpZipDir).entryList("*.xml");
|
insilmaril@721
|
400 |
if (flist.count()==1)
|
insilmaril@721
|
401 |
{
|
insilmaril@721
|
402 |
// Only one entry, take this one
|
insilmaril@721
|
403 |
xmlfile=tmpZipDir + "/"+flist.first();
|
insilmaril@721
|
404 |
} else
|
insilmaril@721
|
405 |
{
|
insilmaril@721
|
406 |
for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
|
insilmaril@721
|
407 |
*it=tmpZipDir + "/" + *it;
|
insilmaril@721
|
408 |
// TODO Multiple entries, load all (but only the first one into this ME)
|
insilmaril@721
|
409 |
//mainWindow->fileLoadFromTmp (flist);
|
insilmaril@721
|
410 |
//returnCode=1; // Silently forget this attempt to load
|
insilmaril@721
|
411 |
qWarning ("MainWindow::load (fn) multimap found...");
|
insilmaril@721
|
412 |
}
|
insilmaril@721
|
413 |
|
insilmaril@721
|
414 |
if (flist.isEmpty() )
|
insilmaril@721
|
415 |
{
|
insilmaril@721
|
416 |
QMessageBox::critical( 0, tr( "Critical Load Error" ),
|
insilmaril@721
|
417 |
tr("Couldn't find a map (*.xml) in .vym archive.\n"));
|
insilmaril@721
|
418 |
err=aborted;
|
insilmaril@721
|
419 |
}
|
insilmaril@721
|
420 |
} //file doesn't exist
|
insilmaril@721
|
421 |
else
|
insilmaril@721
|
422 |
xmlfile=mfile.name();
|
insilmaril@721
|
423 |
}
|
insilmaril@721
|
424 |
|
insilmaril@721
|
425 |
QFile file( xmlfile);
|
insilmaril@721
|
426 |
|
insilmaril@721
|
427 |
// I am paranoid: file should exist anyway
|
insilmaril@721
|
428 |
// according to check in mainwindow.
|
insilmaril@721
|
429 |
if (!file.exists() )
|
insilmaril@721
|
430 |
{
|
insilmaril@721
|
431 |
QMessageBox::critical( 0, tr( "Critical Parse Error" ),
|
insilmaril@721
|
432 |
tr(QString("Couldn't open map %1").arg(file.name())));
|
insilmaril@721
|
433 |
err=aborted;
|
insilmaril@721
|
434 |
} else
|
insilmaril@721
|
435 |
{
|
insilmaril@721
|
436 |
bool blockSaveStateOrg=blockSaveState;
|
insilmaril@721
|
437 |
blockReposition=true;
|
insilmaril@721
|
438 |
blockSaveState=true;
|
insilmaril@721
|
439 |
QXmlInputSource source( file);
|
insilmaril@721
|
440 |
QXmlSimpleReader reader;
|
insilmaril@721
|
441 |
reader.setContentHandler( handler );
|
insilmaril@721
|
442 |
reader.setErrorHandler( handler );
|
insilmaril@721
|
443 |
handler->setModel ( this);
|
insilmaril@721
|
444 |
|
insilmaril@721
|
445 |
|
insilmaril@721
|
446 |
// We need to set the tmpDir in order to load files with rel. path
|
insilmaril@721
|
447 |
QString tmpdir;
|
insilmaril@721
|
448 |
if (zipped)
|
insilmaril@721
|
449 |
tmpdir=tmpZipDir;
|
insilmaril@721
|
450 |
else
|
insilmaril@721
|
451 |
tmpdir=fname.left(fname.findRev("/",-1));
|
insilmaril@721
|
452 |
handler->setTmpDir (tmpdir);
|
insilmaril@721
|
453 |
handler->setInputFile (file.name());
|
insilmaril@721
|
454 |
handler->setLoadMode (lmode);
|
insilmaril@721
|
455 |
bool ok = reader.parse( source );
|
insilmaril@721
|
456 |
blockReposition=false;
|
insilmaril@721
|
457 |
blockSaveState=blockSaveStateOrg;
|
insilmaril@721
|
458 |
file.close();
|
insilmaril@721
|
459 |
if ( ok )
|
insilmaril@721
|
460 |
{
|
insilmaril@727
|
461 |
reposition(); // FIXME VM reposition the view instead...
|
insilmaril@721
|
462 |
selection.update();
|
insilmaril@721
|
463 |
if (lmode==NewMap)
|
insilmaril@721
|
464 |
{
|
insilmaril@721
|
465 |
mapDefault=false;
|
insilmaril@721
|
466 |
mapChanged=false;
|
insilmaril@721
|
467 |
mapUnsaved=false;
|
insilmaril@721
|
468 |
autosaveTimer->stop();
|
insilmaril@721
|
469 |
}
|
insilmaril@721
|
470 |
|
insilmaril@721
|
471 |
// Reset timestamp to check for later updates of file
|
insilmaril@721
|
472 |
fileChangedTime=QFileInfo (destPath).lastModified();
|
insilmaril@721
|
473 |
} else
|
insilmaril@721
|
474 |
{
|
insilmaril@721
|
475 |
QMessageBox::critical( 0, tr( "Critical Parse Error" ),
|
insilmaril@721
|
476 |
tr( handler->errorProtocol() ) );
|
insilmaril@721
|
477 |
// returnCode=1;
|
insilmaril@721
|
478 |
// Still return "success": the map maybe at least
|
insilmaril@721
|
479 |
// partially read by the parser
|
insilmaril@721
|
480 |
}
|
insilmaril@721
|
481 |
}
|
insilmaril@721
|
482 |
|
insilmaril@721
|
483 |
// Delete tmpZipDir
|
insilmaril@721
|
484 |
removeDir (QDir(tmpZipDir));
|
insilmaril@721
|
485 |
|
insilmaril@729
|
486 |
// Restore original zip state
|
insilmaril@729
|
487 |
zipped=zipped_org;
|
insilmaril@729
|
488 |
|
insilmaril@721
|
489 |
updateActions();
|
insilmaril@721
|
490 |
return err;
|
insilmaril@721
|
491 |
}
|
insilmaril@721
|
492 |
|
insilmaril@721
|
493 |
ErrorCode VymModel::save (const SaveMode &savemode)
|
insilmaril@721
|
494 |
{
|
insilmaril@721
|
495 |
QString tmpZipDir;
|
insilmaril@721
|
496 |
QString mapFileName;
|
insilmaril@721
|
497 |
QString safeFilePath;
|
insilmaril@721
|
498 |
|
insilmaril@721
|
499 |
ErrorCode err=success;
|
insilmaril@721
|
500 |
|
insilmaril@721
|
501 |
if (zipped)
|
insilmaril@721
|
502 |
// save as .xml
|
insilmaril@721
|
503 |
mapFileName=mapName+".xml";
|
insilmaril@721
|
504 |
else
|
insilmaril@721
|
505 |
// use name given by user, even if he chooses .doc
|
insilmaril@721
|
506 |
mapFileName=fileName;
|
insilmaril@721
|
507 |
|
insilmaril@721
|
508 |
// Look, if we should zip the data:
|
insilmaril@721
|
509 |
if (!zipped)
|
insilmaril@721
|
510 |
{
|
insilmaril@721
|
511 |
QMessageBox mb( vymName,
|
insilmaril@721
|
512 |
tr("The map %1\ndid not use the compressed "
|
insilmaril@721
|
513 |
"vym file format.\nWriting it uncompressed will also write images \n"
|
insilmaril@721
|
514 |
"and flags and thus may overwrite files in the "
|
insilmaril@721
|
515 |
"given directory\n\nDo you want to write the map").arg(filePath),
|
insilmaril@721
|
516 |
QMessageBox::Warning,
|
insilmaril@721
|
517 |
QMessageBox::Yes | QMessageBox::Default,
|
insilmaril@721
|
518 |
QMessageBox::No ,
|
insilmaril@721
|
519 |
QMessageBox::Cancel | QMessageBox::Escape);
|
insilmaril@721
|
520 |
mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
|
insilmaril@721
|
521 |
mb.setButtonText( QMessageBox::No, tr("uncompressed") );
|
insilmaril@721
|
522 |
mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
|
insilmaril@721
|
523 |
switch( mb.exec() )
|
insilmaril@721
|
524 |
{
|
insilmaril@721
|
525 |
case QMessageBox::Yes:
|
insilmaril@721
|
526 |
// save compressed (default file format)
|
insilmaril@721
|
527 |
zipped=true;
|
insilmaril@721
|
528 |
break;
|
insilmaril@721
|
529 |
case QMessageBox::No:
|
insilmaril@721
|
530 |
// save uncompressed
|
insilmaril@721
|
531 |
zipped=false;
|
insilmaril@721
|
532 |
break;
|
insilmaril@721
|
533 |
case QMessageBox::Cancel:
|
insilmaril@721
|
534 |
// do nothing
|
insilmaril@721
|
535 |
return aborted;
|
insilmaril@721
|
536 |
break;
|
insilmaril@721
|
537 |
}
|
insilmaril@721
|
538 |
}
|
insilmaril@721
|
539 |
|
insilmaril@721
|
540 |
// First backup existing file, we
|
insilmaril@721
|
541 |
// don't want to add to old zip archives
|
insilmaril@721
|
542 |
QFile f(destPath);
|
insilmaril@721
|
543 |
if (f.exists())
|
insilmaril@721
|
544 |
{
|
insilmaril@721
|
545 |
if ( settings.value ("/mapeditor/writeBackupFile").toBool())
|
insilmaril@721
|
546 |
{
|
insilmaril@721
|
547 |
QString backupFileName(destPath + "~");
|
insilmaril@721
|
548 |
QFile backupFile(backupFileName);
|
insilmaril@721
|
549 |
if (backupFile.exists() && !backupFile.remove())
|
insilmaril@721
|
550 |
{
|
insilmaril@721
|
551 |
QMessageBox::warning(0, tr("Save Error"),
|
insilmaril@721
|
552 |
tr("%1\ncould not be removed before saving").arg(backupFileName));
|
insilmaril@721
|
553 |
}
|
insilmaril@721
|
554 |
else if (!f.rename(backupFileName))
|
insilmaril@721
|
555 |
{
|
insilmaril@721
|
556 |
QMessageBox::warning(0, tr("Save Error"),
|
insilmaril@721
|
557 |
tr("%1\ncould not be renamed before saving").arg(destPath));
|
insilmaril@721
|
558 |
}
|
insilmaril@721
|
559 |
}
|
insilmaril@721
|
560 |
}
|
insilmaril@721
|
561 |
|
insilmaril@721
|
562 |
if (zipped)
|
insilmaril@721
|
563 |
{
|
insilmaril@721
|
564 |
// Create temporary directory for packing
|
insilmaril@721
|
565 |
bool ok;
|
insilmaril@721
|
566 |
tmpZipDir=makeTmpDir (ok,"vym-zip");
|
insilmaril@721
|
567 |
if (!ok)
|
insilmaril@721
|
568 |
{
|
insilmaril@721
|
569 |
QMessageBox::critical( 0, tr( "Critical Load Error" ),
|
insilmaril@721
|
570 |
tr("Couldn't create temporary directory before save\n"));
|
insilmaril@721
|
571 |
return aborted;
|
insilmaril@721
|
572 |
}
|
insilmaril@721
|
573 |
|
insilmaril@721
|
574 |
safeFilePath=filePath;
|
insilmaril@721
|
575 |
setFilePath (tmpZipDir+"/"+ mapName+ ".xml", safeFilePath);
|
insilmaril@721
|
576 |
} // zipped
|
insilmaril@721
|
577 |
|
insilmaril@721
|
578 |
// Create mapName and fileDir
|
insilmaril@721
|
579 |
makeSubDirs (fileDir);
|
insilmaril@721
|
580 |
|
insilmaril@721
|
581 |
QString saveFile;
|
insilmaril@721
|
582 |
if (savemode==CompleteMap || selection.isEmpty())
|
insilmaril@721
|
583 |
{
|
insilmaril@721
|
584 |
// Save complete map
|
insilmaril@721
|
585 |
saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),NULL);
|
insilmaril@721
|
586 |
mapChanged=false;
|
insilmaril@721
|
587 |
mapUnsaved=false;
|
insilmaril@721
|
588 |
autosaveTimer->stop();
|
insilmaril@721
|
589 |
}
|
insilmaril@721
|
590 |
else
|
insilmaril@721
|
591 |
{
|
insilmaril@721
|
592 |
// Save part of map
|
insilmaril@721
|
593 |
if (selection.type()==Selection::FloatImage)
|
insilmaril@721
|
594 |
saveFloatImage();
|
insilmaril@721
|
595 |
else
|
insilmaril@721
|
596 |
saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),selection.getBranch());
|
insilmaril@721
|
597 |
// TODO take care of multiselections
|
insilmaril@721
|
598 |
}
|
insilmaril@721
|
599 |
|
insilmaril@721
|
600 |
if (!saveStringToDisk(fileDir+mapFileName,saveFile))
|
insilmaril@721
|
601 |
{
|
insilmaril@721
|
602 |
err=aborted;
|
insilmaril@721
|
603 |
qWarning ("ME::saveStringToDisk failed!");
|
insilmaril@721
|
604 |
}
|
insilmaril@721
|
605 |
|
insilmaril@721
|
606 |
if (zipped)
|
insilmaril@721
|
607 |
{
|
insilmaril@721
|
608 |
// zip
|
insilmaril@721
|
609 |
if (err==success) err=zipDir (tmpZipDir,destPath);
|
insilmaril@721
|
610 |
|
insilmaril@721
|
611 |
// Delete tmpDir
|
insilmaril@721
|
612 |
removeDir (QDir(tmpZipDir));
|
insilmaril@721
|
613 |
|
insilmaril@721
|
614 |
// Restore original filepath outside of tmp zip dir
|
insilmaril@721
|
615 |
setFilePath (safeFilePath);
|
insilmaril@721
|
616 |
}
|
insilmaril@721
|
617 |
|
insilmaril@721
|
618 |
updateActions();
|
insilmaril@721
|
619 |
fileChangedTime=QFileInfo (destPath).lastModified();
|
insilmaril@721
|
620 |
return err;
|
insilmaril@721
|
621 |
}
|
insilmaril@721
|
622 |
|
insilmaril@721
|
623 |
void VymModel::addMapReplaceInt(const QString &undoSel, const QString &path)
|
insilmaril@721
|
624 |
{
|
insilmaril@721
|
625 |
QString pathDir=path.left(path.findRev("/"));
|
insilmaril@721
|
626 |
QDir d(pathDir);
|
insilmaril@721
|
627 |
QFile file (path);
|
insilmaril@721
|
628 |
|
insilmaril@721
|
629 |
if (d.exists() )
|
insilmaril@721
|
630 |
{
|
insilmaril@721
|
631 |
// We need to parse saved XML data
|
insilmaril@721
|
632 |
parseVYMHandler handler;
|
insilmaril@721
|
633 |
QXmlInputSource source( file);
|
insilmaril@721
|
634 |
QXmlSimpleReader reader;
|
insilmaril@721
|
635 |
reader.setContentHandler( &handler );
|
insilmaril@721
|
636 |
reader.setErrorHandler( &handler );
|
insilmaril@721
|
637 |
handler.setModel ( this);
|
insilmaril@721
|
638 |
handler.setTmpDir ( pathDir ); // needed to load files with rel. path
|
insilmaril@721
|
639 |
if (undoSel.isEmpty())
|
insilmaril@721
|
640 |
{
|
insilmaril@721
|
641 |
unselect();
|
insilmaril@721
|
642 |
clear();
|
insilmaril@721
|
643 |
handler.setLoadMode (NewMap);
|
insilmaril@721
|
644 |
} else
|
insilmaril@721
|
645 |
{
|
insilmaril@721
|
646 |
select (undoSel);
|
insilmaril@721
|
647 |
handler.setLoadMode (ImportReplace);
|
insilmaril@721
|
648 |
}
|
insilmaril@721
|
649 |
blockReposition=true;
|
insilmaril@721
|
650 |
bool ok = reader.parse( source );
|
insilmaril@721
|
651 |
blockReposition=false;
|
insilmaril@721
|
652 |
if (! ok )
|
insilmaril@721
|
653 |
{
|
insilmaril@721
|
654 |
// This should never ever happen
|
insilmaril@721
|
655 |
QMessageBox::critical( 0, tr( "Critical Parse Error while reading %1").arg(path),
|
insilmaril@721
|
656 |
handler.errorProtocol());
|
insilmaril@721
|
657 |
}
|
insilmaril@721
|
658 |
} else
|
insilmaril@721
|
659 |
QMessageBox::critical( 0, tr( "Critical Error" ), tr("Could not read %1").arg(path));
|
insilmaril@721
|
660 |
}
|
insilmaril@721
|
661 |
|
insilmaril@721
|
662 |
void VymModel::addMapInsertInt (const QString &path, int pos)
|
insilmaril@721
|
663 |
{
|
insilmaril@721
|
664 |
BranchObj *sel=selection.getBranch();
|
insilmaril@721
|
665 |
if (sel)
|
insilmaril@721
|
666 |
{
|
insilmaril@721
|
667 |
QString pathDir=path.left(path.findRev("/"));
|
insilmaril@721
|
668 |
QDir d(pathDir);
|
insilmaril@721
|
669 |
QFile file (path);
|
insilmaril@721
|
670 |
|
insilmaril@721
|
671 |
if (d.exists() )
|
insilmaril@721
|
672 |
{
|
insilmaril@721
|
673 |
// We need to parse saved XML data
|
insilmaril@721
|
674 |
parseVYMHandler handler;
|
insilmaril@721
|
675 |
QXmlInputSource source( file);
|
insilmaril@721
|
676 |
QXmlSimpleReader reader;
|
insilmaril@721
|
677 |
reader.setContentHandler( &handler );
|
insilmaril@721
|
678 |
reader.setErrorHandler( &handler );
|
insilmaril@721
|
679 |
handler.setModel (this);
|
insilmaril@721
|
680 |
handler.setTmpDir ( pathDir ); // needed to load files with rel. path
|
insilmaril@721
|
681 |
handler.setLoadMode (ImportAdd);
|
insilmaril@721
|
682 |
blockReposition=true;
|
insilmaril@721
|
683 |
bool ok = reader.parse( source );
|
insilmaril@721
|
684 |
blockReposition=false;
|
insilmaril@721
|
685 |
if (! ok )
|
insilmaril@721
|
686 |
{
|
insilmaril@721
|
687 |
// This should never ever happen
|
insilmaril@721
|
688 |
QMessageBox::critical( 0, tr( "Critical Parse Error while reading %1").arg(path),
|
insilmaril@721
|
689 |
handler.errorProtocol());
|
insilmaril@721
|
690 |
}
|
insilmaril@721
|
691 |
if (sel->getDepth()>0)
|
insilmaril@721
|
692 |
sel->getLastBranch()->linkTo (sel,pos);
|
insilmaril@721
|
693 |
} else
|
insilmaril@721
|
694 |
QMessageBox::critical( 0, tr( "Critical Error" ), tr("Could not read %1").arg(path));
|
insilmaril@721
|
695 |
}
|
insilmaril@721
|
696 |
}
|
insilmaril@721
|
697 |
|
insilmaril@721
|
698 |
FloatImageObj* VymModel::loadFloatImageInt (QString fn)
|
insilmaril@721
|
699 |
{
|
insilmaril@721
|
700 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
701 |
if (bo)
|
insilmaril@721
|
702 |
{
|
insilmaril@721
|
703 |
FloatImageObj *fio;
|
insilmaril@721
|
704 |
bo->addFloatImage();
|
insilmaril@721
|
705 |
fio=bo->getLastFloatImage();
|
insilmaril@721
|
706 |
fio->load(fn);
|
insilmaril@721
|
707 |
reposition();
|
insilmaril@727
|
708 |
// FIXME VM needed? scene()->update();
|
insilmaril@721
|
709 |
return fio;
|
insilmaril@721
|
710 |
}
|
insilmaril@721
|
711 |
return NULL;
|
insilmaril@721
|
712 |
}
|
insilmaril@721
|
713 |
|
insilmaril@721
|
714 |
void VymModel::loadFloatImage ()
|
insilmaril@721
|
715 |
{
|
insilmaril@721
|
716 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
717 |
if (bo)
|
insilmaril@721
|
718 |
{
|
insilmaril@721
|
719 |
|
insilmaril@721
|
720 |
Q3FileDialog *fd=new Q3FileDialog( NULL);
|
insilmaril@721
|
721 |
fd->setMode (Q3FileDialog::ExistingFiles);
|
insilmaril@721
|
722 |
fd->addFilter (QString (tr("Images") + " (*.png *.bmp *.xbm *.jpg *.png *.xpm *.gif *.pnm)"));
|
insilmaril@721
|
723 |
ImagePreview *p =new ImagePreview (fd);
|
insilmaril@721
|
724 |
fd->setContentsPreviewEnabled( TRUE );
|
insilmaril@721
|
725 |
fd->setContentsPreview( p, p );
|
insilmaril@721
|
726 |
fd->setPreviewMode( Q3FileDialog::Contents );
|
insilmaril@721
|
727 |
fd->setCaption(vymName+" - " +tr("Load image"));
|
insilmaril@721
|
728 |
fd->setDir (lastImageDir);
|
insilmaril@721
|
729 |
fd->show();
|
insilmaril@721
|
730 |
|
insilmaril@721
|
731 |
if ( fd->exec() == QDialog::Accepted )
|
insilmaril@721
|
732 |
{
|
insilmaril@721
|
733 |
// TODO loadFIO in QT4 use: lastImageDir=fd->directory();
|
insilmaril@721
|
734 |
lastImageDir=QDir (fd->dirPath());
|
insilmaril@721
|
735 |
QString s;
|
insilmaril@721
|
736 |
FloatImageObj *fio;
|
insilmaril@721
|
737 |
for (int j=0; j<fd->selectedFiles().count(); j++)
|
insilmaril@721
|
738 |
{
|
insilmaril@721
|
739 |
s=fd->selectedFiles().at(j);
|
insilmaril@721
|
740 |
fio=loadFloatImageInt (s);
|
insilmaril@721
|
741 |
if (fio)
|
insilmaril@721
|
742 |
saveState(
|
insilmaril@721
|
743 |
(LinkableMapObj*)fio,
|
insilmaril@721
|
744 |
"delete ()",
|
insilmaril@721
|
745 |
bo,
|
insilmaril@721
|
746 |
QString ("loadImage (%1)").arg(s ),
|
insilmaril@721
|
747 |
QString("Add image %1 to %2").arg(s).arg(getObjectName(bo))
|
insilmaril@721
|
748 |
);
|
insilmaril@721
|
749 |
else
|
insilmaril@721
|
750 |
// TODO loadFIO error handling
|
insilmaril@721
|
751 |
qWarning ("Failed to load "+s);
|
insilmaril@721
|
752 |
}
|
insilmaril@721
|
753 |
}
|
insilmaril@721
|
754 |
delete (p);
|
insilmaril@721
|
755 |
delete (fd);
|
insilmaril@721
|
756 |
}
|
insilmaril@721
|
757 |
}
|
insilmaril@721
|
758 |
|
insilmaril@721
|
759 |
void VymModel::saveFloatImageInt (FloatImageObj *fio, const QString &type, const QString &fn)
|
insilmaril@721
|
760 |
{
|
insilmaril@721
|
761 |
fio->save (fn,type);
|
insilmaril@721
|
762 |
}
|
insilmaril@721
|
763 |
|
insilmaril@721
|
764 |
void VymModel::saveFloatImage ()
|
insilmaril@721
|
765 |
{
|
insilmaril@721
|
766 |
FloatImageObj *fio=selection.getFloatImage();
|
insilmaril@721
|
767 |
if (fio)
|
insilmaril@721
|
768 |
{
|
insilmaril@721
|
769 |
QFileDialog *fd=new QFileDialog( NULL);
|
insilmaril@721
|
770 |
fd->setFilters (imageIO.getFilters());
|
insilmaril@721
|
771 |
fd->setCaption(vymName+" - " +tr("Save image"));
|
insilmaril@721
|
772 |
fd->setFileMode( QFileDialog::AnyFile );
|
insilmaril@721
|
773 |
fd->setDirectory (lastImageDir);
|
insilmaril@721
|
774 |
// fd->setSelection (fio->getOriginalFilename());
|
insilmaril@721
|
775 |
fd->show();
|
insilmaril@721
|
776 |
|
insilmaril@721
|
777 |
QString fn;
|
insilmaril@721
|
778 |
if ( fd->exec() == QDialog::Accepted && fd->selectedFiles().count()==1)
|
insilmaril@721
|
779 |
{
|
insilmaril@721
|
780 |
fn=fd->selectedFiles().at(0);
|
insilmaril@721
|
781 |
if (QFile (fn).exists() )
|
insilmaril@721
|
782 |
{
|
insilmaril@721
|
783 |
QMessageBox mb( vymName,
|
insilmaril@721
|
784 |
tr("The file %1 exists already.\n"
|
insilmaril@721
|
785 |
"Do you want to overwrite it?").arg(fn),
|
insilmaril@721
|
786 |
QMessageBox::Warning,
|
insilmaril@721
|
787 |
QMessageBox::Yes | QMessageBox::Default,
|
insilmaril@721
|
788 |
QMessageBox::Cancel | QMessageBox::Escape,
|
insilmaril@721
|
789 |
QMessageBox::NoButton );
|
insilmaril@721
|
790 |
|
insilmaril@721
|
791 |
mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
|
insilmaril@721
|
792 |
mb.setButtonText( QMessageBox::No, tr("Cancel"));
|
insilmaril@721
|
793 |
switch( mb.exec() )
|
insilmaril@721
|
794 |
{
|
insilmaril@721
|
795 |
case QMessageBox::Yes:
|
insilmaril@721
|
796 |
// save
|
insilmaril@721
|
797 |
break;
|
insilmaril@721
|
798 |
case QMessageBox::Cancel:
|
insilmaril@721
|
799 |
// do nothing
|
insilmaril@721
|
800 |
delete (fd);
|
insilmaril@721
|
801 |
return;
|
insilmaril@721
|
802 |
break;
|
insilmaril@721
|
803 |
}
|
insilmaril@721
|
804 |
}
|
insilmaril@721
|
805 |
saveFloatImageInt (fio,fd->selectedFilter(),fn );
|
insilmaril@721
|
806 |
}
|
insilmaril@721
|
807 |
delete (fd);
|
insilmaril@721
|
808 |
}
|
insilmaril@721
|
809 |
}
|
insilmaril@721
|
810 |
|
insilmaril@721
|
811 |
|
insilmaril@721
|
812 |
void VymModel::importDirInt(BranchObj *dst, QDir d)
|
insilmaril@721
|
813 |
{
|
insilmaril@721
|
814 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
815 |
if (bo)
|
insilmaril@721
|
816 |
{
|
insilmaril@721
|
817 |
// Traverse directories
|
insilmaril@721
|
818 |
d.setFilter( QDir::Dirs| QDir::Hidden | QDir::NoSymLinks );
|
insilmaril@721
|
819 |
QFileInfoList list = d.entryInfoList();
|
insilmaril@721
|
820 |
QFileInfo fi;
|
insilmaril@721
|
821 |
|
insilmaril@721
|
822 |
for (int i = 0; i < list.size(); ++i)
|
insilmaril@721
|
823 |
{
|
insilmaril@721
|
824 |
fi=list.at(i);
|
insilmaril@721
|
825 |
if (fi.fileName() != "." && fi.fileName() != ".." )
|
insilmaril@721
|
826 |
{
|
insilmaril@721
|
827 |
dst->addBranch();
|
insilmaril@721
|
828 |
bo=dst->getLastBranch();
|
insilmaril@721
|
829 |
bo->setHeading (fi.fileName() );
|
insilmaril@721
|
830 |
bo->setColor (QColor("blue"));
|
insilmaril@721
|
831 |
bo->toggleScroll();
|
insilmaril@721
|
832 |
if ( !d.cd(fi.fileName()) )
|
insilmaril@721
|
833 |
QMessageBox::critical (0,tr("Critical Import Error"),tr("Cannot find the directory %1").arg(fi.fileName()));
|
insilmaril@721
|
834 |
else
|
insilmaril@721
|
835 |
{
|
insilmaril@721
|
836 |
// Recursively add subdirs
|
insilmaril@721
|
837 |
importDirInt (bo,d);
|
insilmaril@721
|
838 |
d.cdUp();
|
insilmaril@721
|
839 |
}
|
insilmaril@721
|
840 |
}
|
insilmaril@721
|
841 |
}
|
insilmaril@721
|
842 |
// Traverse files
|
insilmaril@721
|
843 |
d.setFilter( QDir::Files| QDir::Hidden | QDir::NoSymLinks );
|
insilmaril@721
|
844 |
list = d.entryInfoList();
|
insilmaril@721
|
845 |
|
insilmaril@721
|
846 |
for (int i = 0; i < list.size(); ++i)
|
insilmaril@721
|
847 |
{
|
insilmaril@721
|
848 |
fi=list.at(i);
|
insilmaril@721
|
849 |
dst->addBranch();
|
insilmaril@721
|
850 |
bo=dst->getLastBranch();
|
insilmaril@721
|
851 |
bo->setHeading (fi.fileName() );
|
insilmaril@721
|
852 |
bo->setColor (QColor("black"));
|
insilmaril@721
|
853 |
if (fi.fileName().right(4) == ".vym" )
|
insilmaril@721
|
854 |
bo->setVymLink (fi.filePath());
|
insilmaril@721
|
855 |
}
|
insilmaril@721
|
856 |
}
|
insilmaril@721
|
857 |
}
|
insilmaril@721
|
858 |
|
insilmaril@721
|
859 |
void VymModel::importDirInt (const QString &s)
|
insilmaril@721
|
860 |
{
|
insilmaril@721
|
861 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
862 |
if (bo)
|
insilmaril@721
|
863 |
{
|
insilmaril@721
|
864 |
saveStateChangingPart (bo,bo,QString ("importDir (\"%1\")").arg(s),QString("Import directory structure from %1").arg(s));
|
insilmaril@721
|
865 |
|
insilmaril@721
|
866 |
QDir d(s);
|
insilmaril@721
|
867 |
importDirInt (bo,d);
|
insilmaril@721
|
868 |
}
|
insilmaril@721
|
869 |
}
|
insilmaril@721
|
870 |
|
insilmaril@721
|
871 |
void VymModel::importDir()
|
insilmaril@721
|
872 |
{
|
insilmaril@721
|
873 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
874 |
if (bo)
|
insilmaril@721
|
875 |
{
|
insilmaril@721
|
876 |
QStringList filters;
|
insilmaril@721
|
877 |
filters <<"VYM map (*.vym)";
|
insilmaril@721
|
878 |
QFileDialog *fd=new QFileDialog( NULL,vymName+ " - " +tr("Choose directory structure to import"));
|
insilmaril@721
|
879 |
fd->setMode (QFileDialog::DirectoryOnly);
|
insilmaril@721
|
880 |
fd->setFilters (filters);
|
insilmaril@721
|
881 |
fd->setCaption(vymName+" - " +tr("Choose directory structure to import"));
|
insilmaril@721
|
882 |
fd->show();
|
insilmaril@721
|
883 |
|
insilmaril@721
|
884 |
QString fn;
|
insilmaril@721
|
885 |
if ( fd->exec() == QDialog::Accepted )
|
insilmaril@721
|
886 |
{
|
insilmaril@721
|
887 |
importDirInt (fd->selectedFile() );
|
insilmaril@721
|
888 |
reposition();
|
insilmaril@727
|
889 |
//FIXME VM needed? scene()->update();
|
insilmaril@721
|
890 |
}
|
insilmaril@721
|
891 |
}
|
insilmaril@721
|
892 |
}
|
insilmaril@721
|
893 |
|
insilmaril@721
|
894 |
|
insilmaril@721
|
895 |
void VymModel::autosave()
|
insilmaril@721
|
896 |
{
|
insilmaril@721
|
897 |
QDateTime now=QDateTime().currentDateTime();
|
insilmaril@721
|
898 |
|
insilmaril@721
|
899 |
// Disable autosave, while we have gone back in history
|
insilmaril@721
|
900 |
int redosAvail=undoSet.readNumEntry (QString("/history/redosAvail"));
|
insilmaril@721
|
901 |
if (redosAvail>0) return;
|
insilmaril@721
|
902 |
|
insilmaril@721
|
903 |
// Also disable autosave for new map without filename
|
insilmaril@721
|
904 |
if (filePath.isEmpty()) return;
|
insilmaril@721
|
905 |
|
insilmaril@721
|
906 |
|
insilmaril@721
|
907 |
if (mapUnsaved &&mapChanged && settings.value ("/autosave/use",true).toBool() )
|
insilmaril@721
|
908 |
{
|
insilmaril@721
|
909 |
if (QFileInfo(filePath).lastModified()<=fileChangedTime)
|
insilmaril@721
|
910 |
mainWindow->fileSave (this);
|
insilmaril@721
|
911 |
else
|
insilmaril@721
|
912 |
if (debug)
|
insilmaril@721
|
913 |
cout <<" ME::autosave rejected, file on disk is newer than last save.\n";
|
insilmaril@721
|
914 |
|
insilmaril@721
|
915 |
}
|
insilmaril@721
|
916 |
}
|
insilmaril@721
|
917 |
|
insilmaril@721
|
918 |
void VymModel::fileChanged()
|
insilmaril@721
|
919 |
{
|
insilmaril@721
|
920 |
// Check if file on disk has changed meanwhile
|
insilmaril@721
|
921 |
if (!filePath.isEmpty())
|
insilmaril@721
|
922 |
{
|
insilmaril@721
|
923 |
QDateTime tmod=QFileInfo (filePath).lastModified();
|
insilmaril@721
|
924 |
if (tmod>fileChangedTime)
|
insilmaril@721
|
925 |
{
|
insilmaril@727
|
926 |
// FIXME VM switch to current mapeditor and finish lineedits...
|
insilmaril@721
|
927 |
QMessageBox mb( vymName,
|
insilmaril@721
|
928 |
tr("The file of the map on disk has changed:\n\n"
|
insilmaril@721
|
929 |
" %1\n\nDo you want to reload that map with the new file?").arg(filePath),
|
insilmaril@721
|
930 |
QMessageBox::Question,
|
insilmaril@721
|
931 |
QMessageBox::Yes ,
|
insilmaril@721
|
932 |
QMessageBox::Cancel | QMessageBox::Default,
|
insilmaril@721
|
933 |
QMessageBox::NoButton );
|
insilmaril@721
|
934 |
|
insilmaril@721
|
935 |
mb.setButtonText( QMessageBox::Yes, tr("Reload"));
|
insilmaril@721
|
936 |
mb.setButtonText( QMessageBox::No, tr("Ignore"));
|
insilmaril@721
|
937 |
switch( mb.exec() )
|
insilmaril@721
|
938 |
{
|
insilmaril@721
|
939 |
case QMessageBox::Yes:
|
insilmaril@721
|
940 |
// Reload map
|
insilmaril@721
|
941 |
load (filePath,NewMap,fileType);
|
insilmaril@721
|
942 |
case QMessageBox::Cancel:
|
insilmaril@721
|
943 |
fileChangedTime=tmod; // allow autosave to overwrite newer file!
|
insilmaril@721
|
944 |
}
|
insilmaril@721
|
945 |
}
|
insilmaril@721
|
946 |
}
|
insilmaril@721
|
947 |
}
|
insilmaril@721
|
948 |
|
insilmaril@721
|
949 |
bool VymModel::isDefault()
|
insilmaril@721
|
950 |
{
|
insilmaril@721
|
951 |
return mapDefault;
|
insilmaril@721
|
952 |
}
|
insilmaril@721
|
953 |
|
insilmaril@721
|
954 |
void VymModel::makeDefault()
|
insilmaril@721
|
955 |
{
|
insilmaril@721
|
956 |
mapChanged=false;
|
insilmaril@721
|
957 |
mapDefault=true;
|
insilmaril@721
|
958 |
}
|
insilmaril@721
|
959 |
|
insilmaril@721
|
960 |
bool VymModel::hasChanged()
|
insilmaril@721
|
961 |
{
|
insilmaril@721
|
962 |
return mapChanged;
|
insilmaril@721
|
963 |
}
|
insilmaril@721
|
964 |
|
insilmaril@721
|
965 |
void VymModel::setChanged()
|
insilmaril@721
|
966 |
{
|
insilmaril@721
|
967 |
if (!mapChanged)
|
insilmaril@721
|
968 |
autosaveTimer->start(settings.value("/autosave/ms/",300000).toInt());
|
insilmaril@721
|
969 |
mapChanged=true;
|
insilmaril@721
|
970 |
mapDefault=false;
|
insilmaril@721
|
971 |
mapUnsaved=true;
|
insilmaril@721
|
972 |
findReset();
|
insilmaril@721
|
973 |
}
|
insilmaril@721
|
974 |
|
insilmaril@721
|
975 |
|
insilmaril@721
|
976 |
QString VymModel::getObjectName (const LinkableMapObj *lmo)
|
insilmaril@721
|
977 |
{
|
insilmaril@721
|
978 |
QString s;
|
insilmaril@721
|
979 |
if (!lmo) return QString("Error: NULL has no name!");
|
insilmaril@721
|
980 |
|
insilmaril@721
|
981 |
if ((typeid(*lmo) == typeid(BranchObj) ||
|
insilmaril@721
|
982 |
typeid(*lmo) == typeid(MapCenterObj)))
|
insilmaril@721
|
983 |
{
|
insilmaril@721
|
984 |
|
insilmaril@721
|
985 |
s=(((BranchObj*)lmo)->getHeading());
|
insilmaril@721
|
986 |
if (s=="") s="unnamed";
|
insilmaril@721
|
987 |
return QString("branch (%1)").arg(s);
|
insilmaril@721
|
988 |
}
|
insilmaril@721
|
989 |
if ((typeid(*lmo) == typeid(FloatImageObj) ))
|
insilmaril@721
|
990 |
return QString ("floatimage [%1]").arg(((FloatImageObj*)lmo)->getOriginalFilename());
|
insilmaril@721
|
991 |
return QString("Unknown type has no name!");
|
insilmaril@721
|
992 |
}
|
insilmaril@721
|
993 |
|
insilmaril@721
|
994 |
void VymModel::redo()
|
insilmaril@721
|
995 |
{
|
insilmaril@721
|
996 |
// Can we undo at all?
|
insilmaril@721
|
997 |
if (redosAvail<1) return;
|
insilmaril@721
|
998 |
|
insilmaril@721
|
999 |
bool blockSaveStateOrg=blockSaveState;
|
insilmaril@721
|
1000 |
blockSaveState=true;
|
insilmaril@721
|
1001 |
|
insilmaril@721
|
1002 |
redosAvail--;
|
insilmaril@721
|
1003 |
|
insilmaril@721
|
1004 |
if (undosAvail<stepsTotal) undosAvail++;
|
insilmaril@721
|
1005 |
curStep++;
|
insilmaril@721
|
1006 |
if (curStep>stepsTotal) curStep=1;
|
insilmaril@721
|
1007 |
QString undoCommand= undoSet.readEntry (QString("/history/step-%1/undoCommand").arg(curStep));
|
insilmaril@721
|
1008 |
QString undoSelection=undoSet.readEntry (QString("/history/step-%1/undoSelection").arg(curStep));
|
insilmaril@721
|
1009 |
QString redoCommand= undoSet.readEntry (QString("/history/step-%1/redoCommand").arg(curStep));
|
insilmaril@721
|
1010 |
QString redoSelection=undoSet.readEntry (QString("/history/step-%1/redoSelection").arg(curStep));
|
insilmaril@721
|
1011 |
QString comment=undoSet.readEntry (QString("/history/step-%1/comment").arg(curStep));
|
insilmaril@721
|
1012 |
QString version=undoSet.readEntry ("/history/version");
|
insilmaril@721
|
1013 |
|
insilmaril@721
|
1014 |
/* TODO Maybe check for version, if we save the history
|
insilmaril@721
|
1015 |
if (!checkVersion(version))
|
insilmaril@721
|
1016 |
QMessageBox::warning(0,tr("Warning"),
|
insilmaril@721
|
1017 |
tr("Version %1 of saved undo/redo data\ndoes not match current vym version %2.").arg(version).arg(vymVersion));
|
insilmaril@721
|
1018 |
*/
|
insilmaril@721
|
1019 |
|
insilmaril@721
|
1020 |
// Find out current undo directory
|
insilmaril@721
|
1021 |
QString bakMapDir(QString(tmpMapDir+"/undo-%1").arg(curStep));
|
insilmaril@721
|
1022 |
|
insilmaril@721
|
1023 |
if (debug)
|
insilmaril@721
|
1024 |
{
|
insilmaril@721
|
1025 |
cout << "VymModel::redo() begin\n";
|
insilmaril@721
|
1026 |
cout << " undosAvail="<<undosAvail<<endl;
|
insilmaril@721
|
1027 |
cout << " redosAvail="<<redosAvail<<endl;
|
insilmaril@721
|
1028 |
cout << " curStep="<<curStep<<endl;
|
insilmaril@721
|
1029 |
cout << " ---------------------------"<<endl;
|
insilmaril@721
|
1030 |
cout << " comment="<<comment.toStdString()<<endl;
|
insilmaril@721
|
1031 |
cout << " undoCom="<<undoCommand.toStdString()<<endl;
|
insilmaril@721
|
1032 |
cout << " undoSel="<<undoSelection.toStdString()<<endl;
|
insilmaril@721
|
1033 |
cout << " redoCom="<<redoCommand.toStdString()<<endl;
|
insilmaril@721
|
1034 |
cout << " redoSel="<<redoSelection.toStdString()<<endl;
|
insilmaril@721
|
1035 |
cout << " ---------------------------"<<endl<<endl;
|
insilmaril@721
|
1036 |
}
|
insilmaril@721
|
1037 |
|
insilmaril@721
|
1038 |
// select object before redo
|
insilmaril@721
|
1039 |
if (!redoSelection.isEmpty())
|
insilmaril@721
|
1040 |
select (redoSelection);
|
insilmaril@721
|
1041 |
|
insilmaril@721
|
1042 |
|
insilmaril@721
|
1043 |
parseAtom (redoCommand);
|
insilmaril@721
|
1044 |
reposition();
|
insilmaril@721
|
1045 |
|
insilmaril@721
|
1046 |
blockSaveState=blockSaveStateOrg;
|
insilmaril@721
|
1047 |
|
insilmaril@721
|
1048 |
undoSet.setEntry ("/history/undosAvail",QString::number(undosAvail));
|
insilmaril@721
|
1049 |
undoSet.setEntry ("/history/redosAvail",QString::number(redosAvail));
|
insilmaril@721
|
1050 |
undoSet.setEntry ("/history/curStep",QString::number(curStep));
|
insilmaril@721
|
1051 |
undoSet.writeSettings(histPath);
|
insilmaril@721
|
1052 |
|
insilmaril@721
|
1053 |
mainWindow->updateHistory (undoSet);
|
insilmaril@721
|
1054 |
updateActions();
|
insilmaril@721
|
1055 |
|
insilmaril@721
|
1056 |
/* TODO remove testing
|
insilmaril@721
|
1057 |
cout << "ME::redo() end\n";
|
insilmaril@721
|
1058 |
cout << " undosAvail="<<undosAvail<<endl;
|
insilmaril@721
|
1059 |
cout << " redosAvail="<<redosAvail<<endl;
|
insilmaril@721
|
1060 |
cout << " curStep="<<curStep<<endl;
|
insilmaril@721
|
1061 |
cout << " ---------------------------"<<endl<<endl;
|
insilmaril@721
|
1062 |
*/
|
insilmaril@721
|
1063 |
|
insilmaril@721
|
1064 |
|
insilmaril@721
|
1065 |
}
|
insilmaril@721
|
1066 |
|
insilmaril@721
|
1067 |
bool VymModel::isRedoAvailable()
|
insilmaril@721
|
1068 |
{
|
insilmaril@721
|
1069 |
if (undoSet.readNumEntry("/history/redosAvail",0)>0)
|
insilmaril@721
|
1070 |
return true;
|
insilmaril@721
|
1071 |
else
|
insilmaril@721
|
1072 |
return false;
|
insilmaril@721
|
1073 |
}
|
insilmaril@721
|
1074 |
|
insilmaril@721
|
1075 |
void VymModel::undo()
|
insilmaril@721
|
1076 |
{
|
insilmaril@721
|
1077 |
// Can we undo at all?
|
insilmaril@721
|
1078 |
if (undosAvail<1) return;
|
insilmaril@721
|
1079 |
|
insilmaril@721
|
1080 |
mainWindow->statusMessage (tr("Autosave disabled during undo."));
|
insilmaril@721
|
1081 |
|
insilmaril@721
|
1082 |
bool blockSaveStateOrg=blockSaveState;
|
insilmaril@721
|
1083 |
blockSaveState=true;
|
insilmaril@721
|
1084 |
|
insilmaril@721
|
1085 |
QString undoCommand= undoSet.readEntry (QString("/history/step-%1/undoCommand").arg(curStep));
|
insilmaril@721
|
1086 |
QString undoSelection=undoSet.readEntry (QString("/history/step-%1/undoSelection").arg(curStep));
|
insilmaril@721
|
1087 |
QString redoCommand= undoSet.readEntry (QString("/history/step-%1/redoCommand").arg(curStep));
|
insilmaril@721
|
1088 |
QString redoSelection=undoSet.readEntry (QString("/history/step-%1/redoSelection").arg(curStep));
|
insilmaril@721
|
1089 |
QString comment=undoSet.readEntry (QString("/history/step-%1/comment").arg(curStep));
|
insilmaril@721
|
1090 |
QString version=undoSet.readEntry ("/history/version");
|
insilmaril@721
|
1091 |
|
insilmaril@721
|
1092 |
/* TODO Maybe check for version, if we save the history
|
insilmaril@721
|
1093 |
if (!checkVersion(version))
|
insilmaril@721
|
1094 |
QMessageBox::warning(0,tr("Warning"),
|
insilmaril@721
|
1095 |
tr("Version %1 of saved undo/redo data\ndoes not match current vym version %2.").arg(version).arg(vymVersion));
|
insilmaril@721
|
1096 |
*/
|
insilmaril@721
|
1097 |
|
insilmaril@721
|
1098 |
// Find out current undo directory
|
insilmaril@721
|
1099 |
QString bakMapDir(QString(tmpMapDir+"/undo-%1").arg(curStep));
|
insilmaril@721
|
1100 |
|
insilmaril@721
|
1101 |
// select object before undo
|
insilmaril@721
|
1102 |
if (!undoSelection.isEmpty())
|
insilmaril@721
|
1103 |
select (undoSelection);
|
insilmaril@721
|
1104 |
|
insilmaril@721
|
1105 |
if (debug)
|
insilmaril@721
|
1106 |
{
|
insilmaril@721
|
1107 |
cout << "VymModel::undo() begin\n";
|
insilmaril@721
|
1108 |
cout << " undosAvail="<<undosAvail<<endl;
|
insilmaril@721
|
1109 |
cout << " redosAvail="<<redosAvail<<endl;
|
insilmaril@721
|
1110 |
cout << " curStep="<<curStep<<endl;
|
insilmaril@721
|
1111 |
cout << " ---------------------------"<<endl;
|
insilmaril@721
|
1112 |
cout << " comment="<<comment.toStdString()<<endl;
|
insilmaril@721
|
1113 |
cout << " undoCom="<<undoCommand.toStdString()<<endl;
|
insilmaril@721
|
1114 |
cout << " undoSel="<<undoSelection.toStdString()<<endl;
|
insilmaril@721
|
1115 |
cout << " redoCom="<<redoCommand.toStdString()<<endl;
|
insilmaril@721
|
1116 |
cout << " redoSel="<<redoSelection.toStdString()<<endl;
|
insilmaril@721
|
1117 |
cout << " ---------------------------"<<endl<<endl;
|
insilmaril@721
|
1118 |
}
|
insilmaril@721
|
1119 |
parseAtom (undoCommand);
|
insilmaril@721
|
1120 |
reposition();
|
insilmaril@721
|
1121 |
|
insilmaril@721
|
1122 |
undosAvail--;
|
insilmaril@721
|
1123 |
curStep--;
|
insilmaril@721
|
1124 |
if (curStep<1) curStep=stepsTotal;
|
insilmaril@721
|
1125 |
|
insilmaril@721
|
1126 |
redosAvail++;
|
insilmaril@721
|
1127 |
|
insilmaril@721
|
1128 |
blockSaveState=blockSaveStateOrg;
|
insilmaril@721
|
1129 |
/* TODO remove testing
|
insilmaril@721
|
1130 |
cout << "VymModel::undo() end\n";
|
insilmaril@721
|
1131 |
cout << " undosAvail="<<undosAvail<<endl;
|
insilmaril@721
|
1132 |
cout << " redosAvail="<<redosAvail<<endl;
|
insilmaril@721
|
1133 |
cout << " curStep="<<curStep<<endl;
|
insilmaril@721
|
1134 |
cout << " ---------------------------"<<endl<<endl;
|
insilmaril@721
|
1135 |
*/
|
insilmaril@721
|
1136 |
|
insilmaril@721
|
1137 |
undoSet.setEntry ("/history/undosAvail",QString::number(undosAvail));
|
insilmaril@721
|
1138 |
undoSet.setEntry ("/history/redosAvail",QString::number(redosAvail));
|
insilmaril@721
|
1139 |
undoSet.setEntry ("/history/curStep",QString::number(curStep));
|
insilmaril@721
|
1140 |
undoSet.writeSettings(histPath);
|
insilmaril@721
|
1141 |
|
insilmaril@721
|
1142 |
mainWindow->updateHistory (undoSet);
|
insilmaril@721
|
1143 |
updateActions();
|
insilmaril@721
|
1144 |
selection.update();
|
insilmaril@721
|
1145 |
ensureSelectionVisible();
|
insilmaril@721
|
1146 |
}
|
insilmaril@721
|
1147 |
|
insilmaril@721
|
1148 |
bool VymModel::isUndoAvailable()
|
insilmaril@721
|
1149 |
{
|
insilmaril@721
|
1150 |
if (undoSet.readNumEntry("/history/undosAvail",0)>0)
|
insilmaril@721
|
1151 |
return true;
|
insilmaril@721
|
1152 |
else
|
insilmaril@721
|
1153 |
return false;
|
insilmaril@721
|
1154 |
}
|
insilmaril@721
|
1155 |
|
insilmaril@721
|
1156 |
void VymModel::gotoHistoryStep (int i)
|
insilmaril@721
|
1157 |
{
|
insilmaril@721
|
1158 |
// Restore variables
|
insilmaril@721
|
1159 |
int undosAvail=undoSet.readNumEntry (QString("/history/undosAvail"));
|
insilmaril@721
|
1160 |
int redosAvail=undoSet.readNumEntry (QString("/history/redosAvail"));
|
insilmaril@721
|
1161 |
|
insilmaril@721
|
1162 |
if (i<0) i=undosAvail+redosAvail;
|
insilmaril@721
|
1163 |
|
insilmaril@721
|
1164 |
// Clicking above current step makes us undo things
|
insilmaril@721
|
1165 |
if (i<undosAvail)
|
insilmaril@721
|
1166 |
{
|
insilmaril@721
|
1167 |
for (int j=0; j<undosAvail-i; j++) undo();
|
insilmaril@721
|
1168 |
return;
|
insilmaril@721
|
1169 |
}
|
insilmaril@721
|
1170 |
// Clicking below current step makes us redo things
|
insilmaril@721
|
1171 |
if (i>undosAvail)
|
insilmaril@721
|
1172 |
for (int j=undosAvail; j<i; j++)
|
insilmaril@721
|
1173 |
{
|
insilmaril@721
|
1174 |
if (debug) cout << "VymModel::gotoHistoryStep redo "<<j<<"/"<<undosAvail<<" i="<<i<<endl;
|
insilmaril@721
|
1175 |
redo();
|
insilmaril@721
|
1176 |
}
|
insilmaril@721
|
1177 |
|
insilmaril@721
|
1178 |
// And ignore clicking the current row ;-)
|
insilmaril@721
|
1179 |
}
|
insilmaril@721
|
1180 |
|
insilmaril@721
|
1181 |
|
insilmaril@721
|
1182 |
QString VymModel::getHistoryPath()
|
insilmaril@721
|
1183 |
{
|
insilmaril@721
|
1184 |
QString histName(QString("history-%1").arg(curStep));
|
insilmaril@721
|
1185 |
return (tmpMapDir+"/"+histName);
|
insilmaril@721
|
1186 |
}
|
insilmaril@721
|
1187 |
|
insilmaril@721
|
1188 |
void VymModel::saveState(const SaveMode &savemode, const QString &undoSelection, const QString &undoCom, const QString &redoSelection, const QString &redoCom, const QString &comment, LinkableMapObj *saveSel)
|
insilmaril@721
|
1189 |
{
|
insilmaril@721
|
1190 |
sendData(redoCom); //FIXME testing
|
insilmaril@721
|
1191 |
|
insilmaril@721
|
1192 |
// Main saveState
|
insilmaril@721
|
1193 |
|
insilmaril@721
|
1194 |
|
insilmaril@721
|
1195 |
if (blockSaveState) return;
|
insilmaril@721
|
1196 |
|
insilmaril@721
|
1197 |
if (debug) cout << "ME::saveState() for "<<qPrintable (mapName)<<endl;
|
insilmaril@721
|
1198 |
|
insilmaril@721
|
1199 |
// Find out current undo directory
|
insilmaril@721
|
1200 |
if (undosAvail<stepsTotal) undosAvail++;
|
insilmaril@721
|
1201 |
curStep++;
|
insilmaril@721
|
1202 |
if (curStep>stepsTotal) curStep=1;
|
insilmaril@721
|
1203 |
|
insilmaril@721
|
1204 |
QString backupXML="";
|
insilmaril@721
|
1205 |
QString histDir=getHistoryPath();
|
insilmaril@721
|
1206 |
QString bakMapPath=histDir+"/map.xml";
|
insilmaril@721
|
1207 |
|
insilmaril@721
|
1208 |
// Create histDir if not available
|
insilmaril@721
|
1209 |
QDir d(histDir);
|
insilmaril@721
|
1210 |
if (!d.exists())
|
insilmaril@721
|
1211 |
makeSubDirs (histDir);
|
insilmaril@721
|
1212 |
|
insilmaril@721
|
1213 |
// Save depending on how much needs to be saved
|
insilmaril@721
|
1214 |
if (saveSel)
|
insilmaril@721
|
1215 |
backupXML=saveToDir (histDir,mapName+"-",false, QPointF (),saveSel);
|
insilmaril@721
|
1216 |
|
insilmaril@721
|
1217 |
QString undoCommand="";
|
insilmaril@721
|
1218 |
if (savemode==UndoCommand)
|
insilmaril@721
|
1219 |
{
|
insilmaril@721
|
1220 |
undoCommand=undoCom;
|
insilmaril@721
|
1221 |
}
|
insilmaril@721
|
1222 |
else if (savemode==PartOfMap )
|
insilmaril@721
|
1223 |
{
|
insilmaril@721
|
1224 |
undoCommand=undoCom;
|
insilmaril@721
|
1225 |
undoCommand.replace ("PATH",bakMapPath);
|
insilmaril@721
|
1226 |
}
|
insilmaril@721
|
1227 |
|
insilmaril@721
|
1228 |
if (!backupXML.isEmpty())
|
insilmaril@721
|
1229 |
// Write XML Data to disk
|
insilmaril@721
|
1230 |
saveStringToDisk (bakMapPath,backupXML);
|
insilmaril@721
|
1231 |
|
insilmaril@721
|
1232 |
// We would have to save all actions in a tree, to keep track of
|
insilmaril@721
|
1233 |
// possible redos after a action. Possible, but we are too lazy: forget about redos.
|
insilmaril@721
|
1234 |
redosAvail=0;
|
insilmaril@721
|
1235 |
|
insilmaril@721
|
1236 |
// Write the current state to disk
|
insilmaril@721
|
1237 |
undoSet.setEntry ("/history/undosAvail",QString::number(undosAvail));
|
insilmaril@721
|
1238 |
undoSet.setEntry ("/history/redosAvail",QString::number(redosAvail));
|
insilmaril@721
|
1239 |
undoSet.setEntry ("/history/curStep",QString::number(curStep));
|
insilmaril@721
|
1240 |
undoSet.setEntry (QString("/history/step-%1/undoCommand").arg(curStep),undoCommand);
|
insilmaril@721
|
1241 |
undoSet.setEntry (QString("/history/step-%1/undoSelection").arg(curStep),undoSelection);
|
insilmaril@721
|
1242 |
undoSet.setEntry (QString("/history/step-%1/redoCommand").arg(curStep),redoCom);
|
insilmaril@721
|
1243 |
undoSet.setEntry (QString("/history/step-%1/redoSelection").arg(curStep),redoSelection);
|
insilmaril@721
|
1244 |
undoSet.setEntry (QString("/history/step-%1/comment").arg(curStep),comment);
|
insilmaril@721
|
1245 |
undoSet.setEntry (QString("/history/version"),vymVersion);
|
insilmaril@721
|
1246 |
undoSet.writeSettings(histPath);
|
insilmaril@721
|
1247 |
|
insilmaril@721
|
1248 |
if (debug)
|
insilmaril@721
|
1249 |
{
|
insilmaril@721
|
1250 |
// TODO remove after testing
|
insilmaril@721
|
1251 |
//cout << " into="<< histPath.toStdString()<<endl;
|
insilmaril@721
|
1252 |
cout << " stepsTotal="<<stepsTotal<<
|
insilmaril@721
|
1253 |
", undosAvail="<<undosAvail<<
|
insilmaril@721
|
1254 |
", redosAvail="<<redosAvail<<
|
insilmaril@721
|
1255 |
", curStep="<<curStep<<endl;
|
insilmaril@721
|
1256 |
cout << " ---------------------------"<<endl;
|
insilmaril@721
|
1257 |
cout << " comment="<<comment.toStdString()<<endl;
|
insilmaril@721
|
1258 |
cout << " undoCom="<<undoCommand.toStdString()<<endl;
|
insilmaril@721
|
1259 |
cout << " undoSel="<<undoSelection.toStdString()<<endl;
|
insilmaril@721
|
1260 |
cout << " redoCom="<<redoCom.toStdString()<<endl;
|
insilmaril@721
|
1261 |
cout << " redoSel="<<redoSelection.toStdString()<<endl;
|
insilmaril@721
|
1262 |
if (saveSel) cout << " saveSel="<<qPrintable (getSelectString(saveSel))<<endl;
|
insilmaril@721
|
1263 |
cout << " ---------------------------"<<endl;
|
insilmaril@721
|
1264 |
}
|
insilmaril@721
|
1265 |
|
insilmaril@721
|
1266 |
mainWindow->updateHistory (undoSet);
|
insilmaril@721
|
1267 |
setChanged();
|
insilmaril@721
|
1268 |
updateActions();
|
insilmaril@721
|
1269 |
}
|
insilmaril@721
|
1270 |
|
insilmaril@721
|
1271 |
|
insilmaril@721
|
1272 |
void VymModel::saveStateChangingPart(LinkableMapObj *undoSel, LinkableMapObj* redoSel, const QString &rc, const QString &comment)
|
insilmaril@721
|
1273 |
{
|
insilmaril@721
|
1274 |
// save the selected part of the map, Undo will replace part of map
|
insilmaril@721
|
1275 |
QString undoSelection="";
|
insilmaril@721
|
1276 |
if (undoSel)
|
insilmaril@721
|
1277 |
undoSelection=getSelectString(undoSel);
|
insilmaril@721
|
1278 |
else
|
insilmaril@721
|
1279 |
qWarning ("VymModel::saveStateChangingPart no undoSel given!");
|
insilmaril@721
|
1280 |
QString redoSelection="";
|
insilmaril@721
|
1281 |
if (redoSel)
|
insilmaril@721
|
1282 |
redoSelection=getSelectString(undoSel);
|
insilmaril@721
|
1283 |
else
|
insilmaril@721
|
1284 |
qWarning ("VymModel::saveStateChangingPart no redoSel given!");
|
insilmaril@721
|
1285 |
|
insilmaril@721
|
1286 |
|
insilmaril@721
|
1287 |
saveState (PartOfMap,
|
insilmaril@721
|
1288 |
undoSelection, "addMapReplace (\"PATH\")",
|
insilmaril@721
|
1289 |
redoSelection, rc,
|
insilmaril@721
|
1290 |
comment,
|
insilmaril@721
|
1291 |
undoSel);
|
insilmaril@721
|
1292 |
}
|
insilmaril@721
|
1293 |
|
insilmaril@721
|
1294 |
void VymModel::saveStateRemovingPart(LinkableMapObj *redoSel, const QString &comment)
|
insilmaril@721
|
1295 |
{
|
insilmaril@721
|
1296 |
if (!redoSel)
|
insilmaril@721
|
1297 |
{
|
insilmaril@721
|
1298 |
qWarning ("VymModel::saveStateRemovingPart no redoSel given!");
|
insilmaril@721
|
1299 |
return;
|
insilmaril@721
|
1300 |
}
|
insilmaril@721
|
1301 |
QString undoSelection=getSelectString (redoSel->getParObj());
|
insilmaril@721
|
1302 |
QString redoSelection=getSelectString(redoSel);
|
insilmaril@721
|
1303 |
if (typeid(*redoSel) == typeid(BranchObj) )
|
insilmaril@721
|
1304 |
{
|
insilmaril@721
|
1305 |
// save the selected branch of the map, Undo will insert part of map
|
insilmaril@721
|
1306 |
saveState (PartOfMap,
|
insilmaril@721
|
1307 |
undoSelection, QString("addMapInsert (\"PATH\",%1)").arg(((BranchObj*)redoSel)->getNum()),
|
insilmaril@721
|
1308 |
redoSelection, "delete ()",
|
insilmaril@721
|
1309 |
comment,
|
insilmaril@721
|
1310 |
redoSel);
|
insilmaril@721
|
1311 |
}
|
insilmaril@721
|
1312 |
}
|
insilmaril@721
|
1313 |
|
insilmaril@721
|
1314 |
|
insilmaril@721
|
1315 |
void VymModel::saveState(LinkableMapObj *undoSel, const QString &uc, LinkableMapObj *redoSel, const QString &rc, const QString &comment)
|
insilmaril@721
|
1316 |
{
|
insilmaril@721
|
1317 |
// "Normal" savestate: save commands, selections and comment
|
insilmaril@721
|
1318 |
// so just save commands for undo and redo
|
insilmaril@721
|
1319 |
// and use current selection
|
insilmaril@721
|
1320 |
|
insilmaril@721
|
1321 |
QString redoSelection="";
|
insilmaril@721
|
1322 |
if (redoSel) redoSelection=getSelectString(redoSel);
|
insilmaril@721
|
1323 |
QString undoSelection="";
|
insilmaril@721
|
1324 |
if (undoSel) undoSelection=getSelectString(undoSel);
|
insilmaril@721
|
1325 |
|
insilmaril@721
|
1326 |
saveState (UndoCommand,
|
insilmaril@721
|
1327 |
undoSelection, uc,
|
insilmaril@721
|
1328 |
redoSelection, rc,
|
insilmaril@721
|
1329 |
comment,
|
insilmaril@721
|
1330 |
NULL);
|
insilmaril@721
|
1331 |
}
|
insilmaril@721
|
1332 |
|
insilmaril@721
|
1333 |
void VymModel::saveState(const QString &undoSel, const QString &uc, const QString &redoSel, const QString &rc, const QString &comment)
|
insilmaril@721
|
1334 |
{
|
insilmaril@721
|
1335 |
// "Normal" savestate: save commands, selections and comment
|
insilmaril@721
|
1336 |
// so just save commands for undo and redo
|
insilmaril@721
|
1337 |
// and use current selection
|
insilmaril@721
|
1338 |
saveState (UndoCommand,
|
insilmaril@721
|
1339 |
undoSel, uc,
|
insilmaril@721
|
1340 |
redoSel, rc,
|
insilmaril@721
|
1341 |
comment,
|
insilmaril@721
|
1342 |
NULL);
|
insilmaril@721
|
1343 |
}
|
insilmaril@721
|
1344 |
|
insilmaril@721
|
1345 |
void VymModel::saveState(const QString &uc, const QString &rc, const QString &comment)
|
insilmaril@721
|
1346 |
{
|
insilmaril@721
|
1347 |
// "Normal" savestate applied to model (no selection needed):
|
insilmaril@721
|
1348 |
// save commands and comment
|
insilmaril@721
|
1349 |
saveState (UndoCommand,
|
insilmaril@721
|
1350 |
NULL, uc,
|
insilmaril@721
|
1351 |
NULL, rc,
|
insilmaril@721
|
1352 |
comment,
|
insilmaril@721
|
1353 |
NULL);
|
insilmaril@721
|
1354 |
}
|
insilmaril@721
|
1355 |
|
insilmaril@721
|
1356 |
|
insilmaril@650
|
1357 |
QGraphicsScene* VymModel::getScene ()
|
insilmaril@650
|
1358 |
{
|
insilmaril@650
|
1359 |
return mapScene;
|
insilmaril@650
|
1360 |
}
|
insilmaril@650
|
1361 |
|
insilmaril@650
|
1362 |
BranchObj* VymModel::first()
|
insilmaril@650
|
1363 |
{
|
insilmaril@650
|
1364 |
if (mapCenters.count()>0)
|
insilmaril@650
|
1365 |
return mapCenters.first();
|
insilmaril@650
|
1366 |
else
|
insilmaril@650
|
1367 |
return NULL;
|
insilmaril@650
|
1368 |
}
|
insilmaril@650
|
1369 |
|
insilmaril@650
|
1370 |
BranchObj* VymModel::next(BranchObj *bo_start)
|
insilmaril@650
|
1371 |
{
|
insilmaril@650
|
1372 |
BranchObj *rbo;
|
insilmaril@650
|
1373 |
BranchObj *bo=bo_start;
|
insilmaril@650
|
1374 |
if (bo)
|
insilmaril@650
|
1375 |
{
|
insilmaril@665
|
1376 |
// Try to find next branch in current MapCenter
|
insilmaril@650
|
1377 |
rbo=bo->next();
|
insilmaril@650
|
1378 |
if (rbo) return rbo;
|
insilmaril@650
|
1379 |
|
insilmaril@650
|
1380 |
// Try to find MapCenter of bo
|
insilmaril@650
|
1381 |
while (bo->getDepth()>0) bo=(BranchObj*)bo->getParObj();
|
insilmaril@650
|
1382 |
|
insilmaril@650
|
1383 |
// Try to find next MapCenter
|
insilmaril@650
|
1384 |
int i=mapCenters.indexOf ((MapCenterObj*)bo);
|
insilmaril@684
|
1385 |
if (i+2 > mapCenters.count() || i<0) return NULL;
|
insilmaril@684
|
1386 |
if (mapCenters.at(i+1)!=bo_start)
|
insilmaril@684
|
1387 |
return mapCenters.at(i+1);
|
insilmaril@650
|
1388 |
}
|
insilmaril@650
|
1389 |
return NULL;
|
insilmaril@650
|
1390 |
}
|
insilmaril@650
|
1391 |
|
insilmaril@650
|
1392 |
LinkableMapObj* VymModel::findMapObj(QPointF p, LinkableMapObj *excludeLMO)
|
insilmaril@650
|
1393 |
{
|
insilmaril@650
|
1394 |
LinkableMapObj *lmo;
|
insilmaril@650
|
1395 |
|
insilmaril@650
|
1396 |
for (int i=0;i<mapCenters.count(); i++)
|
insilmaril@650
|
1397 |
{
|
insilmaril@650
|
1398 |
lmo=mapCenters.at(i)->findMapObj (p,excludeLMO);
|
insilmaril@650
|
1399 |
if (lmo) return lmo;
|
insilmaril@650
|
1400 |
}
|
insilmaril@650
|
1401 |
return NULL;
|
insilmaril@650
|
1402 |
}
|
insilmaril@650
|
1403 |
|
insilmaril@650
|
1404 |
LinkableMapObj* VymModel::findObjBySelect(const QString &s)
|
insilmaril@650
|
1405 |
{
|
insilmaril@650
|
1406 |
LinkableMapObj *lmo;
|
insilmaril@650
|
1407 |
if (!s.isEmpty() )
|
insilmaril@650
|
1408 |
{
|
insilmaril@650
|
1409 |
QString part;
|
insilmaril@650
|
1410 |
QString typ;
|
insilmaril@650
|
1411 |
QString num;
|
insilmaril@650
|
1412 |
part=s.section(",",0,0);
|
insilmaril@652
|
1413 |
typ=part.left (2);
|
insilmaril@650
|
1414 |
num=part.right(part.length() - 3);
|
insilmaril@650
|
1415 |
if (typ=="mc" && num.toInt()>=0 && num.toInt() <mapCenters.count() )
|
insilmaril@650
|
1416 |
return mapCenters.at(num.toInt() );
|
insilmaril@650
|
1417 |
}
|
insilmaril@650
|
1418 |
|
insilmaril@650
|
1419 |
for (int i=0; i<mapCenters.count(); i++)
|
insilmaril@650
|
1420 |
{
|
insilmaril@650
|
1421 |
lmo=mapCenters.at(i)->findObjBySelect(s);
|
insilmaril@650
|
1422 |
if (lmo) return lmo;
|
insilmaril@650
|
1423 |
}
|
insilmaril@650
|
1424 |
return NULL;
|
insilmaril@650
|
1425 |
}
|
insilmaril@650
|
1426 |
|
insilmaril@650
|
1427 |
LinkableMapObj* VymModel::findID (const QString &s)
|
insilmaril@650
|
1428 |
{
|
insilmaril@650
|
1429 |
LinkableMapObj *lmo;
|
insilmaril@650
|
1430 |
for (int i=0; i<mapCenters.count(); i++)
|
insilmaril@650
|
1431 |
{
|
insilmaril@650
|
1432 |
lmo=mapCenters.at(i)->findID (s);
|
insilmaril@650
|
1433 |
if (lmo) return lmo;
|
insilmaril@650
|
1434 |
}
|
insilmaril@650
|
1435 |
return NULL;
|
insilmaril@650
|
1436 |
}
|
insilmaril@650
|
1437 |
|
insilmaril@650
|
1438 |
QString VymModel::saveToDir (const QString &tmpdir,const QString &prefix, int verbose, const QPointF &offset)
|
insilmaril@650
|
1439 |
{
|
insilmaril@650
|
1440 |
QString s;
|
insilmaril@650
|
1441 |
|
insilmaril@650
|
1442 |
for (int i=0; i<mapCenters.count(); i++)
|
insilmaril@650
|
1443 |
s+=mapCenters.at(i)->saveToDir (tmpdir,prefix,verbose,offset);
|
insilmaril@650
|
1444 |
return s;
|
insilmaril@650
|
1445 |
}
|
insilmaril@650
|
1446 |
|
insilmaril@721
|
1447 |
//////////////////////////////////////////////
|
insilmaril@721
|
1448 |
// Interface
|
insilmaril@721
|
1449 |
//////////////////////////////////////////////
|
insilmaril@721
|
1450 |
void VymModel::setVersion (const QString &s)
|
insilmaril@721
|
1451 |
{
|
insilmaril@721
|
1452 |
version=s;
|
insilmaril@721
|
1453 |
}
|
insilmaril@721
|
1454 |
|
insilmaril@721
|
1455 |
void VymModel::setAuthor (const QString &s)
|
insilmaril@721
|
1456 |
{
|
insilmaril@721
|
1457 |
saveState (
|
insilmaril@721
|
1458 |
QString ("setMapAuthor (\"%1\")").arg(author),
|
insilmaril@721
|
1459 |
QString ("setMapAuthor (\"%1\")").arg(s),
|
insilmaril@721
|
1460 |
QString ("Set author of map to \"%1\"").arg(s)
|
insilmaril@721
|
1461 |
);
|
insilmaril@721
|
1462 |
|
insilmaril@721
|
1463 |
author=s;
|
insilmaril@721
|
1464 |
}
|
insilmaril@721
|
1465 |
|
insilmaril@721
|
1466 |
QString VymModel::getAuthor()
|
insilmaril@721
|
1467 |
{
|
insilmaril@721
|
1468 |
return author;
|
insilmaril@721
|
1469 |
}
|
insilmaril@721
|
1470 |
|
insilmaril@721
|
1471 |
void VymModel::setComment (const QString &s)
|
insilmaril@721
|
1472 |
{
|
insilmaril@721
|
1473 |
saveState (
|
insilmaril@721
|
1474 |
QString ("setMapComment (\"%1\")").arg(comment),
|
insilmaril@721
|
1475 |
QString ("setMapComment (\"%1\")").arg(s),
|
insilmaril@721
|
1476 |
QString ("Set comment of map")
|
insilmaril@721
|
1477 |
);
|
insilmaril@721
|
1478 |
|
insilmaril@721
|
1479 |
comment=s;
|
insilmaril@721
|
1480 |
}
|
insilmaril@721
|
1481 |
|
insilmaril@721
|
1482 |
QString VymModel::getComment ()
|
insilmaril@721
|
1483 |
{
|
insilmaril@721
|
1484 |
return comment;
|
insilmaril@721
|
1485 |
}
|
insilmaril@721
|
1486 |
|
insilmaril@721
|
1487 |
QString VymModel::getDate ()
|
insilmaril@721
|
1488 |
{
|
insilmaril@721
|
1489 |
return QDate::currentDate().toString ("yyyy-MM-dd");
|
insilmaril@721
|
1490 |
}
|
insilmaril@721
|
1491 |
|
insilmaril@721
|
1492 |
void VymModel::setHeading(const QString &s)
|
insilmaril@721
|
1493 |
{
|
insilmaril@721
|
1494 |
BranchObj *sel=selection.getBranch();
|
insilmaril@721
|
1495 |
if (sel)
|
insilmaril@721
|
1496 |
{
|
insilmaril@721
|
1497 |
saveState(
|
insilmaril@721
|
1498 |
sel,
|
insilmaril@721
|
1499 |
"setHeading (\""+sel->getHeading()+"\")",
|
insilmaril@721
|
1500 |
sel,
|
insilmaril@721
|
1501 |
"setHeading (\""+s+"\")",
|
insilmaril@721
|
1502 |
QString("Set heading of %1 to \"%2\"").arg(getObjectName(sel)).arg(s) );
|
insilmaril@721
|
1503 |
sel->setHeading(s );
|
insilmaril@726
|
1504 |
TreeItem *ti=selection.getBranchItem();
|
insilmaril@727
|
1505 |
if (ti)
|
insilmaril@726
|
1506 |
{
|
insilmaril@727
|
1507 |
ti->setHeading (s);
|
insilmaril@727
|
1508 |
//FIXME VM ix is wrong ModelIndex below, ix2 is (hopefully) correct:
|
insilmaril@727
|
1509 |
QModelIndex ix=index( ti->row(), ti->column(), index (0,0,QModelIndex()) );
|
insilmaril@727
|
1510 |
//FIXME VM testing only cout <<"VM::setHeading s="<<s.toStdString()<<" ti="<<ti<<" r,c=("<<ti->row()<<","<<ti->column()<<")"<<endl;
|
insilmaril@727
|
1511 |
QModelIndex ix2=index (ti);
|
insilmaril@727
|
1512 |
emit (dataChanged ( ix2,ix2));
|
insilmaril@726
|
1513 |
}
|
insilmaril@727
|
1514 |
else
|
insilmaril@727
|
1515 |
{
|
insilmaril@727
|
1516 |
cout << "Warning: VM::setHeading ti==NULL\n";
|
insilmaril@727
|
1517 |
}
|
insilmaril@727
|
1518 |
|
insilmaril@727
|
1519 |
//cout <<" (r,c)=("<<ix2.row()<<","<<ix2.column()<<")"<<endl;
|
insilmaril@726
|
1520 |
|
insilmaril@721
|
1521 |
reposition();
|
insilmaril@721
|
1522 |
selection.update();
|
insilmaril@721
|
1523 |
ensureSelectionVisible();
|
insilmaril@721
|
1524 |
}
|
insilmaril@721
|
1525 |
}
|
insilmaril@721
|
1526 |
|
insilmaril@721
|
1527 |
void VymModel::setHeadingInt(const QString &s)
|
insilmaril@721
|
1528 |
{
|
insilmaril@721
|
1529 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
1530 |
if (bo)
|
insilmaril@721
|
1531 |
{
|
insilmaril@721
|
1532 |
bo->setHeading(s);
|
insilmaril@721
|
1533 |
reposition();
|
insilmaril@721
|
1534 |
selection.update();
|
insilmaril@721
|
1535 |
ensureSelectionVisible();
|
insilmaril@721
|
1536 |
}
|
insilmaril@721
|
1537 |
}
|
insilmaril@721
|
1538 |
|
insilmaril@721
|
1539 |
BranchObj* VymModel::findText (QString s, bool cs)
|
insilmaril@721
|
1540 |
{
|
insilmaril@721
|
1541 |
QTextDocument::FindFlags flags=0;
|
insilmaril@721
|
1542 |
if (cs) flags=QTextDocument::FindCaseSensitively;
|
insilmaril@721
|
1543 |
|
insilmaril@721
|
1544 |
if (!itFind)
|
insilmaril@721
|
1545 |
{ // Nothing found or new find process
|
insilmaril@721
|
1546 |
if (EOFind)
|
insilmaril@721
|
1547 |
// nothing found, start again
|
insilmaril@721
|
1548 |
EOFind=false;
|
insilmaril@721
|
1549 |
itFind=first();
|
insilmaril@721
|
1550 |
}
|
insilmaril@721
|
1551 |
bool searching=true;
|
insilmaril@721
|
1552 |
bool foundNote=false;
|
insilmaril@721
|
1553 |
while (searching && !EOFind)
|
insilmaril@721
|
1554 |
{
|
insilmaril@721
|
1555 |
if (itFind)
|
insilmaril@721
|
1556 |
{
|
insilmaril@721
|
1557 |
// Searching in Note
|
insilmaril@721
|
1558 |
if (itFind->getNote().contains(s,cs))
|
insilmaril@721
|
1559 |
{
|
insilmaril@721
|
1560 |
if (selection.single()!=itFind)
|
insilmaril@721
|
1561 |
{
|
insilmaril@721
|
1562 |
selection.select(itFind);
|
insilmaril@721
|
1563 |
ensureSelectionVisible();
|
insilmaril@721
|
1564 |
}
|
insilmaril@721
|
1565 |
if (textEditor->findText(s,flags))
|
insilmaril@721
|
1566 |
{
|
insilmaril@721
|
1567 |
searching=false;
|
insilmaril@721
|
1568 |
foundNote=true;
|
insilmaril@721
|
1569 |
}
|
insilmaril@721
|
1570 |
}
|
insilmaril@721
|
1571 |
// Searching in Heading
|
insilmaril@721
|
1572 |
if (searching && itFind->getHeading().contains (s,cs) )
|
insilmaril@721
|
1573 |
{
|
insilmaril@721
|
1574 |
selection.select(itFind);
|
insilmaril@721
|
1575 |
ensureSelectionVisible();
|
insilmaril@721
|
1576 |
searching=false;
|
insilmaril@721
|
1577 |
}
|
insilmaril@721
|
1578 |
}
|
insilmaril@721
|
1579 |
if (!foundNote)
|
insilmaril@721
|
1580 |
{
|
insilmaril@721
|
1581 |
itFind=next(itFind);
|
insilmaril@721
|
1582 |
if (!itFind) EOFind=true;
|
insilmaril@721
|
1583 |
}
|
insilmaril@721
|
1584 |
//cout <<"still searching... "<<qPrintable( itFind->getHeading())<<endl;
|
insilmaril@721
|
1585 |
}
|
insilmaril@721
|
1586 |
if (!searching)
|
insilmaril@721
|
1587 |
return selection.getBranch();
|
insilmaril@721
|
1588 |
else
|
insilmaril@721
|
1589 |
return NULL;
|
insilmaril@721
|
1590 |
}
|
insilmaril@721
|
1591 |
|
insilmaril@721
|
1592 |
void VymModel::findReset()
|
insilmaril@721
|
1593 |
{ // Necessary if text to find changes during a find process
|
insilmaril@721
|
1594 |
itFind=NULL;
|
insilmaril@721
|
1595 |
EOFind=false;
|
insilmaril@721
|
1596 |
}
|
insilmaril@721
|
1597 |
|
insilmaril@721
|
1598 |
|
insilmaril@721
|
1599 |
|
insilmaril@721
|
1600 |
void VymModel::setScene (QGraphicsScene *s)
|
insilmaril@721
|
1601 |
{
|
insilmaril@728
|
1602 |
cout << "VM::setscene scene="<<s<<endl;
|
insilmaril@728
|
1603 |
mapScene=s; // FIXME VM should not be necessary anymore, move all occurences to MapEditor
|
insilmaril@728
|
1604 |
//init(); // Here we have a mapScene set,
|
insilmaril@721
|
1605 |
// which is (still) needed to create MapCenters
|
insilmaril@721
|
1606 |
}
|
insilmaril@721
|
1607 |
|
insilmaril@721
|
1608 |
void VymModel::setURL(const QString &url)
|
insilmaril@721
|
1609 |
{
|
insilmaril@721
|
1610 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
1611 |
if (bo)
|
insilmaril@721
|
1612 |
{
|
insilmaril@721
|
1613 |
QString oldurl=bo->getURL();
|
insilmaril@721
|
1614 |
bo->setURL (url);
|
insilmaril@721
|
1615 |
saveState (
|
insilmaril@721
|
1616 |
bo,
|
insilmaril@721
|
1617 |
QString ("setURL (\"%1\")").arg(oldurl),
|
insilmaril@721
|
1618 |
bo,
|
insilmaril@721
|
1619 |
QString ("setURL (\"%1\")").arg(url),
|
insilmaril@721
|
1620 |
QString ("set URL of %1 to %2").arg(getObjectName(bo)).arg(url)
|
insilmaril@721
|
1621 |
);
|
insilmaril@721
|
1622 |
updateActions();
|
insilmaril@721
|
1623 |
reposition();
|
insilmaril@721
|
1624 |
selection.update();
|
insilmaril@721
|
1625 |
ensureSelectionVisible();
|
insilmaril@721
|
1626 |
}
|
insilmaril@721
|
1627 |
}
|
insilmaril@721
|
1628 |
|
insilmaril@721
|
1629 |
QString VymModel::getURL()
|
insilmaril@721
|
1630 |
{
|
insilmaril@721
|
1631 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
1632 |
if (bo)
|
insilmaril@721
|
1633 |
return bo->getURL();
|
insilmaril@721
|
1634 |
else
|
insilmaril@721
|
1635 |
return "";
|
insilmaril@721
|
1636 |
}
|
insilmaril@721
|
1637 |
|
insilmaril@721
|
1638 |
QStringList VymModel::getURLs()
|
insilmaril@721
|
1639 |
{
|
insilmaril@721
|
1640 |
QStringList urls;
|
insilmaril@721
|
1641 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
1642 |
if (bo)
|
insilmaril@721
|
1643 |
{
|
insilmaril@721
|
1644 |
bo=bo->first();
|
insilmaril@721
|
1645 |
while (bo)
|
insilmaril@721
|
1646 |
{
|
insilmaril@721
|
1647 |
if (!bo->getURL().isEmpty()) urls.append( bo->getURL());
|
insilmaril@721
|
1648 |
bo=bo->next();
|
insilmaril@721
|
1649 |
}
|
insilmaril@721
|
1650 |
}
|
insilmaril@721
|
1651 |
return urls;
|
insilmaril@721
|
1652 |
}
|
insilmaril@721
|
1653 |
|
insilmaril@721
|
1654 |
void VymModel::linkFloatImageTo(const QString &dstString)
|
insilmaril@721
|
1655 |
{
|
insilmaril@721
|
1656 |
FloatImageObj *fio=selection.getFloatImage();
|
insilmaril@721
|
1657 |
if (fio)
|
insilmaril@721
|
1658 |
{
|
insilmaril@721
|
1659 |
BranchObj *dst=(BranchObj*)findObjBySelect(dstString);
|
insilmaril@721
|
1660 |
if (dst && (typeid(*dst)==typeid (BranchObj) ||
|
insilmaril@721
|
1661 |
typeid(*dst)==typeid (MapCenterObj)))
|
insilmaril@721
|
1662 |
{
|
insilmaril@721
|
1663 |
LinkableMapObj *dstPar=dst->getParObj();
|
insilmaril@721
|
1664 |
QString parString=getSelectString(dstPar);
|
insilmaril@721
|
1665 |
QString fioPreSelectString=getSelectString(fio);
|
insilmaril@721
|
1666 |
QString fioPreParentSelectString=getSelectString (fio->getParObj());
|
insilmaril@721
|
1667 |
((BranchObj*)dst)->addFloatImage (fio);
|
insilmaril@721
|
1668 |
selection.unselect();
|
insilmaril@721
|
1669 |
((BranchObj*)(fio->getParObj()))->removeFloatImage (fio);
|
insilmaril@721
|
1670 |
fio=((BranchObj*)dst)->getLastFloatImage();
|
insilmaril@721
|
1671 |
fio->setRelPos();
|
insilmaril@721
|
1672 |
fio->reposition();
|
insilmaril@721
|
1673 |
selection.select(fio);
|
insilmaril@721
|
1674 |
saveState(
|
insilmaril@721
|
1675 |
getSelectString(fio),
|
insilmaril@721
|
1676 |
QString("linkTo (\"%1\")").arg(fioPreParentSelectString),
|
insilmaril@721
|
1677 |
fioPreSelectString,
|
insilmaril@721
|
1678 |
QString ("linkTo (\"%1\")").arg(dstString),
|
insilmaril@721
|
1679 |
QString ("Link floatimage to %1").arg(getObjectName(dst)));
|
insilmaril@721
|
1680 |
}
|
insilmaril@721
|
1681 |
}
|
insilmaril@721
|
1682 |
}
|
insilmaril@721
|
1683 |
|
insilmaril@721
|
1684 |
|
insilmaril@721
|
1685 |
void VymModel::setFrameType(const FrameObj::FrameType &t)
|
insilmaril@721
|
1686 |
{
|
insilmaril@721
|
1687 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
1688 |
if (bo)
|
insilmaril@721
|
1689 |
{
|
insilmaril@721
|
1690 |
QString s=bo->getFrameTypeName();
|
insilmaril@721
|
1691 |
bo->setFrameType (t);
|
insilmaril@721
|
1692 |
saveState (bo, QString("setFrameType (\"%1\")").arg(s),
|
insilmaril@721
|
1693 |
bo, QString ("setFrameType (\"%1\")").arg(bo->getFrameTypeName()),QString ("set type of frame to %1").arg(s));
|
insilmaril@721
|
1694 |
reposition();
|
insilmaril@721
|
1695 |
bo->updateLink();
|
insilmaril@721
|
1696 |
}
|
insilmaril@721
|
1697 |
}
|
insilmaril@721
|
1698 |
|
insilmaril@721
|
1699 |
void VymModel::setFrameType(const QString &s)
|
insilmaril@721
|
1700 |
{
|
insilmaril@721
|
1701 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
1702 |
if (bo)
|
insilmaril@721
|
1703 |
{
|
insilmaril@721
|
1704 |
saveState (bo, QString("setFrameType (\"%1\")").arg(bo->getFrameTypeName()),
|
insilmaril@721
|
1705 |
bo, QString ("setFrameType (\"%1\")").arg(s),QString ("set type of frame to %1").arg(s));
|
insilmaril@721
|
1706 |
bo->setFrameType (s);
|
insilmaril@721
|
1707 |
reposition();
|
insilmaril@721
|
1708 |
bo->updateLink();
|
insilmaril@721
|
1709 |
}
|
insilmaril@721
|
1710 |
}
|
insilmaril@721
|
1711 |
|
insilmaril@721
|
1712 |
void VymModel::setFramePenColor(const QColor &c)
|
insilmaril@721
|
1713 |
{
|
insilmaril@721
|
1714 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
1715 |
if (bo)
|
insilmaril@721
|
1716 |
{
|
insilmaril@721
|
1717 |
saveState (bo, QString("setFramePenColor (\"%1\")").arg(bo->getFramePenColor().name() ),
|
insilmaril@721
|
1718 |
bo, QString ("setFramePenColor (\"%1\")").arg(c.name() ),QString ("set pen color of frame to %1").arg(c.name() ));
|
insilmaril@721
|
1719 |
bo->setFramePenColor (c);
|
insilmaril@721
|
1720 |
}
|
insilmaril@721
|
1721 |
}
|
insilmaril@721
|
1722 |
|
insilmaril@721
|
1723 |
void VymModel::setFrameBrushColor(const QColor &c)
|
insilmaril@721
|
1724 |
{
|
insilmaril@721
|
1725 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
1726 |
if (bo)
|
insilmaril@721
|
1727 |
{
|
insilmaril@721
|
1728 |
saveState (bo, QString("setFrameBrushColor (\"%1\")").arg(bo->getFrameBrushColor().name() ),
|
insilmaril@721
|
1729 |
bo, QString ("setFrameBrushColor (\"%1\")").arg(c.name() ),QString ("set brush color of frame to %1").arg(c.name() ));
|
insilmaril@721
|
1730 |
bo->setFrameBrushColor (c);
|
insilmaril@721
|
1731 |
}
|
insilmaril@721
|
1732 |
}
|
insilmaril@721
|
1733 |
|
insilmaril@721
|
1734 |
void VymModel::setFramePadding (const int &i)
|
insilmaril@721
|
1735 |
{
|
insilmaril@721
|
1736 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
1737 |
if (bo)
|
insilmaril@721
|
1738 |
{
|
insilmaril@721
|
1739 |
saveState (bo, QString("setFramePadding (\"%1\")").arg(bo->getFramePadding() ),
|
insilmaril@721
|
1740 |
bo, QString ("setFramePadding (\"%1\")").arg(i),QString ("set brush color of frame to %1").arg(i));
|
insilmaril@721
|
1741 |
bo->setFramePadding (i);
|
insilmaril@721
|
1742 |
reposition();
|
insilmaril@721
|
1743 |
bo->updateLink();
|
insilmaril@721
|
1744 |
}
|
insilmaril@721
|
1745 |
}
|
insilmaril@721
|
1746 |
|
insilmaril@721
|
1747 |
void VymModel::setFrameBorderWidth(const int &i)
|
insilmaril@721
|
1748 |
{
|
insilmaril@721
|
1749 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
1750 |
if (bo)
|
insilmaril@721
|
1751 |
{
|
insilmaril@721
|
1752 |
saveState (bo, QString("setFrameBorderWidth (\"%1\")").arg(bo->getFrameBorderWidth() ),
|
insilmaril@721
|
1753 |
bo, QString ("setFrameBorderWidth (\"%1\")").arg(i),QString ("set border width of frame to %1").arg(i));
|
insilmaril@721
|
1754 |
bo->setFrameBorderWidth (i);
|
insilmaril@721
|
1755 |
reposition();
|
insilmaril@721
|
1756 |
bo->updateLink();
|
insilmaril@721
|
1757 |
}
|
insilmaril@721
|
1758 |
}
|
insilmaril@721
|
1759 |
|
insilmaril@721
|
1760 |
void VymModel::setIncludeImagesVer(bool b)
|
insilmaril@721
|
1761 |
{
|
insilmaril@721
|
1762 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
1763 |
if (bo)
|
insilmaril@721
|
1764 |
{
|
insilmaril@721
|
1765 |
QString u= b ? "false" : "true";
|
insilmaril@721
|
1766 |
QString r=!b ? "false" : "true";
|
insilmaril@721
|
1767 |
|
insilmaril@721
|
1768 |
saveState(
|
insilmaril@721
|
1769 |
bo,
|
insilmaril@721
|
1770 |
QString("setIncludeImagesVertically (%1)").arg(u),
|
insilmaril@721
|
1771 |
bo,
|
insilmaril@721
|
1772 |
QString("setIncludeImagesVertically (%1)").arg(r),
|
insilmaril@721
|
1773 |
QString("Include images vertically in %1").arg(getObjectName(bo))
|
insilmaril@721
|
1774 |
);
|
insilmaril@721
|
1775 |
bo->setIncludeImagesVer(b);
|
insilmaril@721
|
1776 |
reposition();
|
insilmaril@721
|
1777 |
}
|
insilmaril@721
|
1778 |
}
|
insilmaril@721
|
1779 |
|
insilmaril@721
|
1780 |
void VymModel::setIncludeImagesHor(bool b)
|
insilmaril@721
|
1781 |
{
|
insilmaril@721
|
1782 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
1783 |
if (bo)
|
insilmaril@721
|
1784 |
{
|
insilmaril@721
|
1785 |
QString u= b ? "false" : "true";
|
insilmaril@721
|
1786 |
QString r=!b ? "false" : "true";
|
insilmaril@721
|
1787 |
|
insilmaril@721
|
1788 |
saveState(
|
insilmaril@721
|
1789 |
bo,
|
insilmaril@721
|
1790 |
QString("setIncludeImagesHorizontally (%1)").arg(u),
|
insilmaril@721
|
1791 |
bo,
|
insilmaril@721
|
1792 |
QString("setIncludeImagesHorizontally (%1)").arg(r),
|
insilmaril@721
|
1793 |
QString("Include images horizontally in %1").arg(getObjectName(bo))
|
insilmaril@721
|
1794 |
);
|
insilmaril@721
|
1795 |
bo->setIncludeImagesHor(b);
|
insilmaril@721
|
1796 |
reposition();
|
insilmaril@721
|
1797 |
}
|
insilmaril@721
|
1798 |
}
|
insilmaril@721
|
1799 |
|
insilmaril@721
|
1800 |
void VymModel::setHideLinkUnselected (bool b)
|
insilmaril@721
|
1801 |
{
|
insilmaril@721
|
1802 |
LinkableMapObj *sel=selection.single();
|
insilmaril@721
|
1803 |
if (sel &&
|
insilmaril@721
|
1804 |
(selection.type() == Selection::Branch ||
|
insilmaril@721
|
1805 |
selection.type() == Selection::MapCenter ||
|
insilmaril@721
|
1806 |
selection.type() == Selection::FloatImage ))
|
insilmaril@721
|
1807 |
{
|
insilmaril@721
|
1808 |
QString u= b ? "false" : "true";
|
insilmaril@721
|
1809 |
QString r=!b ? "false" : "true";
|
insilmaril@721
|
1810 |
|
insilmaril@721
|
1811 |
saveState(
|
insilmaril@721
|
1812 |
sel,
|
insilmaril@721
|
1813 |
QString("setHideLinkUnselected (%1)").arg(u),
|
insilmaril@721
|
1814 |
sel,
|
insilmaril@721
|
1815 |
QString("setHideLinkUnselected (%1)").arg(r),
|
insilmaril@721
|
1816 |
QString("Hide link of %1 if unselected").arg(getObjectName(sel))
|
insilmaril@721
|
1817 |
);
|
insilmaril@721
|
1818 |
sel->setHideLinkUnselected(b);
|
insilmaril@721
|
1819 |
}
|
insilmaril@721
|
1820 |
}
|
insilmaril@721
|
1821 |
|
insilmaril@721
|
1822 |
void VymModel::setHideExport(bool b)
|
insilmaril@721
|
1823 |
{
|
insilmaril@721
|
1824 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
1825 |
if (bo)
|
insilmaril@721
|
1826 |
{
|
insilmaril@721
|
1827 |
bo->setHideInExport (b);
|
insilmaril@721
|
1828 |
QString u= b ? "false" : "true";
|
insilmaril@721
|
1829 |
QString r=!b ? "false" : "true";
|
insilmaril@721
|
1830 |
|
insilmaril@721
|
1831 |
saveState(
|
insilmaril@721
|
1832 |
bo,
|
insilmaril@721
|
1833 |
QString ("setHideExport (%1)").arg(u),
|
insilmaril@721
|
1834 |
bo,
|
insilmaril@721
|
1835 |
QString ("setHideExport (%1)").arg(r),
|
insilmaril@721
|
1836 |
QString ("Set HideExport flag of %1 to %2").arg(getObjectName(bo)).arg (r)
|
insilmaril@721
|
1837 |
);
|
insilmaril@721
|
1838 |
updateActions();
|
insilmaril@721
|
1839 |
reposition();
|
insilmaril@721
|
1840 |
selection.update();
|
insilmaril@727
|
1841 |
// FIXME VM needed? scene()->update();
|
insilmaril@721
|
1842 |
}
|
insilmaril@721
|
1843 |
}
|
insilmaril@721
|
1844 |
|
insilmaril@721
|
1845 |
void VymModel::toggleHideExport()
|
insilmaril@721
|
1846 |
{
|
insilmaril@721
|
1847 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
1848 |
if (bo)
|
insilmaril@721
|
1849 |
setHideExport ( !bo->hideInExport() );
|
insilmaril@721
|
1850 |
}
|
insilmaril@721
|
1851 |
|
insilmaril@721
|
1852 |
|
insilmaril@721
|
1853 |
void VymModel::copy()
|
insilmaril@721
|
1854 |
{
|
insilmaril@721
|
1855 |
LinkableMapObj *sel=selection.single();
|
insilmaril@721
|
1856 |
if (sel)
|
insilmaril@721
|
1857 |
{
|
insilmaril@721
|
1858 |
if (redosAvail == 0)
|
insilmaril@721
|
1859 |
{
|
insilmaril@721
|
1860 |
// Copy to history
|
insilmaril@721
|
1861 |
QString s=getSelectString(sel);
|
insilmaril@721
|
1862 |
saveState (PartOfMap, s, "nop ()", s, "copy ()","Copy selection to clipboard",sel );
|
insilmaril@721
|
1863 |
curClipboard=curStep;
|
insilmaril@721
|
1864 |
}
|
insilmaril@721
|
1865 |
|
insilmaril@721
|
1866 |
// Copy also to global clipboard, because we are at last step in history
|
insilmaril@721
|
1867 |
QString bakMapName(QString("history-%1").arg(curStep));
|
insilmaril@721
|
1868 |
QString bakMapDir(tmpMapDir +"/"+bakMapName);
|
insilmaril@721
|
1869 |
copyDir (bakMapDir,clipboardDir );
|
insilmaril@721
|
1870 |
|
insilmaril@721
|
1871 |
clipboardEmpty=false;
|
insilmaril@721
|
1872 |
updateActions();
|
insilmaril@721
|
1873 |
}
|
insilmaril@721
|
1874 |
}
|
insilmaril@721
|
1875 |
|
insilmaril@721
|
1876 |
|
insilmaril@721
|
1877 |
void VymModel::pasteNoSave(const int &n)
|
insilmaril@721
|
1878 |
{
|
insilmaril@721
|
1879 |
bool old=blockSaveState;
|
insilmaril@721
|
1880 |
blockSaveState=true;
|
insilmaril@721
|
1881 |
bool zippedOrg=zipped;
|
insilmaril@721
|
1882 |
if (redosAvail > 0 || n!=0)
|
insilmaril@721
|
1883 |
{
|
insilmaril@721
|
1884 |
// Use the "historical" buffer
|
insilmaril@721
|
1885 |
QString bakMapName(QString("history-%1").arg(n));
|
insilmaril@721
|
1886 |
QString bakMapDir(tmpMapDir +"/"+bakMapName);
|
insilmaril@721
|
1887 |
load (bakMapDir+"/"+clipboardFile,ImportAdd, VymMap);
|
insilmaril@721
|
1888 |
} else
|
insilmaril@721
|
1889 |
// Use the global buffer
|
insilmaril@721
|
1890 |
load (clipboardDir+"/"+clipboardFile,ImportAdd, VymMap);
|
insilmaril@721
|
1891 |
zipped=zippedOrg;
|
insilmaril@721
|
1892 |
blockSaveState=old;
|
insilmaril@721
|
1893 |
}
|
insilmaril@721
|
1894 |
|
insilmaril@721
|
1895 |
void VymModel::paste()
|
insilmaril@721
|
1896 |
{
|
insilmaril@721
|
1897 |
BranchObj *sel=selection.getBranch();
|
insilmaril@721
|
1898 |
if (sel)
|
insilmaril@721
|
1899 |
{
|
insilmaril@721
|
1900 |
saveStateChangingPart(
|
insilmaril@721
|
1901 |
sel,
|
insilmaril@721
|
1902 |
sel,
|
insilmaril@721
|
1903 |
QString ("paste (%1)").arg(curClipboard),
|
insilmaril@721
|
1904 |
QString("Paste to %1").arg( getObjectName(sel))
|
insilmaril@721
|
1905 |
);
|
insilmaril@721
|
1906 |
pasteNoSave(0);
|
insilmaril@721
|
1907 |
reposition();
|
insilmaril@721
|
1908 |
}
|
insilmaril@721
|
1909 |
}
|
insilmaril@721
|
1910 |
|
insilmaril@721
|
1911 |
void VymModel::cut()
|
insilmaril@721
|
1912 |
{
|
insilmaril@721
|
1913 |
LinkableMapObj *sel=selection.single();
|
insilmaril@721
|
1914 |
if ( sel && (selection.type() == Selection::Branch ||
|
insilmaril@721
|
1915 |
selection.type()==Selection::MapCenter ||
|
insilmaril@721
|
1916 |
selection.type()==Selection::FloatImage))
|
insilmaril@721
|
1917 |
{
|
insilmaril@721
|
1918 |
/* No savestate! savestate is called in cutNoSave
|
insilmaril@721
|
1919 |
saveStateChangingPart(
|
insilmaril@721
|
1920 |
sel->getParObj(),
|
insilmaril@721
|
1921 |
sel,
|
insilmaril@721
|
1922 |
"cut ()",
|
insilmaril@721
|
1923 |
QString("Cut %1").arg(getObjectName(sel ))
|
insilmaril@721
|
1924 |
);
|
insilmaril@721
|
1925 |
*/
|
insilmaril@721
|
1926 |
copy();
|
insilmaril@721
|
1927 |
deleteSelection();
|
insilmaril@721
|
1928 |
reposition();
|
insilmaril@721
|
1929 |
}
|
insilmaril@721
|
1930 |
}
|
insilmaril@721
|
1931 |
|
insilmaril@721
|
1932 |
void VymModel::moveBranchUp()
|
insilmaril@721
|
1933 |
{
|
insilmaril@721
|
1934 |
BranchObj* bo=selection.getBranch();
|
insilmaril@721
|
1935 |
BranchObj* par;
|
insilmaril@721
|
1936 |
if (bo)
|
insilmaril@721
|
1937 |
{
|
insilmaril@721
|
1938 |
if (!bo->canMoveBranchUp()) return;
|
insilmaril@721
|
1939 |
par=(BranchObj*)(bo->getParObj());
|
insilmaril@721
|
1940 |
BranchObj *obo=par->moveBranchUp (bo); // bo will be the one below selection
|
insilmaril@721
|
1941 |
saveState (getSelectString(bo),"moveBranchDown ()",getSelectString(obo),"moveBranchUp ()",QString("Move up %1").arg(getObjectName(bo)));
|
insilmaril@721
|
1942 |
reposition();
|
insilmaril@727
|
1943 |
//FIXME VM needed? scene()->update();
|
insilmaril@721
|
1944 |
selection.update();
|
insilmaril@721
|
1945 |
ensureSelectionVisible();
|
insilmaril@721
|
1946 |
}
|
insilmaril@721
|
1947 |
}
|
insilmaril@721
|
1948 |
|
insilmaril@721
|
1949 |
void VymModel::moveBranchDown()
|
insilmaril@721
|
1950 |
{
|
insilmaril@721
|
1951 |
BranchObj* bo=selection.getBranch();
|
insilmaril@721
|
1952 |
BranchObj* par;
|
insilmaril@721
|
1953 |
if (bo)
|
insilmaril@721
|
1954 |
{
|
insilmaril@721
|
1955 |
if (!bo->canMoveBranchDown()) return;
|
insilmaril@721
|
1956 |
par=(BranchObj*)(bo->getParObj());
|
insilmaril@721
|
1957 |
BranchObj *obo=par->moveBranchDown(bo); // bo will be the one above selection
|
insilmaril@721
|
1958 |
saveState(getSelectString(bo),"moveBranchUp ()",getSelectString(obo),"moveBranchDown ()",QString("Move down %1").arg(getObjectName(bo)));
|
insilmaril@721
|
1959 |
reposition();
|
insilmaril@727
|
1960 |
//FIXME VM needed? scene()->update();
|
insilmaril@721
|
1961 |
selection.update();
|
insilmaril@721
|
1962 |
ensureSelectionVisible();
|
insilmaril@721
|
1963 |
}
|
insilmaril@721
|
1964 |
}
|
insilmaril@721
|
1965 |
|
insilmaril@721
|
1966 |
void VymModel::sortChildren()
|
insilmaril@721
|
1967 |
{
|
insilmaril@721
|
1968 |
BranchObj* bo=selection.getBranch();
|
insilmaril@721
|
1969 |
if (bo)
|
insilmaril@721
|
1970 |
{
|
insilmaril@721
|
1971 |
if(bo->countBranches()>1)
|
insilmaril@721
|
1972 |
{
|
insilmaril@721
|
1973 |
saveStateChangingPart(bo,bo, "sortChildren ()",QString("Sort children of %1").arg(getObjectName(bo)));
|
insilmaril@721
|
1974 |
bo->sortChildren();
|
insilmaril@721
|
1975 |
reposition();
|
insilmaril@721
|
1976 |
ensureSelectionVisible();
|
insilmaril@721
|
1977 |
}
|
insilmaril@721
|
1978 |
}
|
insilmaril@721
|
1979 |
}
|
insilmaril@721
|
1980 |
|
insilmaril@726
|
1981 |
void VymModel::createMapCenter()
|
insilmaril@726
|
1982 |
{
|
insilmaril@726
|
1983 |
MapCenterObj *mco=addMapCenter (QPointF (0,0) );
|
insilmaril@726
|
1984 |
selection.select (mco);
|
insilmaril@726
|
1985 |
}
|
insilmaril@726
|
1986 |
|
insilmaril@726
|
1987 |
void VymModel::createBranch()
|
insilmaril@726
|
1988 |
{
|
insilmaril@726
|
1989 |
BranchObj *bo=selection.getBranch();
|
insilmaril@726
|
1990 |
if (bo)
|
insilmaril@726
|
1991 |
{
|
insilmaril@727
|
1992 |
BranchObj *newbo=addNewBranchInt (-2); // FIXME VM Old model, merge with below
|
insilmaril@726
|
1993 |
|
insilmaril@726
|
1994 |
// Create TreeItem
|
insilmaril@726
|
1995 |
QList<QVariant> cData;
|
insilmaril@726
|
1996 |
cData << "VM:createBranch" << "undef"<<"undef";
|
insilmaril@726
|
1997 |
TreeItem *parti=bo->getTreeItem();
|
insilmaril@726
|
1998 |
TreeItem *ti=new TreeItem (cData,parti);
|
insilmaril@726
|
1999 |
ti->setLMO (newbo);
|
insilmaril@726
|
2000 |
ti->setType (TreeItem::Branch);
|
insilmaril@726
|
2001 |
parti->appendChild (ti);
|
insilmaril@726
|
2002 |
|
insilmaril@726
|
2003 |
if (newbo)
|
insilmaril@726
|
2004 |
{
|
insilmaril@726
|
2005 |
newbo->setTreeItem (ti);
|
insilmaril@727
|
2006 |
selection.select (newbo); // FIXME VM really needed here?
|
insilmaril@726
|
2007 |
}
|
insilmaril@726
|
2008 |
}
|
insilmaril@726
|
2009 |
}
|
insilmaril@726
|
2010 |
|
insilmaril@721
|
2011 |
MapCenterObj* VymModel::addMapCenter ()
|
insilmaril@721
|
2012 |
{
|
insilmaril@723
|
2013 |
MapCenterObj *mco=addMapCenter (contextPos);
|
insilmaril@728
|
2014 |
cout <<"VM::addMCO () mapScene="<<mapScene<<endl;
|
insilmaril@721
|
2015 |
selection.select (mco);
|
insilmaril@721
|
2016 |
updateActions();
|
insilmaril@721
|
2017 |
ensureSelectionVisible();
|
insilmaril@721
|
2018 |
saveState (
|
insilmaril@721
|
2019 |
mco,
|
insilmaril@721
|
2020 |
"delete()",
|
insilmaril@721
|
2021 |
NULL,
|
insilmaril@723
|
2022 |
QString ("addMapCenter (%1,%2)").arg (contextPos.x()).arg(contextPos.y()),
|
insilmaril@723
|
2023 |
QString ("Adding MapCenter to (%1,%2)").arg (contextPos.x()).arg(contextPos.y())
|
insilmaril@721
|
2024 |
);
|
insilmaril@721
|
2025 |
return mco;
|
insilmaril@721
|
2026 |
}
|
insilmaril@721
|
2027 |
|
insilmaril@721
|
2028 |
MapCenterObj* VymModel::addMapCenter(QPointF absPos)
|
insilmaril@721
|
2029 |
{
|
insilmaril@727
|
2030 |
MapCenterObj *mapCenter = new MapCenterObj(mapScene,this);
|
insilmaril@727
|
2031 |
mapCenter->setMapEditor(mapEditor); //FIXME VM needed to get defLinkStyle, mapLinkColorHint ... for later added objects
|
insilmaril@721
|
2032 |
mapCenter->move (absPos);
|
insilmaril@721
|
2033 |
mapCenter->setVisibility (true);
|
insilmaril@721
|
2034 |
mapCenter->setHeading (QApplication::translate("Heading of mapcenter in new map", "New map"));
|
insilmaril@721
|
2035 |
mapCenters.append(mapCenter);
|
insilmaril@726
|
2036 |
|
insilmaril@726
|
2037 |
// Create TreeItem
|
insilmaril@726
|
2038 |
QList<QVariant> cData;
|
insilmaril@726
|
2039 |
cData << "VM:addMapCenter" << "undef"<<"undef";
|
insilmaril@726
|
2040 |
TreeItem *ti=new TreeItem (cData,rootItem);
|
insilmaril@726
|
2041 |
ti->setLMO (mapCenter);
|
insilmaril@726
|
2042 |
ti->setType (TreeItem::MapCenter);
|
insilmaril@726
|
2043 |
mapCenter->setTreeItem (ti);
|
insilmaril@726
|
2044 |
rootItem->appendChild (ti);
|
insilmaril@726
|
2045 |
|
insilmaril@721
|
2046 |
return mapCenter;
|
insilmaril@721
|
2047 |
}
|
insilmaril@721
|
2048 |
|
insilmaril@723
|
2049 |
MapCenterObj* VymModel::removeMapCenter(MapCenterObj* mco)
|
insilmaril@721
|
2050 |
{
|
insilmaril@721
|
2051 |
int i=mapCenters.indexOf (mco);
|
insilmaril@721
|
2052 |
if (i>=0)
|
insilmaril@721
|
2053 |
{
|
insilmaril@721
|
2054 |
mapCenters.removeAt (i);
|
insilmaril@721
|
2055 |
delete (mco);
|
insilmaril@721
|
2056 |
if (i>0) return mapCenters.at(i-1); // Return previous MCO
|
insilmaril@721
|
2057 |
}
|
insilmaril@721
|
2058 |
return NULL;
|
insilmaril@721
|
2059 |
}
|
insilmaril@721
|
2060 |
|
insilmaril@723
|
2061 |
MapCenterObj* VymModel::getLastMapCenter()
|
insilmaril@723
|
2062 |
{
|
insilmaril@723
|
2063 |
if (mapCenters.size()>0)
|
insilmaril@723
|
2064 |
return mapCenters.last();
|
insilmaril@723
|
2065 |
else
|
insilmaril@723
|
2066 |
return NULL;
|
insilmaril@723
|
2067 |
|
insilmaril@723
|
2068 |
}
|
insilmaril@723
|
2069 |
|
insilmaril@721
|
2070 |
|
insilmaril@721
|
2071 |
BranchObj* VymModel::addNewBranchInt(int num)
|
insilmaril@721
|
2072 |
{
|
insilmaril@721
|
2073 |
// Depending on pos:
|
insilmaril@721
|
2074 |
// -3 insert in children of parent above selection
|
insilmaril@721
|
2075 |
// -2 add branch to selection
|
insilmaril@721
|
2076 |
// -1 insert in children of parent below selection
|
insilmaril@721
|
2077 |
// 0..n insert in children of parent at pos
|
insilmaril@721
|
2078 |
BranchObj *newbo=NULL;
|
insilmaril@721
|
2079 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
2080 |
if (bo)
|
insilmaril@721
|
2081 |
{
|
insilmaril@721
|
2082 |
if (num==-2)
|
insilmaril@721
|
2083 |
{
|
insilmaril@721
|
2084 |
// save scroll state. If scrolled, automatically select
|
insilmaril@721
|
2085 |
// new branch in order to tmp unscroll parent...
|
insilmaril@721
|
2086 |
newbo=bo->addBranch();
|
insilmaril@721
|
2087 |
|
insilmaril@721
|
2088 |
}else if (num==-1)
|
insilmaril@721
|
2089 |
{
|
insilmaril@721
|
2090 |
num=bo->getNum()+1;
|
insilmaril@721
|
2091 |
bo=(BranchObj*)bo->getParObj();
|
insilmaril@721
|
2092 |
if (bo) newbo=bo->insertBranch(num);
|
insilmaril@721
|
2093 |
}else if (num==-3)
|
insilmaril@721
|
2094 |
{
|
insilmaril@721
|
2095 |
num=bo->getNum();
|
insilmaril@721
|
2096 |
bo=(BranchObj*)bo->getParObj();
|
insilmaril@721
|
2097 |
if (bo) newbo=bo->insertBranch(num);
|
insilmaril@721
|
2098 |
}
|
insilmaril@721
|
2099 |
if (!newbo) return NULL;
|
insilmaril@721
|
2100 |
}
|
insilmaril@721
|
2101 |
return newbo;
|
insilmaril@721
|
2102 |
}
|
insilmaril@721
|
2103 |
|
insilmaril@721
|
2104 |
BranchObj* VymModel::addNewBranch(int pos)
|
insilmaril@721
|
2105 |
{
|
insilmaril@721
|
2106 |
// Different meaning than num in addNewBranchInt!
|
insilmaril@721
|
2107 |
// -1 add above
|
insilmaril@721
|
2108 |
// 0 add as child
|
insilmaril@721
|
2109 |
// +1 add below
|
insilmaril@721
|
2110 |
BranchObj *bo = selection.getBranch();
|
insilmaril@721
|
2111 |
BranchObj *newbo=NULL;
|
insilmaril@721
|
2112 |
|
insilmaril@721
|
2113 |
if (bo)
|
insilmaril@721
|
2114 |
{
|
insilmaril@727
|
2115 |
// FIXME VM do we still need this in model? setCursor (Qt::ArrowCursor);
|
insilmaril@721
|
2116 |
|
insilmaril@721
|
2117 |
newbo=addNewBranchInt (pos-2);
|
insilmaril@721
|
2118 |
|
insilmaril@721
|
2119 |
if (newbo)
|
insilmaril@721
|
2120 |
{
|
insilmaril@721
|
2121 |
saveState(
|
insilmaril@721
|
2122 |
newbo,
|
insilmaril@721
|
2123 |
"delete ()",
|
insilmaril@721
|
2124 |
bo,
|
insilmaril@721
|
2125 |
QString ("addBranch (%1)").arg(pos),
|
insilmaril@721
|
2126 |
QString ("Add new branch to %1").arg(getObjectName(bo)));
|
insilmaril@721
|
2127 |
|
insilmaril@721
|
2128 |
reposition();
|
insilmaril@721
|
2129 |
selection.update();
|
insilmaril@721
|
2130 |
latestSelectionString=getSelectString(newbo);
|
insilmaril@721
|
2131 |
// In Network mode, the client needs to know where the new branch is,
|
insilmaril@721
|
2132 |
// so we have to pass on this information via saveState.
|
insilmaril@721
|
2133 |
// TODO: Get rid of this positioning workaround
|
insilmaril@721
|
2134 |
QString ps=qpointfToString (newbo->getAbsPos());
|
insilmaril@721
|
2135 |
sendData ("selectLatestAdded ()");
|
insilmaril@721
|
2136 |
sendData (QString("move %1").arg(ps));
|
insilmaril@721
|
2137 |
sendSelection();
|
insilmaril@721
|
2138 |
}
|
insilmaril@721
|
2139 |
}
|
insilmaril@721
|
2140 |
return newbo;
|
insilmaril@721
|
2141 |
}
|
insilmaril@721
|
2142 |
|
insilmaril@721
|
2143 |
|
insilmaril@721
|
2144 |
BranchObj* VymModel::addNewBranchBefore()
|
insilmaril@721
|
2145 |
{
|
insilmaril@721
|
2146 |
BranchObj *newbo=NULL;
|
insilmaril@721
|
2147 |
BranchObj *bo = selection.getBranch();
|
insilmaril@721
|
2148 |
if (bo && selection.type()==Selection::Branch)
|
insilmaril@721
|
2149 |
// We accept no MapCenterObj here, so we _have_ a parent
|
insilmaril@721
|
2150 |
{
|
insilmaril@721
|
2151 |
QPointF p=bo->getRelPos();
|
insilmaril@721
|
2152 |
|
insilmaril@721
|
2153 |
|
insilmaril@721
|
2154 |
BranchObj *parbo=(BranchObj*)(bo->getParObj());
|
insilmaril@721
|
2155 |
|
insilmaril@721
|
2156 |
// add below selection
|
insilmaril@721
|
2157 |
newbo=parbo->insertBranch(bo->getNum()+1);
|
insilmaril@721
|
2158 |
if (newbo)
|
insilmaril@721
|
2159 |
{
|
insilmaril@721
|
2160 |
newbo->move2RelPos (p);
|
insilmaril@721
|
2161 |
|
insilmaril@721
|
2162 |
// Move selection to new branch
|
insilmaril@721
|
2163 |
bo->linkTo (newbo,-1);
|
insilmaril@721
|
2164 |
|
insilmaril@721
|
2165 |
saveState (newbo, "deleteKeepChildren ()", newbo, "addBranchBefore ()",
|
insilmaril@721
|
2166 |
QString ("Add branch before %1").arg(getObjectName(bo)));
|
insilmaril@721
|
2167 |
|
insilmaril@721
|
2168 |
reposition();
|
insilmaril@721
|
2169 |
selection.update();
|
insilmaril@721
|
2170 |
}
|
insilmaril@721
|
2171 |
}
|
insilmaril@721
|
2172 |
latestSelectionString=selection.getSelectString();
|
insilmaril@721
|
2173 |
return newbo;
|
insilmaril@721
|
2174 |
}
|
insilmaril@721
|
2175 |
|
insilmaril@721
|
2176 |
void VymModel::deleteSelection()
|
insilmaril@721
|
2177 |
{
|
insilmaril@721
|
2178 |
BranchObj *bo = selection.getBranch();
|
insilmaril@728
|
2179 |
|
insilmaril@721
|
2180 |
if (bo && selection.type()==Selection::MapCenter)
|
insilmaril@721
|
2181 |
{
|
insilmaril@721
|
2182 |
// BranchObj* par=(BranchObj*)(bo->getParObj());
|
insilmaril@721
|
2183 |
selection.unselect();
|
insilmaril@727
|
2184 |
/* FIXME VM Note: does saveStateRemovingPart work for MCO? (No parent!)
|
insilmaril@721
|
2185 |
saveStateRemovingPart (bo, QString ("Delete %1").arg(getObjectName(bo)));
|
insilmaril@721
|
2186 |
*/
|
insilmaril@721
|
2187 |
bo=removeMapCenter ((MapCenterObj*)bo);
|
insilmaril@721
|
2188 |
if (bo)
|
insilmaril@721
|
2189 |
{
|
insilmaril@721
|
2190 |
selection.select (bo);
|
insilmaril@721
|
2191 |
ensureSelectionVisible();
|
insilmaril@721
|
2192 |
selection.update();
|
insilmaril@721
|
2193 |
}
|
insilmaril@721
|
2194 |
reposition();
|
insilmaril@721
|
2195 |
return;
|
insilmaril@721
|
2196 |
}
|
insilmaril@721
|
2197 |
if (bo && selection.type()==Selection::Branch)
|
insilmaril@721
|
2198 |
{
|
insilmaril@728
|
2199 |
QModelIndex ix=selection.getBranchIndex();
|
insilmaril@728
|
2200 |
if (ix.isValid())
|
insilmaril@728
|
2201 |
{
|
insilmaril@728
|
2202 |
cout << "VM::deleteSelection\n";
|
insilmaril@728
|
2203 |
}
|
insilmaril@722
|
2204 |
|
insilmaril@721
|
2205 |
BranchObj* par=(BranchObj*)bo->getParObj();
|
insilmaril@721
|
2206 |
selection.unselect();
|
insilmaril@721
|
2207 |
saveStateRemovingPart (bo, QString ("Delete %1").arg(getObjectName(bo)));
|
insilmaril@721
|
2208 |
par->removeBranch(bo);
|
insilmaril@721
|
2209 |
selection.select (par);
|
insilmaril@721
|
2210 |
ensureSelectionVisible();
|
insilmaril@721
|
2211 |
reposition();
|
insilmaril@721
|
2212 |
selection.update();
|
insilmaril@721
|
2213 |
return;
|
insilmaril@721
|
2214 |
}
|
insilmaril@721
|
2215 |
FloatImageObj *fio=selection.getFloatImage();
|
insilmaril@721
|
2216 |
if (fio)
|
insilmaril@721
|
2217 |
{
|
insilmaril@721
|
2218 |
BranchObj* par=(BranchObj*)fio->getParObj();
|
insilmaril@721
|
2219 |
saveStateChangingPart(
|
insilmaril@721
|
2220 |
par,
|
insilmaril@721
|
2221 |
fio,
|
insilmaril@721
|
2222 |
"delete ()",
|
insilmaril@721
|
2223 |
QString("Delete %1").arg(getObjectName(fio))
|
insilmaril@721
|
2224 |
);
|
insilmaril@721
|
2225 |
selection.unselect();
|
insilmaril@721
|
2226 |
par->removeFloatImage(fio);
|
insilmaril@721
|
2227 |
selection.select (par);
|
insilmaril@721
|
2228 |
reposition();
|
insilmaril@721
|
2229 |
selection.update();
|
insilmaril@721
|
2230 |
ensureSelectionVisible();
|
insilmaril@721
|
2231 |
return;
|
insilmaril@721
|
2232 |
}
|
insilmaril@721
|
2233 |
}
|
insilmaril@721
|
2234 |
|
insilmaril@721
|
2235 |
void VymModel::deleteKeepChildren()
|
insilmaril@721
|
2236 |
{
|
insilmaril@721
|
2237 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
2238 |
BranchObj *par;
|
insilmaril@721
|
2239 |
if (bo)
|
insilmaril@721
|
2240 |
{
|
insilmaril@721
|
2241 |
par=(BranchObj*)(bo->getParObj());
|
insilmaril@726
|
2242 |
|
insilmaril@726
|
2243 |
// Don't use this on mapcenter
|
insilmaril@726
|
2244 |
if (!par) return;
|
insilmaril@726
|
2245 |
|
insilmaril@726
|
2246 |
// Check if we have childs at all to keep
|
insilmaril@726
|
2247 |
if (bo->countBranches()==0)
|
insilmaril@726
|
2248 |
{
|
insilmaril@726
|
2249 |
deleteSelection();
|
insilmaril@726
|
2250 |
return;
|
insilmaril@726
|
2251 |
}
|
insilmaril@726
|
2252 |
|
insilmaril@721
|
2253 |
QPointF p=bo->getRelPos();
|
insilmaril@721
|
2254 |
saveStateChangingPart(
|
insilmaril@721
|
2255 |
bo->getParObj(),
|
insilmaril@721
|
2256 |
bo,
|
insilmaril@721
|
2257 |
"deleteKeepChildren ()",
|
insilmaril@721
|
2258 |
QString("Remove %1 and keep its children").arg(getObjectName(bo))
|
insilmaril@721
|
2259 |
);
|
insilmaril@721
|
2260 |
|
insilmaril@721
|
2261 |
QString sel=getSelectString(bo);
|
insilmaril@721
|
2262 |
unselect();
|
insilmaril@721
|
2263 |
par->removeBranchHere(bo);
|
insilmaril@721
|
2264 |
reposition();
|
insilmaril@721
|
2265 |
select (sel);
|
insilmaril@721
|
2266 |
selection.getBranch()->move2RelPos (p);
|
insilmaril@721
|
2267 |
reposition();
|
insilmaril@721
|
2268 |
}
|
insilmaril@721
|
2269 |
}
|
insilmaril@721
|
2270 |
|
insilmaril@721
|
2271 |
void VymModel::deleteChildren()
|
insilmaril@721
|
2272 |
{
|
insilmaril@721
|
2273 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
2274 |
if (bo)
|
insilmaril@721
|
2275 |
{
|
insilmaril@721
|
2276 |
saveStateChangingPart(
|
insilmaril@721
|
2277 |
bo,
|
insilmaril@721
|
2278 |
bo,
|
insilmaril@721
|
2279 |
"deleteChildren ()",
|
insilmaril@721
|
2280 |
QString( "Remove children of branch %1").arg(getObjectName(bo))
|
insilmaril@721
|
2281 |
);
|
insilmaril@721
|
2282 |
bo->removeChildren();
|
insilmaril@721
|
2283 |
reposition();
|
insilmaril@721
|
2284 |
}
|
insilmaril@721
|
2285 |
}
|
insilmaril@721
|
2286 |
|
insilmaril@721
|
2287 |
|
insilmaril@721
|
2288 |
bool VymModel::scrollBranch(BranchObj *bo)
|
insilmaril@721
|
2289 |
{
|
insilmaril@721
|
2290 |
if (bo)
|
insilmaril@721
|
2291 |
{
|
insilmaril@721
|
2292 |
if (bo->isScrolled()) return false;
|
insilmaril@721
|
2293 |
if (bo->countBranches()==0) return false;
|
insilmaril@721
|
2294 |
if (bo->getDepth()==0) return false;
|
insilmaril@721
|
2295 |
QString u,r;
|
insilmaril@721
|
2296 |
r="scroll";
|
insilmaril@721
|
2297 |
u="unscroll";
|
insilmaril@721
|
2298 |
saveState(
|
insilmaril@721
|
2299 |
bo,
|
insilmaril@721
|
2300 |
QString ("%1 ()").arg(u),
|
insilmaril@721
|
2301 |
bo,
|
insilmaril@721
|
2302 |
QString ("%1 ()").arg(r),
|
insilmaril@721
|
2303 |
QString ("%1 %2").arg(r).arg(getObjectName(bo))
|
insilmaril@721
|
2304 |
);
|
insilmaril@721
|
2305 |
bo->toggleScroll();
|
insilmaril@721
|
2306 |
selection.update();
|
insilmaril@727
|
2307 |
// FIXME VM needed? scene()->update();
|
insilmaril@721
|
2308 |
return true;
|
insilmaril@721
|
2309 |
}
|
insilmaril@721
|
2310 |
return false;
|
insilmaril@721
|
2311 |
}
|
insilmaril@721
|
2312 |
|
insilmaril@721
|
2313 |
bool VymModel::unscrollBranch(BranchObj *bo)
|
insilmaril@721
|
2314 |
{
|
insilmaril@721
|
2315 |
if (bo)
|
insilmaril@721
|
2316 |
{
|
insilmaril@721
|
2317 |
if (!bo->isScrolled()) return false;
|
insilmaril@721
|
2318 |
if (bo->countBranches()==0) return false;
|
insilmaril@721
|
2319 |
if (bo->getDepth()==0) return false;
|
insilmaril@721
|
2320 |
QString u,r;
|
insilmaril@721
|
2321 |
u="scroll";
|
insilmaril@721
|
2322 |
r="unscroll";
|
insilmaril@721
|
2323 |
saveState(
|
insilmaril@721
|
2324 |
bo,
|
insilmaril@721
|
2325 |
QString ("%1 ()").arg(u),
|
insilmaril@721
|
2326 |
bo,
|
insilmaril@721
|
2327 |
QString ("%1 ()").arg(r),
|
insilmaril@721
|
2328 |
QString ("%1 %2").arg(r).arg(getObjectName(bo))
|
insilmaril@721
|
2329 |
);
|
insilmaril@721
|
2330 |
bo->toggleScroll();
|
insilmaril@721
|
2331 |
selection.update();
|
insilmaril@727
|
2332 |
// FIXME VM needed? scene()->update();
|
insilmaril@721
|
2333 |
return true;
|
insilmaril@721
|
2334 |
}
|
insilmaril@721
|
2335 |
return false;
|
insilmaril@721
|
2336 |
}
|
insilmaril@721
|
2337 |
|
insilmaril@721
|
2338 |
void VymModel::toggleScroll()
|
insilmaril@721
|
2339 |
{
|
insilmaril@721
|
2340 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
2341 |
if (selection.type()==Selection::Branch )
|
insilmaril@721
|
2342 |
{
|
insilmaril@721
|
2343 |
if (bo->isScrolled())
|
insilmaril@721
|
2344 |
unscrollBranch (bo);
|
insilmaril@721
|
2345 |
else
|
insilmaril@721
|
2346 |
scrollBranch (bo);
|
insilmaril@721
|
2347 |
}
|
insilmaril@721
|
2348 |
}
|
insilmaril@721
|
2349 |
|
insilmaril@721
|
2350 |
void VymModel::unscrollChildren()
|
insilmaril@721
|
2351 |
{
|
insilmaril@721
|
2352 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
2353 |
if (bo)
|
insilmaril@721
|
2354 |
{
|
insilmaril@721
|
2355 |
bo->first();
|
insilmaril@721
|
2356 |
while (bo)
|
insilmaril@721
|
2357 |
{
|
insilmaril@721
|
2358 |
if (bo->isScrolled()) unscrollBranch (bo);
|
insilmaril@721
|
2359 |
bo=bo->next();
|
insilmaril@721
|
2360 |
}
|
insilmaril@721
|
2361 |
}
|
insilmaril@721
|
2362 |
}
|
insilmaril@721
|
2363 |
void VymModel::addFloatImage (const QPixmap &img)
|
insilmaril@721
|
2364 |
{
|
insilmaril@721
|
2365 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
2366 |
if (bo)
|
insilmaril@721
|
2367 |
{
|
insilmaril@721
|
2368 |
FloatImageObj *fio=bo->addFloatImage();
|
insilmaril@721
|
2369 |
fio->load(img);
|
insilmaril@721
|
2370 |
fio->setOriginalFilename("No original filename (image added by dropevent)");
|
insilmaril@721
|
2371 |
QString s=getSelectString(bo);
|
insilmaril@721
|
2372 |
saveState (PartOfMap, s, "nop ()", s, "copy ()","Copy dropped image to clipboard",fio );
|
insilmaril@721
|
2373 |
saveState (fio,"delete ()", bo,QString("paste(%1)").arg(curStep),"Pasting dropped image");
|
insilmaril@721
|
2374 |
reposition();
|
insilmaril@727
|
2375 |
// FIXME VM needed? scene()->update();
|
insilmaril@721
|
2376 |
}
|
insilmaril@721
|
2377 |
}
|
insilmaril@721
|
2378 |
|
insilmaril@721
|
2379 |
|
insilmaril@721
|
2380 |
void VymModel::colorBranch (QColor c)
|
insilmaril@721
|
2381 |
{
|
insilmaril@721
|
2382 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
2383 |
if (bo)
|
insilmaril@721
|
2384 |
{
|
insilmaril@721
|
2385 |
saveState(
|
insilmaril@721
|
2386 |
bo,
|
insilmaril@721
|
2387 |
QString ("colorBranch (\"%1\")").arg(bo->getColor().name()),
|
insilmaril@721
|
2388 |
bo,
|
insilmaril@721
|
2389 |
QString ("colorBranch (\"%1\")").arg(c.name()),
|
insilmaril@721
|
2390 |
QString("Set color of %1 to %2").arg(getObjectName(bo)).arg(c.name())
|
insilmaril@721
|
2391 |
);
|
insilmaril@721
|
2392 |
bo->setColor(c); // color branch
|
insilmaril@721
|
2393 |
}
|
insilmaril@721
|
2394 |
}
|
insilmaril@721
|
2395 |
|
insilmaril@721
|
2396 |
void VymModel::colorSubtree (QColor c)
|
insilmaril@721
|
2397 |
{
|
insilmaril@721
|
2398 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
2399 |
if (bo)
|
insilmaril@721
|
2400 |
{
|
insilmaril@721
|
2401 |
saveStateChangingPart(
|
insilmaril@721
|
2402 |
bo,
|
insilmaril@721
|
2403 |
bo,
|
insilmaril@721
|
2404 |
QString ("colorSubtree (\"%1\")").arg(c.name()),
|
insilmaril@721
|
2405 |
QString ("Set color of %1 and children to %2").arg(getObjectName(bo)).arg(c.name())
|
insilmaril@721
|
2406 |
);
|
insilmaril@721
|
2407 |
bo->setColorSubtree (c); // color links, color children
|
insilmaril@721
|
2408 |
}
|
insilmaril@721
|
2409 |
}
|
insilmaril@721
|
2410 |
|
insilmaril@721
|
2411 |
QColor VymModel::getCurrentHeadingColor()
|
insilmaril@721
|
2412 |
{
|
insilmaril@721
|
2413 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
2414 |
if (bo) return bo->getColor();
|
insilmaril@721
|
2415 |
|
insilmaril@721
|
2416 |
QMessageBox::warning(0,"Warning","Can't get color of heading,\nthere's no branch selected");
|
insilmaril@721
|
2417 |
return Qt::black;
|
insilmaril@721
|
2418 |
}
|
insilmaril@721
|
2419 |
|
insilmaril@721
|
2420 |
|
insilmaril@721
|
2421 |
|
insilmaril@721
|
2422 |
void VymModel::editURL()
|
insilmaril@721
|
2423 |
{
|
insilmaril@721
|
2424 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
2425 |
if (bo)
|
insilmaril@721
|
2426 |
{
|
insilmaril@721
|
2427 |
bool ok;
|
insilmaril@721
|
2428 |
QString text = QInputDialog::getText(
|
insilmaril@721
|
2429 |
"VYM", tr("Enter URL:"), QLineEdit::Normal,
|
insilmaril@721
|
2430 |
bo->getURL(), &ok, NULL);
|
insilmaril@721
|
2431 |
if ( ok)
|
insilmaril@721
|
2432 |
// user entered something and pressed OK
|
insilmaril@721
|
2433 |
setURL(text);
|
insilmaril@721
|
2434 |
}
|
insilmaril@721
|
2435 |
}
|
insilmaril@721
|
2436 |
|
insilmaril@721
|
2437 |
void VymModel::editLocalURL()
|
insilmaril@721
|
2438 |
{
|
insilmaril@721
|
2439 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
2440 |
if (bo)
|
insilmaril@721
|
2441 |
{
|
insilmaril@721
|
2442 |
QStringList filters;
|
insilmaril@721
|
2443 |
filters <<"All files (*)";
|
insilmaril@721
|
2444 |
filters << tr("Text","Filedialog") + " (*.txt)";
|
insilmaril@721
|
2445 |
filters << tr("Spreadsheet","Filedialog") + " (*.odp,*.sxc)";
|
insilmaril@721
|
2446 |
filters << tr("Textdocument","Filedialog") +" (*.odw,*.sxw)";
|
insilmaril@721
|
2447 |
filters << tr("Images","Filedialog") + " (*.png *.bmp *.xbm *.jpg *.png *.xpm *.gif *.pnm)";
|
insilmaril@721
|
2448 |
QFileDialog *fd=new QFileDialog( NULL,vymName+" - " +tr("Set URL to a local file"));
|
insilmaril@721
|
2449 |
fd->setFilters (filters);
|
insilmaril@721
|
2450 |
fd->setCaption(vymName+" - " +tr("Set URL to a local file"));
|
insilmaril@721
|
2451 |
fd->setDirectory (lastFileDir);
|
insilmaril@721
|
2452 |
if (! bo->getVymLink().isEmpty() )
|
insilmaril@721
|
2453 |
fd->selectFile( bo->getURL() );
|
insilmaril@721
|
2454 |
fd->show();
|
insilmaril@721
|
2455 |
|
insilmaril@721
|
2456 |
if ( fd->exec() == QDialog::Accepted )
|
insilmaril@721
|
2457 |
{
|
insilmaril@721
|
2458 |
lastFileDir=QDir (fd->directory().path());
|
insilmaril@721
|
2459 |
setURL (fd->selectedFile() );
|
insilmaril@721
|
2460 |
}
|
insilmaril@721
|
2461 |
}
|
insilmaril@721
|
2462 |
}
|
insilmaril@721
|
2463 |
|
insilmaril@721
|
2464 |
|
insilmaril@721
|
2465 |
void VymModel::editHeading2URL()
|
insilmaril@721
|
2466 |
{
|
insilmaril@721
|
2467 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
2468 |
if (bo)
|
insilmaril@721
|
2469 |
setURL (bo->getHeading());
|
insilmaril@721
|
2470 |
}
|
insilmaril@721
|
2471 |
|
insilmaril@721
|
2472 |
void VymModel::editBugzilla2URL()
|
insilmaril@721
|
2473 |
{
|
insilmaril@721
|
2474 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
2475 |
if (bo)
|
insilmaril@721
|
2476 |
{
|
insilmaril@721
|
2477 |
QString url= "https://bugzilla.novell.com/show_bug.cgi?id="+bo->getHeading();
|
insilmaril@721
|
2478 |
setURL (url);
|
insilmaril@721
|
2479 |
}
|
insilmaril@721
|
2480 |
}
|
insilmaril@721
|
2481 |
|
insilmaril@721
|
2482 |
void VymModel::editFATE2URL()
|
insilmaril@721
|
2483 |
{
|
insilmaril@721
|
2484 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
2485 |
if (bo)
|
insilmaril@721
|
2486 |
{
|
insilmaril@721
|
2487 |
QString url= "http://keeper.suse.de:8080/webfate/match/id?value=ID"+bo->getHeading();
|
insilmaril@721
|
2488 |
saveState(
|
insilmaril@721
|
2489 |
bo,
|
insilmaril@721
|
2490 |
"setURL (\""+bo->getURL()+"\")",
|
insilmaril@721
|
2491 |
bo,
|
insilmaril@721
|
2492 |
"setURL (\""+url+"\")",
|
insilmaril@721
|
2493 |
QString("Use heading of %1 as link to FATE").arg(getObjectName(bo))
|
insilmaril@721
|
2494 |
);
|
insilmaril@721
|
2495 |
bo->setURL (url);
|
insilmaril@721
|
2496 |
updateActions();
|
insilmaril@721
|
2497 |
}
|
insilmaril@721
|
2498 |
}
|
insilmaril@721
|
2499 |
|
insilmaril@721
|
2500 |
void VymModel::editVymLink()
|
insilmaril@721
|
2501 |
{
|
insilmaril@721
|
2502 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
2503 |
if (bo)
|
insilmaril@721
|
2504 |
{
|
insilmaril@721
|
2505 |
QStringList filters;
|
insilmaril@721
|
2506 |
filters <<"VYM map (*.vym)";
|
insilmaril@721
|
2507 |
QFileDialog *fd=new QFileDialog( NULL,vymName+" - " +tr("Link to another map"));
|
insilmaril@721
|
2508 |
fd->setFilters (filters);
|
insilmaril@721
|
2509 |
fd->setCaption(vymName+" - " +tr("Link to another map"));
|
insilmaril@721
|
2510 |
fd->setDirectory (lastFileDir);
|
insilmaril@721
|
2511 |
if (! bo->getVymLink().isEmpty() )
|
insilmaril@721
|
2512 |
fd->selectFile( bo->getVymLink() );
|
insilmaril@721
|
2513 |
fd->show();
|
insilmaril@721
|
2514 |
|
insilmaril@721
|
2515 |
QString fn;
|
insilmaril@721
|
2516 |
if ( fd->exec() == QDialog::Accepted )
|
insilmaril@721
|
2517 |
{
|
insilmaril@721
|
2518 |
lastFileDir=QDir (fd->directory().path());
|
insilmaril@721
|
2519 |
saveState(
|
insilmaril@721
|
2520 |
bo,
|
insilmaril@721
|
2521 |
"setVymLink (\""+bo->getVymLink()+"\")",
|
insilmaril@721
|
2522 |
bo,
|
insilmaril@721
|
2523 |
"setVymLink (\""+fd->selectedFile()+"\")",
|
insilmaril@721
|
2524 |
QString("Set vymlink of %1 to %2").arg(getObjectName(bo)).arg(fd->selectedFile())
|
insilmaril@721
|
2525 |
);
|
insilmaril@721
|
2526 |
setVymLink (fd->selectedFile() ); // FIXME ok?
|
insilmaril@721
|
2527 |
}
|
insilmaril@721
|
2528 |
}
|
insilmaril@721
|
2529 |
}
|
insilmaril@721
|
2530 |
|
insilmaril@721
|
2531 |
void VymModel::setVymLink (const QString &s)
|
insilmaril@721
|
2532 |
{
|
insilmaril@721
|
2533 |
// Internal function, no saveState needed
|
insilmaril@721
|
2534 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
2535 |
if (bo)
|
insilmaril@721
|
2536 |
{
|
insilmaril@721
|
2537 |
bo->setVymLink(s);
|
insilmaril@721
|
2538 |
reposition();
|
insilmaril@721
|
2539 |
updateActions();
|
insilmaril@721
|
2540 |
selection.update();
|
insilmaril@721
|
2541 |
ensureSelectionVisible();
|
insilmaril@721
|
2542 |
}
|
insilmaril@721
|
2543 |
}
|
insilmaril@721
|
2544 |
|
insilmaril@721
|
2545 |
void VymModel::deleteVymLink()
|
insilmaril@721
|
2546 |
{
|
insilmaril@721
|
2547 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
2548 |
if (bo)
|
insilmaril@721
|
2549 |
{
|
insilmaril@721
|
2550 |
saveState(
|
insilmaril@721
|
2551 |
bo,
|
insilmaril@721
|
2552 |
"setVymLink (\""+bo->getVymLink()+"\")",
|
insilmaril@721
|
2553 |
bo,
|
insilmaril@721
|
2554 |
"setVymLink (\"\")",
|
insilmaril@721
|
2555 |
QString("Unset vymlink of %1").arg(getObjectName(bo))
|
insilmaril@721
|
2556 |
);
|
insilmaril@721
|
2557 |
bo->setVymLink ("" );
|
insilmaril@721
|
2558 |
updateActions();
|
insilmaril@721
|
2559 |
reposition();
|
insilmaril@727
|
2560 |
// FIXME VM needed? scene()->update();
|
insilmaril@721
|
2561 |
}
|
insilmaril@721
|
2562 |
}
|
insilmaril@721
|
2563 |
|
insilmaril@721
|
2564 |
QString VymModel::getVymLink()
|
insilmaril@721
|
2565 |
{
|
insilmaril@721
|
2566 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
2567 |
if (bo)
|
insilmaril@721
|
2568 |
return bo->getVymLink();
|
insilmaril@721
|
2569 |
else
|
insilmaril@721
|
2570 |
return "";
|
insilmaril@721
|
2571 |
|
insilmaril@721
|
2572 |
}
|
insilmaril@721
|
2573 |
|
insilmaril@721
|
2574 |
QStringList VymModel::getVymLinks()
|
insilmaril@721
|
2575 |
{
|
insilmaril@721
|
2576 |
QStringList links;
|
insilmaril@721
|
2577 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
2578 |
if (bo)
|
insilmaril@721
|
2579 |
{
|
insilmaril@721
|
2580 |
bo=bo->first();
|
insilmaril@721
|
2581 |
while (bo)
|
insilmaril@721
|
2582 |
{
|
insilmaril@721
|
2583 |
if (!bo->getVymLink().isEmpty()) links.append( bo->getVymLink());
|
insilmaril@721
|
2584 |
bo=bo->next();
|
insilmaril@721
|
2585 |
}
|
insilmaril@721
|
2586 |
}
|
insilmaril@721
|
2587 |
return links;
|
insilmaril@721
|
2588 |
}
|
insilmaril@721
|
2589 |
|
insilmaril@721
|
2590 |
|
insilmaril@721
|
2591 |
void VymModel::followXLink(int i)
|
insilmaril@721
|
2592 |
{
|
insilmaril@721
|
2593 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
2594 |
if (bo)
|
insilmaril@721
|
2595 |
{
|
insilmaril@721
|
2596 |
bo=bo->XLinkTargetAt(i);
|
insilmaril@721
|
2597 |
if (bo)
|
insilmaril@721
|
2598 |
{
|
insilmaril@721
|
2599 |
selection.select(bo);
|
insilmaril@721
|
2600 |
ensureSelectionVisible();
|
insilmaril@721
|
2601 |
}
|
insilmaril@721
|
2602 |
}
|
insilmaril@721
|
2603 |
}
|
insilmaril@721
|
2604 |
|
insilmaril@727
|
2605 |
void VymModel::editXLink(int i) // FIXME VM missing saveState
|
insilmaril@721
|
2606 |
{
|
insilmaril@721
|
2607 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
2608 |
if (bo)
|
insilmaril@721
|
2609 |
{
|
insilmaril@721
|
2610 |
XLinkObj *xlo=bo->XLinkAt(i);
|
insilmaril@721
|
2611 |
if (xlo)
|
insilmaril@721
|
2612 |
{
|
insilmaril@721
|
2613 |
EditXLinkDialog dia;
|
insilmaril@721
|
2614 |
dia.setXLink (xlo);
|
insilmaril@721
|
2615 |
dia.setSelection(bo);
|
insilmaril@721
|
2616 |
if (dia.exec() == QDialog::Accepted)
|
insilmaril@721
|
2617 |
{
|
insilmaril@721
|
2618 |
if (dia.useSettingsGlobal() )
|
insilmaril@721
|
2619 |
{
|
insilmaril@721
|
2620 |
setMapDefXLinkColor (xlo->getColor() );
|
insilmaril@721
|
2621 |
setMapDefXLinkWidth (xlo->getWidth() );
|
insilmaril@721
|
2622 |
}
|
insilmaril@721
|
2623 |
if (dia.deleteXLink())
|
insilmaril@721
|
2624 |
bo->deleteXLinkAt(i);
|
insilmaril@721
|
2625 |
}
|
insilmaril@721
|
2626 |
}
|
insilmaril@721
|
2627 |
}
|
insilmaril@721
|
2628 |
}
|
insilmaril@721
|
2629 |
|
insilmaril@721
|
2630 |
|
insilmaril@721
|
2631 |
|
insilmaril@721
|
2632 |
|
insilmaril@721
|
2633 |
|
insilmaril@721
|
2634 |
//////////////////////////////////////////////
|
insilmaril@721
|
2635 |
// Scripting
|
insilmaril@721
|
2636 |
//////////////////////////////////////////////
|
insilmaril@721
|
2637 |
|
insilmaril@721
|
2638 |
void VymModel::parseAtom(const QString &atom)
|
insilmaril@721
|
2639 |
{
|
insilmaril@721
|
2640 |
BranchObj *selb=selection.getBranch();
|
insilmaril@721
|
2641 |
QString s,t;
|
insilmaril@721
|
2642 |
double x,y;
|
insilmaril@721
|
2643 |
int n;
|
insilmaril@721
|
2644 |
bool b,ok;
|
insilmaril@721
|
2645 |
|
insilmaril@721
|
2646 |
// Split string s into command and parameters
|
insilmaril@721
|
2647 |
parser.parseAtom (atom);
|
insilmaril@721
|
2648 |
QString com=parser.getCommand();
|
insilmaril@721
|
2649 |
|
insilmaril@721
|
2650 |
// External commands
|
insilmaril@721
|
2651 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
2652 |
if (com=="addBranch")
|
insilmaril@721
|
2653 |
{
|
insilmaril@721
|
2654 |
if (selection.isEmpty())
|
insilmaril@721
|
2655 |
{
|
insilmaril@721
|
2656 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
2657 |
} else if (! selb )
|
insilmaril@721
|
2658 |
{
|
insilmaril@721
|
2659 |
parser.setError (Aborted,"Type of selection is not a branch");
|
insilmaril@721
|
2660 |
} else
|
insilmaril@721
|
2661 |
{
|
insilmaril@721
|
2662 |
QList <int> pl;
|
insilmaril@721
|
2663 |
pl << 0 <<1;
|
insilmaril@721
|
2664 |
if (parser.checkParCount(pl))
|
insilmaril@721
|
2665 |
{
|
insilmaril@721
|
2666 |
if (parser.parCount()==0)
|
insilmaril@721
|
2667 |
addNewBranch (0);
|
insilmaril@721
|
2668 |
else
|
insilmaril@721
|
2669 |
{
|
insilmaril@721
|
2670 |
n=parser.parInt (ok,0);
|
insilmaril@721
|
2671 |
if (ok ) addNewBranch (n);
|
insilmaril@721
|
2672 |
}
|
insilmaril@721
|
2673 |
}
|
insilmaril@721
|
2674 |
}
|
insilmaril@721
|
2675 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
2676 |
} else if (com=="addBranchBefore")
|
insilmaril@721
|
2677 |
{
|
insilmaril@721
|
2678 |
if (selection.isEmpty())
|
insilmaril@721
|
2679 |
{
|
insilmaril@721
|
2680 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
2681 |
} else if (! selb )
|
insilmaril@721
|
2682 |
{
|
insilmaril@721
|
2683 |
parser.setError (Aborted,"Type of selection is not a branch");
|
insilmaril@721
|
2684 |
} else
|
insilmaril@721
|
2685 |
{
|
insilmaril@721
|
2686 |
if (parser.parCount()==0)
|
insilmaril@721
|
2687 |
{
|
insilmaril@721
|
2688 |
addNewBranchBefore ();
|
insilmaril@721
|
2689 |
}
|
insilmaril@721
|
2690 |
}
|
insilmaril@721
|
2691 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
2692 |
} else if (com==QString("addMapCenter"))
|
insilmaril@721
|
2693 |
{
|
insilmaril@721
|
2694 |
if (parser.checkParCount(2))
|
insilmaril@721
|
2695 |
{
|
insilmaril@721
|
2696 |
x=parser.parDouble (ok,0);
|
insilmaril@721
|
2697 |
if (ok)
|
insilmaril@721
|
2698 |
{
|
insilmaril@721
|
2699 |
y=parser.parDouble (ok,1);
|
insilmaril@721
|
2700 |
if (ok) addMapCenter (QPointF(x,y));
|
insilmaril@721
|
2701 |
}
|
insilmaril@721
|
2702 |
}
|
insilmaril@721
|
2703 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
2704 |
} else if (com==QString("addMapReplace"))
|
insilmaril@721
|
2705 |
{
|
insilmaril@721
|
2706 |
if (selection.isEmpty())
|
insilmaril@721
|
2707 |
{
|
insilmaril@721
|
2708 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
2709 |
} else if (! selb )
|
insilmaril@721
|
2710 |
{
|
insilmaril@721
|
2711 |
parser.setError (Aborted,"Type of selection is not a branch");
|
insilmaril@721
|
2712 |
} else if (parser.checkParCount(1))
|
insilmaril@721
|
2713 |
{
|
insilmaril@721
|
2714 |
//s=parser.parString (ok,0); // selection
|
insilmaril@721
|
2715 |
t=parser.parString (ok,0); // path to map
|
insilmaril@721
|
2716 |
if (QDir::isRelativePath(t)) t=(tmpMapDir + "/"+t);
|
insilmaril@721
|
2717 |
addMapReplaceInt(getSelectString(selb),t);
|
insilmaril@721
|
2718 |
}
|
insilmaril@721
|
2719 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
2720 |
} else if (com==QString("addMapInsert"))
|
insilmaril@721
|
2721 |
{
|
insilmaril@721
|
2722 |
if (selection.isEmpty())
|
insilmaril@721
|
2723 |
{
|
insilmaril@721
|
2724 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
2725 |
} else if (! selb )
|
insilmaril@721
|
2726 |
{
|
insilmaril@721
|
2727 |
parser.setError (Aborted,"Type of selection is not a branch");
|
insilmaril@721
|
2728 |
} else
|
insilmaril@721
|
2729 |
{
|
insilmaril@721
|
2730 |
if (parser.checkParCount(2))
|
insilmaril@721
|
2731 |
{
|
insilmaril@721
|
2732 |
t=parser.parString (ok,0); // path to map
|
insilmaril@721
|
2733 |
n=parser.parInt(ok,1); // position
|
insilmaril@721
|
2734 |
if (QDir::isRelativePath(t)) t=(tmpMapDir + "/"+t);
|
insilmaril@721
|
2735 |
addMapInsertInt(t,n);
|
insilmaril@721
|
2736 |
}
|
insilmaril@721
|
2737 |
}
|
insilmaril@721
|
2738 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
2739 |
} else if (com=="clearFlags")
|
insilmaril@721
|
2740 |
{
|
insilmaril@721
|
2741 |
if (selection.isEmpty() )
|
insilmaril@721
|
2742 |
{
|
insilmaril@721
|
2743 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
2744 |
} else if (! selb )
|
insilmaril@721
|
2745 |
{
|
insilmaril@721
|
2746 |
parser.setError (Aborted,"Type of selection is not a branch");
|
insilmaril@721
|
2747 |
} else if (parser.checkParCount(0))
|
insilmaril@721
|
2748 |
{
|
insilmaril@721
|
2749 |
selb->clearStandardFlags();
|
insilmaril@721
|
2750 |
selb->updateFlagsToolbar();
|
insilmaril@721
|
2751 |
}
|
insilmaril@721
|
2752 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
2753 |
} else if (com=="colorBranch")
|
insilmaril@721
|
2754 |
{
|
insilmaril@721
|
2755 |
if (selection.isEmpty())
|
insilmaril@721
|
2756 |
{
|
insilmaril@721
|
2757 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
2758 |
} else if (! selb )
|
insilmaril@721
|
2759 |
{
|
insilmaril@721
|
2760 |
parser.setError (Aborted,"Type of selection is not a branch");
|
insilmaril@721
|
2761 |
} else if (parser.checkParCount(1))
|
insilmaril@721
|
2762 |
{
|
insilmaril@721
|
2763 |
QColor c=parser.parColor (ok,0);
|
insilmaril@721
|
2764 |
if (ok) colorBranch (c);
|
insilmaril@721
|
2765 |
}
|
insilmaril@721
|
2766 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
2767 |
} else if (com=="colorSubtree")
|
insilmaril@721
|
2768 |
{
|
insilmaril@721
|
2769 |
if (selection.isEmpty())
|
insilmaril@721
|
2770 |
{
|
insilmaril@721
|
2771 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
2772 |
} else if (! selb )
|
insilmaril@721
|
2773 |
{
|
insilmaril@721
|
2774 |
parser.setError (Aborted,"Type of selection is not a branch");
|
insilmaril@721
|
2775 |
} else if (parser.checkParCount(1))
|
insilmaril@721
|
2776 |
{
|
insilmaril@721
|
2777 |
QColor c=parser.parColor (ok,0);
|
insilmaril@721
|
2778 |
if (ok) colorSubtree (c);
|
insilmaril@721
|
2779 |
}
|
insilmaril@721
|
2780 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
2781 |
} else if (com=="copy")
|
insilmaril@721
|
2782 |
{
|
insilmaril@721
|
2783 |
if (selection.isEmpty())
|
insilmaril@721
|
2784 |
{
|
insilmaril@721
|
2785 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
2786 |
} else if (! selb )
|
insilmaril@721
|
2787 |
{
|
insilmaril@721
|
2788 |
parser.setError (Aborted,"Type of selection is not a branch");
|
insilmaril@721
|
2789 |
} else if (parser.checkParCount(0))
|
insilmaril@721
|
2790 |
{
|
insilmaril@721
|
2791 |
//FIXME missing action for copy
|
insilmaril@721
|
2792 |
}
|
insilmaril@721
|
2793 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
2794 |
} else if (com=="cut")
|
insilmaril@721
|
2795 |
{
|
insilmaril@721
|
2796 |
if (selection.isEmpty())
|
insilmaril@721
|
2797 |
{
|
insilmaril@721
|
2798 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
2799 |
} else if ( selection.type()!=Selection::Branch &&
|
insilmaril@721
|
2800 |
selection.type()!=Selection::MapCenter &&
|
insilmaril@721
|
2801 |
selection.type()!=Selection::FloatImage )
|
insilmaril@721
|
2802 |
{
|
insilmaril@721
|
2803 |
parser.setError (Aborted,"Type of selection is not a branch or floatimage");
|
insilmaril@721
|
2804 |
} else if (parser.checkParCount(0))
|
insilmaril@721
|
2805 |
{
|
insilmaril@721
|
2806 |
cut();
|
insilmaril@721
|
2807 |
}
|
insilmaril@721
|
2808 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
2809 |
} else if (com=="delete")
|
insilmaril@721
|
2810 |
{
|
insilmaril@721
|
2811 |
if (selection.isEmpty())
|
insilmaril@721
|
2812 |
{
|
insilmaril@721
|
2813 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
2814 |
}
|
insilmaril@721
|
2815 |
/*else if (selection.type() != Selection::Branch && selection.type() != Selection::FloatImage )
|
insilmaril@721
|
2816 |
{
|
insilmaril@721
|
2817 |
parser.setError (Aborted,"Type of selection is wrong.");
|
insilmaril@721
|
2818 |
}
|
insilmaril@721
|
2819 |
*/
|
insilmaril@721
|
2820 |
else if (parser.checkParCount(0))
|
insilmaril@721
|
2821 |
{
|
insilmaril@721
|
2822 |
deleteSelection();
|
insilmaril@721
|
2823 |
}
|
insilmaril@721
|
2824 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
2825 |
} else if (com=="deleteKeepChildren")
|
insilmaril@721
|
2826 |
{
|
insilmaril@721
|
2827 |
if (selection.isEmpty())
|
insilmaril@721
|
2828 |
{
|
insilmaril@721
|
2829 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
2830 |
} else if (! selb )
|
insilmaril@721
|
2831 |
{
|
insilmaril@721
|
2832 |
parser.setError (Aborted,"Type of selection is not a branch");
|
insilmaril@721
|
2833 |
} else if (parser.checkParCount(0))
|
insilmaril@721
|
2834 |
{
|
insilmaril@721
|
2835 |
deleteKeepChildren();
|
insilmaril@721
|
2836 |
}
|
insilmaril@721
|
2837 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
2838 |
} else if (com=="deleteChildren")
|
insilmaril@721
|
2839 |
{
|
insilmaril@721
|
2840 |
if (selection.isEmpty())
|
insilmaril@721
|
2841 |
{
|
insilmaril@721
|
2842 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
2843 |
} else if (! selb)
|
insilmaril@721
|
2844 |
{
|
insilmaril@721
|
2845 |
parser.setError (Aborted,"Type of selection is not a branch");
|
insilmaril@721
|
2846 |
} else if (parser.checkParCount(0))
|
insilmaril@721
|
2847 |
{
|
insilmaril@721
|
2848 |
deleteChildren();
|
insilmaril@721
|
2849 |
}
|
insilmaril@721
|
2850 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
2851 |
} else if (com=="exportASCII")
|
insilmaril@721
|
2852 |
{
|
insilmaril@721
|
2853 |
QString fname="";
|
insilmaril@721
|
2854 |
ok=true;
|
insilmaril@721
|
2855 |
if (parser.parCount()>=1)
|
insilmaril@721
|
2856 |
// Hey, we even have a filename
|
insilmaril@721
|
2857 |
fname=parser.parString(ok,0);
|
insilmaril@721
|
2858 |
if (!ok)
|
insilmaril@721
|
2859 |
{
|
insilmaril@721
|
2860 |
parser.setError (Aborted,"Could not read filename");
|
insilmaril@721
|
2861 |
} else
|
insilmaril@721
|
2862 |
{
|
insilmaril@721
|
2863 |
exportASCII (fname,false);
|
insilmaril@721
|
2864 |
}
|
insilmaril@721
|
2865 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
2866 |
} else if (com=="exportImage")
|
insilmaril@721
|
2867 |
{
|
insilmaril@721
|
2868 |
QString fname="";
|
insilmaril@721
|
2869 |
ok=true;
|
insilmaril@721
|
2870 |
if (parser.parCount()>=2)
|
insilmaril@721
|
2871 |
// Hey, we even have a filename
|
insilmaril@721
|
2872 |
fname=parser.parString(ok,0);
|
insilmaril@721
|
2873 |
if (!ok)
|
insilmaril@721
|
2874 |
{
|
insilmaril@721
|
2875 |
parser.setError (Aborted,"Could not read filename");
|
insilmaril@721
|
2876 |
} else
|
insilmaril@721
|
2877 |
{
|
insilmaril@721
|
2878 |
QString format="PNG";
|
insilmaril@721
|
2879 |
if (parser.parCount()>=2)
|
insilmaril@721
|
2880 |
{
|
insilmaril@721
|
2881 |
format=parser.parString(ok,1);
|
insilmaril@721
|
2882 |
}
|
insilmaril@721
|
2883 |
exportImage (fname,false,format);
|
insilmaril@721
|
2884 |
}
|
insilmaril@721
|
2885 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
2886 |
} else if (com=="exportXHTML")
|
insilmaril@721
|
2887 |
{
|
insilmaril@721
|
2888 |
QString fname="";
|
insilmaril@721
|
2889 |
ok=true;
|
insilmaril@721
|
2890 |
if (parser.parCount()>=2)
|
insilmaril@721
|
2891 |
// Hey, we even have a filename
|
insilmaril@721
|
2892 |
fname=parser.parString(ok,1);
|
insilmaril@721
|
2893 |
if (!ok)
|
insilmaril@721
|
2894 |
{
|
insilmaril@721
|
2895 |
parser.setError (Aborted,"Could not read filename");
|
insilmaril@721
|
2896 |
} else
|
insilmaril@721
|
2897 |
{
|
insilmaril@721
|
2898 |
exportXHTML (fname,false);
|
insilmaril@721
|
2899 |
}
|
insilmaril@721
|
2900 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
2901 |
} else if (com=="exportXML")
|
insilmaril@721
|
2902 |
{
|
insilmaril@721
|
2903 |
QString fname="";
|
insilmaril@721
|
2904 |
ok=true;
|
insilmaril@721
|
2905 |
if (parser.parCount()>=2)
|
insilmaril@721
|
2906 |
// Hey, we even have a filename
|
insilmaril@721
|
2907 |
fname=parser.parString(ok,1);
|
insilmaril@721
|
2908 |
if (!ok)
|
insilmaril@721
|
2909 |
{
|
insilmaril@721
|
2910 |
parser.setError (Aborted,"Could not read filename");
|
insilmaril@721
|
2911 |
} else
|
insilmaril@721
|
2912 |
{
|
insilmaril@721
|
2913 |
exportXML (fname,false);
|
insilmaril@721
|
2914 |
}
|
insilmaril@721
|
2915 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
2916 |
} else if (com=="importDir")
|
insilmaril@721
|
2917 |
{
|
insilmaril@721
|
2918 |
if (selection.isEmpty())
|
insilmaril@721
|
2919 |
{
|
insilmaril@721
|
2920 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
2921 |
} else if (! selb )
|
insilmaril@721
|
2922 |
{
|
insilmaril@721
|
2923 |
parser.setError (Aborted,"Type of selection is not a branch");
|
insilmaril@721
|
2924 |
} else if (parser.checkParCount(1))
|
insilmaril@721
|
2925 |
{
|
insilmaril@721
|
2926 |
s=parser.parString(ok,0);
|
insilmaril@721
|
2927 |
if (ok) importDirInt(s);
|
insilmaril@721
|
2928 |
}
|
insilmaril@721
|
2929 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
2930 |
} else if (com=="linkTo")
|
insilmaril@721
|
2931 |
{
|
insilmaril@721
|
2932 |
if (selection.isEmpty())
|
insilmaril@721
|
2933 |
{
|
insilmaril@721
|
2934 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
2935 |
} else if ( selb)
|
insilmaril@721
|
2936 |
{
|
insilmaril@721
|
2937 |
if (parser.checkParCount(4))
|
insilmaril@721
|
2938 |
{
|
insilmaril@721
|
2939 |
// 0 selectstring of parent
|
insilmaril@721
|
2940 |
// 1 num in parent (for branches)
|
insilmaril@721
|
2941 |
// 2,3 x,y of mainbranch or mapcenter
|
insilmaril@721
|
2942 |
s=parser.parString(ok,0);
|
insilmaril@721
|
2943 |
LinkableMapObj *dst=findObjBySelect (s);
|
insilmaril@721
|
2944 |
if (dst)
|
insilmaril@721
|
2945 |
{
|
insilmaril@721
|
2946 |
if (typeid(*dst) == typeid(BranchObj) )
|
insilmaril@721
|
2947 |
{
|
insilmaril@721
|
2948 |
// Get number in parent
|
insilmaril@721
|
2949 |
n=parser.parInt (ok,1);
|
insilmaril@721
|
2950 |
if (ok)
|
insilmaril@721
|
2951 |
{
|
insilmaril@721
|
2952 |
selb->linkTo ((BranchObj*)(dst),n);
|
insilmaril@721
|
2953 |
selection.update();
|
insilmaril@721
|
2954 |
}
|
insilmaril@721
|
2955 |
} else if (typeid(*dst) == typeid(MapCenterObj) )
|
insilmaril@721
|
2956 |
{
|
insilmaril@721
|
2957 |
selb->linkTo ((BranchObj*)(dst),-1);
|
insilmaril@721
|
2958 |
// Get coordinates of mainbranch
|
insilmaril@721
|
2959 |
x=parser.parDouble(ok,2);
|
insilmaril@721
|
2960 |
if (ok)
|
insilmaril@721
|
2961 |
{
|
insilmaril@721
|
2962 |
y=parser.parDouble(ok,3);
|
insilmaril@721
|
2963 |
if (ok)
|
insilmaril@721
|
2964 |
{
|
insilmaril@721
|
2965 |
selb->move (x,y);
|
insilmaril@721
|
2966 |
selection.update();
|
insilmaril@721
|
2967 |
}
|
insilmaril@721
|
2968 |
}
|
insilmaril@721
|
2969 |
}
|
insilmaril@721
|
2970 |
}
|
insilmaril@721
|
2971 |
}
|
insilmaril@721
|
2972 |
} else if ( selection.type() == Selection::FloatImage)
|
insilmaril@721
|
2973 |
{
|
insilmaril@721
|
2974 |
if (parser.checkParCount(1))
|
insilmaril@721
|
2975 |
{
|
insilmaril@721
|
2976 |
// 0 selectstring of parent
|
insilmaril@721
|
2977 |
s=parser.parString(ok,0);
|
insilmaril@721
|
2978 |
LinkableMapObj *dst=findObjBySelect (s);
|
insilmaril@721
|
2979 |
if (dst)
|
insilmaril@721
|
2980 |
{
|
insilmaril@721
|
2981 |
if (typeid(*dst) == typeid(BranchObj) ||
|
insilmaril@721
|
2982 |
typeid(*dst) == typeid(MapCenterObj))
|
insilmaril@721
|
2983 |
linkFloatImageTo (getSelectString(dst));
|
insilmaril@721
|
2984 |
} else
|
insilmaril@721
|
2985 |
parser.setError (Aborted,"Destination is not a branch");
|
insilmaril@721
|
2986 |
}
|
insilmaril@721
|
2987 |
} else
|
insilmaril@721
|
2988 |
parser.setError (Aborted,"Type of selection is not a floatimage or branch");
|
insilmaril@721
|
2989 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
2990 |
} else if (com=="loadImage")
|
insilmaril@721
|
2991 |
{
|
insilmaril@721
|
2992 |
if (selection.isEmpty())
|
insilmaril@721
|
2993 |
{
|
insilmaril@721
|
2994 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
2995 |
} else if (! selb )
|
insilmaril@721
|
2996 |
{
|
insilmaril@721
|
2997 |
parser.setError (Aborted,"Type of selection is not a branch");
|
insilmaril@721
|
2998 |
} else if (parser.checkParCount(1))
|
insilmaril@721
|
2999 |
{
|
insilmaril@721
|
3000 |
s=parser.parString(ok,0);
|
insilmaril@721
|
3001 |
if (ok) loadFloatImageInt (s);
|
insilmaril@721
|
3002 |
}
|
insilmaril@721
|
3003 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3004 |
} else if (com=="moveBranchUp")
|
insilmaril@721
|
3005 |
{
|
insilmaril@721
|
3006 |
if (selection.isEmpty() )
|
insilmaril@721
|
3007 |
{
|
insilmaril@721
|
3008 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
3009 |
} else if (! selb )
|
insilmaril@721
|
3010 |
{
|
insilmaril@721
|
3011 |
parser.setError (Aborted,"Type of selection is not a branch");
|
insilmaril@721
|
3012 |
} else if (parser.checkParCount(0))
|
insilmaril@721
|
3013 |
{
|
insilmaril@721
|
3014 |
moveBranchUp();
|
insilmaril@721
|
3015 |
}
|
insilmaril@721
|
3016 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3017 |
} else if (com=="moveBranchDown")
|
insilmaril@721
|
3018 |
{
|
insilmaril@721
|
3019 |
if (selection.isEmpty() )
|
insilmaril@721
|
3020 |
{
|
insilmaril@721
|
3021 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
3022 |
} else if (! selb )
|
insilmaril@721
|
3023 |
{
|
insilmaril@721
|
3024 |
parser.setError (Aborted,"Type of selection is not a branch");
|
insilmaril@721
|
3025 |
} else if (parser.checkParCount(0))
|
insilmaril@721
|
3026 |
{
|
insilmaril@721
|
3027 |
moveBranchDown();
|
insilmaril@721
|
3028 |
}
|
insilmaril@721
|
3029 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3030 |
} else if (com=="move")
|
insilmaril@721
|
3031 |
{
|
insilmaril@721
|
3032 |
if (selection.isEmpty() )
|
insilmaril@721
|
3033 |
{
|
insilmaril@721
|
3034 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
3035 |
} else if ( selection.type()!=Selection::Branch &&
|
insilmaril@721
|
3036 |
selection.type()!=Selection::MapCenter &&
|
insilmaril@721
|
3037 |
selection.type()!=Selection::FloatImage )
|
insilmaril@721
|
3038 |
{
|
insilmaril@721
|
3039 |
parser.setError (Aborted,"Type of selection is not a branch or floatimage");
|
insilmaril@721
|
3040 |
} else if (parser.checkParCount(2))
|
insilmaril@721
|
3041 |
{
|
insilmaril@721
|
3042 |
x=parser.parDouble (ok,0);
|
insilmaril@721
|
3043 |
if (ok)
|
insilmaril@721
|
3044 |
{
|
insilmaril@721
|
3045 |
y=parser.parDouble (ok,1);
|
insilmaril@721
|
3046 |
if (ok) move (x,y);
|
insilmaril@721
|
3047 |
}
|
insilmaril@721
|
3048 |
}
|
insilmaril@721
|
3049 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3050 |
} else if (com=="moveRel")
|
insilmaril@721
|
3051 |
{
|
insilmaril@721
|
3052 |
if (selection.isEmpty() )
|
insilmaril@721
|
3053 |
{
|
insilmaril@721
|
3054 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
3055 |
} else if ( selection.type()!=Selection::Branch &&
|
insilmaril@721
|
3056 |
selection.type()!=Selection::MapCenter &&
|
insilmaril@721
|
3057 |
selection.type()!=Selection::FloatImage )
|
insilmaril@721
|
3058 |
{
|
insilmaril@721
|
3059 |
parser.setError (Aborted,"Type of selection is not a branch or floatimage");
|
insilmaril@721
|
3060 |
} else if (parser.checkParCount(2))
|
insilmaril@721
|
3061 |
{
|
insilmaril@721
|
3062 |
x=parser.parDouble (ok,0);
|
insilmaril@721
|
3063 |
if (ok)
|
insilmaril@721
|
3064 |
{
|
insilmaril@721
|
3065 |
y=parser.parDouble (ok,1);
|
insilmaril@721
|
3066 |
if (ok) moveRel (x,y);
|
insilmaril@721
|
3067 |
}
|
insilmaril@721
|
3068 |
}
|
insilmaril@721
|
3069 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3070 |
} else if (com=="nop")
|
insilmaril@721
|
3071 |
{
|
insilmaril@721
|
3072 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3073 |
} else if (com=="paste")
|
insilmaril@721
|
3074 |
{
|
insilmaril@721
|
3075 |
if (selection.isEmpty() )
|
insilmaril@721
|
3076 |
{
|
insilmaril@721
|
3077 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
3078 |
} else if (! selb )
|
insilmaril@721
|
3079 |
{
|
insilmaril@721
|
3080 |
parser.setError (Aborted,"Type of selection is not a branch");
|
insilmaril@721
|
3081 |
} else if (parser.checkParCount(1))
|
insilmaril@721
|
3082 |
{
|
insilmaril@721
|
3083 |
n=parser.parInt (ok,0);
|
insilmaril@721
|
3084 |
if (ok) pasteNoSave(n);
|
insilmaril@721
|
3085 |
}
|
insilmaril@721
|
3086 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3087 |
} else if (com=="qa")
|
insilmaril@721
|
3088 |
{
|
insilmaril@721
|
3089 |
if (selection.isEmpty() )
|
insilmaril@721
|
3090 |
{
|
insilmaril@721
|
3091 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
3092 |
} else if (! selb )
|
insilmaril@721
|
3093 |
{
|
insilmaril@721
|
3094 |
parser.setError (Aborted,"Type of selection is not a branch");
|
insilmaril@721
|
3095 |
} else if (parser.checkParCount(4))
|
insilmaril@721
|
3096 |
{
|
insilmaril@721
|
3097 |
QString c,u;
|
insilmaril@721
|
3098 |
c=parser.parString (ok,0);
|
insilmaril@721
|
3099 |
if (!ok)
|
insilmaril@721
|
3100 |
{
|
insilmaril@721
|
3101 |
parser.setError (Aborted,"No comment given");
|
insilmaril@721
|
3102 |
} else
|
insilmaril@721
|
3103 |
{
|
insilmaril@721
|
3104 |
s=parser.parString (ok,1);
|
insilmaril@721
|
3105 |
if (!ok)
|
insilmaril@721
|
3106 |
{
|
insilmaril@721
|
3107 |
parser.setError (Aborted,"First parameter is not a string");
|
insilmaril@721
|
3108 |
} else
|
insilmaril@721
|
3109 |
{
|
insilmaril@721
|
3110 |
t=parser.parString (ok,2);
|
insilmaril@721
|
3111 |
if (!ok)
|
insilmaril@721
|
3112 |
{
|
insilmaril@721
|
3113 |
parser.setError (Aborted,"Condition is not a string");
|
insilmaril@721
|
3114 |
} else
|
insilmaril@721
|
3115 |
{
|
insilmaril@721
|
3116 |
u=parser.parString (ok,3);
|
insilmaril@721
|
3117 |
if (!ok)
|
insilmaril@721
|
3118 |
{
|
insilmaril@721
|
3119 |
parser.setError (Aborted,"Third parameter is not a string");
|
insilmaril@721
|
3120 |
} else
|
insilmaril@721
|
3121 |
{
|
insilmaril@721
|
3122 |
if (s!="heading")
|
insilmaril@721
|
3123 |
{
|
insilmaril@721
|
3124 |
parser.setError (Aborted,"Unknown type: "+s);
|
insilmaril@721
|
3125 |
} else
|
insilmaril@721
|
3126 |
{
|
insilmaril@721
|
3127 |
if (! (t=="eq") )
|
insilmaril@721
|
3128 |
{
|
insilmaril@721
|
3129 |
parser.setError (Aborted,"Unknown operator: "+t);
|
insilmaril@721
|
3130 |
} else
|
insilmaril@721
|
3131 |
{
|
insilmaril@721
|
3132 |
if (! selb )
|
insilmaril@721
|
3133 |
{
|
insilmaril@721
|
3134 |
parser.setError (Aborted,"Type of selection is not a branch");
|
insilmaril@721
|
3135 |
} else
|
insilmaril@721
|
3136 |
{
|
insilmaril@721
|
3137 |
if (selb->getHeading() == u)
|
insilmaril@721
|
3138 |
{
|
insilmaril@721
|
3139 |
cout << "PASSED: " << qPrintable (c) << endl;
|
insilmaril@721
|
3140 |
} else
|
insilmaril@721
|
3141 |
{
|
insilmaril@721
|
3142 |
cout << "FAILED: " << qPrintable (c) << endl;
|
insilmaril@721
|
3143 |
}
|
insilmaril@721
|
3144 |
}
|
insilmaril@721
|
3145 |
}
|
insilmaril@721
|
3146 |
}
|
insilmaril@721
|
3147 |
}
|
insilmaril@721
|
3148 |
}
|
insilmaril@721
|
3149 |
}
|
insilmaril@721
|
3150 |
}
|
insilmaril@721
|
3151 |
}
|
insilmaril@721
|
3152 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3153 |
} else if (com=="saveImage")
|
insilmaril@721
|
3154 |
{
|
insilmaril@721
|
3155 |
FloatImageObj *fio=selection.getFloatImage();
|
insilmaril@721
|
3156 |
if (!fio)
|
insilmaril@721
|
3157 |
{
|
insilmaril@721
|
3158 |
parser.setError (Aborted,"Type of selection is not an image");
|
insilmaril@721
|
3159 |
} else if (parser.checkParCount(2))
|
insilmaril@721
|
3160 |
{
|
insilmaril@721
|
3161 |
s=parser.parString(ok,0);
|
insilmaril@721
|
3162 |
if (ok)
|
insilmaril@721
|
3163 |
{
|
insilmaril@721
|
3164 |
t=parser.parString(ok,1);
|
insilmaril@721
|
3165 |
if (ok) saveFloatImageInt (fio,t,s);
|
insilmaril@721
|
3166 |
}
|
insilmaril@721
|
3167 |
}
|
insilmaril@721
|
3168 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3169 |
} else if (com=="scroll")
|
insilmaril@721
|
3170 |
{
|
insilmaril@721
|
3171 |
if (selection.isEmpty() )
|
insilmaril@721
|
3172 |
{
|
insilmaril@721
|
3173 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
3174 |
} else if (! selb )
|
insilmaril@721
|
3175 |
{
|
insilmaril@721
|
3176 |
parser.setError (Aborted,"Type of selection is not a branch");
|
insilmaril@721
|
3177 |
} else if (parser.checkParCount(0))
|
insilmaril@721
|
3178 |
{
|
insilmaril@721
|
3179 |
if (!scrollBranch (selb))
|
insilmaril@721
|
3180 |
parser.setError (Aborted,"Could not scroll branch");
|
insilmaril@721
|
3181 |
}
|
insilmaril@721
|
3182 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3183 |
} else if (com=="select")
|
insilmaril@721
|
3184 |
{
|
insilmaril@721
|
3185 |
if (parser.checkParCount(1))
|
insilmaril@721
|
3186 |
{
|
insilmaril@721
|
3187 |
s=parser.parString(ok,0);
|
insilmaril@721
|
3188 |
if (ok) select (s);
|
insilmaril@721
|
3189 |
}
|
insilmaril@721
|
3190 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3191 |
} else if (com=="selectLastBranch")
|
insilmaril@721
|
3192 |
{
|
insilmaril@721
|
3193 |
if (selection.isEmpty() )
|
insilmaril@721
|
3194 |
{
|
insilmaril@721
|
3195 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
3196 |
} else if (! selb )
|
insilmaril@721
|
3197 |
{
|
insilmaril@721
|
3198 |
parser.setError (Aborted,"Type of selection is not a branch");
|
insilmaril@721
|
3199 |
} else if (parser.checkParCount(0))
|
insilmaril@721
|
3200 |
{
|
insilmaril@721
|
3201 |
BranchObj *bo=selb->getLastBranch();
|
insilmaril@721
|
3202 |
if (!bo)
|
insilmaril@721
|
3203 |
parser.setError (Aborted,"Could not select last branch");
|
insilmaril@721
|
3204 |
selectInt (bo);
|
insilmaril@721
|
3205 |
|
insilmaril@721
|
3206 |
}
|
insilmaril@721
|
3207 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3208 |
} else if (com=="selectLastImage")
|
insilmaril@721
|
3209 |
{
|
insilmaril@721
|
3210 |
if (selection.isEmpty() )
|
insilmaril@721
|
3211 |
{
|
insilmaril@721
|
3212 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
3213 |
} else if (! selb )
|
insilmaril@721
|
3214 |
{
|
insilmaril@721
|
3215 |
parser.setError (Aborted,"Type of selection is not a branch");
|
insilmaril@721
|
3216 |
} else if (parser.checkParCount(0))
|
insilmaril@721
|
3217 |
{
|
insilmaril@721
|
3218 |
FloatImageObj *fio=selb->getLastFloatImage();
|
insilmaril@721
|
3219 |
if (!fio)
|
insilmaril@721
|
3220 |
parser.setError (Aborted,"Could not select last image");
|
insilmaril@721
|
3221 |
selectInt (fio);
|
insilmaril@721
|
3222 |
|
insilmaril@721
|
3223 |
}
|
insilmaril@721
|
3224 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3225 |
} else if (com=="selectLatestAdded")
|
insilmaril@721
|
3226 |
{
|
insilmaril@721
|
3227 |
if (latestSelectionString.isEmpty() )
|
insilmaril@721
|
3228 |
{
|
insilmaril@721
|
3229 |
parser.setError (Aborted,"No latest added object");
|
insilmaril@721
|
3230 |
} else
|
insilmaril@721
|
3231 |
{
|
insilmaril@721
|
3232 |
if (!select (latestSelectionString))
|
insilmaril@721
|
3233 |
parser.setError (Aborted,"Could not select latest added object "+latestSelectionString);
|
insilmaril@721
|
3234 |
}
|
insilmaril@721
|
3235 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3236 |
} else if (com=="setFrameType")
|
insilmaril@721
|
3237 |
{
|
insilmaril@721
|
3238 |
if ( selection.type()!=Selection::Branch && selection.type()!= Selection::MapCenter && selection.type()!=Selection::FloatImage)
|
insilmaril@721
|
3239 |
{
|
insilmaril@721
|
3240 |
parser.setError (Aborted,"Type of selection does not allow setting frame type");
|
insilmaril@721
|
3241 |
}
|
insilmaril@721
|
3242 |
else if (parser.checkParCount(1))
|
insilmaril@721
|
3243 |
{
|
insilmaril@721
|
3244 |
s=parser.parString(ok,0);
|
insilmaril@721
|
3245 |
if (ok) setFrameType (s);
|
insilmaril@721
|
3246 |
}
|
insilmaril@721
|
3247 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3248 |
} else if (com=="setFramePenColor")
|
insilmaril@721
|
3249 |
{
|
insilmaril@721
|
3250 |
if ( selection.type()!=Selection::Branch && selection.type()!= Selection::MapCenter && selection.type()!=Selection::FloatImage)
|
insilmaril@721
|
3251 |
{
|
insilmaril@721
|
3252 |
parser.setError (Aborted,"Type of selection does not allow setting of pen color");
|
insilmaril@721
|
3253 |
}
|
insilmaril@721
|
3254 |
else if (parser.checkParCount(1))
|
insilmaril@721
|
3255 |
{
|
insilmaril@721
|
3256 |
QColor c=parser.parColor(ok,0);
|
insilmaril@721
|
3257 |
if (ok) setFramePenColor (c);
|
insilmaril@721
|
3258 |
}
|
insilmaril@721
|
3259 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3260 |
} else if (com=="setFrameBrushColor")
|
insilmaril@721
|
3261 |
{
|
insilmaril@721
|
3262 |
if ( selection.type()!=Selection::Branch && selection.type()!= Selection::MapCenter && selection.type()!=Selection::FloatImage)
|
insilmaril@721
|
3263 |
{
|
insilmaril@721
|
3264 |
parser.setError (Aborted,"Type of selection does not allow setting brush color");
|
insilmaril@721
|
3265 |
}
|
insilmaril@721
|
3266 |
else if (parser.checkParCount(1))
|
insilmaril@721
|
3267 |
{
|
insilmaril@721
|
3268 |
QColor c=parser.parColor(ok,0);
|
insilmaril@721
|
3269 |
if (ok) setFrameBrushColor (c);
|
insilmaril@721
|
3270 |
}
|
insilmaril@721
|
3271 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3272 |
} else if (com=="setFramePadding")
|
insilmaril@721
|
3273 |
{
|
insilmaril@721
|
3274 |
if ( selection.type()!=Selection::Branch && selection.type()!= Selection::MapCenter && selection.type()!=Selection::FloatImage)
|
insilmaril@721
|
3275 |
{
|
insilmaril@721
|
3276 |
parser.setError (Aborted,"Type of selection does not allow setting frame padding");
|
insilmaril@721
|
3277 |
}
|
insilmaril@721
|
3278 |
else if (parser.checkParCount(1))
|
insilmaril@721
|
3279 |
{
|
insilmaril@721
|
3280 |
n=parser.parInt(ok,0);
|
insilmaril@721
|
3281 |
if (ok) setFramePadding(n);
|
insilmaril@721
|
3282 |
}
|
insilmaril@721
|
3283 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3284 |
} else if (com=="setFrameBorderWidth")
|
insilmaril@721
|
3285 |
{
|
insilmaril@721
|
3286 |
if ( selection.type()!=Selection::Branch && selection.type()!= Selection::MapCenter && selection.type()!=Selection::FloatImage)
|
insilmaril@721
|
3287 |
{
|
insilmaril@721
|
3288 |
parser.setError (Aborted,"Type of selection does not allow setting frame border width");
|
insilmaril@721
|
3289 |
}
|
insilmaril@721
|
3290 |
else if (parser.checkParCount(1))
|
insilmaril@721
|
3291 |
{
|
insilmaril@721
|
3292 |
n=parser.parInt(ok,0);
|
insilmaril@721
|
3293 |
if (ok) setFrameBorderWidth (n);
|
insilmaril@721
|
3294 |
}
|
insilmaril@721
|
3295 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3296 |
} else if (com=="setMapAuthor")
|
insilmaril@721
|
3297 |
{
|
insilmaril@721
|
3298 |
if (parser.checkParCount(1))
|
insilmaril@721
|
3299 |
{
|
insilmaril@721
|
3300 |
s=parser.parString(ok,0);
|
insilmaril@721
|
3301 |
if (ok) setAuthor (s);
|
insilmaril@721
|
3302 |
}
|
insilmaril@721
|
3303 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3304 |
} else if (com=="setMapComment")
|
insilmaril@721
|
3305 |
{
|
insilmaril@721
|
3306 |
if (parser.checkParCount(1))
|
insilmaril@721
|
3307 |
{
|
insilmaril@721
|
3308 |
s=parser.parString(ok,0);
|
insilmaril@721
|
3309 |
if (ok) setComment(s);
|
insilmaril@721
|
3310 |
}
|
insilmaril@721
|
3311 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3312 |
} else if (com=="setMapBackgroundColor")
|
insilmaril@721
|
3313 |
{
|
insilmaril@721
|
3314 |
if (selection.isEmpty() )
|
insilmaril@721
|
3315 |
{
|
insilmaril@721
|
3316 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
3317 |
} else if (! selection.getBranch() )
|
insilmaril@721
|
3318 |
{
|
insilmaril@721
|
3319 |
parser.setError (Aborted,"Type of selection is not a branch");
|
insilmaril@721
|
3320 |
} else if (parser.checkParCount(1))
|
insilmaril@721
|
3321 |
{
|
insilmaril@721
|
3322 |
QColor c=parser.parColor (ok,0);
|
insilmaril@721
|
3323 |
if (ok) setMapBackgroundColor (c);
|
insilmaril@721
|
3324 |
}
|
insilmaril@721
|
3325 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3326 |
} else if (com=="setMapDefLinkColor")
|
insilmaril@721
|
3327 |
{
|
insilmaril@721
|
3328 |
if (selection.isEmpty() )
|
insilmaril@721
|
3329 |
{
|
insilmaril@721
|
3330 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
3331 |
} else if (! selb )
|
insilmaril@721
|
3332 |
{
|
insilmaril@721
|
3333 |
parser.setError (Aborted,"Type of selection is not a branch");
|
insilmaril@721
|
3334 |
} else if (parser.checkParCount(1))
|
insilmaril@721
|
3335 |
{
|
insilmaril@721
|
3336 |
QColor c=parser.parColor (ok,0);
|
insilmaril@721
|
3337 |
if (ok) setMapDefLinkColor (c);
|
insilmaril@721
|
3338 |
}
|
insilmaril@721
|
3339 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3340 |
} else if (com=="setMapLinkStyle")
|
insilmaril@721
|
3341 |
{
|
insilmaril@721
|
3342 |
if (parser.checkParCount(1))
|
insilmaril@721
|
3343 |
{
|
insilmaril@721
|
3344 |
s=parser.parString (ok,0);
|
insilmaril@721
|
3345 |
if (ok) setMapLinkStyle(s);
|
insilmaril@721
|
3346 |
}
|
insilmaril@721
|
3347 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3348 |
} else if (com=="setHeading")
|
insilmaril@721
|
3349 |
{
|
insilmaril@721
|
3350 |
if (selection.isEmpty() )
|
insilmaril@721
|
3351 |
{
|
insilmaril@721
|
3352 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
3353 |
} else if (! selb )
|
insilmaril@721
|
3354 |
{
|
insilmaril@721
|
3355 |
parser.setError (Aborted,"Type of selection is not a branch");
|
insilmaril@721
|
3356 |
} else if (parser.checkParCount(1))
|
insilmaril@721
|
3357 |
{
|
insilmaril@721
|
3358 |
s=parser.parString (ok,0);
|
insilmaril@721
|
3359 |
if (ok)
|
insilmaril@721
|
3360 |
setHeading (s);
|
insilmaril@721
|
3361 |
}
|
insilmaril@721
|
3362 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3363 |
} else if (com=="setHideExport")
|
insilmaril@721
|
3364 |
{
|
insilmaril@721
|
3365 |
if (selection.isEmpty() )
|
insilmaril@721
|
3366 |
{
|
insilmaril@721
|
3367 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
3368 |
} else if (selection.type()!=Selection::Branch && selection.type() != Selection::MapCenter &&selection.type()!=Selection::FloatImage)
|
insilmaril@721
|
3369 |
{
|
insilmaril@721
|
3370 |
parser.setError (Aborted,"Type of selection is not a branch or floatimage");
|
insilmaril@721
|
3371 |
} else if (parser.checkParCount(1))
|
insilmaril@721
|
3372 |
{
|
insilmaril@721
|
3373 |
b=parser.parBool(ok,0);
|
insilmaril@721
|
3374 |
if (ok) setHideExport (b);
|
insilmaril@721
|
3375 |
}
|
insilmaril@721
|
3376 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3377 |
} else if (com=="setIncludeImagesHorizontally")
|
insilmaril@721
|
3378 |
{
|
insilmaril@721
|
3379 |
if (selection.isEmpty() )
|
insilmaril@721
|
3380 |
{
|
insilmaril@721
|
3381 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
3382 |
} else if (! selb)
|
insilmaril@721
|
3383 |
{
|
insilmaril@721
|
3384 |
parser.setError (Aborted,"Type of selection is not a branch");
|
insilmaril@721
|
3385 |
} else if (parser.checkParCount(1))
|
insilmaril@721
|
3386 |
{
|
insilmaril@721
|
3387 |
b=parser.parBool(ok,0);
|
insilmaril@721
|
3388 |
if (ok) setIncludeImagesHor(b);
|
insilmaril@721
|
3389 |
}
|
insilmaril@721
|
3390 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3391 |
} else if (com=="setIncludeImagesVertically")
|
insilmaril@721
|
3392 |
{
|
insilmaril@721
|
3393 |
if (selection.isEmpty() )
|
insilmaril@721
|
3394 |
{
|
insilmaril@721
|
3395 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
3396 |
} else if (! selb)
|
insilmaril@721
|
3397 |
{
|
insilmaril@721
|
3398 |
parser.setError (Aborted,"Type of selection is not a branch");
|
insilmaril@721
|
3399 |
} else if (parser.checkParCount(1))
|
insilmaril@721
|
3400 |
{
|
insilmaril@721
|
3401 |
b=parser.parBool(ok,0);
|
insilmaril@721
|
3402 |
if (ok) setIncludeImagesVer(b);
|
insilmaril@721
|
3403 |
}
|
insilmaril@721
|
3404 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3405 |
} else if (com=="setHideLinkUnselected")
|
insilmaril@721
|
3406 |
{
|
insilmaril@721
|
3407 |
if (selection.isEmpty() )
|
insilmaril@721
|
3408 |
{
|
insilmaril@721
|
3409 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
3410 |
} else if ( selection.type()!=Selection::Branch && selection.type()!= Selection::MapCenter && selection.type()!=Selection::FloatImage)
|
insilmaril@721
|
3411 |
{
|
insilmaril@721
|
3412 |
parser.setError (Aborted,"Type of selection does not allow hiding the link");
|
insilmaril@721
|
3413 |
} else if (parser.checkParCount(1))
|
insilmaril@721
|
3414 |
{
|
insilmaril@721
|
3415 |
b=parser.parBool(ok,0);
|
insilmaril@721
|
3416 |
if (ok) setHideLinkUnselected(b);
|
insilmaril@721
|
3417 |
}
|
insilmaril@721
|
3418 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3419 |
} else if (com=="setSelectionColor")
|
insilmaril@721
|
3420 |
{
|
insilmaril@721
|
3421 |
if (parser.checkParCount(1))
|
insilmaril@721
|
3422 |
{
|
insilmaril@721
|
3423 |
QColor c=parser.parColor (ok,0);
|
insilmaril@721
|
3424 |
if (ok) setSelectionColorInt (c);
|
insilmaril@721
|
3425 |
}
|
insilmaril@721
|
3426 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3427 |
} else if (com=="setURL")
|
insilmaril@721
|
3428 |
{
|
insilmaril@721
|
3429 |
if (selection.isEmpty() )
|
insilmaril@721
|
3430 |
{
|
insilmaril@721
|
3431 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
3432 |
} else if (! selb )
|
insilmaril@721
|
3433 |
{
|
insilmaril@721
|
3434 |
parser.setError (Aborted,"Type of selection is not a branch");
|
insilmaril@721
|
3435 |
} else if (parser.checkParCount(1))
|
insilmaril@721
|
3436 |
{
|
insilmaril@721
|
3437 |
s=parser.parString (ok,0);
|
insilmaril@721
|
3438 |
if (ok) setURL(s);
|
insilmaril@721
|
3439 |
}
|
insilmaril@721
|
3440 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3441 |
} else if (com=="setVymLink")
|
insilmaril@721
|
3442 |
{
|
insilmaril@721
|
3443 |
if (selection.isEmpty() )
|
insilmaril@721
|
3444 |
{
|
insilmaril@721
|
3445 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
3446 |
} else if (! selb )
|
insilmaril@721
|
3447 |
{
|
insilmaril@721
|
3448 |
parser.setError (Aborted,"Type of selection is not a branch");
|
insilmaril@721
|
3449 |
} else if (parser.checkParCount(1))
|
insilmaril@721
|
3450 |
{
|
insilmaril@721
|
3451 |
s=parser.parString (ok,0);
|
insilmaril@721
|
3452 |
if (ok) setVymLink(s);
|
insilmaril@721
|
3453 |
}
|
insilmaril@721
|
3454 |
}
|
insilmaril@721
|
3455 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3456 |
else if (com=="setFlag")
|
insilmaril@721
|
3457 |
{
|
insilmaril@721
|
3458 |
if (selection.isEmpty() )
|
insilmaril@721
|
3459 |
{
|
insilmaril@721
|
3460 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
3461 |
} else if (! selb )
|
insilmaril@721
|
3462 |
{
|
insilmaril@721
|
3463 |
parser.setError (Aborted,"Type of selection is not a branch");
|
insilmaril@721
|
3464 |
} else if (parser.checkParCount(1))
|
insilmaril@721
|
3465 |
{
|
insilmaril@721
|
3466 |
s=parser.parString(ok,0);
|
insilmaril@721
|
3467 |
if (ok)
|
insilmaril@721
|
3468 |
{
|
insilmaril@721
|
3469 |
selb->activateStandardFlag(s);
|
insilmaril@721
|
3470 |
selb->updateFlagsToolbar();
|
insilmaril@721
|
3471 |
}
|
insilmaril@721
|
3472 |
}
|
insilmaril@721
|
3473 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3474 |
} else if (com=="setFrameType")
|
insilmaril@721
|
3475 |
{
|
insilmaril@721
|
3476 |
if (selection.isEmpty() )
|
insilmaril@721
|
3477 |
{
|
insilmaril@721
|
3478 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
3479 |
} else if (! selb )
|
insilmaril@721
|
3480 |
{
|
insilmaril@721
|
3481 |
parser.setError (Aborted,"Type of selection is not a branch");
|
insilmaril@721
|
3482 |
} else if (parser.checkParCount(1))
|
insilmaril@721
|
3483 |
{
|
insilmaril@721
|
3484 |
s=parser.parString(ok,0);
|
insilmaril@721
|
3485 |
if (ok)
|
insilmaril@721
|
3486 |
setFrameType (s);
|
insilmaril@721
|
3487 |
}
|
insilmaril@721
|
3488 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3489 |
} else if (com=="sortChildren")
|
insilmaril@721
|
3490 |
{
|
insilmaril@721
|
3491 |
if (selection.isEmpty() )
|
insilmaril@721
|
3492 |
{
|
insilmaril@721
|
3493 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
3494 |
} else if (! selb )
|
insilmaril@721
|
3495 |
{
|
insilmaril@721
|
3496 |
parser.setError (Aborted,"Type of selection is not a branch");
|
insilmaril@721
|
3497 |
} else if (parser.checkParCount(0))
|
insilmaril@721
|
3498 |
{
|
insilmaril@721
|
3499 |
sortChildren();
|
insilmaril@721
|
3500 |
}
|
insilmaril@721
|
3501 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3502 |
} else if (com=="toggleFlag")
|
insilmaril@721
|
3503 |
{
|
insilmaril@721
|
3504 |
if (selection.isEmpty() )
|
insilmaril@721
|
3505 |
{
|
insilmaril@721
|
3506 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
3507 |
} else if (! selb )
|
insilmaril@721
|
3508 |
{
|
insilmaril@721
|
3509 |
parser.setError (Aborted,"Type of selection is not a branch");
|
insilmaril@721
|
3510 |
} else if (parser.checkParCount(1))
|
insilmaril@721
|
3511 |
{
|
insilmaril@721
|
3512 |
s=parser.parString(ok,0);
|
insilmaril@721
|
3513 |
if (ok)
|
insilmaril@721
|
3514 |
{
|
insilmaril@721
|
3515 |
selb->toggleStandardFlag(s);
|
insilmaril@721
|
3516 |
selb->updateFlagsToolbar();
|
insilmaril@721
|
3517 |
}
|
insilmaril@721
|
3518 |
}
|
insilmaril@721
|
3519 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3520 |
} else if (com=="unscroll")
|
insilmaril@721
|
3521 |
{
|
insilmaril@721
|
3522 |
if (selection.isEmpty() )
|
insilmaril@721
|
3523 |
{
|
insilmaril@721
|
3524 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
3525 |
} else if (! selb )
|
insilmaril@721
|
3526 |
{
|
insilmaril@721
|
3527 |
parser.setError (Aborted,"Type of selection is not a branch");
|
insilmaril@721
|
3528 |
} else if (parser.checkParCount(0))
|
insilmaril@721
|
3529 |
{
|
insilmaril@721
|
3530 |
if (!unscrollBranch (selb))
|
insilmaril@721
|
3531 |
parser.setError (Aborted,"Could not unscroll branch");
|
insilmaril@721
|
3532 |
}
|
insilmaril@721
|
3533 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3534 |
} else if (com=="unscrollChildren")
|
insilmaril@721
|
3535 |
{
|
insilmaril@721
|
3536 |
if (selection.isEmpty() )
|
insilmaril@721
|
3537 |
{
|
insilmaril@721
|
3538 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
3539 |
} else if (! selb )
|
insilmaril@721
|
3540 |
{
|
insilmaril@721
|
3541 |
parser.setError (Aborted,"Type of selection is not a branch");
|
insilmaril@721
|
3542 |
} else if (parser.checkParCount(0))
|
insilmaril@721
|
3543 |
{
|
insilmaril@721
|
3544 |
unscrollChildren ();
|
insilmaril@721
|
3545 |
}
|
insilmaril@721
|
3546 |
/////////////////////////////////////////////////////////////////////
|
insilmaril@721
|
3547 |
} else if (com=="unsetFlag")
|
insilmaril@721
|
3548 |
{
|
insilmaril@721
|
3549 |
if (selection.isEmpty() )
|
insilmaril@721
|
3550 |
{
|
insilmaril@721
|
3551 |
parser.setError (Aborted,"Nothing selected");
|
insilmaril@721
|
3552 |
} else if (! selb )
|
insilmaril@721
|
3553 |
{
|
insilmaril@721
|
3554 |
parser.setError (Aborted,"Type of selection is not a branch");
|
insilmaril@721
|
3555 |
} else if (parser.checkParCount(1))
|
insilmaril@721
|
3556 |
{
|
insilmaril@721
|
3557 |
s=parser.parString(ok,0);
|
insilmaril@721
|
3558 |
if (ok)
|
insilmaril@721
|
3559 |
{
|
insilmaril@721
|
3560 |
selb->deactivateStandardFlag(s);
|
insilmaril@721
|
3561 |
selb->updateFlagsToolbar();
|
insilmaril@721
|
3562 |
}
|
insilmaril@721
|
3563 |
}
|
insilmaril@721
|
3564 |
} else
|
insilmaril@721
|
3565 |
parser.setError (Aborted,"Unknown command");
|
insilmaril@721
|
3566 |
|
insilmaril@721
|
3567 |
// Any errors?
|
insilmaril@721
|
3568 |
if (parser.errorLevel()==NoError)
|
insilmaril@721
|
3569 |
{
|
insilmaril@721
|
3570 |
// setChanged(); FIXME should not be called e.g. for export?!
|
insilmaril@721
|
3571 |
reposition();
|
insilmaril@721
|
3572 |
}
|
insilmaril@721
|
3573 |
else
|
insilmaril@721
|
3574 |
{
|
insilmaril@721
|
3575 |
// TODO Error handling
|
insilmaril@721
|
3576 |
qWarning("VymModel::parseAtom: Error!");
|
insilmaril@721
|
3577 |
qWarning(parser.errorMessage());
|
insilmaril@721
|
3578 |
}
|
insilmaril@721
|
3579 |
}
|
insilmaril@721
|
3580 |
|
insilmaril@721
|
3581 |
void VymModel::runScript (QString script)
|
insilmaril@721
|
3582 |
{
|
insilmaril@721
|
3583 |
parser.setScript (script);
|
insilmaril@721
|
3584 |
parser.runScript();
|
insilmaril@721
|
3585 |
while (parser.next() )
|
insilmaril@721
|
3586 |
parseAtom(parser.getAtom());
|
insilmaril@721
|
3587 |
}
|
insilmaril@721
|
3588 |
|
insilmaril@721
|
3589 |
void VymModel::setExportMode (bool b)
|
insilmaril@721
|
3590 |
{
|
insilmaril@721
|
3591 |
// should be called before and after exports
|
insilmaril@721
|
3592 |
// depending on the settings
|
insilmaril@721
|
3593 |
if (b && settings.value("/export/useHideExport","true")=="true")
|
insilmaril@721
|
3594 |
setHideTmpMode (HideExport);
|
insilmaril@721
|
3595 |
else
|
insilmaril@721
|
3596 |
setHideTmpMode (HideNone);
|
insilmaril@721
|
3597 |
}
|
insilmaril@721
|
3598 |
|
insilmaril@721
|
3599 |
void VymModel::exportImage(QString fname, bool askName, QString format)
|
insilmaril@721
|
3600 |
{
|
insilmaril@721
|
3601 |
if (fname=="")
|
insilmaril@721
|
3602 |
{
|
insilmaril@721
|
3603 |
fname=getMapName()+".png";
|
insilmaril@721
|
3604 |
format="PNG";
|
insilmaril@721
|
3605 |
}
|
insilmaril@721
|
3606 |
|
insilmaril@721
|
3607 |
if (askName)
|
insilmaril@721
|
3608 |
{
|
insilmaril@721
|
3609 |
QStringList fl;
|
insilmaril@721
|
3610 |
QFileDialog *fd=new QFileDialog (NULL);
|
insilmaril@721
|
3611 |
fd->setCaption (tr("Export map as image"));
|
insilmaril@721
|
3612 |
fd->setDirectory (lastImageDir);
|
insilmaril@721
|
3613 |
fd->setFileMode(QFileDialog::AnyFile);
|
insilmaril@721
|
3614 |
fd->setFilters (imageIO.getFilters() );
|
insilmaril@721
|
3615 |
if (fd->exec())
|
insilmaril@721
|
3616 |
{
|
insilmaril@721
|
3617 |
fl=fd->selectedFiles();
|
insilmaril@721
|
3618 |
fname=fl.first();
|
insilmaril@721
|
3619 |
format=imageIO.getType(fd->selectedFilter());
|
insilmaril@721
|
3620 |
}
|
insilmaril@721
|
3621 |
}
|
insilmaril@721
|
3622 |
|
insilmaril@721
|
3623 |
setExportMode (true);
|
insilmaril@721
|
3624 |
QPixmap pix (getPixmap());
|
insilmaril@721
|
3625 |
pix.save(fname, format);
|
insilmaril@721
|
3626 |
setExportMode (false);
|
insilmaril@721
|
3627 |
}
|
insilmaril@721
|
3628 |
|
insilmaril@721
|
3629 |
|
insilmaril@721
|
3630 |
void VymModel::exportXML(QString dir, bool askForName)
|
insilmaril@721
|
3631 |
{
|
insilmaril@721
|
3632 |
if (askForName)
|
insilmaril@721
|
3633 |
{
|
insilmaril@721
|
3634 |
dir=browseDirectory(NULL,tr("Export XML to directory"));
|
insilmaril@721
|
3635 |
if (dir =="" && !reallyWriteDirectory(dir) )
|
insilmaril@721
|
3636 |
return;
|
insilmaril@721
|
3637 |
}
|
insilmaril@721
|
3638 |
|
insilmaril@721
|
3639 |
// Hide stuff during export, if settings want this
|
insilmaril@721
|
3640 |
setExportMode (true);
|
insilmaril@721
|
3641 |
|
insilmaril@721
|
3642 |
// Create subdirectories
|
insilmaril@721
|
3643 |
makeSubDirs (dir);
|
insilmaril@721
|
3644 |
|
insilmaril@721
|
3645 |
// write to directory
|
insilmaril@721
|
3646 |
QString saveFile=saveToDir (dir,mapName+"-",true,getTotalBBox().topLeft() ,NULL);
|
insilmaril@721
|
3647 |
QFile file;
|
insilmaril@721
|
3648 |
|
insilmaril@721
|
3649 |
file.setName ( dir + "/"+mapName+".xml");
|
insilmaril@721
|
3650 |
if ( !file.open( QIODevice::WriteOnly ) )
|
insilmaril@721
|
3651 |
{
|
insilmaril@721
|
3652 |
// This should neverever happen
|
insilmaril@721
|
3653 |
QMessageBox::critical (0,tr("Critical Export Error"),tr("VymModel::exportXML couldn't open %1").arg(file.name()));
|
insilmaril@721
|
3654 |
return;
|
insilmaril@721
|
3655 |
}
|
insilmaril@721
|
3656 |
|
insilmaril@721
|
3657 |
// Write it finally, and write in UTF8, no matter what
|
insilmaril@721
|
3658 |
QTextStream ts( &file );
|
insilmaril@721
|
3659 |
ts.setEncoding (QTextStream::UnicodeUTF8);
|
insilmaril@721
|
3660 |
ts << saveFile;
|
insilmaril@721
|
3661 |
file.close();
|
insilmaril@721
|
3662 |
|
insilmaril@721
|
3663 |
// Now write image, too
|
insilmaril@721
|
3664 |
exportImage (dir+"/images/"+mapName+".png",false,"PNG");
|
insilmaril@721
|
3665 |
|
insilmaril@721
|
3666 |
setExportMode (false);
|
insilmaril@721
|
3667 |
}
|
insilmaril@721
|
3668 |
|
insilmaril@721
|
3669 |
void VymModel::exportASCII(QString fname,bool askName)
|
insilmaril@721
|
3670 |
{
|
insilmaril@721
|
3671 |
ExportASCII ex;
|
insilmaril@721
|
3672 |
ex.setModel (this);
|
insilmaril@721
|
3673 |
if (fname=="")
|
insilmaril@721
|
3674 |
ex.setFile (mapName+".txt");
|
insilmaril@721
|
3675 |
else
|
insilmaril@721
|
3676 |
ex.setFile (fname);
|
insilmaril@721
|
3677 |
|
insilmaril@721
|
3678 |
if (askName)
|
insilmaril@721
|
3679 |
{
|
insilmaril@721
|
3680 |
//ex.addFilter ("TXT (*.txt)");
|
insilmaril@721
|
3681 |
ex.setDir(lastImageDir);
|
insilmaril@721
|
3682 |
//ex.setCaption(vymName+ " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
|
insilmaril@721
|
3683 |
ex.execDialog() ;
|
insilmaril@721
|
3684 |
}
|
insilmaril@721
|
3685 |
if (!ex.canceled())
|
insilmaril@721
|
3686 |
{
|
insilmaril@721
|
3687 |
setExportMode(true);
|
insilmaril@721
|
3688 |
ex.doExport();
|
insilmaril@721
|
3689 |
setExportMode(false);
|
insilmaril@721
|
3690 |
}
|
insilmaril@721
|
3691 |
}
|
insilmaril@721
|
3692 |
|
insilmaril@721
|
3693 |
void VymModel::exportXHTML (const QString &dir, bool askForName)
|
insilmaril@721
|
3694 |
{
|
insilmaril@721
|
3695 |
ExportXHTMLDialog dia(NULL);
|
insilmaril@721
|
3696 |
dia.setFilePath (filePath );
|
insilmaril@721
|
3697 |
dia.setMapName (mapName );
|
insilmaril@721
|
3698 |
dia.readSettings();
|
insilmaril@721
|
3699 |
if (dir!="") dia.setDir (dir);
|
insilmaril@721
|
3700 |
|
insilmaril@721
|
3701 |
bool ok=true;
|
insilmaril@721
|
3702 |
|
insilmaril@721
|
3703 |
if (askForName)
|
insilmaril@721
|
3704 |
{
|
insilmaril@721
|
3705 |
if (dia.exec()!=QDialog::Accepted)
|
insilmaril@721
|
3706 |
ok=false;
|
insilmaril@721
|
3707 |
else
|
insilmaril@721
|
3708 |
{
|
insilmaril@721
|
3709 |
QDir d (dia.getDir());
|
insilmaril@721
|
3710 |
// Check, if warnings should be used before overwriting
|
insilmaril@721
|
3711 |
// the output directory
|
insilmaril@721
|
3712 |
if (d.exists() && d.count()>0)
|
insilmaril@721
|
3713 |
{
|
insilmaril@721
|
3714 |
WarningDialog warn;
|
insilmaril@721
|
3715 |
warn.showCancelButton (true);
|
insilmaril@721
|
3716 |
warn.setText(QString(
|
insilmaril@721
|
3717 |
"The directory %1 is not empty.\n"
|
insilmaril@721
|
3718 |
"Do you risk to overwrite some of its contents?").arg(d.path() ));
|
insilmaril@721
|
3719 |
warn.setCaption("Warning: Directory not empty");
|
insilmaril@721
|
3720 |
warn.setShowAgainName("mainwindow/overwrite-dir-xhtml");
|
insilmaril@721
|
3721 |
|
insilmaril@721
|
3722 |
if (warn.exec()!=QDialog::Accepted) ok=false;
|
insilmaril@721
|
3723 |
}
|
insilmaril@721
|
3724 |
}
|
insilmaril@721
|
3725 |
}
|
insilmaril@721
|
3726 |
|
insilmaril@721
|
3727 |
if (ok)
|
insilmaril@721
|
3728 |
{
|
insilmaril@721
|
3729 |
exportXML (dia.getDir(),false );
|
insilmaril@721
|
3730 |
dia.doExport(mapName );
|
insilmaril@721
|
3731 |
//if (dia.hasChanged()) setChanged();
|
insilmaril@721
|
3732 |
}
|
insilmaril@721
|
3733 |
}
|
insilmaril@721
|
3734 |
|
insilmaril@721
|
3735 |
void VymModel::exportOOPresentation(const QString &fn, const QString &cf)
|
insilmaril@721
|
3736 |
{
|
insilmaril@721
|
3737 |
ExportOO ex;
|
insilmaril@721
|
3738 |
ex.setFile (fn);
|
insilmaril@721
|
3739 |
ex.setModel (this);
|
insilmaril@721
|
3740 |
if (ex.setConfigFile(cf))
|
insilmaril@721
|
3741 |
{
|
insilmaril@721
|
3742 |
setExportMode (true);
|
insilmaril@721
|
3743 |
ex.exportPresentation();
|
insilmaril@721
|
3744 |
setExportMode (false);
|
insilmaril@721
|
3745 |
}
|
insilmaril@721
|
3746 |
}
|
insilmaril@721
|
3747 |
|
insilmaril@721
|
3748 |
|
insilmaril@721
|
3749 |
|
insilmaril@650
|
3750 |
|
insilmaril@652
|
3751 |
//////////////////////////////////////////////
|
insilmaril@652
|
3752 |
// View related
|
insilmaril@652
|
3753 |
//////////////////////////////////////////////
|
insilmaril@652
|
3754 |
|
insilmaril@723
|
3755 |
void VymModel::registerEditor(QWidget *me)
|
insilmaril@721
|
3756 |
{
|
insilmaril@723
|
3757 |
mapEditor=(MapEditor*)me;
|
insilmaril@723
|
3758 |
for (int i=0; i<mapCenters.count(); i++)
|
insilmaril@723
|
3759 |
mapCenters.at(i)->setMapEditor(mapEditor);
|
insilmaril@721
|
3760 |
}
|
insilmaril@721
|
3761 |
|
insilmaril@721
|
3762 |
void VymModel::unregisterEditor(QWidget *)
|
insilmaril@721
|
3763 |
{
|
insilmaril@723
|
3764 |
mapEditor=NULL;
|
insilmaril@723
|
3765 |
}
|
insilmaril@723
|
3766 |
|
insilmaril@723
|
3767 |
void VymModel::setContextPos(QPointF p)
|
insilmaril@723
|
3768 |
{
|
insilmaril@723
|
3769 |
contextPos=p;
|
insilmaril@723
|
3770 |
}
|
insilmaril@723
|
3771 |
|
insilmaril@723
|
3772 |
void VymModel::unsetContextPos()
|
insilmaril@723
|
3773 |
{
|
insilmaril@723
|
3774 |
contextPos=QPointF();
|
insilmaril@721
|
3775 |
}
|
insilmaril@721
|
3776 |
|
insilmaril@721
|
3777 |
void VymModel::updateNoteFlag()
|
insilmaril@721
|
3778 |
{
|
insilmaril@721
|
3779 |
setChanged();
|
insilmaril@721
|
3780 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
3781 |
if (bo)
|
insilmaril@721
|
3782 |
{
|
insilmaril@721
|
3783 |
bo->updateNoteFlag();
|
insilmaril@721
|
3784 |
mainWindow->updateActions();
|
insilmaril@721
|
3785 |
}
|
insilmaril@721
|
3786 |
}
|
insilmaril@721
|
3787 |
|
insilmaril@652
|
3788 |
void VymModel::updateRelPositions()
|
insilmaril@652
|
3789 |
{
|
insilmaril@652
|
3790 |
for (int i=0; i<mapCenters.count(); i++)
|
insilmaril@652
|
3791 |
mapCenters.at(i)->updateRelPositions();
|
insilmaril@652
|
3792 |
}
|
insilmaril@652
|
3793 |
|
insilmaril@652
|
3794 |
void VymModel::reposition()
|
insilmaril@652
|
3795 |
{
|
insilmaril@652
|
3796 |
for (int i=0;i<mapCenters.count(); i++)
|
insilmaril@652
|
3797 |
mapCenters.at(i)->reposition(); // for positioning heading
|
insilmaril@652
|
3798 |
}
|
insilmaril@652
|
3799 |
|
insilmaril@665
|
3800 |
QPolygonF VymModel::shape(BranchObj *bo)
|
insilmaril@665
|
3801 |
{
|
insilmaril@665
|
3802 |
// Creating (arbitrary) shapes
|
insilmaril@665
|
3803 |
|
insilmaril@665
|
3804 |
QPolygonF p;
|
insilmaril@665
|
3805 |
QRectF rb=bo->getBBox();
|
insilmaril@665
|
3806 |
if (bo->getDepth()==0)
|
insilmaril@665
|
3807 |
{
|
insilmaril@665
|
3808 |
// Just take BBox of this mapCenter
|
insilmaril@665
|
3809 |
p<<rb.topLeft()<<rb.topRight()<<rb.bottomRight()<<rb.bottomLeft();
|
insilmaril@665
|
3810 |
return p;
|
insilmaril@665
|
3811 |
}
|
insilmaril@665
|
3812 |
|
insilmaril@665
|
3813 |
// Take union of BBox and TotalBBox
|
insilmaril@665
|
3814 |
|
insilmaril@665
|
3815 |
QRectF ra=bo->getTotalBBox();
|
insilmaril@665
|
3816 |
if (bo->getOrientation()==LinkableMapObj::LeftOfCenter)
|
insilmaril@665
|
3817 |
p <<ra.bottomLeft()
|
insilmaril@665
|
3818 |
<<ra.topLeft()
|
insilmaril@665
|
3819 |
<<QPointF (rb.topLeft().x(), ra.topLeft().y() )
|
insilmaril@665
|
3820 |
<<rb.topRight()
|
insilmaril@665
|
3821 |
<<rb.bottomRight()
|
insilmaril@665
|
3822 |
<<QPointF (rb.bottomLeft().x(), ra.bottomLeft().y() ) ;
|
insilmaril@665
|
3823 |
else
|
insilmaril@665
|
3824 |
p <<ra.bottomRight()
|
insilmaril@665
|
3825 |
<<ra.topRight()
|
insilmaril@665
|
3826 |
<<QPointF (rb.topRight().x(), ra.topRight().y() )
|
insilmaril@665
|
3827 |
<<rb.topLeft()
|
insilmaril@665
|
3828 |
<<rb.bottomLeft()
|
insilmaril@665
|
3829 |
<<QPointF (rb.bottomRight().x(), ra.bottomRight().y() ) ;
|
insilmaril@665
|
3830 |
return p;
|
insilmaril@665
|
3831 |
|
insilmaril@665
|
3832 |
}
|
insilmaril@665
|
3833 |
|
insilmaril@665
|
3834 |
void VymModel::moveAway(LinkableMapObj *lmo)
|
insilmaril@665
|
3835 |
{
|
insilmaril@665
|
3836 |
// Autolayout:
|
insilmaril@665
|
3837 |
//
|
insilmaril@665
|
3838 |
// Move all branches and MapCenters away from lmo
|
insilmaril@665
|
3839 |
// to avoid collisions
|
insilmaril@665
|
3840 |
|
insilmaril@665
|
3841 |
QPolygonF pA;
|
insilmaril@665
|
3842 |
QPolygonF pB;
|
insilmaril@665
|
3843 |
|
insilmaril@665
|
3844 |
BranchObj *boA=(BranchObj*)lmo;
|
insilmaril@665
|
3845 |
BranchObj *boB;
|
insilmaril@665
|
3846 |
for (int i=0; i<mapCenters.count(); i++)
|
insilmaril@665
|
3847 |
{
|
insilmaril@665
|
3848 |
boB=mapCenters.at(i);
|
insilmaril@665
|
3849 |
pA=shape (boA);
|
insilmaril@665
|
3850 |
pB=shape (boB);
|
insilmaril@665
|
3851 |
PolygonCollisionResult r = PolygonCollision(pA, pB, QPoint(0,0));
|
insilmaril@665
|
3852 |
cout <<"------->"
|
insilmaril@665
|
3853 |
<<"="<<r.intersect
|
insilmaril@665
|
3854 |
<<" ("<<qPrintable(boA->getHeading() )<<")"
|
insilmaril@665
|
3855 |
<<" with ("<< qPrintable (boB->getHeading() )
|
insilmaril@665
|
3856 |
<<") willIntersect"
|
insilmaril@665
|
3857 |
<<r.willIntersect
|
insilmaril@665
|
3858 |
<<" minT="<<r.minTranslation<<endl<<endl;
|
insilmaril@665
|
3859 |
}
|
insilmaril@665
|
3860 |
}
|
insilmaril@652
|
3861 |
|
insilmaril@721
|
3862 |
QPixmap VymModel::getPixmap()
|
insilmaril@721
|
3863 |
{
|
insilmaril@721
|
3864 |
QRectF mapRect=getTotalBBox();
|
insilmaril@721
|
3865 |
QPixmap pix((int)mapRect.width()+2,(int)mapRect.height()+1);
|
insilmaril@721
|
3866 |
QPainter pp (&pix);
|
insilmaril@721
|
3867 |
|
insilmaril@721
|
3868 |
pp.setRenderHints(mapEditor->renderHints());
|
insilmaril@721
|
3869 |
|
insilmaril@721
|
3870 |
// Don't print the visualisation of selection
|
insilmaril@721
|
3871 |
selection.unselect();
|
insilmaril@721
|
3872 |
|
insilmaril@721
|
3873 |
mapScene->render ( &pp,
|
insilmaril@721
|
3874 |
QRectF(0,0,mapRect.width()+2,mapRect.height()+2),
|
insilmaril@721
|
3875 |
QRectF(mapRect.x(),mapRect.y(),mapRect.width(),mapRect.height() ));
|
insilmaril@721
|
3876 |
|
insilmaril@721
|
3877 |
// Restore selection
|
insilmaril@721
|
3878 |
selection.reselect();
|
insilmaril@721
|
3879 |
|
insilmaril@721
|
3880 |
return pix;
|
insilmaril@721
|
3881 |
}
|
insilmaril@721
|
3882 |
|
insilmaril@721
|
3883 |
|
insilmaril@721
|
3884 |
void VymModel::setMapLinkStyle (const QString & s)
|
insilmaril@721
|
3885 |
{
|
insilmaril@721
|
3886 |
QString snow;
|
insilmaril@727
|
3887 |
switch (linkstyle)
|
insilmaril@727
|
3888 |
{
|
insilmaril@727
|
3889 |
case LinkableMapObj::Line :
|
insilmaril@727
|
3890 |
snow="StyleLine";
|
insilmaril@727
|
3891 |
break;
|
insilmaril@727
|
3892 |
case LinkableMapObj::Parabel:
|
insilmaril@727
|
3893 |
snow="StyleParabel";
|
insilmaril@727
|
3894 |
break;
|
insilmaril@727
|
3895 |
case LinkableMapObj::PolyLine:
|
insilmaril@727
|
3896 |
snow="StylePolyLine";
|
insilmaril@727
|
3897 |
break;
|
insilmaril@727
|
3898 |
case LinkableMapObj::PolyParabel:
|
insilmaril@727
|
3899 |
snow="StylePolyParabel";
|
insilmaril@727
|
3900 |
break;
|
insilmaril@727
|
3901 |
default:
|
insilmaril@727
|
3902 |
snow="UndefinedStyle";
|
insilmaril@727
|
3903 |
break;
|
insilmaril@727
|
3904 |
}
|
insilmaril@721
|
3905 |
|
insilmaril@721
|
3906 |
saveState (
|
insilmaril@721
|
3907 |
QString("setMapLinkStyle (\"%1\")").arg(s),
|
insilmaril@721
|
3908 |
QString("setMapLinkStyle (\"%1\")").arg(snow),
|
insilmaril@721
|
3909 |
QString("Set map link style (\"%1\")").arg(s)
|
insilmaril@721
|
3910 |
);
|
insilmaril@721
|
3911 |
|
insilmaril@721
|
3912 |
if (s=="StyleLine")
|
insilmaril@721
|
3913 |
linkstyle=LinkableMapObj::Line;
|
insilmaril@721
|
3914 |
else if (s=="StyleParabel")
|
insilmaril@721
|
3915 |
linkstyle=LinkableMapObj::Parabel;
|
insilmaril@721
|
3916 |
else if (s=="StylePolyLine")
|
insilmaril@721
|
3917 |
linkstyle=LinkableMapObj::PolyLine;
|
insilmaril@727
|
3918 |
else if (s=="StylePolyParabel")
|
insilmaril@721
|
3919 |
linkstyle=LinkableMapObj::PolyParabel;
|
insilmaril@727
|
3920 |
else
|
insilmaril@727
|
3921 |
linkstyle=LinkableMapObj::UndefinedStyle;
|
insilmaril@721
|
3922 |
|
insilmaril@721
|
3923 |
BranchObj *bo;
|
insilmaril@721
|
3924 |
bo=first();
|
insilmaril@721
|
3925 |
bo=next(bo);
|
insilmaril@721
|
3926 |
while (bo)
|
insilmaril@721
|
3927 |
{
|
insilmaril@721
|
3928 |
bo->setLinkStyle(bo->getDefLinkStyle());
|
insilmaril@721
|
3929 |
bo=next(bo);
|
insilmaril@721
|
3930 |
}
|
insilmaril@721
|
3931 |
reposition();
|
insilmaril@721
|
3932 |
}
|
insilmaril@721
|
3933 |
|
insilmaril@721
|
3934 |
LinkableMapObj::Style VymModel::getMapLinkStyle ()
|
insilmaril@721
|
3935 |
{
|
insilmaril@721
|
3936 |
return linkstyle;
|
insilmaril@721
|
3937 |
}
|
insilmaril@721
|
3938 |
|
insilmaril@721
|
3939 |
void VymModel::setMapDefLinkColor(QColor col)
|
insilmaril@721
|
3940 |
{
|
insilmaril@721
|
3941 |
if ( !col.isValid() ) return;
|
insilmaril@721
|
3942 |
saveState (
|
insilmaril@721
|
3943 |
QString("setMapDefLinkColor (\"%1\")").arg(getMapDefLinkColor().name()),
|
insilmaril@721
|
3944 |
QString("setMapDefLinkColor (\"%1\")").arg(col.name()),
|
insilmaril@721
|
3945 |
QString("Set map link color to %1").arg(col.name())
|
insilmaril@721
|
3946 |
);
|
insilmaril@721
|
3947 |
|
insilmaril@721
|
3948 |
defLinkColor=col;
|
insilmaril@721
|
3949 |
BranchObj *bo;
|
insilmaril@721
|
3950 |
bo=first();
|
insilmaril@721
|
3951 |
while (bo)
|
insilmaril@721
|
3952 |
{
|
insilmaril@721
|
3953 |
bo->setLinkColor();
|
insilmaril@721
|
3954 |
bo=next(bo);
|
insilmaril@721
|
3955 |
}
|
insilmaril@721
|
3956 |
updateActions();
|
insilmaril@721
|
3957 |
}
|
insilmaril@721
|
3958 |
|
insilmaril@721
|
3959 |
void VymModel::setMapLinkColorHintInt()
|
insilmaril@721
|
3960 |
{
|
insilmaril@721
|
3961 |
// called from setMapLinkColorHint(lch) or at end of parse
|
insilmaril@721
|
3962 |
BranchObj *bo;
|
insilmaril@721
|
3963 |
bo=first();
|
insilmaril@721
|
3964 |
while (bo)
|
insilmaril@721
|
3965 |
{
|
insilmaril@721
|
3966 |
bo->setLinkColor();
|
insilmaril@721
|
3967 |
bo=next(bo);
|
insilmaril@721
|
3968 |
}
|
insilmaril@721
|
3969 |
}
|
insilmaril@721
|
3970 |
|
insilmaril@721
|
3971 |
void VymModel::setMapLinkColorHint(LinkableMapObj::ColorHint lch)
|
insilmaril@721
|
3972 |
{
|
insilmaril@721
|
3973 |
linkcolorhint=lch;
|
insilmaril@721
|
3974 |
setMapLinkColorHintInt();
|
insilmaril@721
|
3975 |
}
|
insilmaril@721
|
3976 |
|
insilmaril@721
|
3977 |
void VymModel::toggleMapLinkColorHint()
|
insilmaril@721
|
3978 |
{
|
insilmaril@721
|
3979 |
if (linkcolorhint==LinkableMapObj::HeadingColor)
|
insilmaril@721
|
3980 |
linkcolorhint=LinkableMapObj::DefaultColor;
|
insilmaril@721
|
3981 |
else
|
insilmaril@721
|
3982 |
linkcolorhint=LinkableMapObj::HeadingColor;
|
insilmaril@721
|
3983 |
BranchObj *bo;
|
insilmaril@721
|
3984 |
bo=first();
|
insilmaril@721
|
3985 |
while (bo)
|
insilmaril@721
|
3986 |
{
|
insilmaril@721
|
3987 |
bo->setLinkColor();
|
insilmaril@721
|
3988 |
bo=next(bo);
|
insilmaril@721
|
3989 |
}
|
insilmaril@721
|
3990 |
}
|
insilmaril@721
|
3991 |
|
insilmaril@721
|
3992 |
void VymModel::selectMapBackgroundImage ()
|
insilmaril@721
|
3993 |
{
|
insilmaril@721
|
3994 |
Q3FileDialog *fd=new Q3FileDialog( NULL);
|
insilmaril@721
|
3995 |
fd->setMode (Q3FileDialog::ExistingFile);
|
insilmaril@721
|
3996 |
fd->addFilter (QString (tr("Images") + " (*.png *.bmp *.xbm *.jpg *.png *.xpm *.gif *.pnm)"));
|
insilmaril@721
|
3997 |
ImagePreview *p =new ImagePreview (fd);
|
insilmaril@721
|
3998 |
fd->setContentsPreviewEnabled( TRUE );
|
insilmaril@721
|
3999 |
fd->setContentsPreview( p, p );
|
insilmaril@721
|
4000 |
fd->setPreviewMode( Q3FileDialog::Contents );
|
insilmaril@721
|
4001 |
fd->setCaption(vymName+" - " +tr("Load background image"));
|
insilmaril@721
|
4002 |
fd->setDir (lastImageDir);
|
insilmaril@721
|
4003 |
fd->show();
|
insilmaril@721
|
4004 |
|
insilmaril@721
|
4005 |
if ( fd->exec() == QDialog::Accepted )
|
insilmaril@721
|
4006 |
{
|
insilmaril@721
|
4007 |
// TODO selectMapBackgroundImg in QT4 use: lastImageDir=fd->directory();
|
insilmaril@721
|
4008 |
lastImageDir=QDir (fd->dirPath());
|
insilmaril@721
|
4009 |
setMapBackgroundImage (fd->selectedFile());
|
insilmaril@721
|
4010 |
}
|
insilmaril@721
|
4011 |
}
|
insilmaril@721
|
4012 |
|
insilmaril@721
|
4013 |
void VymModel::setMapBackgroundImage (const QString &fn) //FIXME missing savestate
|
insilmaril@721
|
4014 |
{
|
insilmaril@721
|
4015 |
QColor oldcol=mapScene->backgroundBrush().color();
|
insilmaril@721
|
4016 |
/*
|
insilmaril@721
|
4017 |
saveState(
|
insilmaril@721
|
4018 |
selection,
|
insilmaril@721
|
4019 |
QString ("setMapBackgroundImage (%1)").arg(oldcol.name()),
|
insilmaril@721
|
4020 |
selection,
|
insilmaril@721
|
4021 |
QString ("setMapBackgroundImage (%1)").arg(col.name()),
|
insilmaril@721
|
4022 |
QString("Set background color of map to %1").arg(col.name()));
|
insilmaril@721
|
4023 |
*/
|
insilmaril@721
|
4024 |
QBrush brush;
|
insilmaril@721
|
4025 |
brush.setTextureImage (QPixmap (fn));
|
insilmaril@721
|
4026 |
mapScene->setBackgroundBrush(brush);
|
insilmaril@721
|
4027 |
}
|
insilmaril@721
|
4028 |
|
insilmaril@721
|
4029 |
void VymModel::selectMapBackgroundColor()
|
insilmaril@721
|
4030 |
{
|
insilmaril@721
|
4031 |
QColor col = QColorDialog::getColor( mapScene->backgroundBrush().color(), NULL);
|
insilmaril@721
|
4032 |
if ( !col.isValid() ) return;
|
insilmaril@721
|
4033 |
setMapBackgroundColor( col );
|
insilmaril@721
|
4034 |
}
|
insilmaril@721
|
4035 |
|
insilmaril@721
|
4036 |
|
insilmaril@721
|
4037 |
void VymModel::setMapBackgroundColor(QColor col)
|
insilmaril@721
|
4038 |
{
|
insilmaril@721
|
4039 |
QColor oldcol=mapScene->backgroundBrush().color();
|
insilmaril@721
|
4040 |
saveState(
|
insilmaril@721
|
4041 |
QString ("setMapBackgroundColor (\"%1\")").arg(oldcol.name()),
|
insilmaril@721
|
4042 |
QString ("setMapBackgroundColor (\"%1\")").arg(col.name()),
|
insilmaril@721
|
4043 |
QString("Set background color of map to %1").arg(col.name()));
|
insilmaril@721
|
4044 |
mapScene->setBackgroundBrush(col);
|
insilmaril@721
|
4045 |
}
|
insilmaril@721
|
4046 |
|
insilmaril@721
|
4047 |
QColor VymModel::getMapBackgroundColor()
|
insilmaril@721
|
4048 |
{
|
insilmaril@721
|
4049 |
return mapScene->backgroundBrush().color();
|
insilmaril@721
|
4050 |
}
|
insilmaril@721
|
4051 |
|
insilmaril@721
|
4052 |
|
insilmaril@721
|
4053 |
LinkableMapObj::ColorHint VymModel::getMapLinkColorHint()
|
insilmaril@721
|
4054 |
{
|
insilmaril@721
|
4055 |
return linkcolorhint;
|
insilmaril@721
|
4056 |
}
|
insilmaril@721
|
4057 |
|
insilmaril@721
|
4058 |
QColor VymModel::getMapDefLinkColor()
|
insilmaril@721
|
4059 |
{
|
insilmaril@721
|
4060 |
return defLinkColor;
|
insilmaril@721
|
4061 |
}
|
insilmaril@721
|
4062 |
|
insilmaril@721
|
4063 |
void VymModel::setMapDefXLinkColor(QColor col)
|
insilmaril@721
|
4064 |
{
|
insilmaril@721
|
4065 |
defXLinkColor=col;
|
insilmaril@721
|
4066 |
}
|
insilmaril@721
|
4067 |
|
insilmaril@721
|
4068 |
QColor VymModel::getMapDefXLinkColor()
|
insilmaril@721
|
4069 |
{
|
insilmaril@721
|
4070 |
return defXLinkColor;
|
insilmaril@721
|
4071 |
}
|
insilmaril@721
|
4072 |
|
insilmaril@721
|
4073 |
void VymModel::setMapDefXLinkWidth (int w)
|
insilmaril@721
|
4074 |
{
|
insilmaril@721
|
4075 |
defXLinkWidth=w;
|
insilmaril@721
|
4076 |
}
|
insilmaril@721
|
4077 |
|
insilmaril@721
|
4078 |
int VymModel::getMapDefXLinkWidth()
|
insilmaril@721
|
4079 |
{
|
insilmaril@721
|
4080 |
return defXLinkWidth;
|
insilmaril@721
|
4081 |
}
|
insilmaril@721
|
4082 |
|
insilmaril@721
|
4083 |
void VymModel::move(const double &x, const double &y)
|
insilmaril@721
|
4084 |
{
|
insilmaril@721
|
4085 |
LinkableMapObj *sel=selection.single();
|
insilmaril@721
|
4086 |
if (sel)
|
insilmaril@721
|
4087 |
{
|
insilmaril@721
|
4088 |
QPointF ap(sel->getAbsPos());
|
insilmaril@721
|
4089 |
QPointF to(x, y);
|
insilmaril@721
|
4090 |
if (ap != to)
|
insilmaril@721
|
4091 |
{
|
insilmaril@721
|
4092 |
QString ps=qpointfToString(ap);
|
insilmaril@721
|
4093 |
QString s=selection.getSelectString();
|
insilmaril@721
|
4094 |
saveState(
|
insilmaril@721
|
4095 |
s, "move "+ps,
|
insilmaril@721
|
4096 |
s, "move "+qpointfToString(to),
|
insilmaril@721
|
4097 |
QString("Move %1 to %2").arg(getObjectName(sel)).arg(ps));
|
insilmaril@721
|
4098 |
sel->move(x,y);
|
insilmaril@721
|
4099 |
reposition();
|
insilmaril@721
|
4100 |
selection.update();
|
insilmaril@721
|
4101 |
}
|
insilmaril@721
|
4102 |
}
|
insilmaril@721
|
4103 |
}
|
insilmaril@721
|
4104 |
|
insilmaril@721
|
4105 |
void VymModel::moveRel (const double &x, const double &y)
|
insilmaril@721
|
4106 |
{
|
insilmaril@721
|
4107 |
LinkableMapObj *sel=selection.single();
|
insilmaril@721
|
4108 |
if (sel)
|
insilmaril@721
|
4109 |
{
|
insilmaril@721
|
4110 |
QPointF rp(sel->getRelPos());
|
insilmaril@721
|
4111 |
QPointF to(x, y);
|
insilmaril@721
|
4112 |
if (rp != to)
|
insilmaril@721
|
4113 |
{
|
insilmaril@721
|
4114 |
QString ps=qpointfToString (sel->getRelPos());
|
insilmaril@721
|
4115 |
QString s=getSelectString(sel);
|
insilmaril@721
|
4116 |
saveState(
|
insilmaril@721
|
4117 |
s, "moveRel "+ps,
|
insilmaril@721
|
4118 |
s, "moveRel "+qpointfToString(to),
|
insilmaril@721
|
4119 |
QString("Move %1 to relative position %2").arg(getObjectName(sel)).arg(ps));
|
insilmaril@721
|
4120 |
((OrnamentedObj*)sel)->move2RelPos (x,y);
|
insilmaril@721
|
4121 |
reposition();
|
insilmaril@721
|
4122 |
sel->updateLink();
|
insilmaril@721
|
4123 |
selection.update();
|
insilmaril@721
|
4124 |
}
|
insilmaril@721
|
4125 |
}
|
insilmaril@721
|
4126 |
}
|
insilmaril@721
|
4127 |
|
insilmaril@721
|
4128 |
|
insilmaril@696
|
4129 |
void VymModel::animate()
|
insilmaril@696
|
4130 |
{
|
insilmaril@696
|
4131 |
animationTimer->stop();
|
insilmaril@696
|
4132 |
BranchObj *bo;
|
insilmaril@696
|
4133 |
int i=0;
|
insilmaril@696
|
4134 |
while (i<animObjList.size() )
|
insilmaril@696
|
4135 |
{
|
insilmaril@696
|
4136 |
bo=(BranchObj*)animObjList.at(i);
|
insilmaril@696
|
4137 |
if (!bo->animate())
|
insilmaril@696
|
4138 |
{
|
insilmaril@721
|
4139 |
if (i>=0)
|
insilmaril@721
|
4140 |
{
|
insilmaril@721
|
4141 |
animObjList.removeAt(i);
|
insilmaril@721
|
4142 |
i--;
|
insilmaril@721
|
4143 |
}
|
insilmaril@696
|
4144 |
}
|
insilmaril@696
|
4145 |
bo->reposition();
|
insilmaril@696
|
4146 |
i++;
|
insilmaril@696
|
4147 |
}
|
insilmaril@731
|
4148 |
cout << "VM::animate\n";
|
insilmaril@728
|
4149 |
emit (selectionChanged(selModel->selection(), selModel->selection()) );
|
insilmaril@696
|
4150 |
mapScene->update();
|
insilmaril@723
|
4151 |
if (!animObjList.isEmpty()) animationTimer->start();
|
insilmaril@696
|
4152 |
}
|
insilmaril@696
|
4153 |
|
insilmaril@696
|
4154 |
|
insilmaril@723
|
4155 |
void VymModel::startAnimation(BranchObj *bo, const QPointF &start, const QPointF &dest)
|
insilmaril@696
|
4156 |
{
|
insilmaril@696
|
4157 |
if (bo && bo->getDepth()>0)
|
insilmaril@696
|
4158 |
{
|
insilmaril@696
|
4159 |
AnimPoint ap;
|
insilmaril@696
|
4160 |
ap.setStart (start);
|
insilmaril@696
|
4161 |
ap.setDest (dest);
|
insilmaril@696
|
4162 |
ap.setTicks (animationTicks);
|
insilmaril@696
|
4163 |
ap.setAnimated (true);
|
insilmaril@696
|
4164 |
bo->setAnimation (ap);
|
insilmaril@696
|
4165 |
animObjList.append( bo );
|
insilmaril@696
|
4166 |
animationTimer->setSingleShot (true);
|
insilmaril@696
|
4167 |
animationTimer->start(animationInterval);
|
insilmaril@696
|
4168 |
}
|
insilmaril@696
|
4169 |
}
|
insilmaril@696
|
4170 |
|
insilmaril@722
|
4171 |
void VymModel::stopAnimation (MapObj *mo)
|
insilmaril@722
|
4172 |
{
|
insilmaril@722
|
4173 |
int i=animObjList.indexOf(mo);
|
insilmaril@722
|
4174 |
if (i>=0)
|
insilmaril@722
|
4175 |
animObjList.removeAt (i);
|
insilmaril@722
|
4176 |
}
|
insilmaril@722
|
4177 |
|
insilmaril@721
|
4178 |
void VymModel::sendSelection()
|
insilmaril@721
|
4179 |
{
|
insilmaril@721
|
4180 |
if (netstate!=Server) return;
|
insilmaril@721
|
4181 |
sendData (QString("select (\"%1\")").arg(selection.getSelectString()) );
|
insilmaril@721
|
4182 |
}
|
insilmaril@721
|
4183 |
|
insilmaril@721
|
4184 |
void VymModel::newServer()
|
insilmaril@721
|
4185 |
{
|
insilmaril@721
|
4186 |
port=54321;
|
insilmaril@721
|
4187 |
sendCounter=0;
|
insilmaril@721
|
4188 |
tcpServer = new QTcpServer(this);
|
insilmaril@721
|
4189 |
if (!tcpServer->listen(QHostAddress::Any,port)) {
|
insilmaril@721
|
4190 |
QMessageBox::critical(NULL, "vym server",
|
insilmaril@721
|
4191 |
QString("Unable to start the server: %1.").arg(tcpServer->errorString()));
|
insilmaril@721
|
4192 |
//FIXME needed? we are no widget any longer... close();
|
insilmaril@721
|
4193 |
return;
|
insilmaril@721
|
4194 |
}
|
insilmaril@721
|
4195 |
connect(tcpServer, SIGNAL(newConnection()), this, SLOT(newClient()));
|
insilmaril@721
|
4196 |
netstate=Server;
|
insilmaril@721
|
4197 |
cout<<"Server is running on port "<<tcpServer->serverPort()<<endl;
|
insilmaril@721
|
4198 |
}
|
insilmaril@721
|
4199 |
|
insilmaril@721
|
4200 |
void VymModel::connectToServer()
|
insilmaril@721
|
4201 |
{
|
insilmaril@721
|
4202 |
port=54321;
|
insilmaril@721
|
4203 |
server="salam.suse.de";
|
insilmaril@721
|
4204 |
server="localhost";
|
insilmaril@721
|
4205 |
clientSocket = new QTcpSocket (this);
|
insilmaril@721
|
4206 |
clientSocket->abort();
|
insilmaril@721
|
4207 |
clientSocket->connectToHost(server ,port);
|
insilmaril@721
|
4208 |
connect(clientSocket, SIGNAL(readyRead()), this, SLOT(readData()));
|
insilmaril@721
|
4209 |
connect(clientSocket, SIGNAL(error(QAbstractSocket::SocketError)),
|
insilmaril@721
|
4210 |
this, SLOT(displayNetworkError(QAbstractSocket::SocketError)));
|
insilmaril@721
|
4211 |
netstate=Client;
|
insilmaril@721
|
4212 |
cout<<"connected to "<<qPrintable (server)<<" port "<<port<<endl;
|
insilmaril@721
|
4213 |
|
insilmaril@721
|
4214 |
|
insilmaril@721
|
4215 |
}
|
insilmaril@721
|
4216 |
|
insilmaril@721
|
4217 |
void VymModel::newClient()
|
insilmaril@721
|
4218 |
{
|
insilmaril@721
|
4219 |
QTcpSocket *newClient = tcpServer->nextPendingConnection();
|
insilmaril@721
|
4220 |
connect(newClient, SIGNAL(disconnected()),
|
insilmaril@721
|
4221 |
newClient, SLOT(deleteLater()));
|
insilmaril@721
|
4222 |
|
insilmaril@721
|
4223 |
cout <<"ME::newClient at "<<qPrintable( newClient->peerAddress().toString() )<<endl;
|
insilmaril@721
|
4224 |
|
insilmaril@721
|
4225 |
clientList.append (newClient);
|
insilmaril@721
|
4226 |
}
|
insilmaril@721
|
4227 |
|
insilmaril@721
|
4228 |
|
insilmaril@721
|
4229 |
void VymModel::sendData(const QString &s)
|
insilmaril@721
|
4230 |
{
|
insilmaril@721
|
4231 |
if (clientList.size()==0) return;
|
insilmaril@721
|
4232 |
|
insilmaril@721
|
4233 |
// Create bytearray to send
|
insilmaril@721
|
4234 |
QByteArray block;
|
insilmaril@721
|
4235 |
QDataStream out(&block, QIODevice::WriteOnly);
|
insilmaril@721
|
4236 |
out.setVersion(QDataStream::Qt_4_0);
|
insilmaril@721
|
4237 |
|
insilmaril@721
|
4238 |
// Reserve some space for blocksize
|
insilmaril@721
|
4239 |
out << (quint16)0;
|
insilmaril@721
|
4240 |
|
insilmaril@721
|
4241 |
// Write sendCounter
|
insilmaril@721
|
4242 |
out << sendCounter++;
|
insilmaril@721
|
4243 |
|
insilmaril@721
|
4244 |
// Write data
|
insilmaril@721
|
4245 |
out << s;
|
insilmaril@721
|
4246 |
|
insilmaril@721
|
4247 |
// Go back and write blocksize so far
|
insilmaril@721
|
4248 |
out.device()->seek(0);
|
insilmaril@721
|
4249 |
quint16 bs=(quint16)(block.size() - 2*sizeof(quint16));
|
insilmaril@721
|
4250 |
out << bs;
|
insilmaril@721
|
4251 |
|
insilmaril@721
|
4252 |
if (debug)
|
insilmaril@721
|
4253 |
cout << "ME::sendData bs="<<bs<<" counter="<<sendCounter<<" s="<<qPrintable(s)<<endl;
|
insilmaril@721
|
4254 |
|
insilmaril@721
|
4255 |
for (int i=0; i<clientList.size(); ++i)
|
insilmaril@721
|
4256 |
{
|
insilmaril@721
|
4257 |
//cout << "Sending \""<<qPrintable (s)<<"\" to "<<qPrintable (clientList.at(i)->peerAddress().toString())<<endl;
|
insilmaril@721
|
4258 |
clientList.at(i)->write (block);
|
insilmaril@721
|
4259 |
}
|
insilmaril@721
|
4260 |
}
|
insilmaril@721
|
4261 |
|
insilmaril@721
|
4262 |
void VymModel::readData ()
|
insilmaril@721
|
4263 |
{
|
insilmaril@721
|
4264 |
while (clientSocket->bytesAvailable() >=(int)sizeof(quint16) )
|
insilmaril@721
|
4265 |
{
|
insilmaril@721
|
4266 |
if (debug)
|
insilmaril@721
|
4267 |
cout <<"readData bytesAvail="<<clientSocket->bytesAvailable();
|
insilmaril@721
|
4268 |
quint16 recCounter;
|
insilmaril@721
|
4269 |
quint16 blockSize;
|
insilmaril@721
|
4270 |
|
insilmaril@721
|
4271 |
QDataStream in(clientSocket);
|
insilmaril@721
|
4272 |
in.setVersion(QDataStream::Qt_4_0);
|
insilmaril@721
|
4273 |
|
insilmaril@721
|
4274 |
in >> blockSize;
|
insilmaril@721
|
4275 |
in >> recCounter;
|
insilmaril@721
|
4276 |
|
insilmaril@721
|
4277 |
QString t;
|
insilmaril@721
|
4278 |
in >>t;
|
insilmaril@721
|
4279 |
if (debug)
|
insilmaril@721
|
4280 |
cout << " t="<<qPrintable (t)<<endl;
|
insilmaril@721
|
4281 |
parseAtom (t);
|
insilmaril@721
|
4282 |
}
|
insilmaril@721
|
4283 |
return;
|
insilmaril@721
|
4284 |
}
|
insilmaril@721
|
4285 |
|
insilmaril@721
|
4286 |
void VymModel::displayNetworkError(QAbstractSocket::SocketError socketError)
|
insilmaril@721
|
4287 |
{
|
insilmaril@721
|
4288 |
switch (socketError) {
|
insilmaril@721
|
4289 |
case QAbstractSocket::RemoteHostClosedError:
|
insilmaril@721
|
4290 |
break;
|
insilmaril@721
|
4291 |
case QAbstractSocket::HostNotFoundError:
|
insilmaril@721
|
4292 |
QMessageBox::information(NULL, vymName +" Network client",
|
insilmaril@721
|
4293 |
"The host was not found. Please check the "
|
insilmaril@721
|
4294 |
"host name and port settings.");
|
insilmaril@721
|
4295 |
break;
|
insilmaril@721
|
4296 |
case QAbstractSocket::ConnectionRefusedError:
|
insilmaril@721
|
4297 |
QMessageBox::information(NULL, vymName + " Network client",
|
insilmaril@721
|
4298 |
"The connection was refused by the peer. "
|
insilmaril@721
|
4299 |
"Make sure the fortune server is running, "
|
insilmaril@721
|
4300 |
"and check that the host name and port "
|
insilmaril@721
|
4301 |
"settings are correct.");
|
insilmaril@721
|
4302 |
break;
|
insilmaril@721
|
4303 |
default:
|
insilmaril@721
|
4304 |
QMessageBox::information(NULL, vymName + " Network client",
|
insilmaril@721
|
4305 |
QString("The following error occurred: %1.")
|
insilmaril@721
|
4306 |
.arg(clientSocket->errorString()));
|
insilmaril@721
|
4307 |
}
|
insilmaril@721
|
4308 |
}
|
insilmaril@721
|
4309 |
|
insilmaril@721
|
4310 |
|
insilmaril@721
|
4311 |
|
insilmaril@721
|
4312 |
|
insilmaril@721
|
4313 |
void VymModel::selectMapSelectionColor()
|
insilmaril@721
|
4314 |
{
|
insilmaril@721
|
4315 |
QColor col = QColorDialog::getColor( defLinkColor, NULL);
|
insilmaril@721
|
4316 |
setSelectionColor (col);
|
insilmaril@721
|
4317 |
}
|
insilmaril@721
|
4318 |
|
insilmaril@721
|
4319 |
void VymModel::setSelectionColorInt (QColor col)
|
insilmaril@721
|
4320 |
{
|
insilmaril@721
|
4321 |
if ( !col.isValid() ) return;
|
insilmaril@721
|
4322 |
saveState (
|
insilmaril@728
|
4323 |
QString("setSelectionColor (%1)").arg(mapEditor->getSelectionColor().name()),
|
insilmaril@721
|
4324 |
QString("setSelectionColor (%1)").arg(col.name()),
|
insilmaril@721
|
4325 |
QString("Set color of selection box to %1").arg(col.name())
|
insilmaril@721
|
4326 |
);
|
insilmaril@721
|
4327 |
|
insilmaril@728
|
4328 |
mapEditor->setSelectionColor (col);
|
insilmaril@721
|
4329 |
}
|
insilmaril@721
|
4330 |
|
insilmaril@721
|
4331 |
void VymModel::updateSelection()
|
insilmaril@721
|
4332 |
{
|
insilmaril@721
|
4333 |
selection.update();
|
insilmaril@721
|
4334 |
}
|
insilmaril@721
|
4335 |
|
insilmaril@721
|
4336 |
void VymModel::setSelectionColor(QColor col)
|
insilmaril@721
|
4337 |
{
|
insilmaril@721
|
4338 |
if ( !col.isValid() ) return;
|
insilmaril@721
|
4339 |
saveState (
|
insilmaril@728
|
4340 |
QString("setSelectionColor (%1)").arg(mapEditor->getSelectionColor().name()),
|
insilmaril@721
|
4341 |
QString("setSelectionColor (%1)").arg(col.name()),
|
insilmaril@721
|
4342 |
QString("Set color of selection box to %1").arg(col.name())
|
insilmaril@721
|
4343 |
);
|
insilmaril@721
|
4344 |
setSelectionColorInt (col);
|
insilmaril@721
|
4345 |
}
|
insilmaril@721
|
4346 |
|
insilmaril@721
|
4347 |
QColor VymModel::getSelectionColor()
|
insilmaril@721
|
4348 |
{
|
insilmaril@728
|
4349 |
return mapEditor->getSelectionColor();
|
insilmaril@721
|
4350 |
}
|
insilmaril@721
|
4351 |
|
insilmaril@721
|
4352 |
void VymModel::setHideTmpMode (HideTmpMode mode)
|
insilmaril@721
|
4353 |
{
|
insilmaril@721
|
4354 |
hidemode=mode;
|
insilmaril@721
|
4355 |
for (int i=0;i<mapCenters.count(); i++)
|
insilmaril@721
|
4356 |
mapCenters.at(i)->setHideTmp (mode);
|
insilmaril@721
|
4357 |
reposition();
|
insilmaril@721
|
4358 |
// FIXME needed? scene()->update();
|
insilmaril@721
|
4359 |
}
|
insilmaril@721
|
4360 |
|
insilmaril@721
|
4361 |
|
insilmaril@721
|
4362 |
QRectF VymModel::getTotalBBox()
|
insilmaril@721
|
4363 |
{
|
insilmaril@721
|
4364 |
QRectF r;
|
insilmaril@721
|
4365 |
for (int i=0;i<mapCenters.count(); i++)
|
insilmaril@721
|
4366 |
r=addBBox (mapCenters.at(i)->getTotalBBox(), r);
|
insilmaril@721
|
4367 |
return r;
|
insilmaril@721
|
4368 |
}
|
insilmaril@652
|
4369 |
|
insilmaril@652
|
4370 |
//////////////////////////////////////////////
|
insilmaril@652
|
4371 |
// Selection related
|
insilmaril@652
|
4372 |
//////////////////////////////////////////////
|
insilmaril@652
|
4373 |
|
insilmaril@727
|
4374 |
void VymModel::setSelectionModel (QItemSelectionModel *sm)
|
insilmaril@727
|
4375 |
{
|
insilmaril@727
|
4376 |
selModel=sm;
|
insilmaril@728
|
4377 |
cout << "VM::setSelModel selModel="<<selModel<<endl;
|
insilmaril@728
|
4378 |
}
|
insilmaril@728
|
4379 |
|
insilmaril@728
|
4380 |
QItemSelectionModel* VymModel::getSelectionModel()
|
insilmaril@728
|
4381 |
{
|
insilmaril@728
|
4382 |
return selModel;
|
insilmaril@727
|
4383 |
}
|
insilmaril@727
|
4384 |
|
insilmaril@721
|
4385 |
void VymModel::setSelectionBlocked (bool b)
|
insilmaril@721
|
4386 |
{
|
insilmaril@721
|
4387 |
if (b)
|
insilmaril@721
|
4388 |
selection.block();
|
insilmaril@721
|
4389 |
else
|
insilmaril@721
|
4390 |
selection.unblock();
|
insilmaril@721
|
4391 |
}
|
insilmaril@721
|
4392 |
|
insilmaril@721
|
4393 |
bool VymModel::isSelectionBlocked()
|
insilmaril@721
|
4394 |
{
|
insilmaril@721
|
4395 |
return selection.isBlocked();
|
insilmaril@721
|
4396 |
}
|
insilmaril@721
|
4397 |
|
insilmaril@727
|
4398 |
bool VymModel::select ()
|
insilmaril@727
|
4399 |
{
|
insilmaril@727
|
4400 |
QModelIndex index=selModel->selectedIndexes().first(); // TODO no multiselections yet
|
insilmaril@727
|
4401 |
|
insilmaril@727
|
4402 |
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
insilmaril@727
|
4403 |
return select (item->getLMO() );
|
insilmaril@727
|
4404 |
}
|
insilmaril@727
|
4405 |
|
insilmaril@721
|
4406 |
bool VymModel::select (const QString &s)
|
insilmaril@721
|
4407 |
{
|
insilmaril@721
|
4408 |
if (selection.select(s))
|
insilmaril@721
|
4409 |
{
|
insilmaril@721
|
4410 |
selection.update();
|
insilmaril@721
|
4411 |
ensureSelectionVisible();
|
insilmaril@721
|
4412 |
sendSelection ();
|
insilmaril@721
|
4413 |
return true;
|
insilmaril@721
|
4414 |
}
|
insilmaril@721
|
4415 |
return false;
|
insilmaril@721
|
4416 |
|
insilmaril@721
|
4417 |
}
|
insilmaril@721
|
4418 |
|
insilmaril@721
|
4419 |
bool VymModel::select (LinkableMapObj *lmo)
|
insilmaril@721
|
4420 |
{
|
insilmaril@721
|
4421 |
if (selection.select(lmo))
|
insilmaril@721
|
4422 |
{
|
insilmaril@721
|
4423 |
selection.update();
|
insilmaril@721
|
4424 |
ensureSelectionVisible();
|
insilmaril@721
|
4425 |
sendSelection ();
|
insilmaril@721
|
4426 |
return true;
|
insilmaril@721
|
4427 |
}
|
insilmaril@721
|
4428 |
return false;
|
insilmaril@721
|
4429 |
}
|
insilmaril@721
|
4430 |
|
insilmaril@721
|
4431 |
void VymModel::unselect()
|
insilmaril@721
|
4432 |
{
|
insilmaril@721
|
4433 |
selection.unselect();
|
insilmaril@721
|
4434 |
}
|
insilmaril@721
|
4435 |
|
insilmaril@721
|
4436 |
void VymModel::reselect()
|
insilmaril@721
|
4437 |
{
|
insilmaril@721
|
4438 |
selection.reselect();
|
insilmaril@721
|
4439 |
}
|
insilmaril@721
|
4440 |
|
insilmaril@721
|
4441 |
void VymModel::ensureSelectionVisible()
|
insilmaril@721
|
4442 |
{
|
insilmaril@721
|
4443 |
LinkableMapObj *lmo=selection.single();
|
insilmaril@721
|
4444 |
if (lmo &&mapEditor) mapEditor->ensureVisible (lmo->getBBox() );
|
insilmaril@721
|
4445 |
|
insilmaril@721
|
4446 |
}
|
insilmaril@721
|
4447 |
|
insilmaril@721
|
4448 |
void VymModel::selectInt (LinkableMapObj *lmo)
|
insilmaril@721
|
4449 |
{
|
insilmaril@721
|
4450 |
if (selection.select(lmo))
|
insilmaril@721
|
4451 |
{
|
insilmaril@729
|
4452 |
//selection.update();
|
insilmaril@729
|
4453 |
sendSelection (); // FIXME VM use signal
|
insilmaril@721
|
4454 |
}
|
insilmaril@721
|
4455 |
}
|
insilmaril@721
|
4456 |
|
insilmaril@721
|
4457 |
|
insilmaril@721
|
4458 |
void VymModel::selectNextBranchInt()
|
insilmaril@721
|
4459 |
{
|
insilmaril@721
|
4460 |
// Increase number of branch
|
insilmaril@721
|
4461 |
LinkableMapObj *sel=selection.single();
|
insilmaril@721
|
4462 |
if (sel)
|
insilmaril@721
|
4463 |
{
|
insilmaril@721
|
4464 |
QString s=selection.getSelectString();
|
insilmaril@721
|
4465 |
QString part;
|
insilmaril@721
|
4466 |
QString typ;
|
insilmaril@721
|
4467 |
QString num;
|
insilmaril@721
|
4468 |
|
insilmaril@721
|
4469 |
// Where am I?
|
insilmaril@721
|
4470 |
part=s.section(",",-1);
|
insilmaril@721
|
4471 |
typ=part.left (3);
|
insilmaril@721
|
4472 |
num=part.right(part.length() - 3);
|
insilmaril@721
|
4473 |
|
insilmaril@721
|
4474 |
s=s.left (s.length() -num.length());
|
insilmaril@721
|
4475 |
|
insilmaril@721
|
4476 |
// Go to next lmo
|
insilmaril@721
|
4477 |
num=QString ("%1").arg(num.toUInt()+1);
|
insilmaril@721
|
4478 |
|
insilmaril@721
|
4479 |
s=s+num;
|
insilmaril@721
|
4480 |
|
insilmaril@721
|
4481 |
// Try to select this one
|
insilmaril@721
|
4482 |
if (select (s)) return;
|
insilmaril@721
|
4483 |
|
insilmaril@721
|
4484 |
// We have no direct successor,
|
insilmaril@721
|
4485 |
// try to increase the parental number in order to
|
insilmaril@721
|
4486 |
// find a successor with same depth
|
insilmaril@721
|
4487 |
|
insilmaril@721
|
4488 |
int d=selection.single()->getDepth();
|
insilmaril@721
|
4489 |
int oldDepth=d;
|
insilmaril@721
|
4490 |
int i;
|
insilmaril@721
|
4491 |
bool found=false;
|
insilmaril@721
|
4492 |
bool b;
|
insilmaril@721
|
4493 |
while (!found && d>0)
|
insilmaril@721
|
4494 |
{
|
insilmaril@721
|
4495 |
s=s.section (",",0,d-1);
|
insilmaril@721
|
4496 |
// replace substring of current depth in s with "1"
|
insilmaril@721
|
4497 |
part=s.section(",",-1);
|
insilmaril@721
|
4498 |
typ=part.left (3);
|
insilmaril@721
|
4499 |
num=part.right(part.length() - 3);
|
insilmaril@721
|
4500 |
|
insilmaril@721
|
4501 |
if (d>1)
|
insilmaril@721
|
4502 |
{
|
insilmaril@721
|
4503 |
// increase number of parent
|
insilmaril@721
|
4504 |
num=QString ("%1").arg(num.toUInt()+1);
|
insilmaril@721
|
4505 |
s=s.section (",",0,d-2) + ","+ typ+num;
|
insilmaril@721
|
4506 |
} else
|
insilmaril@721
|
4507 |
{
|
insilmaril@721
|
4508 |
// Special case, look at orientation
|
insilmaril@721
|
4509 |
if (selection.single()->getOrientation()==LinkableMapObj::RightOfCenter)
|
insilmaril@721
|
4510 |
num=QString ("%1").arg(num.toUInt()+1);
|
insilmaril@721
|
4511 |
else
|
insilmaril@721
|
4512 |
num=QString ("%1").arg(num.toUInt()-1);
|
insilmaril@721
|
4513 |
s=typ+num;
|
insilmaril@721
|
4514 |
}
|
insilmaril@721
|
4515 |
|
insilmaril@721
|
4516 |
if (select (s))
|
insilmaril@721
|
4517 |
// pad to oldDepth, select the first branch for each depth
|
insilmaril@721
|
4518 |
for (i=d;i<oldDepth;i++)
|
insilmaril@721
|
4519 |
{
|
insilmaril@721
|
4520 |
b=select (s);
|
insilmaril@721
|
4521 |
if (b)
|
insilmaril@721
|
4522 |
{
|
insilmaril@721
|
4523 |
if ( selection.getBranch()->countBranches()>0)
|
insilmaril@721
|
4524 |
s+=",bo:0";
|
insilmaril@721
|
4525 |
else
|
insilmaril@721
|
4526 |
break;
|
insilmaril@721
|
4527 |
} else
|
insilmaril@721
|
4528 |
break;
|
insilmaril@721
|
4529 |
}
|
insilmaril@721
|
4530 |
|
insilmaril@721
|
4531 |
// try to select the freshly built string
|
insilmaril@721
|
4532 |
found=select(s);
|
insilmaril@721
|
4533 |
d--;
|
insilmaril@721
|
4534 |
}
|
insilmaril@721
|
4535 |
return;
|
insilmaril@721
|
4536 |
}
|
insilmaril@721
|
4537 |
}
|
insilmaril@721
|
4538 |
|
insilmaril@721
|
4539 |
void VymModel::selectPrevBranchInt()
|
insilmaril@721
|
4540 |
{
|
insilmaril@721
|
4541 |
// Decrease number of branch
|
insilmaril@721
|
4542 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
4543 |
if (bo)
|
insilmaril@721
|
4544 |
{
|
insilmaril@721
|
4545 |
QString s=selection.getSelectString();
|
insilmaril@721
|
4546 |
QString part;
|
insilmaril@721
|
4547 |
QString typ;
|
insilmaril@721
|
4548 |
QString num;
|
insilmaril@721
|
4549 |
|
insilmaril@721
|
4550 |
// Where am I?
|
insilmaril@721
|
4551 |
part=s.section(",",-1);
|
insilmaril@721
|
4552 |
typ=part.left (3);
|
insilmaril@721
|
4553 |
num=part.right(part.length() - 3);
|
insilmaril@721
|
4554 |
|
insilmaril@721
|
4555 |
s=s.left (s.length() -num.length());
|
insilmaril@721
|
4556 |
|
insilmaril@721
|
4557 |
int n=num.toInt()-1;
|
insilmaril@721
|
4558 |
|
insilmaril@721
|
4559 |
// Go to next lmo
|
insilmaril@721
|
4560 |
num=QString ("%1").arg(n);
|
insilmaril@721
|
4561 |
s=s+num;
|
insilmaril@721
|
4562 |
|
insilmaril@721
|
4563 |
// Try to select this one
|
insilmaril@721
|
4564 |
if (n>=0 && select (s)) return;
|
insilmaril@721
|
4565 |
|
insilmaril@721
|
4566 |
// We have no direct precessor,
|
insilmaril@721
|
4567 |
// try to decrease the parental number in order to
|
insilmaril@721
|
4568 |
// find a precessor with same depth
|
insilmaril@721
|
4569 |
|
insilmaril@721
|
4570 |
int d=selection.single()->getDepth();
|
insilmaril@721
|
4571 |
int oldDepth=d;
|
insilmaril@721
|
4572 |
int i;
|
insilmaril@721
|
4573 |
bool found=false;
|
insilmaril@721
|
4574 |
bool b;
|
insilmaril@721
|
4575 |
while (!found && d>0)
|
insilmaril@721
|
4576 |
{
|
insilmaril@721
|
4577 |
s=s.section (",",0,d-1);
|
insilmaril@721
|
4578 |
// replace substring of current depth in s with "1"
|
insilmaril@721
|
4579 |
part=s.section(",",-1);
|
insilmaril@721
|
4580 |
typ=part.left (3);
|
insilmaril@721
|
4581 |
num=part.right(part.length() - 3);
|
insilmaril@721
|
4582 |
|
insilmaril@721
|
4583 |
if (d>1)
|
insilmaril@721
|
4584 |
{
|
insilmaril@721
|
4585 |
// decrease number of parent
|
insilmaril@721
|
4586 |
num=QString ("%1").arg(num.toInt()-1);
|
insilmaril@721
|
4587 |
s=s.section (",",0,d-2) + ","+ typ+num;
|
insilmaril@721
|
4588 |
} else
|
insilmaril@721
|
4589 |
{
|
insilmaril@721
|
4590 |
// Special case, look at orientation
|
insilmaril@721
|
4591 |
if (selection.single()->getOrientation()==LinkableMapObj::RightOfCenter)
|
insilmaril@721
|
4592 |
num=QString ("%1").arg(num.toInt()-1);
|
insilmaril@721
|
4593 |
else
|
insilmaril@721
|
4594 |
num=QString ("%1").arg(num.toInt()+1);
|
insilmaril@721
|
4595 |
s=typ+num;
|
insilmaril@721
|
4596 |
}
|
insilmaril@721
|
4597 |
|
insilmaril@721
|
4598 |
if (select(s))
|
insilmaril@721
|
4599 |
// pad to oldDepth, select the last branch for each depth
|
insilmaril@721
|
4600 |
for (i=d;i<oldDepth;i++)
|
insilmaril@721
|
4601 |
{
|
insilmaril@721
|
4602 |
b=select (s);
|
insilmaril@721
|
4603 |
if (b)
|
insilmaril@721
|
4604 |
if ( selection.getBranch()->countBranches()>0)
|
insilmaril@721
|
4605 |
s+=",bo:"+ QString ("%1").arg( selection.getBranch()->countBranches()-1 );
|
insilmaril@721
|
4606 |
else
|
insilmaril@721
|
4607 |
break;
|
insilmaril@721
|
4608 |
else
|
insilmaril@721
|
4609 |
break;
|
insilmaril@721
|
4610 |
}
|
insilmaril@721
|
4611 |
|
insilmaril@721
|
4612 |
// try to select the freshly built string
|
insilmaril@721
|
4613 |
found=select(s);
|
insilmaril@721
|
4614 |
d--;
|
insilmaril@721
|
4615 |
}
|
insilmaril@721
|
4616 |
return;
|
insilmaril@721
|
4617 |
}
|
insilmaril@721
|
4618 |
}
|
insilmaril@721
|
4619 |
|
insilmaril@721
|
4620 |
void VymModel::selectUpperBranch()
|
insilmaril@721
|
4621 |
{
|
insilmaril@721
|
4622 |
if (selection.isBlocked() ) return;
|
insilmaril@721
|
4623 |
|
insilmaril@721
|
4624 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
4625 |
if (bo && selection.type()==Selection::Branch)
|
insilmaril@721
|
4626 |
{
|
insilmaril@721
|
4627 |
if (bo->getOrientation()==LinkableMapObj::RightOfCenter)
|
insilmaril@721
|
4628 |
selectPrevBranchInt();
|
insilmaril@721
|
4629 |
else
|
insilmaril@721
|
4630 |
if (bo->getDepth()==1)
|
insilmaril@721
|
4631 |
selectNextBranchInt();
|
insilmaril@721
|
4632 |
else
|
insilmaril@721
|
4633 |
selectPrevBranchInt();
|
insilmaril@721
|
4634 |
}
|
insilmaril@721
|
4635 |
}
|
insilmaril@721
|
4636 |
|
insilmaril@721
|
4637 |
void VymModel::selectLowerBranch()
|
insilmaril@721
|
4638 |
{
|
insilmaril@721
|
4639 |
if (selection.isBlocked() ) return;
|
insilmaril@721
|
4640 |
|
insilmaril@721
|
4641 |
BranchObj *bo=selection.getBranch();
|
insilmaril@721
|
4642 |
if (bo && selection.type()==Selection::Branch)
|
insilmaril@721
|
4643 |
{
|
insilmaril@721
|
4644 |
if (bo->getOrientation()==LinkableMapObj::RightOfCenter)
|
insilmaril@721
|
4645 |
selectNextBranchInt();
|
insilmaril@721
|
4646 |
else
|
insilmaril@721
|
4647 |
if (bo->getDepth()==1)
|
insilmaril@721
|
4648 |
selectPrevBranchInt();
|
insilmaril@721
|
4649 |
else
|
insilmaril@721
|
4650 |
selectNextBranchInt();
|
insilmaril@721
|
4651 |
}
|
insilmaril@721
|
4652 |
}
|
insilmaril@721
|
4653 |
|
insilmaril@721
|
4654 |
|
insilmaril@721
|
4655 |
void VymModel::selectLeftBranch()
|
insilmaril@721
|
4656 |
{
|
insilmaril@721
|
4657 |
if (selection.isBlocked() ) return;
|
insilmaril@721
|
4658 |
|
insilmaril@721
|
4659 |
BranchObj* bo;
|
insilmaril@721
|
4660 |
BranchObj* par;
|
insilmaril@721
|
4661 |
LinkableMapObj *sel=selection.single();
|
insilmaril@721
|
4662 |
if (sel)
|
insilmaril@721
|
4663 |
{
|
insilmaril@721
|
4664 |
if (selection.type()== Selection::MapCenter)
|
insilmaril@721
|
4665 |
{
|
insilmaril@721
|
4666 |
par=selection.getBranch();
|
insilmaril@721
|
4667 |
bo=par->getLastSelectedBranch();
|
insilmaril@721
|
4668 |
if (bo)
|
insilmaril@721
|
4669 |
{
|
insilmaril@721
|
4670 |
// Workaround for reselecting on left and right side
|
insilmaril@721
|
4671 |
if (bo->getOrientation()==LinkableMapObj::RightOfCenter)
|
insilmaril@721
|
4672 |
bo=par->getLastBranch();
|
insilmaril@721
|
4673 |
if (bo)
|
insilmaril@721
|
4674 |
{
|
insilmaril@721
|
4675 |
bo=par->getLastBranch();
|
insilmaril@721
|
4676 |
selection.select(bo);
|
insilmaril@721
|
4677 |
selection.update();
|
insilmaril@721
|
4678 |
ensureSelectionVisible();
|
insilmaril@721
|
4679 |
sendSelection();
|
insilmaril@721
|
4680 |
}
|
insilmaril@721
|
4681 |
}
|
insilmaril@721
|
4682 |
} else
|
insilmaril@721
|
4683 |
{
|
insilmaril@721
|
4684 |
par=(BranchObj*)(sel->getParObj());
|
insilmaril@721
|
4685 |
if (sel->getOrientation()==LinkableMapObj::RightOfCenter)
|
insilmaril@721
|
4686 |
{
|
insilmaril@721
|
4687 |
if (selection.type() == Selection::Branch ||
|
insilmaril@721
|
4688 |
selection.type() == Selection::FloatImage)
|
insilmaril@721
|
4689 |
{
|
insilmaril@721
|
4690 |
selection.select(par);
|
insilmaril@721
|
4691 |
selection.update();
|
insilmaril@721
|
4692 |
ensureSelectionVisible();
|
insilmaril@721
|
4693 |
sendSelection();
|
insilmaril@721
|
4694 |
}
|
insilmaril@721
|
4695 |
} else
|
insilmaril@721
|
4696 |
{
|
insilmaril@721
|
4697 |
if (selection.type() == Selection::Branch )
|
insilmaril@721
|
4698 |
{
|
insilmaril@721
|
4699 |
bo=selection.getBranch()->getLastSelectedBranch();
|
insilmaril@721
|
4700 |
if (bo)
|
insilmaril@721
|
4701 |
{
|
insilmaril@721
|
4702 |
selection.select(bo);
|
insilmaril@721
|
4703 |
selection.update();
|
insilmaril@721
|
4704 |
ensureSelectionVisible();
|
insilmaril@721
|
4705 |
sendSelection();
|
insilmaril@721
|
4706 |
}
|
insilmaril@721
|
4707 |
}
|
insilmaril@721
|
4708 |
}
|
insilmaril@721
|
4709 |
}
|
insilmaril@721
|
4710 |
}
|
insilmaril@721
|
4711 |
}
|
insilmaril@721
|
4712 |
|
insilmaril@721
|
4713 |
void VymModel::selectRightBranch()
|
insilmaril@721
|
4714 |
{
|
insilmaril@721
|
4715 |
if (selection.isBlocked() ) return;
|
insilmaril@721
|
4716 |
|
insilmaril@721
|
4717 |
BranchObj* bo;
|
insilmaril@721
|
4718 |
BranchObj* par;
|
insilmaril@721
|
4719 |
LinkableMapObj *sel=selection.single();
|
insilmaril@721
|
4720 |
if (sel)
|
insilmaril@721
|
4721 |
{
|
insilmaril@721
|
4722 |
if (selection.type()==Selection::MapCenter)
|
insilmaril@721
|
4723 |
{
|
insilmaril@721
|
4724 |
par=selection.getBranch();
|
insilmaril@721
|
4725 |
bo=par->getLastSelectedBranch();
|
insilmaril@721
|
4726 |
if (bo)
|
insilmaril@721
|
4727 |
{
|
insilmaril@721
|
4728 |
// Workaround for reselecting on left and right side
|
insilmaril@721
|
4729 |
if (bo->getOrientation()==LinkableMapObj::LeftOfCenter)
|
insilmaril@721
|
4730 |
bo=par->getFirstBranch();
|
insilmaril@721
|
4731 |
if (bo)
|
insilmaril@721
|
4732 |
{
|
insilmaril@721
|
4733 |
selection.select(bo);
|
insilmaril@721
|
4734 |
selection.update();
|
insilmaril@721
|
4735 |
ensureSelectionVisible();
|
insilmaril@721
|
4736 |
sendSelection();
|
insilmaril@721
|
4737 |
}
|
insilmaril@721
|
4738 |
}
|
insilmaril@721
|
4739 |
} else
|
insilmaril@721
|
4740 |
{
|
insilmaril@721
|
4741 |
par=(BranchObj*)(selection.single()->getParObj());
|
insilmaril@721
|
4742 |
if (selection.single()->getOrientation()==LinkableMapObj::LeftOfCenter)
|
insilmaril@721
|
4743 |
{
|
insilmaril@721
|
4744 |
if (selection.type() == Selection::Branch ||
|
insilmaril@721
|
4745 |
selection.type() == Selection::FloatImage)
|
insilmaril@721
|
4746 |
{
|
insilmaril@721
|
4747 |
selection.select(par);
|
insilmaril@721
|
4748 |
selection.update();
|
insilmaril@721
|
4749 |
ensureSelectionVisible();
|
insilmaril@721
|
4750 |
sendSelection();
|
insilmaril@721
|
4751 |
}
|
insilmaril@721
|
4752 |
} else
|
insilmaril@721
|
4753 |
{
|
insilmaril@721
|
4754 |
if (selection.type() == Selection::Branch)
|
insilmaril@721
|
4755 |
{
|
insilmaril@721
|
4756 |
bo=selection.getBranch()->getLastSelectedBranch();
|
insilmaril@721
|
4757 |
if (bo)
|
insilmaril@721
|
4758 |
{
|
insilmaril@721
|
4759 |
selection.select(bo);
|
insilmaril@721
|
4760 |
selection.update();
|
insilmaril@721
|
4761 |
ensureSelectionVisible();
|
insilmaril@721
|
4762 |
sendSelection();
|
insilmaril@721
|
4763 |
}
|
insilmaril@721
|
4764 |
}
|
insilmaril@721
|
4765 |
}
|
insilmaril@721
|
4766 |
}
|
insilmaril@721
|
4767 |
}
|
insilmaril@721
|
4768 |
}
|
insilmaril@721
|
4769 |
|
insilmaril@721
|
4770 |
void VymModel::selectFirstBranch()
|
insilmaril@721
|
4771 |
{
|
insilmaril@721
|
4772 |
BranchObj *bo1=selection.getBranch();
|
insilmaril@721
|
4773 |
BranchObj *bo2;
|
insilmaril@721
|
4774 |
BranchObj* par;
|
insilmaril@721
|
4775 |
if (bo1)
|
insilmaril@721
|
4776 |
{
|
insilmaril@721
|
4777 |
par=(BranchObj*)(bo1->getParObj());
|
insilmaril@721
|
4778 |
if (!par) return;
|
insilmaril@721
|
4779 |
bo2=par->getFirstBranch();
|
insilmaril@721
|
4780 |
if (bo2) {
|
insilmaril@721
|
4781 |
selection.select(bo2);
|
insilmaril@721
|
4782 |
selection.update();
|
insilmaril@721
|
4783 |
ensureSelectionVisible();
|
insilmaril@721
|
4784 |
sendSelection();
|
insilmaril@721
|
4785 |
}
|
insilmaril@721
|
4786 |
}
|
insilmaril@721
|
4787 |
}
|
insilmaril@721
|
4788 |
|
insilmaril@721
|
4789 |
void VymModel::selectLastBranch()
|
insilmaril@721
|
4790 |
{
|
insilmaril@721
|
4791 |
BranchObj *bo1=selection.getBranch();
|
insilmaril@721
|
4792 |
BranchObj *bo2;
|
insilmaril@721
|
4793 |
BranchObj* par;
|
insilmaril@721
|
4794 |
if (bo1)
|
insilmaril@721
|
4795 |
{
|
insilmaril@721
|
4796 |
par=(BranchObj*)(bo1->getParObj());
|
insilmaril@721
|
4797 |
if (!par) return;
|
insilmaril@721
|
4798 |
bo2=par->getLastBranch();
|
insilmaril@721
|
4799 |
if (bo2)
|
insilmaril@721
|
4800 |
{
|
insilmaril@721
|
4801 |
selection.select(bo2);
|
insilmaril@721
|
4802 |
selection.update();
|
insilmaril@721
|
4803 |
ensureSelectionVisible();
|
insilmaril@721
|
4804 |
sendSelection();
|
insilmaril@721
|
4805 |
}
|
insilmaril@721
|
4806 |
}
|
insilmaril@721
|
4807 |
}
|
insilmaril@721
|
4808 |
|
insilmaril@726
|
4809 |
void VymModel::selectParent()
|
insilmaril@726
|
4810 |
{
|
insilmaril@726
|
4811 |
LinkableMapObj *lmo=selection.first();
|
insilmaril@726
|
4812 |
BranchObj* par;
|
insilmaril@726
|
4813 |
if (lmo)
|
insilmaril@726
|
4814 |
{
|
insilmaril@726
|
4815 |
par=(BranchObj*)(lmo->getParObj());
|
insilmaril@726
|
4816 |
if (!par) return;
|
insilmaril@726
|
4817 |
selection.select(par);
|
insilmaril@726
|
4818 |
selection.update();
|
insilmaril@726
|
4819 |
ensureSelectionVisible();
|
insilmaril@726
|
4820 |
sendSelection();
|
insilmaril@726
|
4821 |
}
|
insilmaril@726
|
4822 |
}
|
insilmaril@726
|
4823 |
|
insilmaril@721
|
4824 |
Selection::Type VymModel::selectionType()
|
insilmaril@721
|
4825 |
{
|
insilmaril@721
|
4826 |
return selection.type();
|
insilmaril@721
|
4827 |
}
|
insilmaril@721
|
4828 |
|
insilmaril@652
|
4829 |
LinkableMapObj* VymModel::getSelection()
|
insilmaril@652
|
4830 |
{
|
insilmaril@721
|
4831 |
return selection.single();
|
insilmaril@652
|
4832 |
}
|
insilmaril@652
|
4833 |
BranchObj* VymModel::getSelectedBranch()
|
insilmaril@652
|
4834 |
{
|
insilmaril@721
|
4835 |
return selection.getBranch();
|
insilmaril@652
|
4836 |
}
|
insilmaril@652
|
4837 |
|
insilmaril@721
|
4838 |
FloatImageObj* VymModel::getSelectedFloatImage()
|
insilmaril@652
|
4839 |
{
|
insilmaril@721
|
4840 |
return selection.getFloatImage();
|
insilmaril@721
|
4841 |
}
|
insilmaril@721
|
4842 |
|
insilmaril@721
|
4843 |
QString VymModel::getSelectString ()
|
insilmaril@721
|
4844 |
{
|
insilmaril@721
|
4845 |
return selection.getSelectString();
|
insilmaril@652
|
4846 |
}
|
insilmaril@652
|
4847 |
|
insilmaril@729
|
4848 |
QString VymModel::getSelectString (LinkableMapObj *lmo) // FIXME VM needs to use TreeModel
|
insilmaril@652
|
4849 |
{
|
insilmaril@652
|
4850 |
QString s;
|
insilmaril@652
|
4851 |
if (!lmo) return s;
|
insilmaril@652
|
4852 |
if (typeid(*lmo)==typeid(BranchObj) ||
|
insilmaril@652
|
4853 |
typeid(*lmo)==typeid(MapCenterObj) )
|
insilmaril@652
|
4854 |
{
|
insilmaril@652
|
4855 |
LinkableMapObj *par=lmo->getParObj();
|
insilmaril@652
|
4856 |
if (par)
|
insilmaril@652
|
4857 |
{
|
insilmaril@652
|
4858 |
if (lmo->getDepth() ==1)
|
insilmaril@652
|
4859 |
// Mainbranch, return
|
insilmaril@652
|
4860 |
s= "bo:" + QString("%1").arg(((BranchObj*)lmo)->getNum());
|
insilmaril@652
|
4861 |
else
|
insilmaril@729
|
4862 |
{
|
insilmaril@729
|
4863 |
//cout << "VM::getSelectString lmo="<<lmo<<" d="<<lmo->getDepth()<<" s="<<s.toStdString()<<" h="<<((BranchObj*)lmo)->getHeading().toStdString()<<endl;
|
insilmaril@652
|
4864 |
// Branch, call myself recursively
|
insilmaril@652
|
4865 |
s= getSelectString(par) + ",bo:" + QString("%1").arg(((BranchObj*)lmo)->getNum());
|
insilmaril@729
|
4866 |
}
|
insilmaril@652
|
4867 |
} else
|
insilmaril@652
|
4868 |
{
|
insilmaril@652
|
4869 |
// MapCenter
|
insilmaril@652
|
4870 |
int i=mapCenters.indexOf ((MapCenterObj*)lmo);
|
insilmaril@652
|
4871 |
if (i>=0) s=QString("mc:%1").arg(i);
|
insilmaril@652
|
4872 |
}
|
insilmaril@652
|
4873 |
}
|
insilmaril@652
|
4874 |
return s;
|
insilmaril@652
|
4875 |
}
|
insilmaril@652
|
4876 |
|