mapeditor.h
author insilmaril
Mon Sep 05 16:48:10 2005 +0000 (2005-09-05)
changeset 161 88efbd21cff1
parent 143 56c57552f1d2
child 163 30b22f7bd009
permissions -rw-r--r--
copied vym-48x48.png to vym.png
     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 	void makeSubDirs(const QString&);		
    35 							// create subdirs in dir
    36     QString saveToDir(const QString&,const QString &,bool, const QPoint &,LinkableMapObj*);
    37     void saveState();		// save actual state to backup
    38     void saveState(LinkableMapObj *);
    39     void saveState(const QString &, const QString &);
    40     void saveState(const SaveMode&, LinkableMapObj *, const QString &, const QString &);
    41     void parseAtom(const QString &);	
    42 
    43     void addFloatImage(const QPixmap &img);
    44 
    45   private slots:
    46     void finishedLineEditNoSave();
    47     void fetchImage(const QString &img);
    48     void imageDataFetched(const QByteArray &, QNetworkOperation *);
    49     void imageDataFinished(QNetworkOperation *);
    50 
    51 public:
    52 	bool isDefault();		// false, if map was changed once
    53     bool isUnsaved();		// save necessary
    54     bool hasChanged();		// undo possible
    55 	void setChanged();		// called from NoteEditor via LMO
    56 	void closeMap();
    57 	void setFilePath (QString);	
    58 	void setFilePath (QString,QString);	
    59 	QString getFilePath ();	// Full path e.g. "/home/tux/map.xml"
    60 	QString getFileName ();	// e.g. "map.xml"
    61 	QString getMapName ();	// e.g. "map"
    62 	QString getDestPath (); // e.g. "/home/tux/map.vym"
    63     int load (QString&, const LoadMode &);	// newmap, import/replace selection
    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 exportXML(const QString&);		// export to directory
    75     void clear();		// clear map
    76     void copy();		// copy branch to clipboard
    77     void undo();		// undo last action
    78 private:	
    79     void undoXML(const QString &);	// undo by replacing with saved data
    80     LinkableMapObj* pasteNoSave();		// paste clipboard to branch
    81     void cutNoSave();	// cut to clipboard
    82 public:	
    83     void paste();		// paste clipboard to branch and backup
    84     void cut();			// cut to clipboard and backup
    85     void move(const int &,const int&);
    86     void moveBranchUp();
    87     void moveBranchDown();
    88     void editHeading();					// Start editing heading 
    89 private:
    90 	void setHeading(const QString &);	// Just set the heading for selection
    91 	void setURL(const QString &);		// Just set the URL for selection
    92 	void setVymLink(const QString &);	// Set vymLink for selection
    93 public:	
    94     void addNewBranch(int);			// pos allows to add above/below selection
    95     void addNewBranchHere();		// insert and make selection its
    96     void deleteSelection();
    97 	LinkableMapObj* getSelection();	// returns selection
    98 	bool select(const QString &);	// Select 
    99 	void unselect();				// before changing current noteedit
   100 	void reselect();				// after  changing current noteedit
   101 private:	
   102 	void selectNextBranch();		// Increment number of branch
   103 	void selectPrevBranch();		// Decrement number of branch
   104 public:	
   105     void selectUpperBranch();
   106     void selectLowerBranch();
   107     void selectLeftBranch();
   108     void selectRightBranch();
   109     void selectFirstBranch();
   110     void selectLastBranch();
   111     void setColor(QColor);
   112     void selectBackgroundColor();
   113     void setBackgroundColor(QColor);
   114     QColor pickColor();
   115     void colorItem();
   116     void colorBranch();
   117 	void toggleStandardFlag(QString);
   118 	virtual void setViewCenter();			// needed for zooming
   119     BranchObj* findText(QString,bool);		// Find object
   120     void findReset();						// Reset Find 
   121 	void openURL();							// open URL in external browser
   122 	void editURL();							// edit the URL
   123 	void editHeading2URL();					// copy heading to URL
   124 	void editBugzilla2URL();				// create URL to Bugzilla
   125 	void editVymLink();						// edit link to another map
   126 	void deleteVymLink();					// delete link to another map
   127 	QString getVymLink();					// return path to map
   128 	void removeBranchHere();				// remove but keep childs
   129 	void removeChilds();					// remove childs
   130 	void editMapInfo();						// dialog to enter author, ...
   131 	void updateActions();					// update e.g. format buttons
   132 	void updateNoteFlag();					// when TextEditor changes
   133 	void setLinkStyle (LinkStyle);			// Set style of link
   134 	LinkStyle getLinkStyle ();				// requested in LMO
   135 	void setLinkColor(QColor);				// default color of links
   136 	void setLinkColorHint();				// color of links
   137 	void setLinkColorHint(LinkColorHint);	// color of links
   138 	LinkColorHint getLinkColorHint();
   139 	QColor getDefLinkColor();
   140 	void setDefXLinkColor(QColor);
   141 	QColor getDefXLinkColor();
   142 	void setDefXLinkWidth (int);
   143 	int getDefXLinkWidth();
   144 	void toggleLinkColorHint();				// after changing linkStyles
   145     void selectLinkColor();
   146     void toggleScroll();
   147     void unScrollAll();
   148 	void loadFloatImage ();
   149 	void saveFloatImage (int);
   150 	void toggleFloatExport();
   151 	void setFrame(const FrameType &);
   152 	void setHideLinkUnselected (bool);
   153 	bool getHideLinkUnselected ();
   154 private:	
   155     void importDir(BranchObj *,QDir);
   156 public:	
   157     void importDir();
   158 	void followXLink (int);
   159 	void editXLink (int);
   160     void testFunction();				// FIXME just testing
   161 
   162 protected:
   163 	void ensureSelectionVisible();		
   164 	virtual void updateViewCenter();	// needed for zooming
   165 	virtual void contentsContextMenuEvent ( QContextMenuEvent *e );
   166     virtual void contentsMousePressEvent(QMouseEvent*);
   167     virtual void contentsMouseReleaseEvent(QMouseEvent*);
   168     virtual void contentsMouseDoubleClickEvent(QMouseEvent*);
   169     virtual void contentsMouseMoveEvent(QMouseEvent*);
   170 
   171     virtual void contentsDragEnterEvent(QDragEnterEvent *event);
   172     virtual void contentsDropEvent(QDropEvent *event);
   173 private:
   174     QCanvas* mapCanvas;
   175     MapCenterObj* mapCenter;
   176 
   177 	bool adjustCanvasRequested;	// collect requests until end of user event
   178 	BranchObj *editingBO;		// entering Text into BO
   179     QLineEdit* lineedit;
   180 
   181     QColor actColor;			// actual color
   182 	QColor defLinkColor;		// default color for links
   183 	QColor defXLinkColor;		// default color for xlinks
   184 	int defXLinkWidth;			// default width for xlinks
   185 	LinkColorHint linkcolorhint;// use heading color or own color
   186 	LinkStyle linkstyle;		// default style for links
   187 
   188     QCursor handOpenCursor;		// cursor while moving canvas view
   189 	QCursor pickColorCursor;	// cursor while picking color 
   190 	bool pickingColor;
   191 	bool drawingLink;			// true while creating a link
   192 	bool copyingObj;			// true while creating a link
   193 	XLinkObj* tmpXLink;
   194 	
   195     LinkableMapObj* selection;		// select a LinkableMapObj
   196     LinkableMapObj* selectionLast;	// last selection 
   197 	QString undoSelection;			// selection for undo
   198 	QString redoSelection;			// selection for redo
   199     MapObj* movingObj;				// moving a MapObj
   200 	MapObj* linkingObj_src;			// part of a link
   201     QPoint movingObj_orgPos;		// org. pos of mouse before move
   202     QPoint movingObj_start;			// rel. pos of mouse to absPos 
   203     QPoint movingCont_start;		// inital pos of moving Content or
   204     QPoint movingVec;				// how far has Content moved
   205 	QPoint movingCenter;			// used when zooming
   206     QPrinter* printer;				// Printing
   207 
   208     bool mapDefault;				// Flag if map is untouched
   209     bool mapChanged;				// Flag if undo is possible
   210 	bool mapUnsaved;				// Flag if map should be saved
   211     QString backupXML;				// backup (XML) for undo
   212 	QString undoCommand;			// FIXME testing
   213 	QString redoCommand;			// FIXME testing
   214 									// if != NULL
   215 
   216 	bool printFrame;			// Print frame around map
   217 	bool printFooter;			// Print footer below map
   218 
   219 	bool zipped;				// should map be zipped
   220 	QString fileName;			// short name of file (for tab)
   221 	QString filePath;			// path to file which will be saved
   222 	QString fileDir;			// dir where file is saved
   223 	QString destPath;			// path to .vym file (needed for vymlinks)
   224 	QString mapName;			// fileName without ".vym"
   225 	QString lastImageDir;		// save dir for adding images
   226 
   227 	bool isInteractive;			// non interactive don't need tmpdirs
   228 	QString bakMapDir;			// tmp directory with data for undo
   229 	bool blockReposition;		// block while load or undo
   230 	bool blockSaveState;		// block while load or undo
   231 
   232 	BranchObj* itFind;			// next object in find process
   233 	bool EOFind;				// true, if search failed
   234 
   235 	QPoint exportOffset;		// set before export, used in save
   236     void resizeEvent( QResizeEvent * );
   237 
   238   QUrlOperator *urlOperator;
   239   QDataStream *imageData;
   240   QBuffer *imageBuffer;
   241 
   242 };
   243 #endif
   244