コード例 #1
0
users::users(QWidget* parent, const char* name, Qt::WFlags fl)
    : XWidget(parent, name, fl)
{
  XSqlQuery usersusers;
  setupUi(this);

  connect(_close,             SIGNAL(clicked()), this,  SLOT(close()));
  connect(_edit,              SIGNAL(clicked()), this,  SLOT(sEdit()));
  connect(_new,               SIGNAL(clicked()), this,  SLOT(sNew()));
  connect(_print,             SIGNAL(clicked()), this,  SLOT(sPrint()));
  connect(_showInactive,  SIGNAL(toggled(bool)), this,  SLOT(sFillList()));
  connect(_usr,       SIGNAL(itemSelected(int)), _edit, SLOT(animateClick()));
  connect(_usr,             SIGNAL(valid(bool)), _edit, SLOT(setEnabled(bool)));
  connect(omfgThis,SIGNAL(userUpdated(QString)), this,  SLOT(sFillList()));

  _usr->addColumn(tr("Username"),    80, Qt::AlignLeft,   true, "usr_username");
  _usr->addColumn(tr("Proper Name"), -1, Qt::AlignLeft,   true, "usr_propername");
  _usr->addColumn(tr("Status"),      50, Qt::AlignCenter, true, "status");

  usersusers.exec("SELECT userCanCreateUsers(getEffectiveXtUser()) AS cancreate;");
  if (usersusers.first())
    _new->setEnabled(usersusers.value("cancreate").toBool());
  else
    systemError(this, tr("A System Error occurred at %1::%2.")
                      .arg(__FILE__)
                      .arg(__LINE__) );
     
  sFillList();
}
コード例 #2
0
users::users(QWidget* parent, const char* name, Qt::WFlags fl)
    : XWidget(parent, name, fl)
{
  setupUi(this);

  connect(_close,             SIGNAL(clicked()), this,  SLOT(close()));
  connect(_edit,              SIGNAL(clicked()), this,  SLOT(sEdit()));
  connect(_new,               SIGNAL(clicked()), this,  SLOT(sNew()));
  connect(_print,             SIGNAL(clicked()), this,  SLOT(sPrint()));
  connect(_showInactive,  SIGNAL(toggled(bool)), this,  SLOT(sFillList()));
  connect(_usr,       SIGNAL(itemSelected(int)), _edit, SLOT(animateClick()));
  connect(_usr,             SIGNAL(valid(bool)), _edit, SLOT(setEnabled(bool)));
  connect(omfgThis,SIGNAL(userUpdated(QString)), this,  SLOT(sFillList()));

  _usr->addColumn(tr("Username"),    80, Qt::AlignLeft,   true, "usr_username");
  _usr->addColumn(tr("Proper Name"), -1, Qt::AlignLeft,   true, "usr_propername");
  _usr->addColumn(tr("Status"),      50, Qt::AlignCenter, true, "status");

  XSqlQuery uq;
  uq.exec("SELECT userCanCreateUsers(CURRENT_USER) AS cancreate;");
  if (uq.first())
    _new->setEnabled(uq.value("cancreate").toBool());
  ErrorReporter::error(QtCriticalMsg, this, tr("Database Error"),
                       uq, __FILE__, __LINE__);
     
  sFillList();
}
コード例 #3
0
ConnectDialog::ConnectDialog()
	: QDialog(0)
{
	setModal(true);

	QGridLayout *layout = new QGridLayout(this);
	setLayout(layout);


	QLabel *hostLabel = new QLabel("Host", this);
	layout->addWidget(hostLabel, 0, 0);
	wHost = new QLineEdit("localhost", this);
	connect(wHost, SIGNAL(textChanged(QString)), this, SIGNAL(hostUpdated(QString)));
	layout->addWidget(wHost, 0, 1);

	QLabel *portLabel = new QLabel("Port", this);
	layout->addWidget(portLabel, 1, 0);
	wPort = new QSpinBox(this);
	wPort->setRange(0, 65535);
	wPort->setValue(7000);
	connect(wPort, SIGNAL(valueChanged(int)), this, SLOT(sendPortUpdated(int)));
	layout->addWidget(wPort, 1, 1);

	QLabel *userLabel = new QLabel("User", this);
	layout->addWidget(userLabel, 2, 0);
	wUser = new QLineEdit(this);
	connect(wUser, SIGNAL(textChanged(QString)), this, SIGNAL(userUpdated(QString)));
	layout->addWidget(wUser, 2, 1);

	QLabel *passwdLabel = new QLabel("Password", this);
	layout->addWidget(passwdLabel, 3, 0);
	wPasswd = new QLineEdit(this);
	wPasswd->setEchoMode(QLineEdit::Password);
	connect(wPasswd, SIGNAL(textChanged(QString)), this, SIGNAL(passwdUpdated(QString)));
	layout->addWidget(wPasswd, 3, 1);
	
	
	wConnect = new QPushButton("Connect");
	wConnect->setDefault(true);
	connect(wConnect, SIGNAL(clicked()), this, SIGNAL(connectClicked()));
	
	QPushButton *cancel = new QPushButton("Cancel");
	connect(cancel, SIGNAL(clicked()), this, SLOT(close()));
	
	QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
	buttonBox->addButton(wConnect, QDialogButtonBox::AcceptRole);
	buttonBox->addButton(cancel, QDialogButtonBox::RejectRole);
	
	layout->addWidget(buttonBox, 4, 1);
}