mapeditor.h
author insilmaril
Wed, 11 Apr 2007 09:21:14 +0000
changeset 452 28700534e598
parent 445 0796c5592f00
child 473 8b9cfc26638c
permissions -rw-r--r--
Updated documentation about macros
     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 	BranchObj* getSelectedBranch();			// returns selected branch or NULL
   105 	FloatImageObj* getSelectedFloatImage();	// returns selected branch or NULL
   106 	void unselect();						// before changing current noteedit
   107 	void reselect();						// after  changing current noteedit
   108 	bool select(const QString &);			// Select by string
   109 	QString getSelectString();
   110 private:	
   111 	void selectInt(LinkableMapObj*);	
   112 	void selectNextBranchInt();		// Increment number of branch
   113 	void selectPrevBranchInt();		// Decrement number of branch
   114 public:	
   115     void selectUpperBranch();
   116     void selectLowerBranch();
   117     void selectLeftBranch();
   118     void selectRightBranch();
   119     void selectFirstBranch();
   120     void selectLastBranch();
   121     void selectMapBackgroundImage();
   122     void setMapBackgroundImage(const QString &);
   123     void selectMapBackgroundColor();
   124     void setMapBackgroundColor(QColor);
   125     QColor getMapBackgroundColor();
   126     QColor getCurrentHeadingColor();
   127     void colorBranch(QColor);
   128     void colorSubtree(QColor);
   129 	void toggleStandardFlag(QString);
   130     BranchObj* findText(QString,bool);		// Find object
   131     void findReset();						// Reset Find 
   132 	void setURL(const QString &);			// set the URL
   133 	void editURL();							// edit the URL
   134 	QString getURL();						// returns URL of selection or ""
   135 	QStringList getURLs();					// returns URLs of subtree
   136 	void editHeading2URL();					// copy heading to URL
   137 	void editBugzilla2URL();				// create URL to Bugzilla
   138 	void editFATE2URL();					// create URL to FATE
   139 	void editVymLink();						// edit link to another map
   140 	void deleteVymLink();					// delete link to another map
   141 	QString getVymLink();					// return path to map
   142 	QStringList getVymLinks();				// return paths in subtree
   143 	void setHideExport(bool);				// toggle the export flag
   144 	void toggleHideExport();				// toggle the export flag
   145 	void deleteKeepChilds();				// remove but keep childs
   146 	void deleteChilds();					// remove childs
   147 	void editMapInfo();						// dialog to enter author, ...
   148 	void ensureSelectionVisible();		
   149 	void updateSelection();					// update geometry of selection
   150 	void updateActions();					// update e.g. format buttons
   151 	void updateNoteFlag();					// when TextEditor changes
   152 	void setMapAuthor (const QString &);
   153 	void setMapComment(const QString &);
   154 	void setMapLinkStyle (const QString &);	// Set style of link
   155 	LinkStyle getMapLinkStyle ();			// requested in LMO
   156 	void setMapDefLinkColor(QColor);		// default color of links
   157 	void setMapLinkColorHintInt();			// color of links
   158 	void setMapLinkColorHint(LinkColorHint);// color of links
   159 	LinkColorHint getMapLinkColorHint();
   160 	QColor getMapDefLinkColor();
   161 	void setMapDefXLinkColor(QColor);
   162 	QColor getMapDefXLinkColor();
   163 	void setMapDefXLinkWidth (int);
   164 	int getMapDefXLinkWidth();
   165 	void toggleMapLinkColorHint();			// after changing linkStyles
   166     void selectMapLinkColor();
   167     void selectMapSelectionColor();
   168 private:	
   169     void setSelectionColorInt(QColor);
   170 public:	
   171     void setSelectionColor(QColor);
   172     QColor getSelectionColor();
   173 	bool scrollBranch();
   174 	bool unscrollBranch();
   175     void toggleScroll();
   176     void unscrollChilds();
   177 private:	
   178 	FloatImageObj* loadFloatImageInt (QString);
   179 public:	
   180 	void loadFloatImage ();
   181 private:	
   182 	void saveFloatImageInt (FloatImageObj*, const QString &, const QString &);
   183 public:	
   184 	void saveFloatImage ();
   185 	void setFrameType(const FrameType &);
   186 	void setFrameType(const QString &);
   187 	void setFramePenColor (const QColor &);
   188 	void setFrameBrushColor (const QColor &);
   189 	void setIncludeImagesVer(bool);
   190 	void setIncludeImagesHor(bool);
   191 	void setHideLinkUnselected (bool);
   192 	bool getHideLinkUnselected ();
   193 private:	
   194     void importDirInt(BranchObj *,QDir);
   195 public:	
   196     void importDir();
   197 	void followXLink (int);
   198 	void editXLink (int);
   199     void testFunction();					// just testing new stuff
   200 											// set /mainwindo/showTestMenu=true...
   201 
   202 protected:
   203 	virtual void contextMenuEvent ( QContextMenuEvent *e );
   204     virtual void keyPressEvent(QKeyEvent*);
   205     virtual void keyReleaseEvent(QKeyEvent*);
   206     virtual void mousePressEvent(QMouseEvent*);
   207     virtual void mouseReleaseEvent(QMouseEvent*);
   208     virtual void mouseDoubleClickEvent(QMouseEvent*);
   209     virtual void mouseMoveEvent(QMouseEvent*);
   210 
   211 	void dragEnterEvent (QDragEnterEvent *);
   212 	void dragMoveEvent (QDragMoveEvent *);
   213 	void dragLeaveEvent (QDragLeaveEvent *);
   214 	void dropEvent (QDropEvent *);
   215 
   216 private:
   217 	QGraphicsScene *mapScene;
   218     MapCenterObj* mapCenter;
   219 
   220 	bool adjustCanvasRequested;	// collect requests until end of user event
   221 	BranchObj *editingBO;		// entering Text into BO
   222 
   223 	QColor defLinkColor;		// default color for links
   224 	QColor defXLinkColor;		// default color for xlinks
   225 	int defXLinkWidth;			// default width for xlinks
   226 	LinkColorHint linkcolorhint;// use heading color or own color
   227 	LinkStyle linkstyle;		// default style for links
   228 
   229     QCursor HandOpenCursor;		// cursor while moving canvas view
   230 	QCursor PickColorCursor;	// cursor while picking color 
   231 	QCursor CopyCursor;			// cursor while picking color 
   232 	QCursor XLinkCursor;		// cursor while picking color 
   233 	bool pickingColor;
   234 	bool drawingLink;			// true while creating a link
   235 	bool copyingObj;			// true while creating a link
   236 	XLinkObj* tmpXLink;
   237 
   238 	Selection xelection;	
   239     MapObj* movingObj;				// moving a MapObj
   240 	MapObj* linkingObj_src;			// part of a link
   241     QPointF movingObj_orgPos;		// org. pos of mouse before move
   242     QPointF movingObj_orgRelPos;	// org. relative pos of mouse before move
   243     QPointF movingObj_start;		// rel. pos of mouse to absPos 
   244     QPointF movingCont_start;		// inital pos of moving Content or
   245     QPointF movingVec;				// how far has Content moved
   246     QPrinter* printer;				// Printing
   247 
   248     bool mapDefault;				// Flag if map is untouched
   249     bool mapChanged;				// Flag if undo is possible
   250 	bool mapUnsaved;				// Flag if map should be saved
   251 
   252 	Parser parser;				// Parser stuff for scripting
   253 
   254 	bool printFrame;			// Print frame around map
   255 	bool printFooter;			// Print footer below map
   256 
   257 	bool zipped;				// should map be zipped
   258 	static	int mapNum;			// unique number for Editor
   259 	QString fileName;			// short name of file (for tab)
   260 	QString filePath;			// path to file which will be saved
   261 	QString fileDir;			// dir where file is saved
   262 	QString destPath;			// path to .vym file (needed for vymlinks)
   263 	QString mapName;			// fileName without ".vym"
   264 
   265 	QString tmpMapDir;			// tmp directory with undo history
   266 	QString histPath;			// Path to history file
   267 	int stepsTotal;				// total number of steps (undos+redos) 
   268 	SimpleSettings undoSet;		// undo/redo commands
   269 	bool blockReposition;		// block while load or undo
   270 	bool blockSaveState;		// block while load or undo
   271 
   272 	BranchObj* itFind;			// next object in find process
   273 	bool EOFind;				// true, if search failed
   274 
   275 	QPoint exportOffset;		// set before export, used in save
   276 	HideTmpMode hidemode;			// true while exporting to hide some stuff
   277 	
   278     void resizeEvent( QResizeEvent * );
   279 };
   280 #endif
   281