Mercurial > projects > qtd
diff demos/browser/edittreeview.d @ 73:7bfd46c330dc
more porting
author | mandel |
---|---|
date | Fri, 22 May 2009 10:59:00 +0000 |
parents | 71b382c10ef6 |
children | 37caa90ce503 |
line wrap: on
line diff
--- a/demos/browser/edittreeview.d Wed May 20 22:44:31 2009 +0000 +++ b/demos/browser/edittreeview.d Fri May 22 10:59:00 2009 +0000 @@ -42,43 +42,43 @@ module edittreeview; -import QtGui.QTreeView; -import QtGui.QKeyEvent; +import qt.gui.QTreeView; +import qt.gui.QKeyEvent; + class EditTreeView : public QTreeView { - Q_OBJECT +public: + + this(QWidget parent = null) + { + super(parent); + } + + void keyPressEvent(QKeyEvent event) + { + if ((event.key() == Qt.Key_Delete || event.key() == Qt.Key_Backspace) && model()) { + removeOne(); + } else { + QAbstractItemView::keyPressEvent(event); + } + } public: -this(QWidget *parent = null) -{ - super(parent); -} - void keyPressEvent(QKeyEvent *event) -{ - if ((event.key() == Qt::Key_Delete - || event.key() == Qt::Key_Backspace) - && model()) { - removeOne(); - } else { - QAbstractItemView::keyPressEvent(event); - } -} -public slots: - void removeOne() -{ - if (!model()) - return; - QModelIndex ci = currentIndex(); - int row = ci.row(); - model().removeRow(row, ci.parent()); + void removeOne() + { + if (!model()) + return; + QModelIndex ci = currentIndex(); + int row = ci.row(); + model().removeRow(row, ci.parent()); + } + + void removeAll() + { + if (!model()) + return; + model().removeRows(0, model().rowCount(rootIndex()), rootIndex()); + } } - - void removeAll() -{ - if (!model()) - return; - model().removeRows(0, model().rowCount(rootIndex()), rootIndex()); -} -}