mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
DiagramContextWidget: Fix verification of keys
This commit is contained in:
parent
a8d42b0f9a
commit
e9a5fded5c
@ -92,7 +92,7 @@ const QVariant DiagramContext::operator[](const QString &key) const
|
||||
@return true if the insertion succeeds, false otherwise
|
||||
*/
|
||||
bool DiagramContext::addValue(const QString &key, const QVariant &value, bool show) {
|
||||
if (keyIsAcceptable(key)) {
|
||||
if (isKeyAcceptable(key)) {
|
||||
m_content.insert(key, value);
|
||||
m_content_show.insert(key, show);
|
||||
return(true);
|
||||
@ -240,10 +240,11 @@ bool DiagramContext::stringLongerThan(const QString &a, const QString &b) {
|
||||
@param key a key string
|
||||
@return true if that key is acceptable, false otherwise
|
||||
*/
|
||||
bool DiagramContext::keyIsAcceptable(const QString &key) const
|
||||
bool DiagramContext::isKeyAcceptable(const QString &key)
|
||||
{
|
||||
QRegularExpression re(DiagramContext::validKeyRegExp());
|
||||
QRegularExpressionMatch match =re.match(key);
|
||||
static const QRegularExpression re(DiagramContext::validKeyRegExp());
|
||||
|
||||
QRegularExpressionMatch match = re.match(key);
|
||||
return match.hasMatch();
|
||||
}
|
||||
|
||||
|
@ -82,11 +82,12 @@ class DiagramContext
|
||||
void toSettings(QSettings &, const QString &) const;
|
||||
void fromSettings(QSettings &, const QString &);
|
||||
|
||||
static QString validKeyRegExp();
|
||||
static bool isKeyAcceptable(const QString &);
|
||||
|
||||
private:
|
||||
static bool stringLongerThan(const QString &, const QString &);
|
||||
bool keyIsAcceptable(const QString &) const;
|
||||
static QString validKeyRegExp();
|
||||
|
||||
/// Diagram context data (key/value pairs)
|
||||
QHash<QString, QVariant> m_content;
|
||||
QHash<QString, bool> m_content_show;
|
||||
|
@ -120,8 +120,6 @@ void DiagramContextWidget::clear()
|
||||
*/
|
||||
int DiagramContextWidget::highlightNonAcceptableKeys()
|
||||
{
|
||||
static QRegularExpression re(DiagramContext::validKeyRegExp());
|
||||
|
||||
QBrush fg_brush = ui->m_table->palette().brush(QPalette::WindowText);
|
||||
|
||||
int invalid_keys = 0;
|
||||
@ -135,7 +133,7 @@ int DiagramContextWidget::highlightNonAcceptableKeys()
|
||||
bool highlight = false;
|
||||
if (!qtwi_name -> text().isEmpty())
|
||||
{
|
||||
if (re!=QRegularExpression(qtwi_name -> text()))
|
||||
if (! DiagramContext::isKeyAcceptable(qtwi_name->text()))
|
||||
{
|
||||
highlight = true;
|
||||
++ invalid_keys;
|
||||
|
Loading…
x
Reference in New Issue
Block a user