void CLineEdit::setCanEdit(bool p) { if (p == _canEdit) return; if (!p) setEditMode(false); _canEdit=p; sUpdateMenu(); }
void CLineEdit::setId(int pId) { VirtualClusterLineEdit::setId(pId); if (model() && _id != -1) { if (model()->data(model()->index(0,ISCUSTOMER)).toBool()) { setUiName("customer"); setEditPriv("MaintainCustomerMasters"); setViewPriv("ViewCustomerMasters"); setNewPriv("MaintainCustomerMasters"); _idColName="cust_id"; } else { setUiName("prospect"); setEditPriv("MaintainProspectMasters"); setViewPriv("ViewProspectMasters"); setNewPriv("MaintainProspectMasters"); _idColName="prospect_id"; } sUpdateMenu(); _crmacctId = model()->data(model()->index(0,CRMACCT_ID)).toInt(); emit newCrmacctId(_crmacctId); // Handle Credit Status QString status = model()->data(model()->index(0,CREDITSTATUS)).toString(); if (!editMode() && status != "G") { if (status == "W") _menuLabel->setPixmap(QPixmap(":/widgets/images/credit_warn.png")); else _menuLabel->setPixmap(QPixmap(":/widgets/images/credit_hold.png")); return; } } if (_editMode) _menuLabel->setPixmap(QPixmap(":/widgets/images/edit.png")); else _menuLabel->setPixmap(QPixmap(":/widgets/images/magnifier.png")); }
void CLineEdit::setCanEdit(bool p) { if (p == _canEdit || !_x_metrics) return; if (p) { if (_x_privileges && _subtype == CRMAcctLineEdit::Cust) _canEdit = _x_privileges->check("MaintainCustomerMasters"); else if (_x_privileges && _subtype == CRMAcctLineEdit::Prospect) _canEdit = _x_privileges->check("MaintainProspectMasters"); else if (_x_privileges) _canEdit = _x_privileges->check("MaintainCustomerMasters") || _x_privileges->check("MaintainProspectMasters"); } else _canEdit=p; if (!_canEdit) setEditMode(false); sUpdateMenu(); }
bool CLineEdit::setEditMode(bool p) { if (p == _editMode) return p; if (!_canEdit) return false; _editMode=p; _modeAct->setChecked(p); if (_x_preferences) { if (!_x_preferences->boolean("ClusterButtons")) { if (_editMode) _menuLabel->setPixmap(QPixmap(":/widgets/images/edit.png")); else _menuLabel->setPixmap(QPixmap(":/widgets/images/magnifier.png")); } if (!_x_metrics->boolean("DisableAutoComplete") && _editMode) disconnect(this, SIGNAL(textEdited(QString)), this, SLOT(sHandleCompleter())); else if (!_x_metrics->boolean("DisableAutoComplete")) connect(this, SIGNAL(textEdited(QString)), this, SLOT(sHandleCompleter())); } sUpdateMenu(); setDisabled(_editMode && _x_metrics->value("CRMAccountNumberGeneration") == "A"); if (!_editMode) selectAll(); emit editable(p); return p; }
void ShiptoEdit::setCustid(int pCustid) { if (pCustid == _custid) return; clear(); _custid = pCustid; if (_custid != -1) { _extraClause = QString(" (shipto_cust_id=%1) ").arg(_custid); setNewPriv("MaintainShiptos"); } else { _extraClause = " (false) "; setNewPriv(""); } sUpdateMenu(); emit newCustid(pCustid); emit disableList(_custid == -1); }
sheet += QString::number(_menuLabel->pixmap()->width() + 6); sheet += QLatin1String(";}"); setStyleSheet(sheet); // Little hack. Somehow style sheet makes widget short. Put back height. setMinimumHeight(height); // Set default menu with standard actions QMenu* menu = new QMenu; menu->addAction(_listAct); menu->addAction(_searchAct); menu->addSeparator(); menu->addAction(_infoAct); setMenu(menu); connect(this, SIGNAL(valid(bool)), this, SLOT(sUpdateMenu())); connect(menu, SIGNAL(aboutToShow()), this, SLOT(sUpdateMenu())); } bool VirtualClusterLineEdit::eventFilter(QObject *obj, QEvent *event) { if (!_menu || obj != _menuLabel) return QObject::eventFilter(obj, event); switch (event->type()) { case QEvent::MouseButtonPress: { const QMouseEvent *me = static_cast<QMouseEvent *>(event); _menu->exec(me->globalPos()); return true; } default: break;
void VirtualClusterLineEdit::setViewPriv(const QString& priv) { _viewPriv = priv; sUpdateMenu(); }
void VirtualClusterLineEdit::setUiName(const QString& name) { _uiName = name; sUpdateMenu(); }
void VirtualClusterLineEdit::focusInEvent(QFocusEvent * event) { sUpdateMenu(); XLineEdit::focusInEvent(event); }
VirtualClusterLineEdit::VirtualClusterLineEdit(QWidget* pParent, const char* pTabName, const char* pIdColumn, const char* pNumberColumn, const char* pNameColumn, const char* pDescripColumn, const char* pExtra, const char* pName, const char* pActiveColumn) : XLineEdit(pParent, pName) { if (DEBUG) qDebug("VirtualClusterLineEdit(%p, %s, %s, %s, %s, %s, %s, %s, %s)", pParent ? pParent : 0, pTabName ? pTabName : "", pIdColumn ? pIdColumn : "", pNumberColumn ? pNumberColumn : "", pNameColumn ? pNameColumn : "", pDescripColumn ? pDescripColumn : "", pExtra ? pExtra : "", pName ? pName : "", pActiveColumn ? pActiveColumn : ""); setObjectName(pName ? pName : "VirtualClusterLineEdit"); _valid = false; _parsed = true; _strict = true; _completer = 0; _showInactive = false; setTableAndColumnNames(pTabName, pIdColumn, pNumberColumn, pNameColumn, pDescripColumn, pActiveColumn); if (pExtra && QString(pExtra).trimmed().length()) _extraClause = pExtra; setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); clear(); _titleSingular = tr("Object"); _titlePlural = tr("Objects"); // Completer set up if (_x_metrics) { if (!_x_metrics->boolean("DisableAutoComplete")) { QSqlQueryModel* hints = new QSqlQueryModel(this); _completer = new QCompleter(hints,this); _completer->setWidget(this); QTreeView* view = new QTreeView(this); view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); view->setHeaderHidden(true); view->setRootIsDecorated(false); _completer->setPopup(view); _completer->setCaseSensitivity(Qt::CaseInsensitive); _completer->setCompletionColumn(1); _completer->setModelSorting(QCompleter::CaseInsensitivelySortedModel); connect(this, SIGNAL(textEdited(QString)), this, SLOT(sHandleCompleter())); connect(_completer, SIGNAL(highlighted(QString)), this, SLOT(setText(QString))); } } // Set up actions connect(_listAct, SIGNAL(triggered()), this, SLOT(sList())); connect(_searchAct, SIGNAL(triggered()), this, SLOT(sSearch())); _infoAct = new QAction(tr("Info..."), this); _infoAct->setShortcut(QKeySequence(tr("Ctrl+Shift+I"))); _infoAct->setShortcutContext(Qt::WidgetWithChildrenShortcut); _infoAct->setToolTip(tr("View record information")); _infoAct->setEnabled(false); connect(_infoAct, SIGNAL(triggered()), this, SLOT(sInfo())); addAction(_infoAct); _openAct = new QAction(tr("Open..."), this); _openAct->setShortcut(QKeySequence(tr("Ctrl+Shift+O"))); _openAct->setShortcutContext(Qt::WidgetWithChildrenShortcut); _openAct->setToolTip(tr("Open record detail")); _openAct->setEnabled(false); connect(_openAct, SIGNAL(triggered()), this, SLOT(sOpen())); addAction(_openAct); _newAct = new QAction(tr("New..."), this); _newAct->setShortcut(QKeySequence(tr("Ctrl+Shift+N"))); _newAct->setShortcutContext(Qt::WidgetWithChildrenShortcut); _newAct->setToolTip(tr("Create new record")); _newAct->setEnabled(false); connect(_newAct, SIGNAL(triggered()), this, SLOT(sNew())); addAction(_newAct); connect(this, SIGNAL(valid(bool)), _infoAct, SLOT(setEnabled(bool))); _menuLabel = new QLabel(this); // Menu set up _menu = 0; _menuLabel->setPixmap(QPixmap(":/widgets/images/magnifier.png")); _menuLabel->installEventFilter(this); int height = minimumSizeHint().height(); QString sheet = QLatin1String("QLineEdit{ padding-right: "); sheet += QString::number(_menuLabel->pixmap()->width() + 6); sheet += QLatin1String(";}"); setStyleSheet(sheet); // Little hack. Somehow style sheet makes widget short. Put back height. setMinimumHeight(height); // Set default menu with standard actions QMenu* menu = new QMenu; menu->addAction(_listAct); menu->addAction(_searchAct); menu->addSeparator(); menu->addAction(_infoAct); setMenu(menu); connect(this, SIGNAL(valid(bool)), this, SLOT(sUpdateMenu())); connect(menu, SIGNAL(aboutToShow()), this, SLOT(sUpdateMenu())); }
void CrmClusterLineEdit::setViewOwnPriv(const QString& priv) { _viewOwnPriv = priv; buildExtraClause(); sUpdateMenu(); }
void CrmClusterLineEdit::setViewOwnPriv(const QString& priv) { _viewOwnPriv = priv; sUpdateMenu(); }