WidgetBoxCategoryListView *WidgetBoxTreeWidget::addCategoryView(QTreeWidgetItem *parent, bool iconMode) { QTreeWidgetItem *embed_item = new QTreeWidgetItem(parent); embed_item->setFlags(Qt::ItemIsEnabled); WidgetBoxCategoryListView *categoryView = new WidgetBoxCategoryListView(m_core, this); categoryView->setViewMode(iconMode ? QListView::IconMode : QListView::ListMode); connect(categoryView, SIGNAL(scratchPadChanged()), this, SLOT(slotSave())); connect(categoryView, SIGNAL(pressed(QString,QString,QPoint)), this, SIGNAL(pressed(QString,QString,QPoint))); connect(categoryView, SIGNAL(itemRemoved()), this, SLOT(slotScratchPadItemDeleted())); connect(categoryView, SIGNAL(lastItemRemoved()), this, SLOT(slotLastScratchPadItemDeleted())); setItemWidget(embed_item, 0, categoryView); return categoryView; }
void WidgetBoxCategoryListView::removeCurrentItem() { const QModelIndex index = currentIndex(); if (!index.isValid() || !m_proxyModel->removeRow(index.row())) return; // We check the unfiltered item count here, we don't want to get removed if the // filtered view is empty if (m_model->rowCount()) { emit itemRemoved(); } else { emit lastItemRemoved(); } }