Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
- magenta-colored unsymmetric border for QTreeView
- yellow background for SplitterHandle
- debug output for window sizes
- F5 triggers updateGeometry
  • Loading branch information
rhaschke committed Jul 31, 2022
1 parent 1cdf614 commit 2f71723
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/rviz/properties/property_tree_delegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
*/

#include <QAbstractItemView>
#include <QPainter>

#include "rviz/properties/property.h"
#include "rviz/properties/line_edit_with_button.h"
Expand All @@ -47,7 +48,9 @@ void PropertyTreeDelegate::paint(QPainter* painter,
Property* prop = static_cast<Property*>(index.internalPointer());
if (!prop || !prop->paint(painter, option))
{
QStyledItemDelegate::paint(painter, option, index);
QStyleOptionViewItem opt = option;
painter->fillRect(opt.rect, Qt::red);
QStyledItemDelegate::paint(painter, opt, index);
}
}

Expand Down
12 changes: 12 additions & 0 deletions src/rviz/properties/splitter_handle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include <QPainter>
#include <QTreeView>
#include <QHeaderView>
#include <QAction>
#include <QDebug>

#include "rviz/properties/splitter_handle.h"

Expand All @@ -45,6 +47,13 @@ SplitterHandle::SplitterHandle(QTreeView* parent)
updateGeometry();
parent_->header()->setStretchLastSection(false);
parent_->installEventFilter(this);

parent->setStyleSheet("border-width: 1 1 1 10; border-style: solid; border-color: magenta");
auto act = new QAction("Update Geometry", this);
act->setShortcut(QKeySequence("F5"));
act->setShortcutContext(Qt::WidgetShortcut);
parent->addAction(act);
connect(act, &QAction::triggered, this, &SplitterHandle::updateGeometry);
}

bool SplitterHandle::eventFilter(QObject* event_target, QEvent* event)
Expand All @@ -61,6 +70,8 @@ void SplitterHandle::updateGeometry()
int w = 7;
const auto& content = parent_->contentsRect();
int new_column_width = int(first_column_size_ratio_ * content.width());
qDebug() << parent_->contentsRect() << parent_->contentsRect().width() << parent_->width()
<< new_column_width;
parent_->header()->resizeSection(0, new_column_width); // fixed size for name column
parent_->header()->resizeSection(1, content.width() - new_column_width);

Expand Down Expand Up @@ -121,6 +132,7 @@ void SplitterHandle::mouseMoveEvent(QMouseEvent* event)
void SplitterHandle::paintEvent(QPaintEvent* /*event*/)
{
QPainter painter(this);
painter.fillRect(0, 0, width(), height(), Qt::yellow);
painter.setPen(color_);
painter.drawLine(1 + width() / 2, 0, 1 + width() / 2, height());
}
Expand Down

0 comments on commit 2f71723

Please sign in to comment.