Example #1
0
  CEMatrixEditor::CEMatrixEditor(CrystallographyExtension *ext, QMainWindow *w)
    : CEAbstractEditor(ext, w)
  {
    ui.setupUi(this);

    // Emit editStarted
    connect(ui.edit_matrix, SIGNAL(textChanged()),
            this, SIGNAL(editStarted()));

    // Apply button connections
    connect(ui.push_matrix_apply, SIGNAL(clicked()),
            this, SIGNAL(editAccepted()));
    connect(ui.push_matrix_apply, SIGNAL(clicked()),
            this, SLOT(setMatrix()));

    // Reset button connections
    connect(ui.push_matrix_reset, SIGNAL(clicked()),
            this, SIGNAL(editRejected()));
    connect(ui.push_matrix_reset, SIGNAL(clicked()),
            this, SLOT(refreshEditor()));

    // Validation
    connect(ui.edit_matrix, SIGNAL(textChanged()),
            this, SLOT(validateEditor()));

    // Apply/reset enable
    connect(ui.edit_matrix, SIGNAL(textChanged()),
            this, SLOT(enableButtons()));

    ui.edit_matrix->setCurrentFont(QFont("Monospace",
                                         CE_FONTSIZE));
    m_charFormat = ui.edit_matrix->textCursor().charFormat();
  }
  CEParameterEditor::CEParameterEditor(CrystallographyExtension *ext)
    : CEAbstractEditor(ext)
  {
    ui.setupUi(this);

    // Emit editStarted
    connect(ui.spin_a, SIGNAL(valueChanged(double)),
            this, SIGNAL(editStarted()));
    connect(ui.spin_b, SIGNAL(valueChanged(double)),
            this, SIGNAL(editStarted()));
    connect(ui.spin_c, SIGNAL(valueChanged(double)),
            this, SIGNAL(editStarted()));
    connect(ui.spin_alpha, SIGNAL(valueChanged(double)),
            this, SIGNAL(editStarted()));
    connect(ui.spin_beta, SIGNAL(valueChanged(double)),
            this, SIGNAL(editStarted()));
    connect(ui.spin_gamma, SIGNAL(valueChanged(double)),
            this, SIGNAL(editStarted()));

    // Apply button connections
    connect(ui.push_params_apply, SIGNAL(clicked()),
            this, SIGNAL(editAccepted()));
    connect(ui.push_params_apply, SIGNAL(clicked()),
            this, SLOT(setParameters()));

    // Reset button connections
    connect(ui.push_params_reset, SIGNAL(clicked()),
            this, SIGNAL(editRejected()));
    connect(ui.push_params_reset, SIGNAL(clicked()),
            this, SLOT(refreshEditor()));

    // Validation
    connect(ui.spin_a, SIGNAL(valueChanged(double)),
            this, SLOT(validateEditor()));
    connect(ui.spin_b, SIGNAL(valueChanged(double)),
            this, SLOT(validateEditor()));
    connect(ui.spin_c, SIGNAL(valueChanged(double)),
            this, SLOT(validateEditor()));
    connect(ui.spin_alpha, SIGNAL(valueChanged(double)),
            this, SLOT(validateEditor()));
    connect(ui.spin_beta, SIGNAL(valueChanged(double)),
            this, SLOT(validateEditor()));
    connect(ui.spin_gamma, SIGNAL(valueChanged(double)),
            this, SLOT(validateEditor()));

    // Apply/reset enable
    connect(ui.spin_a, SIGNAL(valueChanged(double)),
            this, SLOT(enableButtons()));
    connect(ui.spin_b, SIGNAL(valueChanged(double)),
            this, SLOT(enableButtons()));
    connect(ui.spin_c, SIGNAL(valueChanged(double)),
            this, SLOT(enableButtons()));
    connect(ui.spin_alpha, SIGNAL(valueChanged(double)),
            this, SLOT(enableButtons()));
    connect(ui.spin_beta, SIGNAL(valueChanged(double)),
            this, SLOT(enableButtons()));
    connect(ui.spin_gamma, SIGNAL(valueChanged(double)),
            this, SLOT(enableButtons()));
  }
void MIPS32SyntaxHighlighter::highlightBlock(QString const &text){
    refreshEditor();
    for(int i=0; i<highlightingRules.size(); i++){
        HighlightingRule rule = highlightingRules[i];
        int start = rule.regex.indexIn(text);
        while(start >= 0){
            int len = rule.regex.matchedLength();
            setFormat(start, len, rule.format);
            start = rule.regex.indexIn(text, start + len);
        }
    }
    setCurrentBlockState(0);
}
  CEAbstractEditor::CEAbstractEditor(CrystallographyExtension *ext)
    : CEAbstractDockWidget(ext),
      m_isLocked(false)
  {
    connect(this, SIGNAL(invalidInput()),
            this, SLOT(markAsInvalid()));
    connect(this, SIGNAL(validInput()),
            this, SLOT(markAsValid()));

    connect(m_ext, SIGNAL(cellChanged()),
            this, SLOT(refreshEditor()));

    connect(this, SIGNAL(visibilityChanged()),
            m_ext, SLOT(refreshActions()));

    connect(this, SIGNAL(editStarted()),
            m_ext, SLOT(lockEditors()));
    connect(this, SIGNAL(editAccepted()),
            m_ext, SLOT(unlockEditors()));
    connect(this, SIGNAL(editRejected()),
            m_ext, SLOT(unlockEditors()));

  }