##// END OF EJS Templates
Adds actions for items in the DataSourceWidget...
Adds actions for items in the DataSourceWidget For each item will be associated actions (generated from the model of the item) that will be displayed in the menu when right clicking on the item in the tree

File last commit:

r79:0afc39d45cc4
r142:11579fae1cc2
Show More
DataSourceItem.cpp
56 lines | 1.4 KiB | text/x-c | CppLexer
Alexandre Leroux
Define a data source item
r35 #include <DataSource/DataSourceItem.h>
#include <QVector>
struct DataSourceItem::DataSourceItemPrivate {
Alexandre Leroux
Adds type for a data source item...
r79 explicit DataSourceItemPrivate(DataSourceItemType type, QVector<QVariant> data)
: m_Parent{nullptr}, m_Children{}, m_Type{type}, m_Data{std::move(data)}
Alexandre Leroux
Define a data source item
r35 {
}
DataSourceItem *m_Parent;
std::vector<std::unique_ptr<DataSourceItem> > m_Children;
Alexandre Leroux
Adds type for a data source item...
r79 DataSourceItemType m_Type;
Alexandre Leroux
Define a data source item
r35 QVector<QVariant> m_Data;
};
Alexandre Leroux
Adds type for a data source item...
r79 DataSourceItem::DataSourceItem(DataSourceItemType type, QVector<QVariant> data)
: impl{spimpl::make_unique_impl<DataSourceItemPrivate>(type, std::move(data))}
Alexandre Leroux
Define a data source item
r35 {
}
void DataSourceItem::appendChild(std::unique_ptr<DataSourceItem> child) noexcept
{
child->impl->m_Parent = this;
impl->m_Children.push_back(std::move(child));
}
DataSourceItem *DataSourceItem::child(int childIndex) const noexcept
{
if (childIndex < 0 || childIndex >= childCount()) {
return nullptr;
}
else {
return impl->m_Children.at(childIndex).get();
}
}
int DataSourceItem::childCount() const noexcept
{
return impl->m_Children.size();
}
QVariant DataSourceItem::data(int dataIndex) const noexcept
{
return impl->m_Data.value(dataIndex);
}
DataSourceItem *DataSourceItem::parentItem() const noexcept
{
return impl->m_Parent;
}
Alexandre Leroux
Adds type for a data source item...
r79
DataSourceItemType DataSourceItem::type() const noexcept
{
return impl->m_Type;
}