2008-07-03 21:50:57 +03:00
|
|
|
// -*- Mode: C++ ; indent-tabs-mode: t -*-
|
|
|
|
/* This file is part of Patchage.
|
|
|
|
* Copyright (C) 2008 Nedko Arnaudov <nedko@arnaudov.name>
|
|
|
|
*
|
|
|
|
* Patchage is free software; you can redistribute it and/or modify it under the
|
|
|
|
* terms of the GNU General Public License as published by the Free Software
|
|
|
|
* Foundation; either version 2 of the License, or (at your option) any later
|
|
|
|
* version.
|
|
|
|
*
|
|
|
|
* Patchage is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common.hpp"
|
|
|
|
#include "project.hpp"
|
2008-07-04 23:53:03 +03:00
|
|
|
#include "lash_proxy.hpp"
|
2008-07-05 21:52:35 +03:00
|
|
|
#include "lash_client.hpp"
|
2008-07-06 19:44:47 +03:00
|
|
|
//#include "globals.hpp"
|
2008-07-03 21:50:57 +03:00
|
|
|
|
|
|
|
struct project_impl
|
|
|
|
{
|
2008-07-04 23:53:03 +03:00
|
|
|
lash_proxy * lash_ptr;
|
2008-07-03 21:50:57 +03:00
|
|
|
string name;
|
2008-07-05 02:04:31 +03:00
|
|
|
string description;
|
|
|
|
string notes;
|
2008-07-04 01:54:41 +03:00
|
|
|
bool modified_status;
|
2008-07-05 21:52:35 +03:00
|
|
|
list<shared_ptr<lash_client> > clients;
|
2008-07-03 21:50:57 +03:00
|
|
|
};
|
|
|
|
|
2008-07-03 23:27:11 +03:00
|
|
|
project::project(
|
2008-07-04 23:53:03 +03:00
|
|
|
lash_proxy * lash_ptr,
|
|
|
|
const string& name)
|
2008-07-03 21:50:57 +03:00
|
|
|
{
|
2008-07-05 00:51:34 +03:00
|
|
|
lash_loaded_project_properties properties;
|
|
|
|
|
|
|
|
lash_ptr->get_loaded_project_properties(name, properties);
|
|
|
|
|
2008-07-03 21:50:57 +03:00
|
|
|
_impl_ptr = new project_impl;
|
2008-07-04 23:53:03 +03:00
|
|
|
_impl_ptr->lash_ptr = lash_ptr;
|
2008-07-03 23:27:11 +03:00
|
|
|
_impl_ptr->name = name;
|
2008-07-05 00:51:34 +03:00
|
|
|
|
2008-07-05 02:04:31 +03:00
|
|
|
_impl_ptr->description = properties.description;
|
|
|
|
_impl_ptr->notes = properties.notes;
|
2008-07-05 00:51:34 +03:00
|
|
|
_impl_ptr->modified_status = properties.modified_status;
|
2008-07-06 19:44:47 +03:00
|
|
|
|
|
|
|
//g_app->info_msg("project created");
|
2008-07-03 21:50:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
project::~project()
|
|
|
|
{
|
|
|
|
delete _impl_ptr;
|
2008-07-06 19:44:47 +03:00
|
|
|
//g_app->info_msg("project destroyed");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
project::clear()
|
|
|
|
{
|
|
|
|
shared_ptr<lash_client> client_ptr;
|
|
|
|
|
|
|
|
while (!_impl_ptr->clients.empty())
|
|
|
|
{
|
|
|
|
client_ptr = _impl_ptr->clients.front();
|
|
|
|
_impl_ptr->clients.pop_front();
|
|
|
|
_signal_client_removed.emit(client_ptr);
|
|
|
|
}
|
2008-07-03 21:50:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-07-03 23:27:11 +03:00
|
|
|
project::get_name(
|
|
|
|
string& name)
|
|
|
|
{
|
|
|
|
name = _impl_ptr->name;
|
|
|
|
}
|
|
|
|
|
2008-07-03 23:50:32 +03:00
|
|
|
void
|
2008-07-04 23:53:03 +03:00
|
|
|
project::on_name_changed(
|
2008-07-03 23:50:32 +03:00
|
|
|
const string& name)
|
|
|
|
{
|
|
|
|
_impl_ptr->name = name;
|
2008-07-04 02:14:25 +03:00
|
|
|
_signal_renamed.emit();
|
2008-07-03 23:50:32 +03:00
|
|
|
}
|
|
|
|
|
2008-07-03 23:27:11 +03:00
|
|
|
void
|
2008-07-05 02:04:31 +03:00
|
|
|
project::get_description(
|
|
|
|
string& description)
|
2008-07-03 21:50:57 +03:00
|
|
|
{
|
2008-07-05 02:04:31 +03:00
|
|
|
description = _impl_ptr->description;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
project::get_notes(
|
|
|
|
string& notes)
|
|
|
|
{
|
|
|
|
notes = _impl_ptr->notes;
|
2008-07-03 21:50:57 +03:00
|
|
|
}
|
2008-07-04 01:54:41 +03:00
|
|
|
|
|
|
|
bool
|
|
|
|
project::get_modified_status()
|
|
|
|
{
|
|
|
|
return _impl_ptr->modified_status;
|
|
|
|
}
|
2008-07-04 02:28:39 +03:00
|
|
|
|
2008-07-05 21:52:35 +03:00
|
|
|
void
|
|
|
|
project::get_clients(
|
|
|
|
list<shared_ptr<lash_client> >& clients)
|
|
|
|
{
|
|
|
|
clients = _impl_ptr->clients;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
project::on_client_added(
|
|
|
|
shared_ptr<lash_client> client_ptr)
|
|
|
|
{
|
|
|
|
_impl_ptr->clients.push_back(client_ptr);
|
|
|
|
_signal_client_added.emit(client_ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
project::on_client_removed(
|
|
|
|
const string& id)
|
|
|
|
{
|
|
|
|
shared_ptr<lash_client> client_ptr;
|
|
|
|
string temp_id;
|
|
|
|
|
|
|
|
for (list<shared_ptr<lash_client> >::iterator iter = _impl_ptr->clients.begin(); iter != _impl_ptr->clients.end(); iter++)
|
|
|
|
{
|
|
|
|
client_ptr = *iter;
|
|
|
|
client_ptr->get_id(temp_id);
|
|
|
|
|
|
|
|
if (temp_id == id)
|
|
|
|
{
|
|
|
|
_impl_ptr->clients.erase(iter);
|
|
|
|
_signal_client_removed.emit(client_ptr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-01 12:32:17 +03:00
|
|
|
void
|
2008-07-04 23:53:03 +03:00
|
|
|
project::on_modified_status_changed(
|
2008-07-04 02:28:39 +03:00
|
|
|
bool modified_status)
|
|
|
|
{
|
|
|
|
_impl_ptr->modified_status = modified_status;
|
|
|
|
_signal_modified_status_changed.emit();
|
|
|
|
}
|
2008-07-04 23:53:03 +03:00
|
|
|
|
2008-07-05 03:18:21 +03:00
|
|
|
void
|
|
|
|
project::on_description_changed(
|
|
|
|
const string& description)
|
|
|
|
{
|
|
|
|
_impl_ptr->description = description;
|
|
|
|
_signal_description_changed.emit();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
project::on_notes_changed(
|
|
|
|
const string& notes)
|
|
|
|
{
|
|
|
|
_impl_ptr->notes = notes;
|
|
|
|
_signal_notes_changed.emit();
|
|
|
|
}
|
|
|
|
|
2008-07-04 23:53:03 +03:00
|
|
|
void
|
|
|
|
project::do_rename(
|
|
|
|
const string& name)
|
|
|
|
{
|
2008-07-05 02:04:31 +03:00
|
|
|
if (_impl_ptr->name != name)
|
|
|
|
{
|
|
|
|
_impl_ptr->lash_ptr->project_rename(_impl_ptr->name, name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
project::do_change_description(
|
|
|
|
const string& description)
|
|
|
|
{
|
|
|
|
if (_impl_ptr->description != description)
|
|
|
|
{
|
|
|
|
_impl_ptr->lash_ptr->project_set_description(_impl_ptr->name, description);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
project::do_change_notes(
|
|
|
|
const string& notes)
|
|
|
|
{
|
|
|
|
if (_impl_ptr->notes != notes)
|
|
|
|
{
|
|
|
|
_impl_ptr->lash_ptr->project_set_notes(_impl_ptr->name, notes);
|
|
|
|
}
|
2008-07-04 23:53:03 +03:00
|
|
|
}
|