mapeditor.h
author insilmaril
Wed, 18 May 2005 07:39:51 +0000
changeset 101 1d092be4fe33
parent 98 58adc2d2ed08
child 105 67a91e28b30f
permissions -rw-r--r--
fixed some bugs in xlinks, more remove/insert functions
     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 
    37 private slots:
    38     void finishedLineEditNoSave();
    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     int load (QString&, const LoadMode &);	// newmap, import/replace selection
    53     int save(const SaveMode &);	// Save map 
    54 	void setZipped(bool);		// save map zipped
    55 	bool saveZipped();			// 1 if file will be saved zipped
    56     void print();				// print canvas
    57 private:
    58     QPixmap getPixmap();
    59 public:
    60     void exportImage (QString fn);		// export as PNG	
    61     void exportImage (QString fn, int);	// export in given format
    62     void exportASCII();
    63     void exportXML(const QString&);		// export to directory
    64     void clear();		// clear map
    65     void undo();		// undo last action
    66     void copy();		// copy branch to clipboard
    67 private:	
    68     LinkableMapObj* pasteNoSave();		// paste clipboard to branch
    69     void cutNoSave();	// cut to clipboard
    70 public:	
    71     void paste();		// paste clipboard to branch and backup
    72     void cut();			// cut to clipboard and backup
    73     void moveBranchUp();
    74     void moveBranchDown();
    75     void editHeading();
    76     void addNewBranch(int);			// pos allows to add above/below selection
    77     void addNewBranchHere();		// insert and make selection its
    78     void deleteSelection();
    79 	LinkableMapObj* getSelection();	// returns selection
    80 	bool select(const QString &);	// Select 
    81 	void unselect();				// before changing current noteedit
    82 	void reselect();				// after  changing current noteedit
    83 private:	
    84 	void selectNextBranch();		// Increment number of branch
    85 	void selectPrevBranch();		// Decrement number of branch
    86 public:	
    87     void selectUpperBranch();
    88     void selectLowerBranch();
    89     void selectLeftBranch();
    90     void selectRightBranch();
    91     void selectFirstBranch();
    92     void selectLastBranch();
    93     void setColor(QColor);
    94     void selectBackgroundColor();
    95     void setBackgroundColor(QColor);
    96     QColor pickColor();
    97     void colorItem();
    98     void colorBranch();
    99 	void toggleStandardFlag(QString);
   100 	virtual void setViewCenter();			// needed for zooming
   101     BranchObj* findText(QString,bool);		// Find object
   102     void findReset();						// Reset Find 
   103 	void openURL();							// open URL in external browser
   104 	void editURL();							// edit the URL
   105 	void editHeading2URL();					// copy heading to URL
   106 	void editBugzilla2URL();				// create URL to Bugzilla
   107 	void editVymLink();						// edit link to another map
   108 	void deleteVymLink();					// delete link to another map
   109 	QString getVymLink();					// return path to map
   110 	void removeBranchHere();				// remove but keep childs
   111 	void removeChilds();					// remove childs
   112 	void editMapInfo();						// dialog to enter author, ...
   113 	void updateActions();					// update e.g. format buttons
   114 	void setLinkStyle (LinkStyle);			// Set style of link
   115 	LinkStyle getLinkStyle ();				// requested in LMO
   116 	void setLinkColor(QColor);				// default color of links
   117 	void setLinkColorHint();				// color of links
   118 	void setLinkColorHint(LinkColorHint);	// color of links
   119 	LinkColorHint getLinkColorHint();
   120 	QColor getDefLinkColor();
   121 	void setDefXLinkColor(QColor);
   122 	QColor getDefXLinkColor();
   123 	void setDefXLinkWidth (int);
   124 	int getDefXLinkWidth();
   125 	void toggleLinkColorHint();				// after changing linkStyles
   126     void selectLinkColor();
   127     void toggleScroll();
   128     void unScrollAll();
   129 	void loadFloatImage ();
   130 	void saveFloatImage (int);
   131 	void toggleFloatExport();
   132 	void setFrame(const FrameType &);
   133 private:	
   134     void importDir(BranchObj *,QDir);
   135 public:	
   136     void importDir();
   137 	void followXLink (int);
   138 	void editXLink (int);
   139     void testFunction();				// FIXME just testing
   140 
   141 protected:
   142 	void ensureSelectionVisible();		
   143 	virtual void updateViewCenter();	// needed for zooming
   144 	virtual void contentsContextMenuEvent ( QContextMenuEvent *e );
   145     virtual void contentsMousePressEvent(QMouseEvent*);
   146     virtual void contentsMouseReleaseEvent(QMouseEvent*);
   147     virtual void contentsMouseDoubleClickEvent(QMouseEvent*);
   148     virtual void contentsMouseMoveEvent(QMouseEvent*);
   149 
   150 private:
   151     QCanvas* mapCanvas;
   152     MapCenterObj* mapCenter;
   153 
   154 	bool adjustCanvasRequested;	// collect requests until end of user event
   155 	BranchObj *editingBO;		// entering Text into BO
   156     QLineEdit* lineedit;
   157 
   158     QColor actColor;			// actual color
   159 	QColor defLinkColor;		// default color for links
   160 	QColor defXLinkColor;		// default color for xlinks
   161 	int defXLinkWidth;			// default width for xlinks
   162 	LinkColorHint linkcolorhint;// use heading color or own color
   163 	LinkStyle linkstyle;		// default style for links
   164 
   165     QCursor handOpenCursor;		// cursor while moving canvas view
   166 	QCursor pickColorCursor;	// cursor while picking color 
   167 	bool pickingColor;
   168 	bool drawingLink;			// true while creating a link
   169 	bool copyingObj;			// true while creating a link
   170 	XLinkObj* tmpXLink;
   171 	
   172     LinkableMapObj* selection;		// select a LinkableMapObj
   173     LinkableMapObj* selectionLast;	// last selection 
   174     MapObj* movingObj;				// moving a MapObj
   175 	MapObj* linkingObj_src;			// part of a link
   176     QPoint movingObj_start;			// rel. pos of mouse to absPos 
   177     QPoint movingCont_start;		// inital pos of moving Content or
   178     QPoint movingVec;				// how far has Content moved
   179 	QPoint movingCenter;			// used when zooming
   180     QPrinter* printer;				// Printing
   181 
   182     bool mapDefault;				// Flag if map is untouched
   183     bool mapChanged;				// Flag if undo is possible
   184 	bool mapUnsaved;				// Flag if map should be saved
   185     QString backupXML;				// backup (XML) for undo
   186 	LinkableMapObj* undoSelection;	// replace this LMO with vympart from backup
   187 									// if != NULL
   188 
   189 	bool printFrame;			// Print frame around map
   190 	bool printFooter;			// Print footer below map
   191 
   192 	bool zipped;				// should map be zipped
   193 	QString fileName;			// short name of file (for tab)
   194 	QString filePath;			// path to file which will be saved
   195 	QString fileDir;			// dir where file is saved
   196 	QString destPath;			// path to .vym file (needed for vymlinks)
   197 	QString mapName;			// fileName without ".vym"
   198 	QString lastImageDir;		// save dir for adding images
   199 
   200 	bool isInteractive;			// non interactive don't need tmpdirs
   201 	QString bakMapDir;			// tmp directory with data for undo
   202 	bool blockreposition;		// block while load or undo
   203 
   204 	BranchObj* itFind;			// next object in find process
   205 	bool EOFind;				// true, if search failed
   206 
   207 	QPoint exportOffset;		// set before export, used in save
   208     void resizeEvent( QResizeEvent * );
   209 };
   210 #endif
   211