diff -r 000000000000 -r cf274b28e5fe mapeditor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mapeditor.h Wed Jul 30 14:42:03 2008 +0000 @@ -0,0 +1,197 @@ +#ifndef MAPEDITOR_H +#define MAPEDITOR_H + +#include +#include +#include +#include +#include +#include + +#include "mapcenterobj.h" +#include "misc.h" + +class MapEditor : public QCanvasView , public xmlObj { + Q_OBJECT + +public: + MapEditor(QWidget* parent=0, bool interactive=false, const char* name=0, WFlags f=0); + ~MapEditor(); + QColor color(); + QColor backgroundColor(); + MapCenterObj* getMapCenter(); + QCanvas* getCanvas(); + void adjustCanvasSize();// adjust canvas size to map and scrollview + bool blockReposition(); // block while load or undo + +private: + void makeTmpDirs(); // create temporary directories + void delTmpDirs(); // delete temporary directories + void makeSubDirs(const QString&); + // create subdirs in dir + QString saveToDir(const QString&,const QString &,bool, const QPoint + &,SaveMode); + void saveState(); // save actual state to backup + void saveState(const SaveMode&, LinkableMapObj *); + +private slots: + void finishedLineEditNoSave(); + +public: + bool isDefault(); // false, if map was changed once + bool isUnsaved(); // save necessary + bool hasChanged(); // undo possible + void setChanged(); // called from NoteEditor via LMO + void closeMap(); + void setFilePath (QString); + void setFilePath (QString,QString); + QString getFilePath (); // Full path e.g. "/home/tux/map.xml" + QString getFileName (); // e.g. "map.xml" + QString getMapName (); // e.g. "map" + QString getDestPath (); // e.g. "/home/tux/map.vym" + int load (QString&, const LoadMode &); // newmap, import/replace selection + int save(const SaveMode &); // Save map + void setZipped(bool); // save map zipped + bool saveZipped(); // 1 if file will be saved zipped + void print(); // print canvas +private: + QPixmap getPixmap(); +public: + void exportImage (QString fn); // export as PNG + void exportImage (QString fn, int); // export in given format + void exportASCII(); + void exportXML(const QString&); // export to directory + void clear(); // clear map + void undo(); // undo last action + void copy(); // copy branch to clipboard +private: + LinkableMapObj* pasteNoSave(); // paste clipboard to branch + LinkableMapObj* pasteAtNoSave(int); // paste clipboard to branch at position i + void cutNoSave(); // cut to clipboard +public: + void paste(); // paste clipboard to branch and backup + void cut(); // cut to clipboard and backup + void moveBranchUp(); + void moveBranchDown(); + void editHeading(); + void addNewBranch(int); // pos allows to add above/below selection + void deleteSelection(); + LinkableMapObj* getSelection(); // returns selection + bool select(QString ); // Select + void unselect(); // before changing current noteedit + void reselect(); // after changing current noteedit +private: + void selectNextBranch(); // Increment number of branch + void selectPrevBranch(); // Decrement number of branch +public: + void selectUpperBranch(); + void selectLowerBranch(); + void selectLeftBranch(); + void selectRightBranch(); + void selectFirstBranch(); + void selectLastBranch(); + void setColor(QColor); + void selectBackgroundColor(); + void setBackgroundColor(QColor); + QColor pickColor(); + void colorItem(); + void colorBranch(); + void toggleStandardFlag(QString); + virtual void setViewCenter(); // needed for zooming + BranchObj* findText(QString,bool); // Find object + void findReset(); // Reset Find + void openURL(); // open URL in external browser + void editURL(); // edit the URL + void editHeading2URL(); // copy heading to URL + void editBugzilla2URL(); // create URL to Bugzilla + void editVymLink(); // edit link to another map + void deleteVymLink(); // delete link to another map + QString getVymLink(); // return path to map + void editMapInfo(); // dialog to enter author, ... + void updateActions(); // update e.g. format buttons + void setLinkStyle (LinkStyle); // Set style of link + LinkStyle getLinkStyle (); // requested in LMO + void setLinkColor(QColor); // default color of links + void setLinkColorHint(); // color of links + void setLinkColorHint(LinkColorHint); // color of links + LinkColorHint getLinkColorHint(); + QColor getDefLinkColor(); + void toggleLinkColorHint(); // after changing linkStyles + void selectLinkColor(); + void toggleScroll(); + void unScrollAll(); + void loadFloatImage (); + void saveFloatImage (int); + void toggleFloatExport(); + void setFrame(const FrameType &); +private: + void importDir(BranchObj *,QDir); +public: + void importDir(); + void testFunction(); // FIXME just testing + +protected: + void ensureSelectionVisible(); + virtual void updateViewCenter(); // needed for zooming + virtual void contentsContextMenuEvent ( QContextMenuEvent *e ); + virtual void contentsMousePressEvent(QMouseEvent*); + virtual void contentsMouseReleaseEvent(QMouseEvent*); + virtual void contentsMouseDoubleClickEvent(QMouseEvent*); + virtual void contentsMouseMoveEvent(QMouseEvent*); + +private: + QCanvas* mapCanvas; + MapCenterObj* mapCenter; + + bool adjustCanvasRequested; // collect requests until end of user event + BranchObj *editingBO; // entering Text into BO + QLineEdit* lineedit; + + QColor actColor; // actual color + QColor deflinkcolor; // default color for links + LinkColorHint linkcolorhint;// use heading color or own color + LinkStyle linkstyle; // default style for links + + QCursor handOpenCursor; // cursor while moving canvas view + QCursor pickColorCursor; // cursor while picking color + bool pickingColor; // true while picking Color CTRL-LeftButton + + LinkableMapObj* selection; // select a LinkableMapObj + LinkableMapObj* selectionLast; // last selection + MapObj* movingObj; // moving a MapObj + QPoint movingObj_start; // rel. pos of mouse to absPos + QPoint movingCont_start; // inital pos of moving Content or + QPoint movingVec; // how far has Content moved + QPoint movingCenter; // used when zooming + QPrinter* printer; // Printing + + bool mapDefault; // Flag if map is untouched + bool mapChanged; // Flag if undo is possible + bool mapUnsaved; // Flag if map should be saved + QString backupXML; // backup (XML) for undo + LinkableMapObj* undoSelection; // replace this LMO with vympart from backup + // if != NULL + + bool printFrame; // Print frame around map + bool printFooter; // Print footer below map + + bool zipped; // should map be zipped + QString fileName; // short name of file (for tab) + QString filePath; // path to file which will be saved + QString fileDir; // dir where file is saved + QString destPath; // path to .vym file (needed for vymlinks) + QString mapName; // fileName without ".vym" + QString lastImageDir; // save dir for adding images + + bool isInteractive; // non interactive don't need tmpdirs + QString bakMapDir; // tmp directory with data for undo + bool blockreposition; // block while load or undo + + BranchObj* itFind; // next object in find process + bool EOFind; // true, if search failed + + QPoint exportOffset; // set before export, used in save + void resizeEvent( QResizeEvent * ); +}; +#endif +