X-Git-Url: http://git.code-monkey.de/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Fmarginwidget.cpp;h=0d35c5fc6e981718513e7c56d421fd3d8be98ada;hp=2ef262762cc0c13a7683b0aa7379099e3fca2502;hb=efdec55aec1a137460fa362a381ed1904182bfed;hpb=5a6a4ce3e32a250cd586f4755573ed3bed530d7b diff --git a/pv/view/marginwidget.cpp b/pv/view/marginwidget.cpp index 2ef2627..0d35c5f 100644 --- a/pv/view/marginwidget.cpp +++ b/pv/view/marginwidget.cpp @@ -14,8 +14,7 @@ * 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, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * along with this program; if not, see . */ #include @@ -30,16 +29,19 @@ using std::shared_ptr; namespace pv { -namespace view { +namespace views { +namespace TraceView { MarginWidget::MarginWidget(View &parent) : - QWidget(&parent), - view_(parent), - dragging_(false) + ViewWidget(parent) { setAttribute(Qt::WA_NoSystemBackground, true); - setFocusPolicy(Qt::ClickFocus); - setMouseTracking(true); +} + +void MarginWidget::item_clicked(const shared_ptr &item) +{ + if (item && item->enabled()) + show_popup(item); } void MarginWidget::show_popup(const shared_ptr &item) @@ -49,12 +51,6 @@ void MarginWidget::show_popup(const shared_ptr &item) p->show(); } -void MarginWidget::leaveEvent(QEvent*) -{ - mouse_point_ = QPoint(-1, -1); - update(); -} - void MarginWidget::contextMenuEvent(QContextMenuEvent *event) { const shared_ptr r = get_mouse_over_item(mouse_point_); @@ -66,13 +62,18 @@ void MarginWidget::contextMenuEvent(QContextMenuEvent *event) menu->exec(event->globalPos()); } -void MarginWidget::clear_selection() +void MarginWidget::keyPressEvent(QKeyEvent *event) { - const auto items = this->items(); - for (auto &i : items) - i->select(false); - update(); + assert(event); + + if (event->key() == Qt::Key_Delete) { + const auto items = this->items(); + for (auto &i : items) + if (i->selected()) + i->delete_pressed(); + } } -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv