Maraiah/tycho/cc/mapmodel.cc

45 lines
718 B
C++
Raw Normal View History

2019-07-02 14:57:10 -07:00
#include "tycho.h"
MapModel::MapModel(Project *parent) :
2019-07-05 20:21:11 -07:00
IMapModel(parent)
2019-07-02 14:57:10 -07:00
{
2019-07-05 20:21:11 -07:00
dbgPrintFunc();
2019-07-02 14:57:10 -07:00
}
MapModel::~MapModel()
2019-07-02 14:57:10 -07:00
{
2019-07-05 20:21:11 -07:00
dbgPrintFunc();
2019-07-02 14:57:10 -07:00
}
void MapModel::deselect()
2019-07-03 16:26:28 -07:00
{
2019-07-05 20:21:11 -07:00
IMapModel::deselect();
2019-07-03 16:26:28 -07:00
2019-07-05 20:21:11 -07:00
emit deselected();
2019-07-03 16:26:28 -07:00
}
void MapModel::select(QModelIndex const &index)
2019-07-03 16:26:28 -07:00
{
2019-07-05 20:21:11 -07:00
auto idx = index.internalId();
2019-07-03 16:26:28 -07:00
2019-07-05 20:21:11 -07:00
IMapModel::select(idx);
2019-07-03 16:26:28 -07:00
2019-07-05 20:21:11 -07:00
emit selected(idx);
2019-07-03 16:26:28 -07:00
}
QVariant MapModel::data(const QModelIndex &index, int role) const
2019-07-02 14:57:10 -07:00
{
2019-07-05 20:21:11 -07:00
switch(role) {
case Qt::DecorationRole: {
auto name = propIcon(index.row());
auto icon = name.front() == ':' ? QIcon(name)
: QIcon::fromTheme(name);
return QVariant::fromValue(icon);
}
default:
return IMapModel::data(index, role);
}
2019-07-02 14:57:10 -07:00
}
// EOF