mapeditor.h
author insilmaril
Thu, 23 Nov 2006 16:18:26 +0000
changeset 407 5db8dfd30ea2
parent 406 1c8ff1928b97
child 408 c2a05fa925a1
permissions -rw-r--r--
Removed even more QT3 stuff. Drag & Drop not 100% functional at the moment
     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 "misc.h"
    10 #include "selection.h"
    11 #include "settings.h"
    12 
    13 
    14 class MapEditor : public Q3CanvasView , public xmlObj {
    15     Q_OBJECT
    16 
    17 public:
    18     MapEditor(QWidget* parent=0,  const char* name=0, Qt::WFlags f=0);
    19 	~MapEditor();
    20     MapCenterObj* getMapCenter();
    21 	Q3Canvas* getCanvas();
    22 	void adjustCanvasSize();// adjust canvas size to map and scrollview
    23 	bool isRepositionBlocked(); // block while load or undo
    24 	
    25 private:
    26 	QString getName(LinkableMapObj*);	// Get e.g. heading or filename
    27 	void makeTmpDirs();		// create temporary directories
    28     QString saveToDir(const QString&,const QString &,bool, const QPoint &,LinkableMapObj*);
    29     void saveStateChangingPart (LinkableMapObj *, LinkableMapObj *, const QString &, const QString &);
    30     void saveStateRemovingPart (LinkableMapObj *, const QString &);
    31     void saveState(LinkableMapObj *, const QString &, LinkableMapObj *, const QString &, const QString &);
    32     void saveState(const QString &, const QString &, const QString &, const QString &, const QString &);
    33     void saveState(const SaveMode&, const QString &, const QString &, const QString &, const QString &, const QString &, LinkableMapObj *);
    34 public:	
    35     void parseAtom(const QString &);	
    36 private:
    37     void addFloatImageInt(const QPixmap &img);
    38 
    39   private slots:
    40 //FIXME not needed QT4    void fetchImage(const QString &img);
    41 //FIXME not needed QT4    void imageDataFetched(const QByteArray &, Q3NetworkOperation *);
    42 //FIXME not needed QT4    void imageDataFinished(Q3NetworkOperation *);
    43 
    44 public:
    45 	void toggleHistoryWindow();
    46 	bool isDefault();		// false, if map was changed once
    47     bool isUnsaved();		// save necessary
    48     bool hasChanged();		// undo possible
    49 	void setChanged();		// called from NoteEditor via LMO
    50 	void closeMap();
    51 	void setFilePath (QString);	
    52 	void setFilePath (QString,QString);	
    53 	QString getFilePath ();	// Full path e.g. "/home/tux/map.xml"
    54 	QString getFileName ();	// e.g. "map.xml"
    55 	QString getMapName ();	// e.g. "map"
    56 	QString getDestPath (); // e.g. "/home/tux/map.vym"
    57     ErrorCode load (QString, LoadMode );	// newmap, import/replace selection
    58 public:
    59     int save(const SaveMode &);	// Save map 
    60 	void setZipped(bool);		// save map zipped
    61 	bool saveZipped();			// 1 if file will be saved zipped
    62     void print();				// print canvas
    63 private:
    64     QPixmap getPixmap();
    65 	void setHideTmpMode (HideTmpMode);	// temporary hide stuff
    66 	HideTmpMode getHideTmpMode();		// temporary hide stuff
    67 public:
    68 	void setExportMode (bool);			// temporary hide stuff during export
    69     void exportImage (QString fn);			// export as PNG	
    70     void exportImage (QString fn, QString);	// export in given format
    71     void exportOOPresentation(const QString &,const QString &);
    72     void exportXML(const QString&);		// export to directory
    73     void clear();		// clear map
    74     void copy();		// copy branch to clipboard
    75     void redo();		// redo last action
    76 	bool isRedoAvailable();
    77     void undo();		// undo last action
    78 	bool isUndoAvailable();
    79 	void gotoHistoryStep (int);// goto a step in history
    80 private:	
    81     void addMapReplaceInt(const QString & undoSel, const QString & path);
    82     void addMapInsertInt (const QString & path, int pos);
    83     void pasteNoSave();		// paste clipboard to branch
    84     void cutNoSave();	// cut to clipboard
    85 public:	
    86     void paste();		// paste clipboard to branch and backup
    87     void cut();			// cut to clipboard and backup
    88     void move    (const int &x, const int &y);
    89     void moveRel (const int &x, const int &y);
    90     void moveBranchUp();
    91     void moveBranchDown();
    92 	QString getHeading (bool &ok,QPoint &p); // Get heading, ok if selection is branch
    93 	void setHeading(const QString &);
    94 private:
    95 	void setHeadingInt(const QString &);
    96 	void setURLInt(const QString &);		// Just set the URL for selection
    97 	void setVymLinkInt(const QString &);	// Set vymLink for selection
    98     BranchObj* addNewBranchInt(int);		// pos allows to add above/below selection
    99 public:	
   100     BranchObj* addNewBranch(int);			// pos allows to add above/below selection
   101     BranchObj* addNewBranchBefore();		// insert and make selection its
   102     void deleteSelection();
   103 	LinkableMapObj* getSelection();	// returns selection
   104 	void unselect();				// before changing current noteedit
   105 	void reselect();				// after  changing current noteedit
   106 	bool select(const QString &);	// Select by string
   107 	QString getSelectString();
   108 private:	
   109 	void selectInt(LinkableMapObj*);	
   110 	void selectNextBranchInt();		// Increment number of branch
   111 	void selectPrevBranchInt();		// Decrement number of branch
   112 public:	
   113     void selectUpperBranch();
   114     void selectLowerBranch();
   115     void selectLeftBranch();
   116     void selectRightBranch();
   117     void selectFirstBranch();
   118     void selectLastBranch();
   119     void selectMapBackgroundColor();
   120     void setMapBackgroundColor(QColor);
   121     QColor getMapBackgroundColor();
   122     QColor getCurrentHeadingColor();
   123     void colorItem(QColor);
   124     void colorBranch(QColor);
   125 	void toggleStandardFlag(QString);
   126 	virtual void setViewCenter();			// needed for zooming
   127     BranchObj* findText(QString,bool);		// Find object
   128     void findReset();						// Reset Find 
   129 	void setURL(const QString &);			// set the URL
   130 	void editURL();							// edit the URL
   131 	QString getURL();						// returns URL of selection or ""
   132 	QStringList getURLs();					// returns URLs of subtree
   133 	void editHeading2URL();					// copy heading to URL
   134 	void editBugzilla2URL();				// create URL to Bugzilla
   135 	void editFATE2URL();					// create URL to FATE
   136 	void editVymLink();						// edit link to another map
   137 	void deleteVymLink();					// delete link to another map
   138 	QString getVymLink();					// return path to map
   139 	QStringList getVymLinks();				// return paths in subtree
   140 	void setHideExport(bool);				// toggle the export flag
   141 	void toggleHideExport();				// toggle the export flag
   142 	void deleteKeepChilds();				// remove but keep childs
   143 	void deleteChilds();					// remove childs
   144 	void editMapInfo();						// dialog to enter author, ...
   145 	void updateActions();					// update e.g. format buttons
   146 	void updateNoteFlag();					// when TextEditor changes
   147 	void setMapAuthor (const QString &);
   148 	void setMapComment(const QString &);
   149 	void setMapLinkStyle (const QString &);	// Set style of link
   150 	LinkStyle getMapLinkStyle ();			// requested in LMO
   151 	void setMapDefLinkColor(QColor);		// default color of links
   152 	void setMapLinkColorHintInt();			// color of links
   153 	void setMapLinkColorHint(LinkColorHint);// color of links
   154 	LinkColorHint getMapLinkColorHint();
   155 	QColor getMapDefLinkColor();
   156 	void setMapDefXLinkColor(QColor);
   157 	QColor getMapDefXLinkColor();
   158 	void setMapDefXLinkWidth (int);
   159 	int getMapDefXLinkWidth();
   160 	void toggleMapLinkColorHint();			// after changing linkStyles
   161     void selectMapLinkColor();
   162     void toggleScroll();
   163     void unScrollAll();
   164 	void loadFloatImage ();
   165 	void saveFloatImage ();
   166 	void setFrame(const FrameType &);
   167 	void setIncludeImagesVer(bool);
   168 	void setIncludeImagesHor(bool);
   169 	void setHideLinkUnselected (bool);
   170 	bool getHideLinkUnselected ();
   171 private:	
   172     void importDirInt(BranchObj *,QDir);
   173 public:	
   174     void importDir();
   175 	void followXLink (int);
   176 	void editXLink (int);
   177     void testFunction();					// just testing new stuff
   178 											// set /mainwindo/showTestMenu=true...
   179 
   180 protected:
   181 	void ensureSelectionVisible();		
   182 	virtual void updateViewCenter();	// needed for zooming
   183 	virtual void contentsContextMenuEvent ( QContextMenuEvent *e );
   184     virtual void keyPressEvent(QKeyEvent*);
   185     virtual void keyReleaseEvent(QKeyEvent*);
   186     virtual void contentsMousePressEvent(QMouseEvent*);
   187     virtual void contentsMouseReleaseEvent(QMouseEvent*);
   188     virtual void contentsMouseDoubleClickEvent(QMouseEvent*);
   189     virtual void contentsMouseMoveEvent(QMouseEvent*);
   190 
   191 	virtual void contentsDragEnterEvent(QDragEnterEvent *event);
   192     virtual void contentsDropEvent(QDropEvent *event);
   193 private:
   194     Q3Canvas* mapCanvas;
   195     MapCenterObj* mapCenter;
   196 
   197 	bool adjustCanvasRequested;	// collect requests until end of user event
   198 	BranchObj *editingBO;		// entering Text into BO
   199 
   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 	QCursor CopyCursor;			// cursor while picking color 
   209 	QCursor XLinkCursor;		// 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 #endif
   263