mapeditor.h
author insilmaril
Sun, 30 Jan 2005 23:28:09 +0000
changeset 87 5cf1836a440a
parent 83 e90f5bef70c8
child 89 9db3eaa21237
permissions -rw-r--r--
added linkobj.*
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@0
    10
insilmaril@0
    11
#include "mapcenterobj.h"
insilmaril@0
    12
#include "misc.h"
insilmaril@0
    13
insilmaril@83
    14
enum ModifierMode {pickColorMode,linkObjectsMode};
insilmaril@83
    15
insilmaril@0
    16
class MapEditor : public QCanvasView , public xmlObj {
insilmaril@0
    17
    Q_OBJECT
insilmaril@0
    18
insilmaril@0
    19
public:
insilmaril@0
    20
    MapEditor(QWidget* parent=0, bool interactive=false, const char* name=0, WFlags f=0);
insilmaril@0
    21
	~MapEditor();
insilmaril@0
    22
    QColor color();
insilmaril@0
    23
    QColor backgroundColor();
insilmaril@0
    24
    MapCenterObj* getMapCenter();
insilmaril@0
    25
	QCanvas* getCanvas();
insilmaril@0
    26
	void adjustCanvasSize();// adjust canvas size to map and scrollview
insilmaril@0
    27
	bool blockReposition(); // block while load or undo
insilmaril@0
    28
	
insilmaril@0
    29
private:
insilmaril@0
    30
	void makeTmpDirs();		// create temporary directories
insilmaril@0
    31
	void delTmpDirs();		// delete temporary directories
insilmaril@0
    32
	void makeSubDirs(const QString&);		
insilmaril@0
    33
							// create subdirs in dir
insilmaril@0
    34
    QString saveToDir(const QString&,const QString &,bool, const QPoint
insilmaril@0
    35
	&,SaveMode);
insilmaril@0
    36
    void saveState();		// save actual state to backup
insilmaril@0
    37
    void saveState(const SaveMode&, LinkableMapObj *);
insilmaril@0
    38
insilmaril@0
    39
private slots:
insilmaril@0
    40
    void finishedLineEditNoSave();
insilmaril@0
    41
insilmaril@0
    42
public:
insilmaril@0
    43
	bool isDefault();		// false, if map was changed once
insilmaril@0
    44
    bool isUnsaved();		// save necessary
insilmaril@0
    45
    bool hasChanged();		// undo possible
insilmaril@0
    46
	void setChanged();		// called from NoteEditor via LMO
insilmaril@0
    47
	void closeMap();
insilmaril@0
    48
	void setFilePath (QString);	
insilmaril@0
    49
	void setFilePath (QString,QString);	
insilmaril@0
    50
	QString getFilePath ();	// Full path e.g. "/home/tux/map.xml"
insilmaril@0
    51
	QString getFileName ();	// e.g. "map.xml"
insilmaril@0
    52
	QString getMapName ();	// e.g. "map"
insilmaril@0
    53
	QString getDestPath (); // e.g. "/home/tux/map.vym"
insilmaril@0
    54
    int load (QString&, const LoadMode &);	// newmap, import/replace selection
insilmaril@0
    55
    int save(const SaveMode &);	// Save map 
insilmaril@0
    56
	void setZipped(bool);		// save map zipped
insilmaril@0
    57
	bool saveZipped();			// 1 if file will be saved zipped
insilmaril@0
    58
    void print();				// print canvas
insilmaril@0
    59
private:
insilmaril@0
    60
    QPixmap getPixmap();
insilmaril@0
    61
public:
insilmaril@0
    62
    void exportImage (QString fn);		// export as PNG	
insilmaril@0
    63
    void exportImage (QString fn, int);	// export in given format
insilmaril@0
    64
    void exportASCII();
insilmaril@0
    65
    void exportXML(const QString&);		// export to directory
insilmaril@0
    66
    void clear();		// clear map
insilmaril@0
    67
    void undo();		// undo last action
insilmaril@0
    68
    void copy();		// copy branch to clipboard
insilmaril@0
    69
private:	
insilmaril@0
    70
    LinkableMapObj* pasteNoSave();		// paste clipboard to branch
insilmaril@0
    71
    void cutNoSave();	// cut to clipboard
insilmaril@0
    72
public:	
insilmaril@0
    73
    void paste();		// paste clipboard to branch and backup
insilmaril@0
    74
    void cut();			// cut to clipboard and backup
insilmaril@0
    75
    void moveBranchUp();
insilmaril@0
    76
    void moveBranchDown();
insilmaril@0
    77
    void editHeading();
insilmaril@0
    78
    void addNewBranch(int);			// pos allows to add above/below selection
insilmaril@0
    79
    void deleteSelection();
insilmaril@0
    80
	LinkableMapObj* getSelection();	// returns selection
insilmaril@83
    81
	LinkableMapObj* findObj (QString);
insilmaril@83
    82
	bool select(const QString &);	// Select 
insilmaril@0
    83
	void unselect();				// before changing current noteedit
insilmaril@0
    84
	void reselect();				// after  changing current noteedit
insilmaril@0
    85
private:	
insilmaril@0
    86
	void selectNextBranch();		// Increment number of branch
insilmaril@0
    87
	void selectPrevBranch();		// Decrement number of branch
insilmaril@0
    88
public:	
insilmaril@0
    89
    void selectUpperBranch();
insilmaril@0
    90
    void selectLowerBranch();
insilmaril@0
    91
    void selectLeftBranch();
insilmaril@0
    92
    void selectRightBranch();
insilmaril@0
    93
    void selectFirstBranch();
insilmaril@0
    94
    void selectLastBranch();
insilmaril@0
    95
    void setColor(QColor);
insilmaril@0
    96
    void selectBackgroundColor();
insilmaril@0
    97
    void setBackgroundColor(QColor);
insilmaril@0
    98
    QColor pickColor();
insilmaril@0
    99
    void colorItem();
insilmaril@0
   100
    void colorBranch();
insilmaril@0
   101
	void toggleStandardFlag(QString);
insilmaril@0
   102
	virtual void setViewCenter();			// needed for zooming
insilmaril@0
   103
    BranchObj* findText(QString,bool);		// Find object
insilmaril@0
   104
    void findReset();						// Reset Find 
insilmaril@0
   105
	void openURL();							// open URL in external browser
insilmaril@0
   106
	void editURL();							// edit the URL
insilmaril@0
   107
	void editHeading2URL();					// copy heading to URL
insilmaril@0
   108
	void editBugzilla2URL();				// create URL to Bugzilla
insilmaril@0
   109
	void editVymLink();						// edit link to another map
insilmaril@0
   110
	void deleteVymLink();					// delete link to another map
insilmaril@0
   111
	QString getVymLink();					// return path to map
insilmaril@0
   112
	void editMapInfo();						// dialog to enter author, ...
insilmaril@0
   113
	void updateActions();					// update e.g. format buttons
insilmaril@0
   114
	void setLinkStyle (LinkStyle);			// Set style of link
insilmaril@0
   115
	LinkStyle getLinkStyle ();				// requested in LMO
insilmaril@0
   116
	void setLinkColor(QColor);				// default color of links
insilmaril@0
   117
	void setLinkColorHint();				// color of links
insilmaril@0
   118
	void setLinkColorHint(LinkColorHint);	// color of links
insilmaril@0
   119
	LinkColorHint getLinkColorHint();
insilmaril@0
   120
	QColor getDefLinkColor();
insilmaril@0
   121
	void toggleLinkColorHint();				// after changing linkStyles
insilmaril@0
   122
    void selectLinkColor();
insilmaril@0
   123
    void toggleScroll();
insilmaril@0
   124
    void unScrollAll();
insilmaril@0
   125
	void loadFloatImage ();
insilmaril@0
   126
	void saveFloatImage (int);
insilmaril@0
   127
	void toggleFloatExport();
insilmaril@0
   128
	void setFrame(const FrameType &);
insilmaril@0
   129
private:	
insilmaril@0
   130
    void importDir(BranchObj *,QDir);
insilmaril@0
   131
public:	
insilmaril@0
   132
    void importDir();
insilmaril@0
   133
    void testFunction();				// FIXME just testing
insilmaril@0
   134
insilmaril@0
   135
protected:
insilmaril@0
   136
	void ensureSelectionVisible();		
insilmaril@0
   137
	virtual void updateViewCenter();	// needed for zooming
insilmaril@0
   138
	virtual void contentsContextMenuEvent ( QContextMenuEvent *e );
insilmaril@0
   139
    virtual void contentsMousePressEvent(QMouseEvent*);
insilmaril@0
   140
    virtual void contentsMouseReleaseEvent(QMouseEvent*);
insilmaril@0
   141
    virtual void contentsMouseDoubleClickEvent(QMouseEvent*);
insilmaril@0
   142
    virtual void contentsMouseMoveEvent(QMouseEvent*);
insilmaril@0
   143
insilmaril@0
   144
private:
insilmaril@0
   145
    QCanvas* mapCanvas;
insilmaril@0
   146
    MapCenterObj* mapCenter;
insilmaril@0
   147
insilmaril@0
   148
	bool adjustCanvasRequested;	// collect requests until end of user event
insilmaril@0
   149
	BranchObj *editingBO;		// entering Text into BO
insilmaril@0
   150
    QLineEdit* lineedit;
insilmaril@0
   151
insilmaril@0
   152
    QColor actColor;			// actual color
insilmaril@0
   153
	QColor deflinkcolor;		// default color for links
insilmaril@0
   154
	LinkColorHint linkcolorhint;// use heading color or own color
insilmaril@0
   155
	LinkStyle linkstyle;		// default style for links
insilmaril@0
   156
insilmaril@83
   157
	ModifierMode modifierMode;	// pick color or link objects?
insilmaril@83
   158
insilmaril@0
   159
    QCursor handOpenCursor;		// cursor while moving canvas view
insilmaril@0
   160
	QCursor pickColorCursor;	// cursor while picking color 
insilmaril@83
   161
	bool pickingColor;
insilmaril@83
   162
	bool drawingLink;			// true while creating a link
insilmaril@83
   163
	LinkObj* tmpLink;
insilmaril@0
   164
	
insilmaril@0
   165
    LinkableMapObj* selection;		// select a LinkableMapObj
insilmaril@0
   166
    LinkableMapObj* selectionLast;	// last selection 
insilmaril@0
   167
    MapObj* movingObj;				// moving a MapObj
insilmaril@83
   168
	MapObj* linkingObj_src;			// part of a link
insilmaril@0
   169
    QPoint movingObj_start;			// rel. pos of mouse to absPos 
insilmaril@0
   170
    QPoint movingCont_start;		// inital pos of moving Content or
insilmaril@0
   171
    QPoint movingVec;				// how far has Content moved
insilmaril@0
   172
	QPoint movingCenter;			// used when zooming
insilmaril@0
   173
    QPrinter* printer;				// Printing
insilmaril@0
   174
insilmaril@0
   175
    bool mapDefault;				// Flag if map is untouched
insilmaril@0
   176
    bool mapChanged;				// Flag if undo is possible
insilmaril@0
   177
	bool mapUnsaved;				// Flag if map should be saved
insilmaril@0
   178
    QString backupXML;				// backup (XML) for undo
insilmaril@0
   179
	LinkableMapObj* undoSelection;	// replace this LMO with vympart from backup
insilmaril@0
   180
									// if != NULL
insilmaril@0
   181
insilmaril@0
   182
	bool printFrame;			// Print frame around map
insilmaril@0
   183
	bool printFooter;			// Print footer below map
insilmaril@0
   184
insilmaril@0
   185
	bool zipped;				// should map be zipped
insilmaril@0
   186
	QString fileName;			// short name of file (for tab)
insilmaril@0
   187
	QString filePath;			// path to file which will be saved
insilmaril@0
   188
	QString fileDir;			// dir where file is saved
insilmaril@0
   189
	QString destPath;			// path to .vym file (needed for vymlinks)
insilmaril@0
   190
	QString mapName;			// fileName without ".vym"
insilmaril@0
   191
	QString lastImageDir;		// save dir for adding images
insilmaril@0
   192
insilmaril@0
   193
	bool isInteractive;			// non interactive don't need tmpdirs
insilmaril@0
   194
	QString bakMapDir;			// tmp directory with data for undo
insilmaril@0
   195
	bool blockreposition;		// block while load or undo
insilmaril@0
   196
insilmaril@0
   197
	BranchObj* itFind;			// next object in find process
insilmaril@0
   198
	bool EOFind;				// true, if search failed
insilmaril@0
   199
insilmaril@0
   200
	QPoint exportOffset;		// set before export, used in save
insilmaril@0
   201
    void resizeEvent( QResizeEvent * );
insilmaril@0
   202
};
insilmaril@0
   203
#endif
insilmaril@0
   204