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