mapeditor.h
author insilmaril
Sun Jan 30 23:25:48 2005 +0000 (2005-01-30)
changeset 84 0f2271678dea
parent 0 7a96bd401351
child 89 9db3eaa21237
permissions -rw-r--r--
1.6.1 optimized moving of branches, basic linking 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 enum ModifierMode {pickColorMode,linkObjectsMode};
    15 
    16 class MapEditor : public QCanvasView , public xmlObj {
    17     Q_OBJECT
    18 
    19 public:
    20     MapEditor(QWidget* parent=0, bool interactive=false, const char* name=0, WFlags f=0);
    21 	~MapEditor();
    22     QColor color();
    23     QColor backgroundColor();
    24     MapCenterObj* getMapCenter();
    25 	QCanvas* getCanvas();
    26 	void adjustCanvasSize();// adjust canvas size to map and scrollview
    27 	bool blockReposition(); // block while load or undo
    28 	
    29 private:
    30 	void makeTmpDirs();		// create temporary directories
    31 	void delTmpDirs();		// delete temporary directories
    32 	void makeSubDirs(const QString&);		
    33 							// create subdirs in dir
    34     QString saveToDir(const QString&,const QString &,bool, const QPoint
    35 	&,SaveMode);
    36     void saveState();		// save actual state to backup
    37     void saveState(const SaveMode&, LinkableMapObj *);
    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 undo();		// undo last action
    68     void copy();		// copy branch to clipboard
    69 private:	
    70     LinkableMapObj* pasteNoSave();		// paste clipboard to branch
    71     void cutNoSave();	// cut to clipboard
    72 public:	
    73     void paste();		// paste clipboard to branch and backup
    74     void cut();			// cut to clipboard and backup
    75     void moveBranchUp();
    76     void moveBranchDown();
    77     void editHeading();
    78     void addNewBranch(int);			// pos allows to add above/below selection
    79     void deleteSelection();
    80 	LinkableMapObj* getSelection();	// returns selection
    81 	LinkableMapObj* findObj (QString);
    82 	bool select(const QString &);	// Select 
    83 	void unselect();				// before changing current noteedit
    84 	void reselect();				// after  changing current noteedit
    85 private:	
    86 	void selectNextBranch();		// Increment number of branch
    87 	void selectPrevBranch();		// Decrement number of branch
    88 public:	
    89     void selectUpperBranch();
    90     void selectLowerBranch();
    91     void selectLeftBranch();
    92     void selectRightBranch();
    93     void selectFirstBranch();
    94     void selectLastBranch();
    95     void setColor(QColor);
    96     void selectBackgroundColor();
    97     void setBackgroundColor(QColor);
    98     QColor pickColor();
    99     void colorItem();
   100     void colorBranch();
   101 	void toggleStandardFlag(QString);
   102 	virtual void setViewCenter();			// needed for zooming
   103     BranchObj* findText(QString,bool);		// Find object
   104     void findReset();						// Reset Find 
   105 	void openURL();							// open URL in external browser
   106 	void editURL();							// edit the URL
   107 	void editHeading2URL();					// copy heading to URL
   108 	void editBugzilla2URL();				// create URL to Bugzilla
   109 	void editVymLink();						// edit link to another map
   110 	void deleteVymLink();					// delete link to another map
   111 	QString getVymLink();					// return path to map
   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 toggleLinkColorHint();				// after changing linkStyles
   122     void selectLinkColor();
   123     void toggleScroll();
   124     void unScrollAll();
   125 	void loadFloatImage ();
   126 	void saveFloatImage (int);
   127 	void toggleFloatExport();
   128 	void setFrame(const FrameType &);
   129 private:	
   130     void importDir(BranchObj *,QDir);
   131 public:	
   132     void importDir();
   133     void testFunction();				// FIXME just testing
   134 
   135 protected:
   136 	void ensureSelectionVisible();		
   137 	virtual void updateViewCenter();	// needed for zooming
   138 	virtual void contentsContextMenuEvent ( QContextMenuEvent *e );
   139     virtual void contentsMousePressEvent(QMouseEvent*);
   140     virtual void contentsMouseReleaseEvent(QMouseEvent*);
   141     virtual void contentsMouseDoubleClickEvent(QMouseEvent*);
   142     virtual void contentsMouseMoveEvent(QMouseEvent*);
   143 
   144 private:
   145     QCanvas* mapCanvas;
   146     MapCenterObj* mapCenter;
   147 
   148 	bool adjustCanvasRequested;	// collect requests until end of user event
   149 	BranchObj *editingBO;		// entering Text into BO
   150     QLineEdit* lineedit;
   151 
   152     QColor actColor;			// actual color
   153 	QColor deflinkcolor;		// default color for links
   154 	LinkColorHint linkcolorhint;// use heading color or own color
   155 	LinkStyle linkstyle;		// default style for links
   156 
   157 	ModifierMode modifierMode;	// pick color or link objects?
   158 
   159     QCursor handOpenCursor;		// cursor while moving canvas view
   160 	QCursor pickColorCursor;	// cursor while picking color 
   161 	bool pickingColor;
   162 	bool drawingLink;			// true while creating a link
   163 	LinkObj* tmpLink;
   164 	
   165     LinkableMapObj* selection;		// select a LinkableMapObj
   166     LinkableMapObj* selectionLast;	// last selection 
   167     MapObj* movingObj;				// moving a MapObj
   168 	MapObj* linkingObj_src;			// part of a link
   169     QPoint movingObj_start;			// rel. pos of mouse to absPos 
   170     QPoint movingCont_start;		// inital pos of moving Content or
   171     QPoint movingVec;				// how far has Content moved
   172 	QPoint movingCenter;			// used when zooming
   173     QPrinter* printer;				// Printing
   174 
   175     bool mapDefault;				// Flag if map is untouched
   176     bool mapChanged;				// Flag if undo is possible
   177 	bool mapUnsaved;				// Flag if map should be saved
   178     QString backupXML;				// backup (XML) for undo
   179 	LinkableMapObj* undoSelection;	// replace this LMO with vympart from backup
   180 									// if != NULL
   181 
   182 	bool printFrame;			// Print frame around map
   183 	bool printFooter;			// Print footer below map
   184 
   185 	bool zipped;				// should map be zipped
   186 	QString fileName;			// short name of file (for tab)
   187 	QString filePath;			// path to file which will be saved
   188 	QString fileDir;			// dir where file is saved
   189 	QString destPath;			// path to .vym file (needed for vymlinks)
   190 	QString mapName;			// fileName without ".vym"
   191 	QString lastImageDir;		// save dir for adding images
   192 
   193 	bool isInteractive;			// non interactive don't need tmpdirs
   194 	QString bakMapDir;			// tmp directory with data for undo
   195 	bool blockreposition;		// block while load or undo
   196 
   197 	BranchObj* itFind;			// next object in find process
   198 	bool EOFind;				// true, if search failed
   199 
   200 	QPoint exportOffset;		// set before export, used in save
   201     void resizeEvent( QResizeEvent * );
   202 };
   203 #endif
   204