forked from qt-creator/qt-creator
		
	Editor: Refactor Open Link in Next Split.
Cleanup code and added shortcuts and menu entries for - open header/source in next split - follow symbol under cursor in next split - open declaration/definition in next split Change-Id: I2c4347749d26669d88b7c2968f30f60710f442b1 Reviewed-by: Petar Perisin <petar.perisin@gmail.com> Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
		@@ -37,6 +37,7 @@ namespace Constants {
 | 
			
		||||
 | 
			
		||||
const char M_TOOLS_CPP[]              = "CppTools.Tools.Menu";
 | 
			
		||||
const char SWITCH_HEADER_SOURCE[]     = "CppTools.SwitchHeaderSource";
 | 
			
		||||
const char OPEN_HEADER_SOURCE_IN_NEXT_SPLIT[] = "CppTools.OpenHeaderSourceInNextSplit";
 | 
			
		||||
const char TASK_INDEX[]               = "CppTools.Task.Index";
 | 
			
		||||
const char TASK_SEARCH[]              = "CppTools.Task.Search";
 | 
			
		||||
const char C_SOURCE_MIMETYPE[] = "text/x-csrc";
 | 
			
		||||
 
 | 
			
		||||
@@ -138,6 +138,12 @@ bool CppToolsPlugin::initialize(const QStringList &arguments, QString *error)
 | 
			
		||||
    mcpptools->addAction(command);
 | 
			
		||||
    connect(switchAction, SIGNAL(triggered()), this, SLOT(switchHeaderSource()));
 | 
			
		||||
 | 
			
		||||
    QAction *openInNextSplitAction = new QAction(tr("Open corresponding Header/Source in Next Split"), this);
 | 
			
		||||
    command = Core::ActionManager::registerAction(openInNextSplitAction, Constants::OPEN_HEADER_SOURCE_IN_NEXT_SPLIT, context, true);
 | 
			
		||||
    command->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::Key_E, Qt::Key_F4));
 | 
			
		||||
    mcpptools->addAction(command);
 | 
			
		||||
    connect(openInNextSplitAction, SIGNAL(triggered()), this, SLOT(switchHeaderSourceInNextSplit()));
 | 
			
		||||
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -157,33 +163,18 @@ ExtensionSystem::IPlugin::ShutdownFlag CppToolsPlugin::aboutToShutdown()
 | 
			
		||||
 | 
			
		||||
void CppToolsPlugin::switchHeaderSource()
 | 
			
		||||
{
 | 
			
		||||
    Core::IEditor *editor = Core::EditorManager::currentEditor();
 | 
			
		||||
    QString otherFile = correspondingHeaderOrSource(editor->document()->fileName());
 | 
			
		||||
    if (otherFile.isEmpty())
 | 
			
		||||
        return;
 | 
			
		||||
    QString otherFile = correspondingHeaderOrSource(
 | 
			
		||||
                Core::EditorManager::currentEditor()->document()->fileName());
 | 
			
		||||
    if (!otherFile.isEmpty())
 | 
			
		||||
        Core::EditorManager::openEditor(otherFile);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    Core::EditorManager* editorManager = Core::EditorManager::instance();
 | 
			
		||||
    editorManager->addCurrentPositionToNavigationHistory();
 | 
			
		||||
    TextEditor::BaseTextEditorWidget *ed = qobject_cast<TextEditor::BaseTextEditorWidget *>(editor->widget());
 | 
			
		||||
    if (editorManager->hasSplitter()) {
 | 
			
		||||
        if (ed->forceOpenLinksInNextSplit()) {
 | 
			
		||||
            editorManager->gotoOtherSplit();
 | 
			
		||||
        } else if (ed->openLinksInNextSplit()) {
 | 
			
		||||
            bool isVisible = false;
 | 
			
		||||
            foreach (Core::IEditor *visEditor, editorManager->visibleEditors()) {
 | 
			
		||||
                if (visEditor->document() &&
 | 
			
		||||
                        (otherFile == visEditor->document()->fileName())) {
 | 
			
		||||
                    isVisible = true;
 | 
			
		||||
                    editorManager->activateEditor(visEditor);
 | 
			
		||||
                    break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (!isVisible)
 | 
			
		||||
                editorManager->gotoOtherSplit();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    Core::EditorManager::openEditor(otherFile);
 | 
			
		||||
void CppToolsPlugin::switchHeaderSourceInNextSplit()
 | 
			
		||||
{
 | 
			
		||||
    QString otherFile = correspondingHeaderOrSource(
 | 
			
		||||
                Core::EditorManager::currentEditor()->document()->fileName());
 | 
			
		||||
    if (!otherFile.isEmpty())
 | 
			
		||||
        Core::EditorManager::openEditorInNextSplit(otherFile);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static QStringList findFilesInProject(const QString &name,
 | 
			
		||||
 
 | 
			
		||||
@@ -74,6 +74,7 @@ public:
 | 
			
		||||
 | 
			
		||||
private slots:
 | 
			
		||||
    void switchHeaderSource();
 | 
			
		||||
    void switchHeaderSourceInNextSplit();
 | 
			
		||||
 | 
			
		||||
#ifdef WITH_TESTS
 | 
			
		||||
    void test_codegen_public_in_empty_class();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user