7 #include <QDragEnterEvent>
8 #include <QDragLeaveEvent>
9 #include <QDragMoveEvent>
15 #include <QStringList>
19 #include "ui_dbdistributorselectorcomponent.h"
32 using namespace swift::misc::simulation;
33 using namespace swift::misc::network;
37 CDbDistributorSelectorComponent::CDbDistributorSelectorComponent(
QWidget *parent)
40 Q_ASSERT_X(
sGui, Q_FUNC_INFO,
"Missing sGui");
49 Q_ASSERT_X(c, Q_FUNC_INFO,
"Missing connect");
55 Q_ASSERT_X(c, Q_FUNC_INFO,
"Missing connect");
58 this->onDistributorsRead(CEntityFlags::DistributorEntity, CEntityFlags::ReadFinished,
68 if (distributor != m_currentDistributor)
70 ui->le_Distributor->setText(key);
71 m_currentDistributor = distributor;
84 ui->lbl_Description->setText(
"");
85 ui->le_Distributor->setText(keyOrAlias);
91 if (!
sGui) {
return {}; }
92 const QString distributorKeyOrAlias(ui->le_Distributor->text().trimmed().toUpper());
93 if (distributorKeyOrAlias.
isEmpty()) {
return {}; }
94 if (m_currentDistributor.
matchesKeyOrAlias(distributorKeyOrAlias)) {
return m_currentDistributor; }
109 ui->lbl_Description->setVisible(description);
116 ui->le_Distributor->clear();
124 event->acceptProposedAction();
130 event->acceptProposedAction();
135 if (!
event) {
return; }
148 if (!distributor.hasValidDbKey()) {
return; }
154 if (distributors.isEmpty()) {
return; }
160 void CDbDistributorSelectorComponent::onDistributorsRead(CEntityFlags::Entity entity,
164 if (entity.testFlag(CEntityFlags::DistributorEntity) && CEntityFlags::isFinishedReadState(readState))
170 auto *c =
new QCompleter(keysAndAliases,
this);
173 c->setMaxVisibleItems(10);
175 &CDbDistributorSelectorComponent::onCompleterActivated);
177 ui->le_Distributor->setCompleter(c);
178 m_completerDistributors.
reset(c);
183 m_completerDistributors.
reset(
nullptr);
189 void CDbDistributorSelectorComponent::onDataChanged()
192 const QString keyOrAlias(ui->le_Distributor->text().trimmed().toUpper());
193 if (keyOrAlias.isEmpty()) {
return; }
198 void CDbDistributorSelectorComponent::onCompleterActivated(
const QString &distributorKeyOrAlias)
SWIFT_CORE_EXPORT swift::core::CApplication * sApp
Single instance of application object.
bool hasWebDataServices() const
Web data services available?
bool isShuttingDown() const
Is application shutting down?
CWebDataServices * getWebDataServices() const
Get the web data services.
int getDistributorsCount() const
Distributors count.
swift::misc::simulation::CDistributorList getDistributors() const
Distributors.
bool acceptDrop(const QMimeData *mime) const
Accept drop?
swift::misc::CVariant toCVariant(const QMimeData *mime) const
Mime data to CVariant (normally encapsulating a value object)
void setAcceptedMetaTypeIds(const QList< int > &ids)
Accepted ids.
void clear()
Clear selection.
void changedDistributor(const swift::misc::simulation::CDistributor &distributor)
Distributor was changed.
void dragLeaveEvent(QDragLeaveEvent *event)
bool isSet() const
Set with valid Distributor.
void dropEvent(QDropEvent *event)
void setReadOnly(bool readOnly)
Read only.
void dragMoveEvent(QDragMoveEvent *event)
void dragEnterEvent(QDragEnterEvent *event)
void setDistributor(const swift::misc::simulation::CDistributor &distributor)
Current distributor.
swift::misc::simulation::CDistributor getDistributor() const
Distributor.
~CDbDistributorSelectorComponent()
Destructor.
void withDistributorDescription(bool description)
Display distributor description.
Wrapper around QVariant which provides transparent access to CValueObject methods of the contained ob...
T value() const
Return the value converted to the type T.
bool isValid() const
True if this variant is valid.
bool canConvert(int typeId) const
True if this variant can be converted to the type with the given metatype ID.
OBJ findByKey(KEYTYPE key, const OBJ ¬Found=OBJ()) const
Object with key, notFound otherwise.
bool hasValidDbKey() const
Has valid DB key.
const QString & getDbKey() const
Get DB key.
ReadState
State of operation.
Value object encapsulating information of software distributor.
bool matchesKeyOrAlias(const QString &keyOrAlias) const
Matches key or alias.
bool hasCompleteData() const
Complete data?
Value object encapsulating a list of distributors.
CDistributor findByKeyOrAlias(const QString &keyOrAlias) const
Find by id or alias.
QStringList getDbKeysAndAliases(bool sort) const
All DB keys and aliases.
SWIFT_GUI_EXPORT swift::gui::CGuiApplication * sGui
Single instance of GUI application object.
Backend services of the swift project, like dealing with the network or the simulators.
High level reusable GUI components.
Free functions in swift::misc.
void activated(const QModelIndex &index)
virtual bool event(QEvent *e) override
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool isEmpty() const const
QString toUpper() const const
QString trimmed() const const