Commit cc1e8464 authored by Eike Ziller's avatar Eike Ziller
Browse files

Qmake/AddLibrary: Remove unneeded indirection over widget



Change-Id: Ifc949a520054228d882ae1ff8ddbb7de87977abc
Reviewed-by: default avatarJarek Kobus <jaroslaw.kobus@digia.com>
parent 02796611
......@@ -140,10 +140,10 @@ void QmakeManager::setContextFile(ProjectExplorer::FileNode *file)
void QmakeManager::addLibrary()
{
ProFileEditorWidget *editor =
qobject_cast<ProFileEditorWidget*>(Core::EditorManager::currentEditor()->widget());
ProFileEditor *editor =
qobject_cast<ProFileEditor*>(Core::EditorManager::currentEditor());
if (editor)
addLibrary(editor->baseTextDocument()->filePath(), editor);
addLibrary(editor->document()->filePath(), editor);
}
void QmakeManager::addLibraryContextMenu()
......@@ -153,34 +153,29 @@ void QmakeManager::addLibraryContextMenu()
addLibrary(node->path());
}
void QmakeManager::addLibrary(const QString &fileName, ProFileEditorWidget *editor)
void QmakeManager::addLibrary(const QString &fileName, ProFileEditor *editor)
{
AddLibraryWizard wizard(fileName, Core::EditorManager::instance());
if (wizard.exec() != QDialog::Accepted)
return;
TextEditor::BaseTextEditor *editable = 0;
if (editor) {
editable = editor->editor();
} else {
editable = qobject_cast<TextEditor::BaseTextEditor *>
(Core::EditorManager::openEditor(fileName, QmakeProjectManager::Constants::PROFILE_EDITOR_ID,
Core::EditorManager::DoNotMakeVisible));
}
if (!editable)
if (!editor)
editor = qobject_cast<ProFileEditor *> (Core::EditorManager::openEditor(fileName,
QmakeProjectManager::Constants::PROFILE_EDITOR_ID, Core::EditorManager::DoNotMakeVisible));
if (!editor)
return;
const int endOfDoc = editable->position(TextEditor::ITextEditor::EndOfDoc);
editable->setCursorPosition(endOfDoc);
const int endOfDoc = editor->position(TextEditor::ITextEditor::EndOfDoc);
editor->setCursorPosition(endOfDoc);
QString snippet = wizard.snippet();
// add extra \n in case the last line is not empty
int line, column;
editable->convertPosition(endOfDoc, &line, &column);
if (!editable->textDocument()->textAt(endOfDoc - column, column).simplified().isEmpty())
editor->convertPosition(endOfDoc, &line, &column);
if (!editor->textDocument()->textAt(endOfDoc - column, column).simplified().isEmpty())
snippet = QLatin1Char('\n') + snippet;
editable->insert(snippet);
editor->insert(snippet);
}
......
......@@ -47,7 +47,7 @@ class ToolChain;
namespace QmakeProjectManager {
namespace Internal {
class ProFileEditorWidget;
class ProFileEditor;
class QmakeProjectManagerPlugin;
} // namespace Internal
......@@ -99,7 +99,7 @@ private:
ProjectExplorer::Project *contextProject,
ProjectExplorer::Node *contextNode,
ProjectExplorer::FileNode *contextFile);
void addLibrary(const QString &fileName, Internal::ProFileEditorWidget *editor = 0);
void addLibrary(const QString &fileName, Internal::ProFileEditor *editor = 0);
void runQMake(ProjectExplorer::Project *p, ProjectExplorer::Node *node);
Internal::QmakeProjectManagerPlugin *m_plugin;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment