mapeditor.h
branchqt4-port
changeset 2 608f976aa7bb
parent 0 7a96bd401351
child 4 ec3d2962893d
     1.1 --- a/mapeditor.h	Sun Jan 30 12:58:47 2005 +0000
     1.2 +++ b/mapeditor.h	Tue Jun 06 14:58:11 2006 +0000
     1.3 @@ -1,43 +1,63 @@
     1.4  #ifndef MAPEDITOR_H
     1.5  #define MAPEDITOR_H
     1.6  
     1.7 -#include <qcanvas.h>
     1.8 +#include <q3canvas.h>
     1.9  #include <qlineedit.h>
    1.10  #include <qcursor.h>
    1.11 -#include <qfiledialog.h>
    1.12 +#include <q3filedialog.h>
    1.13  #include <qevent.h>
    1.14 -#include <qprocess.h>
    1.15 +#include <q3process.h>
    1.16 +#include <qbuffer.h>
    1.17 +//Added by qt3to4:
    1.18 +#include <QContextMenuEvent>
    1.19 +#include <QDropEvent>
    1.20 +#include <QResizeEvent>
    1.21 +#include <QPixmap>
    1.22 +#include <QMouseEvent>
    1.23 +#include <QDragEnterEvent>
    1.24  
    1.25  #include "mapcenterobj.h"
    1.26 +#include "file.h"
    1.27  #include "misc.h"
    1.28 +#include "showtextdialog.h"
    1.29  
    1.30 -class MapEditor : public QCanvasView , public xmlObj {
    1.31 +class Q3NetworkOperation;
    1.32 +class Q3UrlOperator;
    1.33 +
    1.34 +class MapEditor : public Q3CanvasView , public xmlObj {
    1.35      Q_OBJECT
    1.36  
    1.37  public:
    1.38 -    MapEditor(QWidget* parent=0, bool interactive=false, const char* name=0, WFlags f=0);
    1.39 +    MapEditor(QWidget* parent=0, bool interactive=false, const char* name=0, Qt::WFlags f=0);
    1.40  	~MapEditor();
    1.41      QColor color();
    1.42      QColor backgroundColor();
    1.43      MapCenterObj* getMapCenter();
    1.44 -	QCanvas* getCanvas();
    1.45 +	Q3Canvas* getCanvas();
    1.46  	void adjustCanvasSize();// adjust canvas size to map and scrollview
    1.47 -	bool blockReposition(); // block while load or undo
    1.48 +	bool isRepositionBlocked(); // block while load or undo
    1.49  	
    1.50  private:
    1.51 +	QString getName(LinkableMapObj*);	// Get e.g. heading or filename
    1.52  	void makeTmpDirs();		// create temporary directories
    1.53 -	void delTmpDirs();		// delete temporary directories
    1.54 -	void makeSubDirs(const QString&);		
    1.55 -							// create subdirs in dir
    1.56 -    QString saveToDir(const QString&,const QString &,bool, const QPoint
    1.57 -	&,SaveMode);
    1.58 -    void saveState();		// save actual state to backup
    1.59 -    void saveState(const SaveMode&, LinkableMapObj *);
    1.60 +    QString saveToDir(const QString&,const QString &,bool, const QPoint &,LinkableMapObj*);
    1.61 +    void saveState(const QString &);	// save actual state to backup
    1.62 +    void saveState(LinkableMapObj *, const QString &);
    1.63 +    void saveState(const QString &, const QString &, const QString &);
    1.64 +    void saveState(const QString &, LinkableMapObj *, const QString &);
    1.65 +    void saveState(const SaveMode&, const QString &, LinkableMapObj *, const QString &, LinkableMapObj *, const QString &);
    1.66 +    void parseAtom(const QString &);	
    1.67  
    1.68 -private slots:
    1.69 -    void finishedLineEditNoSave();
    1.70 +    void addFloatImage(const QPixmap &img);
    1.71 +
    1.72 +  private slots:
    1.73 +    void finishedLineEdit();
    1.74 +    void fetchImage(const QString &img);
    1.75 +    void imageDataFetched(const QByteArray &, Q3NetworkOperation *);
    1.76 +    void imageDataFinished(Q3NetworkOperation *);
    1.77  
    1.78  public:
    1.79 +	void toggleHistoryWindow();
    1.80  	bool isDefault();		// false, if map was changed once
    1.81      bool isUnsaved();		// save necessary
    1.82      bool hasChanged();		// undo possible
    1.83 @@ -49,38 +69,51 @@
    1.84  	QString getFileName ();	// e.g. "map.xml"
    1.85  	QString getMapName ();	// e.g. "map"
    1.86  	QString getDestPath (); // e.g. "/home/tux/map.vym"
    1.87 -    int load (QString&, const LoadMode &);	// newmap, import/replace selection
    1.88 +    ErrorCode load (QString, LoadMode );	// newmap, import/replace selection
    1.89 +public:
    1.90      int save(const SaveMode &);	// Save map 
    1.91  	void setZipped(bool);		// save map zipped
    1.92  	bool saveZipped();			// 1 if file will be saved zipped
    1.93      void print();				// print canvas
    1.94  private:
    1.95      QPixmap getPixmap();
    1.96 +	void setHideTmpMode (HideTmpMode);	// temporary hide stuff
    1.97 +	HideTmpMode getHideTmpMode();		// temporary hide stuff
    1.98  public:
    1.99 +	void setExportMode (bool);			// temporary hide stuff during export
   1.100      void exportImage (QString fn);		// export as PNG	
   1.101      void exportImage (QString fn, int);	// export in given format
   1.102 -    void exportASCII();
   1.103 +    void exportOOPresentation(const QString &,const QString &);
   1.104      void exportXML(const QString&);		// export to directory
   1.105      void clear();		// clear map
   1.106 +    void copy();		// copy branch to clipboard
   1.107 +    void redo();		// redo last action
   1.108      void undo();		// undo last action
   1.109 -    void copy();		// copy branch to clipboard
   1.110  private:	
   1.111 -    LinkableMapObj* pasteNoSave();		// paste clipboard to branch
   1.112 -    LinkableMapObj* pasteAtNoSave(int);	// paste clipboard to branch at position i
   1.113 +    void undoXML(const QString &, const QString &);
   1.114 +    void pasteNoSave();		// paste clipboard to branch
   1.115      void cutNoSave();	// cut to clipboard
   1.116  public:	
   1.117      void paste();		// paste clipboard to branch and backup
   1.118      void cut();			// cut to clipboard and backup
   1.119 +    void move(const int &,const int&);
   1.120      void moveBranchUp();
   1.121      void moveBranchDown();
   1.122 -    void editHeading();
   1.123 +    void editHeading();					// Start editing heading 
   1.124 +private:
   1.125 +	void setHeading(const QString &);	// Just set the heading for selection
   1.126 +	void setURL(const QString &);		// Just set the URL for selection
   1.127 +	void setVymLink(const QString &);	// Set vymLink for selection
   1.128 +public:	
   1.129      void addNewBranch(int);			// pos allows to add above/below selection
   1.130 +    void addNewBranchHere();		// insert and make selection its
   1.131      void deleteSelection();
   1.132  	LinkableMapObj* getSelection();	// returns selection
   1.133 -	bool select(QString );			// Select 
   1.134  	void unselect();				// before changing current noteedit
   1.135  	void reselect();				// after  changing current noteedit
   1.136 +	bool select(const QString &);	// Select 
   1.137  private:	
   1.138 +	void select(LinkableMapObj*);	
   1.139  	void selectNextBranch();		// Increment number of branch
   1.140  	void selectPrevBranch();		// Decrement number of branch
   1.141  public:	
   1.142 @@ -100,15 +133,20 @@
   1.143  	virtual void setViewCenter();			// needed for zooming
   1.144      BranchObj* findText(QString,bool);		// Find object
   1.145      void findReset();						// Reset Find 
   1.146 -	void openURL();							// open URL in external browser
   1.147  	void editURL();							// edit the URL
   1.148 +	QString getURL();						// returns URL of selection or ""
   1.149  	void editHeading2URL();					// copy heading to URL
   1.150  	void editBugzilla2URL();				// create URL to Bugzilla
   1.151 +	void editFATE2URL();					// create URL to FATE
   1.152  	void editVymLink();						// edit link to another map
   1.153  	void deleteVymLink();					// delete link to another map
   1.154  	QString getVymLink();					// return path to map
   1.155 +	void toggleHideExport();				// toggle the export flag
   1.156 +	void removeBranchKeepChilds();			// remove but keep childs
   1.157 +	void removeChilds();					// remove childs
   1.158  	void editMapInfo();						// dialog to enter author, ...
   1.159  	void updateActions();					// update e.g. format buttons
   1.160 +	void updateNoteFlag();					// when TextEditor changes
   1.161  	void setLinkStyle (LinkStyle);			// Set style of link
   1.162  	LinkStyle getLinkStyle ();				// requested in LMO
   1.163  	void setLinkColor(QColor);				// default color of links
   1.164 @@ -116,18 +154,27 @@
   1.165  	void setLinkColorHint(LinkColorHint);	// color of links
   1.166  	LinkColorHint getLinkColorHint();
   1.167  	QColor getDefLinkColor();
   1.168 +	void setDefXLinkColor(QColor);
   1.169 +	QColor getDefXLinkColor();
   1.170 +	void setDefXLinkWidth (int);
   1.171 +	int getDefXLinkWidth();
   1.172  	void toggleLinkColorHint();				// after changing linkStyles
   1.173      void selectLinkColor();
   1.174      void toggleScroll();
   1.175      void unScrollAll();
   1.176  	void loadFloatImage ();
   1.177  	void saveFloatImage (int);
   1.178 -	void toggleFloatExport();
   1.179  	void setFrame(const FrameType &);
   1.180 +	void setIncludeImagesVer(bool);
   1.181 +	void setIncludeImagesHor(bool);
   1.182 +	void setHideLinkUnselected (bool);
   1.183 +	bool getHideLinkUnselected ();
   1.184  private:	
   1.185      void importDir(BranchObj *,QDir);
   1.186  public:	
   1.187      void importDir();
   1.188 +	void followXLink (int);
   1.189 +	void editXLink (int);
   1.190      void testFunction();				// FIXME just testing
   1.191  
   1.192  protected:
   1.193 @@ -139,8 +186,10 @@
   1.194      virtual void contentsMouseDoubleClickEvent(QMouseEvent*);
   1.195      virtual void contentsMouseMoveEvent(QMouseEvent*);
   1.196  
   1.197 +    virtual void contentsDragEnterEvent(QDragEnterEvent *event);
   1.198 +    virtual void contentsDropEvent(QDropEvent *event);
   1.199  private:
   1.200 -    QCanvas* mapCanvas;
   1.201 +    Q3Canvas* mapCanvas;
   1.202      MapCenterObj* mapCenter;
   1.203  
   1.204  	bool adjustCanvasRequested;	// collect requests until end of user event
   1.205 @@ -148,17 +197,24 @@
   1.206      QLineEdit* lineedit;
   1.207  
   1.208      QColor actColor;			// actual color
   1.209 -	QColor deflinkcolor;		// default color for links
   1.210 +	QColor defLinkColor;		// default color for links
   1.211 +	QColor defXLinkColor;		// default color for xlinks
   1.212 +	int defXLinkWidth;			// default width for xlinks
   1.213  	LinkColorHint linkcolorhint;// use heading color or own color
   1.214  	LinkStyle linkstyle;		// default style for links
   1.215  
   1.216      QCursor handOpenCursor;		// cursor while moving canvas view
   1.217  	QCursor pickColorCursor;	// cursor while picking color 
   1.218 -	bool pickingColor;			// true while picking Color CTRL-LeftButton
   1.219 +	bool pickingColor;
   1.220 +	bool drawingLink;			// true while creating a link
   1.221 +	bool copyingObj;			// true while creating a link
   1.222 +	XLinkObj* tmpXLink;
   1.223  	
   1.224      LinkableMapObj* selection;		// select a LinkableMapObj
   1.225      LinkableMapObj* selectionLast;	// last selection 
   1.226      MapObj* movingObj;				// moving a MapObj
   1.227 +	MapObj* linkingObj_src;			// part of a link
   1.228 +    QPoint movingObj_orgPos;		// org. pos of mouse before move
   1.229      QPoint movingObj_start;			// rel. pos of mouse to absPos 
   1.230      QPoint movingCont_start;		// inital pos of moving Content or
   1.231      QPoint movingVec;				// how far has Content moved
   1.232 @@ -168,14 +224,12 @@
   1.233      bool mapDefault;				// Flag if map is untouched
   1.234      bool mapChanged;				// Flag if undo is possible
   1.235  	bool mapUnsaved;				// Flag if map should be saved
   1.236 -    QString backupXML;				// backup (XML) for undo
   1.237 -	LinkableMapObj* undoSelection;	// replace this LMO with vympart from backup
   1.238 -									// if != NULL
   1.239  
   1.240  	bool printFrame;			// Print frame around map
   1.241  	bool printFooter;			// Print footer below map
   1.242  
   1.243  	bool zipped;				// should map be zipped
   1.244 +static	int mapNum;				// unique number for Editor
   1.245  	QString fileName;			// short name of file (for tab)
   1.246  	QString filePath;			// path to file which will be saved
   1.247  	QString fileDir;			// dir where file is saved
   1.248 @@ -184,14 +238,27 @@
   1.249  	QString lastImageDir;		// save dir for adding images
   1.250  
   1.251  	bool isInteractive;			// non interactive don't need tmpdirs
   1.252 -	QString bakMapDir;			// tmp directory with data for undo
   1.253 -	bool blockreposition;		// block while load or undo
   1.254 +	QString tmpMapDir;			// tmp directory with data for undo/redo
   1.255 +	int undosTotal;				// total number of undos 
   1.256 +	int undoNum;				// current number of bakMapDir to be used 
   1.257 +	int undosAvail;				// how many actions can currently be undone
   1.258 +	bool blockReposition;		// block while load or undo
   1.259 +	bool blockSaveState;		// block while load or undo
   1.260  
   1.261  	BranchObj* itFind;			// next object in find process
   1.262  	bool EOFind;				// true, if search failed
   1.263  
   1.264  	QPoint exportOffset;		// set before export, used in save
   1.265 +	HideTmpMode hidemode;			// true while exporting to hide some stuff
   1.266 +	
   1.267      void resizeEvent( QResizeEvent * );
   1.268 +
   1.269 +  Q3UrlOperator *urlOperator;
   1.270 +  QDataStream *imageData;
   1.271 +  QBuffer *imageBuffer;
   1.272 +
   1.273 +	ShowTextDialog *historyWindow;
   1.274 +
   1.275  };
   1.276  #endif
   1.277