From 301f66ba016186b85397355039cdb0261f055b8e Mon Sep 17 00:00:00 2001 From: stefan <stefan@5a81b35b-ba03-0410-adc8-b2c5c5119f08> Date: Thu, 29 Jul 2010 09:22:45 +0000 Subject: [PATCH] InfoPanel, added clear action git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2601 5a81b35b-ba03-0410-adc8-b2c5c5119f08 --- modules/gui/pymod/export_info_widget.cc | 2 ++ modules/gui/share/CMakeLists.txt | 1 + modules/gui/share/icons/delete_icon.png | Bin 0 -> 769 bytes modules/gui/src/info_widget/info_widget.cc | 34 ++++++++++++++++++--- modules/gui/src/info_widget/info_widget.hh | 5 +++ 5 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 modules/gui/share/icons/delete_icon.png diff --git a/modules/gui/pymod/export_info_widget.cc b/modules/gui/pymod/export_info_widget.cc index 408f39a66..8847116bc 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 23601130f..db9da9d43 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 GIT binary patch literal 769 zcmeAS@N?(olHy`uVBq!ia0y~yU=Rag4mJh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modules/gui/src/info_widget/info_widget.cc index 4a31d0fa2..fd582d46b 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 2bf22886a..d74ceaa65 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 -- GitLab