mapeditor.h
author insilmaril
Sat, 31 Mar 2007 09:28:27 +0000
changeset 440 c6a8651e6bbc
parent 434 c585be63ec69
child 442 dfbc371b7280
permissions -rw-r--r--
1.8.70 Fixes in property window
     1 #ifndef MAPEDITOR_H
     2 #define MAPEDITOR_H
     3 
     4 #include <QBuffer>
     5 #include <QGraphicsView>
     6 
     7 #include "mapcenterobj.h"
     8 #include "file.h"
     9 #include "misc.h"
    10 #include "parser.h"
    11 #include "selection.h"
    12 #include "settings.h"
    13 
    14 
    15 class MapEditor : public QGraphicsView, public xmlObj {
    16     Q_OBJECT
    17 
    18 public:
    19     MapEditor(QWidget* parent=0);
    20 	~MapEditor();
    21     MapCenterObj* getMapCenter();
    22 	QGraphicsScene * getScene();
    23 	bool isRepositionBlocked(); // block while load or undo
    24 	
    25 private:
    26 	QString getName(const LinkableMapObj*);	// Get e.g. heading or filename
    27 	void makeTmpDirs();		// create temporary directories
    28     QString saveToDir(const QString&,const QString &,bool, const QPointF &,LinkableMapObj*);
    29     void saveStateChangingPart (LinkableMapObj *, LinkableMapObj *, const QString &, const QString &);
    30     void saveStateRemovingPart (LinkableMapObj *, const QString &);
    31     void saveState(LinkableMapObj *, const QString &, LinkableMapObj *, const QString &, const QString &);
    32     void saveState(const QString &, const QString &, const QString &, const QString &, const QString &);
    33     void saveState(const SaveMode&, const QString &, const QString &, const QString &, const QString &, const QString &, LinkableMapObj *);
    34 public:	
    35     void parseAtom (const QString &);	
    36 	void runScript (QString);
    37 private:
    38     void addFloatImageInt(const QPixmap &img);
    39 
    40 public:
    41 	bool isDefault();		// false, if map was changed once
    42     bool isUnsaved();		// save necessary
    43     bool hasChanged();		// undo possible
    44 	void setChanged();		// called from NoteEditor via LMO
    45 	void closeMap();
    46 	void setFilePath (QString);	
    47 	void setFilePath (QString,QString);	
    48 	QString getFilePath ();	// Full path e.g. "/home/tux/map.xml"
    49 	QString getFileName ();	// e.g. "map.xml"
    50 	QString getMapName ();	// e.g. "map"
    51 	QString getDestPath (); // e.g. "/home/tux/map.vym"
    52     ErrorCode load (QString, LoadMode );	// newmap, import/replace selection
    53 public:
    54     int save(const SaveMode &);	// Save map 
    55 	void setZipped(bool);		// save map zipped
    56 	bool saveZipped();			// 1 if file will be saved zipped
    57     void print();				// print canvas
    58 	void setAntiAlias (bool);
    59 	void setSmoothPixmap(bool);
    60 private:
    61     QPixmap getPixmap();
    62 	void setHideTmpMode (HideTmpMode);	// temporary hide stuff
    63 	HideTmpMode getHideTmpMode();		// temporary hide stuff
    64 public:
    65 	void setExportMode (bool);			// temporary hide stuff during export
    66     void exportImage (QString fn);			// export as PNG	
    67     void exportImage (QString fn, QString);	// export in given format
    68     void exportOOPresentation(const QString &,const QString &);
    69     void exportXML(const QString&);		// export to directory
    70     void clear();		// clear map
    71     void copy();		// copy branch to clipboard
    72     void redo();		// redo last action
    73 	bool isRedoAvailable();
    74     void undo();		// undo last action
    75 	bool isUndoAvailable();
    76 	void gotoHistoryStep (int);// goto a step in history
    77 private:	
    78     void addMapReplaceInt(const QString & undoSel, const QString & path);
    79     void addMapInsertInt (const QString & path, int pos);
    80     void pasteNoSave();		// paste clipboard to branch
    81     void cutNoSave();	// cut to clipboard
    82 public:	
    83     void paste();		// paste clipboard to branch and backup
    84     void cut();			// cut to clipboard and backup
    85     void move    (const int &x, const int &y);
    86     void moveRel (const int &x, const int &y);
    87     void moveBranchUp();
    88     void moveBranchDown();
    89 private:	
    90 	void linkTo(const QString &);
    91 public:	
    92 	QString getHeading (bool &ok,QPoint &p); // Get heading, ok if selection is branch
    93 	void setHeading(const QString &);
    94 private:
    95 	void setHeadingInt(const QString &);
    96 	void setURLInt(const QString &);		// Just set the URL for selection
    97 	void setVymLinkInt(const QString &);	// Set vymLink for selection
    98     BranchObj* addNewBranchInt(int);		// pos allows to add above/below selection
    99 public:	
   100     BranchObj* addNewBranch(int);			// pos allows to add above/below selection
   101     BranchObj* addNewBranchBefore();		// insert and make selection its
   102     void deleteSelection();
   103 	LinkableMapObj* getSelection();	// returns selection
   104 	void unselect();				// before changing current noteedit
   105 	void reselect();				// after  changing current noteedit
   106 	bool select(const QString &);	// Select by string
   107 	QString getSelectString();
   108 private:	
   109 	void selectInt(LinkableMapObj*);	
   110 	void selectNextBranchInt();		// Increment number of branch
   111 	void selectPrevBranchInt();		// Decrement number of branch
   112 public:	
   113     void selectUpperBranch();
   114     void selectLowerBranch();
   115     void selectLeftBranch();
   116     void selectRightBranch();
   117     void selectFirstBranch();
   118     void selectLastBranch();
   119     void selectMapBackgroundImage();
   120     void setMapBackgroundImage(const QString &);
   121     void selectMapBackgroundColor();
   122     void setMapBackgroundColor(QColor);
   123     QColor getMapBackgroundColor();
   124     QColor getCurrentHeadingColor();
   125     void colorBranch(QColor);
   126     void colorSubtree(QColor);
   127 	void toggleStandardFlag(QString);
   128     BranchObj* findText(QString,bool);		// Find object
   129     void findReset();						// Reset Find 
   130 	void setURL(const QString &);			// set the URL
   131 	void editURL();							// edit the URL
   132 	QString getURL();						// returns URL of selection or ""
   133 	QStringList getURLs();					// returns URLs of subtree
   134 	void editHeading2URL();					// copy heading to URL
   135 	void editBugzilla2URL();				// create URL to Bugzilla
   136 	void editFATE2URL();					// create URL to FATE
   137 	void editVymLink();						// edit link to another map
   138 	void deleteVymLink();					// delete link to another map
   139 	QString getVymLink();					// return path to map
   140 	QStringList getVymLinks();				// return paths in subtree
   141 	void setHideExport(bool);				// toggle the export flag
   142 	void toggleHideExport();				// toggle the export flag
   143 	void deleteKeepChilds();				// remove but keep childs
   144 	void deleteChilds();					// remove childs
   145 	void editMapInfo();						// dialog to enter author, ...
   146 	void updateActions();					// update e.g. format buttons
   147 	void updateNoteFlag();					// when TextEditor changes
   148 	void setMapAuthor (const QString &);
   149 	void setMapComment(const QString &);
   150 	void setMapLinkStyle (const QString &);	// Set style of link
   151 	LinkStyle getMapLinkStyle ();			// requested in LMO
   152 	void setMapDefLinkColor(QColor);		// default color of links
   153 	void setMapLinkColorHintInt();			// color of links
   154 	void setMapLinkColorHint(LinkColorHint);// color of links
   155 	LinkColorHint getMapLinkColorHint();
   156 	QColor getMapDefLinkColor();
   157 	void setMapDefXLinkColor(QColor);
   158 	QColor getMapDefXLinkColor();
   159 	void setMapDefXLinkWidth (int);
   160 	int getMapDefXLinkWidth();
   161 	void toggleMapLinkColorHint();			// after changing linkStyles
   162     void selectMapLinkColor();
   163 	bool scrollBranch();
   164 	bool unscrollBranch();
   165     void toggleScroll();
   166     void unscrollChilds();
   167 private:	
   168 	FloatImageObj* loadFloatImageInt (QString);
   169 public:	
   170 	void loadFloatImage ();
   171 private:	
   172 	void saveFloatImageInt (FloatImageObj*, const QString &, const QString &);
   173 public:	
   174 	void saveFloatImage ();
   175 	void setFrame(const FrameType &);
   176 	void setIncludeImagesVer(bool);
   177 	void setIncludeImagesHor(bool);
   178 	void setHideLinkUnselected (bool);
   179 	bool getHideLinkUnselected ();
   180 private:	
   181     void importDirInt(BranchObj *,QDir);
   182 public:	
   183     void importDir();
   184 	void followXLink (int);
   185 	void editXLink (int);
   186     void testFunction();					// just testing new stuff
   187 											// set /mainwindo/showTestMenu=true...
   188 
   189 protected:
   190 	void ensureSelectionVisible();		
   191 	virtual void contextMenuEvent ( QContextMenuEvent *e );
   192     virtual void keyPressEvent(QKeyEvent*);
   193     virtual void keyReleaseEvent(QKeyEvent*);
   194     virtual void mousePressEvent(QMouseEvent*);
   195     virtual void mouseReleaseEvent(QMouseEvent*);
   196     virtual void mouseDoubleClickEvent(QMouseEvent*);
   197     virtual void mouseMoveEvent(QMouseEvent*);
   198 
   199 	void dragEnterEvent (QDragEnterEvent *);
   200 	void dragMoveEvent (QDragMoveEvent *);
   201 	void dragLeaveEvent (QDragLeaveEvent *);
   202 	void dropEvent (QDropEvent *);
   203 
   204 private:
   205 	QGraphicsScene *mapScene;
   206     MapCenterObj* mapCenter;
   207 
   208 	bool adjustCanvasRequested;	// collect requests until end of user event
   209 	BranchObj *editingBO;		// entering Text into BO
   210 
   211 	QColor defLinkColor;		// default color for links
   212 	QColor defXLinkColor;		// default color for xlinks
   213 	int defXLinkWidth;			// default width for xlinks
   214 	LinkColorHint linkcolorhint;// use heading color or own color
   215 	LinkStyle linkstyle;		// default style for links
   216 
   217     QCursor HandOpenCursor;		// cursor while moving canvas view
   218 	QCursor PickColorCursor;	// cursor while picking color 
   219 	QCursor CopyCursor;			// cursor while picking color 
   220 	QCursor XLinkCursor;		// cursor while picking color 
   221 	bool pickingColor;
   222 	bool drawingLink;			// true while creating a link
   223 	bool copyingObj;			// true while creating a link
   224 	XLinkObj* tmpXLink;
   225 
   226 	Selection xelection;	
   227     MapObj* movingObj;				// moving a MapObj
   228 	MapObj* linkingObj_src;			// part of a link
   229     QPointF movingObj_orgPos;		// org. pos of mouse before move
   230     QPointF movingObj_orgRelPos;	// org. relative pos of mouse before move
   231     QPointF movingObj_start;		// rel. pos of mouse to absPos 
   232     QPointF movingCont_start;		// inital pos of moving Content or
   233     QPointF movingVec;				// how far has Content moved
   234     QPrinter* printer;				// Printing
   235 
   236     bool mapDefault;				// Flag if map is untouched
   237     bool mapChanged;				// Flag if undo is possible
   238 	bool mapUnsaved;				// Flag if map should be saved
   239 
   240 	Parser parser;				// Parser stuff for scripting
   241 
   242 	bool printFrame;			// Print frame around map
   243 	bool printFooter;			// Print footer below map
   244 
   245 	bool zipped;				// should map be zipped
   246 	static	int mapNum;			// unique number for Editor
   247 	QString fileName;			// short name of file (for tab)
   248 	QString filePath;			// path to file which will be saved
   249 	QString fileDir;			// dir where file is saved
   250 	QString destPath;			// path to .vym file (needed for vymlinks)
   251 	QString mapName;			// fileName without ".vym"
   252 
   253 	QString tmpMapDir;			// tmp directory with undo history
   254 	QString histPath;			// Path to history file
   255 	int stepsTotal;				// total number of steps (undos+redos) 
   256 	SimpleSettings undoSet;		// undo/redo commands
   257 	bool blockReposition;		// block while load or undo
   258 	bool blockSaveState;		// block while load or undo
   259 
   260 	BranchObj* itFind;			// next object in find process
   261 	bool EOFind;				// true, if search failed
   262 
   263 	QPoint exportOffset;		// set before export, used in save
   264 	HideTmpMode hidemode;			// true while exporting to hide some stuff
   265 	
   266     void resizeEvent( QResizeEvent * );
   267 };
   268 #endif
   269