From b7ff45799cf6baf1c5ac106c5c53f9c29b4ccf7a Mon Sep 17 00:00:00 2001 From: Jay Nabonne Date: Fri, 8 Feb 2019 10:57:08 +0000 Subject: [PATCH] Clean up file. --- include/wx/qt/private/treeitemfactory.h | 37 +++++++++++++++++-------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/include/wx/qt/private/treeitemfactory.h b/include/wx/qt/private/treeitemfactory.h index 886af1e0a5..94ea97a808 100644 --- a/include/wx/qt/private/treeitemfactory.h +++ b/include/wx/qt/private/treeitemfactory.h @@ -1,3 +1,13 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: wx/treeitemfactory.h +// Purpose: Factory to create text edit controls for the tree items +// Author: Graham Dawes +// Modified by: +// Created: 02/2019 +// Copyright: Graham Dawes +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + #ifndef _WX_TREEITEM_FACTORY_H_ #define _WX_TREEITEM_FACTORY_H_ @@ -17,6 +27,7 @@ // // To work around these issues we create a wxTextCtl parented by the wxListCtrl // then recalculate its position relative to the internal widget. + class wxQtListTextCtrl : public wxTextCtrl { public: @@ -27,7 +38,6 @@ public: m_actualParent(actualParent), m_moving(0) { - Bind(wxEVT_MOVE, &wxQtListTextCtrl::onMove, this); } @@ -36,22 +46,23 @@ public: // QWidget::move generates a QMoveEvent so we need to guard against // reentrant calls. wxRecursionGuard guard(m_moving); - if (guard.IsInside()) + + if ( guard.IsInside() ) { event.Skip(); return; } - const QPoint eventPosition = wxQtConvertPoint(event.GetPosition()); - const QPoint globalPosition = m_actualParent->mapToGlobal(eventPosition); + const QPoint eventPos = wxQtConvertPoint(event.GetPosition()); + const QPoint globalPos = m_actualParent->mapToGlobal(eventPos); // For some reason this always gives us the offset from the header info // the internal control. So we need to treat this as an offset rather // than a position. QWidget* widget = GetHandle(); - const QPoint offset = widget->mapFromGlobal(globalPosition); + const QPoint offset = widget->mapFromGlobal(globalPos); - widget->move(eventPosition + offset); + widget->move(eventPos + offset); } private: @@ -64,29 +75,34 @@ private: // QT doesn't give us direct access to the editor within the QTreeWidget. // Instead, we'll supply a factory to create the widget for QT and keep track // of it ourselves. + class wxQtTreeItemEditorFactory : public QItemEditorFactory { public: explicit wxQtTreeItemEditorFactory(wxWindow* parent) : m_parent(parent), - m_textCtrl(NULL) + m_textCtrl(NULL) { } void AttachTo(QTreeWidget *tree) { - QItemDelegate *qItemDelegate = static_cast(tree->itemDelegate()); + QAbstractItemDelegate* delegate = tree->itemDelegate(); + QItemDelegate *qItemDelegate = static_cast(delegate); qItemDelegate->setItemEditorFactory(this); } - QWidget* createEditor(int WXUNUSED(userType), QWidget* parent) const wxOVERRIDE + virtual QWidget* createEditor( + int WXUNUSED(userType), + QWidget* parent + ) const wxOVERRIDE { m_textCtrl = new wxQtListTextCtrl(m_parent, parent); m_textCtrl->SetFocus(); return m_textCtrl->GetHandle(); } - wxTextCtrl* GetEditControl() + wxTextCtrl* GetEditControl() const { return m_textCtrl; } @@ -105,4 +121,3 @@ private: }; #endif //_WX_TREEITEM_FACTORY_H_ -