示例#1
0
void CxxView::gotoDefinition() {
    if (auto definition = getDefinitionOfFunctionUnderCursor()) {
        if (auto range = document()->getRange(definition)) {
            moveCursor(range.start());
            return;
        }
    }
    gotoDeclaration();
}
示例#2
0
KateCTagsView::KateCTagsView(Kate::MainWindow *mw, const KComponentData& componentData)
    : Kate::PluginView (mw)
        , Kate::XMLGUIClient(componentData)
        , m_toolView (mw->createToolView ("kate_private_plugin_katectagsplugin",
                      Kate::MainWindow::Bottom,
                      SmallIcon("application-x-ms-dos-executable"),
                                i18n("CTags"))
                     )
        , m_proc(0)
{
    m_mWin = mw;

    KAction *back = actionCollection()->addAction("ctags_return_step");
    back->setText(i18n("Jump back one step"));
    back->setShortcut(QKeySequence(Qt::ALT+Qt::Key_1) );
    connect(back, SIGNAL(triggered(bool)), this, SLOT(stepBack()));

    KAction *decl = actionCollection()->addAction("ctags_lookup_current_as_declaration");
    decl->setText(i18n("Go to Declaration"));
    decl->setShortcut(QKeySequence(Qt::ALT+Qt::Key_2) );
    connect(decl, SIGNAL(triggered(bool)), this, SLOT(gotoDeclaration()));

    KAction *defin = actionCollection()->addAction("ctags_lookup_current_as_definition");
    defin->setText(i18n("Go to Definition"));
    defin->setShortcut(QKeySequence(Qt::ALT+Qt::Key_3) );
    connect(defin, SIGNAL(triggered(bool)), this, SLOT(gotoDefinition()));

    KAction *lookup = actionCollection()->addAction("ctags_lookup_current");
    lookup->setText(i18n("Lookup Current Text"));
    lookup->setShortcut(QKeySequence(Qt::ALT+Qt::Key_4) );
    connect(lookup, SIGNAL(triggered(bool)), this, SLOT(lookupTag()));

    // popup menu
    m_menu = new KActionMenu(i18n("CTags"), this);
    actionCollection()->addAction("popup_ctags", m_menu);

    m_gotoDec=m_menu->menu()->addAction(i18n("Go to Declaration: %1",QString()), this, SLOT(gotoDeclaration()));
    m_gotoDef=m_menu->menu()->addAction(i18n("Go to Definition: %1",QString()), this, SLOT(gotoDefinition()));
    m_lookup=m_menu->menu()->addAction(i18n("Lookup: %1",QString()), this, SLOT(lookupTag()));

    connect(m_menu->menu(), SIGNAL(aboutToShow()), this, SLOT(aboutToShow()));

    QWidget *ctagsWidget = new QWidget(m_toolView);
    m_ctagsUi.setupUi(ctagsWidget);
    m_ctagsUi.cmdEdit->setText(DEFAULT_CTAGS_CMD);

    m_ctagsUi.addButton->setToolTip(i18n("Add a directory to index."));
    m_ctagsUi.addButton->setIcon(KIcon("list-add"));

    m_ctagsUi.delButton->setToolTip(i18n("Remove a directory."));
    m_ctagsUi.delButton->setIcon(KIcon("list-remove"));

    m_ctagsUi.updateButton->setToolTip(i18n("(Re-)generate the session specific CTags database."));
    m_ctagsUi.updateButton->setIcon(KIcon("view-refresh"));

    m_ctagsUi.updateButton2->setToolTip(i18n("(Re-)generate the session specific CTags database."));
    m_ctagsUi.updateButton2->setIcon(KIcon("view-refresh"));

    m_ctagsUi.resetCMD->setIcon(KIcon("view-refresh"));

    m_ctagsUi.tagsFile->setToolTip(i18n("Select new or existing database file."));

    connect(m_ctagsUi.resetCMD, SIGNAL(clicked()), this, SLOT(resetCMD()));
    connect(m_ctagsUi.addButton, SIGNAL(clicked()), this, SLOT(addTagTarget()));
    connect(m_ctagsUi.delButton, SIGNAL(clicked()), this, SLOT(delTagTarget()));
    connect(m_ctagsUi.updateButton,  SIGNAL(clicked()), this, SLOT(updateSessionDB()));
    connect(m_ctagsUi.updateButton2,  SIGNAL(clicked()), this, SLOT(updateSessionDB()));
    connect(&m_proc, SIGNAL(finished(int,QProcess::ExitStatus)),
            this, SLOT(updateDone(int,QProcess::ExitStatus)));

    connect(m_ctagsUi.inputEdit, SIGNAL(textChanged(QString)), this, SLOT(startEditTmr()));

    m_editTimer.setSingleShot(true);
    connect(&m_editTimer, SIGNAL(timeout()), this, SLOT(editLookUp()));

    connect(m_ctagsUi.tagTreeWidget, SIGNAL(itemActivated(QTreeWidgetItem*,int)),
            SLOT(tagHitClicked(QTreeWidgetItem*)));

    m_toolView->installEventFilter(this);

    mainWindow()->guiFactory()->addClient(this);

    m_commonDB = KStandardDirs::locateLocal("appdata", "plugins/katectags/common_db", true);
}