Skip to content

Commit

Permalink
Customise aviso rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
sandorkertesz authored and marcosbento committed Jun 17, 2024
1 parent 310cb39 commit 5d5e354
Show file tree
Hide file tree
Showing 7 changed files with 311 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ ecflow_*.files
ecflow_*.cflags
ecflow_*.cxxflags
CMakeLists.txt.user
.qtc_clangd/

#vscode
.vscode
Expand Down
257 changes: 257 additions & 0 deletions Viewer/ecflowUI/images/aviso.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 18 additions & 3 deletions Viewer/ecflowUI/src/NodeViewDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#include "NodeViewDelegate.hpp"

#include <algorithm>

#include <QApplication>
#include <QDebug>
#include <QImageReader>
Expand Down Expand Up @@ -84,6 +86,8 @@ NodeViewDelegate::NodeViewDelegate(QWidget* parent) : QStyledItemDelegate(parent
errPix_ = QPixmap(QPixmap::fromImage(img));
}

avisoPixId_ = IconProvider::add(":/viewer/aviso.svg", "aviso");

grad_.setCoordinateMode(QGradient::ObjectBoundingMode);
grad_.setStart(0, 0);
grad_.setFinalStop(0, 1);
Expand Down Expand Up @@ -666,13 +670,14 @@ void NodeViewDelegate::renderAviso(QPainter* painter,
QStringList data,
const QStyleOptionViewItem& option,
QSize& size) const {

int totalWidth = 0;
size = QSize(totalWidth, attrBox_->fullHeight);

if (data.count() < 2)
return;

QString name = data.at(1) + ":";
QString name = data.at(1); // + ":";
QString val;
if (data.count() > 2)
val = data.at(2);
Expand All @@ -688,6 +693,7 @@ void NodeViewDelegate::renderAviso(QPainter* painter,
int currentRight = contRect.x();
int multiCnt = val.count('\n');

QRect avisoRect;
QRect nameRect;
QRect valRect, valRestRect;

Expand All @@ -697,11 +703,16 @@ void NodeViewDelegate::renderAviso(QPainter* painter,
QString valFirst, valRest;
QString full;

auto avisoPix = IconProvider::pixmapToHeight(avisoPixId_, contRect.height());
avisoRect = contRect.adjusted(attrBox_->leftPadding, 0, 0, 0);
avisoRect.setWidth(avisoPix.width());

if (multiCnt == 0) {
// The text rectangle
QFontMetrics fm(nameFont);
int nameWidth = ViewerUtil::textWidth(fm, name);
nameRect = contRect.adjusted(attrBox_->leftPadding, 0, 0, 0);
nameRect = contRect;
nameRect.setX(avisoRect.x() + avisoRect.width() + attrBox_->spacing);
nameRect.setWidth(nameWidth);

// The value rectangle
Expand All @@ -718,7 +729,8 @@ void NodeViewDelegate::renderAviso(QPainter* painter,
// The text rectangle
QFontMetrics fm(nameFont);
int nameWidth = ViewerUtil::textWidth(fm, name);
nameRect = contRect.adjusted(attrBox_->leftPadding, 0, 0, 0);
nameRect = contRect;
nameRect.setX(avisoRect.x() + avisoRect.width() + attrBox_->spacing);
nameRect.setWidth(nameWidth);
nameRect.setHeight(attrBox_->height - attrBox_->topPadding - attrBox_->bottomPadding);

Expand Down Expand Up @@ -781,6 +793,9 @@ void NodeViewDelegate::renderAviso(QPainter* painter,
}
}

// aviso pixmap
painter->drawPixmap(avisoRect, avisoPix);

// Draw name
painter->setPen(fontPen);
painter->setFont(nameFont);
Expand Down
1 change: 1 addition & 0 deletions Viewer/ecflowUI/src/NodeViewDelegate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ class NodeViewDelegate : public QStyledItemDelegate, public VPropertyObserver {
QPen holdingTimeFontPen_;
QPen holdingDateFontPen_;

int avisoPixId_;
int holdingTimePixId_;
int holdingDatePixId_;

Expand Down
1 change: 1 addition & 0 deletions Viewer/ecflowUI/src/viewer.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<file alias="add_tab.svg">../images/add_tab.svg</file>
<file alias="add_variable_column.svg">../images/add_variable_column.svg</file>
<file alias="attribute.svg">../images/attribute.svg</file>
<file alias="aviso.svg">../images/aviso.svg</file>
<file alias="autoscroll.svg">../images/autoscroll.svg</file>
<file alias="autoscroll_off.svg">../images/autoscroll_off.svg</file>
<file alias="chain.svg">../images/chain.svg</file>
Expand Down
Loading

0 comments on commit 5d5e354

Please sign in to comment.