1.1 --- a/mapeditor.h Mon Jul 14 11:25:09 2008 +0000
1.2 +++ b/mapeditor.h Wed Jul 16 10:44:44 2008 +0000
1.3 @@ -2,370 +2,46 @@
1.4 #define MAPEDITOR_H
1.5
1.6 #include <QGraphicsView>
1.7 -#include <QtNetwork>
1.8
1.9 #include "attribute.h"
1.10 -#include "file.h"
1.11 -#include "misc.h"
1.12 -#include "parser.h"
1.13 #include "ornamentedobj.h"
1.14 -#include "selection.h"
1.15 +#include "selection.h" // FIXME should not be needed
1.16 #include "settings.h"
1.17 #include "vymmodel.h"
1.18
1.19 -class VymModel;
1.20 -class Selection;
1.21
1.22 /*! \brief Main widget in vym to display and edit a map */
1.23
1.24 -class MapEditor : public QGraphicsView, public XMLObj {
1.25 +class MapEditor : public QGraphicsView {
1.26 Q_OBJECT
1.27
1.28 public:
1.29 - /*! \brief State of the mapeditor
1.30 -
1.31 - While a heading is edited, the state has to change, so
1.32 - that e.g. no other object might get selected. This is done
1.33 - in Main by calling setStateEditHeading
1.34 - */
1.35 - enum State {
1.36 - Idle, //!< Idle, waiting for user event
1.37 - EditHeading //!< Editing heading (dont't select another branch now)
1.38 - };
1.39 - /*! \brief Networking states
1.40 -
1.41 - In Network modus we want to switch of saveState, autosave, ...
1.42 - */
1.43 - enum NetState {
1.44 - Offline, //!< Offline
1.45 - Client, //!< I am the client and connected to server
1.46 - Server //!< I am the server
1.47 - };
1.48 - MapEditor(QWidget* parent=0);
1.49 + MapEditor(VymModel *vm);
1.50 ~MapEditor();
1.51 VymModel* getModel();
1.52 QGraphicsScene * getScene();
1.53 - State getState(); //!< Return State of MapEditor
1.54 - void setStateEditHeading (bool); //!< If set to true, State will change to EditHeading
1.55 - bool isRepositionBlocked(); //!< While load or undo there is no need to update graphicsview
1.56 - bool isSaveStateBlocked(); //!< block while undo/redo or while running scripts
1.57 - void setSaveStateBlocked(bool); //!< block saving the undo/redo state
1.58 - bool isSelectBlocked(); //!< true, if no change of selection is possible, e.g. while editing the heading of abranch
1.59 -
1.60 -protected:
1.61 - /*! \brief Get name of object
1.62 -
1.63 - Returns heading of a branch or name of an object for use in comment
1.64 - of undo/redo history
1.65 - */
1.66 - QString getName(const LinkableMapObj*); // Get e.g. heading or filename
1.67 - void makeTmpDirs(); // create temporary directories
1.68 -
1.69 - /*! This function saves all information of the map to disc.
1.70 - saveToDir also calls the functions for all BranchObj and other objects in the map.
1.71 - The structure of the map itself is returned as QString and passed back to Main,
1.72 - where saveToDir is called initially
1.73 - */
1.74 - QString saveToDir (const QString &tmpdir, const QString &prefix, bool writeflags, const QPointF &offset, LinkableMapObj *saveSel);
1.75 -
1.76 - /*! \brief Get directory, where current step in history is save
1.77 -
1.78 - saveState creates a directory for each step in history. This function returns the
1.79 - path of the current directory
1.80 - */
1.81 - QString getHistoryDir();
1.82 -
1.83 - /*! \brief Save the current changes in map
1.84 -
1.85 - Two commands and selections are saved:
1.86 -
1.87 - - undocommand and undoselection to undo the change
1.88 - - redocommand and redoselection to redo the action after an undo
1.89 -
1.90 - Additionally a comment is logged.
1.91 -
1.92 - */
1.93 - void saveState(
1.94 - const SaveMode& savemode,
1.95 - const QString &undoSelection,
1.96 - const QString &undoCommand,
1.97 - const QString &redoSelection,
1.98 - const QString &redoCommand,
1.99 - const QString &comment,
1.100 - LinkableMapObj *saveSelection);
1.101 - /*! Overloaded for convenience */
1.102 - void saveStateChangingPart(
1.103 - LinkableMapObj *undoSelection,
1.104 - LinkableMapObj* redoSelection,
1.105 - const QString &redoCommand,
1.106 - const QString &comment);
1.107 - /*! Overloaded for convenience */
1.108 - void saveStateRemovingPart(
1.109 - LinkableMapObj *redoSelection,
1.110 - const QString &comment);
1.111 - /*! Overloaded for convenience */
1.112 - void saveState(
1.113 - LinkableMapObj *undoSelection,
1.114 - const QString &undoCommand,
1.115 - LinkableMapObj *redoSelection,
1.116 - const QString &redoCommand,
1.117 - const QString &comment);
1.118 - /*! Overloaded for convenience */
1.119 - void saveState(
1.120 - const QString &undoSelection,
1.121 - const QString &undoCommand,
1.122 - const QString &redoSelection,
1.123 - const QString &redoCommand,
1.124 - const QString &comment) ;
1.125 - void saveState(
1.126 - const QString &undoCommand,
1.127 - const QString &redoCommand,
1.128 - const QString &comment) ;
1.129 -
1.130 -public:
1.131 -
1.132 - /* \brief Process one command and its parameters */
1.133 - void parseAtom (const QString &atom);
1.134 -
1.135 - /* \brief Runs the script */
1.136 - void runScript (QString script);
1.137 -private:
1.138 - void addFloatImageInt(const QPixmap &img);
1.139
1.140 public:
1.141 - bool isDefault(); //!< true, if map is still the empty default map
1.142 - bool hasChanged(); //!< true, if something has changed and is not saved yet
1.143 - void setChanged(); //!< called from TextEditor via LinkableMapObj
1.144 - void closeMap(); //!< Closes the map
1.145 -
1.146 - /*! \brief Sets filepath, filename and mapname
1.147 -
1.148 - If the filepath is "/home/tux/map.xml", then the filename will be set
1.149 - to map.xml. The destname is needed for vymLinks, pointing to another map.
1.150 - The destname holds the real name of the file, after it has been compressed, e.g. "map.vym"
1.151 - */
1.152 -
1.153 - /*! \brief Set File path
1.154 -
1.155 - The destname is needed to construct the references between maps
1.156 - */
1.157 - void setFilePath (QString filepath,QString destname);
1.158 - void setFilePath (QString); //!< Overloaded for convenience
1.159 - QString getFilePath (); //!< Full path e.g. "/home/tux/map.xml"
1.160 - QString getFileName (); //!< e.g. "map.xml"
1.161 - QString getMapName (); //!< e.g. "map"
1.162 - QString getDestPath (); //!< e.g. "/home/tux/map.vym"
1.163 -
1.164 - /*! \brief Load map
1.165 -
1.166 - The data is read from file. Depending on LoadMode the current
1.167 - selection gets replaced by data or the data is appended.
1.168 - */
1.169 - ErrorCode load (QString, const LoadMode &, const FileType& ); // newmap, import/replace selection
1.170 -public:
1.171 - /*! \brief Save the map to file */
1.172 - ErrorCode save(const SaveMode &);
1.173 - /* FIXME no needed any longer
1.174 - void setZipped(bool); //!< Set or unset compression of map with zip save map zipped
1.175 - bool saveZipped(); //!< True, if file will be saved zipped
1.176 - */
1.177 void print(); //!< Print the map
1.178 void setAntiAlias (bool); //!< Set or unset antialiasing
1.179 void setSmoothPixmap(bool); //!< Set or unset smoothing of pixmaps
1.180 -private:
1.181 - QPixmap getPixmap();
1.182 - void setHideTmpMode (HideTmpMode); // temporary hide stuff
1.183 - HideTmpMode getHideTmpMode(); // temporary hide stuff
1.184 public:
1.185 - /*! Set or unset temporary hiding of objects during export */
1.186 - void setExportMode (bool);
1.187 + void toggleStandardFlag(QString);
1.188
1.189 - /*! Export as ASCII text to file */
1.190 - void exportASCII (QString fname="",bool askForName=true);
1.191 + void updateSelection(); // update geometry of selection
1.192
1.193 - /*! Save as image */
1.194 - void exportImage (QString fname="",bool askForName=true,QString format="PNG");
1.195 -
1.196 - /*! Export as OpenOfficeOrg presentation */
1.197 - void exportOOPresentation(const QString &,const QString &);
1.198 -
1.199 - /*! Export as XHTML to directory */
1.200 - void exportXHTML(const QString& dir="", bool askForName=true);
1.201 -
1.202 - /*! Export as XTML to directory */
1.203 - void exportXML(QString dir="", bool askForName=true);
1.204 -
1.205 - void clear(); //!< Clear map
1.206 - void copy(); //!< Copy to clipboard
1.207 - void redo(); //!< Redo last action
1.208 - bool isRedoAvailable(); //!< True, if redo is available
1.209 - void undo(); //!< Undo last action
1.210 - bool isUndoAvailable(); //!< True, if undo is available
1.211 - void gotoHistoryStep (int); //!< Goto a specifig step in history
1.212 -private:
1.213 - void addMapReplaceInt(const QString & undoSel, const QString & path);
1.214 - void addMapInsertInt (const QString & path, int pos);
1.215 - void pasteNoSave(const int &n); //!< paste clipboard to branch
1.216 -public:
1.217 - void paste(); //!< Paste clipboard to branch and backup
1.218 - void cut(); //!< Cut to clipboard (and copy)
1.219 - /*! \brief Move absolutly
1.220 -
1.221 - Move absolutly to (x,y).
1.222 - */
1.223 - void move (const double &x, const double &y);
1.224 - /*! \brief Move relativly
1.225 -
1.226 - Move relativly to (x,y).
1.227 - */
1.228 - void moveRel (const double &x, const double &y);
1.229 - void moveBranchUp(); //!< Move branch up
1.230 - void moveBranchDown(); //!< Move branch down
1.231 - void sortChildren(); //!< Sort children lexically
1.232 -private:
1.233 - void linkTo(const QString &);
1.234 -public:
1.235 - QString getHeading (bool &ok,QPoint &p); //!< Get heading, ok if selection is branch
1.236 - void setHeading(const QString &); //!< Set heading of branch
1.237 -private:
1.238 - void setHeadingInt(const QString &);
1.239 - void setVymLinkInt(const QString &); // Set vymLink for selection
1.240 - /*! \brief Add new mapcenter
1.241 -
1.242 - Disclaimer: Still experimental, not fully supported.
1.243 - */
1.244 -public:
1.245 - BranchObj* addMapCenter();
1.246 -
1.247 - /*! \brief Add new branch
1.248 -
1.249 - Depending on num the new branch is created
1.250 -
1.251 - -3 above selection as child of selections parent
1.252 - -2 as child of selection
1.253 - -1 below selection as child of selections parent
1.254 - 0..n insert at a specific position in selections parent
1.255 - (needed for free relinking)
1.256 - */
1.257 -private:
1.258 - BranchObj* addNewBranchInt(int); // pos allows to add above/below selection
1.259 -public:
1.260 - /*! \Add new branch
1.261 -
1.262 - Depending on num the new branch is created
1.263 - -1 above selection
1.264 - 0 as child of selection
1.265 - 1 below selection
1.266 - */
1.267 - BranchObj* addNewBranch(int pos);
1.268 - BranchObj* addNewBranchBefore(); //!< Insert branch between selection and its parent
1.269 - void deleteSelection(); //!< Delete selection
1.270 - LinkableMapObj* getSelection(); //!< Returns selection
1.271 - BranchObj* getSelectedBranch(); // returns selected branch or NULL
1.272 - FloatImageObj* getSelectedFloatImage(); // returns selected branch or NULL
1.273 - void unselect(); // before changing current noteedit
1.274 - void reselect(); // after changing current noteedit
1.275 - bool select(const QString &); // Select by string
1.276 - bool select(LinkableMapObj *lmo); // Select by pointer
1.277 - QString getSelectString();
1.278 -private:
1.279 - void selectInt(LinkableMapObj*);
1.280 - void selectNextBranchInt(); // Increment number of branch
1.281 - void selectPrevBranchInt(); // Decrement number of branch
1.282 -public:
1.283 - void selectUpperBranch();
1.284 - void selectLowerBranch();
1.285 - void selectLeftBranch();
1.286 - void selectRightBranch();
1.287 - void selectFirstBranch();
1.288 - void selectLastBranch();
1.289 - void selectMapBackgroundImage();
1.290 - void setMapBackgroundImage(const QString &);
1.291 - void selectMapBackgroundColor();
1.292 - void setMapBackgroundColor(QColor);
1.293 - QColor getMapBackgroundColor();
1.294 - QColor getCurrentHeadingColor();
1.295 - void colorBranch(QColor);
1.296 - void colorSubtree(QColor);
1.297 - void toggleStandardFlag(QString);
1.298 - BranchObj* findText(QString,bool); // Find object
1.299 - void findReset(); // Reset Find
1.300 - void setURL(const QString &); // set URL
1.301 - void editURL(); // edit URL
1.302 - void editLocalURL(); // edit URL to local file
1.303 - QString getURL(); // returns URL of selection or ""
1.304 - QStringList getURLs(); // returns URLs of subtree
1.305 - void editHeading2URL(); // copy heading to URL
1.306 - void editBugzilla2URL(); // create URL to Bugzilla
1.307 - void editFATE2URL(); // create URL to FATE
1.308 - void editVymLink(); // edit link to another map
1.309 - void deleteVymLink(); // delete link to another map
1.310 - QString getVymLink(); // return path to map
1.311 - QStringList getVymLinks(); // return paths in subtree
1.312 - void setHideExport(bool); // toggle the export flag
1.313 - void toggleHideExport(); // toggle the export flag
1.314 - void deleteKeepChilds(); // remove but keep childs
1.315 - void deleteChilds(); // remove childs
1.316 - void editMapInfo(); // dialog to enter author, ...
1.317 - void ensureSelectionVisible();
1.318 - void updateSelection(); // update geometry of selection
1.319 - void updateActions(); // update e.g. format buttons
1.320 - void updateNoteFlag(); // when TextEditor changes
1.321 - void setMapAuthor (const QString &);
1.322 - void setMapComment(const QString &);
1.323 - void setMapLinkStyle (const QString &); // Set style of link
1.324 - LinkableMapObj::Style getMapLinkStyle (); // requested in LMO
1.325 - void setMapDefLinkColor(QColor); // default color of links
1.326 - void setMapLinkColorHintInt(); // color of links
1.327 - void setMapLinkColorHint(LinkableMapObj::ColorHint);// color of links
1.328 - LinkableMapObj::ColorHint getMapLinkColorHint();
1.329 - QColor getMapDefLinkColor();
1.330 - void setMapDefXLinkColor(QColor);
1.331 - QColor getMapDefXLinkColor();
1.332 - void setMapDefXLinkWidth (int);
1.333 - int getMapDefXLinkWidth();
1.334 - void toggleMapLinkColorHint(); // after changing linkStyles
1.335 - void selectMapLinkColor();
1.336 - void selectMapSelectionColor();
1.337 -private:
1.338 - void setSelectionColorInt(QColor);
1.339 -public:
1.340 - void setSelectionColor(QColor);
1.341 - QColor getSelectionColor();
1.342 - bool scrollBranch(BranchObj*);
1.343 - bool unscrollBranch(BranchObj*);
1.344 - void toggleScroll();
1.345 - void unscrollChilds();
1.346 -private:
1.347 - FloatImageObj* loadFloatImageInt (QString);
1.348 -public:
1.349 - void loadFloatImage ();
1.350 -private:
1.351 - void saveFloatImageInt (FloatImageObj*, const QString &, const QString &);
1.352 -public:
1.353 - void saveFloatImage ();
1.354 - void setFrameType(const FrameObj::FrameType &);
1.355 - void setFrameType(const QString &);
1.356 - void setFramePenColor (const QColor &);
1.357 - void setFrameBrushColor (const QColor &);
1.358 - void setFramePadding (const int &);
1.359 - void setFrameBorderWidth (const int &);
1.360 - void setIncludeImagesVer(bool);
1.361 - void setIncludeImagesHor(bool);
1.362 - void setHideLinkUnselected (bool);
1.363 - bool getHideLinkUnselected ();
1.364 -private:
1.365 - void importDirInt(BranchObj *,QDir);
1.366 - void importDirInt(const QString&);
1.367 -public:
1.368 - void importDir();
1.369 - void followXLink (int);
1.370 - void editXLink (int);
1.371 AttributeTable* attributeTable();
1.372 void testFunction1(); // just testing new stuff
1.373 void testFunction2(); // just testing new stuff
1.374 // set /mainwindo/showTestMenu=true...
1.375
1.376 +public slots:
1.377 + void editHeading();
1.378 + void editHeadingFinished();
1.379 +private:
1.380 + bool editingHeading;
1.381 + QLineEdit *lineEdit;
1.382 +
1.383 protected:
1.384 virtual void contextMenuEvent ( QContextMenuEvent *e );
1.385 virtual void keyPressEvent(QKeyEvent*);
1.386 @@ -382,39 +58,13 @@
1.387 void dropEvent (QDropEvent *);
1.388
1.389
1.390 -protected:
1.391 - void sendSelection();
1.392 -
1.393 -public:
1.394 - void newServer();
1.395 - void connectToServer();
1.396 -
1.397 -private slots:
1.398 - void newClient();
1.399 - void sendData(const QString &s);
1.400 - void readData();
1.401 - void displayNetworkError (QAbstractSocket::SocketError);
1.402 -
1.403 - void autosave ();
1.404 - void fileChanged();
1.405 -
1.406 private:
1.407 - State state; // State of MapEditor
1.408 QGraphicsScene *mapScene;
1.409 VymModel *model; // Vym Map, includding several mapCenters
1.410 - QTimer *autosaveTimer;
1.411 - QTimer *fileChangedTimer;
1.412 - QDateTime fileChangedTime;
1.413
1.414 bool adjustCanvasRequested; // collect requests until end of user event
1.415 BranchObj *editingBO; // entering Text into BO
1.416
1.417 - QColor defLinkColor; // default color for links
1.418 - QColor defXLinkColor; // default color for xlinks
1.419 - int defXLinkWidth; // default width for xlinks
1.420 - LinkableMapObj::ColorHint linkcolorhint;// use heading color or own color
1.421 - LinkableMapObj::Style linkstyle; // default style for links
1.422 -
1.423 QCursor HandOpenCursor; // cursor while moving canvas view
1.424 QCursor PickColorCursor; // cursor while picking color
1.425 QCursor CopyCursor; // cursor while picking color
1.426 @@ -424,11 +74,7 @@
1.427 bool copyingObj; // true while creating a link
1.428 XLinkObj* tmpXLink;
1.429
1.430 - Selection xelection;
1.431 -
1.432 - QString latestSelection; // select string of latest added object
1.433 -
1.434 - MapObj* movingObj; // moving a MapObj
1.435 + MapObj* movingObj; // moving a MapObj
1.436 MapObj* linkingObj_src; // part of a link
1.437 QPointF movingObj_orgPos; // org. pos of mouse before move
1.438 QPointF movingObj_orgRelPos; // org. relative pos of mouse before move
1.439 @@ -436,58 +82,19 @@
1.440 QPointF movingCont_start; // inital pos of moving Content or
1.441 QPointF movingVec; // how far has Content moved
1.442
1.443 - QPointF contextMenuPos; // position where context event was triggered
1.444 + QPointF contextMenuPos; // position where context event was triggered
1.445
1.446 QPrinter* printer; // Printing
1.447
1.448 - bool mapDefault; // Flag if map is untouched
1.449 - bool mapChanged; // Flag if undo is possible
1.450 - bool mapUnsaved; // Flag if map should be saved
1.451 -
1.452 - Parser parser; // Parser stuff for scripting
1.453 -
1.454 AttributeTable *attrTable;
1.455
1.456 bool printFrame; // Print frame around map
1.457 bool printFooter; // Print footer below map
1.458
1.459 - bool zipped; // should map be zipped
1.460 - static int mapNum; // unique number for Editor
1.461 - FileType fileType; // type of file, e.g. vym, freemind...
1.462 - QString fileName; // short name of file (for tab)
1.463 - QString filePath; // path to file which will be saved
1.464 - QString fileDir; // dir where file is saved
1.465 - QString destPath; // path to .vym file (needed for vymlinks)
1.466 - QString mapName; // fileName without ".vym"
1.467 + QPoint exportOffset; // set before export, used in save
1.468
1.469 - QString tmpMapDir; // tmp directory with undo history
1.470 - QString histPath; // Path to history file
1.471 - SimpleSettings undoSet; // undo/redo commands, saved in histPath
1.472 - int stepsTotal; // total number of steps (undos+redos)
1.473 - int curStep; // Current step in history (ring buffer)
1.474 - int curClipboard; // number of history step, which is the current clipboard
1.475 - int redosAvail; // Available number of redo steps
1.476 - int undosAvail; // Available number of undo steps
1.477 - bool blockReposition; // block while load or undo
1.478 - bool blockSaveState; // block while load or undo
1.479 -
1.480 - BranchObj* itFind; // next object in find process
1.481 - bool EOFind; // true, if search failed
1.482 -
1.483 - QPoint exportOffset; // set before export, used in save
1.484 - HideTmpMode hidemode; // true while exporting to hide some stuff
1.485 -
1.486 - // Network connections **Experimental**
1.487 - NetState netstate; // offline, client, server
1.488 - QTcpServer *tcpServer; // Act as server in conference mode (experimental)
1.489 - QList <QTcpSocket*> clientList; // List of connected clients
1.490 - quint16 sendCounter; // Increased with every sent command
1.491 -
1.492 - QTcpSocket *clientSocket; // socket of this client
1.493 - QString server; // server address of this client
1.494 - int port; // server port of this client
1.495 - void displayClientError(QAbstractSocket::SocketError socketError);
1.496 -
1.497 + Selection xelection; // FIXME only here to get rid of some gcc errors...
1.498 + QString getName(const LinkableMapObj*); // FIXME see above, renamed to getObjectName in VymModel...
1.499 };
1.500 #endif
1.501