patchbay interface
[ladish.git] / gui / project.cpp
blob21223ee6de95c57b31a81c6248a5d4deb9187dff
1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
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.
27 #include "common.h"
28 #include "project.hpp"
29 #include "lash_proxy.hpp"
30 #include "lash_client.hpp"
31 //#include "globals.hpp"
33 struct project_impl
35 lash_proxy * lash_ptr;
36 std::string name;
37 std::string description;
38 std::string notes;
39 bool modified_status;
40 std::list<boost::shared_ptr<lash_client> > clients;
43 project::project(
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");
62 project::~project()
64 delete _impl_ptr;
65 //g_app->info_msg("project destroyed");
68 void
69 project::clear()
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);
81 void
82 project::get_name(
83 std::string& name)
85 name = _impl_ptr->name;
88 void
89 project::on_name_changed(
90 const std::string& name)
92 _impl_ptr->name = name;
93 _signal_renamed.emit();
96 void
97 project::get_description(
98 std::string& description)
100 description = _impl_ptr->description;
103 void
104 project::get_notes(
105 std::string& notes)
107 notes = _impl_ptr->notes;
110 bool
111 project::get_modified_status()
113 return _impl_ptr->modified_status;
116 void
117 project::get_clients(
118 std::list<boost::shared_ptr<lash_client> >& clients)
120 clients = _impl_ptr->clients;
123 void
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);
131 void
132 project::on_client_removed(
133 const std::string& id)
135 boost::shared_ptr<lash_client> client_ptr;
136 std::string temp_id;
138 for (std::list<boost::shared_ptr<lash_client> >::iterator iter = _impl_ptr->clients.begin(); iter != _impl_ptr->clients.end(); iter++)
140 client_ptr = *iter;
141 client_ptr->get_id(temp_id);
143 if (temp_id == id)
145 _impl_ptr->clients.erase(iter);
146 _signal_client_removed.emit(client_ptr);
147 return;
152 void
153 project::on_modified_status_changed(
154 bool modified_status)
156 _impl_ptr->modified_status = modified_status;
157 _signal_modified_status_changed.emit();
160 void
161 project::on_description_changed(
162 const std::string& description)
164 _impl_ptr->description = description;
165 _signal_description_changed.emit();
168 void
169 project::on_notes_changed(
170 const std::string& notes)
172 _impl_ptr->notes = notes;
173 _signal_notes_changed.emit();
176 void
177 project::do_rename(
178 const std::string& name)
180 if (_impl_ptr->name != name)
182 _impl_ptr->lash_ptr->project_rename(_impl_ptr->name, name);
186 void
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);
196 void
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);