TouchSlider showIncDec, QCodeEditCompleter filter by str start

This commit is contained in:
2022-02-03 14:39:01 +03:00
parent 604441efc3
commit 04c7d773e3
3 changed files with 31 additions and 6 deletions

View File

@@ -9,7 +9,8 @@ TouchSlider::TouchSlider(QWidget * parent): QGroupBox(parent), ui(new Ui::TouchS
id_click = id_set = -1; id_click = id_set = -1;
hasZero = true; hasZero = true;
m_readOnly = false; m_readOnly = false;
m_showMinMax = false; m_showMinMax = true;
m_showIncDec = true;
} }
@@ -248,17 +249,37 @@ void TouchSlider::setShowMinMax(bool arg) {
QBoxLayout * bl = qobject_cast<QBoxLayout *>(layout()); QBoxLayout * bl = qobject_cast<QBoxLayout *>(layout());
m_showMinMax = arg; m_showMinMax = arg;
if (arg) { if (arg) {
ui->pbMin->hide(); ui->pbMin->show();
ui->pbMax->hide(); ui->pbMax->show();
bl->setStretchFactor(ui->pbInc, 2); bl->setStretchFactor(ui->pbInc, 2);
bl->setStretchFactor(ui->pbDec, 2); bl->setStretchFactor(ui->pbDec, 2);
bl->setStretchFactor(ui->pbZero, 2); bl->setStretchFactor(ui->pbZero, 2);
} else { } else {
ui->pbMin->show(); ui->pbMin->hide();
ui->pbMax->show(); ui->pbMax->hide();
bl->setStretchFactor(ui->pbInc, 1); bl->setStretchFactor(ui->pbInc, 1);
bl->setStretchFactor(ui->pbDec, 1); bl->setStretchFactor(ui->pbDec, 1);
bl->setStretchFactor(ui->pbZero, 1); bl->setStretchFactor(ui->pbZero, 1);
} }
} }
void TouchSlider::setShowIncDec(bool arg) {
QBoxLayout * bl = qobject_cast<QBoxLayout *>(layout());
m_showIncDec = arg;
if (arg) {
ui->pbDec->show();
ui->pbInc->show();
if (hasZero)
ui->pbZero->show();
bl->setStretchFactor(ui->pbMin, 2);
bl->setStretchFactor(ui->pbMax, 2);
} else {
ui->pbDec->hide();
ui->pbInc->hide();
if (hasZero)
ui->pbZero->hide();
bl->setStretchFactor(ui->pbMin, 1);
bl->setStretchFactor(ui->pbMax, 1);
}
}

View File

@@ -35,6 +35,7 @@ class QAD_TOUCH_WIDGETS_EXPORT TouchSlider: public QGroupBox
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool readOnly READ readOnly WRITE setReadOnly) Q_PROPERTY(bool readOnly READ readOnly WRITE setReadOnly)
Q_PROPERTY(bool showMinMax READ showMinMax WRITE setShowMinMax) Q_PROPERTY(bool showMinMax READ showMinMax WRITE setShowMinMax)
Q_PROPERTY(bool showIncDec READ showIncDec WRITE setShowIncDec)
Q_PROPERTY(double minimum READ minimum WRITE setMinimum) Q_PROPERTY(double minimum READ minimum WRITE setMinimum)
Q_PROPERTY(double maximum READ maximum WRITE setMaximum) Q_PROPERTY(double maximum READ maximum WRITE setMaximum)
Q_PROPERTY(double value READ value WRITE setValue) Q_PROPERTY(double value READ value WRITE setValue)
@@ -59,6 +60,7 @@ public:
QString suffix() const {return suff;} QString suffix() const {return suff;}
bool readOnly() const {return m_readOnly;} bool readOnly() const {return m_readOnly;}
bool showMinMax() const {return m_showMinMax;} bool showMinMax() const {return m_showMinMax;}
bool showIncDec() const {return m_showIncDec;}
private: private:
void updateCaption(); void updateCaption();
@@ -67,6 +69,7 @@ private:
bool hasZero; bool hasZero;
bool m_readOnly; bool m_readOnly;
bool m_showMinMax; bool m_showMinMax;
bool m_showIncDec;
double prec; double prec;
int id_click, id_set; int id_click, id_set;
QString pref, suff; QString pref, suff;
@@ -88,6 +91,7 @@ public slots:
void setMaximum(int max) {setMaximum((double)max);} void setMaximum(int max) {setMaximum((double)max);}
void setReadOnly(bool yes); void setReadOnly(bool yes);
void setShowMinMax(bool yes); void setShowMinMax(bool yes);
void setShowIncDec(bool yes);
void setValue(double val); void setValue(double val);
void setValue(int val) {setValue((double)val);} void setValue(int val) {setValue((double)val);}

View File

@@ -341,7 +341,7 @@ int QCodeEdit::skipCWord(const QString & s, int pos) {
bool QCodeEdit::matchWritten(QString s, QString w) { bool QCodeEdit::matchWritten(QString s, QString w) {
if (s.isEmpty() || w.isEmpty()) return true; if (s.isEmpty() || w.isEmpty()) return true;
if (s.contains(w, Qt::CaseInsensitive)) return true; if (s.startsWith(w, Qt::CaseInsensitive)) return true;
int sp(0); int sp(0);
for (int i = 0; i < w.size(); ++i, ++sp) { for (int i = 0; i < w.size(); ++i, ++sp) {
if (sp >= s.size()) return false; if (sp >= s.size()) return false;