~bzoltan/kubuntu-packaging/decouple_cmake_plugin

« back to all changes in this revision

Viewing changes to src/plugins/cppeditor/cppeditor.cpp

  • Committer: Timo Jyrinki
  • Date: 2013-12-02 09:16:15 UTC
  • mfrom: (1.1.29)
  • Revision ID: timo.jyrinki@canonical.com-20131202091615-xbj1os1f604ber1m
New upstream release candidate.

Show diffs side-by-side

added added

removed removed

Lines of Context:
430
430
 
431
431
    const QString commentMarker = text.mid(offset, 3);
432
432
    newLine.append(commentMarker);
 
433
    newLine.append(QLatin1Char(' '));
433
434
 
434
435
    cursor.insertText(newLine);
435
436
    e->accept();
481
482
            c.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, offset);
482
483
            newLine.append(c.selectedText());
483
484
            if (text.at(offset) == QLatin1Char('/')) {
484
 
                newLine.append(QLatin1String(" *"));
 
485
                newLine.append(QLatin1String(" * "));
485
486
            } else {
486
487
                int start = offset;
487
488
                while (offset < blockPos && text.at(offset) == QLatin1Char('*'))
488
489
                    ++offset;
489
490
                newLine.append(QString(offset - start, QLatin1Char('*')));
 
491
                newLine.append(QLatin1Char(' '));
490
492
            }
491
493
            cursor.insertText(newLine);
492
494
            e->accept();
518
520
    , m_objcEnabled(false)
519
521
    , m_commentsSettings(CppTools::CppToolsSettings::instance()->commentsSettings())
520
522
    , m_followSymbolUnderCursor(new FollowSymbolUnderCursor(this))
 
523
    , m_preprocessorButton(0)
521
524
{
522
525
    qRegisterMetaType<SemanticInfo>("CppTools::SemanticInfo");
523
526
 
647
650
    connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(updateUses()));
648
651
    connect(this, SIGNAL(textChanged()), this, SLOT(updateUses()));
649
652
 
650
 
    QToolButton *hashButton = new QToolButton(this);
651
 
    hashButton->setText(QLatin1String("#"));
652
 
    connect(hashButton, SIGNAL(clicked()), this, SLOT(showPreProcessorWidget()));
653
 
    editor->insertExtraToolBarWidget(TextEditor::BaseTextEditor::Left, hashButton);
 
653
    m_preprocessorButton = new QToolButton(this);
 
654
    m_preprocessorButton->setText(QLatin1String("#"));
 
655
    Core::Command *cmd = Core::ActionManager::command(Constants::OPEN_PREPROCESSOR_DIALOG);
 
656
    connect(cmd, SIGNAL(keySequenceChanged()), this, SLOT(updatePreprocessorButtonTooltip()));
 
657
    updatePreprocessorButtonTooltip();
 
658
    connect(m_preprocessorButton, SIGNAL(clicked()), this, SLOT(showPreProcessorWidget()));
 
659
    editor->insertExtraToolBarWidget(TextEditor::BaseTextEditor::Left, m_preprocessorButton);
654
660
    editor->insertExtraToolBarWidget(TextEditor::BaseTextEditor::Left, m_outlineCombo);
655
661
}
656
662
 
705
711
    const QString &projectFile = ProjectExplorer::SessionManager::value(
706
712
                QLatin1String(Constants::CPP_PREPROCESSOR_PROJECT_PREFIX) + filePath).toString();
707
713
    const QByteArray &additionalDirectives = ProjectExplorer::SessionManager::value(
708
 
                projectFile + QLatin1Char(',') + filePath).toByteArray();
 
714
                projectFile + QLatin1Char(',') + filePath).toString().toUtf8();
709
715
 
710
716
    QSharedPointer<SnapshotUpdater> updater
711
717
            = m_modelManager->cppEditorSupport(editor())->snapshotUpdater();
1012
1018
        updateUses();
1013
1019
}
1014
1020
 
 
1021
void CPPEditorWidget::updatePreprocessorButtonTooltip()
 
1022
{
 
1023
    QTC_ASSERT(m_preprocessorButton, return);
 
1024
    Core::Command *cmd = Core::ActionManager::command(Constants::OPEN_PREPROCESSOR_DIALOG);
 
1025
    QTC_ASSERT(cmd, return);
 
1026
    m_preprocessorButton->setToolTip(cmd->action()->toolTip());
 
1027
}
 
1028
 
1015
1029
void CPPEditorWidget::jumpToOutlineElement(int index)
1016
1030
{
1017
1031
    QModelIndex modelIndex = m_outlineCombo->view()->currentIndex();
1976
1990
    if (preProcessorDialog.exec() == QDialog::Accepted) {
1977
1991
        QSharedPointer<SnapshotUpdater> updater
1978
1992
                = m_modelManager->cppEditorSupport(editor())->snapshotUpdater();
1979
 
        updater->setEditorDefines(preProcessorDialog.additionalPreProcessorDirectives().toLatin1());
 
1993
        updater->setEditorDefines(preProcessorDialog.additionalPreProcessorDirectives().toUtf8());
1980
1994
        updater->update(m_modelManager->workingCopy());
1981
1995
    }
1982
1996
}