void AddressCluster::init() { _titleSingular = tr("Address"); _titlePlural = tr("Addresses"); _query = "SELECT * FROM addr "; // handle differences between VirtualCluster and AddressCluster _grid->removeWidget(_label); _grid->removeWidget(_description); _grid->removeWidget(_list); _grid->removeWidget(_info); delete _description; _number = new QLineEdit(this); _addrLit = new QLabel(tr("Street\nAddress:"), this); _addr1 = new QLineEdit(this); _addr2 = new QLineEdit(this); _addr3 = new QLineEdit(this); _cityLit = new QLabel(tr("City:"), this); _city = new QLineEdit(this); _stateLit = new QLabel(tr("State:")); _state = new XComboBox(this); _postalcodeLit = new QLabel(tr("Postal Code:")); _postalcode = new QLineEdit(this); _countryLit = new QLabel(tr("Country:")); _country = new XComboBox(this); _active = new QCheckBox(tr("Active"), this); _mapper = new XDataWidgetMapper(this); _number->hide(); _addrLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _cityLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _stateLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _state->setEditable(true); _country->setEditable(true); _country->setMaximumWidth(250); _postalcodeLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _countryLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _grid->setMargin(0); _grid->setSpacing(2); _grid->addWidget(_label, 0, 0, 1, -1); _grid->addWidget(_addrLit, 1, 0, 3, 1); _grid->addWidget(_addr1, 1, 1, 1, -1); _grid->addWidget(_addr2, 2, 1, 1, -1); _grid->addWidget(_addr3, 3, 1, 1, -1); _grid->addWidget(_cityLit, 4, 0); _grid->addWidget(_city, 4, 1); _grid->addWidget(_stateLit, 4, 2); _grid->addWidget(_state, 4, 3); _grid->addWidget(_postalcodeLit, 4, 4); _grid->addWidget(_postalcode, 4, 5, 1, 2); _grid->addWidget(_countryLit, 5, 0); _grid->addWidget(_country, 5, 1, 1, 3); _grid->addWidget(_active, 5, 4); QHBoxLayout* hbox = new QHBoxLayout; hbox->addWidget(_list); hbox->addWidget(_info); _grid->addLayout(hbox, 5, 5, 1, -1, Qt::AlignRight); _grid->setColumnStretch(0, 0); _grid->setColumnStretch(1, 3); _grid->setColumnStretch(2, 0); _grid->setColumnStretch(3, 1); _grid->setColumnStretch(4, 0); _grid->setColumnStretch(5, 2); connect(_list, SIGNAL(clicked()), this, SLOT(sEllipses())); connect(_info, SIGNAL(clicked()), this, SLOT(sInfo())); connect(_addr1, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_addr2, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_addr3, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_city, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_state, SIGNAL(editTextChanged(const QString&)), this, SIGNAL(changed())); connect(_postalcode,SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_country, SIGNAL(editTextChanged(const QString&)), this, SIGNAL(changed())); setFocusProxy(_addr1); setFocusPolicy(Qt::StrongFocus); setLabel(""); setActiveVisible(false); setInfoVisible(false); // TODO - remove this and implement Info button silentSetId(-1); }
void AddressCluster::init() { _list = new QPushButton(tr("..."), this); _list->setObjectName("_list"); _list->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); #ifndef Q_OS_MAC _list->setMaximumWidth(25); #else _list->setMinimumWidth(60); _list->setMinimumHeight(32); #endif _titleSingular = tr("Address"); _titlePlural = tr("Addresses"); _query = "SELECT * FROM address "; _searchAcctId = -1; // handle differences between VirtualCluster and AddressCluster _grid->removeWidget(_label); _grid->removeWidget(_description); delete _description; _description = 0; _addrChange = new XLineEdit(this); _number = new XLineEdit(this); _addrLit = new QLabel(tr("Street\nAddress:"), this); _addr1 = new XLineEdit(this); _addr2 = new XLineEdit(this); _addr3 = new XLineEdit(this); _cityLit = new QLabel(tr("City:"), this); _city = new XLineEdit(this); _stateLit = new QLabel(tr("State:")); _state = new XComboBox(this, "_state"); _postalcodeLit = new QLabel(tr("Postal:")); _postalcode = new XLineEdit(this); _countryLit = new QLabel(tr("Country:")); _country = new XComboBox(this, "_country"); _active = new QCheckBox(tr("Active"), this); _mapper = new XDataWidgetMapper(this); _addrChange->hide(); #if defined Q_OS_MAC _city->setMinimumWidth(110); #else _city->setMinimumWidth(85); #endif if (! DEBUG) _number->hide(); _addrLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _cityLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _stateLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _state->setEditable(true); _state->setAllowNull(true); _country->setMaximumWidth(250); _country->setEditable(! (_x_metrics && _x_metrics->boolean("StrictAddressCountry"))); if (DEBUG) qDebug("%s::_country.isEditable() = %d", (objectName().isEmpty() ? "AddressCluster":qPrintable(objectName())), _country->isEditable()); _postalcodeLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _countryLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _grid->setMargin(0); _grid->setSpacing(2); _grid->addWidget(_label, 0, 0, 1, -1); _grid->addWidget(_addrLit, 1, 0, 3, 1); _grid->addWidget(_addr1, 1, 1, 1, -1); _grid->addWidget(_addr2, 2, 1, 1, -1); _grid->addWidget(_addr3, 3, 1, 1, -1); _grid->addWidget(_cityLit, 5, 0); _grid->addWidget(_city, 5, 1); _grid->addWidget(_stateLit, 5, 2); _grid->addWidget(_state, 5, 3); _grid->addWidget(_postalcodeLit, 5, 4); _grid->addWidget(_postalcode, 5, 5, 1, 2); _grid->addWidget(_countryLit, 4, 0); _grid->addWidget(_country, 4, 1, 1, 3); _grid->addWidget(_active, 4, 4); QHBoxLayout* hbox = new QHBoxLayout; hbox->addWidget(_list); _grid->addLayout(hbox, 4, 5, 1, -1, Qt::AlignRight); _grid->setColumnStretch(0, 0); _grid->setColumnStretch(1, 3); _grid->setColumnStretch(2, 0); _grid->setColumnStretch(3, 1); _grid->setColumnStretch(4, 0); _grid->setColumnStretch(5, 2); #if defined Q_OS_MAC setMinimumSize(_grid->columnCount() * 60, 132); #endif connect(_list, SIGNAL(clicked()), this, SLOT(sEllipses())); connect(_addr1, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_addr2, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_addr3, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_city, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_state, SIGNAL(editTextChanged(const QString&)), this, SIGNAL(changed())); connect(_state, SIGNAL(newID(int)), this, SIGNAL(changed())); connect(_postalcode,SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_country,SIGNAL(editTextChanged(const QString&)),this, SLOT(setCountry(const QString&))); connect(_country, SIGNAL(newID(int)), this, SIGNAL(changed())); connect(_country, SIGNAL(newID(int)), this, SLOT(populateStateComboBox())); connect(_addr1, SIGNAL(requestList()), this, SLOT(sList())); connect(_addr2, SIGNAL(requestList()), this, SLOT(sList())); connect(_addr3, SIGNAL(requestList()), this, SLOT(sList())); connect(_city, SIGNAL(requestList()), this, SLOT(sList())); connect(_postalcode, SIGNAL(requestList()), this, SLOT(sList())); connect(_addr1, SIGNAL(requestSearch()), this, SLOT(sSearch())); connect(_addr2, SIGNAL(requestSearch()), this, SLOT(sSearch())); connect(_addr3, SIGNAL(requestSearch()), this, SLOT(sSearch())); connect(_city, SIGNAL(requestSearch()), this, SLOT(sSearch())); connect(_postalcode, SIGNAL(requestSearch()), this, SLOT(sSearch())); connect(_addr1, SIGNAL(textChanged(QString)), this, SLOT(emitAddressChanged())); connect(_addr2, SIGNAL(textChanged(QString)), this, SLOT(emitAddressChanged())); connect(_addr3, SIGNAL(textChanged(QString)), this, SLOT(emitAddressChanged())); connect(_city, SIGNAL(textChanged(QString)), this, SLOT(emitAddressChanged())); connect(_postalcode,SIGNAL(textChanged(QString)), this, SLOT(emitAddressChanged())); setFocusProxy(_addr1); setFocusPolicy(Qt::StrongFocus); setLabel(""); setActiveVisible(false); silentSetId(-1); _list->show(); _mode = Edit; }