Merge branch '0.9.1-beta' of git@scm.dev.nokia.troll.no:creator/mainline into 0.9.1-beta

This commit is contained in:
dt
2008-12-10 17:26:21 +01:00
41 changed files with 693 additions and 373 deletions

View File

@@ -33,8 +33,6 @@
#include "CppDocument.h"
#include <utils/qtcassert.h>
#include <Control.h>
#include <TranslationUnit.h>
#include <DiagnosticClient.h>
@@ -133,12 +131,16 @@ QString Document::fileName() const
QStringList Document::includedFiles() const
{
return _includedFiles;
QStringList files;
foreach (const Include &i, _includes)
files.append(i.fileName());
files.removeDuplicates();
return files;
}
void Document::addIncludeFile(const QString &fileName)
void Document::addIncludeFile(const QString &fileName, unsigned line)
{
_includedFiles.append(fileName);
_includes.append(Include(fileName, line));
}
void Document::appendMacro(const Macro &macro)
@@ -273,7 +275,7 @@ bool Document::parse(ParseMode mode)
void Document::check()
{
QTC_ASSERT(!_globalNamespace, return);
Q_ASSERT(!_globalNamespace);
Semantic semantic(_control);

View File

@@ -65,7 +65,7 @@ public:
QString fileName() const;
QStringList includedFiles() const;
void addIncludeFile(const QString &fileName);
void addIncludeFile(const QString &fileName, unsigned line);
void appendMacro(const Macro &macro);
void addMacroUse(const Macro &macro, unsigned offset, unsigned length);
@@ -181,6 +181,22 @@ public:
{ return pos >= _begin && pos < _end; }
};
class Include {
QString _fileName;
unsigned _line;
public:
Include(const QString &fileName, unsigned line)
: _fileName(fileName), _line(line)
{ }
QString fileName() const
{ return _fileName; }
unsigned line() const
{ return _line; }
};
class MacroUse: public Block {
Macro _macro;
@@ -196,6 +212,9 @@ public:
{ return _macro; }
};
QList<Include> includes() const
{ return _includes; }
QList<Block> skippedBlocks() const
{ return _skippedBlocks; }
@@ -207,11 +226,11 @@ private:
private:
QString _fileName;
QStringList _includedFiles;
Control *_control;
TranslationUnit *_translationUnit;
Namespace *_globalNamespace;
QList<DiagnosticMessage> _diagnosticMessages;
QList<Include> _includes;
QList<Macro> _definedMacros;
QList<Block> _skippedBlocks;
QList<MacroUse> _macroUses;

View File

@@ -34,8 +34,6 @@
#include "OverviewModel.h"
#include "Overview.h"
#include <utils/qtcassert.h>
#include <Scope.h>
#include <Semantic.h>
#include <Literals.h>
@@ -83,13 +81,13 @@ QModelIndex OverviewModel::index(int row, int column, const QModelIndex &parent)
return createIndex(row, column, symbol);
} else {
Symbol *parentSymbol = static_cast<Symbol *>(parent.internalPointer());
QTC_ASSERT(parentSymbol, return QModelIndex());
Q_ASSERT(parentSymbol);
ScopedSymbol *scopedSymbol = parentSymbol->asScopedSymbol();
QTC_ASSERT(scopedSymbol, return QModelIndex());
Q_ASSERT(scopedSymbol);
Scope *scope = scopedSymbol->members();
QTC_ASSERT(scope, return QModelIndex());
Q_ASSERT(scope);
return createIndex(row, 0, scope->symbolAt(row));
}
@@ -126,12 +124,12 @@ int OverviewModel::rowCount(const QModelIndex &parent) const
if (!parent.parent().isValid() && parent.row() == 0) // account for no symbol item
return 0;
Symbol *parentSymbol = static_cast<Symbol *>(parent.internalPointer());
QTC_ASSERT(parentSymbol, return 0);
Q_ASSERT(parentSymbol);
if (ScopedSymbol *scopedSymbol = parentSymbol->asScopedSymbol()) {
if (!scopedSymbol->isFunction()) {
Scope *parentScope = scopedSymbol->members();
QTC_ASSERT(parentScope, return 0);
Q_ASSERT(parentScope);
return parentScope->symbolCount();
}

View File

@@ -45,8 +45,6 @@
#include <TypeVisitor.h>
#include <NameVisitor.h>
#include <utils/qtcassert.h>
#include <QtCore/QList>
#include <QtCore/QtDebug>
@@ -100,7 +98,7 @@ protected:
// types
virtual void visit(PointerToMemberType * /*ty*/)
{
QTC_ASSERT(false, /**/);
Q_ASSERT(false);
}
virtual void visit(PointerType *ty)
@@ -152,32 +150,32 @@ protected:
{ /* nothing to do*/ }
virtual void visit(Namespace *)
{ QTC_ASSERT(false, /**/); }
{ Q_ASSERT(false); }
virtual void visit(Class *)
{ QTC_ASSERT(false, /**/); }
{ Q_ASSERT(false); }
virtual void visit(Enum *)
{ QTC_ASSERT(false, /**/); }
{ Q_ASSERT(false); }
// names
virtual void visit(NameId *)
{ QTC_ASSERT(false, /**/); }
{ Q_ASSERT(false); }
virtual void visit(TemplateNameId *)
{ QTC_ASSERT(false, /**/); }
{ Q_ASSERT(false); }
virtual void visit(DestructorNameId *)
{ QTC_ASSERT(false, /**/); }
{ Q_ASSERT(false); }
virtual void visit(OperatorNameId *)
{ QTC_ASSERT(false, /**/); }
{ Q_ASSERT(false); }
virtual void visit(ConversionNameId *)
{ QTC_ASSERT(false, /**/); }
{ Q_ASSERT(false); }
virtual void visit(QualifiedNameId *)
{ QTC_ASSERT(false, /**/); }
{ Q_ASSERT(false); }
};
} // end of anonymous namespace

View File

@@ -63,7 +63,8 @@ public:
{ }
virtual void macroAdded(const Macro &macro) = 0;
virtual void sourceNeeded(QString &fileName, IncludeType mode) = 0; // ### FIX the signature.
virtual void sourceNeeded(QString &fileName, IncludeType mode,
unsigned line) = 0; // ### FIX the signature.
virtual void startExpandingMacro(unsigned offset,
const Macro &macro,

View File

@@ -164,7 +164,15 @@ protected:
bool process_primary()
{
if ((*_lex)->is(T_INT_LITERAL)) {
_value.set_long(tokenSpell().toLong());
int base = 10;
const QByteArray spell = tokenSpell();
if (spell.at(0) == '0') {
if (spell.size() > 1 && (spell.at(1) == 'x' || spell.at(1) == 'X'))
base = 16;
else
base = 8;
}
_value.set_long(tokenSpell().toLong(0, base));
++(*_lex);
return true;
} else if (isTokenDefined()) {
@@ -367,7 +375,7 @@ protected:
{
process_xor();
while ((*_lex)->is(T_CARET)) {
while ((*_lex)->is(T_PIPE)) {
const Token op = *(*_lex);
++(*_lex);
@@ -810,7 +818,7 @@ void pp::processInclude(bool skipCurentPath,
QString fn = QString::fromUtf8(path.constData(), path.length());
if (client)
client->sourceNeeded(fn, Client::IncludeGlobal);
client->sourceNeeded(fn, Client::IncludeGlobal, firstToken->lineno);
} else if (tk->is(T_ANGLE_STRING_LITERAL) || tk->is(T_STRING_LITERAL)) {
const QByteArray spell = tokenSpell(*tk);
const char *beginOfPath = spell.constBegin();
@@ -823,7 +831,7 @@ void pp::processInclude(bool skipCurentPath,
QString fn = QString::fromUtf8(path.constData(), path.length());
if (client)
client->sourceNeeded(fn, Client::IncludeLocal);
client->sourceNeeded(fn, Client::IncludeLocal, firstToken->lineno);
}
}
}

View File

@@ -53,8 +53,6 @@
#include "pp-environment.h"
#include "pp.h"
#include <utils/qtcassert.h>
#include <cstring>
using namespace CPlusPlus;
@@ -93,7 +91,7 @@ Macro *Environment::macroAt(unsigned index) const
Macro *Environment::bind(const Macro &__macro)
{
QTC_ASSERT(! __macro.name.isEmpty(), return 0);
Q_ASSERT(! __macro.name.isEmpty());
Macro *m = new Macro (__macro);
m->hashcode = hash_code(m->name);

View File

@@ -201,14 +201,18 @@ void BookmarksPlugin::updateActions(int state)
void BookmarksPlugin::editorOpened(Core::IEditor *editor)
{
connect(editor, SIGNAL(markContextMenuRequested(TextEditor::ITextEditor*,int,QMenu*)),
this, SLOT(requestContextMenu(TextEditor::ITextEditor*,int,QMenu*)));
if (qobject_cast<ITextEditor *>(editor)) {
connect(editor, SIGNAL(markContextMenuRequested(TextEditor::ITextEditor*,int,QMenu*)),
this, SLOT(requestContextMenu(TextEditor::ITextEditor*,int,QMenu*)));
}
}
void BookmarksPlugin::editorAboutToClose(Core::IEditor *editor)
{
disconnect(editor, SIGNAL(markContextMenuRequested(TextEditor::ITextEditor*,int,QMenu*)),
this, SLOT(requestContextMenu(TextEditor::ITextEditor*,int,QMenu*)));
if (qobject_cast<ITextEditor *>(editor)) {
disconnect(editor, SIGNAL(markContextMenuRequested(TextEditor::ITextEditor*,int,QMenu*)),
this, SLOT(requestContextMenu(TextEditor::ITextEditor*,int,QMenu*)));
}
}
void BookmarksPlugin::requestContextMenu(TextEditor::ITextEditor *editor,

View File

@@ -47,6 +47,7 @@ SettingsDialog::SettingsDialog(QWidget *parent, const QString &initialCategory,
setupUi(this);
buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
splitter->setCollapsible(1, false);
pageTree->header()->setVisible(false);
connect(pageTree, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
@@ -59,7 +60,7 @@ SettingsDialog::SettingsDialog(QWidget *parent, const QString &initialCategory,
int index = 0;
foreach (IOptionsPage *page, pages) {
QTreeWidgetItem *item = new QTreeWidgetItem();
QTreeWidgetItem *item = new QTreeWidgetItem;
item->setText(0, page->name());
item->setData(0, Qt::UserRole, index);

View File

@@ -480,13 +480,23 @@ void CPPEditor::jumpToDefinition()
Document::Ptr doc = m_modelManager->document(file()->fileName());
if (!doc)
return;
QTextCursor tc = textCursor();
unsigned lineno = tc.blockNumber() + 1;
foreach (const Document::Include &incl, doc->includes()) {
if (incl.line() == lineno) {
if (TextEditor::BaseTextEditor::openEditorAt(incl.fileName(), 0, 0))
return; // done
break;
}
}
Symbol *lastSymbol = doc->findSymbolAt(line, column);
if (!lastSymbol)
return;
// Get the expression under the cursor
const int endOfName = endOfNameUnderCursor();
QTextCursor tc = textCursor();
tc.setPosition(endOfName);
ExpressionUnderCursor expressionUnderCursor;
const QString expression = expressionUnderCursor(tc);

View File

@@ -175,13 +175,14 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
break;
}
}
}
if (m_toolTip.isEmpty()) {
foreach (const Document::MacroUse use, doc->macroUses()) {
if (use.contains(pos)) {
m_toolTip = use.macro().toString();
break;
}
if (m_toolTip.isEmpty()) {
unsigned lineno = tc.blockNumber() + 1;
foreach (const Document::Include &incl, doc->includes()) {
if (lineno == incl.line()) {
m_toolTip = incl.fileName();
break;
}
}
}
@@ -240,6 +241,16 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
}
}
if (doc && m_toolTip.isEmpty()) {
foreach (const Document::MacroUse &use, doc->macroUses()) {
if (use.contains(pos)) {
m_toolTip = use.macro().toString();
m_helpId = use.macro().name;
break;
}
}
}
if (m_helpEngineNeedsSetup
&& m_helpEngine->registeredDocumentations().count() > 0) {
m_helpEngine->setupData();
@@ -248,7 +259,8 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
if (!m_helpId.isEmpty() && !m_helpEngine->linksForIdentifier(m_helpId).isEmpty()) {
m_toolTip = QString(QLatin1String("<table><tr><td valign=middle><nobr>%1</td>"
"<td><img src=\":/cpptools/images/f1.svg\"></td></tr></table>")).arg(Qt::escape(m_toolTip));
"<td><img src=\":/cpptools/images/f1.svg\"></td></tr></table>"))
.arg(Qt::escape(m_toolTip));
editor->setContextHelpId(m_helpId);
} else if (!m_toolTip.isEmpty()) {
m_toolTip = QString(QLatin1String("<nobr>%1")).arg(Qt::escape(m_toolTip));

View File

@@ -138,7 +138,8 @@ protected:
virtual void stopExpandingMacro(unsigned offset, const Macro &macro);
virtual void startSkippingBlocks(unsigned offset);
virtual void stopSkippingBlocks(unsigned offset);
virtual void sourceNeeded(QString &fileName, IncludeType type);
virtual void sourceNeeded(QString &fileName, IncludeType type,
unsigned line);
private:
QPointer<CppModelManager> m_modelManager;
@@ -176,7 +177,7 @@ void CppPreprocessor::setProjectFiles(const QStringList &files)
{ m_projectFiles = files; }
void CppPreprocessor::run(QString &fileName)
{ sourceNeeded(fileName, IncludeGlobal); }
{ sourceNeeded(fileName, IncludeGlobal, /*line = */ 0); }
void CppPreprocessor::operator()(QString &fileName)
{ run(fileName); }
@@ -361,7 +362,8 @@ void CppPreprocessor::stopSkippingBlocks(unsigned offset)
m_currentDoc->stopSkippingBlocks(offset);
}
void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type)
void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type,
unsigned line)
{
if (fileName.isEmpty())
return;
@@ -369,7 +371,7 @@ void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type)
QByteArray contents = tryIncludeFile(fileName, type);
if (m_currentDoc) {
m_currentDoc->addIncludeFile(fileName);
m_currentDoc->addIncludeFile(fileName, line);
if (contents.isEmpty() && ! QFileInfo(fileName).isAbsolute()) {
QString msg;
msg += fileName;

View File

@@ -1033,7 +1033,6 @@ void DebuggerManager::addToWatchWindow()
void DebuggerManager::watchExpression(const QString &expression)
{
watchHandler()->watchExpression(expression);
//engine()->updateWatchModel();
}
void DebuggerManager::setBreakpoint(const QString &fileName, int lineNumber)

View File

@@ -2939,6 +2939,8 @@ bool GdbEngine::isCustomValueDumperAvailable(const QString &type) const
if (tmplate == "QSet")
return true;
}
if (tmplate == "std::list")
return true;
if (tmplate == "std::vector" && inner != "bool")
return true;
if (tmplate == "std::basic_string") {

View File

@@ -402,18 +402,30 @@ bool WatchHandler::setData(const QModelIndex &idx,
static QString niceType(QString type)
{
if (type.contains("std::")) {
static QRegExp re("std::vector<(.*)\\s*,std::allocator<(.*)>\\s*>");
re.setMinimal(true);
// std::string
type.replace("std::basic_string<char, std::char_traits<char>, "
"std::allocator<char> >", "std::string");
// std::wstring
type.replace("std::basic_string<wchar_t, std::char_traits<wchar_t>, "
"std::allocator<wchar_t> >", "std::wstring");
// std::vector
static QRegExp re1("std::vector<(.*)\\s*,std::allocator<(.*)>\\s*>");
re1.setMinimal(true);
for (int i = 0; i != 10; ++i) {
if (re.indexIn(type) == -1 || re.cap(1) != re.cap(2))
if (re1.indexIn(type) == -1 || re1.cap(1) != re1.cap(2))
break;
type.replace(re.cap(0), "std::vector<" + re.cap(1) + ">");
type.replace(re1.cap(0), "std::vector<" + re1.cap(1) + ">");
}
// std::list
static QRegExp re2("std::list<(.*)\\s*,std::allocator<(.*)>\\s*>");
re2.setMinimal(true);
for (int i = 0; i != 10; ++i) {
if (re2.indexIn(type) == -1 || re2.cap(1) != re2.cap(2))
break;
type.replace(re2.cap(0), "std::list<" + re2.cap(1) + ">");
}
type.replace(" >", ">");
@@ -865,9 +877,9 @@ void WatchHandler::watchExpression(const QString &exp)
data.name = exp;
data.iname = "watch." + exp;
insertData(data);
emit watchModelUpdateRequested();
}
void WatchHandler::setDisplayedIName(const QString &iname, bool on)
{
WatchData *d = findData(iname);

View File

@@ -56,6 +56,9 @@
</item>
<item>
<widget class="QToolButton" name="findPreviousButton">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="arrowType">
<enum>Qt::LeftArrow</enum>
</property>
@@ -66,6 +69,9 @@
<property name="font">
<font/>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="arrowType">
<enum>Qt::RightArrow</enum>
</property>
@@ -103,6 +109,9 @@
</item>
<item>
<widget class="QToolButton" name="replacePreviousButton">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="arrowType">
<enum>Qt::LeftArrow</enum>
</property>
@@ -113,6 +122,9 @@
<property name="font">
<font/>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="arrowType">
<enum>Qt::RightArrow</enum>
</property>

View File

@@ -43,6 +43,7 @@ ChangeSelectionDialog::ChangeSelectionDialog(QWidget *parent)
{
m_ui.setupUi(this);
connect(m_ui.repositoryButton, SIGNAL(clicked()), this, SLOT(selectWorkingDirectory()));
setWindowTitle(tr("Select a Git commit"));
}
void ChangeSelectionDialog::selectWorkingDirectory()
@@ -59,7 +60,7 @@ void ChangeSelectionDialog::selectWorkingDirectory()
// the head directory of the repository.
QDir repository(location);
do {
if (repository.entryList(QDir::AllDirs).contains(QLatin1String(".git"))) {
if (repository.entryList(QDir::AllDirs|QDir::Hidden).contains(QLatin1String(".git"))) {
m_ui.repositoryEdit->setText(repository.absolutePath());
return;
}

View File

@@ -197,7 +197,7 @@ void GitClient::diff(const QString &workingDirectory, const QStringList &fileNam
const QString title = tr("Git Diff");
VCSBase::VCSBaseEditor *editor = createVCSEditor(kind, title, workingDirectory, true, "originalFileName", workingDirectory);
executeGit(workingDirectory, arguments, m_plugin->outputWindow(), editor);
executeGit(workingDirectory, arguments, editor);
}
@@ -215,14 +215,14 @@ void GitClient::diff(const QString &workingDirectory, const QString &fileName)
const QString sourceFile = source(workingDirectory, fileName);
VCSBase::VCSBaseEditor *editor = createVCSEditor(kind, title, sourceFile, true, "originalFileName", sourceFile);
executeGit(workingDirectory, arguments, m_plugin->outputWindow(), editor);
executeGit(workingDirectory, arguments, editor);
}
void GitClient::status(const QString &workingDirectory)
{
QStringList statusArgs(QLatin1String("status"));
statusArgs << QLatin1String("-u");
executeGit(workingDirectory, statusArgs, m_plugin->outputWindow(), 0,true);
executeGit(workingDirectory, statusArgs, 0, true);
}
void GitClient::log(const QString &workingDirectory, const QString &fileName)
@@ -242,7 +242,7 @@ void GitClient::log(const QString &workingDirectory, const QString &fileName)
const QString kind = QLatin1String(Git::Constants::GIT_LOG_EDITOR_KIND);
const QString sourceFile = source(workingDirectory, fileName);
VCSBase::VCSBaseEditor *editor = createVCSEditor(kind, title, sourceFile, false, "logFileName", sourceFile);
executeGit(workingDirectory, arguments, m_plugin->outputWindow(), editor);
executeGit(workingDirectory, arguments, editor);
}
void GitClient::show(const QString &source, const QString &id)
@@ -258,7 +258,7 @@ void GitClient::show(const QString &source, const QString &id)
const QFileInfo sourceFi(source);
const QString workDir = sourceFi.isDir() ? sourceFi.absoluteFilePath() : sourceFi.absolutePath();
executeGit(workDir, arguments, m_plugin->outputWindow(), editor);
executeGit(workDir, arguments, editor);
}
void GitClient::blame(const QString &workingDirectory, const QString &fileName)
@@ -273,7 +273,7 @@ void GitClient::blame(const QString &workingDirectory, const QString &fileName)
const QString sourceFile = source(workingDirectory, fileName);
VCSBase::VCSBaseEditor *editor = createVCSEditor(kind, title, sourceFile, true, "blameFileName", sourceFile);
executeGit(workingDirectory, arguments, m_plugin->outputWindow(), editor);
executeGit(workingDirectory, arguments, editor);
}
void GitClient::checkout(const QString &workingDirectory, const QString &fileName)
@@ -287,7 +287,7 @@ void GitClient::checkout(const QString &workingDirectory, const QString &fileNam
arguments << QLatin1String("checkout") << QLatin1String("HEAD") << QLatin1String("--")
<< fileName;
executeGit(workingDirectory, arguments, m_plugin->outputWindow(), 0,true);
executeGit(workingDirectory, arguments, 0, true);
}
void GitClient::hardReset(const QString &workingDirectory, const QString &commit)
@@ -297,7 +297,7 @@ void GitClient::hardReset(const QString &workingDirectory, const QString &commit
if (!commit.isEmpty())
arguments << commit;
executeGit(workingDirectory, arguments, m_plugin->outputWindow(), 0,true);
executeGit(workingDirectory, arguments, 0, true);
}
void GitClient::addFile(const QString &workingDirectory, const QString &fileName)
@@ -305,7 +305,7 @@ void GitClient::addFile(const QString &workingDirectory, const QString &fileName
QStringList arguments;
arguments << QLatin1String("add") << fileName;
executeGit(workingDirectory, arguments, m_plugin->outputWindow(), 0,true);
executeGit(workingDirectory, arguments, 0, true);
}
bool GitClient::synchronousAdd(const QString &workingDirectory, const QStringList &files)
@@ -380,13 +380,14 @@ bool GitClient::synchronousCheckout(const QString &workingDirectory,
}
void GitClient::executeGit(const QString &workingDirectory, const QStringList &arguments,
GitOutputWindow *outputWindow, VCSBase::VCSBaseEditor* editor,
VCSBase::VCSBaseEditor* editor,
bool outputToWindow)
{
if (Git::Constants::debug)
qDebug() << "executeGit" << workingDirectory << arguments << editor;
m_plugin->outputWindow()->append(formatCommand(QLatin1String(kGitCommand), arguments));
GitOutputWindow *outputWindow = m_plugin->outputWindow();
outputWindow->append(formatCommand(QLatin1String(kGitCommand), arguments));
QProcess process;
ProjectExplorer::Environment environment = ProjectExplorer::Environment::systemEnvironment();
@@ -396,8 +397,13 @@ void GitClient::executeGit(const QString &workingDirectory, const QStringList &a
GitCommand* command = new GitCommand();
if (outputToWindow) {
connect(command, SIGNAL(outputText(QString)), outputWindow, SLOT(append(QString)));
connect(command, SIGNAL(outputData(QByteArray)), outputWindow, SLOT(appendData(QByteArray)));
if (!editor) { // assume that the commands output is the important thing
connect(command, SIGNAL(outputText(QString)), this, SLOT(appendAndPopup(QString)));
connect(command, SIGNAL(outputData(QByteArray)), this, SLOT(appendDataAndPopup(QByteArray)));
} else {
connect(command, SIGNAL(outputText(QString)), outputWindow, SLOT(append(QString)));
connect(command, SIGNAL(outputData(QByteArray)), outputWindow, SLOT(appendData(QByteArray)));
}
} else {
QTC_ASSERT(editor, /**/);
connect(command, SIGNAL(outputText(QString)), editor, SLOT(setPlainText(QString)));
@@ -405,11 +411,23 @@ void GitClient::executeGit(const QString &workingDirectory, const QStringList &a
}
if (outputWindow)
connect(command, SIGNAL(errorText(QString)), outputWindow, SLOT(append(QString)));
connect(command, SIGNAL(errorText(QString)), this, SLOT(appendAndPopup(QString)));
command->execute(arguments, workingDirectory, environment);
}
void GitClient::appendDataAndPopup(const QByteArray &data)
{
m_plugin->outputWindow()->appendData(data);
m_plugin->outputWindow()->popup(false);
}
void GitClient::appendAndPopup(const QString &text)
{
m_plugin->outputWindow()->append(text);
m_plugin->outputWindow()->popup(false);
}
bool GitClient::synchronousGit(const QString &workingDirectory,
const QStringList &arguments,
QByteArray* outputText,
@@ -810,12 +828,12 @@ void GitClient::revert(const QStringList &files)
void GitClient::pull(const QString &workingDirectory)
{
executeGit(workingDirectory, QStringList(QLatin1String("pull")), m_plugin->outputWindow(), 0, true);
executeGit(workingDirectory, QStringList(QLatin1String("pull")), 0, true);
}
void GitClient::push(const QString &workingDirectory)
{
executeGit(workingDirectory, QStringList(QLatin1String("push")), m_plugin->outputWindow(), 0, true);
executeGit(workingDirectory, QStringList(QLatin1String("push")), 0, true);
}
QString GitClient::msgNoChangedFiles()
@@ -829,7 +847,7 @@ void GitClient::stash(const QString &workingDirectory)
QString errorMessage;
switch (gitStatus(workingDirectory, false, 0, &errorMessage)) {
case StatusChanged:
executeGit(workingDirectory, QStringList(QLatin1String("stash")), m_plugin->outputWindow(), 0, true);
executeGit(workingDirectory, QStringList(QLatin1String("stash")), 0, true);
break;
case StatusUnchanged:
m_plugin->outputWindow()->append(msgNoChangedFiles());
@@ -846,21 +864,21 @@ void GitClient::stashPop(const QString &workingDirectory)
{
QStringList arguments(QLatin1String("stash"));
arguments << QLatin1String("pop");
executeGit(workingDirectory, arguments, m_plugin->outputWindow(), 0, true);
executeGit(workingDirectory, arguments, 0, true);
}
void GitClient::branchList(const QString &workingDirectory)
{
QStringList arguments(QLatin1String("branch"));
arguments << QLatin1String("-r");
executeGit(workingDirectory, arguments, m_plugin->outputWindow(), 0, true);
executeGit(workingDirectory, arguments, 0, true);
}
void GitClient::stashList(const QString &workingDirectory)
{
QStringList arguments(QLatin1String("stash"));
arguments << QLatin1String("list");
executeGit(workingDirectory, arguments, m_plugin->outputWindow(), 0, true);
executeGit(workingDirectory, arguments, 0, true);
}
QString GitClient::readConfig(const QString &workingDirectory, const QStringList &configVar)

View File

@@ -130,6 +130,10 @@ public:
public slots:
void show(const QString &source, const QString &id);
private slots:
void appendAndPopup(const QString &text);
void appendDataAndPopup(const QByteArray &data);
private:
VCSBase::VCSBaseEditor *createVCSEditor(const QString &kind,
QString title,
@@ -141,7 +145,6 @@ private:
void executeGit(const QString &workingDirectory,
const QStringList &arguments,
GitOutputWindow *outputWindow,
VCSBase::VCSBaseEditor* editor = 0,
bool outputToWindow = false);

View File

@@ -105,7 +105,6 @@ void GitOutputWindow::append(const QString &text)
foreach (const QString &s, lines)
m_outputListWidget->addItem(s);
m_outputListWidget->scrollToBottom();
popup();
}
void GitOutputWindow::setData(const QByteArray &data)

View File

@@ -496,7 +496,7 @@ QString GitPlugin::getWorkingDirectory()
if (workingDirectory.isEmpty()) {
m_outputWindow->clearContents();
m_outputWindow->append(tr("Could not find working directory"));
m_outputWindow->popup();
m_outputWindow->popup(false);
return QString();
}
return workingDirectory;
@@ -612,6 +612,7 @@ void GitPlugin::startCommit()
changeTmpFile->setAutoRemove(true);
if (!changeTmpFile->open()) {
m_outputWindow->append(tr("Cannot create temporary file: %1").arg(changeTmpFile->errorString()));
m_outputWindow->popup(false);
delete changeTmpFile;
return;
}

View File

@@ -6,114 +6,97 @@
<rect>
<x>0</x>
<y>0</y>
<width>436</width>
<height>186</height>
<width>389</width>
<height>183</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="environmentGroupBox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="title">
<string>Environment variables</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="pathlabel">
<property name="text">
<string>PATH:</string>
</property>
</widget>
<widget class="QGroupBox" name="environmentGroupBox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="title">
<string>Environment variables</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="pathlabel">
<property name="text">
<string>PATH:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="pathLineEdit"/>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="pathLineEdit"/>
</item>
<item>
<widget class="QPushButton" name="adoptButton">
<property name="text">
<string>From system</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="noteLabel">
<item>
<widget class="QPushButton" name="adoptButton">
<property name="text">
<string>&lt;b&gt;Note:&lt;/b&gt;</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="noteFieldlabel">
<property name="text">
<string>Git needs to find Perl in the environment as well.</string>
<string>From system</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="noteLabel">
<property name="text">
<string>&lt;b&gt;Note:&lt;/b&gt;</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="noteFieldlabel">
<property name="text">
<string>Git needs to find Perl in the environment as well.</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QFormLayout" name="logFormLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="1">
<widget class="QSpinBox" name="logCountSpinBox">
<property name="toolTip">
<string>Note that huge amount of commits might take some time.</string>
</property>
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="logFormLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
<item row="0" column="0">
<widget class="QLabel" name="logCountLabel">
<property name="text">
<string>Log commit display count:</string>
</property>
<item row="0" column="1">
<widget class="QSpinBox" name="logCountSpinBox">
<property name="toolTip">
<string>Note that huge amount of commits might take some time.</string>
</property>
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="logCountLabel">
<property name="text">
<string>Log commit display count:</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>

View File

@@ -90,6 +90,20 @@ protected:
if (event->reason() != Qt::PopupFocusReason)
QTreeView::focusOutEvent(event);
}
#ifdef Q_OS_MAC
void keyPressEvent(QKeyEvent *event)
{
if ((event->key() == Qt::Key_Return
|| event->key() == Qt::Key_Enter)
&& event->modifiers() == 0
&& currentIndex().isValid()) {
emit activated(currentIndex());
return;
}
QTreeView::keyPressEvent(event);
}
#endif
};
/*!

View File

@@ -45,6 +45,7 @@
#include <coreplugin/icore.h>
#include <QtCore/QDebug>
#include <QtGui/QApplication>
#include <QtGui/QBoxLayout>
#include <QtGui/QComboBox>
#include <QtGui/QTabWidget>
@@ -190,7 +191,14 @@ void ProjectWindow::updateTreeWidget()
// That one runs fully thorough and deletes all widgets, even that one that we are currently removing
// from m_panelsTabWidget.
// To prevent that, we simply prevent the focus switching....
m_treeWidget->setFocus();
QWidget *focusWidget = qApp->focusWidget();
while (focusWidget) {
if (focusWidget == this) {
m_treeWidget->setFocus();
break;
}
focusWidget = focusWidget->parentWidget();
}
m_treeWidget->clear();
foreach(Project *project, m_session->projects()) {

View File

@@ -628,8 +628,10 @@ bool SessionManager::loadImpl(const QString &fileName)
if (success) {
// restore the active mode
const QString &modeIdentifier = value(QLatin1String("ActiveMode")).toString();
if (!modeIdentifier.isEmpty())
if (!modeIdentifier.isEmpty()) {
m_core->modeManager()->activateMode(modeIdentifier);
m_core->modeManager()->setFocusToCurrentMode();
}
}
if (debug)

View File

@@ -38,7 +38,7 @@ namespace QuickOpen {
namespace Constants {
const char * const FILTER_OPTIONS_PAGE = "Filters";
const char * const QUICKOPEN_CATEGORY = "QuickOpen";
const char * const QUICKOPEN_CATEGORY = "Locator";
const char * const TASK_INDEX = "QuickOpen.Task.Index";
} // namespace Constants

View File

@@ -264,7 +264,7 @@ QuickOpenToolWindow::QuickOpenToolWindow(QuickOpenPlugin *qop) :
// Explcitly hide the completion list popup.
m_completionList->hide();
setWindowTitle("Quick Open");
setWindowTitle("Locate...");
resize(200, 90);
QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
sizePolicy.setHorizontalStretch(0);
@@ -281,7 +281,7 @@ QuickOpenToolWindow::QuickOpenToolWindow(QuickOpenPlugin *qop) :
QPixmap image(Core::Constants::ICON_MAGNIFIER);
m_fileLineEdit->setPixmap(image);
m_fileLineEdit->setUseLayoutDirection(true);
m_fileLineEdit->setHintText(tr("Type to QuickOpen"));
m_fileLineEdit->setHintText(tr("Type to locate"));
m_fileLineEdit->setFocusPolicy(Qt::ClickFocus);
m_fileLineEdit->installEventFilter(this);

View File

@@ -302,6 +302,18 @@ void BaseTextDocument::setSyntaxHighlighter(QSyntaxHighlighter *highlighter)
m_highlighter->setDocument(m_document);
}
void BaseTextDocument::cleanWhitespace()
{
QTextCursor cursor(m_document);
cursor.beginEditBlock();
cleanWhitespace(cursor, true);
if (m_storageSettings.m_addFinalNewLine)
ensureFinalNewLine(cursor);
cursor.endEditBlock();
}
void BaseTextDocument::cleanWhitespace(QTextCursor& cursor, bool inEntireDocument)
{

View File

@@ -118,6 +118,8 @@ public:
void reload(QTextCodec *codec);
void cleanWhitespace();
signals:
void titleChanged(QString title);
void changed();

View File

@@ -685,6 +685,10 @@ void BaseTextEditor::selectBlockDown()
}
void BaseTextEditor::cleanWhitespace()
{
d->m_document->cleanWhitespace();
}
void BaseTextEditor::keyPressEvent(QKeyEvent *e)
{
@@ -2751,7 +2755,9 @@ void BaseTextEditor::handleBackspaceKey()
void BaseTextEditor::format()
{
QTextCursor cursor = textCursor();
cursor.beginEditBlock();
indent(document(), cursor, QChar::Null);
cursor.endEditBlock();
}
void BaseTextEditor::unCommentSelection()
@@ -3319,16 +3325,13 @@ void BaseTextEditor::collapse()
TextEditDocumentLayout *documentLayout = qobject_cast<TextEditDocumentLayout*>(doc->documentLayout());
QTC_ASSERT(documentLayout, return);
QTextBlock block = textCursor().block();
qDebug() << "collapse at block" << block.blockNumber();
while (block.isValid()) {
qDebug() << "test block" << block.blockNumber();
if (TextBlockUserData::canCollapse(block) && block.next().isVisible()) {
if ((block.next().userState()) >> 8 <= (textCursor().block().userState() >> 8))
break;
}
block = block.previous();
}
qDebug() << "found" << block.blockNumber();
if (block.isValid()) {
TextBlockUserData::doCollapse(block, false);
d->moveCursorVisible();

View File

@@ -329,6 +329,8 @@ public slots:
void selectBlockUp();
void selectBlockDown();
void cleanWhitespace();
signals:
void changed();

View File

@@ -132,7 +132,7 @@ bool TabSettings::isIndentationClean(const QString &text) const
if (c == QLatin1Char(' ')) {
++spaceCount;
if (spaceCount == m_tabSize)
if (!m_spacesForTabs && spaceCount == m_tabSize)
return false;
} else if (c == QLatin1Char('\t')) {
if (m_spacesForTabs || spaceCount != m_indentSize)

View File

@@ -63,7 +63,7 @@ TextEditorActionHandler::TextEditorActionHandler(Core::ICore *core,
{
m_undoAction = m_redoAction = m_copyAction = m_cutAction = m_pasteAction
= m_selectAllAction = m_gotoAction = m_printAction = m_formatAction
= m_visualizeWhitespaceAction = m_textWrappingAction
= m_visualizeWhitespaceAction = m_cleanWhitespaceAction = m_textWrappingAction
= m_unCommentSelectionAction = m_unCollapseAllAction
= m_collapseAction = m_expandAction
= m_deleteLineAction = m_selectEncodingAction
@@ -128,17 +128,23 @@ void TextEditorActionHandler::createActions()
connect(m_formatAction, SIGNAL(triggered(bool)), this, SLOT(formatAction()));
m_visualizeWhitespaceAction = new QAction(tr("Visualize &Whitespace"), this);
m_visualizeWhitespaceAction = new QAction(tr("&Visualize Whitespace"), this);
m_visualizeWhitespaceAction->setCheckable(true);
command = am->registerAction(m_visualizeWhitespaceAction,
TextEditor::Constants::VISUALIZE_WHITESPACE, m_contextId);
#ifndef Q_OS_MAC
command->setDefaultKeySequence(QKeySequence(tr("Ctrl+E, Ctrl+V")));
#endif
advancedMenu->addAction(command);
connect(m_visualizeWhitespaceAction, SIGNAL(triggered(bool)), this, SLOT(setVisualizeWhitespace(bool)));
m_cleanWhitespaceAction = new QAction(tr("Clean Whitespace"), this);
command = am->registerAction(m_cleanWhitespaceAction,
TextEditor::Constants::CLEAN_WHITESPACE, m_contextId);
advancedMenu->addAction(command);
connect(m_cleanWhitespaceAction, SIGNAL(triggered()), this, SLOT(cleanWhitespace()));
m_textWrappingAction = new QAction(tr("Enable Text &Wrapping"), this);
m_textWrappingAction->setCheckable(true);
command = am->registerAction(m_textWrappingAction,
@@ -285,6 +291,7 @@ void TextEditorActionHandler::updateActions(UpdateMode um)
m_visualizeWhitespaceAction->setEnabled(um != NoEditor);
if (m_currentEditor)
m_visualizeWhitespaceAction->setChecked(m_currentEditor->displaySettings().m_visualizeWhitespace);
m_cleanWhitespaceAction->setEnabled(um != NoEditor);
if (m_textWrappingAction) {
m_textWrappingAction->setEnabled(um != NoEditor);
if (m_currentEditor)
@@ -317,42 +324,6 @@ void TextEditorActionHandler::updateCopyAction()
m_copyAction->setEnabled(hasCopyableText);
}
void TextEditorActionHandler::undoAction()
{
if (m_currentEditor)
m_currentEditor->undo();
}
void TextEditorActionHandler::redoAction()
{
if (m_currentEditor)
m_currentEditor->redo();
}
void TextEditorActionHandler::copyAction()
{
if (m_currentEditor)
m_currentEditor->copy();
}
void TextEditorActionHandler::cutAction()
{
if (m_currentEditor)
m_currentEditor->cut();
}
void TextEditorActionHandler::pasteAction()
{
if (m_currentEditor)
m_currentEditor->paste();
}
void TextEditorActionHandler::selectAllAction()
{
if (m_currentEditor)
m_currentEditor->selectAll();
}
void TextEditorActionHandler::gotoAction()
{
QuickOpen::QuickOpenManager *quickopen = QuickOpen::QuickOpenManager::instance();
@@ -367,13 +338,6 @@ void TextEditorActionHandler::printAction()
m_currentEditor->print(m_core->printer());
}
void TextEditorActionHandler::formatAction()
{
if (m_currentEditor)
m_currentEditor->format();
}
void TextEditorActionHandler::setVisualizeWhitespace(bool checked)
{
if (m_currentEditor) {
@@ -403,6 +367,15 @@ void TextEditorActionHandler::setTextWrapping(bool checked)
m_currentEditor->funcname2 ();\
}
FUNCTION2(undoAction, undo)
FUNCTION2(redoAction, redo)
FUNCTION2(copyAction, copy)
FUNCTION2(cutAction, cut)
FUNCTION2(pasteAction, paste)
FUNCTION2(formatAction, format)
FUNCTION2(selectAllAction, selectAll)
FUNCTION(cleanWhitespace)
FUNCTION(unCommentSelection)
FUNCTION(deleteLine)
FUNCTION(unCollapseAll)

View File

@@ -100,6 +100,7 @@ private slots:
void printAction();
void formatAction();
void setVisualizeWhitespace(bool);
void cleanWhitespace();
void setTextWrapping(bool);
void unCommentSelection();
void unCollapseAll();
@@ -128,6 +129,7 @@ private:
QAction *m_printAction;
QAction *m_formatAction;
QAction *m_visualizeWhitespaceAction;
QAction *m_cleanWhitespaceAction;
QAction *m_textWrappingAction;
QAction *m_unCommentSelectionAction;
QAction *m_unCollapseAllAction;

View File

@@ -40,6 +40,7 @@ namespace Constants {
const char * const C_TEXTEDITOR = "Text Editor";
const char * const COMPLETE_THIS = "TextEditor.CompleteThis";
const char * const VISUALIZE_WHITESPACE = "TextEditor.VisualizeWhitespace";
const char * const CLEAN_WHITESPACE = "TextEditor.CleanWhitespace";
const char * const TEXT_WRAPPING = "TextEditor.TextWrapping";
const char * const UN_COMMENT_SELECTION = "TextEditor.UnCommentSelection";
const char * const COLLAPSE = "TextEditor.Collapse";