mapeditor.h
author insilmaril
Tue, 15 Aug 2006 12:01:14 +0000
branchqt4-port
changeset 15 699f28529079
parent 11 b8c547f0fc58
child 16 41c3d7f9f532
permissions -rw-r--r--
removed unneeded toolbars.*
     1 #ifndef MAPEDITOR_H
     2 #define MAPEDITOR_H
     3 
     4 #include <q3canvas.h>
     5 #include <qlineedit.h>
     6 #include <qcursor.h>
     7 #include <q3filedialog.h>
     8 #include <qevent.h>
     9 #include <q3process.h>
    10 #include <qbuffer.h>
    11 //Added by qt3to4:
    12 #include <QContextMenuEvent>
    13 #include <QDropEvent>
    14 #include <QResizeEvent>
    15 #include <QPixmap>
    16 #include <QMouseEvent>
    17 #include <QDragEnterEvent>
    18 
    19 #include "mapcenterobj.h"
    20 #include "file.h"
    21 #include "misc.h"
    22 #include "showtextdialog.h"
    23 
    24 class Q3NetworkOperation;
    25 class Q3UrlOperator;
    26 
    27 class MapEditor : public Q3CanvasView , public xmlObj {
    28     Q_OBJECT
    29 
    30 public:
    31     MapEditor(QWidget* parent=0, bool interactive=false, const char* name=0, Qt::WFlags f=0);
    32 	~MapEditor();
    33     QColor color();
    34     QColor backgroundColor();
    35     MapCenterObj* getMapCenter();
    36 	Q3Canvas* getCanvas();
    37 	void adjustCanvasSize();// adjust canvas size to map and scrollview
    38 	bool isRepositionBlocked(); // block while load or undo
    39 	
    40 private:
    41 	QString getName(LinkableMapObj*);	// Get e.g. heading or filename
    42 	void makeTmpDirs();		// create temporary directories
    43     QString saveToDir(const QString&,const QString &,bool, const QPoint &,LinkableMapObj*);
    44     void saveState(const QString &);	// save actual state to backup
    45     void saveState(LinkableMapObj *, const QString &);
    46     void saveState(const QString &, const QString &, const QString &);
    47     void saveState(const QString &, LinkableMapObj *, const QString &);
    48     void saveState(const SaveMode&, const QString &, LinkableMapObj *, const QString &, LinkableMapObj *, const QString &);
    49     void parseAtom(const QString &);	
    50 
    51     void addFloatImage(const QPixmap &img);
    52 
    53   private slots:
    54     void finishedLineEdit();
    55     void fetchImage(const QString &img);
    56     void imageDataFetched(const QByteArray &, Q3NetworkOperation *);
    57     void imageDataFinished(Q3NetworkOperation *);
    58 
    59 public:
    60 	void toggleHistoryWindow();
    61 	bool isDefault();		// false, if map was changed once
    62     bool isUnsaved();		// save necessary
    63     bool hasChanged();		// undo possible
    64 	void setChanged();		// called from NoteEditor via LMO
    65 	void closeMap();
    66 	void setFilePath (QString);	
    67 	void setFilePath (QString,QString);	
    68 	QString getFilePath ();	// Full path e.g. "/home/tux/map.xml"
    69 	QString getFileName ();	// e.g. "map.xml"
    70 	QString getMapName ();	// e.g. "map"
    71 	QString getDestPath (); // e.g. "/home/tux/map.vym"
    72     ErrorCode load (QString, LoadMode );	// newmap, import/replace selection
    73 public:
    74     int save(const SaveMode &);	// Save map 
    75 	void setZipped(bool);		// save map zipped
    76 	bool saveZipped();			// 1 if file will be saved zipped
    77     void print();				// print canvas
    78 private:
    79     QPixmap getPixmap();
    80 	void setHideTmpMode (HideTmpMode);	// temporary hide stuff
    81 	HideTmpMode getHideTmpMode();		// temporary hide stuff
    82 public:
    83 	void setExportMode (bool);			// temporary hide stuff during export
    84     void exportImage (QString fn);			// export as PNG	
    85     void exportImage (QString fn, QString);	// export in given format
    86     void exportOOPresentation(const QString &,const QString &);
    87     void exportXML(const QString&);		// export to directory
    88     void clear();		// clear map
    89     void copy();		// copy branch to clipboard
    90     void redo();		// redo last action
    91     void undo();		// undo last action
    92 private:	
    93     void undoXML(const QString &, const QString &);
    94     void pasteNoSave();		// paste clipboard to branch
    95     void cutNoSave();	// cut to clipboard
    96 public:	
    97     void paste();		// paste clipboard to branch and backup
    98     void cut();			// cut to clipboard and backup
    99     void move(const int &,const int&);
   100     void moveBranchUp();
   101     void moveBranchDown();
   102     void editHeading();					// Start editing heading 
   103 private:
   104 	void setHeading(const QString &);	// Just set the heading for selection
   105 	void setURL(const QString &);		// Just set the URL for selection
   106 	void setVymLink(const QString &);	// Set vymLink for selection
   107 public:	
   108     void addNewBranch(int);			// pos allows to add above/below selection
   109     void addNewBranchHere();		// insert and make selection its
   110     void deleteSelection();
   111 	LinkableMapObj* getSelection();	// returns selection
   112 	void unselect();				// before changing current noteedit
   113 	void reselect();				// after  changing current noteedit
   114 	bool select(const QString &);	// Select 
   115 private:	
   116 	void select(LinkableMapObj*);	
   117 	void selectNextBranch();		// Increment number of branch
   118 	void selectPrevBranch();		// 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 	void editHeading2URL();					// copy heading to URL
   139 	void editBugzilla2URL();				// create URL to Bugzilla
   140 	void editFATE2URL();					// create URL to FATE
   141 	void editVymLink();						// edit link to another map
   142 	void deleteVymLink();					// delete link to another map
   143 	QString getVymLink();					// return path to map
   144 	void toggleHideExport();				// toggle the export flag
   145 	void removeBranchKeepChilds();			// remove but keep childs
   146 	void removeChilds();					// remove childs
   147 	void editMapInfo();						// dialog to enter author, ...
   148 	void updateActions();					// update e.g. format buttons
   149 	void updateNoteFlag();					// when TextEditor changes
   150 	void setLinkStyle (LinkStyle);			// Set style of link
   151 	LinkStyle getLinkStyle ();				// requested in LMO
   152 	void setLinkColor(QColor);				// default color of links
   153 	void setLinkColorHint();				// color of links
   154 	void setLinkColorHint(LinkColorHint);	// color of links
   155 	LinkColorHint getLinkColorHint();
   156 	QColor getDefLinkColor();
   157 	void setDefXLinkColor(QColor);
   158 	QColor getDefXLinkColor();
   159 	void setDefXLinkWidth (int);
   160 	int getDefXLinkWidth();
   161 	void toggleLinkColorHint();				// after changing linkStyles
   162     void selectLinkColor();
   163     void toggleScroll();
   164     void unScrollAll();
   165 	void loadFloatImage ();
   166 	void saveFloatImage ();
   167 	void setFrame(const FrameType &);
   168 	void setIncludeImagesVer(bool);
   169 	void setIncludeImagesHor(bool);
   170 	void setHideLinkUnselected (bool);
   171 	bool getHideLinkUnselected ();
   172 private:	
   173     void importDir(BranchObj *,QDir);
   174 public:	
   175     void importDir();
   176 	void followXLink (int);
   177 	void editXLink (int);
   178     void testFunction();				// FIXME just testing
   179 
   180 protected:
   181 	void ensureSelectionVisible();		
   182 	virtual void updateViewCenter();	// needed for zooming
   183 	virtual void contentsContextMenuEvent ( QContextMenuEvent *e );
   184     virtual void contentsMousePressEvent(QMouseEvent*);
   185     virtual void contentsMouseReleaseEvent(QMouseEvent*);
   186     virtual void contentsMouseDoubleClickEvent(QMouseEvent*);
   187     virtual void contentsMouseMoveEvent(QMouseEvent*);
   188 
   189     virtual void contentsDragEnterEvent(QDragEnterEvent *event);
   190     virtual void contentsDropEvent(QDropEvent *event);
   191 private:
   192     Q3Canvas* mapCanvas;
   193     MapCenterObj* mapCenter;
   194 
   195 	bool adjustCanvasRequested;	// collect requests until end of user event
   196 	BranchObj *editingBO;		// entering Text into BO
   197     QLineEdit* lineedit;
   198 
   199     QColor actColor;			// actual color
   200 	QColor defLinkColor;		// default color for links
   201 	QColor defXLinkColor;		// default color for xlinks
   202 	int defXLinkWidth;			// default width for xlinks
   203 	LinkColorHint linkcolorhint;// use heading color or own color
   204 	LinkStyle linkstyle;		// default style for links
   205 
   206     QCursor handOpenCursor;		// cursor while moving canvas view
   207 	QCursor pickColorCursor;	// cursor while picking color 
   208 	bool pickingColor;
   209 	bool drawingLink;			// true while creating a link
   210 	bool copyingObj;			// true while creating a link
   211 	XLinkObj* tmpXLink;
   212 	
   213     LinkableMapObj* selection;		// select a LinkableMapObj
   214     LinkableMapObj* selectionLast;	// last selection 
   215     MapObj* movingObj;				// moving a MapObj
   216 	MapObj* linkingObj_src;			// part of a link
   217     QPoint movingObj_orgPos;		// org. pos of mouse before move
   218     QPoint movingObj_start;			// rel. pos of mouse to absPos 
   219     QPoint movingCont_start;		// inital pos of moving Content or
   220     QPoint movingVec;				// how far has Content moved
   221 	QPoint movingCenter;			// used when zooming
   222     QPrinter* printer;				// Printing
   223 
   224     bool mapDefault;				// Flag if map is untouched
   225     bool mapChanged;				// Flag if undo is possible
   226 	bool mapUnsaved;				// Flag if map should be saved
   227 
   228 	bool printFrame;			// Print frame around map
   229 	bool printFooter;			// Print footer below map
   230 
   231 	bool zipped;				// should map be zipped
   232 static	int mapNum;				// unique number for Editor
   233 	QString fileName;			// short name of file (for tab)
   234 	QString filePath;			// path to file which will be saved
   235 	QString fileDir;			// dir where file is saved
   236 	QString destPath;			// path to .vym file (needed for vymlinks)
   237 	QString mapName;			// fileName without ".vym"
   238 
   239 	bool isInteractive;			// non interactive don't need tmpdirs
   240 	QString tmpMapDir;			// tmp directory with data for undo/redo
   241 	int undosTotal;				// total number of undos 
   242 	int undoNum;				// current number of bakMapDir to be used 
   243 	int undosAvail;				// how many actions can currently be undone
   244 	bool blockReposition;		// block while load or undo
   245 	bool blockSaveState;		// block while load or undo
   246 
   247 	BranchObj* itFind;			// next object in find process
   248 	bool EOFind;				// true, if search failed
   249 
   250 	QPoint exportOffset;		// set before export, used in save
   251 	HideTmpMode hidemode;			// true while exporting to hide some stuff
   252 	
   253     void resizeEvent( QResizeEvent * );
   254 
   255   Q3UrlOperator *urlOperator;
   256   QDataStream *imageData;
   257   QBuffer *imageBuffer;
   258 
   259 	ShowTextDialog *historyWindow;
   260 
   261 };
   262 #endif
   263