forked from qt-creator/qt-creator
Merge branch '0.9.1-beta' of git@scm.dev.nokia.troll.no:creator/mainline into 0.9.1-beta
Conflicts: src/plugins/debugger/gdbtypemacros.ui
This commit is contained in:
@@ -186,6 +186,15 @@ MainWindow::MainWindow() :
|
||||
QCoreApplication::setOrganizationName(QLatin1String("Nokia"));
|
||||
QSettings::setDefaultFormat(QSettings::IniFormat);
|
||||
QString baseName = qApp->style()->objectName();
|
||||
if (baseName == "windows") {
|
||||
// Sometimes we get the standard windows 95 style as a fallback
|
||||
// e.g. if we are running on a KDE4 desktop
|
||||
QByteArray desktopEnvironment = qgetenv("DESKTOP_SESSION");
|
||||
if (desktopEnvironment == "kde")
|
||||
baseName = "plastique";
|
||||
else
|
||||
baseName = "cleanlooks";
|
||||
}
|
||||
qApp->setStyle(new ManhattanStyle(baseName));
|
||||
statusBar()->setProperty("p_styled", true);
|
||||
}
|
||||
|
||||
@@ -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 (openCppEditorAt(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);
|
||||
@@ -515,7 +525,7 @@ void CPPEditor::jumpToDefinition()
|
||||
QList<Symbol *> candidates = context.resolve(namedType->name());
|
||||
if (!candidates.isEmpty()) {
|
||||
Symbol *s = candidates.takeFirst();
|
||||
openEditorAt(s->fileName(), s->line(), s->column());
|
||||
openCppEditorAt(s->fileName(), s->line(), s->column());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -524,7 +534,7 @@ void CPPEditor::jumpToDefinition()
|
||||
if (use.contains(endOfName - 1)) {
|
||||
const Macro ¯o = use.macro();
|
||||
const QString fileName = QString::fromUtf8(macro.fileName);
|
||||
if (TextEditor::BaseTextEditor::openEditorAt(fileName, macro.line, 0))
|
||||
if (openCppEditorAt(fileName, macro.line, 0))
|
||||
return; // done
|
||||
}
|
||||
}
|
||||
@@ -826,8 +836,15 @@ int CPPEditor::endOfNameUnderCursor()
|
||||
return pos;
|
||||
}
|
||||
|
||||
TextEditor::ITextEditor *CPPEditor::openCppEditorAt(const QString &fileName,
|
||||
int line, int column)
|
||||
{
|
||||
return TextEditor::BaseTextEditor::openEditorAt(fileName, line, column,
|
||||
Constants::C_CPPEDITOR);
|
||||
}
|
||||
|
||||
bool CPPEditor::openEditorAt(Symbol *s)
|
||||
{
|
||||
const QString fileName = QString::fromUtf8(s->fileName(), s->fileNameLength());
|
||||
return TextEditor::BaseTextEditor::openEditorAt(fileName, s->line(), s->column());
|
||||
return openCppEditorAt(fileName, s->line(), s->column());
|
||||
}
|
||||
|
||||
@@ -123,6 +123,9 @@ private:
|
||||
CPlusPlus::Symbol *findDefinition(CPlusPlus::Symbol *symbol);
|
||||
virtual void indentBlock(QTextDocument *doc, QTextBlock block, QChar typedChar);
|
||||
|
||||
TextEditor::ITextEditor *openCppEditorAt(const QString &fileName, int line,
|
||||
int column = 0);
|
||||
|
||||
int previousBlockState(QTextBlock block) const;
|
||||
QTextCursor moveToPreviousToken(QTextCursor::MoveMode mode) const;
|
||||
QTextCursor moveToNextToken(QTextCursor::MoveMode mode) const;
|
||||
|
||||
@@ -439,7 +439,8 @@ int CppCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
|
||||
|
||||
typeOfExpression.setDocuments(m_manager->documents());
|
||||
|
||||
QList<TypeOfExpression::Result> resolvedTypes = typeOfExpression(expression, thisDocument, symbol);
|
||||
QList<TypeOfExpression::Result> resolvedTypes = typeOfExpression(expression, thisDocument, symbol,
|
||||
TypeOfExpression::Preprocess);
|
||||
LookupContext context = typeOfExpression.lookupContext();
|
||||
|
||||
if (!typeOfExpression.expressionAST() && (! m_completionOperator ||
|
||||
|
||||
@@ -177,6 +177,16 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_toolTip.isEmpty()) {
|
||||
// Move to the end of a qualified name
|
||||
bool stop = false;
|
||||
|
||||
@@ -138,7 +138,8 @@ protected:
|
||||
virtual void stopExpandingMacro(unsigned offset, const Macro ¯o);
|
||||
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;
|
||||
|
||||
@@ -88,7 +88,6 @@ public:
|
||||
void finished(bool accepted);
|
||||
|
||||
private slots:
|
||||
void onScriptButton();
|
||||
void onAddButton();
|
||||
void onDelButton();
|
||||
void currentItemChanged(QTreeWidgetItem *item);
|
||||
|
||||
@@ -109,6 +109,8 @@ QWidget *TypeMacroPage::createPage(QWidget *parent)
|
||||
|
||||
m_widget = new QWidget(parent);
|
||||
m_ui.setupUi(m_widget);
|
||||
m_ui.scriptFile->setPromptDialogTitle(tr("Select Gdb Script"));
|
||||
m_ui.scriptFile->setExpectedKind(Core::Utils::PathChooser::File);
|
||||
|
||||
connect(m_ui.addButton, SIGNAL(clicked()),
|
||||
this, SLOT(onAddButton()));
|
||||
@@ -116,8 +118,8 @@ QWidget *TypeMacroPage::createPage(QWidget *parent)
|
||||
connect(m_ui.delButton, SIGNAL(clicked()),
|
||||
this, SLOT(onDelButton()));
|
||||
|
||||
connect(m_ui.scriptButton, SIGNAL(clicked()),
|
||||
this, SLOT(onScriptButton()));
|
||||
connect(m_ui.scriptFile, SIGNAL(validChanged()),
|
||||
this, SLOT(updateButtonState()));
|
||||
|
||||
connect(m_ui.treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
|
||||
this, SLOT(currentItemChanged(QTreeWidgetItem *)));
|
||||
@@ -139,7 +141,7 @@ QWidget *TypeMacroPage::createPage(QWidget *parent)
|
||||
++i;
|
||||
}
|
||||
|
||||
m_ui.scriptEdit->setText(m_settings->m_scriptFile);
|
||||
m_ui.scriptFile->setPath(m_settings->m_scriptFile);
|
||||
|
||||
updateButtonState();
|
||||
|
||||
@@ -152,7 +154,7 @@ void TypeMacroPage::finished(bool accepted)
|
||||
return;
|
||||
|
||||
m_settings->m_typeMacros.clear();
|
||||
m_settings->m_scriptFile = m_ui.scriptEdit->text();
|
||||
m_settings->m_scriptFile = m_ui.scriptFile->path();
|
||||
|
||||
for (int i = 0; i < m_ui.treeWidget->topLevelItemCount(); ++i) {
|
||||
QTreeWidgetItem *item = m_ui.treeWidget->topLevelItem(i);
|
||||
@@ -172,13 +174,6 @@ void TypeMacroPage::finished(bool accepted)
|
||||
}
|
||||
}
|
||||
|
||||
void TypeMacroPage::onScriptButton()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(m_widget, tr("Select Gdb Script"));
|
||||
m_ui.scriptEdit->setText(fileName);
|
||||
updateButtonState();
|
||||
}
|
||||
|
||||
void TypeMacroPage::onAddButton()
|
||||
{
|
||||
if (m_ui.typeEdit->text().isEmpty() || m_ui.macroEdit->text().isEmpty())
|
||||
|
||||
@@ -626,7 +626,7 @@ QList<FolderNode*> DetailedModel::recursiveSubFolders(FolderNode *parentFolder)
|
||||
|
||||
FlatModel::FlatModel(SessionNode *rootNode, QObject *parent)
|
||||
: QAbstractItemModel(parent),
|
||||
m_filterProjects(true),
|
||||
m_filterProjects(false),
|
||||
m_filterGeneratedFiles(true),
|
||||
m_rootNode(rootNode),
|
||||
m_startupProject(0),
|
||||
@@ -914,6 +914,8 @@ QModelIndex FlatModel::indexForNode(const Node *node_)
|
||||
|
||||
void FlatModel::setProjectFilterEnabled(bool filter)
|
||||
{
|
||||
if (filter == m_filterProjects)
|
||||
return;
|
||||
m_filterProjects = filter;
|
||||
reset();
|
||||
}
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
/*!
|
||||
|
||||
@@ -54,14 +54,7 @@ QList<FilterEntry> FileSystemFilter::matchesFor(const QString &entry)
|
||||
QString name = entryInfo.fileName();
|
||||
QString directory = entryInfo.path();
|
||||
QString filePath = entryInfo.filePath();
|
||||
bool isDrive = false;
|
||||
foreach (const QFileInfo &drive, QDir::drives()) {
|
||||
if (filePath.startsWith(drive.path())) {
|
||||
isDrive = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isDrive) {
|
||||
if (entryInfo.isRelative()) {
|
||||
if (filePath.startsWith("~/")) {
|
||||
directory.replace(0, 1, QDir::homePath());
|
||||
} else {
|
||||
|
||||
@@ -128,12 +128,13 @@ protected:
|
||||
|
||||
ITextEditor *BaseTextEditor::openEditorAt(const QString &fileName,
|
||||
int line,
|
||||
int column)
|
||||
int column,
|
||||
const QString &editorKind)
|
||||
{
|
||||
Core::EditorManager *editorManager =
|
||||
ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>()->editorManager();
|
||||
editorManager->addCurrentPositionToNavigationHistory(true);
|
||||
Core::IEditor *editor = editorManager->openEditor(fileName, QString(), true);
|
||||
Core::IEditor *editor = editorManager->openEditor(fileName, editorKind, true);
|
||||
TextEditor::ITextEditor *texteditor = qobject_cast<TextEditor::ITextEditor *>(editor);
|
||||
if (texteditor) {
|
||||
texteditor->gotoLine(line, column);
|
||||
@@ -684,6 +685,64 @@ void BaseTextEditor::selectBlockDown()
|
||||
_q_matchParentheses();
|
||||
}
|
||||
|
||||
void BaseTextEditor::moveLineUp()
|
||||
{
|
||||
moveLineUpDown(true);
|
||||
}
|
||||
|
||||
void BaseTextEditor::moveLineDown()
|
||||
{
|
||||
moveLineUpDown(false);
|
||||
}
|
||||
|
||||
void BaseTextEditor::moveLineUpDown(bool up)
|
||||
{
|
||||
QTextCursor cursor = textCursor();
|
||||
QTextCursor move = cursor;
|
||||
move.beginEditBlock();
|
||||
|
||||
bool hasSelection = cursor.hasSelection();
|
||||
|
||||
if (cursor.hasSelection()) {
|
||||
move.setPosition(cursor.selectionStart());
|
||||
move.movePosition(QTextCursor::StartOfBlock);
|
||||
move.setPosition(cursor.selectionEnd(), QTextCursor::KeepAnchor);
|
||||
move.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
|
||||
} else {
|
||||
move.movePosition(QTextCursor::StartOfBlock);
|
||||
move.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
|
||||
}
|
||||
QString text = move.selectedText();
|
||||
move.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor);
|
||||
move.removeSelectedText();
|
||||
|
||||
if (up) {
|
||||
move.movePosition(QTextCursor::PreviousBlock);
|
||||
move.insertBlock();
|
||||
move.movePosition(QTextCursor::Left);
|
||||
} else {
|
||||
move.movePosition(QTextCursor::EndOfBlock);
|
||||
if (move.atBlockStart()) { // empty block
|
||||
move.movePosition(QTextCursor::NextBlock);
|
||||
move.insertBlock();
|
||||
move.movePosition(QTextCursor::Left);
|
||||
} else {
|
||||
move.insertBlock();
|
||||
}
|
||||
}
|
||||
|
||||
int start = move.position();
|
||||
move.clearSelection();
|
||||
move.insertText(text);
|
||||
int end = move.position();
|
||||
move.endEditBlock();
|
||||
if (hasSelection) {
|
||||
move.setPosition(start);
|
||||
move.setPosition(end, QTextCursor::KeepAnchor);
|
||||
}
|
||||
|
||||
setTextCursor(move);
|
||||
}
|
||||
|
||||
void BaseTextEditor::cleanWhitespace()
|
||||
{
|
||||
@@ -740,9 +799,13 @@ void BaseTextEditor::keyPressEvent(QKeyEvent *e)
|
||||
QTextCursor cursor = textCursor();
|
||||
if (d->m_inBlockSelectionMode)
|
||||
cursor.clearSelection();
|
||||
cursor.insertBlock();
|
||||
if (d->m_document->tabSettings().m_autoIndent) {
|
||||
cursor.beginEditBlock();
|
||||
cursor.insertBlock();
|
||||
indent(document(), cursor, QChar::Null);
|
||||
cursor.endEditBlock();
|
||||
} else {
|
||||
cursor.insertBlock();
|
||||
}
|
||||
e->accept();
|
||||
setTextCursor(cursor);
|
||||
@@ -3314,7 +3377,7 @@ void BaseTextEditorPrivate::moveCursorVisible()
|
||||
if (!cursor.block().isVisible()) {
|
||||
cursor.setVisualNavigation(true);
|
||||
cursor.movePosition(QTextCursor::PreviousBlock);
|
||||
q->setTextCursor(cursor);
|
||||
q->setTextCursor(cursor);
|
||||
}
|
||||
q->ensureCursorVisible();
|
||||
}
|
||||
|
||||
@@ -230,7 +230,8 @@ public:
|
||||
BaseTextEditor(QWidget *parent);
|
||||
~BaseTextEditor();
|
||||
|
||||
static ITextEditor *openEditorAt(const QString &fileName, int line, int column = 0);
|
||||
static ITextEditor *openEditorAt(const QString &fileName, int line, int column = 0,
|
||||
const QString &editorKind = QString());
|
||||
|
||||
// EditorInterface
|
||||
Core::IFile * file();
|
||||
@@ -329,6 +330,9 @@ public slots:
|
||||
void selectBlockUp();
|
||||
void selectBlockDown();
|
||||
|
||||
void moveLineUp();
|
||||
void moveLineDown();
|
||||
|
||||
void cleanWhitespace();
|
||||
|
||||
signals:
|
||||
@@ -447,6 +451,7 @@ private:
|
||||
void indentOrUnindent(bool doIndent);
|
||||
void handleHomeKey(bool anchor);
|
||||
void handleBackspaceKey();
|
||||
void moveLineUpDown(bool up);
|
||||
|
||||
void toggleBlockVisible(const QTextBlock &block);
|
||||
QRect collapseBox(const QTextBlock &block);
|
||||
|
||||
@@ -71,6 +71,7 @@ TextEditorActionHandler::TextEditorActionHandler(Core::ICore *core,
|
||||
= m_gotoBlockStartAction = m_gotoBlockStartWithSelectionAction
|
||||
= m_gotoBlockEndAction = m_gotoBlockEndWithSelectionAction
|
||||
= m_selectBlockUpAction = m_selectBlockDownAction
|
||||
= m_moveLineUpAction = m_moveLineDownAction
|
||||
= 0;
|
||||
|
||||
m_contextId << m_core->uniqueIDManager()->uniqueIdentifier(context);
|
||||
@@ -223,6 +224,16 @@ void TextEditorActionHandler::createActions()
|
||||
command = am->registerAction(m_selectBlockDownAction, Constants::SELECT_BLOCK_DOWN, m_contextId);
|
||||
command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+U")));
|
||||
connect(m_selectBlockDownAction, SIGNAL(triggered()), this, SLOT(selectBlockDown()));
|
||||
|
||||
m_moveLineUpAction= new QAction(tr("Move Line Up"), this);
|
||||
command = am->registerAction(m_moveLineUpAction, Constants::MOVE_LINE_UP, m_contextId);
|
||||
command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+Up")));
|
||||
connect(m_moveLineUpAction, SIGNAL(triggered()), this, SLOT(moveLineUp()));
|
||||
|
||||
m_moveLineDownAction= new QAction(tr("Move Line Down"), this);
|
||||
command = am->registerAction(m_moveLineDownAction, Constants::MOVE_LINE_DOWN, m_contextId);
|
||||
command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+Down")));
|
||||
connect(m_moveLineDownAction, SIGNAL(triggered()), this, SLOT(moveLineDown()));
|
||||
}
|
||||
|
||||
bool TextEditorActionHandler::supportsAction(const QString & /*id */) const
|
||||
@@ -287,6 +298,8 @@ void TextEditorActionHandler::updateActions(UpdateMode um)
|
||||
m_gotoBlockEndWithSelectionAction->setEnabled(um != NoEditor);
|
||||
m_selectBlockUpAction->setEnabled(um != NoEditor);
|
||||
m_selectBlockDownAction->setEnabled(um != NoEditor);
|
||||
m_moveLineUpAction->setEnabled(um != NoEditor);
|
||||
m_moveLineDownAction->setEnabled(um != NoEditor);
|
||||
|
||||
m_visualizeWhitespaceAction->setEnabled(um != NoEditor);
|
||||
if (m_currentEditor)
|
||||
@@ -390,6 +403,8 @@ FUNCTION(gotoBlockStartWithSelection)
|
||||
FUNCTION(gotoBlockEndWithSelection)
|
||||
FUNCTION(selectBlockUp)
|
||||
FUNCTION(selectBlockDown)
|
||||
FUNCTION(moveLineUp)
|
||||
FUNCTION(moveLineDown)
|
||||
|
||||
void TextEditorActionHandler::updateCurrentEditor(Core::IContext *object)
|
||||
{
|
||||
|
||||
@@ -116,6 +116,8 @@ private slots:
|
||||
void gotoBlockEndWithSelection();
|
||||
void selectBlockUp();
|
||||
void selectBlockDown();
|
||||
void moveLineUp();
|
||||
void moveLineDown();
|
||||
void updateCurrentEditor(Core::IContext *object);
|
||||
|
||||
private:
|
||||
@@ -145,6 +147,8 @@ private:
|
||||
QAction *m_gotoBlockEndWithSelectionAction;
|
||||
QAction *m_selectBlockUpAction;
|
||||
QAction *m_selectBlockDownAction;
|
||||
QAction *m_moveLineUpAction;
|
||||
QAction *m_moveLineDownAction;
|
||||
|
||||
uint m_optionalActions;
|
||||
QPointer<BaseTextEditor> m_currentEditor;
|
||||
|
||||
@@ -55,6 +55,8 @@ const char * const GOTO_BLOCK_END = "TextEditor.GotoBlockEnd";
|
||||
const char * const GOTO_BLOCK_END_WITH_SELECTION = "TextEditor.GotoBlockEndWithSelection";
|
||||
const char * const SELECT_BLOCK_UP = "TextEditor.SelectBlockUp";
|
||||
const char * const SELECT_BLOCK_DOWN = "TextEditor.SelectBlockDown";
|
||||
const char * const MOVE_LINE_UP = "TextEditor.MoveLineUp";
|
||||
const char * const MOVE_LINE_DOWN = "TextEditor.MoveLineDown";
|
||||
const char * const DELETE_LINE = "TextEditor.DeleteLine";
|
||||
const char * const DELETE_WORD = "TextEditor.DeleteWord";
|
||||
const char * const SELECT_ENCODING = "TextEditor.SelectEncoding";
|
||||
|
||||
Reference in New Issue
Block a user