1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
3 * LADI Session Handler (ladish)
5 * Copyright (C) 2008 Nedko Arnaudov <nedko@arnaudov.name>
7 **************************************************************************
8 * This file contains implementation of the project class
9 **************************************************************************
11 * LADI Session Handler is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * LADI Session Handler is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
23 * or write to the Free Software Foundation, Inc.,
24 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
28 #include "project.hpp"
29 #include "lash_proxy.hpp"
30 #include "lash_client.hpp"
31 //#include "globals.hpp"
35 lash_proxy
* lash_ptr
;
37 std::string description
;
40 std::list
<boost::shared_ptr
<lash_client
> > clients
;
44 lash_proxy
* lash_ptr
,
45 const std::string
& name
)
47 lash_loaded_project_properties properties
;
49 lash_ptr
->get_loaded_project_properties(name
, properties
);
51 _impl_ptr
= new project_impl
;
52 _impl_ptr
->lash_ptr
= lash_ptr
;
53 _impl_ptr
->name
= name
;
55 _impl_ptr
->description
= properties
.description
;
56 _impl_ptr
->notes
= properties
.notes
;
57 _impl_ptr
->modified_status
= properties
.modified_status
;
59 //g_app->info_msg("project created");
65 //g_app->info_msg("project destroyed");
71 boost::shared_ptr
<lash_client
> client_ptr
;
73 while (!_impl_ptr
->clients
.empty())
75 client_ptr
= _impl_ptr
->clients
.front();
76 _impl_ptr
->clients
.pop_front();
77 _signal_client_removed
.emit(client_ptr
);
85 name
= _impl_ptr
->name
;
89 project::on_name_changed(
90 const std::string
& name
)
92 _impl_ptr
->name
= name
;
93 _signal_renamed
.emit();
97 project::get_description(
98 std::string
& description
)
100 description
= _impl_ptr
->description
;
107 notes
= _impl_ptr
->notes
;
111 project::get_modified_status()
113 return _impl_ptr
->modified_status
;
117 project::get_clients(
118 std::list
<boost::shared_ptr
<lash_client
> >& clients
)
120 clients
= _impl_ptr
->clients
;
124 project::on_client_added(
125 boost::shared_ptr
<lash_client
> client_ptr
)
127 _impl_ptr
->clients
.push_back(client_ptr
);
128 _signal_client_added
.emit(client_ptr
);
132 project::on_client_removed(
133 const std::string
& id
)
135 boost::shared_ptr
<lash_client
> client_ptr
;
138 for (std::list
<boost::shared_ptr
<lash_client
> >::iterator iter
= _impl_ptr
->clients
.begin(); iter
!= _impl_ptr
->clients
.end(); iter
++)
141 client_ptr
->get_id(temp_id
);
145 _impl_ptr
->clients
.erase(iter
);
146 _signal_client_removed
.emit(client_ptr
);
153 project::on_modified_status_changed(
154 bool modified_status
)
156 _impl_ptr
->modified_status
= modified_status
;
157 _signal_modified_status_changed
.emit();
161 project::on_description_changed(
162 const std::string
& description
)
164 _impl_ptr
->description
= description
;
165 _signal_description_changed
.emit();
169 project::on_notes_changed(
170 const std::string
& notes
)
172 _impl_ptr
->notes
= notes
;
173 _signal_notes_changed
.emit();
178 const std::string
& name
)
180 if (_impl_ptr
->name
!= name
)
182 _impl_ptr
->lash_ptr
->project_rename(_impl_ptr
->name
, name
);
187 project::do_change_description(
188 const std::string
& description
)
190 if (_impl_ptr
->description
!= description
)
192 _impl_ptr
->lash_ptr
->project_set_description(_impl_ptr
->name
, description
);
197 project::do_change_notes(
198 const std::string
& notes
)
200 if (_impl_ptr
->notes
!= notes
)
202 _impl_ptr
->lash_ptr
->project_set_notes(_impl_ptr
->name
, notes
);