projects
/
pulseview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
6364695
)
Flag: Added delete key support
author
Joel Holdsworth
<joel@airwebreathe.org.uk>
Sat, 20 Dec 2014 08:50:26 +0000
(08:50 +0000)
committer
Joel Holdsworth
<joel@airwebreathe.org.uk>
Sun, 28 Dec 2014 18:52:53 +0000
(18:52 +0000)
pv/view/cursorheader.cpp
patch
|
blob
|
history
pv/view/cursorheader.hpp
patch
|
blob
|
history
pv/view/flag.cpp
patch
|
blob
|
history
pv/view/flag.hpp
patch
|
blob
|
history
pv/view/header.cpp
patch
|
blob
|
history
pv/view/marginwidget.cpp
patch
|
blob
|
history
pv/view/timeitem.hpp
patch
|
blob
|
history
diff --git
a/pv/view/cursorheader.cpp
b/pv/view/cursorheader.cpp
index fbc6e2e791d53eccf26140896fae83291f607714..efc9205e06f05a3885b8bc11802420b6725abd54 100644
(file)
--- a/
pv/view/cursorheader.cpp
+++ b/
pv/view/cursorheader.cpp
@@
-49,7
+49,6
@@
CursorHeader::CursorHeader(View &parent) :
MarginWidget(parent),
textHeight_(calculateTextHeight())
{
MarginWidget(parent),
textHeight_(calculateTextHeight())
{
- setMouseTracking(true);
}
QSize CursorHeader::sizeHint() const
}
QSize CursorHeader::sizeHint() const
@@
-162,5
+161,18
@@
void CursorHeader::mouseDoubleClickEvent(QMouseEvent *e)
view_.add_flag(view_.offset() + ((double)e->x() + 0.5) * view_.scale());
}
view_.add_flag(view_.offset() + ((double)e->x() + 0.5) * view_.scale());
}
+void CursorHeader::keyPressEvent(QKeyEvent *e)
+{
+ assert(e);
+
+ if (e->key() == Qt::Key_Delete)
+ {
+ const vector< shared_ptr<TimeItem> > items(view_.time_items());
+ for (auto &i : items)
+ if (i->selected())
+ i->delete_pressed();
+ }
+}
+
} // namespace view
} // namespace pv
} // namespace view
} // namespace pv
diff --git
a/pv/view/cursorheader.hpp
b/pv/view/cursorheader.hpp
index 8db6408622d76430ac0cd39cece7699aae80f1cc..ff732856ee03f163f0d9e3310552a99d1c9c9c61 100644
(file)
--- a/
pv/view/cursorheader.hpp
+++ b/
pv/view/cursorheader.hpp
@@
-62,6
+62,9
@@
private:
void mouseDoubleClickEvent(QMouseEvent *e);
void mouseDoubleClickEvent(QMouseEvent *e);
+ void keyPressEvent(QKeyEvent *e);
+
+private:
int calculateTextHeight();
std::shared_ptr<TimeItem> mouse_down_item_;
int calculateTextHeight();
std::shared_ptr<TimeItem> mouse_down_item_;
diff --git
a/pv/view/flag.cpp
b/pv/view/flag.cpp
index 53b0feefa07b77c4ecce071b99358490a4fe6012..2ee8ced4972413439d67ba938014c2dee5617e46 100644
(file)
--- a/
pv/view/flag.cpp
+++ b/
pv/view/flag.cpp
@@
-43,7
+43,8
@@
Flag::Flag(View &view, double time, const QString &text) :
}
Flag::Flag(const Flag &flag) :
}
Flag::Flag(const Flag &flag) :
- TimeMarker(flag.view_, FillColour, flag.time_)
+ TimeMarker(flag.view_, FillColour, flag.time_),
+ std::enable_shared_from_this<pv::view::Flag>(flag)
{
}
{
}
@@
-73,6
+74,11
@@
pv::widgets::Popup* Flag::create_popup(QWidget *parent)
return popup;
}
return popup;
}
+void Flag::delete_pressed()
+{
+ view_.remove_flag(shared_ptr<Flag>(shared_from_this()));
+}
+
void Flag::on_text_changed(const QString &text)
{
text_ = text;
void Flag::on_text_changed(const QString &text)
{
text_ = text;
diff --git
a/pv/view/flag.hpp
b/pv/view/flag.hpp
index 659d5cc1c55143aaa88bf45113f980f9a2483cf9..fdebe1c0a6b4139b9675aa57c1771ed151fc7041 100644
(file)
--- a/
pv/view/flag.hpp
+++ b/
pv/view/flag.hpp
@@
-21,12
+21,15
@@
#ifndef PULSEVIEW_PV_VIEW_FLAG_H
#define PULSEVIEW_PV_VIEW_FLAG_H
#ifndef PULSEVIEW_PV_VIEW_FLAG_H
#define PULSEVIEW_PV_VIEW_FLAG_H
+#include <memory>
+
#include "timemarker.hpp"
namespace pv {
namespace view {
#include "timemarker.hpp"
namespace pv {
namespace view {
-class Flag : public TimeMarker
+class Flag : public TimeMarker,
+ public std::enable_shared_from_this<pv::view::Flag>
{
Q_OBJECT
{
Q_OBJECT
@@
-59,6
+62,8
@@
public:
pv::widgets::Popup* create_popup(QWidget *parent);
pv::widgets::Popup* create_popup(QWidget *parent);
+ void delete_pressed();
+
private Q_SLOTS:
void on_text_changed(const QString &text);
private Q_SLOTS:
void on_text_changed(const QString &text);
diff --git
a/pv/view/header.cpp
b/pv/view/header.cpp
index 780b1e3db5f9894c39e845fd6a549e855976038a..4b02c1944d35540bf78f1c220716b213ce4433e4 100644
(file)
--- a/
pv/view/header.cpp
+++ b/
pv/view/header.cpp
@@
-62,9
+62,6
@@
static bool item_selected(shared_ptr<RowItem> r)
Header::Header(View &parent) :
MarginWidget(parent)
{
Header::Header(View &parent) :
MarginWidget(parent)
{
- setFocusPolicy(Qt::ClickFocus);
- setMouseTracking(true);
-
connect(&view_, SIGNAL(signals_moved()),
this, SLOT(on_signals_moved()));
}
connect(&view_, SIGNAL(signals_moved()),
this, SLOT(on_signals_moved()));
}
diff --git
a/pv/view/marginwidget.cpp
b/pv/view/marginwidget.cpp
index e44233c80291c8a1cb1bdd2a5078ef9d505d6211..f8302f646f73867589e68027580fb8435e378895 100644
(file)
--- a/
pv/view/marginwidget.cpp
+++ b/
pv/view/marginwidget.cpp
@@
-31,6
+31,8
@@
MarginWidget::MarginWidget(View &parent) :
dragging_(false)
{
setAttribute(Qt::WA_NoSystemBackground, true);
dragging_(false)
{
setAttribute(Qt::WA_NoSystemBackground, true);
+ setFocusPolicy(Qt::ClickFocus);
+ setMouseTracking(true);
}
void MarginWidget::clear_selection()
}
void MarginWidget::clear_selection()
diff --git
a/pv/view/timeitem.hpp
b/pv/view/timeitem.hpp
index 80fecb5dda316caa587f6616d6af814b5187d041..8374244215807b5c34e4433c441c8f4a19582e6d 100644
(file)
--- a/
pv/view/timeitem.hpp
+++ b/
pv/view/timeitem.hpp
@@
-29,6
+29,7
@@
namespace view {
class View;
class TimeItem : public ViewItem
class View;
class TimeItem : public ViewItem
+
{
Q_OBJECT
{
Q_OBJECT