bool BazaarPlugin::submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submitEditor) { Core::IDocument *editorDocument = submitEditor->document(); const CommitEditor *commitEditor = qobject_cast<const CommitEditor *>(submitEditor); if (!editorDocument || !commitEditor) return true; bool dummyPrompt = m_bazaarSettings.boolValue(BazaarSettings::promptOnSubmitKey); const VcsBase::VcsBaseSubmitEditor::PromptSubmitResult response = commitEditor->promptSubmit(tr("Close Commit Editor"), tr("Do you want to commit the changes?"), tr("Message check failed. Do you want to proceed?"), &dummyPrompt, !m_submitActionTriggered); m_submitActionTriggered = false; switch (response) { case VcsBase::VcsBaseSubmitEditor::SubmitCanceled: return false; case VcsBase::VcsBaseSubmitEditor::SubmitDiscarded: return true; default: break; } QStringList files = commitEditor->checkedFiles(); if (!files.empty()) { //save the commit message if (!Core::DocumentManager::saveDocument(editorDocument)) return false; //rewrite entries of the form 'file => newfile' to 'newfile' because //this would mess the commit command for (QStringList::iterator iFile = files.begin(); iFile != files.end(); ++iFile) { const QStringList parts = iFile->split(QLatin1String(" => "), QString::SkipEmptyParts); if (!parts.isEmpty()) *iFile = parts.last(); } const BazaarCommitWidget *commitWidget = commitEditor->commitWidget(); QStringList extraOptions; // Author if (!commitWidget->committer().isEmpty()) extraOptions.append(QLatin1String("--author=") + commitWidget->committer()); // Fixed bugs foreach (const QString &fix, commitWidget->fixedBugs()) { if (!fix.isEmpty()) extraOptions << QLatin1String("--fixes") << fix; } // Whether local commit or not if (commitWidget->isLocalOptionEnabled()) extraOptions += QLatin1String("--local"); m_client->commit(m_submitRepository, files, editorDocument->fileName(), extraOptions); } return true; }
void Manager::gotoLocations(const QList<QVariant> &list) { QSet<SymbolLocation> locations = Utils::roleToLocations(list); if (locations.count() == 0) return; QString fileName; int line = 0; int column = 0; bool currentPositionAvailable = false; // what is open now? Core::IEditor *editor = Core::EditorManager::instance()->currentEditor(); if (editor) { // get current file name Core::IDocument *document = editor->document(); if (document) fileName = document->fileName(); // if text file - what is current position? TextEditor::ITextEditor *textEditor = qobject_cast<TextEditor::ITextEditor *>(editor); if (textEditor) { // there is open currently text editor int position = textEditor->position(); textEditor->convertPosition(position, &line, &column); currentPositionAvailable = true; } } // if there is something open - try to check, is it currently activated symbol? if (currentPositionAvailable) { SymbolLocation current(fileName, line, column); QSet<SymbolLocation>::const_iterator it = locations.find(current); QSet<SymbolLocation>::const_iterator end = locations.constEnd(); // is it known location? if (it != end) { // found - do one additional step ++it; if (it == end) it = locations.begin(); const SymbolLocation &found = *it; gotoLocation(found.fileName(), found.line(), found.column()); return; } } // no success - open first item in the list const SymbolLocation loc = *locations.constBegin(); gotoLocation(loc.fileName(), loc.line(), loc.column()); }