~ubuntu-branches/ubuntu/raring/notecase/raring

« back to all changes in this revision

Viewing changes to src/DocAction.h

  • Committer: Bazaar Package Importer
  • Author(s): Nathan Handler
  • Date: 2008-12-21 13:09:58 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20081221130958-0ri77h0x7j1dclkq
Tags: 1.9.8-0ubuntu1
New upstream release (LP: #307752)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
////////////////////////////////////////////////////////////////////////////
2
 
// NoteCase notes manager project <http://notecase.sf.net>
3
 
//
4
 
// This code is licensed under BSD license.See "license.txt" for more details.
5
 
//
6
 
// File: Defines atomic action performed on NoteCase document
7
 
//               (base for Undo/Redo framework)
8
 
////////////////////////////////////////////////////////////////////////////
9
 
 
10
 
#ifndef DOCACTION_H_
11
 
#define DOCACTION_H_
12
 
 
13
 
#if _MSC_VER > 1000
14
 
#pragma once
15
 
#endif // _MSC_VER > 1000
16
 
 
17
 
#include "lib/DocActionBase.h"
18
 
#include "lib/NoteDocument.h"
19
 
 
20
 
#if _MSC_VER > 1000
21
 
  #pragma warning(disable: 4786)
22
 
#endif
23
 
#include <string>
24
 
 
25
 
//TOFIX separate class for each action?
26
 
 
27
 
//define all atomic actions in document editing
28
 
#define ACT_UNDEFINED   0
29
 
#define ACT_TEXT_INSERT 1
30
 
#define ACT_TEXT_DELETE 2
31
 
#define ACT_NODE_INSERT 3
32
 
#define ACT_NODE_RENAME 4
33
 
#define ACT_TREE_DELETE 5       //delete branch of nodes
34
 
#define ACT_TREE_MOVE   6       //move branch of nodes
35
 
#define ACT_TREE_IMPORT 7       //multiple nodes inserted
36
 
#define ACT_TREE_DND    8       //drag and drop (move branch of nodes) TOFIX merge with ACT_TREE_MOVE algorithm
37
 
#define ACT_TEXT_REPLACE 9      //replace text operation
38
 
#define ACT_TEXT_LINK_ADD       10
39
 
#define ACT_TEXT_LINK_REMOVE    11
40
 
 
41
 
//define move directions
42
 
#define MOVE_LEFT       1
43
 
#define MOVE_RIGHT      2
44
 
#define MOVE_UP         3
45
 
#define MOVE_DOWN       4
46
 
 
47
 
 
48
 
class DocAction : public DocActionBase
49
 
{
50
 
public:
51
 
        DocAction();
52
 
        virtual ~DocAction();
53
 
 
54
 
        virtual void Exec(bool bInteractive = false);
55
 
        virtual void Undo();
56
 
        //virtual void std::string GetDescription();
57
 
 
58
 
        void SetType(int nType){ m_nType = nType; }
59
 
        int  GetType(){ return m_nType; }
60
 
 
61
 
protected:
62
 
        void DoTextInsert();
63
 
        void DoTextDelete();
64
 
        void DoTreeInsert();
65
 
        void DoTreeDelete();
66
 
        void DoNodeRename();
67
 
        void DoNodeUnrename();
68
 
        void DoTreeMove();
69
 
        void DoTreeUnmove();
70
 
        void DoTreeImport();
71
 
        void DoTreeUnimport();
72
 
        void DoTreeDND(bool bForward = false);
73
 
        void DoTextReplace();
74
 
        void DoTextUnreplace();
75
 
        void DoLinkAdd();
76
 
        void DoLinkRemove();
77
 
        void DoTreeFinished();
78
 
        void DoTreeUnfinished();
79
 
 
80
 
protected:
81
 
        int     m_nType;        //type of action, see defines above
82
 
        bool m_bUndo;
83
 
        bool m_bInteractive;
84
 
 
85
 
public:
86
 
        //node text editing
87
 
        std::string     m_strNodeText;  //store inserted/deleted text
88
 
        int m_nTextStartPos;            //text offset inside the node
89
 
        bool m_bSelected;               //was text in case selected
90
 
 
91
 
        //additional data for node text deleting
92
 
        std::vector<PixInfo> m_lstPictures;
93
 
        std::vector<FmtInfo> m_lstFmt;
94
 
        LinkInfoList m_lstLinks;
95
 
 
96
 
        // node renaming/inserting/deleting
97
 
        int m_nNodeIndex;                       //node position (placement)
98
 
        int m_nNodeSibling;                     //sibling index (index in the )
99
 
        int m_nNodeID;                          //node ID
100
 
        int m_nNodePID;                         //node ID
101
 
        std::string     m_strNodeNameNew;       //store new node name (for rename/redo only)
102
 
        std::string     m_strNodeNameOld;       //store old node name (for rename/undo only)
103
 
 
104
 
        //replace info
105
 
        std::string     m_strFind;              //
106
 
        std::string     m_strReplace;   //
107
 
        int  m_nOffset;
108
 
        bool m_bNodeTitle;
109
 
 
110
 
        //additional data for node moving
111
 
        int m_nMoveDirection;
112
 
 
113
 
        //node DnD
114
 
        int m_nNewNodeID;
115
 
        int m_nNodeNewPID;                      //node position (placement)
116
 
        int m_nNodeNewSibling;          //sibling index (index in the )
117
 
 
118
 
        //data for link info
119
 
        int  m_nLinkOffset;
120
 
        std::string     m_strLinkTitle;
121
 
        std::string     m_strLinkUrl;
122
 
        int  m_nLinkNodeID;
123
 
 
124
 
        NoteDocument m_objSubTree;      //when working with nodes
125
 
};
126
 
 
127
 
#endif // DOCACTION_H_
 
1
////////////////////////////////////////////////////////////////////////////
 
2
// NoteCase notes manager project <http://notecase.sf.net>
 
3
//
 
4
// This code is licensed under BSD license.See "license.txt" for more details.
 
5
//
 
6
// File: Defines atomic action performed on NoteCase document
 
7
//               (base for Undo/Redo framework)
 
8
////////////////////////////////////////////////////////////////////////////
 
9
 
 
10
#ifndef DOCACTION_H_
 
11
#define DOCACTION_H_
 
12
 
 
13
#if _MSC_VER > 1000
 
14
#pragma once
 
15
#endif // _MSC_VER > 1000
 
16
 
 
17
#include "lib/DocActionBase.h"
 
18
#include "lib/NoteDocument.h"
 
19
 
 
20
#if _MSC_VER > 1000
 
21
  #pragma warning(disable: 4786)
 
22
#endif
 
23
#include <string>
 
24
 
 
25
//TOFIX separate class for each action?
 
26
 
 
27
//define all atomic actions in document editing
 
28
#define ACT_UNDEFINED   0
 
29
#define ACT_TEXT_INSERT 1
 
30
#define ACT_TEXT_DELETE 2
 
31
#define ACT_NODE_INSERT 3
 
32
#define ACT_NODE_RENAME 4
 
33
#define ACT_TREE_DELETE 5       //delete branch of nodes
 
34
#define ACT_TREE_MOVE   6       //move branch of nodes
 
35
#define ACT_TREE_IMPORT 7       //multiple nodes inserted
 
36
#define ACT_TREE_DND    8       //drag and drop (move branch of nodes) TOFIX merge with ACT_TREE_MOVE algorithm
 
37
#define ACT_TEXT_REPLACE 9      //replace text operation
 
38
#define ACT_TEXT_LINK_ADD       10
 
39
#define ACT_TEXT_LINK_REMOVE    11
 
40
 
 
41
//define move directions
 
42
#define MOVE_LEFT       1
 
43
#define MOVE_RIGHT      2
 
44
#define MOVE_UP         3
 
45
#define MOVE_DOWN       4
 
46
 
 
47
 
 
48
class DocAction : public DocActionBase
 
49
{
 
50
public:
 
51
        DocAction();
 
52
        virtual ~DocAction();
 
53
 
 
54
        virtual void Exec(bool bInteractive = false);
 
55
        virtual void Undo();
 
56
        //virtual void std::string GetDescription();
 
57
 
 
58
        void SetType(int nType){ m_nType = nType; }
 
59
        int  GetType(){ return m_nType; }
 
60
 
 
61
protected:
 
62
        void DoTextInsert();
 
63
        void DoTextDelete();
 
64
        void DoTreeInsert();
 
65
        void DoTreeDelete();
 
66
        void DoNodeRename();
 
67
        void DoNodeUnrename();
 
68
        void DoTreeMove();
 
69
        void DoTreeUnmove();
 
70
        void DoTreeImport();
 
71
        void DoTreeUnimport();
 
72
        void DoTreeDND(bool bForward = false);
 
73
        void DoTextReplace();
 
74
        void DoTextUnreplace();
 
75
        void DoLinkAdd();
 
76
        void DoLinkRemove();
 
77
        void DoTreeFinished();
 
78
        void DoTreeUnfinished();
 
79
 
 
80
protected:
 
81
        int     m_nType;        //type of action, see defines above
 
82
        bool m_bUndo;
 
83
        bool m_bInteractive;
 
84
 
 
85
public:
 
86
        //node text editing
 
87
        std::string     m_strNodeText;  //store inserted/deleted text
 
88
        int m_nTextStartPos;            //text offset inside the node
 
89
        bool m_bSelected;               //was text in case selected
 
90
 
 
91
        //additional data for node text deleting
 
92
        std::vector<PixInfo> m_lstPictures;
 
93
        std::vector<FmtInfo> m_lstFmt;
 
94
        LinkInfoList m_lstLinks;
 
95
 
 
96
        // node renaming/inserting/deleting
 
97
        int m_nNodeIndex;                       //node position (placement)
 
98
        int m_nNodeSibling;                     //sibling index (index in the )
 
99
        int m_nNodeID;                          //node ID
 
100
        int m_nNodePID;                         //node ID
 
101
        std::string     m_strNodeNameNew;       //store new node name (for rename/redo only)
 
102
        std::string     m_strNodeNameOld;       //store old node name (for rename/undo only)
 
103
 
 
104
        //replace info
 
105
        std::string     m_strFind;              //
 
106
        std::string     m_strReplace;   //
 
107
        int  m_nOffset;
 
108
        bool m_bNodeTitle;
 
109
 
 
110
        //additional data for node moving
 
111
        int m_nMoveDirection;
 
112
 
 
113
        //node DnD
 
114
        int m_nNewNodeID;
 
115
        int m_nNodeNewPID;                      //node position (placement)
 
116
        int m_nNodeNewSibling;          //sibling index (index in the )
 
117
 
 
118
        //data for link info
 
119
        int  m_nLinkOffset;
 
120
        std::string     m_strLinkTitle;
 
121
        std::string     m_strLinkUrl;
 
122
        int  m_nLinkNodeID;
 
123
 
 
124
        NoteDocument m_objSubTree;      //when working with nodes
 
125
};
 
126
 
 
127
#endif // DOCACTION_H_