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