From: Soeren Apel Date: Mon, 25 Mar 2019 17:03:02 +0000 (+0100) Subject: Merge RowItem() into ViewItem() X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=af33d4cbacc745f4473f5c0f4fa1f9ebb8d84d0a;p=pulseview.git Merge RowItem() into ViewItem() --- diff --git a/CMakeLists.txt b/CMakeLists.txt index b6c88f4f..76e12935 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -275,7 +275,6 @@ set(pulseview_SOURCES pv/views/trace/header.cpp pv/views/trace/marginwidget.cpp pv/views/trace/logicsignal.cpp - pv/views/trace/rowitem.cpp pv/views/trace/ruler.cpp pv/views/trace/signal.cpp pv/views/trace/timeitem.cpp @@ -339,7 +338,6 @@ set(pulseview_HEADERS pv/views/trace/header.hpp pv/views/trace/logicsignal.hpp pv/views/trace/marginwidget.hpp - pv/views/trace/rowitem.hpp pv/views/trace/ruler.hpp pv/views/trace/signal.hpp pv/views/trace/timeitem.hpp diff --git a/pv/views/trace/header.cpp b/pv/views/trace/header.cpp index d7da7e03..1e97521a 100644 --- a/pv/views/trace/header.cpp +++ b/pv/views/trace/header.cpp @@ -99,16 +99,16 @@ void Header::paintEvent(QPaintEvent*) { const QRect rect(0, 0, width(), height()); - vector< shared_ptr > items(view_.list_by_type()); + vector< shared_ptr > items(view_.list_by_type()); stable_sort(items.begin(), items.end(), - [](const shared_ptr &a, const shared_ptr &b) { + [](const shared_ptr &a, const shared_ptr &b) { return a->drag_point(QRect()).y() < b->drag_point(QRect()).y(); }); QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); - for (const shared_ptr& r : items) { + for (const shared_ptr& r : items) { assert(r); const bool highlight = !item_dragging_ && diff --git a/pv/views/trace/rowitem.cpp b/pv/views/trace/rowitem.cpp deleted file mode 100644 index c57043d4..00000000 --- a/pv/views/trace/rowitem.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * Copyright (C) 2015 Joel Holdsworth - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ - -#include "rowitem.hpp" - -namespace pv { -namespace views { -namespace trace { - -void RowItem::hover_point_changed(const QPoint &hp) -{ - (void)hp; -} - -} // namespace trace -} // namespace views -} // namespace pv diff --git a/pv/views/trace/rowitem.hpp b/pv/views/trace/rowitem.hpp deleted file mode 100644 index d2a205fb..00000000 --- a/pv/views/trace/rowitem.hpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * Copyright (C) 2013 Joel Holdsworth - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ - -#ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_ROWITEM_HPP -#define PULSEVIEW_PV_VIEWS_TRACEVIEW_ROWITEM_HPP - -#include "viewitem.hpp" - -namespace pv { -namespace views { -namespace trace { - -class RowItem : public ViewItem -{ - Q_OBJECT - -public: - virtual void hover_point_changed(const QPoint &hp); -}; - -} // namespace trace -} // namespace views -} // namespace pv - -#endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_ROWITEM_HPP diff --git a/pv/views/trace/tracetreeitem.hpp b/pv/views/trace/tracetreeitem.hpp index 3605aa1a..932e2b8c 100644 --- a/pv/views/trace/tracetreeitem.hpp +++ b/pv/views/trace/tracetreeitem.hpp @@ -24,7 +24,7 @@ #include -#include "rowitem.hpp" +#include "viewitem.hpp" using std::enable_shared_from_this; using std::pair; @@ -35,7 +35,7 @@ namespace trace { class TraceTreeItemOwner; -class TraceTreeItem : public RowItem, +class TraceTreeItem : public ViewItem, public enable_shared_from_this { Q_OBJECT diff --git a/pv/views/trace/viewitem.cpp b/pv/views/trace/viewitem.cpp index 2dd8ade8..2a3a6926 100644 --- a/pv/views/trace/viewitem.cpp +++ b/pv/views/trace/viewitem.cpp @@ -148,6 +148,11 @@ QColor ViewItem::select_text_color(QColor background) return (background.lightness() > 110) ? Qt::black : Qt::white; } +void ViewItem::hover_point_changed(const QPoint &hp) +{ + (void)hp; +} + } // namespace trace } // namespace views } // namespace pv diff --git a/pv/views/trace/viewitem.hpp b/pv/views/trace/viewitem.hpp index 5ce3bb60..c445f609 100644 --- a/pv/views/trace/viewitem.hpp +++ b/pv/views/trace/viewitem.hpp @@ -167,6 +167,8 @@ public: virtual void delete_pressed(); + virtual void hover_point_changed(const QPoint &hp); + protected: static QPen highlight_pen(); diff --git a/pv/views/trace/viewport.cpp b/pv/views/trace/viewport.cpp index 2ca43a0b..6c51d0a1 100644 --- a/pv/views/trace/viewport.cpp +++ b/pv/views/trace/viewport.cpp @@ -69,7 +69,7 @@ shared_ptr Viewport::get_mouse_over_item(const QPoint &pt) void Viewport::item_hover(const shared_ptr &item, QPoint pos) { if (item && item->is_draggable(pos)) - setCursor(dynamic_pointer_cast(item) ? + setCursor(dynamic_pointer_cast(item) ? Qt::SizeVerCursor : Qt::SizeHorCursor); else unsetCursor(); @@ -161,12 +161,12 @@ void Viewport::paintEvent(QPaintEvent*) &ViewItem::paint_back, &ViewItem::paint_mid, &ViewItem::paint_fore, nullptr}; - vector< shared_ptr > row_items(view_.list_by_type()); + vector< shared_ptr > row_items(view_.list_by_type()); assert(none_of(row_items.begin(), row_items.end(), - [](const shared_ptr &r) { return !r; })); + [](const shared_ptr &r) { return !r; })); stable_sort(row_items.begin(), row_items.end(), - [](const shared_ptr &a, const shared_ptr &b) { + [](const shared_ptr &a, const shared_ptr &b) { return a->drag_point(QRect()).y() < b->drag_point(QRect()).y(); }); const vector< shared_ptr > time_items(view_.time_items()); @@ -187,7 +187,7 @@ void Viewport::paintEvent(QPaintEvent*) (t.get()->*(*paint_func))(p, time_pp); ViewItemPaintParams row_pp(rect(), view_.scale(), view_.offset()); - for (const shared_ptr& r : row_items) + for (const shared_ptr& r : row_items) (r.get()->*(*paint_func))(p, row_pp); } diff --git a/pv/views/trace/viewwidget.cpp b/pv/views/trace/viewwidget.cpp index 73c361f4..46946a5c 100644 --- a/pv/views/trace/viewwidget.cpp +++ b/pv/views/trace/viewwidget.cpp @@ -105,9 +105,9 @@ void ViewWidget::drag_items(const QPoint &delta) bool item_dragged = false; // Drag the row items - const vector< shared_ptr > row_items( - view_.list_by_type()); - for (const shared_ptr& r : row_items) + const vector< shared_ptr > row_items( + view_.list_by_type()); + for (const shared_ptr& r : row_items) if (r->dragging()) { r->drag_by(delta); diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a237ad12..7e753153 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -63,7 +63,6 @@ set(pulseview_TEST_SOURCES ${PROJECT_SOURCE_DIR}/pv/views/trace/header.cpp ${PROJECT_SOURCE_DIR}/pv/views/trace/marginwidget.cpp ${PROJECT_SOURCE_DIR}/pv/views/trace/logicsignal.cpp - ${PROJECT_SOURCE_DIR}/pv/views/trace/rowitem.cpp ${PROJECT_SOURCE_DIR}/pv/views/trace/ruler.cpp ${PROJECT_SOURCE_DIR}/pv/views/trace/signal.cpp ${PROJECT_SOURCE_DIR}/pv/views/trace/timeitem.cpp @@ -136,7 +135,6 @@ set(pulseview_TEST_HEADERS ${PROJECT_SOURCE_DIR}/pv/views/trace/header.hpp ${PROJECT_SOURCE_DIR}/pv/views/trace/logicsignal.hpp ${PROJECT_SOURCE_DIR}/pv/views/trace/marginwidget.hpp - ${PROJECT_SOURCE_DIR}/pv/views/trace/rowitem.hpp ${PROJECT_SOURCE_DIR}/pv/views/trace/ruler.hpp ${PROJECT_SOURCE_DIR}/pv/views/trace/signal.hpp ${PROJECT_SOURCE_DIR}/pv/views/trace/timeitem.hpp