mapeditor.h
author insilmaril
Mon, 06 Jun 2005 20:27:42 +0000
changeset 105 67a91e28b30f
parent 98 58adc2d2ed08
child 106 4083860dd82e
permissions -rw-r--r--
1.6.8 started API to speedup undos
     1 #ifndef MAPEDITOR_H
     2 #define MAPEDITOR_H
     3 
     4 #include <qcanvas.h>
     5 #include <qlineedit.h>
     6 #include <qcursor.h>
     7 #include <qfiledialog.h>
     8 #include <qevent.h>
     9 #include <qprocess.h>
    10 
    11 #include "mapcenterobj.h"
    12 #include "misc.h"
    13 
    14 class MapEditor : public QCanvasView , public xmlObj {
    15     Q_OBJECT
    16 
    17 public:
    18     MapEditor(QWidget* parent=0, bool interactive=false, const char* name=0, WFlags f=0);
    19 	~MapEditor();
    20     QColor color();
    21     QColor backgroundColor();
    22     MapCenterObj* getMapCenter();
    23 	QCanvas* getCanvas();
    24 	void adjustCanvasSize();// adjust canvas size to map and scrollview
    25 	bool blockReposition(); // block while load or undo
    26 	
    27 private:
    28 	void makeTmpDirs();		// create temporary directories
    29 	void delTmpDirs();		// delete temporary directories
    30 	void makeSubDirs(const QString&);		
    31 							// create subdirs in dir
    32     QString saveToDir(const QString&,const QString &,bool, const QPoint
    33 	&,SaveMode);
    34     void saveState();		// save actual state to backup
    35     void saveState(const SaveMode&, LinkableMapObj *);
    36     void saveState(const SaveMode&, LinkableMapObj *, const QString &);
    37 
    38 private slots:
    39     void finishedLineEditNoSave();
    40 
    41 public:
    42 	bool isDefault();		// false, if map was changed once
    43     bool isUnsaved();		// save necessary
    44     bool hasChanged();		// undo possible
    45 	void setChanged();		// called from NoteEditor via LMO
    46 	void closeMap();
    47 	void setFilePath (QString);	
    48 	void setFilePath (QString,QString);	
    49 	QString getFilePath ();	// Full path e.g. "/home/tux/map.xml"
    50 	QString getFileName ();	// e.g. "map.xml"
    51 	QString getMapName ();	// e.g. "map"
    52 	QString getDestPath (); // e.g. "/home/tux/map.vym"
    53     int load (QString&, const LoadMode &);	// newmap, import/replace selection
    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 private:
    59     QPixmap getPixmap();
    60 public:
    61     void exportImage (QString fn);		// export as PNG	
    62     void exportImage (QString fn, int);	// export in given format
    63     void exportASCII();
    64     void exportXML(const QString&);		// export to directory
    65     void clear();		// clear map
    66     void undo();		// undo last action
    67     void copy();		// copy branch to clipboard
    68 private:	
    69     LinkableMapObj* pasteNoSave();		// paste clipboard to branch
    70     void cutNoSave();	// cut to clipboard
    71 public:	
    72     void paste();		// paste clipboard to branch and backup
    73     void cut();			// cut to clipboard and backup
    74     void moveBranchUp();
    75     void moveBranchDown();
    76     void editHeading();
    77     void addNewBranch(int);			// pos allows to add above/below selection
    78     void addNewBranchHere();		// insert and make selection its
    79     void deleteSelection();
    80 	LinkableMapObj* getSelection();	// returns selection
    81 	bool select(const QString &);	// Select 
    82 	void unselect();				// before changing current noteedit
    83 	void reselect();				// after  changing current noteedit
    84 private:	
    85 	void selectNextBranch();		// Increment number of branch
    86 	void selectPrevBranch();		// Decrement number of branch
    87 public:	
    88     void selectUpperBranch();
    89     void selectLowerBranch();
    90     void selectLeftBranch();
    91     void selectRightBranch();
    92     void selectFirstBranch();
    93     void selectLastBranch();
    94     void setColor(QColor);
    95     void selectBackgroundColor();
    96     void setBackgroundColor(QColor);
    97     QColor pickColor();
    98     void colorItem();
    99     void colorBranch();
   100 	void toggleStandardFlag(QString);
   101 	virtual void setViewCenter();			// needed for zooming
   102     BranchObj* findText(QString,bool);		// Find object
   103     void findReset();						// Reset Find 
   104 	void openURL();							// open URL in external browser
   105 	void editURL();							// edit the URL
   106 	void editHeading2URL();					// copy heading to URL
   107 	void editBugzilla2URL();				// create URL to Bugzilla
   108 	void editVymLink();						// edit link to another map
   109 	void deleteVymLink();					// delete link to another map
   110 	QString getVymLink();					// return path to map
   111 	void removeBranchHere();				// remove but keep childs
   112 	void removeChilds();					// remove childs
   113 	void editMapInfo();						// dialog to enter author, ...
   114 	void updateActions();					// update e.g. format buttons
   115 	void setLinkStyle (LinkStyle);			// Set style of link
   116 	LinkStyle getLinkStyle ();				// requested in LMO
   117 	void setLinkColor(QColor);				// default color of links
   118 	void setLinkColorHint();				// color of links
   119 	void setLinkColorHint(LinkColorHint);	// color of links
   120 	LinkColorHint getLinkColorHint();
   121 	QColor getDefLinkColor();
   122 	void setDefXLinkColor(QColor);
   123 	QColor getDefXLinkColor();
   124 	void setDefXLinkWidth (int);
   125 	int getDefXLinkWidth();
   126 	void toggleLinkColorHint();				// after changing linkStyles
   127     void selectLinkColor();
   128     void toggleScroll();
   129     void unScrollAll();
   130 	void loadFloatImage ();
   131 	void saveFloatImage (int);
   132 	void toggleFloatExport();
   133 	void setFrame(const FrameType &);
   134 private:	
   135     void importDir(BranchObj *,QDir);
   136 public:	
   137     void importDir();
   138 	void followXLink (int);
   139 	void editXLink (int);
   140     void testFunction();				// FIXME just testing
   141     void parseTest(const QString &);	// FIXME just testing
   142 
   143 protected:
   144 	void ensureSelectionVisible();		
   145 	virtual void updateViewCenter();	// needed for zooming
   146 	virtual void contentsContextMenuEvent ( QContextMenuEvent *e );
   147     virtual void contentsMousePressEvent(QMouseEvent*);
   148     virtual void contentsMouseReleaseEvent(QMouseEvent*);
   149     virtual void contentsMouseDoubleClickEvent(QMouseEvent*);
   150     virtual void contentsMouseMoveEvent(QMouseEvent*);
   151 
   152 private:
   153     QCanvas* mapCanvas;
   154     MapCenterObj* mapCenter;
   155 
   156 	bool adjustCanvasRequested;	// collect requests until end of user event
   157 	BranchObj *editingBO;		// entering Text into BO
   158     QLineEdit* lineedit;
   159 
   160     QColor actColor;			// actual color
   161 	QColor defLinkColor;		// default color for links
   162 	QColor defXLinkColor;		// default color for xlinks
   163 	int defXLinkWidth;			// default width for xlinks
   164 	LinkColorHint linkcolorhint;// use heading color or own color
   165 	LinkStyle linkstyle;		// default style for links
   166 
   167     QCursor handOpenCursor;		// cursor while moving canvas view
   168 	QCursor pickColorCursor;	// cursor while picking color 
   169 	bool pickingColor;
   170 	bool drawingLink;			// true while creating a link
   171 	bool copyingObj;			// true while creating a link
   172 	XLinkObj* tmpXLink;
   173 	
   174     LinkableMapObj* selection;		// select a LinkableMapObj
   175     LinkableMapObj* selectionLast;	// last selection 
   176     MapObj* movingObj;				// moving a MapObj
   177 	MapObj* linkingObj_src;			// part of a link
   178     QPoint movingObj_start;			// rel. pos of mouse to absPos 
   179     QPoint movingCont_start;		// inital pos of moving Content or
   180     QPoint movingVec;				// how far has Content moved
   181 	QPoint movingCenter;			// used when zooming
   182     QPrinter* printer;				// Printing
   183 
   184     bool mapDefault;				// Flag if map is untouched
   185     bool mapChanged;				// Flag if undo is possible
   186 	bool mapUnsaved;				// Flag if map should be saved
   187     QString backupXML;				// backup (XML) for undo
   188 	LinkableMapObj* undoSelection;	// replace this LMO with vympart from backup
   189 	QString undoCommand;			// FIXME testing
   190 									// if != NULL
   191 
   192 	bool printFrame;			// Print frame around map
   193 	bool printFooter;			// Print footer below map
   194 
   195 	bool zipped;				// should map be zipped
   196 	QString fileName;			// short name of file (for tab)
   197 	QString filePath;			// path to file which will be saved
   198 	QString fileDir;			// dir where file is saved
   199 	QString destPath;			// path to .vym file (needed for vymlinks)
   200 	QString mapName;			// fileName without ".vym"
   201 	QString lastImageDir;		// save dir for adding images
   202 
   203 	bool isInteractive;			// non interactive don't need tmpdirs
   204 	QString bakMapDir;			// tmp directory with data for undo
   205 	bool blockreposition;		// block while load or undo
   206 
   207 	BranchObj* itFind;			// next object in find process
   208 	bool EOFind;				// true, if search failed
   209 
   210 	QPoint exportOffset;		// set before export, used in save
   211     void resizeEvent( QResizeEvent * );
   212 };
   213 #endif
   214