-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dev'
- Loading branch information
Showing
35 changed files
with
863 additions
and
281 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#include <QEvent> | ||
#include "addressbasecombobox.h" | ||
|
||
/// | ||
/// \brief AddressBaseComboBox::AddressBaseComboBox | ||
/// \param parent | ||
/// | ||
AddressBaseComboBox::AddressBaseComboBox(QWidget* parent) | ||
: QComboBox(parent) | ||
{ | ||
addItem(tr("0-based"), QVariant::fromValue(AddressBase::Base0)); | ||
addItem(tr("1-based"), QVariant::fromValue(AddressBase::Base1)); | ||
|
||
connect(this, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &AddressBaseComboBox::on_currentIndexChanged); | ||
} | ||
|
||
/// | ||
/// \brief AddressBaseComboBox::changeEvent | ||
/// \param event | ||
/// | ||
void AddressBaseComboBox::changeEvent(QEvent* event) | ||
{ | ||
if (event->type() == QEvent::LanguageChange) | ||
{ | ||
for(int i = 0; i < count(); i++) | ||
{ | ||
switch(itemData(i).value<AddressBase>()) | ||
{ | ||
case AddressBase::Base0: | ||
setItemText(i, tr("0-based")); | ||
break; | ||
|
||
case AddressBase::Base1: | ||
setItemText(i, tr("1-based")); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
QComboBox::changeEvent(event); | ||
} | ||
|
||
/// | ||
/// \brief AddressBaseComboBox::currentAddressBase | ||
/// \return | ||
/// | ||
AddressBase AddressBaseComboBox::currentAddressBase() const | ||
{ | ||
return currentData().value<AddressBase>(); | ||
} | ||
|
||
/// | ||
/// \brief AddressBaseComboBox::setCurrentAddressBase | ||
/// \param pointType | ||
/// | ||
void AddressBaseComboBox::setCurrentAddressBase(AddressBase base) | ||
{ | ||
const auto idx = findData(QVariant::fromValue(base)); | ||
if(idx == currentIndex()) | ||
{ | ||
emit currentIndexChanged(idx); | ||
} | ||
else if(idx != -1) | ||
{ | ||
setCurrentIndex(idx); | ||
} | ||
} | ||
|
||
/// | ||
/// \brief AddressBaseComboBox::on_currentIndexChanged | ||
/// \param index | ||
/// | ||
void AddressBaseComboBox::on_currentIndexChanged(int index) | ||
{ | ||
emit addressBaseChanged(itemData(index).value<AddressBase>()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef ADDRESSBASECOMBOBOX_H | ||
#define ADDRESSBASECOMBOBOX_H | ||
|
||
#include <QComboBox> | ||
#include "enums.h" | ||
|
||
/// | ||
/// \brief The AddressBaseComboBox class | ||
/// | ||
class AddressBaseComboBox : public QComboBox | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit AddressBaseComboBox(QWidget *parent = nullptr); | ||
|
||
AddressBase currentAddressBase() const; | ||
void setCurrentAddressBase(AddressBase base); | ||
|
||
signals: | ||
void addressBaseChanged(AddressBase base); | ||
|
||
protected: | ||
void changeEvent(QEvent* event) override; | ||
|
||
private slots: | ||
void on_currentIndexChanged(int); | ||
}; | ||
|
||
#endif // ADDRESSBASECOMBOBOX_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.