void AddressCluster::setId(const int pId) { if (pId == _id) return; silentSetId(pId); emit newId(pId); }
void ShiptoEdit::sNew() { if (canOpen()) { if (!_x_privileges->check(_newPriv)) return; ParameterList params; params.append("mode", "new"); params.append("cust_id", _custid); QWidget* w = 0; if (parentWidget()->window()) { if (parentWidget()->window()->isModal()) w = _guiClientInterface->openWindow(_uiName, params, parentWidget()->window() , Qt::WindowModal, Qt::Dialog); else w = _guiClientInterface->openWindow(_uiName, params, parentWidget()->window() , Qt::NonModal, Qt::Window); } if (w->inherits("QDialog")) { QDialog* newdlg = qobject_cast<QDialog*>(w); int id = newdlg->exec(); if (id != QDialog::Rejected) { silentSetId(id); emit newId(_id); emit valid(_id != -1); } } } }
void ItemLineEdit::setId(int pId) { if (pId != _id) { silentSetId(pId); emit privateIdChanged(_id); emit newId(_id); } }
void ItemLineEdit::setId(int pId) { bool changed = (pId != _id); silentSetId(pId); if (changed) { emit privateIdChanged(_id); emit newId(_id); } }
void ContactCluster::setId(const int pId) { if (pId == _id) return; else { silentSetId(pId); emit newId(pId); } }
void ContactCluster::setNumber(QString p) { qDebug("Set Number" + p); if (p == _number->text()) return; _number->setText(p); XSqlQuery q; q.prepare("SELECT cntct_id " "FROM cntct " "WHERE (cntct_number=:number);"); q.bindValue(":number", p); q.exec(); if (q.first()) if (q.value("cntct_id").toInt() != _id) silentSetId(q.value("cntct_id").toInt()); else silentSetId(-1); }
void ItemLineEdit::setId(int pId) { if (DEBUG) qDebug("%s::setId(%d) entered", qPrintable(objectName()), pId); bool changed = (pId != _id); silentSetId(pId); if (changed) { emit privateIdChanged(_id); emit newId(_id); } }
/* returns -1 if error -2 if address is shared -10 if unclear if intent is to overwrite or create new contact */ int ContactCluster::save(AddressCluster::SaveFlags flag) { int addrSave = _address->save(flag); if (addrSave < 0) return addrSave; XSqlQuery datamodQ; datamodQ.prepare("SELECT COALESCE(saveCntct(:cntct_id,:cntct_number,:crmacct_id,:addr_id," ":honorific,:first,:middle,:last,:suffix,:initials," ":active,:phone,:phone2,:fax,:email,:webaddr," ":notes,:title,:flag),0) AS result;"); datamodQ.bindValue(":cntct_number", _number->text()); datamodQ.bindValue(":cntct_id", id()); datamodQ.bindValue(":honorific", _honorific->currentText()); if (_address->id() > 0) datamodQ.bindValue(":addr_id", _address->id()); datamodQ.bindValue(":first", _first->text()); datamodQ.bindValue(":middle", _middle->text()); datamodQ.bindValue(":last", _last->text()); datamodQ.bindValue(":suffix", _suffix->text()); datamodQ.bindValue(":initials", _initials->text()); datamodQ.bindValue(":title", _title->text()); datamodQ.bindValue(":phone", _phone->text()); datamodQ.bindValue(":phone2", _phone2->text()); datamodQ.bindValue(":fax", _fax->text()); datamodQ.bindValue(":email", _email->text()); datamodQ.bindValue(":webaddr", _webaddr->text()); datamodQ.bindValue(":notes", _notes); if (flag == AddressCluster::CHECK) datamodQ.bindValue(":flag", QString("CHECK")); else if (flag == AddressCluster::CHANGEALL) datamodQ.bindValue(":flag", QString("CHANGEALL")); else if (flag == AddressCluster::CHANGEONE) datamodQ.bindValue(":flag", QString("CHANGEONE")); else return -1; if (_crmAcct->id() > 0) datamodQ.bindValue(":crmacct_id",_crmAcct->id()); // else NULL datamodQ.bindValue(":active", QVariant(_active->isChecked(), 0)); datamodQ.exec(); if (datamodQ.first()) { if (datamodQ.value("result").toInt() == 0) return 0; else if (datamodQ.value("result").toInt() > 0) silentSetId(datamodQ.value("result").toInt()); else if (datamodQ.value("result").toInt() == -10) return -10; } else return -1; return id(); }
/* return +N addr_id if save is successful or if found another addr with the same info return 0 if there is no address to save return -1 if there was an error return -2 if there are N contacts sharing this address */ int AddressCluster::save(enum SaveFlags flag) { if (_number->text() == "" && _addr1->text() == "" && _addr2->text() == "" && _addr3->text() == "" && _city->text() == "" && _state->currentText() == "" && _postalcode->text() == "" && _country->currentText() == "") { silentSetId(-1); return 0; } XSqlQuery datamodQ; datamodQ.prepare("SELECT saveAddr(:addr_id,:addr_number,:addr1,:addr2,:addr3," ":city,:state,:postalcode,:country,:active,:notes,:flag) AS result;"); datamodQ.bindValue(":addr_id", id()); if (!_number->text().isEmpty()) datamodQ.bindValue(":addr_number", _number->text()); datamodQ.bindValue(":addr1", _addr1->text()); datamodQ.bindValue(":addr2", _addr2->text()); datamodQ.bindValue(":addr3", _addr3->text()); datamodQ.bindValue(":city", _city->text()); datamodQ.bindValue(":state", _state->currentText()); datamodQ.bindValue(":postalcode", _postalcode->text()); datamodQ.bindValue(":country", _country->currentText()); datamodQ.bindValue(":active", QVariant(_active->isChecked())); datamodQ.bindValue(":notes", _notes); if (flag == CHECK) datamodQ.bindValue(":flag", QString("CHECK")); else if (flag == CHANGEALL) datamodQ.bindValue(":flag", QString("CHANGEALL")); else if (flag == CHANGEONE) datamodQ.bindValue(":flag", QString("CHANGEONE")); else return -1; datamodQ.exec(); if (datamodQ.first()) { if (datamodQ.value("result").toInt() > 0) { _id=datamodQ.value("result").toInt(); _selected = FALSE; _valid = true; return id(); } if (datamodQ.value("result").toInt() == -2) return -2; else return -1; //error } return id(); }
void VirtualClusterLineEdit::setId(const int pId) { if (pId == -1) clear(); else if (pId == _id) return; else { silentSetId(pId); emit newId(pId); emit valid(_valid); } }
void OrderLineEdit::setId(const int pId, const QString &pType) { if (pId == -1) clear(); else if (pId == _id && pType == _name) return; else { OrderTypes oldTypes = _allowedTypes; setAllowedType(pType); silentSetId(pId); setAllowedTypes(oldTypes); emit newId(pId, pType); emit valid(_valid); } }
void VirtualClusterLineEdit::setId(const int pId) { if (DEBUG) qDebug("VCLE %s::setId(%d)", qPrintable(objectName()), pId); if (pId == -1) clear(); else if (pId == _id) return; else { silentSetId(pId); emit newId(pId); emit valid(_valid); } }
void ItemLineEdit::sCopy() { ParameterList params; params.append("item_id", id()); QString uiName = "copyItem"; QWidget* w = 0; w = _guiClientInterface->openWindow(uiName, params, parentWidget()->window() , Qt::WindowModal, Qt::Dialog); QDialog* newdlg = qobject_cast<QDialog*>(w); int id = newdlg->exec(); if (id != QDialog::Rejected) { silentSetId(id); emit newId(_id); emit valid(_id != -1); } return; }
void VirtualClusterLineEdit::setId(const int pId) { if (DEBUG) qDebug("VCLE %s::setId(%d)", qPrintable(objectName()), pId); if (pId == -1 || pId == 0) { clear(); emit parsed(); } else { bool changed = (pId != _id); silentSetId(pId); if (changed) { emit newId(pId); emit valid(_valid); } } }
QWidget* VirtualClusterLineEdit::sOpenWindow(const QString &uiName, ParameterList ¶ms) { QWidget* w = 0; if (parentWidget()->window()) w = _guiClientInterface->openWindow(uiName, params, parentWidget()->window() , Qt::WindowModal, Qt::Dialog); if (w->inherits("QDialog")) { QDialog* newdlg = qobject_cast<QDialog*>(w); int id = newdlg->exec(); if (id != QDialog::Rejected) { silentSetId(id); emit newId(_id); emit valid(_id != -1); } } else connect(w, SIGNAL(saved(int)), this, SLOT(setId(int))); return w; }
void ContactCluster::init() { _ignoreSignals = false; _titleSingular = tr("Contact"); _titlePlural = tr("Contacts"); _query = "SELECT cntct.*, crmacct_name " "FROM cntct LEFT OUTER JOIN crmacct ON (cntct_crmacct_id = crmacct_id) "; _layoutDone = false; _minimalLayout = false; _grid->removeWidget(_label); // will be reinserted _grid->removeWidget(_description); _grid->removeWidget(_list); // will be reinserted _grid->removeWidget(_info); // will be reinserted delete _description; _grid->setMargin(0); _grid->setSpacing(2); //_numberBox = new QHBoxLayout; //_numberBox->setSpacing(2); _nameBox = new QHBoxLayout; _nameBox->setSpacing(2); _titleBox = new QHBoxLayout; _titleBox->setSpacing(2); _numberLit = new QLabel(tr("Number:"), this, "_numberLit"); _number = new QLineEdit(this, "_number"); //_numberBox->addWidget(_numberLit, 0); //_numberBox->addWidget(_number, 0); _number->hide(); _numberLit->hide(); _honorific = new XComboBox(this, "_honorific"); _firstLit = new QLabel(tr("First:"), this, "_firstLit"); _first = new QLineEdit(this, "_first"); _lastLit = new QLabel(tr("Last:"), this, "_lastLit"); _last = new QLineEdit(this, "_last"); _initialsLit = new QLabel(tr("Initials:"), this, "_initialsLit"); _initials = new QLineEdit(this, "_initials"); _initials->resize(_initials->size().width() / 3, _initials->size().height()); _titleLit = new QLabel(tr("Job Title:"), this, "_titleLit"); _title = new QLineEdit(this, "_title"); _mapper = new XDataWidgetMapper(this); _nameBox->addWidget(_honorific, 0); _nameBox->addWidget(_firstLit, 0); _nameBox->addWidget(_first, 1); _nameBox->addWidget(_lastLit, 0); _nameBox->addWidget(_last, 2); _nameBox->addWidget(_initialsLit, 0); _nameBox->addWidget(_initials, 0); _nameBox->addWidget(_list, 0, Qt::AlignRight); _nameBox->addWidget(_info, 0, Qt::AlignRight); _titleBox->addWidget(_titleLit, 0); _titleBox->addWidget(_title, 2); _buttonBox = new QHBoxLayout; _crmAcct = new CRMAcctCluster(this, "_crmAcct"); _active = new QCheckBox(tr("Active"), this, "_active"); _buttonBox->addWidget(_crmAcct, 1, Qt::AlignLeft); _buttonBox->addStretch(); _buttonBox->addWidget(_active, 0); _phoneLit = new QLabel(tr("Voice:"), this, "_phoneLit"); _phone = new QLineEdit(this, "_phone"); _phone2Lit = new QLabel(tr("Alternate:"), this, "_phone2Lit"); _phone2 = new QLineEdit(this, "_phone2"); _faxLit = new QLabel(tr("Fax:"), this, "_faxLit"); _fax = new QLineEdit(this, "_fax"); _emailLit = new QLabel(tr("E-Mail:"), this, "_emailLit"); _email = new QLineEdit(this, "_email"); _webaddrLit = new QLabel(tr("Web:"), this, "_webaddrLit"); _webaddr = new QLineEdit(this, "_webaddr"); _address = new AddressCluster(this, "_address"); _numberLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _label->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); _firstLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _lastLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _titleLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _phoneLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _phone2Lit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _faxLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _emailLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _initialsLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _webaddrLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _honorific->setEditable(true); _honorific->setType(XComboBox::Honorifics); _crmAcct->setLabel(tr("CRM Account:")); layout(); connect(_list, SIGNAL(clicked()), this, SLOT(sEllipses())); connect(_info, SIGNAL(clicked()), this, SLOT(sInfo())); connect(_honorific, SIGNAL(newID(int)), this, SIGNAL(changed())); connect(_first, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_last, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_initials, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_crmAcct, SIGNAL(newId(int)), this, SIGNAL(changed())); connect(_phone, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_phone2, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_fax, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_email, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_webaddr, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_address, SIGNAL(changed()), this, SIGNAL(changed())); connect(_honorific, SIGNAL(newID(int)), this, SLOT(sCheck())); connect(_first, SIGNAL(lostFocus()), this, SLOT(sCheck())); connect(_last, SIGNAL(lostFocus()), this, SLOT(sCheck())); connect(_initials, SIGNAL(lostFocus()), this, SLOT(sCheck())); connect(_crmAcct, SIGNAL(newId(int)), this, SLOT(sCheck())); connect(_phone, SIGNAL(lostFocus()), this, SLOT(sCheck())); connect(_phone2, SIGNAL(lostFocus()), this, SLOT(sCheck())); connect(_fax, SIGNAL(lostFocus()), this, SLOT(sCheck())); connect(_email, SIGNAL(lostFocus()), this, SLOT(sCheck())); connect(_webaddr, SIGNAL(lostFocus()), this, SLOT(sCheck())); connect(_address, SIGNAL(changed()), this, SLOT(sCheck())); setFocusPolicy(Qt::StrongFocus); setFocusProxy(_honorific); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); setLabel(""); _limits = 0; setInfoVisible(false); // TODO - remove this and implement Info button silentSetId(-1); }
/* returns -1 if error -2 if address is shared -10 if unclear if intent is to overwrite or create new contact */ int ContactCluster::save(AddressCluster::SaveFlags flag) { int addrSave = _address->save(flag); if (addrSave < 0) return addrSave; XSqlQuery datamodQ; datamodQ.prepare("SELECT saveCntct(:cntct_id,:cntct_number,:crmacct_id,:addr_id," ":first,:last,:honorific,:initials,:active,:phone,:phone2,:fax,:email,:webaddr," ":notes,:title,:flag) AS result;"); datamodQ.bindValue(":cntct_number", _number->text()); datamodQ.bindValue(":cntct_id", id()); datamodQ.bindValue(":honorific", _honorific->currentText()); if (_address->id() > 0) datamodQ.bindValue(":addr_id", _address->id()); datamodQ.bindValue(":first", _first->text()); datamodQ.bindValue(":last", _last->text()); datamodQ.bindValue(":initials", _initials->text()); datamodQ.bindValue(":title", _title->text()); datamodQ.bindValue(":phone", _phone->text()); datamodQ.bindValue(":phone2", _phone2->text()); datamodQ.bindValue(":fax", _fax->text()); datamodQ.bindValue(":email", _email->text()); datamodQ.bindValue(":webaddr", _webaddr->text()); datamodQ.bindValue(":notes", _notes); if (flag == AddressCluster::CHECK) datamodQ.bindValue(":flag", QString("CHECK")); else if (flag == AddressCluster::CHANGEALL) datamodQ.bindValue(":flag", QString("CHANGEALL")); else if (flag == AddressCluster::CHANGEONE) datamodQ.bindValue(":flag", QString("CHANGEONE")); else return -1; if (_crmAcct->id() > 0) datamodQ.bindValue(":crmacct_id",_crmAcct->id()); // else NULL datamodQ.bindValue(":active", QVariant(_active->isChecked(), 0)); datamodQ.exec(); if (datamodQ.first()) { if (datamodQ.value("result").toInt() > 0) silentSetId(datamodQ.value("result").toInt()); else if (datamodQ.value("result").toInt() == -10) { if (_mapper->model()) { int answer; answer = QMessageBox::question(this, tr("Question Saving %1").arg(label()), tr("<p>Would you like to update the existing Contact or " "create a new one?"), tr("Create New"), tr("Change Existing"), tr("Cancel"), 2, 2); if (0 == answer) return save(AddressCluster::CHANGEONE); else if (1 == answer) return save(AddressCluster::CHANGEALL); else silentSetId(_id); // error } return -10; } } else return -1; return id(); }
void ContactWidget::init() { _ignoreSignals = false; _titleSingular = tr("Contact"); _titlePlural = tr("Contacts"); _query = "SELECT cntct.*, crmacct_name " "FROM cntct LEFT OUTER JOIN crmacct ON (cntct_crmacct_id = crmacct_id) "; _layoutDone = false; _minimalLayout = false; _searchAcctId = -1; _list = new QPushButton(tr("..."), this); _list->setObjectName("_list"); _list->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); #ifndef Q_WS_MAC _list->setMaximumWidth(25); #else _list->setMinimumWidth(60); _list->setMinimumHeight(32); #endif _grid->removeWidget(_label); // will be reinserted _grid->removeWidget(_description); delete _description; _description = 0; _grid->setMargin(0); _grid->setSpacing(2); _nameBox = new QHBoxLayout; _nameBox->setSpacing(2); _initialsBox = new QHBoxLayout; _initialsBox->setSpacing(2); _titleBox = new QHBoxLayout; _titleBox->setSpacing(2); _change = new XLineEdit(this); _numberLit = new QLabel(tr("Number:"), this); _numberLit->setObjectName("_numberLit"); _number = new XLineEdit(this, "_number"); _change->hide(); _number->hide(); _numberLit->hide(); _nameLit = new QLabel(tr("Name:"), this); _nameLit->setObjectName("_nameLit"); _honorific = new XComboBox(this, "_honorific"); _first = new XLineEdit(this, "_first"); _middle = new XLineEdit(this, "_middle"); _middle->setFixedWidth(20); _last = new XLineEdit(this, "_last"); _suffix = new XLineEdit(this, "_suffix"); _suffix->setFixedWidth(30); _initialsLit = new QLabel(tr("Initials:"), this); _initialsLit->setObjectName("_initialsLit"); _initials = new XLineEdit(this, "_initials"); _initials->setFixedWidth(_initials->size().width() / 3); _titleLit = new QLabel(tr("Job Title:"), this); _titleLit->setObjectName("_titleLit"); _title = new XLineEdit(this, "_title"); _mapper = new XDataWidgetMapper(this); //_nameBox->addWidget(_nameLit, 0); _nameBox->addWidget(_honorific, 0); _nameBox->addWidget(_first, 1); _nameBox->addWidget(_middle, 0); _nameBox->addWidget(_last, 2); _nameBox->addWidget(_suffix, 0); _nameBox->addWidget(_list, 0, Qt::AlignRight); //_initialsBox->addWidget(_initialsLit, 0); _initialsBox->addWidget(_initials, 0); _initialsBox->addStretch(0); //_titleBox->addWidget(_titleLit, 0); _titleBox->addWidget(_title, 2); _buttonBox = new QGridLayout; _crmAcct = new CRMAcctCluster(this, "_crmAcct"); _active = new QCheckBox(tr("Active"), this); _active->setObjectName("_active"); _owner = new UsernameCluster(this, "_owner"); _buttonBox->addWidget(_crmAcct, 0, 1, Qt::AlignTop); _buttonBox->addWidget(_owner, 0, 2, Qt::AlignTop); _phoneLit = new QLabel(tr("Voice:"), this); _phoneLit->setObjectName("_phoneLit"); _phone = new XLineEdit(this, "_phone"); _phone2Lit = new QLabel(tr("Alternate:"), this); _phone2Lit->setObjectName("_phone2Lit"); _phone2 = new XLineEdit(this, "_phone2"); _faxLit = new QLabel(tr("Fax:"), this); _faxLit->setObjectName("_faxLit"); _fax = new XLineEdit(this, "_fax"); _emailLit = new QLabel(tr("E-Mail:"), this); _emailLit->setObjectName("_emailLit"); _email = new XLineEdit(this, "_email"); _webaddrLit = new QLabel(tr("Web:"), this); _webaddrLit->setObjectName("_webaddrLit"); _webaddr = new XLineEdit(this, "_webaddr"); _address = new AddressCluster(this, "_address"); #if defined Q_OS_MAC _honorific->setMinimumHeight(26); _first->setMinimumHeight(22); _middle->setMinimumHeight(22); _last->setMinimumHeight(22); _suffix->setMinimumHeight(22); _phone->setMinimumWidth(140); _crmAcct->setMinimumHeight(72); #endif QPalette p = _email->palette(); p.setColor(QPalette::Text, Qt::blue); _email->setPalette(p); _webaddr->setPalette(p); QFont newFont = _email->font(); newFont.setUnderline(TRUE); _email->setFont(newFont); _webaddr->setFont(newFont); _numberLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _label->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); _nameLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _titleLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _phoneLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _phone2Lit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _faxLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _emailLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _initialsLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _webaddrLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _honorific->setEditable(true); _honorific->setType(XComboBox::Honorifics); _crmAcct->setLabel(tr("CRM Account:")); _owner->setLabel(tr("Owner:")); layout(); connect(_list, SIGNAL(clicked()), this, SLOT(sEllipses())); connect(_honorific, SIGNAL(newID(int)), this, SIGNAL(changed())); connect(_first, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_middle, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_last, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_suffix, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_initials, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_crmAcct, SIGNAL(newId(int)), this, SIGNAL(changed())); connect(_title, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_phone, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_phone2, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_fax, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_email, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_webaddr, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_address, SIGNAL(changed()), this, SIGNAL(changed())); connect(this, SIGNAL(changed()), this, SLOT(setChanged())); connect(_honorific, SIGNAL(newID(int)), this, SLOT(sCheck())); connect(_first, SIGNAL(lostFocus()), this, SLOT(sCheck())); connect(_middle, SIGNAL(lostFocus()), this, SLOT(sCheck())); connect(_last, SIGNAL(lostFocus()), this, SLOT(sCheck())); connect(_suffix, SIGNAL(lostFocus()), this, SLOT(sCheck())); connect(_initials, SIGNAL(lostFocus()), this, SLOT(sCheck())); connect(_crmAcct, SIGNAL(newId(int)), this, SLOT(sCheck())); connect(_title, SIGNAL(lostFocus()), this, SLOT(sCheck())); connect(_phone, SIGNAL(lostFocus()), this, SLOT(sCheck())); connect(_phone2, SIGNAL(lostFocus()), this, SLOT(sCheck())); connect(_fax, SIGNAL(lostFocus()), this, SLOT(sCheck())); connect(_email, SIGNAL(lostFocus()), this, SLOT(sCheck())); connect(_webaddr, SIGNAL(lostFocus()), this, SLOT(sCheck())); connect(_address, SIGNAL(changed()), this, SLOT(sCheck())); connect(_email, SIGNAL(doubleClicked()), this, SLOT(sLaunchEmail())); connect(_webaddr, SIGNAL(doubleClicked()), this, SLOT(sLaunchWebaddr())); setListVisible(true); connect(_first, SIGNAL(lostFocus()), this, SLOT(findDuplicates())); connect(_last, SIGNAL(lostFocus()), this, SLOT(findDuplicates())); connect(_crmAcct, SIGNAL(newId(int)), this, SLOT(setSearchAcct(int))); setFocusPolicy(Qt::StrongFocus); setFocusProxy(_honorific); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); setLabel(""); _limits = 0; silentSetId(-1); setOwnerVisible(false); _mode = Edit; }
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); }
/* this should probably be a simple call to a saveAddr stored procedure with the logic moved from here to that stored procedure return +N addr_id if save is successful or if found another addr with the same info return 0 if there is no address to save return -1 if there was an error return -2 if there are N contacts sharing this address TO DO: Both sove functions can and should be removed when all references to them have been removed from the application and replaced by API views */ int AddressCluster::save(enum SaveFlags flag) { if (_number->text() == "" && _addr1->text() == "" && _addr2->text() == "" && _addr3->text() == "" && _city->text() == "" && _state->currentText() == "" && _postalcode->text() == "" && _country->currentText() == "") { silentSetId(-1); return 0; } XSqlQuery datamodQ; datamodQ.prepare("SELECT saveAddr(:addr_id,:addr_number,:addr1,:addr2,:addr3," ":city,:state,:postalcode,:country,:active,:notes,:flag) AS result;"); datamodQ.bindValue(":addr_id", id()); datamodQ.bindValue(":addr_number", _number->text()); datamodQ.bindValue(":addr1", _addr1->text()); datamodQ.bindValue(":addr2", _addr2->text()); datamodQ.bindValue(":addr3", _addr3->text()); datamodQ.bindValue(":city", _city->text()); datamodQ.bindValue(":state", _state->currentText()); datamodQ.bindValue(":postalcode", _postalcode->text()); datamodQ.bindValue(":country", _country->currentText()); datamodQ.bindValue(":active", QVariant(_active->isChecked(), 0)); datamodQ.bindValue(":notes", _notes); if (flag == CHECK) datamodQ.bindValue(":flag", QString("CHECK")); else if (flag == CHANGEALL) datamodQ.bindValue(":flag", QString("CHANGEALL")); else if (flag == CHANGEONE) datamodQ.bindValue(":flag", QString("CHANGEALL")); else return -1; datamodQ.exec(); if (datamodQ.first()) { if (datamodQ.value("result").toInt() > 0) { _id=datamodQ.value("result").toInt(); _selected = FALSE; _valid = true; return id(); } if (datamodQ.value("result").toInt() == -2) { if (_mapper->model()) { int answer = 2; // Cancel answer = QMessageBox::question(this, tr("Question Saving Address"), tr("There are multiple Contacts sharing this Address.\n" "What would you like to do?"), tr("Change This One"), tr("Change Address for All"), tr("Cancel"), 2, 2); if (answer==0) return save(CHANGEONE); else if (answer==1) return save(CHANGEALL); else silentSetId(_id); } else return -2; } else return -1; //error } return id(); }
/* return +N addr_id if save is successful or if found another addr with the same info return 0 if there is no address to save return -1 if there was an error return -2 if there are N contacts sharing this address */ int AddressCluster::save(enum SaveFlags flag) { if (_number->text() == "" && _addr1->text() == "" && _addr2->text() == "" && _addr3->text() == "" && _city->text() == "" && _state->currentText() == "" && _postalcode->text() == "" && (_country->currentText() == "" || (_x_metrics && _country->currentText()==_x_metrics->value("DefaultAddressCountry"))) ) { silentSetId(-1); return 0; } if (_x_metrics && _x_metrics->boolean("StrictAddressCountry") && !_country->currentText().isEmpty() && _country->findText(_country->currentText(), Qt::MatchExactly) < 0) { QMessageBox::critical(this, tr("Error"), tr("<p>This address appears to have a non-standard " "country. Please select a country from the list " "before saving.")); return -3; } XSqlQuery datamodQ; datamodQ.prepare("SELECT saveAddr(:addr_id,:addr_number,:addr1,:addr2,:addr3," ":city,:state,:postalcode,:country,:active,:notes,:flag) AS result;"); datamodQ.bindValue(":addr_id", id()); if (!_number->text().isEmpty()) datamodQ.bindValue(":addr_number", _number->text()); datamodQ.bindValue(":addr1", _addr1->text()); datamodQ.bindValue(":addr2", _addr2->text()); datamodQ.bindValue(":addr3", _addr3->text()); datamodQ.bindValue(":city", _city->text()); datamodQ.bindValue(":state", _state->currentText()); datamodQ.bindValue(":postalcode", _postalcode->text()); datamodQ.bindValue(":country", _country->currentText()); datamodQ.bindValue(":active", QVariant(_active->isChecked())); datamodQ.bindValue(":notes", _notes); if (flag == CHECK) datamodQ.bindValue(":flag", QString("CHECK")); else if (flag == CHANGEALL) datamodQ.bindValue(":flag", QString("CHANGEALL")); else if (flag == CHANGEONE) datamodQ.bindValue(":flag", QString("CHANGEONE")); else return -1; datamodQ.exec(); if (datamodQ.first()) { if (datamodQ.value("result").toInt() > 0) { _id=datamodQ.value("result").toInt(); _selected = false; _valid = true; silentSetId(id()); return id(); } if (datamodQ.value("result").toInt() == -2) return -2; else return -1; } else if (ErrorReporter::error(QtCriticalMsg, this, tr("Error Saving Address"), datamodQ, __FILE__, __LINE__)) return -1; return id(); }
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; }