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