X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fview%2Fmarginwidget.cpp;h=0d35c5fc6e981718513e7c56d421fd3d8be98ada;hb=9a267f8dec48c9a28472c1a3bb146c624819e98b;hp=fcbb31bf0174bb1944286005b11d0d978d715126;hpb=40aca27ed83559f7f79873e353f64d2c36a18fce;p=pulseview.git
diff --git a/pv/view/marginwidget.cpp b/pv/view/marginwidget.cpp
index fcbb31b..0d35c5f 100644
--- a/pv/view/marginwidget.cpp
+++ b/pv/view/marginwidget.cpp
@@ -14,11 +14,9 @@
* 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
#include
#include
@@ -31,15 +29,19 @@
using std::shared_ptr;
namespace pv {
-namespace view {
+namespace views {
+namespace TraceView {
MarginWidget::MarginWidget(View &parent) :
- ViewWidget(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,116 +51,6 @@ void MarginWidget::show_popup(const shared_ptr &item)
p->show();
}
-void MarginWidget::mouse_left_press_event(QMouseEvent *event)
-{
- (void)event;
-
- const bool ctrl_pressed =
- QApplication::keyboardModifiers() & Qt::ControlModifier;
-
- // Clear selection if control is not pressed and this item is unselected
- if ((!mouse_down_item_ || !mouse_down_item_->selected()) &&
- !ctrl_pressed)
- clear_selection();
-
- // Set the signal selection state if the item has been clicked
- if (mouse_down_item_) {
- if (ctrl_pressed)
- mouse_down_item_->select(!mouse_down_item_->selected());
- else
- mouse_down_item_->select(true);
- }
-
- // Save the offsets of any signals which will be dragged
- const auto items = this->items();
- for (auto &i : items)
- if (i->selected())
- i->drag();
-
- selection_changed();
- update();
-}
-
-void MarginWidget::mouse_left_release_event(QMouseEvent *event)
-{
- assert(event);
-
- auto items = this->items();
- const bool ctrl_pressed =
- QApplication::keyboardModifiers() & Qt::ControlModifier;
-
- // Unselect everything if control is not pressed
- const shared_ptr mouse_over =
- get_mouse_over_item(event->pos());
-
- for (auto &i : items)
- i->drag_release();
-
- if (dragging_)
- view_.restack_all_row_items();
- else
- {
- if (!ctrl_pressed) {
- for (shared_ptr i : items)
- if (mouse_down_item_ != i)
- i->select(false);
-
- if (mouse_down_item_)
- show_popup(mouse_down_item_);
- }
- }
-
- dragging_ = false;
-}
-
-void MarginWidget::mousePressEvent(QMouseEvent *event)
-{
- assert(event);
-
- mouse_down_point_ = event->pos();
- mouse_down_item_ = get_mouse_over_item(event->pos());
-
- if (event->button() & Qt::LeftButton)
- mouse_left_press_event(event);
-}
-
-void MarginWidget::mouseReleaseEvent(QMouseEvent *event)
-{
- assert(event);
- if (event->button() & Qt::LeftButton)
- mouse_left_release_event(event);
-
- mouse_down_item_ = nullptr;
-}
-
-void MarginWidget::mouseMoveEvent(QMouseEvent *event)
-{
- assert(event);
- mouse_point_ = event->pos();
-
- if (!(event->buttons() & Qt::LeftButton))
- return;
-
- if ((event->pos() - mouse_down_point_).manhattanLength() <
- QApplication::startDragDistance())
- return;
-
- if (!accept_drag())
- return;
-
- // Do the drag
- dragging_ = true;
- drag_items(event->pos() - mouse_down_point_);
-
- update();
-}
-
-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_);
@@ -170,12 +62,11 @@ void MarginWidget::contextMenuEvent(QContextMenuEvent *event)
menu->exec(event->globalPos());
}
-void MarginWidget::keyPressEvent(QKeyEvent *e)
+void MarginWidget::keyPressEvent(QKeyEvent *event)
{
- assert(e);
+ assert(event);
- if (e->key() == Qt::Key_Delete)
- {
+ if (event->key() == Qt::Key_Delete) {
const auto items = this->items();
for (auto &i : items)
if (i->selected())
@@ -183,13 +74,6 @@ void MarginWidget::keyPressEvent(QKeyEvent *e)
}
}
-void MarginWidget::clear_selection()
-{
- const auto items = this->items();
- for (auto &i : items)
- i->select(false);
- update();
-}
-
-} // namespace view
+} // namespace TraceView
+} // namespace views
} // namespace pv