mapeditor.h
author insilmaril
Tue, 24 Oct 2006 15:36:38 +0000
changeset 394 67cfa6e6b863
parent 393 053b8645e3e9
child 395 7ced3733ba60
permissions -rw-r--r--
1.8.58 - More undoCommands, spanish translation of doc
     1 #ifndef MAPEDITOR_H
     2 #define MAPEDITOR_H
     3 
     4 #include <q3canvas.h>
     5 #include <QBuffer>
     6 
     7 #include "mapcenterobj.h"
     8 #include "file.h"
     9 #include "historywindow.h"
    10 #include "misc.h"
    11 #include "selection.h"
    12 #include "settings.h"
    13 
    14 class Q3NetworkOperation;
    15 class Q3UrlOperator;
    16 
    17 class MapEditor : public Q3CanvasView , public xmlObj {
    18     Q_OBJECT
    19 
    20 public:
    21     MapEditor(QWidget* parent=0,  const char* name=0, Qt::WFlags f=0);
    22 	~MapEditor();
    23     QColor getColor();
    24     QColor getBackgroundColor();
    25     MapCenterObj* getMapCenter();
    26 	Q3Canvas* getCanvas();
    27 	void adjustCanvasSize();// adjust canvas size to map and scrollview
    28 	bool isRepositionBlocked(); // block while load or undo
    29 	
    30 private:
    31 	QString getName(LinkableMapObj*);	// Get e.g. heading or filename
    32 	void makeTmpDirs();		// create temporary directories
    33     QString saveToDir(const QString&,const QString &,bool, const QPoint &,LinkableMapObj*);
    34     void saveStateComplete       (const QString &);					
    35     void saveStateChangingPart (LinkableMapObj *, const QString &);
    36     void saveStateRemovingPart (LinkableMapObj *, const QString &);
    37     void saveStateConstSelection (const QString &, const QString &, const QString &);
    38     void saveState(LinkableMapObj *, const QString &, LinkableMapObj *, const QString &, const QString &);
    39     void saveState(const QString &, const QString &, const QString &, const QString &, const QString &);
    40     void saveState(const SaveMode&, const QString &, const QString &, const QString &, const QString &, const QString &, LinkableMapObj *);
    41 public:	
    42     void parseAtom(const QString &);	
    43 private:
    44     void addFloatImage(const QPixmap &img);
    45 
    46   private slots:
    47     void fetchImage(const QString &img);
    48     void imageDataFetched(const QByteArray &, Q3NetworkOperation *);
    49     void imageDataFinished(Q3NetworkOperation *);
    50 
    51 public:
    52 	void toggleHistoryWindow();
    53 	bool isDefault();		// false, if map was changed once
    54     bool isUnsaved();		// save necessary
    55     bool hasChanged();		// undo possible
    56 	void setChanged();		// called from NoteEditor via LMO
    57 	void closeMap();
    58 	void setFilePath (QString);	
    59 	void setFilePath (QString,QString);	
    60 	QString getFilePath ();	// Full path e.g. "/home/tux/map.xml"
    61 	QString getFileName ();	// e.g. "map.xml"
    62 	QString getMapName ();	// e.g. "map"
    63 	QString getDestPath (); // e.g. "/home/tux/map.vym"
    64     ErrorCode load (QString, LoadMode );	// newmap, import/replace selection
    65 public:
    66     int save(const SaveMode &);	// Save map 
    67 	void setZipped(bool);		// save map zipped
    68 	bool saveZipped();			// 1 if file will be saved zipped
    69     void print();				// print canvas
    70 private:
    71     QPixmap getPixmap();
    72 	void setHideTmpMode (HideTmpMode);	// temporary hide stuff
    73 	HideTmpMode getHideTmpMode();		// temporary hide stuff
    74 public:
    75 	void setExportMode (bool);			// temporary hide stuff during export
    76     void exportImage (QString fn);			// export as PNG	
    77     void exportImage (QString fn, QString);	// export in given format
    78     void exportOOPresentation(const QString &,const QString &);
    79     void exportXML(const QString&);		// export to directory
    80     void clear();		// clear map
    81     void copy();		// copy branch to clipboard
    82     void redo();		// redo last action
    83 	bool isRedoAvailable();
    84     void undo();		// undo last action
    85 	bool isUndoAvailable();
    86 	void gotoStep (int);// goto a step in history
    87 private:	
    88     void addMapReplaceInt(const QString & undoSel, const QString & path);
    89     void addMapInsertInt (const QString & path, int pos);
    90     void pasteNoSave();		// paste clipboard to branch
    91     void cutNoSave();	// cut to clipboard
    92 public:	
    93     void paste();		// paste clipboard to branch and backup
    94     void cut();			// cut to clipboard and backup
    95     void move    (const int &x, const int &y);
    96     void moveRel (const int &x, const int &y);
    97     void moveBranchUp();
    98     void moveBranchDown();
    99 	QString getHeading (bool &ok,QPoint &p); // Get heading, ok if selection is branch
   100 	void setHeading(const QString &);
   101 private:
   102 	void setHeadingInt(const QString &);
   103 	void setURLInt(const QString &);		// Just set the URL for selection
   104 	void setVymLinkInt(const QString &);	// Set vymLink for selection
   105     BranchObj* addNewBranchInt(int);		// pos allows to add above/below selection
   106 public:	
   107     BranchObj* addNewBranch(int);			// pos allows to add above/below selection
   108     BranchObj* addNewBranchBefore();		// insert and make selection its
   109     void deleteSelection();
   110 	LinkableMapObj* getSelection();	// returns selection
   111 	void unselect();				// before changing current noteedit
   112 	void reselect();				// after  changing current noteedit
   113 	bool select(const QString &);	// Select by string
   114 	QString getSelectString();
   115 private:	
   116 	void selectInt(LinkableMapObj*);	
   117 	void selectNextBranchInt();		// Increment number of branch
   118 	void selectPrevBranchInt();		// Decrement number of branch
   119 public:	
   120     void selectUpperBranch();
   121     void selectLowerBranch();
   122     void selectLeftBranch();
   123     void selectRightBranch();
   124     void selectFirstBranch();
   125     void selectLastBranch();
   126     void setColor(QColor);
   127     void selectBackgroundColor();
   128     void setBackgroundColor(QColor);
   129     QColor pickColor();
   130     void colorItem();
   131     void colorBranch();
   132 	void toggleStandardFlag(QString);
   133 	virtual void setViewCenter();			// needed for zooming
   134     BranchObj* findText(QString,bool);		// Find object
   135     void findReset();						// Reset Find 
   136 	void editURL();							// edit the URL
   137 	QString getURL();						// returns URL of selection or ""
   138 	QStringList getURLs();					// returns URLs of subtree
   139 	void editHeading2URL();					// copy heading to URL
   140 	void editBugzilla2URL();				// create URL to Bugzilla
   141 	void editFATE2URL();					// create URL to FATE
   142 	void editVymLink();						// edit link to another map
   143 	void deleteVymLink();					// delete link to another map
   144 	QString getVymLink();					// return path to map
   145 	QStringList getVymLinks();				// return paths in subtree
   146 	void toggleHideExport();				// toggle the export flag
   147 	void removeBranchKeepChilds();			// remove but keep childs
   148 	void removeChilds();					// remove childs
   149 	void editMapInfo();						// dialog to enter author, ...
   150 	void updateActions();					// update e.g. format buttons
   151 	void updateNoteFlag();					// when TextEditor changes
   152 	void setLinkStyle (LinkStyle);			// Set style of link
   153 	LinkStyle getLinkStyle ();				// requested in LMO
   154 	void setLinkColor(QColor);				// default color of links
   155 	void setLinkColorHint();				// color of links
   156 	void setLinkColorHint(LinkColorHint);	// color of links
   157 	LinkColorHint getLinkColorHint();
   158 	QColor getDefLinkColor();
   159 	void setDefXLinkColor(QColor);
   160 	QColor getDefXLinkColor();
   161 	void setDefXLinkWidth (int);
   162 	int getDefXLinkWidth();
   163 	void toggleLinkColorHint();				// after changing linkStyles
   164     void selectLinkColor();
   165     void toggleScroll();
   166     void unScrollAll();
   167 	void loadFloatImage ();
   168 	void saveFloatImage ();
   169 	void setFrame(const FrameType &);
   170 	void setIncludeImagesVer(bool);
   171 	void setIncludeImagesHor(bool);
   172 	void setHideLinkUnselected (bool);
   173 	bool getHideLinkUnselected ();
   174 private:	
   175     void importDirInt(BranchObj *,QDir);
   176 public:	
   177     void importDir();
   178 	void followXLink (int);
   179 	void editXLink (int);
   180     void testFunction();					// just testing new stuff
   181 											// set /mainwindo/showTestMenu=true...
   182 
   183 protected:
   184 	void ensureSelectionVisible();		
   185 	virtual void updateViewCenter();	// needed for zooming
   186 	virtual void contentsContextMenuEvent ( QContextMenuEvent *e );
   187     virtual void contentsMousePressEvent(QMouseEvent*);
   188     virtual void contentsMouseReleaseEvent(QMouseEvent*);
   189     virtual void contentsMouseDoubleClickEvent(QMouseEvent*);
   190     virtual void contentsMouseMoveEvent(QMouseEvent*);
   191 
   192     virtual void contentsDragEnterEvent(QDragEnterEvent *event);
   193     virtual void contentsDropEvent(QDropEvent *event);
   194 private:
   195     Q3Canvas* mapCanvas;
   196     MapCenterObj* mapCenter;
   197 
   198 	bool adjustCanvasRequested;	// collect requests until end of user event
   199 	BranchObj *editingBO;		// entering Text into BO
   200 
   201     QColor actColor;			// actual color
   202 	QColor defLinkColor;		// default color for links
   203 	QColor defXLinkColor;		// default color for xlinks
   204 	int defXLinkWidth;			// default width for xlinks
   205 	LinkColorHint linkcolorhint;// use heading color or own color
   206 	LinkStyle linkstyle;		// default style for links
   207 
   208     QCursor handOpenCursor;		// cursor while moving canvas view
   209 	QCursor pickColorCursor;	// cursor while picking color 
   210 	bool pickingColor;
   211 	bool drawingLink;			// true while creating a link
   212 	bool copyingObj;			// true while creating a link
   213 	XLinkObj* tmpXLink;
   214 
   215 	Selection xelection;
   216     LinkableMapObj* selection;		// select a LinkableMapObj
   217     LinkableMapObj* selectionLast;	// last selection 
   218     MapObj* movingObj;				// moving a MapObj
   219 	MapObj* linkingObj_src;			// part of a link
   220     QPoint movingObj_orgPos;		// org. pos of mouse before move
   221     QPoint movingObj_orgRelPos;		// org. relative pos of mouse before move
   222     QPoint movingObj_start;			// rel. pos of mouse to absPos 
   223     QPoint movingCont_start;		// inital pos of moving Content or
   224     QPoint movingVec;				// how far has Content moved
   225 	QPoint movingCenter;			// used when zooming
   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 	Q3UrlOperator *urlOperator;
   259 	QDataStream *imageData;
   260 	QBuffer *imageBuffer;
   261 
   262 	HistoryWindow historyWindow;
   263 
   264 };
   265 #endif
   266