##// END OF EJS Templates
Add dependencies between target to avoid bug compilation when building...
Add dependencies between target to avoid bug compilation when building in multithread

File last commit:

r90:afb77b3143a6
r100:e9600607c0d7
Show More
DataSourceWidget.cpp
63 lines | 1.8 KiB | text/x-c | CppLexer
/ gui / src / DataSource / DataSourceWidget.cpp
Alexandre Leroux
Creates the data source widget...
r81 #include <DataSource/DataSourceWidget.h>
#include <ui_DataSourceWidget.h>
#include <DataSource/DataSourceItem.h>
#include <DataSource/DataSourceTreeWidgetItem.h>
namespace {
/// Number of columns displayed in the tree
const auto TREE_NB_COLUMNS = 1;
/// Header labels for the tree
const auto TREE_HEADER_LABELS = QStringList{QObject::tr("Name")};
Alexandre Leroux
Implements method to add a data source in the widget...
r82 /**
* Creates the item associated to a data source
* @param dataSource the data source for which to create the item
* @return the new item
*/
DataSourceTreeWidgetItem *createTreeWidgetItem(DataSourceItem *dataSource)
{
// Creates item for the data source
auto item = new DataSourceTreeWidgetItem{dataSource};
// Generates items for the children of the data source
for (auto i = 0; i < dataSource->childCount(); ++i) {
item->addChild(createTreeWidgetItem(dataSource->child(i)));
}
return item;
}
Alexandre Leroux
Creates the data source widget...
r81 } // namespace
class DataSourceWidget::DataSourceWidgetPrivate {
public:
explicit DataSourceWidgetPrivate(DataSourceWidget &widget)
: m_Ui{std::make_unique<Ui::DataSourceWidget>()}
{
m_Ui->setupUi(&widget);
// Set tree properties
m_Ui->treeWidget->setColumnCount(TREE_NB_COLUMNS);
m_Ui->treeWidget->setHeaderLabels(TREE_HEADER_LABELS);
}
std::unique_ptr<Ui::DataSourceWidget> m_Ui;
};
DataSourceWidget::DataSourceWidget(QWidget *parent)
: QWidget{parent}, impl{spimpl::make_unique_impl<DataSourceWidgetPrivate>(*this)}
{
}
Alexandre Leroux
Implements method to add a data source in the widget...
r82
Alexandre Leroux
Change signal/slot signature for data source
r90 void DataSourceWidget::addDataSource(DataSourceItem *dataSource) noexcept
Alexandre Leroux
Implements method to add a data source in the widget...
r82 {
// Creates the item associated to the source and adds it to the tree widget. The tree widget
// takes the ownership of the item
Alexandre Leroux
Change signal/slot signature for data source
r90 if (dataSource) {
impl->m_Ui->treeWidget->addTopLevelItem(createTreeWidgetItem(dataSource));
}
Alexandre Leroux
Implements method to add a data source in the widget...
r82 }