##// END OF EJS Templates
Promotes hedley dep...
Promotes hedley dep Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>

File last commit:

r1497:1e241bda0af5
r1506:ef7b62ddc473
Show More
DataSourceWidget.cpp
63 lines | 1.9 KiB | text/x-c | CppLexer
/ gui / src / DataSource / DataSourceWidget.cpp
Alexandre Leroux
Creates the data source widget...
r82 #include <DataSource/DataSourceWidget.h>
#include <ui_DataSourceWidget.h>
New data sources system switch complete...
r1495 #include <DataSource/datasources.h>
Product tree features:...
r1497 #include <QCompleter>
New data sources system switch complete...
r1495 #include <SqpApplication.h>
Alexandre Leroux
Creates the data source widget...
r82
Product tree features:...
r1497 #include <QAction>
Alexandre Leroux
Handles right clicking on the tree of the data sources...
r143
PySide2 bindings + some GUI clean...
r1478 namespace
{
Alexandre Leroux
Creates the data source widget...
r82
/// Number of columns displayed in the tree
const auto TREE_NB_COLUMNS = 1;
/// Header labels for the tree
PySide2 bindings + some GUI clean...
r1478 const auto TREE_HEADER_LABELS = QStringList { QObject::tr("Name") };
Alexandre Leroux
Creates the data source widget...
r82
} // namespace
PySide2 bindings + some GUI clean...
r1478 DataSourceWidget::DataSourceWidget(QWidget* parent)
Product tree features:...
r1497 : QWidget { parent }, ui { new Ui::DataSourceWidget }
Alexandre Leroux
Creates the data source widget...
r82 {
Alexandre Leroux
(Minor) Extracts ui of DataSourceWidget
r109 ui->setupUi(this);
New data sources system switch complete...
r1495 m_model_proxy.setSourceModel(&(sqpApp->dataSources()));
ui->treeView->setModel(&m_model_proxy);
ui->treeView->setDragEnabled(true);
m_model_proxy.setFilterRole(Qt::ToolTipRole);
m_model_proxy.setRecursiveFilteringEnabled(true);
Alexandre Leroux
Adds line edit as a search box above data source tree
r475
// Connection to filter tree
Product tree features:...
r1497 connect(ui->filterLineEdit, &QLineEdit::textChanged, &m_model_proxy,
static_cast<void (QSortFilterProxyModel::*)(const QString&)>(
&QSortFilterProxyModel::setFilterRegExp));
sqpApp->dataSources().addIcon("satellite", QVariant(QIcon(":/icones/satellite.svg")));
QAction* expandAll = new QAction("Expand all");
QAction* collapseAll = new QAction("Collapse all");
ui->treeView->addAction(expandAll);
ui->treeView->addAction(collapseAll);
ui->treeView->setContextMenuPolicy(Qt::ActionsContextMenu);
connect(expandAll, &QAction::triggered, [treeView = ui->treeView](bool checked) {
(void)checked;
treeView->expandAll();
});
connect(collapseAll, &QAction::triggered, [treeView = ui->treeView](bool checked) {
(void)checked;
treeView->collapseAll();
});
QCompleter* completer = new QCompleter(this);
completer->setModel(sqpApp->dataSources().completionModel());
completer->setCaseSensitivity(Qt::CaseInsensitive);
ui->filterLineEdit->setCompleter(completer);
Alexandre Leroux
Creates the data source widget...
r82 }
Alexandre Leroux
Implements method to add a data source in the widget...
r83
add missing delete ui
r232 DataSourceWidget::~DataSourceWidget() noexcept
{
delete ui;
}