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