vymmodel.h
author insilmaril
Wed, 04 Feb 2009 11:52:52 +0000
changeset 739 3d43b46a8564
parent 738 716a777c1c98
child 740 6dc0a20031f7
permissions -rw-r--r--
Images are now also added to model
insilmaril@650
     1
#ifndef VYMMODEL_H
insilmaril@650
     2
#define VYMMODEL_H
insilmaril@650
     3
insilmaril@650
     4
#include <QGraphicsScene>
insilmaril@721
     5
#include <QtNetwork>
insilmaril@650
     6
insilmaril@721
     7
#include "file.h"
insilmaril@650
     8
#include "mapcenterobj.h"
insilmaril@650
     9
#include "mapeditor.h"
insilmaril@721
    10
#include "parser.h"
insilmaril@721
    11
#include "selection.h"
insilmaril@726
    12
#include "treeitem.h"
insilmaril@725
    13
#include "treemodel.h"
insilmaril@650
    14
insilmaril@726
    15
class VymModel : public TreeModel {		
insilmaril@696
    16
	Q_OBJECT
insilmaril@696
    17
insilmaril@721
    18
////////////////////////////////////////////
insilmaril@721
    19
// General housekeeping
insilmaril@721
    20
////////////////////////////////////////////
insilmaril@721
    21
private:
insilmaril@721
    22
	QGraphicsScene *mapScene;
insilmaril@721
    23
	QList <MapCenterObj*> mapCenters;
insilmaril@721
    24
	QString version;	//!< version string saved in vym file
insilmaril@721
    25
	QString author;
insilmaril@721
    26
	QString comment;
insilmaril@721
    27
	QDate date;
insilmaril@721
    28
insilmaril@650
    29
public:
insilmaril@650
    30
	VymModel();
insilmaril@650
    31
	~VymModel ();
insilmaril@650
    32
    void clear();
insilmaril@650
    33
    void init();
insilmaril@721
    34
	void makeTmpDirectories();		//!< create temporary directories e.g. for history
insilmaril@721
    35
insilmaril@721
    36
	MapEditor* getMapEditor();			// FIXME not necessary
insilmaril@721
    37
insilmaril@721
    38
	bool isRepositionBlocked();		//!< While load or undo there is no need to update graphicsview
insilmaril@721
    39
insilmaril@721
    40
	void updateActions();			//!< Update buttons in mainwindow
insilmaril@721
    41
insilmaril@721
    42
insilmaril@721
    43
////////////////////////////////////////////
insilmaril@721
    44
// Load/save 
insilmaril@721
    45
////////////////////////////////////////////
insilmaril@721
    46
private:
insilmaril@721
    47
insilmaril@721
    48
	bool zipped;				// should map be zipped
insilmaril@721
    49
	static	int mapNum;			// unique number for model used in save/undo
insilmaril@721
    50
	FileType fileType;			// type of file, e.g. vym, freemind...
insilmaril@721
    51
	QString fileName;			// short name of file (for tab)
insilmaril@721
    52
	QString filePath;			// path to file which will be saved
insilmaril@721
    53
	QString fileDir;			// dir where file is saved
insilmaril@721
    54
	QString destPath;			// path to .vym file (needed for vymlinks)
insilmaril@721
    55
	QString mapName;			// fileName without ".vym"
insilmaril@721
    56
insilmaril@721
    57
	QString tmpMapDir;			// tmp directory with undo history
insilmaril@721
    58
insilmaril@721
    59
	QTimer *autosaveTimer;
insilmaril@721
    60
	QTimer *fileChangedTimer;
insilmaril@721
    61
	QDateTime fileChangedTime;
insilmaril@721
    62
insilmaril@721
    63
public:
insilmaril@721
    64
	/*! This function saves all information of the map to disc.
insilmaril@721
    65
	    saveToDir also calls the functions for all BranchObj and other objects in the map.
insilmaril@721
    66
		The structure of the map itself is returned as QString and passed back to Main, 
insilmaril@721
    67
		where saveToDir is called initially
insilmaril@721
    68
	*/	
insilmaril@721
    69
    QString saveToDir (const QString &tmpdir, const QString &prefix, bool writeflags, const QPointF &offset, LinkableMapObj *saveSel);
insilmaril@721
    70
insilmaril@721
    71
	/*! \brief Sets filepath, filename and mapname
insilmaril@721
    72
insilmaril@721
    73
	     If the filepath is "/home/tux/map.xml", then the filename will be set
insilmaril@721
    74
		 to map.xml. The destname is needed for vymLinks, pointing to another map. 
insilmaril@721
    75
		 The destname holds the real name of the file, after it has been compressed, e.g. "map.vym"
insilmaril@721
    76
	*/	 
insilmaril@721
    77
insilmaril@721
    78
insilmaril@721
    79
	/*! \brief Set File path
insilmaril@721
    80
insilmaril@721
    81
	     The destname is needed to construct the references between maps
insilmaril@721
    82
	*/	 
insilmaril@721
    83
	void setFilePath (QString filepath,QString destname);	
insilmaril@721
    84
	void setFilePath (QString);	//!< Overloaded for convenience
insilmaril@721
    85
	QString getFilePath ();	//!< Full path e.g. "/home/tux/map.xml"
insilmaril@721
    86
	QString getFileName ();	//!< e.g. "map.xml"
insilmaril@721
    87
	QString getMapName ();	//!< e.g. "map"
insilmaril@721
    88
	QString getDestPath (); //!< e.g. "/home/tux/map.vym"
insilmaril@721
    89
insilmaril@721
    90
	/*! \brief Load map
insilmaril@721
    91
insilmaril@721
    92
		The data is read from file. Depending on LoadMode the current
insilmaril@721
    93
		selection gets replaced by data or the data is appended.
insilmaril@721
    94
	*/	
insilmaril@721
    95
    ErrorCode load (QString, const LoadMode &, const FileType& );	// newmap, import/replace selection
insilmaril@721
    96
insilmaril@721
    97
public:
insilmaril@721
    98
	/*! \brief Save the map to file */
insilmaril@721
    99
    ErrorCode save(const SaveMode &);	
insilmaril@721
   100
insilmaril@721
   101
private:
insilmaril@721
   102
    void addMapReplaceInt(const QString & undoSel, const QString & path);
insilmaril@721
   103
    void addMapInsertInt (const QString & path, int pos);
insilmaril@721
   104
insilmaril@721
   105
	FloatImageObj* loadFloatImageInt (QString);
insilmaril@721
   106
	void saveFloatImageInt (FloatImageObj*, const QString &, const QString &);
insilmaril@721
   107
public:	
insilmaril@721
   108
	void loadFloatImage ();
insilmaril@721
   109
	void saveFloatImage ();
insilmaril@721
   110
insilmaril@721
   111
private:	
insilmaril@721
   112
    void importDirInt(BranchObj *,QDir);
insilmaril@721
   113
    void importDirInt(const QString&);
insilmaril@721
   114
public:	
insilmaril@721
   115
    void importDir();
insilmaril@721
   116
insilmaril@721
   117
private slots:
insilmaril@721
   118
	void autosave ();
insilmaril@721
   119
	void fileChanged();
insilmaril@721
   120
insilmaril@721
   121
////////////////////////////////////////////
insilmaril@721
   122
// history (undo/redo)
insilmaril@721
   123
////////////////////////////////////////////
insilmaril@721
   124
private:
insilmaril@721
   125
    bool mapDefault;			//!< Flag if map is untouched
insilmaril@721
   126
    bool mapChanged;			//!< Flag if undo is possible
insilmaril@721
   127
	bool mapUnsaved;			//!< Flag if map should be saved
insilmaril@721
   128
insilmaril@721
   129
	QString histPath;			//!< Path to history file
insilmaril@721
   130
	SimpleSettings undoSet;		//!< undo/redo commands, saved in histPath
insilmaril@721
   131
	int stepsTotal;				//!< total number of steps (undos+redos) 
insilmaril@721
   132
	int curStep;				//!< Current step in history (ring buffer)
insilmaril@721
   133
	int curClipboard;			//!< number of history step, which is the current clipboard
insilmaril@721
   134
	int redosAvail;				//!< Available number of redo steps
insilmaril@721
   135
	int undosAvail;				//!< Available number of undo steps
insilmaril@721
   136
	bool blockReposition;		//!< block while load or undo
insilmaril@721
   137
	bool blockSaveState;		//!< block while load or undo
insilmaril@721
   138
public:
insilmaril@721
   139
	bool isDefault();			//!< true, if map is still the empty default map
insilmaril@721
   140
	void makeDefault();			//!< Reset changelog, declare this as default map
insilmaril@721
   141
    bool hasChanged()	;		//!< true, if something has changed and is not saved yet
insilmaril@721
   142
	void setChanged();			//!< called from TextEditor via LinkableMapObj
insilmaril@721
   143
insilmaril@721
   144
	/*! \brief Get name of object
insilmaril@721
   145
	  
insilmaril@721
   146
	  Returns heading of a branch or name of an object for use in comment
insilmaril@721
   147
	  of undo/redo history
insilmaril@721
   148
	*/ 
insilmaril@721
   149
	QString getObjectName(const LinkableMapObj*);	
insilmaril@721
   150
insilmaril@721
   151
    void redo();						//!< Redo last action
insilmaril@721
   152
	bool isRedoAvailable();				//!< True, if redo is available
insilmaril@721
   153
    void undo();						//!< Undo last action
insilmaril@721
   154
	bool isUndoAvailable();				//!< True, if undo is available
insilmaril@721
   155
	void gotoHistoryStep (int);			//!< Goto a specifig step in history
insilmaril@721
   156
insilmaril@721
   157
insilmaril@721
   158
	QString getHistoryPath();			//!< Path to directory containing the history
insilmaril@721
   159
insilmaril@721
   160
	/*! \brief Save the current changes in map 
insilmaril@721
   161
insilmaril@721
   162
		Two commands and selections are saved:
insilmaril@721
   163
insilmaril@721
   164
			- undocommand and undoselection to undo the change
insilmaril@721
   165
			- redocommand and redoselection to redo the action after an undo
insilmaril@721
   166
insilmaril@721
   167
		Additionally a comment is logged. 
insilmaril@721
   168
insilmaril@721
   169
	*/	
insilmaril@721
   170
    void saveState(
insilmaril@721
   171
		const SaveMode& savemode, 
insilmaril@721
   172
		const QString &undoSelection, 
insilmaril@721
   173
		const QString &undoCommand, 
insilmaril@721
   174
		const QString &redoSelection, 
insilmaril@721
   175
		const QString &redoCommand, 
insilmaril@721
   176
		const QString &comment, 
insilmaril@721
   177
		LinkableMapObj *saveSelection);
insilmaril@721
   178
	/*! Overloaded for convenience */
insilmaril@721
   179
    void saveStateChangingPart(
insilmaril@721
   180
		LinkableMapObj *undoSelection, 
insilmaril@721
   181
		LinkableMapObj* redoSelection, 
insilmaril@721
   182
		const QString &redoCommand, 
insilmaril@721
   183
		const QString &comment);
insilmaril@721
   184
	/*! Overloaded for convenience */
insilmaril@721
   185
    void saveStateRemovingPart(
insilmaril@721
   186
		LinkableMapObj *redoSelection, 
insilmaril@721
   187
		const QString &comment);
insilmaril@721
   188
	/*! Overloaded for convenience */
insilmaril@721
   189
    void saveState(
insilmaril@721
   190
		LinkableMapObj *undoSelection, 
insilmaril@721
   191
		const QString &undoCommand, 
insilmaril@721
   192
		LinkableMapObj *redoSelection, 
insilmaril@721
   193
		const QString &redoCommand, 
insilmaril@721
   194
		const QString &comment); 
insilmaril@721
   195
	/*! Overloaded for convenience */
insilmaril@721
   196
    void saveState(
insilmaril@721
   197
		const QString &undoSelection, 
insilmaril@721
   198
		const QString &undoCommand, 
insilmaril@721
   199
		const QString &redoSelection, 
insilmaril@721
   200
		const QString &redoCommand, 
insilmaril@721
   201
		const QString &comment) ;
insilmaril@721
   202
    void saveState(
insilmaril@721
   203
		const QString &undoCommand, 
insilmaril@721
   204
		const QString &redoCommand, 
insilmaril@721
   205
		const QString &comment) ;
insilmaril@721
   206
insilmaril@721
   207
insilmaril@721
   208
////////////////////////////////////////////
insilmaril@721
   209
// unsorted so far
insilmaril@721
   210
////////////////////////////////////////////
insilmaril@721
   211
public:
insilmaril@721
   212
	void setScene(QGraphicsScene *s);
insilmaril@721
   213
	QGraphicsScene *getScene();
insilmaril@721
   214
insilmaril@721
   215
	BranchObj* first();					
insilmaril@721
   216
	BranchObj* next(BranchObj *bo);		
insilmaril@721
   217
insilmaril@721
   218
    LinkableMapObj* findMapObj(QPointF,LinkableMapObj*);	// find MapObj 
insilmaril@721
   219
    LinkableMapObj* findObjBySelect (const QString &s);		// find MapObj by select string
insilmaril@721
   220
    LinkableMapObj* findID (const QString &s);				// find MapObj by previously set ID
insilmaril@721
   221
insilmaril@721
   222
	QString saveToDir (const QString&,const QString&,int, const QPointF&);// Save data recursivly to tempdir
insilmaril@721
   223
insilmaril@721
   224
insilmaril@721
   225
////////////////////////////////////////////
insilmaril@721
   226
// Interface 
insilmaril@721
   227
////////////////////////////////////////////
insilmaril@721
   228
public:
insilmaril@650
   229
	void setVersion(const  QString &);
insilmaril@650
   230
	void setAuthor  (const QString &);
insilmaril@650
   231
	QString getAuthor ();
insilmaril@650
   232
	void setComment (const QString &);
insilmaril@650
   233
	QString getComment ();
insilmaril@650
   234
	QString getDate();
insilmaril@721
   235
insilmaril@721
   236
public:	
insilmaril@721
   237
	void setHeading(const QString &);		//!< Set heading of branch	
insilmaril@725
   238
//	QString getHeading (bool &ok,QPoint &p); //!< Get heading, ok if selection is branch
insilmaril@721
   239
insilmaril@721
   240
private:
insilmaril@721
   241
	BranchObj* itFind;			// next object in find process
insilmaril@721
   242
	bool EOFind;				// true, if search failed
insilmaril@721
   243
public:
insilmaril@721
   244
    BranchObj* findText(QString,bool);		// Find object
insilmaril@721
   245
    void findReset();						// Reset Search
insilmaril@721
   246
insilmaril@721
   247
	void setURL(const QString &url);
insilmaril@721
   248
	QString getURL();						// returns URL of selection or ""
insilmaril@721
   249
	QStringList getURLs();					// returns URLs of subtree
insilmaril@721
   250
insilmaril@721
   251
	void linkFloatImageTo(const QString &);
insilmaril@721
   252
insilmaril@721
   253
	void setFrameType(const FrameObj::FrameType &);
insilmaril@721
   254
	void setFrameType(const QString &);
insilmaril@721
   255
	void setFramePenColor (const QColor &);
insilmaril@721
   256
	void setFrameBrushColor (const QColor &);
insilmaril@721
   257
	void setFramePadding (const int &);
insilmaril@721
   258
	void setFrameBorderWidth (const int &);
insilmaril@721
   259
	void setIncludeImagesVer(bool);
insilmaril@721
   260
	void setIncludeImagesHor(bool);
insilmaril@721
   261
	void setHideLinkUnselected (bool);
insilmaril@721
   262
insilmaril@721
   263
	/*! Should object be hidden in exports (clouded)? */
insilmaril@721
   264
	void setHideExport(bool);			
insilmaril@721
   265
insilmaril@721
   266
	/*! Should object be hidden in exports (clouded)? */
insilmaril@721
   267
	void toggleHideExport();		
insilmaril@721
   268
insilmaril@721
   269
    void copy();						//!< Copy to clipboard
insilmaril@721
   270
private:	
insilmaril@721
   271
    void pasteNoSave(const int &n);		//!< paste clipboard to branch
insilmaril@721
   272
public:	
insilmaril@721
   273
    void paste();		//!< Paste clipboard to branch and backup
insilmaril@721
   274
    void cut();			//!< Cut to clipboard (and copy)
insilmaril@721
   275
insilmaril@721
   276
    void moveBranchUp();	//!< Move branch up
insilmaril@721
   277
    void moveBranchDown();	//!< Move branch down
insilmaril@721
   278
	void sortChildren();	//!< Sort children lexically
insilmaril@721
   279
insilmaril@726
   280
	// The create methods are used to quickly parse a XML file
insilmaril@739
   281
	void createMapCenter();			//!< Create and select MapCenter
insilmaril@739
   282
	void createBranch();			//!< Create and select Branch
insilmaril@739
   283
	TreeItem* createImage();		//!< Create and select image
insilmaril@726
   284
insilmaril@721
   285
	/*! \brief Add new mapcenter
insilmaril@721
   286
insilmaril@721
   287
	    Disclaimer: Still experimental, not fully supported yet.
insilmaril@721
   288
	*/	
insilmaril@650
   289
	MapCenterObj* addMapCenter();
insilmaril@721
   290
private:	
insilmaril@684
   291
	MapCenterObj* addMapCenter(QPointF absPos);
insilmaril@721
   292
public:	
insilmaril@650
   293
	MapCenterObj* removeMapCenter(MapCenterObj *mco);
insilmaril@652
   294
insilmaril@721
   295
	/*! \brief Add new branch
insilmaril@650
   296
insilmaril@721
   297
		Depending on num the new branch is created
insilmaril@652
   298
insilmaril@721
   299
		-3 above selection as child of selections parent
insilmaril@721
   300
		-2 as child of selection
insilmaril@721
   301
		-1 below selection as child of selections parent
insilmaril@721
   302
		0..n	insert at a specific position in selections parent
insilmaril@721
   303
		(needed for free relinking)
insilmaril@721
   304
	*/	
insilmaril@723
   305
	MapCenterObj* getLastMapCenter();		//!< get last added MapCenter, used for context menu
insilmaril@723
   306
insilmaril@721
   307
private:	
insilmaril@721
   308
    BranchObj* addNewBranchInt(int);		// pos allows to add above/below selection
insilmaril@721
   309
public:	
insilmaril@721
   310
	/*! \Add new branch
insilmaril@721
   311
		
insilmaril@721
   312
		Depending on num the new branch is created
insilmaril@721
   313
		-1 above selection
insilmaril@721
   314
		 0 as child of selection
insilmaril@721
   315
		 1 below selection
insilmaril@721
   316
	*/
insilmaril@721
   317
    BranchObj* addNewBranch(int pos);		
insilmaril@721
   318
    BranchObj* addNewBranchBefore();		//!< Insert branch between selection and its parent
insilmaril@721
   319
    void deleteSelection();					//!< Delete selection
insilmaril@721
   320
	void deleteKeepChildren();				//!< remove branch, but keep children
insilmaril@721
   321
	void deleteChildren();					//!< keep branch, but remove children
insilmaril@652
   322
insilmaril@721
   323
private:	
insilmaril@721
   324
	bool scrollBranch(BranchObj*);
insilmaril@721
   325
	bool unscrollBranch(BranchObj*);
insilmaril@721
   326
public:	
insilmaril@721
   327
    void toggleScroll();
insilmaril@721
   328
    void unscrollChildren();
insilmaril@721
   329
insilmaril@721
   330
    void addFloatImage(const QPixmap &img);
insilmaril@721
   331
insilmaril@721
   332
    void colorBranch(QColor);
insilmaril@721
   333
    void colorSubtree(QColor);
insilmaril@721
   334
	QColor getCurrentHeadingColor();
insilmaril@721
   335
insilmaril@721
   336
insilmaril@721
   337
	void editURL();							// edit URL
insilmaril@721
   338
	void editLocalURL();					// edit URL to local file
insilmaril@721
   339
	void editHeading2URL();					// copy heading to URL
insilmaril@721
   340
	void editBugzilla2URL();				// create URL to Bugzilla
insilmaril@721
   341
	void editFATE2URL();					// create URL to FATE
insilmaril@721
   342
	void editVymLink();						// edit link to another map
insilmaril@721
   343
	void setVymLink (const QString &);	// Set vymLink for selection
insilmaril@721
   344
	void deleteVymLink();					// delete link to another map
insilmaril@721
   345
	QString getVymLink();					// return path to map
insilmaril@721
   346
	QStringList getVymLinks();				// return paths in subtree
insilmaril@721
   347
	void followXLink (int);
insilmaril@721
   348
	void editXLink (int);
insilmaril@721
   349
insilmaril@721
   350
insilmaril@721
   351
insilmaril@721
   352
insilmaril@721
   353
////////////////////////////////////////////
insilmaril@721
   354
// Scripting
insilmaril@721
   355
////////////////////////////////////////////
insilmaril@721
   356
public:	
insilmaril@721
   357
insilmaril@721
   358
	/* \brief Process one command and its parameters */
insilmaril@721
   359
    void parseAtom (const QString &atom);	
insilmaril@721
   360
insilmaril@721
   361
	/* \brief Runs the script */
insilmaril@721
   362
	void runScript (QString script);
insilmaril@721
   363
insilmaril@721
   364
private:
insilmaril@721
   365
	Parser parser;
insilmaril@721
   366
insilmaril@721
   367
////////////////////////////////////////////
insilmaril@721
   368
// Exports
insilmaril@721
   369
////////////////////////////////////////////
insilmaril@721
   370
private:
insilmaril@721
   371
	HideTmpMode hidemode;	// true while exporting to hide some stuff
insilmaril@721
   372
insilmaril@721
   373
public:
insilmaril@721
   374
	/*! Set or unset temporary hiding of objects during export  */
insilmaril@721
   375
	void setExportMode (bool);
insilmaril@721
   376
insilmaril@721
   377
	/*! Save as image */
insilmaril@721
   378
    void exportImage (QString fname="",bool askForName=true,QString format="PNG");
insilmaril@721
   379
insilmaril@721
   380
insilmaril@721
   381
	/*! Export as XTML to directory */
insilmaril@721
   382
    void exportXML(QString dir="", bool askForName=true);
insilmaril@721
   383
insilmaril@721
   384
	/*! Export as ASCII text to file */
insilmaril@721
   385
	void exportASCII (QString fname="",bool askForName=true);  
insilmaril@721
   386
insilmaril@721
   387
	/*! Export as XHTML to directory */
insilmaril@721
   388
    void exportXHTML(const QString& dir="", bool askForName=true);	
insilmaril@721
   389
insilmaril@721
   390
    /*! Export as OpenOfficeOrg presentation */
insilmaril@721
   391
    void exportOOPresentation(const QString &,const QString &);	
insilmaril@721
   392
insilmaril@721
   393
insilmaril@721
   394
////////////////////////////////////////////
insilmaril@721
   395
// View related
insilmaril@721
   396
////////////////////////////////////////////
insilmaril@721
   397
public:
insilmaril@721
   398
	void registerEditor (QWidget *);
insilmaril@721
   399
	void unregisterEditor (QWidget *);
insilmaril@723
   400
insilmaril@723
   401
private: 
insilmaril@723
   402
	QPointF contextPos;					//!< local position during context menu
insilmaril@723
   403
public:
insilmaril@723
   404
	void setContextPos (QPointF);		//!< local position during context menu
insilmaril@723
   405
	void unsetContextPos ();			//!< forget local position after context menu
insilmaril@723
   406
insilmaril@721
   407
	void updateNoteFlag();				//!< Signal origination in TextEditor
insilmaril@650
   408
    void updateRelPositions();
insilmaril@650
   409
insilmaril@650
   410
	QRectF getTotalBBox();
insilmaril@650
   411
	void reposition();					//!< Call reposition for all MCOs
insilmaril@721
   412
	void setHideTmpMode (HideTmpMode mode);	
insilmaril@721
   413
insilmaril@665
   414
	QPolygonF shape(BranchObj *bo);		//!< Returns arbitrary shape of subtree
insilmaril@665
   415
	void moveAway (LinkableMapObj *lmo);//!< Autolayout: Move all out of the way
insilmaril@652
   416
insilmaril@721
   417
	//void ensureSelectionVisible();		//!< Show selection in all views
insilmaril@721
   418
insilmaril@721
   419
private:
insilmaril@721
   420
	MapEditor *mapEditor;
insilmaril@721
   421
insilmaril@721
   422
	QColor defLinkColor;		// default color for links
insilmaril@721
   423
	QColor defXLinkColor;		// default color for xlinks
insilmaril@721
   424
	int defXLinkWidth;			// default width for xlinks
insilmaril@721
   425
	LinkableMapObj::ColorHint linkcolorhint;// use heading color or own color
insilmaril@721
   426
	LinkableMapObj::Style linkstyle;		// default style for links
insilmaril@721
   427
insilmaril@721
   428
private:
insilmaril@721
   429
    QPixmap getPixmap();
insilmaril@721
   430
insilmaril@696
   431
public:
insilmaril@721
   432
	void setMapLinkStyle (const QString &);	// Set style of link
insilmaril@721
   433
	LinkableMapObj::Style getMapLinkStyle ();	// requested in LMO
insilmaril@721
   434
	void setMapDefLinkColor(QColor);		// default color of links
insilmaril@721
   435
	void setMapLinkColorHintInt();			// color of links
insilmaril@721
   436
	void setMapLinkColorHint(LinkableMapObj::ColorHint);// color of links
insilmaril@721
   437
	void toggleMapLinkColorHint();			// after changing linkStyles
insilmaril@721
   438
    void selectMapBackgroundImage();
insilmaril@721
   439
    void setMapBackgroundImage(const QString &);
insilmaril@721
   440
    void selectMapBackgroundColor();
insilmaril@721
   441
    void setMapBackgroundColor(QColor);
insilmaril@721
   442
    QColor getMapBackgroundColor();
insilmaril@721
   443
insilmaril@721
   444
insilmaril@721
   445
	LinkableMapObj::ColorHint getMapLinkColorHint();
insilmaril@721
   446
	QColor getMapDefLinkColor();
insilmaril@721
   447
	void setMapDefXLinkColor(QColor);
insilmaril@721
   448
	QColor getMapDefXLinkColor();
insilmaril@721
   449
	void setMapDefXLinkWidth (int);
insilmaril@721
   450
	int getMapDefXLinkWidth();
insilmaril@721
   451
insilmaril@721
   452
	/*!  Move absolutly to (x,y).  */	
insilmaril@721
   453
    void move    (const double &x, const double &y);
insilmaril@721
   454
insilmaril@721
   455
	/*!  Move relativly to (x,y).  */	
insilmaril@721
   456
    void moveRel (const double &x, const double &y);
insilmaril@721
   457
insilmaril@721
   458
////////////////////////////////////////////
insilmaril@721
   459
// Animation  **experimental**
insilmaril@721
   460
////////////////////////////////////////////
insilmaril@696
   461
private:	
insilmaril@696
   462
	QTimer *animationTimer;
insilmaril@696
   463
	bool animationUse;
insilmaril@696
   464
	uint animationTicks;
insilmaril@696
   465
	uint animationInterval;
insilmaril@696
   466
	int timerId;				// animation timer
insilmaril@696
   467
	QList <MapObj*> animObjList;// list with animated objects
insilmaril@696
   468
insilmaril@721
   469
private slots:
insilmaril@721
   470
	void animate();						//!< Called by timer to animate stuff
insilmaril@696
   471
public:
insilmaril@723
   472
	void startAnimation(BranchObj *bo, const QPointF &start, const QPointF &dest);
insilmaril@722
   473
	void stopAnimation(MapObj *mo);
insilmaril@722
   474
insilmaril@721
   475
////////////////////////////////////////////
insilmaril@721
   476
// Network related 
insilmaril@721
   477
////////////////////////////////////////////
insilmaril@721
   478
public:
insilmaril@721
   479
    /*! \brief Networking states
insilmaril@721
   480
		
insilmaril@721
   481
		In Network modus we want to switch of saveState, autosave, ...
insilmaril@721
   482
	*/
insilmaril@721
   483
	enum NetState {
insilmaril@721
   484
		Offline,			//!< Offline
insilmaril@721
   485
		Client,				//!< I am the client and connected to server
insilmaril@721
   486
		Server				//!< I am the server
insilmaril@721
   487
	};
insilmaril@721
   488
insilmaril@721
   489
private:
insilmaril@721
   490
	// Network connections **Experimental**
insilmaril@721
   491
	NetState netstate;			// offline, client, server
insilmaril@721
   492
	QTcpServer *tcpServer;		// Act as server in conference mode (experimental)
insilmaril@721
   493
	QList <QTcpSocket*> clientList;		// List of connected clients
insilmaril@721
   494
	quint16 sendCounter;		// Increased with every sent command
insilmaril@721
   495
insilmaril@721
   496
	QTcpSocket	*clientSocket;	// socket of this client
insilmaril@721
   497
	QString server;				// server address of this client
insilmaril@721
   498
	int port;					// server port of this client
insilmaril@721
   499
insilmaril@721
   500
insilmaril@721
   501
insilmaril@721
   502
protected:
insilmaril@721
   503
	void sendSelection();
insilmaril@721
   504
insilmaril@721
   505
public:
insilmaril@721
   506
	void newServer();
insilmaril@721
   507
	void connectToServer();
insilmaril@721
   508
insilmaril@721
   509
private slots:	
insilmaril@721
   510
	void newClient();
insilmaril@721
   511
	void sendData(const QString &s);
insilmaril@721
   512
	void readData();
insilmaril@721
   513
	void displayNetworkError (QAbstractSocket::SocketError);
insilmaril@721
   514
insilmaril@721
   515
private:	
insilmaril@721
   516
	void displayClientError(QAbstractSocket::SocketError socketError);
insilmaril@721
   517
insilmaril@721
   518
insilmaril@721
   519
////////////////////////////////////////////
insilmaril@721
   520
// Selection related 
insilmaril@721
   521
////////////////////////////////////////////
insilmaril@721
   522
private:
insilmaril@721
   523
	Selection selection;
insilmaril@721
   524
	QString latestSelectionString;	// select string of latest added object
insilmaril@721
   525
insilmaril@728
   526
signals:
insilmaril@728
   527
	void selectionChanged(const QItemSelection &, const QItemSelection &);
insilmaril@728
   528
insilmaril@721
   529
public:
insilmaril@727
   530
	void setSelectionModel(QItemSelectionModel *);		// Set common selectionModel
insilmaril@728
   531
	QItemSelectionModel* getSelectionModel();
insilmaril@727
   532
insilmaril@721
   533
	void setSelectionBlocked(bool);
insilmaril@721
   534
	bool isSelectionBlocked();
insilmaril@721
   535
insilmaril@727
   536
	bool select ();							// select by using common QItemSlectionModel
insilmaril@727
   537
	bool select (const QString &);			// Select by string
insilmaril@738
   538
	bool select (LinkableMapObj *lmo);		// Select by pointer to LMO
insilmaril@738
   539
	bool select (TreeItem *ti );			// Select by point to TreeItem
insilmaril@721
   540
	void unselect();
insilmaril@721
   541
	void reselect();
insilmaril@721
   542
insilmaril@721
   543
	void ensureSelectionVisible();			//!< Show selection in all views
insilmaril@721
   544
insilmaril@721
   545
	void selectInt(LinkableMapObj*);	
insilmaril@721
   546
insilmaril@721
   547
private:	
insilmaril@721
   548
	void selectNextBranchInt();		// Increment number of branch
insilmaril@721
   549
	void selectPrevBranchInt();		// Decrement number of branch
insilmaril@721
   550
public:	
insilmaril@721
   551
    void selectUpperBranch();
insilmaril@721
   552
    void selectLowerBranch();
insilmaril@721
   553
    void selectLeftBranch();
insilmaril@721
   554
    void selectRightBranch();
insilmaril@721
   555
    void selectFirstBranch();
insilmaril@721
   556
    void selectLastBranch();
insilmaril@735
   557
	void selectLastSelectedBranch();
insilmaril@726
   558
	void selectParent();
insilmaril@721
   559
insilmaril@721
   560
public:
insilmaril@735
   561
	TreeItem::Type selectionType();
insilmaril@735
   562
	LinkableMapObj* getSelectedLMO();
insilmaril@652
   563
	BranchObj* getSelectedBranch();
insilmaril@738
   564
	TreeItem* getSelectedBranchItem();
insilmaril@738
   565
	TreeItem* getSelectedItem();
insilmaril@735
   566
	QModelIndex getSelectedIndex();
insilmaril@721
   567
	FloatImageObj* getSelectedFloatImage();
insilmaril@721
   568
	QString getSelectString ();
insilmaril@652
   569
	QString getSelectString (LinkableMapObj *lmo);
insilmaril@721
   570
	
insilmaril@735
   571
	void updateSelection(const QItemSelection &oldsel);
insilmaril@721
   572
	void updateSelection();
insilmaril@721
   573
	void selectMapLinkColor();
insilmaril@721
   574
    void selectMapSelectionColor();
insilmaril@721
   575
private:	
insilmaril@721
   576
    void setSelectionColorInt(QColor);
insilmaril@727
   577
	QItemSelectionModel *selModel;
insilmaril@727
   578
insilmaril@721
   579
public:	
insilmaril@721
   580
    void setSelectionColor(QColor);
insilmaril@721
   581
    QColor getSelectionColor();
insilmaril@652
   582
insilmaril@650
   583
};
insilmaril@650
   584
insilmaril@650
   585
#endif