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