Skip to content
Snippets Groups Projects
Commit 75f4d5c8 authored by Pospelov, Gennady's avatar Pospelov, Gennady
Browse files

ParameterTuningWidget is switched to new warning sign controller.

parent 3e3f2825
No related branches found
No related tags found
No related merge requests found
......@@ -21,14 +21,11 @@
WarningSignWidget::WarningSignWidget(QWidget * parent)
: QWidget(parent)
, m_pixmap(QStringLiteral(":/images/warning@2x.png"))
, m_warning_header(QStringLiteral("Houston, we have a problem."))
{
setAttribute(Qt::WA_NoSystemBackground);
//setAttribute(Qt::WA_TransparentForMouseEvents);
m_pixmap = QPixmap(":/images/warning@2x.png");
setToolTip(QString(
"Houston, we have a problem.\n"
"Click to see details."
));
setToolTip(m_warning_header+"\nClick to see details.");
}
void WarningSignWidget::paintEvent(QPaintEvent *event) {
......@@ -41,7 +38,7 @@ void WarningSignWidget::paintEvent(QPaintEvent *event) {
void WarningSignWidget::mousePressEvent(QMouseEvent *event)
{
Q_UNUSED(event);
QMessageBox::warning(this, "Houston, we have a problem.", m_warning_message);
QMessageBox::warning(this, m_warning_header, m_warning_message);
}
//! set geometry of widget around center point
......@@ -49,3 +46,9 @@ void WarningSignWidget::setPosition(int x, int y)
{
setGeometry(x, y, m_pixmap.width(), m_pixmap.height());
}
void WarningSignWidget::setWarningHeader(const QString& message)
{
m_warning_header = message;
setToolTip(m_warning_header+"\nClick to see details.");
}
......@@ -31,6 +31,7 @@ public:
void setPosition(int x, int y);
void setWarningHeader(const QString &message);
void setWarningMessage(const QString &message) {m_warning_message = message;}
protected:
......@@ -39,6 +40,7 @@ protected:
private:
QPixmap m_pixmap;
QString m_warning_header;
QString m_warning_message;
};
......
......@@ -28,7 +28,7 @@
#include "ParameterTuningModel.h"
#include "SampleModel.h"
#include "SliderSettingsWidget.h"
#include "WarningSignWidget.h"
#include "WarningSign.h"
#include <QApplication>
#include <QItemSelectionModel>
#include <QKeyEvent>
......@@ -39,23 +39,18 @@
#include <QTreeView>
#include <QVBoxLayout>
namespace {
const int warning_sign_xpos = 38;
const int warning_sign_ypos = 38;
}
ParameterTuningWidget::ParameterTuningWidget(QWidget *parent)
: QWidget(parent)
, m_jobModel(0)
, m_currentJobItem(0)
, m_parameterTuningModel(0)
, m_sliderSettingsWidget(new SliderSettingsWidget(this))
, m_treeView(new QTreeView)
, m_delegate(new ParameterTuningDelegate)
, m_warningSign(0)
, m_warningSign(new WarningSign(m_treeView))
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_treeView = new QTreeView();
m_treeView->setStyleSheet(
"QTreeView::branch {background: palette(base);}QTreeView::branch:has-siblings:!adjoins-item "
"{border-image: url(:/images/treeview-vline.png) 0;}QTreeView::branch:has-siblings:"
......@@ -213,13 +208,8 @@ void ParameterTuningWidget::makeSelected(ParameterItem *item)
void ParameterTuningWidget::resizeEvent(QResizeEvent *event)
{
Q_UNUSED(event);
if(m_warningSign) {
QPoint pos = getPositionForWarningSign();
m_warningSign->setPosition(pos.x(),pos.y());
}
if(m_treeView) {
if(m_treeView)
m_treeView->setColumnWidth(0, width()*0.5);
}
}
//! Context menu reimplemented to suppress the default one
......@@ -231,45 +221,19 @@ void ParameterTuningWidget::contextMenuEvent(QContextMenuEvent *event)
void ParameterTuningWidget::onPropertyChanged(const QString &property_name)
{
if(property_name == JobItem::P_STATUS) {
delete m_warningSign;
m_warningSign = 0;
m_warningSign->clear();
if(m_currentJobItem->isFailed()) {
QString message;
message.append("Current parameter values cause simulation failure.\n\n");
message.append(m_currentJobItem->getComments());
m_warningSign = new WarningSignWidget(this);
m_warningSign->setWarningMessage(message);
QPoint pos = getPositionForWarningSign();
m_warningSign->setPosition(pos.x(), pos.y());
m_warningSign->show();
}
updateDragAndDropSettings();
}
}
//! Returns position for warning sign at the bottom right corner of the tree view.
//! The position will be adjusted according to the visibility of scroll bars
QPoint ParameterTuningWidget::getPositionForWarningSign()
{
int x = width()-warning_sign_xpos;
int y = height()-warning_sign_ypos;
if(QScrollBar *horizontal = m_treeView->horizontalScrollBar()) {
if(horizontal->isVisible())
y -= horizontal->height();
}
if(QScrollBar *vertical = m_treeView->verticalScrollBar()) {
if(vertical->isVisible())
x -= vertical->width();
}
return QPoint(x, y);
}
//! Disable drag-and-drop abilities, if job is in fit running state.
void ParameterTuningWidget::updateDragAndDropSettings()
......
......@@ -28,7 +28,7 @@ class ParameterTuningDelegate;
class ParameterTuningModel;
class SliderSettingsWidget;
class QTreeView;
class WarningSignWidget;
class WarningSign;
class ParameterItem;
class ParameterTuningWidget : public QWidget
......@@ -64,7 +64,6 @@ private slots:
void onCustomContextMenuRequested(const QPoint &point);
private:
QPoint getPositionForWarningSign();
void updateDragAndDropSettings();
void setTuningDelegateEnabled(bool enabled);
......@@ -76,7 +75,7 @@ private:
SliderSettingsWidget *m_sliderSettingsWidget;
QTreeView *m_treeView;
ParameterTuningDelegate *m_delegate;
WarningSignWidget *m_warningSign;
WarningSign *m_warningSign;
};
#endif // PARAMETERTUNINGWIDGET_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment