diff --git a/modules/gui/pymod/export_info_widget.cc b/modules/gui/pymod/export_info_widget.cc index 408f39a6662a3c81bb1dd59bb57144b0fe1a934c..8847116bc428a857166ead8482e09d16d5b94106 100644 --- a/modules/gui/pymod/export_info_widget.cc +++ b/modules/gui/pymod/export_info_widget.cc @@ -64,6 +64,8 @@ void export_InfoWidget() class_<InfoWidget, boost::noncopyable>("InfoWidget", no_init) .def("Show", &InfoWidget::show) .def("Hide", &InfoWidget::hide) + .def("Clear", &InfoWidget::Clear) + .def("RemoveSelected", &InfoWidget::RemoveSelected) .def("LogMessage", &log_message_a) .def("LogMessage", &log_message_b) .def("GetQObject",&get_py_qobject<InfoWidget>) diff --git a/modules/gui/share/CMakeLists.txt b/modules/gui/share/CMakeLists.txt index 23601130fe186234cb81d4daa21d8e2107f84a99..db9da9d437fe637435707004f5e5fcf35007247d 100644 --- a/modules/gui/share/CMakeLists.txt +++ b/modules/gui/share/CMakeLists.txt @@ -2,6 +2,7 @@ set(GUI_ICONS icons/add_icon.png icons/close_icon.png + icons/delete_icon.png icons/distance_icon.png icons/find_icon.png icons/map_icon.png diff --git a/modules/gui/share/icons/delete_icon.png b/modules/gui/share/icons/delete_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..07b57dcd7f83d499301f1f778330591ce16dee3d Binary files /dev/null and b/modules/gui/share/icons/delete_icon.png differ diff --git a/modules/gui/src/info_widget/info_widget.cc b/modules/gui/src/info_widget/info_widget.cc index 4a31d0fa293e893c36ae2ed2016a83cd335fd44f..fd582d46b75c9b64e0be64948b60b53342aa2b9e 100644 --- a/modules/gui/src/info_widget/info_widget.cc +++ b/modules/gui/src/info_widget/info_widget.cc @@ -19,9 +19,12 @@ /* Author: Stefan Scheuber */ +#include <QDir> #include <QVBoxLayout> #include <QApplication> +#include <ost/platform.hh> + #include <ost/gui/widget_registry.hh> #include <ost/gui/gosty_app.hh> @@ -42,13 +45,10 @@ public: OST_REGISTER_WIDGET(InfoWidget, InfoWidgetFactory); -InfoWidget::InfoWidget(QWidget* parent) : - Widget(NULL, parent) { +InfoWidget::InfoWidget(QWidget* parent) : Widget(NULL, parent), model_(new QStandardItemModel(this)), view_(new QListView(this)) { QVBoxLayout* layout = new QVBoxLayout(this); layout->setMargin(0); layout->setSpacing(0); - model_ = new QStandardItemModel(this); - view_ = new QListView(this); view_->setAttribute(Qt::WA_MacShowFocusRect, false); view_->setAttribute(Qt::WA_MacSmallSize, true); view_->setModel(model_); @@ -56,6 +56,17 @@ InfoWidget::InfoWidget(QWidget* parent) : view_->setDragEnabled(true); layout->addWidget(view_); + + + QDir icon_path(GetSharedDataPath().c_str()); + icon_path.cd("gui"); + icon_path.cd("icons"); + + QAction* clear_action = new QAction(this); + clear_action->setToolTip("Clear info panel"); + clear_action->setIcon(QIcon(icon_path.absolutePath()+QDir::separator()+QString("delete_icon.png"))); + connect(clear_action,SIGNAL(triggered(bool)), this, SLOT(Clear())); + this->actions_.append(clear_action); } void InfoWidget::Update() { @@ -106,7 +117,22 @@ QPixmap InfoWidget::GetIcon(QMessageBox::Icon icon, QWidget* widget) return QPixmap(); } +void InfoWidget::Clear(){ + this->model_->clear(); +} +void InfoWidget::RemoveSelected(){ + QItemSelectionModel* selection_model = this->view_->selectionModel(); + const QItemSelection& item_selection = selection_model->selection(); + const QModelIndexList& model_indexes = item_selection.indexes(); + for(int i=0;i<model_indexes.size();i++){ + this->model_->removeRow(model_indexes[i].row()); + } +} + +ActionList InfoWidget::GetActions(){ + return this->actions_; +} InfoWidget::~InfoWidget() { } diff --git a/modules/gui/src/info_widget/info_widget.hh b/modules/gui/src/info_widget/info_widget.hh index 2bf22886ae5dc8a31092615062175478b5fdc6e2..d74ceaa6591fb139d3849248d44bf7eea499c4a5 100644 --- a/modules/gui/src/info_widget/info_widget.hh +++ b/modules/gui/src/info_widget/info_widget.hh @@ -53,7 +53,10 @@ public: virtual bool Save(const QString& prefix) { return true; } virtual bool Restore(const QString& prefix) { return true; } + ActionList GetActions(); public slots: + void Clear(); + void RemoveSelected(); void Update(); private: @@ -62,6 +65,8 @@ private: QStandardItemModel* model_; QListView* view_; + + ActionList actions_; }; }} // ns