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