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