Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CustomView for MapObjects
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Norbert Thoden, SLSE, 2017-04-11
|
||||
*/
|
||||
|
||||
// Own
|
||||
#include "jump_point_custom_view.h"
|
||||
#include "ui_jump_point_custom_view.h"
|
||||
#include "jump_point_model.h"
|
||||
#include <Map/map.h>
|
||||
|
||||
|
||||
// Ot
|
||||
#include <QMenu>
|
||||
#include <QBuffer>
|
||||
#include <QDataWidgetMapper>
|
||||
|
||||
|
||||
namespace SituationMap
|
||||
{
|
||||
|
||||
|
||||
JumpPointCustomView::JumpPointCustomView(QWidget *parent)
|
||||
: BaseClass(parent)
|
||||
, m_ui(new Ui::JumpPointCustomView)
|
||||
, m_mapper(new QDataWidgetMapper(this))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->image->setMenuEnabled(false); // no menu !
|
||||
|
||||
// // to keep toolTip up-to-date:
|
||||
// connect(m_ui->image, &LtsWidgets::LtsImageEditor::imageChanged,
|
||||
// this, &JumpPointCustomView::initToolTip);
|
||||
}
|
||||
|
||||
JumpPointCustomView::~JumpPointCustomView()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
bool JumpPointCustomView::init(const QModelIndex &idx)
|
||||
{
|
||||
if (!idx.isValid())
|
||||
return false;
|
||||
|
||||
if (idx.model() != m_mapper->model())
|
||||
{
|
||||
// create mapping;
|
||||
m_mapper->setModel(const_cast<QAbstractItemModel *>(idx.model()));
|
||||
m_mapper->addMapping(m_ui->lbDescription, JumpPointModel::Columns::NAME, "text");
|
||||
// m_mapper->addMapping(m_ui->image, JumpPointModel::Columns::ICON, "pixmap");
|
||||
}
|
||||
|
||||
setRow(idx.row());
|
||||
return true;
|
||||
}
|
||||
|
||||
void JumpPointCustomView::setRow(int row)
|
||||
{
|
||||
m_mapper->setCurrentIndex(row);
|
||||
|
||||
// assume for now, that the relation between row and uniqueMapId will not change:
|
||||
if (m_mapper && m_mapper->model())
|
||||
{
|
||||
QAbstractItemModel *modelPtr = m_mapper->model();
|
||||
m_name = modelPtr->data(modelPtr->index(row, JumpPointModel::Columns::NAME)).toString();
|
||||
QImage img = modelPtr->data(modelPtr->index(row, JumpPointModel::Columns::ICON)).value<QImage>();
|
||||
m_ui->image->setPixmap(QPixmap::fromImage(img));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace SituationMap
|
||||
Reference in new issue
Block a user