37 : KExtendableItemDelegate(parent),
38 m_allowLetterShortcuts(allowLetterShortcuts),
41 Q_ASSERT(qobject_cast<QAbstractItemView *>(parent));
43 QPixmap pixmap(16, 16);
44 pixmap.fill(QColor(Qt::transparent));
47 option.rect = pixmap.rect();
49 bool isRtl = QApplication::isRightToLeft();
50 QApplication::style()->drawPrimitive(isRtl ? QStyle::PE_IndicatorArrowLeft : QStyle::PE_IndicatorArrowRight, &option, &
p);
52 setExtendPixmap(pixmap);
54 pixmap.fill(QColor(Qt::transparent));
56 QApplication::style()->drawPrimitive(QStyle::PE_IndicatorArrowDown, &option, &
p);
58 setContractPixmap(pixmap);
60 parent->installEventFilter(
this);
64 connect(parent, SIGNAL(clicked(QModelIndex)),
this, SLOT(
itemActivated(QModelIndex)));
67 connect(parent, SIGNAL(collapsed(QModelIndex)),
this, SLOT(
itemCollapsed(QModelIndex)));
72 QTreeWidget *view =
static_cast<QTreeWidget *
>(parent());
75 QTreeWidgetItemIterator it(view, QTreeWidgetItemIterator::NoChildren);
79 if (item && (item->
data(0,
ObjectRole).value<QObject*>() ==
dynamic_cast<QObject*
>(action))) {
84 const QKeySequence primary = cut.isEmpty() ? QKeySequence() : cut.at(0);
85 const QKeySequence alternate = cut.size() <= 1 ? QKeySequence() : cut.at(1);
87 if (primary.matches(seq) != QKeySequence::NoMatch
88 || seq.matches(primary) != QKeySequence::NoMatch) {
92 if (alternate.matches(seq) != QKeySequence::NoMatch
93 || seq.matches(alternate) != QKeySequence::NoMatch) {
114 QTreeWidget *view =
static_cast<QTreeWidget *
>(parent());
122 int column = index.column();
123 if (column ==
Name) {
130 index = index.sibling(index.row(), column);
131 view->selectionModel()->select(index, QItemSelectionModel::SelectCurrent);
135 if (!index.data(ShowExtensionIndicatorRole).value<
bool>()) {
139 if (!isExtended(index)) {
150 QWidget *viewport =
static_cast<QAbstractItemView *
>(parent())->viewport();
180 view->selectionModel()->select(index, QItemSelectionModel::Clear);
227 case QEvent::MouseButtonPress:
228 case QEvent::MouseButtonRelease:
229 case QEvent::MouseButtonDblClick:
234 }
else if (o == parent()) {
240 if (e->type() != QEvent::KeyPress) {
243 QKeyEvent *ke =
static_cast<QKeyEvent *
>(e);
244 QTreeWidget *view =
static_cast<QTreeWidget *
>(parent());
245 QItemSelectionModel *selection = view->selectionModel();
246 QModelIndex index = selection->currentIndex();
256 index = index.sibling(index.row(), index.column() - 1);
259 index = index.sibling(index.row(), index.column() + 1);
265 if (index.isValid()) {
266 selection->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect);
269 view->scrollTo(index, QAbstractItemView::PositionAtCenter);