Labels (#59)
* hacked up labels * Custom widget for addresses with labels * turnstile to use labels
This commit is contained in:
41
src/addresscombo.cpp
Normal file
41
src/addresscombo.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#include "addresscombo.h"
|
||||
|
||||
#include "addressbook.h"
|
||||
#include "settings.h"
|
||||
|
||||
AddressCombo::AddressCombo(QWidget* parent) :
|
||||
QComboBox(parent) {
|
||||
|
||||
}
|
||||
|
||||
QString AddressCombo::itemText(int i) {
|
||||
QString txt = QComboBox::itemText(i);
|
||||
return AddressBook::addressFromAddressLabel(txt.split("(")[0].trimmed());
|
||||
}
|
||||
|
||||
QString AddressCombo::currentText() {
|
||||
QString txt = QComboBox::currentText();
|
||||
return AddressBook::addressFromAddressLabel(txt.split("(")[0].trimmed());
|
||||
}
|
||||
|
||||
void AddressCombo::setCurrentText(const QString& text) {
|
||||
for (int i=0; i < count(); i++) {
|
||||
if (itemText(i) == text) {
|
||||
QComboBox::setCurrentIndex(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AddressCombo::addItem(const QString& text, double bal) {
|
||||
QString txt = AddressBook::addLabelToAddress(text);
|
||||
if (bal > 0)
|
||||
txt = txt % "(" % Settings::getZECDisplayFormat(bal) % ")";
|
||||
|
||||
QComboBox::addItem(txt);
|
||||
}
|
||||
|
||||
void AddressCombo::insertItem(int index, const QString& text, double bal) {
|
||||
QString txt = AddressBook::addLabelToAddress(text) %
|
||||
"(" % Settings::getZECDisplayFormat(bal) % ")";
|
||||
QComboBox::insertItem(index, txt);
|
||||
}
|
||||
Reference in New Issue
Block a user