Пример #1
0
void FractionInput::setAllowRange( bool allowRange )
{
	m_allowRange = allowRange;
	if ( allowRange ) {
		setValidator( &m_rangeValidator );
	} else {
		setValidator( &m_numberValidator );
	}
}
Пример #2
0
/*
 * Refreshes the validator used in QLineEdit depending on the options choosed by the user
 */
void SearchLineEdit::setRefreshValidator(ValidatorType validatorType)
{
  if (validatorType == ectn_AUR_VALIDATOR)
    setValidator(m_aurValidator);
  else if (validatorType == ectn_FILE_VALIDATOR)
    setValidator(m_fileValidator);
  else if (validatorType == ectn_DEFAULT_VALIDATOR)
    setValidator(m_defaultValidator);

  //If the current string is not valid anymore, let's erase it!
  int pos = 0;
  QString search = text();
  if (this->validator()->validate(search, pos) == QValidator::Invalid)
    setText("");
}
Пример #3
0
      AdjustButton::AdjustButton (QWidget* parent, float change_rate) :
        QLineEdit (parent),
        rate (change_rate),
        min (-std::numeric_limits<float>::max()),
        max (std::numeric_limits<float>::max()),
        is_min (false),
        is_max (false),
        deadzone_y (-1),
        deadzone_value (NAN)
      {
          setValidator (new QDoubleValidator (this));

          setToolTip (tr ("Click & drag to adjust"));
          setAlignment (Qt::AlignRight);

          connect (this, SIGNAL (editingFinished()), SLOT (onSetValue()));
          installEventFilter (this);
          setStyleSheet ((
              "QLineEdit { "
              "padding: 0.1em 20px 0.2em 0.3ex; "
              "background: qlineargradient(x1:0, y1:0, x2:0, y2:0.2, stop:0 gray, stop:1 white) url(:/adjustbutton.svg); "
              "background-position: right; "
              "background-repeat: no-repeat; "
              "font-size: " + str(font().pointSize()) + "pt; "
              "border: 1px solid grey; "
              "border-color: black lightgray white gray; "
              "border-radius: 0.3em }").c_str());

        }
Пример #4
0
std::pair<QSqlQueryModel *, RecordEditorWidget *>
TeacherForm::createModelAndEditor() {
    const QVariantMap columnLabels = {
        {"first_name", QObject::tr("First Name")},
        {"last_name", QObject::tr("Last Name")},
        {"email", QObject::tr("Email")},
        {"rfid", QObject::tr("RFID")},
        {"employee_number", QObject::tr("Employee Number")},
        {"office", QObject::tr("Office Number")}};

    TeacherQueryModel *model = new TeacherQueryModel(
        columnLabels, QSqlDatabase::database(DEFAULT_DB_NAME));
    const FieldTypes fieldTypes = {{"first_name", FieldType::LineEdit},
                                   {"last_name", FieldType::LineEdit},
                                   {"email", FieldType::LineEdit},
                                   {"rfid", FieldType::LineEdit},
                                   {"employee_number", FieldType::LineEdit},
                                   {"office", FieldType::LineEdit}};
    auto editor = new TeacherEditorWidget(fieldTypes);
    editor->setupUi(columnLabels, model->record());
    editor->setValidator(new TeacherValidator(editor->fieldTypes(),
                                              editor->fieldEditors(), editor));
    editor->clearData();

    return make_pair<QSqlQueryModel *, RecordEditorWidget *>(model, editor);
}
    void changeShellTimeoutDialog()
    {
        auto changeShellTimeoutDialog = new QDialog;
        auto settingsManager = AppRegistry::instance().settingsManager();
        auto currentShellTimeout = new QLabel(QString::number(settingsManager->shellTimeoutSec()));
        auto newShellTimeout = new QLineEdit;
        newShellTimeout->setValidator(new QIntValidator(0, 100000));
        auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Save | QDialogButtonBox::Cancel);
        QObject::connect(buttonBox, SIGNAL(accepted()), changeShellTimeoutDialog, SLOT(accept()));
        QObject::connect(buttonBox, SIGNAL(rejected()), changeShellTimeoutDialog, SLOT(reject()));
        auto lay = new QGridLayout;
        auto firstLabel = new QLabel("Enter new value for Robo 3T shell timeout in seconds:\n");
        lay->addWidget(firstLabel,                      0, 0, 1, 2, Qt::AlignLeft);
        lay->addWidget(new QLabel("Current Value: "),   1, 0);
        lay->addWidget(currentShellTimeout,             1, 1);
        lay->addWidget(new QLabel("New Value: "),       2, 0);
        lay->addWidget(newShellTimeout,                 2, 1);
        lay->addWidget(buttonBox,                       3, 0, 1, 2, Qt::AlignRight);
        changeShellTimeoutDialog->setLayout(lay);
        changeShellTimeoutDialog->setWindowTitle("Robo 3T");

        if (changeShellTimeoutDialog->exec()) {
            settingsManager->setShellTimeoutSec(newShellTimeout->text().toInt());
            settingsManager->save();
            auto subStr = settingsManager->shellTimeoutSec() > 1 ? " seconds." : " second.";
            LOG_MSG("Shell timeout value changed from " + currentShellTimeout->text() + " to " +
                QString::number(settingsManager->shellTimeoutSec()) + subStr, mongo::logger::LogSeverity::Info());

            for (auto server : AppRegistry::instance().app()->getServers())
                server->changeWorkerShellTimeout(std::abs(newShellTimeout->text().toInt()));
        }
    }
Пример #6
0
KexiIdentifierPropertyEdit::KexiIdentifierPropertyEdit(QWidget *parent)
        : KoProperty::StringEdit(parent)
{
    KexiUtils::IdentifierValidator *val = new KexiUtils::IdentifierValidator(this);
    setValidator(val);
    val->setObjectName("KexiIdentifierPropertyEdit Validator");
}
Пример #7
0
PlaceEdit::PlaceEdit(PlaceEdit *_parent, int _index, QString placeholderText, QWidget *qparent)
  : QLineEdit(qparent)
{
  qDebug() << "creating place edit";

  setMaxLength(40);

  setPlaceholderText(placeholderText);

  m_model = new PlaceModel(_index, this);
  m_completer = new QCompleter(m_model, this);
  m_completer->setCaseSensitivity(Qt::CaseInsensitive);

  // TODO put in mask
  // TODO prevent slashes

  m_completer->setModel(m_model);
  setCompleter(m_completer);

  setValidator(new LineValidator(this));

  if (_parent) {
    connect(_parent->model(), SIGNAL(valueChanged(QString)), m_model, SLOT(onParentTextChanged(QString)));
    connect(_parent->model(), SIGNAL(valueChanged(QString)), this, SLOT(onParentTextChanged(QString)));
  }
}
Пример #8
0
IntegerEdit::IntegerEdit()
    : QLineEdit()
{
    val = new IntegerValidator;
    setValidator(val);
    setToolTip(tr("Enter an integer or bool\n0x... for hex, 0b... for binary"));
}
Пример #9
0
 /* Constructor: */
 NameEditor(QWidget *pParent = 0) : QLineEdit(pParent)
 {
     setFrame(false);
     setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
     setValidator(new QRegExpValidator(QRegExp("[^,:]*"), this));
     connect(this, SIGNAL(textEdited(const QString&)), this, SLOT(sltTextEdited(const QString&)));
 }
