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