示例#1
0
int manager::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: { QString _r = autoCalc((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 1: { QString _r = calc((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 2: loadLayouts(); break;
        case 3: restoreLayouts(); break;
        case 4: { QString _r = getFunctions((*reinterpret_cast< QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 5: setABC(); break;
        case 6: setNumbers(); break;
        case 7: setAngleModeRadian(); break;
        case 8: setAngleModeDegree(); break;
        case 9: { QString _r = getAngleMode();
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 10: setClipboard((*reinterpret_cast< QString(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 11;
    }
    return _id;
}
示例#2
0
文件: editor.cpp 项目: KDE/abakus
Editor::Editor( QWidget* parent, const char* name ):
    QTextEdit( parent, name )
{
    d = new Private;
    d->eval = 0;
    d->index = 0;
    d->autoCompleteEnabled = true;
    d->completion = new EditorCompletion( this );
    d->completionTimer = new QTimer( this );
    d->autoCalcEnabled = true;
    d->syntaxHighlightEnabled = true;
    d->highlighter = new EditorHighlighter( this );
    d->autoCalcTimer = new QTimer( this );
    d->matchingTimer = new QTimer( this );

    setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
    setWordWrap( NoWrap );
    setHScrollBarMode( AlwaysOff );
    setVScrollBarMode( AlwaysOff );
    setTextFormat( PlainText );
    setAutoFormatting( AutoNone );
    setTabChangesFocus( true );
    setLinkUnderline( false );

    connect( d->completion, SIGNAL( selectedCompletion( const QString& ) ),
        SLOT( autoComplete( const QString& ) ) );
    connect( this, SIGNAL( textChanged() ), SLOT( checkAutoComplete() ) );
    connect( d->completionTimer, SIGNAL( timeout() ), SLOT( triggerAutoComplete() ) );

    connect( this, SIGNAL( textChanged() ), SLOT( checkMatching() ) );
    connect( d->matchingTimer, SIGNAL( timeout() ), SLOT( doMatchingLeft() ) );
    connect( d->matchingTimer, SIGNAL( timeout() ), SLOT( doMatchingRight() ) );
    connect( this, SIGNAL( textChanged() ), SLOT( checkAutoCalc() ) );
    connect( d->autoCalcTimer, SIGNAL( timeout() ), SLOT( autoCalc() ) );
    d->autoCalcLabel = new CalcResultLabel( 0, "autocalc", WStyle_StaysOnTop |
        WStyle_Customize | WStyle_NoBorder | WStyle_Tool |  WX11BypassWM );
    d->autoCalcLabel->setFrameStyle( QFrame::Plain | QFrame::Box );
    d->autoCalcLabel->setPalette( QToolTip::palette() );
    d->autoCalcLabel->hide();

    setHighlightColor( Number, QColor(0,0,127) );
    setHighlightColor( FunctionName, QColor(85,0,0) );
    setHighlightColor( Variable, QColor(0,85,0) );
    setHighlightColor( MatchedPar, QColor(255,255,183) );
}
示例#3
0
Editor::Editor(QWidget* parent)
    : QPlainTextEdit(parent)
{
    m_evaluator = Evaluator::instance();
    m_currentHistoryIndex = 0;
    m_isAutoCompletionEnabled = true;
    m_completion = new EditorCompletion(this);
    m_constantCompletion = 0;
    m_completionTimer = new QTimer(this);
    m_isAutoCalcEnabled = true;
    m_highlighter = new SyntaxHighlighter(this);
    m_autoCalcTimer = new QTimer(this);
    m_autoCalcSelTimer = new QTimer(this);
    m_matchingTimer = new QTimer(this);
    m_isAnsAvailable = false;
    m_shouldPaintCustomCursor = true;

    setViewportMargins(0, 0, 0, 0);
    setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
    setTabChangesFocus(true);
    setWordWrapMode(QTextOption::NoWrap);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setCursorWidth(0);

    connect(m_autoCalcTimer, SIGNAL(timeout()), SLOT(autoCalc()));
    connect(m_autoCalcSelTimer, SIGNAL(timeout()), SLOT(autoCalcSelection()));
    connect(m_completion, SIGNAL(selectedCompletion(const QString&)), SLOT(autoComplete(const QString&)));
    connect(m_completionTimer, SIGNAL(timeout()), SLOT(triggerAutoComplete()));
    connect(m_matchingTimer, SIGNAL(timeout()), SLOT(doMatchingPar()));
    connect(this, SIGNAL(selectionChanged()), SLOT(startSelAutoCalcTimer()));
    connect(this, SIGNAL(textChanged()), SLOT(checkAutoCalc()));
    connect(this, SIGNAL(textChanged()), SLOT(checkAutoComplete()));
    connect(this, SIGNAL(textChanged()), SLOT(checkMatching()));

    adjustSize();
    setFixedHeight(sizeHint().height());
}
示例#4
0
/******************************************************************************
  * version:    1.0
  * author:     link
  * date:       2016.02.26
  * brief:      电阻设置界面
******************************************************************************/
widget_Res::widget_Res(QWidget *parent) :
    QWidget(parent)
{
    int i;
    QStringList str;
    str.append(tr("选中"));
    str.append(tr("端一"));
    str.append(tr("端二"));
    str.append(tr("电阻下限 Ω"));
    str.append(tr("电阻上限 Ω"));
    str.append(tr("标准电阻 Ω"));
    str.append(tr("线圈材料"));

    tableWidget = new QTableWidget(this);
    tableWidget->setColumnCount(str.size());
    tableWidget->setHorizontalHeaderLabels(str);
    tableWidget->horizontalHeader()->setHighlightSections(false);
    tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
    tableWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
    tableWidget->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
    tableWidget->verticalHeader()->setDefaultSectionSize(53);
    tableWidget->setFrameStyle(QFrame::NoFrame);
    tableWidget->setRowCount(RES_ROW);

    for (i=0; i<RES_ROW; i++)
        insertRow();

    connect(tableWidget,SIGNAL(cellClicked(int,int)),this,SLOT(updateCell(int,int)));

    QGridLayout *other = new QGridLayout;
    str.clear();
    str.append(tr("标准温度°C"));
    str.append(tr("补偿温度°C"));
    str.append(tr("测试时间 s"));
    str.append(tr("阻值下限 %"));
    str.append(tr("阻值上限 %"));

    int dec[RES_OTHER] = {0,0,1,0,0};
    int min[RES_OTHER] = {0,0,0,0,0};
    int max[RES_OTHER] = {99,99,99,99,99};

    for (i=0; i<RES_OTHER; i++){
        otherSpin.append(new QDoubleSpinBox(this));
        otherSpin[i]->setMaximum(max[i]);
        otherSpin[i]->setMinimum(min[i]);
        otherSpin[i]->setDecimals(dec[i]);
        otherSpin[i]->setAlignment(Qt::AlignCenter);
        otherSpin[i]->setFocusPolicy(Qt::ClickFocus);
        otherSpin[i]->setButtonSymbols(QAbstractSpinBox::NoButtons);

        other->addWidget(new QLabel(str[i],this),i/3,2*(i%3));
        other->addWidget(otherSpin[i],i/3,2*(i%3)+1);
    }

    button = new QPushButton(this);
    button->setText(tr("自动计算"));
    other->addWidget(button,1,4);
    connect(button,SIGNAL(clicked()),this,SLOT(autoCalc()));

    QVBoxLayout *layout = new QVBoxLayout;

    layout->addWidget(tableWidget);
    layout->addLayout(other);

    this->setLayout(layout);
}