Beispiel #1
0
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) :
    XLineEdit(pParent, pName)
{
    _valid  = false;
    _parsed = true;
    _strict = true;

    setTableAndColumnNames(pTabName, pIdColumn, pNumberColumn, pNameColumn, pDescripColumn);

    if (pExtra && QString(pExtra).stripWhiteSpace().length())
	_extraClause = pExtra;

    connect(this, SIGNAL(lostFocus()),		this, SLOT(sParse()));
    connect(this, SIGNAL(requestInfo()),	this, SLOT(sInfo()));
    connect(this, SIGNAL(requestList()),	this, SLOT(sList()));
    connect(this, SIGNAL(requestSearch()),	this, SLOT(sSearch()));

    setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    setMaximumWidth(100);

    clear();
    _titleSingular = tr("Object");
    _titlePlural = tr("Objects");
}
Beispiel #2
0
int main(int argc, char ** argv) {
    
    el::Configurations confFromFile("./dev_controller-logger.conf");
    el::Loggers::reconfigureAllLoggers(confFromFile);
    
    if (argc < 10) {
        std::cout<<"dev_controller mqtt_clientid mqtt_username mqtt_password mqtt_connuri, zmq_listenuri redisIPAddr redisPort zookeeperAddrList mongodbUri"<<std::endl;
        return -1;
    }
    
    char hostName[64] = {0};

    int ret = gethostname(hostName, sizeof(hostName)-1);
    if (ret != 0) {
        strcpy(hostName, "pigeon-host");
    }
    
    pid_t procId = getpid();
    char postfix[128] = {0};
    sprintf(postfix, ":%s_%d:", hostName, procId);
    dev_ctl_id += postfix;

    g_stopflag.test_and_set();    
    signal(SIGINT, sigIntHandler);
    signal(SIGTERM, sigIntHandler);

    auto upListener = std::make_shared<UsrPortalMsgListener>();

    gPtrZmqEndInst = std::make_shared<pigeon::ZmqEnd>(argv[5]);
    gPtrZmqEndInst->setMsgListener(upListener);
    gPtrZmqEndInst->startMsgLoop();

    //reg own service into zookeeper
    char svcid[128] = {0};
    sprintf(svcid, "%s_%d", hostName, procId);
    DevCtlServiceInfo sInfo(argv[5], svcid); 
    DevCtlServiceReg  sGeg(argv[8], service_path, sInfo.getServiceInfoJson());
    ret = sGeg.RegService();
    if (ret != 0) {
        LOG(ERROR) << "reg own service into zookeeper fail!";        
        gPtrZmqEndInst->finMsgLoop();
        return -1;
    }
    //DevQueryEnd
    gPtrDqEnd = std::unique_ptr<DevQueryEnd>(new DevQueryEnd(gPtrZmqEndInst, argv[6], atoi(argv[7])));
    gPtrDqEnd->start();

    //DevOptEnd
    gPtrDOpEnd = std::unique_ptr<DevOptEnd>(new DevOptEnd(dev_ctl_id, gPtrZmqEndInst, argv[1], argv[2], argv[3], argv[4], argv[6], atoi(argv[7]), argv[9]));
    gPtrDOpEnd->start();

    while(g_stopflag.test_and_set()) {
        std::this_thread::sleep_for(std::chrono::milliseconds(200));
    }

    gPtrZmqEndInst->finMsgLoop();
    gPtrDqEnd->stop();
    gPtrDOpEnd->stop();
    return 0;
}
Beispiel #3
0
void ItemCluster::addNumberWidget(ItemLineEdit* pNumberWidget)
{
    _number = pNumberWidget;
    if (! _number)
      return;

    _grid->addWidget(_number, 0, 1);
    setFocusProxy(pNumberWidget);

    connect(_list,      SIGNAL(clicked()),      this, SLOT(sEllipses()));
    connect(_info,      SIGNAL(clicked()),      this, SLOT(sInfo()));
    connect(_number,	SIGNAL(newId(int)),	this,	 SIGNAL(newId(int)));
    connect(_number,	SIGNAL(parsed()), 	this, 	 SLOT(sRefresh()));
    connect(_number,	SIGNAL(valid(bool)),	this,	 SIGNAL(valid(bool)));
}
Beispiel #4
0
void ContactCluster::addNumberWidget(ContactClusterLineEdit* pNumberWidget)
{
    _number = pNumberWidget;
    if (! _number)
      return;

    _number->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    _number->setMinimumWidth(200);
    QHBoxLayout* hbox = new QHBoxLayout;
    QSpacerItem* item = new QSpacerItem(100, 20, QSizePolicy::Fixed, QSizePolicy::Fixed);
    hbox->addWidget(_number);
    hbox->addWidget(_list);
    hbox->addWidget(_info);
    hbox->addItem(item);
    _grid->addLayout(hbox, 0, 1, 1, 3);
    setFocusProxy(pNumberWidget);

    connect(_list,      SIGNAL(clicked()),      this,   SLOT(sEllipses()));
    connect(_info,      SIGNAL(clicked()),      this,   SLOT(sInfo()));
    connect(_number,	SIGNAL(newId(int)),	this,	SIGNAL(newId(int)));
    connect(_number,	SIGNAL(parsed()), 	this, 	SLOT(sRefresh()));
    connect(_number,	SIGNAL(valid(bool)),	this,	SIGNAL(valid(bool)));
}
Beispiel #5
0
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);
}
Beispiel #6
0
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);
}
Beispiel #7
0
        connect(this, SIGNAL(textEdited(QString)), this, SLOT(sHandleCompleter()));
        connect(_completer, SIGNAL(highlighted(QString)), this, SLOT(setText(QString)));
        connect(_completer, SIGNAL(highlighted(const QModelIndex &)), this, SLOT(completerHighlighted(const QModelIndex &)));
      }
    }

    // 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);

    _copyAct = new QAction(tr("Copy..."), this);
    _copyAct->setShortcut(QKeySequence(tr("Ctrl+Shift+C")));
    _copyAct->setShortcutContext(Qt::WidgetWithChildrenShortcut);
    _copyAct->setToolTip(tr("Copy record detail"));
    _copyAct->setEnabled(false);
Beispiel #8
0
CustInfo::CustInfo(QWidget *pParent, const char *name) :
  QWidget(pParent, name)
{
//  Create and place the component Widgets
  QHBoxLayout *layoutMain = new QHBoxLayout(this, 0, 6, "layoutMain"); 
  QHBoxLayout *layoutNumber = new QHBoxLayout(0, 0, 6, "layoutNumber"); 
  QHBoxLayout *layoutButtons = new QHBoxLayout(0, 0, -1, "layoutButtons"); 

  _customerNumberLit = new QLabel(tr("Customer #:"), this, "_customerNumberLit");
  _customerNumberLit->setAlignment(Qt::AlignVCenter | Qt::AlignRight);
  layoutNumber->addWidget(_customerNumberLit);

  _customerNumber = new CLineEdit(this, "_customerNumber");
  _customerNumber->setMinimumWidth(100);
  layoutNumber->addWidget(_customerNumber);
  
  _customerNumberEdit = new XLineEdit(this, "_customerNumberEdit");
  _customerNumberEdit->setMinimumWidth(100);
  _customerNumberEdit->setMaximumWidth(100);
  layoutNumber->addWidget(_customerNumberEdit);
  _customerNumberEdit->hide();
  layoutMain->addLayout(layoutNumber);

  _list = new QPushButton(tr("..."), this, "_list");
  _list->setFocusPolicy(Qt::NoFocus);
  if(_x_preferences)
  {
    if(_x_preferences->value("DefaultEllipsesAction") == "search")
      _list->setToolTip(tr("Search"));
    else
      _list->setToolTip(tr("List"));
  }
  layoutButtons->addWidget(_list);

  _info = new QPushButton(tr("?"), this, "_info");
  _info->setFocusPolicy(Qt::NoFocus);
  _info->setToolTip(tr("Open"));
  layoutButtons->addWidget(_info);
  
  _delete = new QPushButton(tr("x"), this, "_delete");
  _delete->setFocusPolicy(Qt::NoFocus);
  _delete->setToolTip(tr("Delete"));
  layoutButtons->addWidget(_delete);
  
  _new = new QPushButton(tr("+"), this, "_new");
  _new->setFocusPolicy(Qt::NoFocus);
  _new->setToolTip(tr("New"));
  layoutButtons->addWidget(_new);

  _edit = new QPushButton(tr("!"), this, "_edit");
  _edit->setFocusPolicy(Qt::NoFocus);
  _edit->setCheckable(true);
  _edit->setToolTip(tr("Edit Mode"));
  layoutButtons->addWidget(_edit);
  
#ifndef Q_WS_MAC
  _list->setMaximumWidth(25);
  _info->setMaximumWidth(25);
  _new->setMaximumWidth(25);
  _edit->setMaximumWidth(25);
  _delete->setMaximumWidth(25);
#else
  _list->setMinimumWidth(60);
  _list->setMinimumHeight(32);
  _info->setMinimumWidth(60);
  _info->setMinimumHeight(32);
  _new->setMinimumWidth(60);
  _new->setMinimumHeight(32);
  _edit->setMinimumWidth(60);
  _edit->setMinimumHeight(32);
  _delete->setMinimumWidth(60);
  _delete->setMinimumHeight(32);
  layoutNumber->setContentsMargins(2,0,0,0);
  layoutButtons->setContentsMargins(0,8,0,0);
  layoutButtons->setSpacing(6);
#endif
  
  layoutMain->addLayout(layoutButtons);

//  Make some internal connections
  connect(_list, SIGNAL(clicked()), _customerNumber, SLOT(sEllipses()));
  connect(_info, SIGNAL(clicked()), this, SLOT(sInfo()));

  connect(_customerNumber, SIGNAL(newId(int)), this, SIGNAL(newId(int)));
  connect(_customerNumber, SIGNAL(custNameChanged(const QString &)), this, SIGNAL(nameChanged(const QString &)));
  connect(_customerNumber, SIGNAL(custAddr1Changed(const QString &)), this, SIGNAL(address1Changed(const QString &)));
  connect(_customerNumber, SIGNAL(custAddr2Changed(const QString &)), this, SIGNAL(address2Changed(const QString &)));
  connect(_customerNumber, SIGNAL(custAddr3Changed(const QString &)), this, SIGNAL(address3Changed(const QString &)));
  connect(_customerNumber, SIGNAL(custCityChanged(const QString &)), this, SIGNAL(cityChanged(const QString &)));
  connect(_customerNumber, SIGNAL(custStateChanged(const QString &)), this, SIGNAL(stateChanged(const QString &)));
  connect(_customerNumber, SIGNAL(custZipCodeChanged(const QString &)), this, SIGNAL(zipCodeChanged(const QString &)));
  connect(_customerNumber, SIGNAL(custCountryChanged(const QString &)), this, SIGNAL(countryChanged(const QString &)));
  connect(_customerNumber, SIGNAL(custAddressChanged(const int)), this, SIGNAL(addressChanged(const int)));
  connect(_customerNumber, SIGNAL(custContactChanged(const int)), this, SIGNAL(contactChanged(const int)));
  connect(_customerNumber, SIGNAL(valid(bool)), this, SIGNAL(valid(bool)));

  connect(_customerNumber, SIGNAL(creditStatusChanged(const QString &)), this, SLOT(sHandleCreditStatus(const QString &)));
  connect(_customerNumber, SIGNAL(textChanged(const QString &)), _customerNumberEdit, SLOT(setText(const QString &)));
  connect(_customerNumberEdit, SIGNAL(editingFinished()), this, SIGNAL(editingFinished()));
  connect(_edit, SIGNAL(clicked()), this, SLOT(setMode()));
  connect(_new, SIGNAL(clicked()), this, SLOT(sNewClicked()));
  connect(_delete, SIGNAL(clicked()), this, SIGNAL(deleteClicked()));
  connect(_customerNumber, SIGNAL(newId(int)), this, SLOT(setMode()));

  if(_x_privileges && (!_x_privileges->check("MaintainCustomerMasters") && !_x_privileges->check("ViewCustomerMasters")))
  {
    _info->setEnabled(false);
    _delete->setEnabled(false);
    _edit->setEnabled(false);
    _new->setEnabled(false);
  }
  else
  {
    connect(_customerNumber, SIGNAL(valid(bool)), _info, SLOT(setEnabled(bool)));
    connect(_customerNumber, SIGNAL(requestInfo()), this, SLOT(sInfo()));
  }
  
  if(_x_privileges && (!_x_privileges->check("MaintainCustomerMasters") ))
  {
    _delete->setEnabled(false);
    _edit->setEnabled(false);
    _new->setEnabled(false);
  }

  setFocusProxy(_customerNumber);

  _mapper = new XDataWidgetMapper(this);
  _labelVisible = true;
  _canEdit=true;
  setCanEdit(false);
}
Beispiel #9
0
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()));
  }
Beispiel #10
0
Pattern* LocalFileMng::loadPattern( const QString& directory )
{

	InstrumentList* instrList = Hydrogen::get_instance()->getSong()->get_instrument_list();
	Pattern *pPattern = NULL;
	QString patternInfoFile = directory;

	QFile check( patternInfoFile );
	if (check.exists() == false) {
		ERRORLOG( QString("Load Pattern: Data file %1 not found." ).arg( patternInfoFile ) );
		return NULL;
	}


	QDomDocument doc  = LocalFileMng::openXmlDocument( patternInfoFile );
	QFile file( patternInfoFile );

	// root element
	QDomNode rootNode = doc.firstChildElement( "drumkit_pattern" );	// root element
	if (  rootNode.isNull() ) {
		ERRORLOG( "Error reading Pattern: Pattern_drumkit_infonode not found" );
		return NULL;
	}

	QDomNode patternNode = rootNode.firstChildElement( "pattern" );

	QString sName( LocalFileMng::readXmlString( patternNode,"pattern_name", "" ) );
	QString sInfo( LocalFileMng::readXmlString( patternNode,"info", "" ) );
	QString sCategory( LocalFileMng::readXmlString( patternNode,"category", "" ) );


	int nSize = -1;
	nSize = LocalFileMng::readXmlInt( patternNode, "size",nSize ,false,false );
	pPattern = new Pattern( sName, sInfo, sCategory, nSize );



	QDomNode pNoteListNode = patternNode.firstChildElement( "noteList" );
	if ( ! pNoteListNode.isNull() )
	{
		// new code  :)
		QDomNode noteNode = pNoteListNode.firstChildElement( "note" );
		while (  ! noteNode.isNull()  )
		{
			Note* pNote = NULL;
			unsigned nPosition = LocalFileMng::readXmlInt( noteNode, "position", 0 );
			float fLeadLag = LocalFileMng::readXmlFloat( noteNode, "leadlag", 0.0 , false , false);
			float fVelocity = LocalFileMng::readXmlFloat( noteNode, "velocity", 0.8f );
			float fPan_L = LocalFileMng::readXmlFloat( noteNode, "pan_L", 0.5 );
			float fPan_R = LocalFileMng::readXmlFloat( noteNode, "pan_R", 0.5 );
			int nLength = LocalFileMng::readXmlInt( noteNode, "length", -1, true );
			float nPitch = LocalFileMng::readXmlFloat( noteNode, "pitch", 0.0, false, false );
			QString sKey = LocalFileMng::readXmlString( noteNode, "key", "C0", false, false );
			QString nNoteOff = LocalFileMng::readXmlString( noteNode, "note_off", "false", false, false );
			int instrId = LocalFileMng::readXmlInt( noteNode, "instrument", 0, true );

			Instrument *instrRef = instrList->find( instrId );
			if ( !instrRef ) {
				ERRORLOG( QString( "Instrument with ID: '%1' not found. Note skipped." ).arg( instrId ) );
				noteNode = noteNode.nextSiblingElement( "note" );
				continue;
			}
			//assert( instrRef );
			bool noteoff = false;
			if ( nNoteOff == "true" )
				noteoff = true;

			pNote = new Note( instrRef, nPosition, fVelocity, fPan_L, fPan_R, nLength, nPitch);
			pNote->set_key_octave( sKey );
			pNote->set_lead_lag(fLeadLag);
			pNote->set_note_off( noteoff );
			pPattern->insert_note( pNote );
			noteNode = noteNode.nextSiblingElement( "note" );
		}
	}

	return pPattern;

}