16#include <QApplication>
20#include <QTreeWidgetItemIterator>
27 QTreeWidgetItem *item =
static_cast<QTreeWidgetHack *
>(
w)->itemFromIndex(index);
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);
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) {
103 const QModelIndex &index)
const
105 QSize ret(KExtendableItemDelegate::sizeHint(option, index));
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);
193 const QAbstractItemModel *model = index.model();
194 for (
int row = 0; row < model->rowCount(index); ++row) {
195 for (
int col = 0; col < index.model()->columnCount(index); ++col) {
196 QModelIndex colIndex = model->index(row, col, index);
208 if (!hidden || !item) {
211 QTreeWidget *view =
static_cast<QTreeWidget *
>(parent());
212 QTreeWidgetItem *editingItem = ::itemFromIndex(view,
m_editingIndex);
213 if (editingItem == item) {
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);
279 QVariant ret = QVariant::fromValue(seq);
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void keySequenceChanged(const QKeySequence &)
void hiddenBySearchLine(QTreeWidgetItem *, bool)
void itemCollapsed(QModelIndex index)
KisShortcutsEditorDelegate(QTreeWidget *parent, bool allowLetterShortcuts)
QList< KisKActionCollection * > m_checkActionCollections
List of actionCollections to check for conflicts.
QPersistentModelIndex m_editingIndex
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override
void stealShortcut(const QKeySequence &seq, QAction *action)
bool m_allowLetterShortcuts
void setCheckActionCollections(const QList< KisKActionCollection * > checkActionCollections)
void itemActivated(QModelIndex index)
bool eventFilter(QObject *, QEvent *) override
void shortcutChanged(QVariant, const QModelIndex &)
void setNameBold(bool flag)
QVariant data(int column, int role=Qt::DisplayRole) const override
void setKeySequence(uint column, const QKeySequence &seq)