1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
|
/************************************************************************
*
* Copyright (C) 2018-2024 IRCAD France
* Copyright (C) 2018-2020 IHU Strasbourg
*
* This file is part of Sight.
*
* Sight is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Sight 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Sight. If not, see <https://www.gnu.org/licenses/>.
*
***********************************************************************/
#include "ui/__/activity_view.hpp"
#include "ui/__/dialog/message.hpp"
#include <activity/validator/activity.hpp>
#include <activity/validator/base.hpp>
#include <core/com/slot.hpp>
#include <core/com/slot.hxx>
#include <core/com/slots.hxx>
#include <core/tools/date_and_time.hpp>
#include <core/tools/uuid.hpp>
#include <data/map.hpp>
#include <data/string.hpp>
#include <service/macros.hpp>
namespace sight::ui
{
const core::com::slots::key_t activity_view::LAUNCH_ACTIVITY_SLOT = "launch_activity";
//-----------------------------------------------------------------------------
activity_view::activity_view()
{
new_slot(LAUNCH_ACTIVITY_SLOT, &activity_view::launch_activity, this);
}
//------------------------------------------------------------------------------
void activity_view::configuring()
{
this->ui::service::initialize();
const config_t config = this->get_config();
sight::activity::launcher::in_out_map_t inout_map;
std::for_each(
m_data.begin(),
m_data.end(),
[&inout_map](const auto& _p)
{
const auto obj = _p.second->lock();
if(obj != nullptr)
{
inout_map.push_back(obj->get_id());
}
});
this->parse_configuration(config, inout_map);
}
//------------------------------------------------------------------------------
bool activity_view::validate_activity(data::activity::sptr _activity) const
{
bool is_valid = false;
std::string message;
std::tie(is_valid, message) = activity::launcher::validate_activity(_activity);
if(!is_valid)
{
ui::dialog::message::show(
"Activity launch",
message,
ui::dialog::message::critical
);
}
return is_valid;
}
//------------------------------------------------------------------------------
data::activity::sptr activity_view::create_main_activity() const
{
auto activity = this->activity::launcher::create_main_activity();
if(!activity)
{
ui::dialog::message::show(
"Main activity",
"The main activity " + m_main_activity_id + " can not be launched. \n"
"This activity needs parameters that cannot be defined",
ui::dialog::message::info
);
}
return activity;
}
} // namespace sight::ui
|