Skip to content
Snippets Groups Projects
Commit 62f4cde6 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

rm delegate from ItemViewOverlayButtons

parent e24e4a3d
No related branches found
No related tags found
1 merge request!2359Use same tree view with delegate for datafiles, samples, and instruments. Also move some code between GUI/View directories. Restore Py wrappers lost in previous MR.
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include <QBoxLayout> #include <QBoxLayout>
#include <QKeyEvent> #include <QKeyEvent>
#include <QMenu> #include <QMenu>
#include <QStyledItemDelegate>
#include <QToolButton> #include <QToolButton>
namespace { namespace {
...@@ -26,8 +25,6 @@ class ItemViewOverlayWidget : public QWidget { ...@@ -26,8 +25,6 @@ class ItemViewOverlayWidget : public QWidget {
public: public:
ItemViewOverlayWidget(QAbstractItemView* view, const QModelIndex& index); ItemViewOverlayWidget(QAbstractItemView* view, const QModelIndex& index);
static int heightForDelegate();
void setHover(bool b); void setHover(bool b);
void create(); void create();
void hover(bool h); void hover(bool h);
...@@ -46,12 +43,6 @@ private: ...@@ -46,12 +43,6 @@ private:
}; };
class ItemViewOverlayDelegate : public QStyledItemDelegate {
public:
QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override;
};
ItemViewOverlayWidget::ItemViewOverlayWidget(QAbstractItemView* view, const QModelIndex& index) ItemViewOverlayWidget::ItemViewOverlayWidget(QAbstractItemView* view, const QModelIndex& index)
: QWidget(view) : QWidget(view)
, m_view(view) , m_view(view)
...@@ -67,14 +58,6 @@ void ItemViewOverlayWidget::setHover(bool b) ...@@ -67,14 +58,6 @@ void ItemViewOverlayWidget::setHover(bool b)
m_hover = b; m_hover = b;
} }
int ItemViewOverlayWidget::heightForDelegate()
{
QToolButton btn;
const int size = QApplication::style()->pixelMetric(QStyle::PM_ToolBarIconSize);
btn.setIconSize(QSize(size, size));
return btn.sizeHint().height() + 6; // 3px on top and bottom
}
void ItemViewOverlayWidget::enterEvent(QEnterEvent*) void ItemViewOverlayWidget::enterEvent(QEnterEvent*)
{ {
hover(true); hover(true);
...@@ -145,17 +128,6 @@ void ItemViewOverlayWidget::setHorizontalAlignment(Qt::Alignment a) ...@@ -145,17 +128,6 @@ void ItemViewOverlayWidget::setHorizontalAlignment(Qt::Alignment a)
} }
QSize ItemViewOverlayDelegate::sizeHint(const QStyleOptionViewItem& option,
const QModelIndex& index) const
{
QSize s = QStyledItemDelegate::sizeHint(option, index);
if (index.parent().isValid()) {
const int h = ItemViewOverlayWidget::heightForDelegate();
s.setHeight(std::max(s.height(), h));
}
return s;
}
} // namespace } // namespace
...@@ -164,13 +136,9 @@ void ItemViewOverlayButtons::install(QAbstractItemView* view, FnGetActions fnGet ...@@ -164,13 +136,9 @@ void ItemViewOverlayButtons::install(QAbstractItemView* view, FnGetActions fnGet
auto* h = new ItemViewOverlayButtons(view); auto* h = new ItemViewOverlayButtons(view);
h->m_get_actions = fnGetActions; h->m_get_actions = fnGetActions;
h->m_view = view; h->m_view = view;
auto* d = new ItemViewOverlayDelegate;
view->setItemDelegate(d);
view->installEventFilter(h); view->installEventFilter(h);
h->update(); h->update();
connect(d, &QAbstractItemDelegate::closeEditor, h, &ItemViewOverlayButtons::update);
connect(view->model(), &QAbstractItemModel::modelReset, h, &ItemViewOverlayButtons::update, connect(view->model(), &QAbstractItemModel::modelReset, h, &ItemViewOverlayButtons::update,
Qt::QueuedConnection); Qt::QueuedConnection);
connect(view->model(), &QAbstractItemModel::rowsInserted, h, &ItemViewOverlayButtons::update, connect(view->model(), &QAbstractItemModel::rowsInserted, h, &ItemViewOverlayButtons::update,
......
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