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