Context menu "Collapse All" and "Expand All".
--HG-- branch : develop
This commit is contained in:
parent
7649ac5f6f
commit
0e5cb30801
|
@ -63,6 +63,7 @@ DialogMDataBase::DialogMDataBase(const QStringList &list, QWidget *parent)
|
||||||
|
|
||||||
connect(ui->treeWidget, &QTreeWidget::itemChanged, this, &DialogMDataBase::UpdateChecks);
|
connect(ui->treeWidget, &QTreeWidget::itemChanged, this, &DialogMDataBase::UpdateChecks);
|
||||||
connect(ui->treeWidget, &QTreeWidget::itemClicked, this, &DialogMDataBase::ShowDescription);
|
connect(ui->treeWidget, &QTreeWidget::itemClicked, this, &DialogMDataBase::ShowDescription);
|
||||||
|
connect(ui->treeWidget, &QTreeWidget::customContextMenuRequested, this, &DialogMDataBase::TreeMenu);
|
||||||
|
|
||||||
ReadSettings();
|
ReadSettings();
|
||||||
}
|
}
|
||||||
|
@ -98,6 +99,8 @@ DialogMDataBase::DialogMDataBase(QWidget *parent)
|
||||||
ui->treeWidget->installEventFilter(this);
|
ui->treeWidget->installEventFilter(this);
|
||||||
|
|
||||||
connect(ui->treeWidget, &QTreeWidget::itemClicked, this, &DialogMDataBase::ShowDescription);
|
connect(ui->treeWidget, &QTreeWidget::itemClicked, this, &DialogMDataBase::ShowDescription);
|
||||||
|
connect(ui->treeWidget, &QTreeWidget::customContextMenuRequested, this, &DialogMDataBase::TreeMenu);
|
||||||
|
connect(ui->treeWidget, &QTreeWidget::itemActivated, this, &DialogMDataBase::ShowDescription);
|
||||||
|
|
||||||
ReadSettings();
|
ReadSettings();
|
||||||
}
|
}
|
||||||
|
@ -185,14 +188,14 @@ bool DialogMDataBase::eventFilter(QObject *target, QEvent *event)
|
||||||
{
|
{
|
||||||
const QModelIndex model = ui->treeWidget->indexAbove(ui->treeWidget->currentIndex());
|
const QModelIndex model = ui->treeWidget->indexAbove(ui->treeWidget->currentIndex());
|
||||||
QTreeWidgetItem *item = ui->treeWidget->itemAbove(ui->treeWidget->currentItem());
|
QTreeWidgetItem *item = ui->treeWidget->itemAbove(ui->treeWidget->currentItem());
|
||||||
emit ShowDescription(item, model.column());
|
ShowDescription(item, model.column());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Qt::Key_Down:
|
case Qt::Key_Down:
|
||||||
{
|
{
|
||||||
const QModelIndex model = ui->treeWidget->indexBelow(ui->treeWidget->currentIndex());
|
const QModelIndex model = ui->treeWidget->indexBelow(ui->treeWidget->currentIndex());
|
||||||
QTreeWidgetItem *item = ui->treeWidget->itemBelow(ui->treeWidget->currentItem());
|
QTreeWidgetItem *item = ui->treeWidget->itemBelow(ui->treeWidget->currentItem());
|
||||||
emit ShowDescription(item, model.column());
|
ShowDescription(item, model.column());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -298,6 +301,26 @@ void DialogMDataBase::ShowDescription(QTreeWidgetItem *item, int column)
|
||||||
ui->textEdit->setHtml(text);
|
ui->textEdit->setHtml(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogMDataBase::TreeMenu(const QPoint &pos)
|
||||||
|
{
|
||||||
|
// Because item also will be selected need to show description
|
||||||
|
const QModelIndex model = ui->treeWidget->currentIndex();
|
||||||
|
QTreeWidgetItem *item = ui->treeWidget->currentItem();
|
||||||
|
ShowDescription(item, model.column());
|
||||||
|
|
||||||
|
QAction *actionCollapseAll = new QAction(tr("Collapse All"), this);
|
||||||
|
connect(actionCollapseAll, &QAction::triggered, ui->treeWidget, &QTreeWidget::collapseAll);
|
||||||
|
|
||||||
|
QAction *actionExpandeAll = new QAction(tr("Expand All"), this);
|
||||||
|
connect(actionExpandeAll, &QAction::triggered, ui->treeWidget, &QTreeWidget::expandAll);
|
||||||
|
|
||||||
|
QMenu menu(this);
|
||||||
|
menu.addAction(actionCollapseAll);
|
||||||
|
menu.addAction(actionExpandeAll);
|
||||||
|
menu.exec(ui->treeWidget->mapToGlobal(pos));
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogMDataBase::InitDataBase(const QStringList &list)
|
void DialogMDataBase::InitDataBase(const QStringList &list)
|
||||||
{
|
{
|
||||||
|
|
|
@ -58,6 +58,7 @@ protected:
|
||||||
private slots:
|
private slots:
|
||||||
void UpdateChecks(QTreeWidgetItem *item, int column);
|
void UpdateChecks(QTreeWidgetItem *item, int column);
|
||||||
void ShowDescription(QTreeWidgetItem *item, int column);
|
void ShowDescription(QTreeWidgetItem *item, int column);
|
||||||
|
void TreeMenu(const QPoint &pos);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogMDataBase)
|
Q_DISABLE_COPY(DialogMDataBase)
|
||||||
|
|
|
@ -36,6 +36,9 @@
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="contextMenuPolicy">
|
||||||
|
<enum>Qt::CustomContextMenu</enum>
|
||||||
|
</property>
|
||||||
<property name="selectionMode">
|
<property name="selectionMode">
|
||||||
<enum>QAbstractItemView::SingleSelection</enum>
|
<enum>QAbstractItemView::SingleSelection</enum>
|
||||||
</property>
|
</property>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user