introtduction of the actionmanager
[silence:silence.git] / src / controller.cpp
1 /*
2  * Silence
3  *
4  * Copyright (C) 2009, 2010 Manuel Unglaub <m.unglaub@gmail.com>
5  *
6  * This file is part of Silence.
7  *
8  * Silence is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, version GPLv2 only of the License.
11  *
12  * Silence is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16
17  * You should have received a copy of the GNU General Public License
18  * along with Silence.  If not, see <http://www.gnu.org/licenses/>.
19  */
20
21 #include "src/controller.h"
22
23 Controller* Controller::controller = 0;
24
25 Controller::Controller()
26 {
27         mainwindow = 0;
28         contentview = 0;
29         welcomeview = 0;
30         textedit = 0;
31         richtextedit = 0;
32         customcontentview = 0;
33         actionCollection = 0;
34         infosidebar = 0;
35         treeview = 0;
36         datastore = 0;
37         statusbar = 0;
38         nodepropertywidget = 0;
39         navigationsidebar = 0;
40         actionmanager = 0;
41 }
42
43 Controller::~Controller()
44 {
45         delete datastore;
46
47         if (welcomeview)
48                 delete welcomeview;
49         if (textedit)
50                 delete textedit;
51         if (richtextedit)
52                 delete richtextedit;
53         if (customcontentview)
54                 delete customcontentview;
55 }
56
57 Controller* Controller::create()
58 {
59         if (controller == 0)
60                 controller = new Controller;
61         return controller;
62 }
63
64 void Controller::setMainWindow(MainWindow* mainwindow)
65 {
66         this->mainwindow = mainwindow;
67 }
68
69 MainWindow* Controller::getMainWindow()
70 {
71         return mainwindow;
72 }
73
74 void Controller::setContentView(ContentView* contentview)
75 {
76         this->contentview = contentview;
77 }
78
79 ContentView* Controller::getContentView() const
80 {
81         return contentview;
82 }
83
84 WelcomeView* Controller::getWelcomeView()
85 {
86         if (welcomeview == 0)
87                 welcomeview = new WelcomeView;
88         return welcomeview;
89 }
90
91 TextEdit* Controller::getTextEdit()
92 {
93         if (textedit == 0)
94                 textedit = new TextEdit(actionCollection);
95         return textedit;
96 }
97
98 RichTextEdit* Controller::getRichTextEdit()
99 {
100         if (richtextedit == 0)
101                 richtextedit = new RichTextEdit(actionCollection);
102         return richtextedit;
103 }
104
105 CustomContentView* Controller::getCustomContentView()
106 {
107         if (customcontentview == 0)
108                 customcontentview = new CustomContentView;
109         return customcontentview;
110 }
111
112 void Controller::setActionCollection(KActionCollection *actionCollection)
113 {
114         this->actionCollection = actionCollection;
115 }
116
117 KActionCollection* Controller::getActionCollection() const
118 {
119         return actionCollection;
120 }
121
122 void Controller::setActionManager(ActionManager *actionmanager)
123 {
124         this->actionmanager = actionmanager;
125 }
126
127 ActionManager* Controller::getActionManager() const
128 {
129         return actionmanager;
130 }
131
132 void Controller::setInfoSidebar(InfoSidebar* infosidebar)
133 {
134         this->infosidebar = infosidebar;
135 }
136
137 InfoSidebar* Controller::getInfoSidebar() const
138 {
139         return infosidebar;
140 }
141
142 void Controller::setSearchNodeSidebar(SearchNodeSidebar* searchsidebar)
143 {
144         this->searchsidebar = searchsidebar;
145 }
146
147 SearchNodeSidebar* Controller::getSearchNodeSidebar() const
148 {
149         return searchsidebar;
150 }
151
152 void Controller::setTreeView(TreeView* treeview)
153 {
154         this->treeview = treeview;
155 }
156
157 TreeView* Controller::getTreeView() const
158 {
159         return treeview;
160 }
161
162 AbstractDataStore* Controller::getDataStore()
163 {
164         if (datastore == 0)
165                 datastore = new XmlDataStore;
166         return datastore;
167 }
168
169 void Controller::setNodePropertyWidget(NodePropertyWidget *nodepropertywidget)
170 {
171         this->nodepropertywidget = nodepropertywidget;
172 }
173
174 NodePropertyWidget* Controller::getNodePropertyWidget() const
175 {
176         return nodepropertywidget;
177 }
178
179 void Controller::setNavigationSidebar(NavigationSidebar *navigationsidebar)
180 {
181         this->navigationsidebar = navigationsidebar;
182 }
183
184 NavigationSidebar* Controller::getNavigationSidebar() const
185 {
186         return navigationsidebar;
187 }
188
189 void Controller::setStatusBar(SiStatusBar *statusbar)
190 {
191         this->statusbar = statusbar;
192 }
193
194 SiStatusBar* Controller::getStatusBar() const
195 {
196         return statusbar;
197 }
198