[qet] qet/qet: [4887] Master, slave and report QTreeWidget used for Xref : |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 4887
Author: blacksun
Date: 2017-01-30 15:29:01 +0100 (Mon, 30 Jan 2017)
Log Message:
-----------
Master, slave and report QTreeWidget used for Xref :
The header of the QTreeWidget have a context menu used to save the current state of the columns (size and position).
Modified Paths:
--------------
trunk/sources/ui/linksingleelementwidget.cpp
trunk/sources/ui/linksingleelementwidget.h
trunk/sources/ui/masterpropertieswidget.cpp
trunk/sources/ui/masterpropertieswidget.h
Modified: trunk/sources/ui/linksingleelementwidget.cpp
===================================================================
--- trunk/sources/ui/linksingleelementwidget.cpp 2017-01-29 18:43:42 UTC (rev 4886)
+++ trunk/sources/ui/linksingleelementwidget.cpp 2017-01-30 14:29:01 UTC (rev 4887)
@@ -44,6 +44,7 @@
m_link_action = new QAction(tr("Lier l'élément"), this);
m_show_qtwi = new QAction(tr("Montrer l'élément"), this);
m_show_element = new QAction(tr("Montrer l'élément esclave"), this);
+ m_save_header_state = new QAction(tr("Enregistrer la disposition"), this);
connect(m_show_qtwi, &QAction::triggered, [this]() {this->on_m_tree_widget_itemDoubleClicked(this->m_qtwi_at_context_menu, 0);});
connect(m_link_action, &QAction::triggered, this, &LinkSingleElementWidget::linkTriggered);
@@ -56,9 +57,19 @@
m_showed_element->setHighlighted(false);
});
-// QHeaderView *qhv = ui->m_tree_widget->header();
-// qhv->setContextMenuPolicy(Qt::CustomContextMenu);
-// connect(qhv, &QHeaderView::customContextMenuRequested, [](){qDebug() << "test";});
+ QHeaderView *qhv = ui->m_tree_widget->header();
+ qhv->setContextMenuPolicy(Qt::CustomContextMenu);
+ connect(qhv, &QHeaderView::customContextMenuRequested, this, &LinkSingleElementWidget::headerCustomContextMenuRequested);
+ connect(m_save_header_state, &QAction::triggered, [this, qhv]()
+ {
+ QByteArray qba = qhv->saveState();
+ QSettings settings;
+
+ if (this->m_element->linkType() & Element::AllReport)
+ settings.setValue("link-element-widget/report-state", qba);
+ else if (this->m_element->linkType() == Element::Slave)
+ settings.setValue("link-element-widget/slave-state", qba);
+ });
setElement(elmt);
}
@@ -196,6 +207,7 @@
{
clearTreeWidget();
setUpHeaderLabels();
+ ui->m_tree_widget->header()->resetDefaultSectionSize();
if (m_element->linkType() == Element::Slave)
{
@@ -229,6 +241,11 @@
m_qtwi_elmt_hash.insert(qtwi, elmt);
m_qtwi_strl_hash.insert(qtwi, search_list);
}
+
+ QSettings settings;
+ QVariant v = settings.value("link-element-widget/slave-state");
+ if(!v.isNull())
+ ui->m_tree_widget->header()->restoreState(v.toByteArray());
}
else if (m_element->linkType() & Element::AllReport)
@@ -272,6 +289,11 @@
m_qtwi_elmt_hash.insert(qtwi, elmt);
m_qtwi_strl_hash.insert(qtwi, search_list);
}
+
+ QSettings settings;
+ QVariant v = settings.value("link-element-widget/report-state");
+ if(!v.isNull())
+ ui->m_tree_widget->header()->restoreState(v.toByteArray());
}
setUpCompleter();
@@ -452,6 +474,13 @@
ui->m_search_field->hide();
}
+void LinkSingleElementWidget::headerCustomContextMenuRequested(const QPoint &pos)
+{
+ m_context_menu->clear();
+ m_context_menu->addAction(m_save_header_state);
+ m_context_menu->popup(ui->m_tree_widget->header()->mapToGlobal(pos));
+}
+
void LinkSingleElementWidget::on_m_unlink_pb_clicked()
{
m_unlink = true;
Modified: trunk/sources/ui/linksingleelementwidget.h
===================================================================
--- trunk/sources/ui/linksingleelementwidget.h 2017-01-29 18:43:42 UTC (rev 4886)
+++ trunk/sources/ui/linksingleelementwidget.h 2017-01-30 14:29:01 UTC (rev 4887)
@@ -70,6 +70,7 @@
void linkTriggered();
void hideButtons();
void showButtons();
+ void headerCustomContextMenuRequested(const QPoint &pos);
void on_m_unlink_pb_clicked();
void on_m_tree_widget_itemDoubleClicked(QTreeWidgetItem *item, int column);
@@ -97,7 +98,8 @@
QMenu *m_context_menu;
QAction *m_link_action,
*m_show_qtwi,
- *m_show_element;
+ *m_show_element,
+ *m_save_header_state;
};
#endif // LINKSINGLEELEMENTWIDGET_H
Modified: trunk/sources/ui/masterpropertieswidget.cpp
===================================================================
--- trunk/sources/ui/masterpropertieswidget.cpp 2017-01-29 18:43:42 UTC (rev 4886)
+++ trunk/sources/ui/masterpropertieswidget.cpp 2017-01-30 14:29:01 UTC (rev 4887)
@@ -46,6 +46,7 @@
m_unlink_action = new QAction(tr("Délier l'élément"), this);
m_show_qtwi = new QAction(tr("Montrer l'élément"), this);
m_show_element = new QAction(tr("Montrer l'élément maître"), this);
+ m_save_header_state = new QAction(tr("Enregistrer la disposition"), this);
connect(ui->m_free_tree_widget, &QTreeWidget::itemDoubleClicked, this, &MasterPropertiesWidget::showElementFromTWI);
connect(ui->m_link_tree_widget, &QTreeWidget::itemDoubleClicked, this, &MasterPropertiesWidget::showElementFromTWI);
@@ -65,6 +66,16 @@
m_showed_element->setHighlighted(false);
});
+ QHeaderView *qhv = ui->m_free_tree_widget->header();
+ qhv->setContextMenuPolicy(Qt::CustomContextMenu);
+ connect(qhv, &QHeaderView::customContextMenuRequested, this, &MasterPropertiesWidget::headerCustomContextMenuRequested);
+ connect(m_save_header_state, &QAction::triggered, [this, qhv]()
+ {
+ QByteArray qba = qhv->saveState();
+ QSettings settings;
+ settings.setValue("link-element-widget/master-state", qba);
+ });
+
setElement(elmt);
}
@@ -249,7 +260,20 @@
if(items_list.count())
ui->m_link_tree_widget->addTopLevelItems(items_list);
+ QSettings settings;
+ QVariant v = settings.value("link-element-widget/master-state");
+ if(!v.isNull())
+ {
+ ui->m_free_tree_widget->header()->restoreState(v.toByteArray());
+ ui->m_link_tree_widget->header()->restoreState(v.toByteArray());
+ }
+}
+void MasterPropertiesWidget::headerCustomContextMenuRequested(const QPoint &pos)
+{
+ m_context_menu->clear();
+ m_context_menu->addAction(m_save_header_state);
+ m_context_menu->popup(ui->m_free_tree_widget->header()->mapToGlobal(pos));
}
/**
Modified: trunk/sources/ui/masterpropertieswidget.h
===================================================================
--- trunk/sources/ui/masterpropertieswidget.h 2017-01-29 18:43:42 UTC (rev 4886)
+++ trunk/sources/ui/masterpropertieswidget.h 2017-01-30 14:29:01 UTC (rev 4887)
@@ -59,6 +59,7 @@
void updateUi();
private slots:
+ void headerCustomContextMenuRequested(const QPoint &pos);
void on_link_button_clicked();
void on_unlink_button_clicked();
void showElementFromTWI(QTreeWidgetItem *qtwi, int column);
@@ -76,7 +77,8 @@
QAction *m_link_action,
*m_unlink_action,
*m_show_qtwi,
- *m_show_element;
+ *m_show_element,
+ *m_save_header_state;
};
#endif // MASTERPROPERTIESWIDGET_H