From: Joel Holdsworth Date: Sun, 7 Dec 2014 10:59:52 +0000 (+0000) Subject: TimeMarker: Renamed get_label_rect, and made it take a const QRectF& X-Git-Tag: pulseview-0.3.0~380 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=689dea92f288564260ef521f6f499e03e3cdbbd2;p=pulseview.git TimeMarker: Renamed get_label_rect, and made it take a const QRectF& --- diff --git a/pv/view/cursor.cpp b/pv/view/cursor.cpp index 836d0e93..5f334160 100644 --- a/pv/view/cursor.cpp +++ b/pv/view/cursor.cpp @@ -55,7 +55,7 @@ QString Cursor::get_text() const return pv::util::format_time(time_, view_.tick_prefix(), 2); } -QRectF Cursor::get_label_rect(const QRect &rect) const +QRectF Cursor::label_rect(const QRectF &rect) const { const shared_ptr other(get_other_cursor()); assert(other); diff --git a/pv/view/cursor.hpp b/pv/view/cursor.hpp index b23bd642..03b97a17 100644 --- a/pv/view/cursor.hpp +++ b/pv/view/cursor.hpp @@ -63,7 +63,7 @@ public: * @param rect The rectangle of the ruler client area. * @return Returns the label rectangle. */ - QRectF get_label_rect(const QRect &rect) const; + QRectF label_rect(const QRectF &rect) const; private: std::shared_ptr get_other_cursor() const; diff --git a/pv/view/cursorheader.cpp b/pv/view/cursorheader.cpp index 076b2a7f..2835750b 100644 --- a/pv/view/cursorheader.cpp +++ b/pv/view/cursorheader.cpp @@ -108,10 +108,10 @@ void CursorHeader::mousePressEvent(QMouseEvent *e) if (view_.cursors_shown()) { shared_ptr cursors(view_.cursors()); - if (cursors->first()->get_label_rect( + if (cursors->first()->label_rect( rect()).contains(e->pos())) grabbed_marker_ = cursors->first(); - else if (cursors->second()->get_label_rect( + else if (cursors->second()->label_rect( rect()).contains(e->pos())) grabbed_marker_ = cursors->second(); } diff --git a/pv/view/cursorpair.cpp b/pv/view/cursorpair.cpp index 0370793d..8a0ecbf2 100644 --- a/pv/view/cursorpair.cpp +++ b/pv/view/cursorpair.cpp @@ -70,7 +70,7 @@ pv::widgets::Popup* CursorPair::create_popup(QWidget *parent) return nullptr; } -QRectF CursorPair::get_label_rect(const QRect &rect) const +QRectF CursorPair::label_rect(const QRectF &rect) const { const QSizeF label_size( text_size_.width() + View::LabelPadding.width() * 2, @@ -98,7 +98,7 @@ void CursorPair::draw_markers(QPainter &p, const QRect &rect) const unsigned int prefix = view_.tick_prefix(); compute_text_size(p, prefix); - QRectF delta_rect(get_label_rect(rect)); + QRectF delta_rect(label_rect(rect)); const int radius = delta_rect.height() / 2; const QRectF text_rect(delta_rect.intersected( diff --git a/pv/view/cursorpair.hpp b/pv/view/cursorpair.hpp index 12ed76af..78780916 100644 --- a/pv/view/cursorpair.hpp +++ b/pv/view/cursorpair.hpp @@ -65,7 +65,7 @@ public: pv::widgets::Popup* create_popup(QWidget *parent); public: - QRectF get_label_rect(const QRect &rect) const; + QRectF label_rect(const QRectF &rect) const; void draw_markers(QPainter &p, const QRect &rect); diff --git a/pv/view/timemarker.cpp b/pv/view/timemarker.cpp index 34b2699b..eebac024 100644 --- a/pv/view/timemarker.cpp +++ b/pv/view/timemarker.cpp @@ -87,7 +87,7 @@ void TimeMarker::paint(QPainter &p, const QRect &rect) p.drawLine(QPointF(x, rect.top()), QPointF(x, rect.bottom())); } -QRectF TimeMarker::get_label_rect(const QRect &rect) const +QRectF TimeMarker::label_rect(const QRectF &rect) const { const float x = (time_ - view_.offset()) / view_.scale(); @@ -113,7 +113,7 @@ void TimeMarker::paint_label(QPainter &p, const QRect &rect) return; const qreal x = (time_ - view_.offset()) / view_.scale(); - const QRectF r(get_label_rect(rect)); + const QRectF r(label_rect(rect)); const QPointF points[] = { r.topLeft(), diff --git a/pv/view/timemarker.hpp b/pv/view/timemarker.hpp index 24688ebc..4e9d1fa2 100644 --- a/pv/view/timemarker.hpp +++ b/pv/view/timemarker.hpp @@ -89,7 +89,7 @@ public: * @param rect The rectangle of the ruler client area. * @return Returns the label rectangle. */ - virtual QRectF get_label_rect(const QRect &rect) const; + virtual QRectF label_rect(const QRectF &rect) const; /** * Paints the marker's label to the ruler.