コード例 #1
0
ファイル: CodeWindow.cpp プロジェクト: micwik/ArnBrowser
CodeWindow::CodeWindow( QSettings* appSettings, const ConnectorPath& conPath, QWidget* parent)
    : QDialog( parent),
    _ui( new Ui::CodeWindow)
{
    _ui->setupUi( this);

    this->setWindowTitle( QString("CodeEdit ") + conPath.normPath());

    _appSettings = appSettings;
    readSettings();

    _font = QFont("MonoSpace", 10);
    _font.setStyleHint( QFont::TypeWriter);
    MTextEdit*  textEdit = _ui->textEdit;

#ifdef QSCINTILLA
    QsciLexer*  lexer = 0;
    if (path.endsWith(".js"))
        lexer = new QsciLexerJavaScript;
    if (path.endsWith(".html") || path.endsWith(".xhtml"))
        lexer = new QsciLexerHTML;

    if (lexer) {
        lexer->setFont( _font);
        textEdit->editor()->setLexer( lexer);
    }
    else {
        textEdit->setFont( _font);
    }

    textEdit->editor()->setTabWidth(4);
    textEdit->editor()->setMarginWidth(0, 35);
    textEdit->editor()->setMarginLineNumbers(0, true);
    textEdit->editor()->setUtf8(true);
    textEdit->editor()->setAutoIndent(true);
    textEdit->editor()->setBraceMatching( QsciScintilla::StrictBraceMatch);
    textEdit->editor()->setMatchedBraceForegroundColor( Qt::red);
#else
    QFontMetrics fm( _font);
    int  tabWidthInPixels = fm.width("    ");
    textEdit->editor()->setTabStopWidth( tabWidthInPixels);
    textEdit->editor()->setCurrentFont( _font);
#endif

    QString  path = conPath.localPath();
    _isHtml = path.endsWith(".html") || path.endsWith(".xhtml");
    _isSetPlainText = true;  // Default
    _arnItem.open( path);
    setText( _arnItem.toString());
}