mapeditor.h
author insilmaril
Mon, 30 Oct 2006 12:39:37 +0000
changeset 396 445a5d5ee20b
parent 395 7ced3733ba60
child 398 d42881c25fb6
permissions -rw-r--r--
Spanish doc is found, if LANG is set. Fixed wrong position of floatimages
     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 getBackgroundColor();
    24     MapCenterObj* getMapCenter();
    25 	Q3Canvas* getCanvas();
    26 	void adjustCanvasSize();// adjust canvas size to map and scrollview
    27 	bool isRepositionBlocked(); // block while load or undo
    28 	
    29 private:
    30 	QString getName(LinkableMapObj*);	// Get e.g. heading or filename
    31 	void makeTmpDirs();		// create temporary directories
    32     QString saveToDir(const QString&,const QString &,bool, const QPoint &,LinkableMapObj*);
    33     void saveStateComplete       (const QString &);					
    34     void saveStateChangingPart (LinkableMapObj *, LinkableMapObj *, const QString &, const QString &);
    35     void saveStateRemovingPart (LinkableMapObj *, const QString &);
    36     void saveState(LinkableMapObj *, const QString &, LinkableMapObj *, const QString &, const QString &);
    37     void saveState(const QString &, const QString &, const QString &, const QString &, const QString &);
    38     void saveState(const SaveMode&, const QString &, const QString &, const QString &, const QString &, const QString &, LinkableMapObj *);
    39 public:	
    40     void parseAtom(const QString &);	
    41 private:
    42     void addFloatImageInt(const QPixmap &img);
    43 
    44   private slots:
    45     void fetchImage(const QString &img);
    46     void imageDataFetched(const QByteArray &, Q3NetworkOperation *);
    47     void imageDataFinished(Q3NetworkOperation *);
    48 
    49 public:
    50 	void toggleHistoryWindow();
    51 	bool isDefault();		// false, if map was changed once
    52     bool isUnsaved();		// save necessary
    53     bool hasChanged();		// undo possible
    54 	void setChanged();		// called from NoteEditor via LMO
    55 	void closeMap();
    56 	void setFilePath (QString);	
    57 	void setFilePath (QString,QString);	
    58 	QString getFilePath ();	// Full path e.g. "/home/tux/map.xml"
    59 	QString getFileName ();	// e.g. "map.xml"
    60 	QString getMapName ();	// e.g. "map"
    61 	QString getDestPath (); // e.g. "/home/tux/map.vym"
    62     ErrorCode load (QString, LoadMode );	// newmap, import/replace selection
    63 public:
    64     int save(const SaveMode &);	// Save map 
    65 	void setZipped(bool);		// save map zipped
    66 	bool saveZipped();			// 1 if file will be saved zipped
    67     void print();				// print canvas
    68 private:
    69     QPixmap getPixmap();
    70 	void setHideTmpMode (HideTmpMode);	// temporary hide stuff
    71 	HideTmpMode getHideTmpMode();		// temporary hide stuff
    72 public:
    73 	void setExportMode (bool);			// temporary hide stuff during export
    74     void exportImage (QString fn);			// export as PNG	
    75     void exportImage (QString fn, QString);	// export in given format
    76     void exportOOPresentation(const QString &,const QString &);
    77     void exportXML(const QString&);		// export to directory
    78     void clear();		// clear map
    79     void copy();		// copy branch to clipboard
    80     void redo();		// redo last action
    81 	bool isRedoAvailable();
    82     void undo();		// undo last action
    83 	bool isUndoAvailable();
    84 	void gotoStep (int);// goto a step in history
    85 private:	
    86     void addMapReplaceInt(const QString & undoSel, const QString & path);
    87     void addMapInsertInt (const QString & path, int pos);
    88     void pasteNoSave();		// paste clipboard to branch
    89     void cutNoSave();	// cut to clipboard
    90 public:	
    91     void paste();		// paste clipboard to branch and backup
    92     void cut();			// cut to clipboard and backup
    93     void move    (const int &x, const int &y);
    94     void moveRel (const int &x, const int &y);
    95     void moveBranchUp();
    96     void moveBranchDown();
    97 	QString getHeading (bool &ok,QPoint &p); // Get heading, ok if selection is branch
    98 	void setHeading(const QString &);
    99 private:
   100 	void setHeadingInt(const QString &);
   101 	void setURLInt(const QString &);		// Just set the URL for selection
   102 	void setVymLinkInt(const QString &);	// Set vymLink for selection
   103     BranchObj* addNewBranchInt(int);		// pos allows to add above/below selection
   104 public:	
   105     BranchObj* addNewBranch(int);			// pos allows to add above/below selection
   106     BranchObj* addNewBranchBefore();		// insert and make selection its
   107     void deleteSelection();
   108 	LinkableMapObj* getSelection();	// returns selection
   109 	void unselect();				// before changing current noteedit
   110 	void reselect();				// after  changing current noteedit
   111 	bool select(const QString &);	// Select by string
   112 	QString getSelectString();
   113 private:	
   114 	void selectInt(LinkableMapObj*);	
   115 	void selectNextBranchInt();		// Increment number of branch
   116 	void selectPrevBranchInt();		// Decrement number of branch
   117 public:	
   118     void selectUpperBranch();
   119     void selectLowerBranch();
   120     void selectLeftBranch();
   121     void selectRightBranch();
   122     void selectFirstBranch();
   123     void selectLastBranch();
   124     void selectBackgroundColor();
   125     void setBackgroundColor(QColor);
   126     QColor getCurrentHeadingColor();
   127     void colorItem(QColor);
   128     void colorBranch(QColor);
   129 	void toggleStandardFlag(QString);
   130 	virtual void setViewCenter();			// needed for zooming
   131     BranchObj* findText(QString,bool);		// Find object
   132     void findReset();						// Reset Find 
   133 	void setURL(const QString &);			// set the URL
   134 	void editURL();							// edit the URL
   135 	QString getURL();						// returns URL of selection or ""
   136 	QStringList getURLs();					// returns URLs of subtree
   137 	void editHeading2URL();					// copy heading to URL
   138 	void editBugzilla2URL();				// create URL to Bugzilla
   139 	void editFATE2URL();					// create URL to FATE
   140 	void editVymLink();						// edit link to another map
   141 	void deleteVymLink();					// delete link to another map
   142 	QString getVymLink();					// return path to map
   143 	QStringList getVymLinks();				// return paths in subtree
   144 	void setHideExport(bool);				// toggle the export flag
   145 	void toggleHideExport();				// toggle the export flag
   146 	void deleteKeepChilds();				// remove but keep childs
   147 	void deleteChilds();					// remove childs
   148 	void editMapInfo();						// dialog to enter author, ...
   149 	void updateActions();					// update e.g. format buttons
   150 	void updateNoteFlag();					// when TextEditor changes
   151 	void setLinkStyle (LinkStyle);			// Set style of link
   152 	LinkStyle getLinkStyle ();				// requested in LMO
   153 	void setLinkColor(QColor);				// default color of links
   154 	void setLinkColorHint();				// color of links
   155 	void setLinkColorHint(LinkColorHint);	// color of links
   156 	LinkColorHint getLinkColorHint();
   157 	QColor getDefLinkColor();
   158 	void setDefXLinkColor(QColor);
   159 	QColor getDefXLinkColor();
   160 	void setDefXLinkWidth (int);
   161 	int getDefXLinkWidth();
   162 	void toggleLinkColorHint();				// after changing linkStyles
   163     void selectLinkColor();
   164     void toggleScroll();
   165     void unScrollAll();
   166 	void loadFloatImage ();
   167 	void saveFloatImage ();
   168 	void setFrame(const FrameType &);
   169 	void setIncludeImagesVer(bool);
   170 	void setIncludeImagesHor(bool);
   171 	void setHideLinkUnselected (bool);
   172 	bool getHideLinkUnselected ();
   173 private:	
   174     void importDirInt(BranchObj *,QDir);
   175 public:	
   176     void importDir();
   177 	void followXLink (int);
   178 	void editXLink (int);
   179     void testFunction();					// just testing new stuff
   180 											// set /mainwindo/showTestMenu=true...
   181 
   182 protected:
   183 	void ensureSelectionVisible();		
   184 	virtual void updateViewCenter();	// needed for zooming
   185 	virtual void contentsContextMenuEvent ( QContextMenuEvent *e );
   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 	bool pickingColor;
   209 	bool drawingLink;			// true while creating a link
   210 	bool copyingObj;			// true while creating a link
   211 	XLinkObj* tmpXLink;
   212 
   213 	Selection xelection;
   214     LinkableMapObj* selection;		// select a LinkableMapObj
   215     LinkableMapObj* selectionLast;	// last selection 
   216     MapObj* movingObj;				// moving a MapObj
   217 	MapObj* linkingObj_src;			// part of a link
   218     QPoint movingObj_orgPos;		// org. pos of mouse before move
   219     QPoint movingObj_orgRelPos;		// org. relative pos of mouse before move
   220     QPoint movingObj_start;			// rel. pos of mouse to absPos 
   221     QPoint movingCont_start;		// inital pos of moving Content or
   222     QPoint movingVec;				// how far has Content moved
   223 	QPoint movingCenter;			// used when zooming
   224     QPrinter* printer;				// Printing
   225 
   226     bool mapDefault;				// Flag if map is untouched
   227     bool mapChanged;				// Flag if undo is possible
   228 	bool mapUnsaved;				// Flag if map should be saved
   229 
   230 	bool printFrame;			// Print frame around map
   231 	bool printFooter;			// Print footer below map
   232 
   233 	bool zipped;				// should map be zipped
   234 	static	int mapNum;			// unique number for Editor
   235 	QString fileName;			// short name of file (for tab)
   236 	QString filePath;			// path to file which will be saved
   237 	QString fileDir;			// dir where file is saved
   238 	QString destPath;			// path to .vym file (needed for vymlinks)
   239 	QString mapName;			// fileName without ".vym"
   240 
   241 	QString tmpMapDir;			// tmp directory with undo history
   242 	QString histPath;			// Path to history file
   243 	int stepsTotal;				// total number of steps (undos+redos) 
   244 	SimpleSettings undoSet;		// undo/redo commands
   245 	bool blockReposition;		// block while load or undo
   246 	bool blockSaveState;		// block while load or undo
   247 
   248 	BranchObj* itFind;			// next object in find process
   249 	bool EOFind;				// true, if search failed
   250 
   251 	QPoint exportOffset;		// set before export, used in save
   252 	HideTmpMode hidemode;			// true while exporting to hide some stuff
   253 	
   254     void resizeEvent( QResizeEvent * );
   255 
   256 	Q3UrlOperator *urlOperator;
   257 	QDataStream *imageData;
   258 	QBuffer *imageBuffer;
   259 
   260 	HistoryWindow historyWindow;
   261 
   262 };
   263 #endif
   264