diff --git a/modules/gui/src/CMakeLists.txt b/modules/gui/src/CMakeLists.txt
index 463d2ecd5008cff8f7d452da0f5697cbefa436ea..2119c8ace88bfab9b180875cb2502f49aa7d62bf 100644
--- a/modules/gui/src/CMakeLists.txt
+++ b/modules/gui/src/CMakeLists.txt
@@ -93,6 +93,7 @@ scene_win_model.hh
set(OST_GUI_MESSAGES_HEADERS
message_widget.hh
+message_box_widget.hh
log_reader.hh
)
@@ -212,6 +213,7 @@ admin.cc
widget_pool.cc
remote_site_loader.cc
messages/message_widget.cc
+messages/message_box_widget.cc
messages/log_reader.cc
sequence_viewer/align_properties_painter.cc
sequence_viewer/base_row.cc
@@ -345,6 +347,7 @@ widget.hh
widget_geom_handler.hh
widget_pool.hh
messages/message_widget.hh
+messages/message_box_widget.hh
messages/log_reader.hh
sequence_viewer/align_properties_painter.hh
sequence_viewer/background_painter.hh
diff --git a/modules/gui/src/messages/message_box_widget.cc b/modules/gui/src/messages/message_box_widget.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0b19027447658ec83101949f112d16f4c57f3698
--- /dev/null
+++ b/modules/gui/src/messages/message_box_widget.cc
@@ -0,0 +1,108 @@
+//------------------------------------------------------------------------------
+// This file is part of the OpenStructure project <www.openstructure.org>
+//
+// Copyright (C) 2008-2010 by the OpenStructure authors
+//
+// This library 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.0 of the License, or (at your option)
+// any later version.
+// This library 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 this library; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+//------------------------------------------------------------------------------
+/*
+ Author: Stefan Scheuber
+ */
+#include <QDir>
+#include <QLabel>
+#include <QMenu>
+#include <QVBoxLayout>
+
+#include <ost/platform.hh>
+
+#include <ost/gui/gosty_app.hh>
+#include <ost/gui/perspective.hh>
+#include <ost/gui/widget_registry.hh>
+
+#include <ost/gui/panels/panel_manager.hh>
+
+#include "log_reader.hh"
+#include "message_box_widget.hh"
+
+namespace ost {namespace gui {
+
+MessageLevel::MessageLevel(QPixmap icon, QWidget* parent): QWidget(parent), message_count_(0), count_label_(new QLabel(QString::number(message_count_)+" ",this)){
+ QHBoxLayout* layout = new QHBoxLayout(this);
+ layout->setMargin(0);
+ layout->setSpacing(0);
+ QLabel* icon_label = new QLabel(this);
+ icon_label->setFixedSize(20,20);
+ icon_label->setPixmap(icon.scaled(20,20));
+ layout->addWidget(icon_label);
+ layout->addWidget(count_label_);
+}
+
+void MessageLevel::SetMessageCount(int message_count){
+ message_count_ = message_count;
+ count_label_->setText(QString::number(message_count_)+" ");
+}
+
+int MessageLevel::GetMessageCount(){
+ return message_count_;
+}
+
+
+
+MessageBoxWidget::MessageBoxWidget(QWidget* parent) :
+ QWidget(parent) {
+ QHBoxLayout* layout = new QHBoxLayout(this);
+ layout->setMargin(0);
+ layout->setSpacing(0);
+ MessageWidget* message_widget = GostyApp::Instance()->GetMessageWidget();
+ this->connect(message_widget,SIGNAL(MessageCountChanged(QMessageBox::Icon)),this,SLOT(Update(QMessageBox::Icon)));
+ this->connect(message_widget,SIGNAL(AllCleared()),this,SLOT(UpdateAll()));
+}
+
+void MessageBoxWidget::Update(QMessageBox::Icon icon) {
+ MessageWidget* message_widget = GostyApp::Instance()->GetMessageWidget();
+ int count = message_widget->GetMessagesCount(icon);
+ if(!level_map_.contains(icon)){
+ level_map_[icon] = new MessageLevel(message_widget->GetIcon(icon,this),this);
+ this->layout()->addWidget(level_map_[icon]);
+ }
+ level_map_[icon]->SetMessageCount(count);
+ if(count > 0){
+ level_map_[icon]->show();
+ }
+ else{
+ level_map_[icon]->hide();
+ }
+}
+
+void MessageBoxWidget::UpdateAll() {
+ QMapIterator<QMessageBox::Icon,MessageLevel*> i(level_map_);
+ while (i.hasNext()) {
+ i.next();
+ this->Update(i.key());
+ }
+}
+
+void MessageBoxWidget::mouseDoubleClickEvent(QMouseEvent* event){
+ MessageWidget* message_widget = GostyApp::Instance()->GetMessageWidget();
+ PanelManager* manager = GostyApp::Instance()->GetPerspective()->GetPanels();
+ if(message_widget->isHidden()){
+ manager->MoveWidget(message_widget,RIGHT_PANEL,0);
+ }
+}
+
+MessageBoxWidget::~MessageBoxWidget() {
+}
+
+}
+} // ns
diff --git a/modules/gui/src/messages/message_box_widget.hh b/modules/gui/src/messages/message_box_widget.hh
new file mode 100644
index 0000000000000000000000000000000000000000..fbd5c954566b71b874072fbb0c7aacdbbddba26c
--- /dev/null
+++ b/modules/gui/src/messages/message_box_widget.hh
@@ -0,0 +1,69 @@
+//------------------------------------------------------------------------------
+// This file is part of the OpenStructure project <www.openstructure.org>
+//
+// Copyright (C) 2008-2010 by the OpenStructure authors
+//
+// This library 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.0 of the License, or (at your option)
+// any later version.
+// This library 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 this library; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+//------------------------------------------------------------------------------
+#ifndef OST_GUI_MESSAGES_BOX_MESSAGE_WIDGET_HH
+#define OST_GUI_MESSAGES_BOX_MESSAGE_WIDGET_HH
+
+#include <QWidget>
+#include <QMap>
+#include <QMessageBox>
+
+#include <ost/gui/module_config.hh>
+
+/*
+ Author: Stefan Scheuber
+*/
+
+namespace ost { namespace gui {
+
+class DLLEXPORT_OST_GUI MessageLevel: public QWidget
+{
+ Q_OBJECT;
+public:
+ MessageLevel(QPixmap icon, QWidget* parent);
+
+ void SetMessageCount(int message_count);
+ int GetMessageCount();
+private:
+ int message_count_;
+ QLabel* count_label_;
+};
+
+// a summarized version for the the Log Messages
+class DLLEXPORT_OST_GUI MessageBoxWidget: public QWidget
+{
+ Q_OBJECT;
+public:
+ MessageBoxWidget(QWidget* parent=NULL);
+ ~MessageBoxWidget();
+
+public slots:
+ void Update(QMessageBox::Icon icon);
+ void UpdateAll();
+
+protected:
+ void mouseDoubleClickEvent(QMouseEvent* event);
+
+private:
+ QMap<QMessageBox::Icon,MessageLevel*> level_map_;
+
+};
+
+}} // ns
+
+#endif
diff --git a/modules/gui/src/messages/message_widget.cc b/modules/gui/src/messages/message_widget.cc
index cd4ff371a250812bacd4c05f9c47cfb6c3ad5995..a812a44e87e98cd9aab657c1f900891d97ebb3d1 100644
--- a/modules/gui/src/messages/message_widget.cc
+++ b/modules/gui/src/messages/message_widget.cc
@@ -86,22 +86,50 @@ void MessageWidget::Update() {
void MessageWidget::LogMessage(const QString& message, QMessageBox::Icon icon) {
QPixmap pix_icon = this->GetIcon(icon, this);
QStandardItem* item = new QStandardItem();
+ item->setData(QVariant(icon));
item->setText(message);
item->setIcon(QIcon(pix_icon));
item->setEditable(false);
this->model_->appendRow(item);
+ this->Increase(icon);
}
void MessageWidget::LogMessage(QStandardItem* item) {
+ item->setData(QVariant(QMessageBox::NoIcon));
this->model_->appendRow(item);
+ this->Increase(QMessageBox::NoIcon);
}
void MessageWidget::LogMessage(const QString& message, QIcon icon) {
QStandardItem* item = new QStandardItem();
item->setText(message);
+ item->setData(QVariant(QMessageBox::NoIcon));
item->setIcon(icon);
item->setEditable(false);
this->model_->appendRow(item);
+ this->Increase(QMessageBox::NoIcon);
+}
+
+void MessageWidget::Increase(QMessageBox::Icon icon){
+ if(count_map_.contains(icon)){
+ count_map_[icon] = count_map_[icon] + 1;
+ }
+ else{
+ count_map_[icon] = 1;
+ }
+ emit MessageCountChanged(icon);
+}
+
+void MessageWidget::Decrease(QMessageBox::Icon icon){
+ if(count_map_.contains(icon)){
+ if(count_map_[icon]>0){
+ count_map_[icon] = count_map_[icon] - 1;
+ }
+ else{
+ count_map_[icon] = 0;
+ }
+ }
+ emit MessageCountChanged(icon);
}
QPixmap MessageWidget::GetIcon(QMessageBox::Icon icon, QWidget* widget) {
@@ -130,6 +158,8 @@ QPixmap MessageWidget::GetIcon(QMessageBox::Icon icon, QWidget* widget) {
void MessageWidget::Clear() {
this->model_->clear();
+ this->count_map_.clear();
+ emit AllCleared();
}
void MessageWidget::RemoveSelected() {
@@ -137,7 +167,10 @@ void MessageWidget::RemoveSelected() {
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());
+ int row = model_indexes[i].row();
+ QMessageBox::Icon icon = QMessageBox::Icon(this->model_->item(row)->data().toInt());
+ this->model_->removeRow(row);
+ this->Decrease(icon);
}
}
@@ -146,7 +179,6 @@ ActionList MessageWidget::GetActions() {
}
void MessageWidget::ContextMenuRequested(const QPoint& pos) {
-
QAction* remove_selected_action = new QAction("Remove", this);
remove_selected_action->setToolTip("Remove this item");
connect(remove_selected_action, SIGNAL(triggered(bool)), this,
@@ -159,6 +191,17 @@ void MessageWidget::ContextMenuRequested(const QPoint& pos) {
}
}
+int MessageWidget::GetMessagesCount(QMessageBox::Icon icon) {
+ if(count_map_.contains(icon)){
+ return count_map_[icon];
+ }
+ return 0;
+}
+
+int MessageWidget::GetTotalMessagesCount() {
+ return model_->rowCount();
+}
+
MessageWidget::~MessageWidget() {
}
diff --git a/modules/gui/src/messages/message_widget.hh b/modules/gui/src/messages/message_widget.hh
index e430e77b61276e0b03ac1403b7c525c46324ccac..3aae2a3787c463c9a6b094203d693903b4624f20 100644
--- a/modules/gui/src/messages/message_widget.hh
+++ b/modules/gui/src/messages/message_widget.hh
@@ -45,15 +45,19 @@ public:
virtual void LogMessage(QStandardItem* item);
virtual void LogMessage(const QString& message, QIcon icon);
- virtual void SetMaxMessages(int max){}
- virtual int GetMaxMessages(){return 0;}
-
- virtual int GetMessagesCount(){return 0;}
-
+ virtual int GetMessagesCount(QMessageBox::Icon icon=QMessageBox::NoIcon);
+ virtual int GetTotalMessagesCount();
virtual bool Save(const QString& prefix) { return true; }
virtual bool Restore(const QString& prefix) { return true; }
+ QPixmap GetIcon(QMessageBox::Icon icon, QWidget* widget);
+
ActionList GetActions();
+
+signals:
+ void MessageCountChanged(QMessageBox::Icon);
+ void AllCleared();
+
public slots:
void Clear();
void RemoveSelected();
@@ -63,13 +67,14 @@ private slots:
void ContextMenuRequested(const QPoint& pos);
private:
- QPixmap GetIcon(QMessageBox::Icon icon, QWidget* widget);
-
+ void Increase(QMessageBox::Icon icon);
+ void Decrease(QMessageBox::Icon icon);
QStandardItemModel* model_;
QListView* view_;
ActionList actions_;
+ QMap<int,int> count_map_;
};
}} // ns
diff --git a/modules/gui/src/perspective.cc b/modules/gui/src/perspective.cc
index 50004183155c51b68344a1bb35376862916e3512..6d047e353a98324a8c8cccf2581616714870f4b9 100644
--- a/modules/gui/src/perspective.cc
+++ b/modules/gui/src/perspective.cc
@@ -17,6 +17,7 @@
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//------------------------------------------------------------------------------
#include <QTextEdit>
+#include <QSizeGrip>
#include <QMainWindow>
#include <QSettings>
#include <QDebug>
@@ -27,12 +28,14 @@
#include <QKeySequence>
#include <QStatusBar>
#include <QPushButton>
+
#include <ost/platform.hh>
#include <ost/gui/widget_registry.hh>
#include <ost/gui/perspective.hh>
#include <ost/gui/file_browser.hh>
#include <ost/gui/main_area.hh>
+#include <ost/gui/messages/message_box_widget.hh>
/*
Author: Marco Biasini
@@ -53,6 +56,7 @@ Perspective::Perspective(QMainWindow* parent):
parent->setCentralWidget(central_);
status_bar_ = new QStatusBar(main_area_);
+ status_bar_->setSizeGripEnabled (false);
panels_ = new PanelManager(main_area_);
l->addWidget(panels_,1);
@@ -96,6 +100,8 @@ void Perspective::SetupQuickAccessBar()
SLOT(AddSideBarWidget()));
l2->addWidget(add_side_bar_widget, 0);
l2->addWidget(status_bar_);
+ l2->addWidget(new MessageBoxWidget(quick_access_bar_));
+ l2->addWidget(new QSizeGrip(quick_access_bar_));
}
void Perspective::StatusMessage(const String& m)