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