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