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