Skip to content
Snippets Groups Projects
Commit 301f66ba authored by stefan's avatar stefan
Browse files

InfoPanel, added clear action

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2601 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent b1ddaad6
No related branches found
No related tags found
No related merge requests found
......@@ -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>)
......
......@@ -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
......
modules/gui/share/icons/delete_icon.png

769 B

......@@ -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() {
}
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment