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