Implement basic styles for wxTreeCtrl under wxQT
This commit is contained in:
parent
308ef18a6d
commit
8efe01bd8e
@ -112,6 +112,8 @@ public:
|
||||
|
||||
virtual bool GetBoundingRect(const wxTreeItemId& item, wxRect& rect, bool textOnly = false) const wxOVERRIDE;
|
||||
|
||||
virtual void SetWindowStyleFlag(long styles) wxOVERRIDE;
|
||||
|
||||
virtual QWidget *GetHandle() const wxOVERRIDE;
|
||||
|
||||
protected:
|
||||
|
@ -71,6 +71,7 @@ bool wxTreeCtrl::Create(wxWindow *parent, wxWindowID id,
|
||||
const wxString& name)
|
||||
{
|
||||
m_qtTreeWidget = new wxQTreeWidget(parent, this);
|
||||
SetWindowStyleFlag(style);
|
||||
|
||||
return QtCreateControl(parent, id, pos, size, style, validator, name);
|
||||
}
|
||||
@ -337,9 +338,7 @@ void wxTreeCtrl::SetFocusedItem(const wxTreeItemId& item)
|
||||
|
||||
void wxTreeCtrl::ClearFocusedItem()
|
||||
{
|
||||
QTreeWidgetItem *current = m_qtTreeWidget->currentItem();
|
||||
if (current != NULL)
|
||||
current->setSelected(false);
|
||||
m_qtTreeWidget->setCurrentItem(NULL);
|
||||
}
|
||||
|
||||
wxTreeItemId wxTreeCtrl::GetFocusedItem() const
|
||||
@ -622,11 +621,7 @@ void wxTreeCtrl::SelectItem(const wxTreeItemId& item, bool select)
|
||||
{
|
||||
QList<QTreeWidgetItem *> selections = m_qtTreeWidget->selectedItems();
|
||||
const size_t nSelections = selections.size();
|
||||
|
||||
for (size_t i = 0; i < nSelections; ++i)
|
||||
{
|
||||
selections[i]->setSelected(false);
|
||||
}
|
||||
m_qtTreeWidget->clearSelection();
|
||||
}
|
||||
|
||||
QTreeWidgetItem *qTreeItem = wxQtConvertTreeItem(item);
|
||||
@ -700,6 +695,13 @@ bool wxTreeCtrl::GetBoundingRect(const wxTreeItemId& item, wxRect& rect, bool te
|
||||
return false;
|
||||
}
|
||||
|
||||
void wxTreeCtrl::SetWindowStyleFlag(long styles)
|
||||
{
|
||||
wxControl::SetWindowStyleFlag(styles);
|
||||
m_qtTreeWidget->invisibleRootItem()->setHidden((styles & wxTR_HIDE_ROOT) != 0);
|
||||
m_qtTreeWidget->setSelectionMode(styles & wxTR_MULTIPLE ? QTreeWidget::MultiSelection : QTreeWidget::SingleSelection);
|
||||
}
|
||||
|
||||
int wxTreeCtrl::DoGetItemState(const wxTreeItemId& item) const
|
||||
{
|
||||
wxCHECK_MSG(item.IsOk(), wxTREE_ITEMSTATE_NONE, "invalid tree item");
|
||||
|
Loading…
Reference in New Issue
Block a user