5#include "PlacemarkEditHeader.h"
6#include "ui_PlacemarkEditHeader.h"
8#include "MarbleDebug.h"
14class PlacemarkEditHeaderPrivate :
public Ui::PlacemarkEditHeaderPrivate
17 explicit PlacemarkEditHeaderPrivate(PlacemarkEditHeader *_q);
18 ~PlacemarkEditHeaderPrivate();
22 void setName(
const QString &name);
24 void setIconLink(
const QString &iconLink);
26 qreal longitude()
const;
27 void setLongitude(qreal longitude);
28 qreal latitude()
const;
29 void setLatitude(qreal latitude);
34 bool isIdVisible()
const;
35 void setIdVisible(
bool visible);
36 bool isIdValid()
const;
38 bool positionVisible()
const;
39 void setPositionVisible(
bool visible);
41 void setTargetId(
const QString &targetId);
43 void setTargetIdList(
const QStringList &targetIdList);
44 bool isTargetIdVisible()
const;
45 void setTargetIdVisible(
bool visible);
50 PlacemarkEditHeader *
const q;
51 bool m_positionVisible;
59PlacemarkEditHeaderPrivate::PlacemarkEditHeaderPrivate(PlacemarkEditHeader *_q)
61 , m_positionVisible(true)
62 , m_idWasEdited(false)
66PlacemarkEditHeaderPrivate::~PlacemarkEditHeaderPrivate() =
default;
68void PlacemarkEditHeaderPrivate::init(
QWidget *parent)
71 m_longitude->setDimension(LatLonEdit::Longitude);
72 m_latitude->setDimension(LatLonEdit::Latitude);
73 m_targetId->setVisible(
false);
74 targetIdLabel->setVisible(
false);
76 QObject::connect(iconLinkButton, SIGNAL(clicked()), q, SLOT(loadIconFile()));
81 m_longitude->setNotation(notation);
82 m_latitude->setNotation(notation);
87 return m_longitude->notation();
90void PlacemarkEditHeaderPrivate::setName(
const QString &name)
92 m_name->setText(name);
98QString PlacemarkEditHeaderPrivate::name()
const
100 return m_name->text();
103void PlacemarkEditHeaderPrivate::setIconLink(
const QString &iconLink)
106 if (!pixmap.isNull()) {
108 m_iconLink->setText(iconLink);
109 iconLinkButton->setText(
QString());
110 iconLinkButton->setIcon(icon);
114QString PlacemarkEditHeaderPrivate::iconLink()
const
116 return m_iconLink->text();
119qreal PlacemarkEditHeaderPrivate::longitude()
const
121 return m_longitude->value();
124void PlacemarkEditHeaderPrivate::setLongitude(qreal longitude)
126 m_longitude->setValue(longitude);
129qreal PlacemarkEditHeaderPrivate::latitude()
const
131 return m_latitude->value();
134void PlacemarkEditHeaderPrivate::setLatitude(qreal latitude)
136 m_latitude->setValue(latitude);
139QString PlacemarkEditHeaderPrivate::id()
const
144QString PlacemarkEditHeaderPrivate::setId(
const QString &
id,
bool isNew)
147 if (newId == m_idString && !isNew) {
153 if (m_idFilter.
contains(newId) && m_id->hasFocus()) {
159 for (
const QString &filterString : std::as_const(m_idFilter)) {
160 if (filterString.startsWith(newId)) {
161 filter.append(filterString);
173 m_id->setText(newId);
177QStringList PlacemarkEditHeaderPrivate::idFilter()
const
182void PlacemarkEditHeaderPrivate::setIdFilter(
const QStringList &filter)
188bool PlacemarkEditHeaderPrivate::isIdVisible()
const
190 return m_id->isVisible() && idLabel->isVisible();
193void PlacemarkEditHeaderPrivate::setIdVisible(
bool visible)
195 m_id->setVisible(visible);
196 idLabel->setVisible(visible);
199bool PlacemarkEditHeaderPrivate::isIdValid()
const
204void PlacemarkEditHeaderPrivate::loadIconFile()
211 setIconLink(filename);
212 iconLinkButton->setIcon(
QIcon(filename));
215bool PlacemarkEditHeaderPrivate::positionVisible()
const
217 return m_positionVisible;
220void PlacemarkEditHeaderPrivate::setPositionVisible(
bool visible)
222 m_longitude->setVisible(visible);
223 m_latitude->setVisible(visible);
224 positionLabel->setVisible(visible);
225 m_positionVisible = visible;
228QString PlacemarkEditHeaderPrivate::targetId()
const
230 return m_targetId->currentText();
233void PlacemarkEditHeaderPrivate::setTargetId(
const QString &targetId)
235 m_targetId->setCurrentIndex(m_targetId->findText(targetId));
236 m_targetIdString = targetId;
239QStringList PlacemarkEditHeaderPrivate::targetIdList()
const
242 for (
int i = 0; i < m_targetId->count(); ++i) {
243 result.
append(m_targetId->itemText(i));
248void PlacemarkEditHeaderPrivate::setTargetIdList(
const QStringList &targetIdList)
251 if (m_targetId->currentIndex() != -1) {
252 current = m_targetId->currentText();
254 current = m_targetIdString;
257 m_targetId->addItems(targetIdList);
258 setTargetId(current);
261bool PlacemarkEditHeaderPrivate::isTargetIdVisible()
const
263 return m_targetId->isVisible() && targetIdLabel->isVisible();
266void PlacemarkEditHeaderPrivate::setTargetIdVisible(
bool visible)
268 m_targetId->setVisible(visible);
269 targetIdLabel->setVisible(visible);
272void PlacemarkEditHeaderPrivate::updateValues()
274 if (m_idString !=
id()) {
276 m_idWasEdited =
true;
277 }
else if (!m_idWasEdited && isIdVisible()) {
282void PlacemarkEditHeaderPrivate::selectAll()
291PlacemarkEditHeader::PlacemarkEditHeader(
QWidget *parent,
298 , d(new PlacemarkEditHeaderPrivate(this))
301 d->setNotation(notation);
303 d->setIconLink(iconLink);
304 d->setIdFilter(idFilter);
305 d->setId(
id.isEmpty() ? d->name() :
id);
306 connect(d->m_longitude, SIGNAL(valueChanged(qreal)),
this, SLOT(updateValues()));
307 connect(d->m_latitude, SIGNAL(valueChanged(qreal)),
this, SLOT(updateValues()));
308 connect(d->m_name, SIGNAL(textChanged(
QString)),
this, SLOT(updateValues()));
309 connect(d->m_iconLink, SIGNAL(textChanged(
QString)),
this, SLOT(updateValues()));
310 connect(d->m_id, SIGNAL(textChanged(
QString)),
this, SLOT(updateValues()));
313PlacemarkEditHeader::~PlacemarkEditHeader()
318QString PlacemarkEditHeader::name()
const
323QString PlacemarkEditHeader::iconLink()
const
325 return d->iconLink();
328qreal PlacemarkEditHeader::latitude()
const
330 return d->latitude();
333qreal PlacemarkEditHeader::longitude()
const
335 return d->longitude();
340 return d->notation();
343bool PlacemarkEditHeader::positionVisible()
const
345 return d->positionVisible();
348QString PlacemarkEditHeader::id()
const
355 return d->idFilter();
358bool PlacemarkEditHeader::isIdVisible()
const
360 return d->isIdVisible();
363bool PlacemarkEditHeader::isIdValid()
const
365 return d->isIdValid();
368QString PlacemarkEditHeader::targetId()
const
370 return d->targetId();
373QStringList PlacemarkEditHeader::targetIdList()
const
375 return d->targetIdList();
378bool PlacemarkEditHeader::isTargetIdVisible()
const
380 return d->isTargetIdVisible();
383void PlacemarkEditHeader::setName(
const QString &name)
388void PlacemarkEditHeader::setIconLink(
const QString &iconLink)
390 d->setIconLink(iconLink);
393void PlacemarkEditHeader::setLatitude(qreal latitude)
395 d->setLatitude(latitude);
398void PlacemarkEditHeader::setLongitude(qreal longitude)
400 d->setLongitude(longitude);
405 d->setNotation(notation);
408void PlacemarkEditHeader::setPositionVisible(
bool visible)
410 d->setPositionVisible(
visible);
418void PlacemarkEditHeader::setIdFilter(
const QStringList &filter)
420 d->setIdFilter(filter);
423void PlacemarkEditHeader::setIdVisible(
bool visible)
428void PlacemarkEditHeader::setTargetId(
const QString &targetId)
430 d->setTargetId(targetId);
433void PlacemarkEditHeader::setTargetIdList(
const QStringList &targetIdList)
435 d->setTargetIdList(targetIdList);
438void PlacemarkEditHeader::setTargetIdVisible(
bool visible)
440 d->setTargetIdVisible(
visible);
443void PlacemarkEditHeader::selectAll()
448void PlacemarkEditHeader::setReadOnly(
bool state)
450 d->m_longitude->setDisabled(state);
451 d->m_latitude->setDisabled(state);
452 d->m_name->setReadOnly(state);
453 d->m_iconLink->setReadOnly(state);
454 d->iconLinkButton->setDisabled(state);
455 d->m_id->setReadOnly(state);
456 d->m_targetId->setDisabled(state);
457 d->m_iconLink->setReadOnly(state);
459 d->idLabel->setVisible(!state);
460 d->m_id->setVisible(!state);
463void PlacemarkEditHeader::updateValues()
467 connect(d->m_id, SIGNAL(textChanged(
QString)),
this, SLOT(updateValues()));
471#include "moc_PlacemarkEditHeader.cpp"
Notation
enum used to specify the notation / numerical system
@ DMS
"Sexagesimal DMS" notation (base-60)
QString name(StandardAction id)
Binds a QML item to a specific geodetic location in screen coordinates.
QString getOpenFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, Options options)
void append(QList< T > &&value)
bool removeOne(const AT &t)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool disconnect(const QMetaObject::Connection &connection)
QString tr(const char *sourceText, const char *disambiguation, int n)
bool isNull() const const
QString number(double n, char format, int precision)
QString & replace(QChar before, QChar after, Qt::CaseSensitivity cs)
QString toLower() const const
bool contains(QLatin1StringView str, Qt::CaseSensitivity cs) const const
QFuture< void > filter(QThreadPool *pool, Sequence &sequence, KeepFunctor &&filterFunction)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)