Пример #10
0
QIPEdit::QIPEdit(QWidget *parent)
	: QLineEdit(parent)
{
	ui.setupUi(this);

	setValidator(new QIPValidator(this));
}
Пример #11
0
WDateEdit::WDateEdit(WContainerWidget *parent)
  : WLineEdit(parent)
{
  changed().connect(this, &WDateEdit::setFromLineEdit);

  const char *TEMPLATE = "${calendar}";

  WTemplate *t = new WTemplate(WString::fromUTF8(TEMPLATE));
  popup_ = new WPopupWidget(t, this);
  popup_->setAnchorWidget(this);
  popup_->setTransient(true);

  calendar_ = new WCalendar();
  calendar_->activated().connect(popup_, &WPopupWidget::hide);
  calendar_->activated().connect(this, &WDateEdit::setFocus);
  calendar_->selectionChanged().connect(this, &WDateEdit::setFromCalendar);

  t->bindWidget("calendar", calendar_);

  WApplication::instance()->theme()->apply(this, popup_, DatePickerPopupRole);

  t->escapePressed().connect(popup_, &WTemplate::hide);
  t->escapePressed().connect(this, &WDateEdit::setFocus);

  setValidator(new WDateValidator("dd/MM/yyyy", this));
}
Пример #12
0
// KTimeWidget/QTimeEdit provide nicer editing, but don't provide a combobox.
// Difficult to get all in one...
// But Qt-3.2 will offer QLineEdit::setMask, so a "99:99" mask would help.
KTimeEdit::KTimeEdit(QWidget *parent, QTime qt, const char *name)
    : QComboBox(true, parent, name)
{
    setInsertionPolicy(NoInsertion);
    setValidator(new KOTimeValidator(this));

    mTime = qt;

    //  mNoTimeString = i18n("No Time");
    //  insertItem( mNoTimeString );

    // Fill combo box with selection of times in localized format.
    QTime timeEntry(0, 0, 0);
    do
    {
        insertItem(KGlobal::locale()->formatTime(timeEntry));
        timeEntry = timeEntry.addSecs(60 * 15);
    }
    while(!timeEntry.isNull());
    // Add end of day.
    insertItem(KGlobal::locale()->formatTime(QTime(23, 59, 59)));

    updateText();
    setFocusPolicy(QWidget::StrongFocus);

    connect(this, SIGNAL(activated(int)), this, SLOT(active(int)));
    connect(this, SIGNAL(highlighted(int)), this, SLOT(hilit(int)));
    connect(this, SIGNAL(textChanged(const QString &)), this, SLOT(changedText()));
}
Пример #13
0
QcNumberBox::QcNumberBox()
: scroll( true ),
  lastPos( 0 ),
  editedTextColor( QColor( "red" ) ),
  normalTextColor( palette().color(QPalette::Text) ),
  _validator( new QDoubleValidator( this ) ),
  step( 0.1f ),
  scrollStep( 1.0f ),
  dragDist( 10.f ),
  _value( 0. ),
  _valueType( Number ),
  _minDec(0),
  _maxDec(2)
{
  _validator->setDecimals( _maxDec );
  setValidator( _validator );

  // Do not display thousands separator. It only eats up precious space.
  QLocale loc( locale() );
  loc.setNumberOptions( QLocale::OmitGroupSeparator );
  setLocale( loc );

  setLocked( true );

  connect( this, SIGNAL( editingFinished() ),
           this, SLOT( onEditingFinished() ) );
  connect( this, SIGNAL( valueChanged() ),
           this, SLOT( updateText() ), Qt::QueuedConnection );
  setValue( 0 );
}
Пример #14
0
DoubleEdit::DoubleEdit(QWidget* parent) 
  : QLineEdit(parent)
{ 
  QDoubleValidator* validator = new QDoubleValidator(-DBL_MAX, DBL_MAX, 3, this);
  setValidator(validator);
  setMaximumWidth(60);
  setValue(0.0);
}
Пример #15
0
FractionInput::FractionInput( QWidget *parent, MixedNumber::Format format ) : KLineEdit( parent ),
	m_allowRange(false),
	m_format(format)
{
	//setAlignment( Qt::AlignRight );

	setValidator( &m_numberValidator );
}
Пример #16
0
DateEdit::DateEdit(QWidget *parent)
        : QLineEdit(parent)
{
    setValidator(new DateValidator(this));
#if COMPAT_QT_VERSION >= 0x030200
    setInputMask("00/00/0000;_");
#endif
}
Пример #17
0
UnsignedIntegerEdit::UnsignedIntegerEdit(QWidget *parent)
 : QLineEdit(parent)
{
    connect(this, SIGNAL(textChanged(QString)), SLOT(onTextChanged(QString)));

    // Set the validator range to the range of values in a 32 bit unsigned integer (dbus-type 'u').
    // FIXME: Maximum value must be a valid type "int" for the validator to work. What a POS
    setValidator(new QIntValidator(0, 2147483647, this));
}
Пример #18
0
RaLineEdit::RaLineEdit(QWidget *pParent, const char *pName) :
  VirtualClusterLineEdit(pParent, "rahead", "rahead_id",
			 "rahead_number", "rahead_billtoname",
			 0, pName)
{
  setTitles(tr("Return Authorization"), tr("Return Authorizations"));

  setValidator(new QIntValidator(0, 9999999, this));
  connect(this, SIGNAL(textChanged(const QString &)), this, SIGNAL(numberChanged(const QString &)));
}
Пример #19
0
QtColorLineEdit::QtColorLineEdit(QWidget * parent)
	: QLineEdit(parent)
{
	QRegExpValidator *validator = new QRegExpValidator();
	validator->setRegExp(QRegExp("#[A-F0-9]{8}", Qt::CaseInsensitive));

	setValidator(validator);

	QObject::connect(this, SIGNAL(editingFinished()), this, SLOT(EditFinished()));
}
Пример #20
0
ParameterNameEdit::ParameterNameEdit( BehaviorTreeContext ctx, Parameter* p ) :
  QLineEdit( p->m_Id.m_Text ), m_Context( ctx ), m_Param( p )
{
  setValidator( new PreventDuplicateSymbols( m_Context, this ) );
  setFrame( false );

  QPalette pal = palette();
  pal.setColor( backgroundRole(), Qt::transparent );
  setPalette( pal );
}
Пример #21
0
SegIPEdit::SegIPEdit(QWidget *parent) :
    QLineEdit(parent)
{
    setAlignment(Qt::AlignCenter);
    setMaxLength(3);

    QRegExp rx("(2[0-5]{2}|2[0-4][0-9]|1?[0-9]{1,2})");

    setValidator(new QRegExpValidator(rx, this));
}
Пример #22
0
//  Routines for SoLineEdit - an sohead validating XLineEdit
SoLineEdit::SoLineEdit(QWidget *pParent, const char *name) : XLineEdit(pParent, name)
{
  _id     = -1;
  _number = -1;
  _custid = -1;

  setValidator(new QIntValidator(0, 9999999, this));

  connect(this, SIGNAL(lostFocus()), this, SLOT(sParse()));
}
Пример #23
0
WSpinBox::WSpinBox(WContainerWidget *parent)
  : WAbstractSpinBox(parent),
    value_(-1),
    min_(0),
    max_(99),
    step_(1)
{ 
  setValidator(createValidator());
  setValue(0);
}
Пример #24
0
void KSimBaseIntSpinBox::init()
{
	setValidator(0);
	connect(this,SIGNAL(valueChanged(int)), this, SLOT(slotValueChanged(int)));
	connect(editor(), SIGNAL(textChanged(const QString &)),SLOT(slotTextChanged(const QString &)));
	KSimSpinBox::setMinValue(Private::s_lowerLimit);
	KSimSpinBox::setMaxValue(Private::s_upperLimit);
	setFocusPolicy(QWidget::WheelFocus);
	setAlignRight();
}
Пример #25
0
UserNameLineEdit::UserNameLineEdit(QWidget *parent)
    :QLineEdit(parent)
{
    static QString userNamePattern("[a-zA-Z0-9 _-]{0,16}"); //allowing lower and upper case letters, numbers, _ and - symbols, blank space, at least 1 character and max 16 characters.
    QRegularExpressionValidator *validator = new QRegularExpressionValidator(QRegularExpression(userNamePattern), this);
    setValidator(validator);

    setMaxLength(16); //this maxLength need be changed if we decide support non ASCII user names

    connect(this, SIGNAL(editingFinished()), this, SLOT(updateText()));
}
Пример #26
0
void LineEditWidget::setRxValidator(const QString &str)
{
    _rxValidator = str;
    if (str.isEmpty()) {
        return;
    }

    QRegExp rx(str);
    QRegExpValidator *validator = new QRegExpValidator(rx, this);
    setValidator(validator);
}
Пример #27
0
KInfobarEdit::KInfobarEdit(QWidget *parent/* = 0*/)
: QLineEdit(parent)
{
    QRegExp regx("[0-9]+$");

    validator = NULL;
    QValidator *validator = new QRegExpValidator(regx, this);

    setValidator( validator );
    setMaxLength(3);
}
Пример #28
0
WDoubleSpinBox::WDoubleSpinBox(WContainerWidget *parent)
  : WAbstractSpinBox(parent),
    value_(-1),
    min_(0.0),
    max_(99.99),
    step_(1.0),
    precision_(2)
{ 
  setValidator(createValidator());
  setValue(0.0);
}
Пример #29
0
//  Routines for SoLineEdit - an sohead validating XLineEdit
SoLineEdit::SoLineEdit(QWidget *pParent, const char *name) : XLineEdit(pParent, name)
{
  _id     = -1;
  _number = -1;
  _custid = -1;
  _sitePrivs = true;

  setValidator(new QIntValidator(0, 9999999, this));
  _mapper = new XDataWidgetMapper(this);
  
  connect(this, SIGNAL(lostFocus()), this, SLOT(sParse()));
}
Пример #30
0
void ValueSlider::
        rangeChanged(int min, int max)
{
    emit rangeChanged(toReal(min), toReal(max));

    lineEdit()->setToolTip(QString("%3 [%1, %2]")
                           .arg(minimum(),0,'f',decimals(minimum()))
                           .arg(maximum(),0,'f',decimals(maximum()))
                           .arg(toolTip()));
    //setValidator(new QDoubleValidator(minimum(), maximum(), 1000));
    setValidator(new QDoubleValidator());// minimum(), maximum(), 1000));
}