Пример #1
0
bool OSComboBox2::event( QEvent * e )
{
  if( e->type() == QEvent::Wheel )
  {
    return false;
  }
  else if (e->type() == QEvent::FocusIn && this->focusPolicy() == Qt::ClickFocus)
  {
    QString style("QComboBox { background: #ffc627; }");
    setStyleSheet(style);

    emit inFocus(true, hasData());

    return QComboBox::event(e);
  }
  else if (e->type() == QEvent::FocusOut && this->focusPolicy() == Qt::ClickFocus)
  {
    QString style("QComboBox { background: white; }");
    setStyleSheet(style);

    emit inFocus(false, false);

    return QComboBox::event(e);
  }
  else
  {
    return QComboBox::event(e);
  }
}
Пример #2
0
void OSLineEdit2::onEditingFinished() {
  if (m_modelObject && (m_set || m_setOptionalStringReturn || m_setVoidReturn)) {
    if (m_text != this->text().toStdString()) {
      m_text = this->text().toStdString();
      auto result = false;
      if (m_set) {
        result = (*m_set)(m_text);
      }
      else if (m_setOptionalStringReturn) {
        auto optionalStringReturn = (*m_setOptionalStringReturn)(m_text);
        if (optionalStringReturn) {
          result = true; // TODO
        }
        result = true;
      }
      else if (m_setVoidReturn) {
        (*m_setVoidReturn)(m_text);
        result = true;
      }
      if (!result){
        //restore
        onModelObjectChange();
      }
      else {
        emit inFocus(true, hasData());
        adjustWidth();
      }
    }
  }
}
Пример #3
0
void GcOverlayWidget::focusInEvent(QFocusEvent *) 
{
    m_infocus = true;
    parentWidget()->installEventFilter(this);
    parentWidget()->repaint();
    emit inFocus(true);
}
Пример #4
0
void OSIntegerEdit2::onEditingFinished() {

  emit inFocus(true, hasData());

  QString text = this->text();
  if (text.isEmpty() || m_text == text) return;

  if (m_modelObject) {
    std::string str = this->text().toStdString();
    boost::regex autore("[aA][uU][tT][oO]");
    ModelObject modelObject = m_modelObject.get();

    if (str.empty()) {
      if (m_reset) {
        (*m_reset)();
      }
    }
    else if (boost::regex_search(str,autore)) {
      if (m_isAutosized) {
        if (m_autosize) {
          (*m_autosize)();
        }
        else if (m_reset) {
          (*m_reset)();
        }
      }
      if (m_isAutocalculated) {
        if (m_autocalculate) {
          (*m_autocalculate)();
        }
        else if (m_reset) {
          (*m_reset)();
        }
      }
    }
    else {
      try {
        int value = boost::lexical_cast<int>(str);
        setPrecision(str);
        if (m_set) {
          QString text = this->text();
          if (text.isEmpty() || m_text == text) return;
          bool result = (*m_set)(value);
          if (!result){
            //restore
            refreshTextAndLabel();
          }
        }
      }
      catch (...) 
      {
        // restore
        refreshTextAndLabel();
      }
    }
  }
}
Пример #5
0
void OSLineEdit2::focusInEvent(QFocusEvent * e)
{
  if (e->reason() == Qt::MouseFocusReason && m_hasClickFocus)
  {
    QString style("QLineEdit { background: #ffc627; }");
    setStyleSheet(style);

    emit inFocus(true, hasData());
  }

  QLineEdit::focusInEvent(e);
}
Пример #6
0
void OSIntegerEdit2::focusOutEvent(QFocusEvent * e)
{
  if (e->reason() == Qt::MouseFocusReason && m_hasClickFocus)
  {
    QString style("QLineEdit { background: white; }");
    setStyleSheet(style);

    emit inFocus(false, false);
  }
  
  QLineEdit::focusOutEvent(e);
}
Пример #7
0
void Edit::focusInEvent(QFocusEvent *e)
{
    QLineEdit::focusInEvent(e);

    emit(inFocus(true));

    if(this->text() == valueStandart)
    {
        this->setText("");
        isMask = true;
    }

}
Пример #8
0
void OSComboBox2::onCurrentIndexChanged(const QString & text)
{
  emit inFocus(true, hasData());

  OS_ASSERT(m_modelObject);

  if( m_choiceConcept )
  {
    std::string value = text.toStdString();

    this->blockSignals(true);
    m_choiceConcept->set(value);
    onModelObjectChanged(); // will be sure to display actual value
    this->blockSignals(false);
  }
}
Пример #9
0
void OSLineEdit2::onEditingFinished() {
    if(m_modelObject && m_set) {
        if (m_text != this->text().toStdString()) {
            m_text = this->text().toStdString();
            bool result = (*m_set)(m_text);
            if (!result) {
                //restore
                onModelObjectChange();
            }
            else {
                emit inFocus(true, hasData());
                adjustWidth();
            }
        }
    }
}
Пример #10
0
void OSLineEdit2::focusOutEvent(QFocusEvent * e)
{
  if (e->reason() == Qt::MouseFocusReason && m_hasClickFocus)
  {
    QString style("QLineEdit { background: white; }");
    setStyleSheet(style);

    emit inFocus(false, false);

#ifdef openstudio_lib_EXPORTS
    auto mouseOverInspectorView = OSAppBase::instance()->currentDocument()->mainRightColumnController()->inspectorController()->inspectorView()->mouseOverInspectorView();
    if (!mouseOverInspectorView) {
      emit itemClicked(nullptr);
    }
#endif

  }

  QLineEdit::focusOutEvent(e);
}
Пример #11
0
void ChatbarTextEdit::dropEvent(QDropEvent *evt) {
	inFocus(true);
	QTextEdit::dropEvent(evt);
}
Пример #12
0
void ChatbarTextEdit::focusOutEvent(QFocusEvent *qfe) {
	inFocus(false);
	QTextEdit::focusOutEvent(qfe);
}
Пример #13
0
void ChatbarTextEdit::focusInEvent(QFocusEvent *qfe) {
	inFocus(true);
	QTextEdit::focusInEvent(qfe);
}
void TContainerLine::m_inFocus(bool value) {
    setLine(value);
    emit inFocus(value);
}
Пример #15
0
int Editor::Painter::next()
{
  int pos = lexemEnd;
  if (str[pos] == 0)
  {
    lexemStart = pos;
    lexemType = tNull;
    return lexemType;
  }

  if (ctx)
  {
    lexemStart = 0;
    if (ctx == ctxString)
      lexemType = tString;
    else
      lexemType = tComment;
    while (str[pos])
    {
      if (str[pos] == ']')
      {
        pos++;
        int count = 0;
        while (str[pos] == '=' && count < ctxType)
          pos++, count++;
        if (str[pos] == ']' && count == ctxType)
        {
          lexemEnd = pos + 1;
          ctx = 0;
          ctxType = 0;
          return lexemType;
        }
      }
      else
        pos++;
    }
    lexemEnd = pos;
    return lexemType;
  }

  while (str[pos])
  {
    if (str[pos] == '-' && str[pos + 1] == '-')
    {
      lexemStart = pos;
      lexemType = tComment;
      pos += 2;
      int ctxCount = -1;
      if (str[pos] == '[')
      {
        pos++;
        ctxCount = 0;
        while (str[pos] == '=')
          pos++, ctxCount++;
        if (str[pos] != '[')
          ctxCount = -1;
      }
      while (str[pos])
      {
        if (ctxCount >= 0 && str[pos] == ']')
        {
          pos++;
          int count = 0;
          while (str[pos] == '=' && count < ctxCount)
            pos++, count++;
          if (str[pos] == ']' && count == ctxCount)
          {
            lexemEnd = pos + 1;
            return lexemType;
          }
        }
        else
          pos++;
      }
      lexemEnd = pos;
      return lexemType;
    } // end comment
    if (str[pos] == '"' || str[pos] == '\'')
    {
      lexemStart = pos++;
      lexemType = tString;
      while (str[pos])
      {
        if (str[pos] == '\\')
          pos++;
        else if (str[pos] == str[lexemStart])
        {
          pos++;
          break;
        }
        if (str[pos])
          pos++;
      }
      lexemEnd = pos;
      return lexemType;
    } // end quoted string
    if (str[pos] == '[')
    {
      lexemType = tString;
      lexemStart = pos++;
      int ctxCount = 0;
      while (str[pos] == '=')
        pos++, ctxCount++;
      if (str[pos] == '[')
      {
        while (str[pos])
        {
          if (str[pos] == ']')
          {
            pos++;
            int count = 0;
            while (str[pos] == '=' && count < ctxCount)
              pos++, count++;
            if (str[pos] == ']' && count == ctxCount)
            {
              lexemEnd = pos + 1;
              return lexemType;
            }
          }
          else
            pos++;
        }
        lexemEnd = pos;
        return lexemType;
      }
      else if (inFocus(lexemStart))
      {
        lexemEnd = lexemStart + 1;
        return lexemType = tFocusBracket;
      }
      else
        pos = lexemStart;
    } // end long string
    if ((str[pos] >= '0' && str[pos] <= '9') ||
        (str[pos] == '.' && str[pos + 1] >= '0' && str[pos + 1] <= '9'))
    {
      lexemType = tNumber;
      lexemStart = pos;
      bool expo = false;
      if (str[pos] == '0' && (str[pos + 1] == 'x' || str[pos + 1] == 'X'))
      {
        pos += 2;
        while ((str[pos] >= '0' && str[pos] <= '9') ||
               (str[pos] >= 'a' && str[pos] <= 'f') ||
               (str[pos] >= 'A' && str[pos] <= 'F'))
          pos++;
        if (str[pos] == '.')
        {
          pos++;
          while ((str[pos] >= '0' && str[pos] <= '9') ||
                 (str[pos] >= 'a' && str[pos] <= 'f') ||
                 (str[pos] >= 'A' && str[pos] <= 'F'))
            pos++;
        }
        if (str[pos] == 'p' || str[pos] == 'P')
          expo = true;
      }
      else
      {
        while (str[pos] >= '0' && str[pos] <= '9')
          pos++;
        if (str[pos] == '.')
        {
          pos++;
          while (str[pos] >= '0' && str[pos] <= '9')
            pos++;
        }
        if (str[pos] == 'e' || str[pos] == 'E')
          expo = true;
      }
      if (expo)
      {
        pos++;
        if ((str[pos] == '+' || str[pos] == '-') && str[pos + 1] >= '0' && str[pos + 1] <= '9')
          pos++;
        while (str[pos] >= '0' && str[pos] <= '9')
          pos++;
      }
      lexemEnd = pos;
      return lexemType;
    } // end number
    if ((str[pos] >= 'a' && str[pos] <= 'z') ||
        (str[pos] >= 'A' && str[pos] <= 'Z') || str[pos] == '_')
    {
      lexemType = tNull;
      lexemStart = pos;
      while ((str[pos] >= 'a' && str[pos] <= 'z') ||
             (str[pos] >= 'A' && str[pos] <= 'Z') ||
             (str[pos] >= '0' && str[pos] <= '9') || str[pos] == '_')
        pos++;
      lexemEnd = pos;
      WideString key(str + lexemStart, lexemEnd - lexemStart);
      if (e->keywords.has(key))
        lexemType = e->keywords.get(key);
      if (lexemType != tNull)
      {
        if (inFocus(lexemStart))
          lexemType = tFocusKeyword;
        return lexemType;
      }
    } // end literal
    else if ((str[pos] == '(' || str[pos] == ')' || str[pos] == '{' || str[pos] == '}' || str[pos] == ']') && inFocus(pos))
    {
      lexemStart = pos;
      lexemEnd = pos + 1;
      return lexemType = tFocusBracket;
    }
    else
      pos++;
  }
  lexemStart = pos;
  lexemEnd = pos;
  lexemType = tNull;
  return lexemType;
}