diff --git a/dist/changes-1.1.0 b/dist/changes-1.1.0 index 681c9c0fc35..d19bcc0d8c5 100644 --- a/dist/changes-1.1.0 +++ b/dist/changes-1.1.0 @@ -25,16 +25,39 @@ Editing * Add signal/slot editor to form editor. * Improved open documents view (sorted, single-click, close buttons). * Copying text from the context help browser and output windows didn't work. - * Fixed "Go to slot..." functionality in the integrated QDesigner -Building, Running and Debugging +Building and Running * Experimental support for generic Makefile based projects. * Improved .pro file parsing, handling scopes and $$system directive. * Support subdir.file in .pro files. - * Experimental cdb debugger. * Option to start application in external terminal. + +Debugging * Possibility to attach debugger to core files. - * Debugger understands std::set now. + * Changed approach to dumper loading: Build once per used Qt version, + no dumper buildstep anymore. + * New dumper for std::set. Improved QString, QVariant, std::wstring + * Make strategy to load shared objects configurable (auto-solib-add). + * Maximum stack depth configurable. + * Improved interaction in the Locals&Watchers view. + * Experimental cdb debugger. + +Wizards + * It is now possible to choose file suffixes in the options dialog. + * Code of language change event is now generated correctly (added call + to base class). + +Designer + * Added signal/slot editor. + * Fixed "Goto slot" (formatting/multiple inheritance). + +Version control plugins + * Fixed handling of colored git output. + * Made svn 1.6 work. + * Added syntax highlighting to the git submit editor. + * Made git submit editor remove comment lines. + * Added configuration options for submit editors (user fields, word + wrapping). Platform Specific diff --git a/src/app/main.cpp b/src/app/main.cpp index 655095956a7..69c7aff13d2 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -179,7 +179,7 @@ static inline QStringList getPluginPaths() // 1) "plugins" (Win/Linux) QString pluginPath = rootDirPath; pluginPath += QDir::separator(); -#ifdef QT_ARCH_X86_64 +#if defined(QT_ARCH_X86_64) && defined(Q_OS_UNIX) && !defined(Q_OS_MAC) pluginPath += QLatin1String("lib64"); #else pluginPath += QLatin1String("lib"); diff --git a/src/plugins/coreplugin/coreconstants.h b/src/plugins/coreplugin/coreconstants.h index 7afdde43663..3c3903376a0 100644 --- a/src/plugins/coreplugin/coreconstants.h +++ b/src/plugins/coreplugin/coreconstants.h @@ -123,8 +123,9 @@ const char * const ZOOM_WINDOW = "QtCreator.ZoomWindow"; const char * const SPLIT = "QtCreator.Split"; const char * const SPLIT_SIDE_BY_SIDE = "QtCreator.SplitSideBySide"; -const char * const UNSPLIT = "QtCreator.Unsplit"; -const char * const GOTO_OTHER_WINDOW = "QtCreator.GotoOtherWindow"; +const char * const REMOVE_CURRENT_SPLIT = "QtCreator.RemoveCurrentSplit"; +const char * const REMOVE_ALL_SPLITS = "QtCreator.RemoveAllSplits"; +const char * const GOTO_OTHER_SPLIT = "QtCreator.GotoOtherSplit"; const char * const SAVEASDEFAULT = "QtCreator.SaveAsDefaultLayout"; const char * const RESTOREDEFAULT = "QtCreator.RestoreDefaultLayout"; const char * const CLOSE = "QtCreator.Close"; diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index 972de1582aa..8e79b50f6aa 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -154,8 +154,9 @@ struct EditorManagerPrivate { QAction *m_openInExternalEditorAction; QAction *m_splitAction; QAction *m_splitSideBySideAction; - QAction *m_unsplitAction; - QAction *m_gotoOtherWindowAction; + QAction *m_removeCurrentSplitAction; + QAction *m_removeAllSplitsAction; + QAction *m_gotoOtherSplitAction; QList m_editorHistory; QList m_navigationHistory; @@ -331,27 +332,33 @@ EditorManager::EditorManager(ICore *core, QWidget *parent) : m_d->m_splitAction = new QAction(tr("Split"), this); cmd = am->registerAction(m_d->m_splitAction, Constants::SPLIT, editManagerContext); - cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+E,1"))); + cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+E,2"))); mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT); connect(m_d->m_splitAction, SIGNAL(triggered()), this, SLOT(split())); m_d->m_splitSideBySideAction = new QAction(tr("Split Side by Side"), this); cmd = am->registerAction(m_d->m_splitSideBySideAction, Constants::SPLIT_SIDE_BY_SIDE, editManagerContext); - cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+E,2"))); + cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+E,3"))); mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT); connect(m_d->m_splitSideBySideAction, SIGNAL(triggered()), this, SLOT(splitSideBySide())); - m_d->m_unsplitAction = new QAction(tr("Unsplit"), this); - cmd = am->registerAction(m_d->m_unsplitAction, Constants::UNSPLIT, editManagerContext); + m_d->m_removeCurrentSplitAction = new QAction(tr("Remove Current Split"), this); + cmd = am->registerAction(m_d->m_removeCurrentSplitAction, Constants::REMOVE_CURRENT_SPLIT, editManagerContext); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+E,0"))); mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT); - connect(m_d->m_unsplitAction, SIGNAL(triggered()), this, SLOT(unsplit())); + connect(m_d->m_removeCurrentSplitAction, SIGNAL(triggered()), this, SLOT(removeCurrentSplit())); - m_d->m_gotoOtherWindowAction = new QAction(tr("Goto other window"), this); - cmd = am->registerAction(m_d->m_gotoOtherWindowAction, Constants::GOTO_OTHER_WINDOW, editManagerContext); + m_d->m_removeAllSplitsAction = new QAction(tr("Remove All Splits"), this); + cmd = am->registerAction(m_d->m_removeAllSplitsAction, Constants::REMOVE_ALL_SPLITS, editManagerContext); + cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+E,1"))); + mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT); + connect(m_d->m_removeAllSplitsAction, SIGNAL(triggered()), this, SLOT(removeAllSplits())); + + m_d->m_gotoOtherSplitAction = new QAction(tr("Goto Other Split"), this); + cmd = am->registerAction(m_d->m_gotoOtherSplitAction, Constants::GOTO_OTHER_SPLIT, editManagerContext); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+E,o"))); mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT); - connect(m_d->m_gotoOtherWindowAction, SIGNAL(triggered()), this, SLOT(gotoOtherWindow())); + connect(m_d->m_gotoOtherSplitAction, SIGNAL(triggered()), this, SLOT(gotoOtherSplit())); ActionContainer *medit = am->actionContainer(Constants::M_EDIT); @@ -1344,8 +1351,9 @@ void EditorManager::updateActions() m_d->m_goForwardAction->setEnabled(m_d->currentNavigationHistoryPosition < m_d->m_navigationHistory.size()-1); bool hasSplitter = m_d->m_splitter->isSplitter(); - m_d->m_unsplitAction->setEnabled(hasSplitter); - m_d->m_gotoOtherWindowAction->setEnabled(hasSplitter); + m_d->m_removeCurrentSplitAction->setEnabled(hasSplitter); + m_d->m_removeAllSplitsAction->setEnabled(hasSplitter); + m_d->m_gotoOtherSplitAction->setEnabled(hasSplitter); m_d->m_openInExternalEditorAction->setEnabled(curEditor != 0); } @@ -1788,7 +1796,7 @@ void EditorManager::splitSideBySide() split(Qt::Horizontal); } -void EditorManager::unsplit() +void EditorManager::removeCurrentSplit() { SplitterOrView *viewToClose = m_d->m_currentView; if (!viewToClose && m_d->m_currentEditor) @@ -1801,7 +1809,18 @@ void EditorManager::unsplit() updateActions(); } -void EditorManager::gotoOtherWindow() +void EditorManager::removeAllSplits() +{ + IEditor *editor = m_d->m_currentEditor; + if (editor && m_d->m_editorModel->isDuplicate(editor)) + editor = m_d->m_editorModel->originalForDuplicate(editor); + m_d->m_splitter->unsplitAll(); + if (!editor) + editor = pickUnusedEditor(); + activateEditor(editor); +} + +void EditorManager::gotoOtherSplit() { if (m_d->m_splitter->isSplitter()) { SplitterOrView *currentView = m_d->m_currentView; diff --git a/src/plugins/coreplugin/editormanager/editormanager.h b/src/plugins/coreplugin/editormanager/editormanager.h index 44df9294cbd..fa4b05740e7 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.h +++ b/src/plugins/coreplugin/editormanager/editormanager.h @@ -211,8 +211,9 @@ private slots: void split(Qt::Orientation orientation); void split(); void splitSideBySide(); - void unsplit(); - void gotoOtherWindow(); + void removeCurrentSplit(); + void removeAllSplits(); + void gotoOtherSplit(); private: QList filesForEditors(QList editors) const; diff --git a/src/plugins/coreplugin/editormanager/editorview.cpp b/src/plugins/coreplugin/editormanager/editorview.cpp index 2909bcd7f0f..92ed402dcbc 100644 --- a/src/plugins/coreplugin/editormanager/editorview.cpp +++ b/src/plugins/coreplugin/editormanager/editorview.cpp @@ -138,8 +138,9 @@ void EditorModel::addEntry(const Entry &entry) } int index; + QString displayName = entry.displayName(); for (index = 0; index < m_editors.count(); ++index) { - if (fileName < m_editors.at(index).fileName()) + if (displayName < m_editors.at(index).displayName()) break; } @@ -656,6 +657,18 @@ SplitterOrView::SplitterOrView(Core::IEditor *editor) setFocusPolicy(Qt::ClickFocus); } +SplitterOrView::~SplitterOrView() +{ + delete m_layout; + m_layout = 0; + delete m_view; + m_view = 0; + delete m_splitter; + m_splitter = 0; +} + + + void SplitterOrView::focusInEvent(QFocusEvent *) { CoreImpl::instance()->editorManager()->setCurrentView(this); @@ -860,24 +873,24 @@ void SplitterOrView::split(Qt::Orientation orientation) em->activateEditor(e); } -void SplitterOrView::close() +void SplitterOrView::unsplitAll() { - Q_ASSERT(!m_isRoot); - if (m_view) { - CoreImpl::instance()->editorManager()->emptyView(m_view); - delete m_view; - m_view = 0; - } - closeSplitterEditors(); + m_splitter->hide(); + m_layout->removeWidget(m_splitter); // workaround Qt bug + unsplitAll_helper(); + delete m_splitter; + m_splitter = 0; } -void SplitterOrView::closeSplitterEditors() +void SplitterOrView::unsplitAll_helper() { - if (!m_splitter) - return; - for (int i = 0; i < m_splitter->count(); ++i) { - if (SplitterOrView *splitterOrView = qobject_cast(m_splitter->widget(i))) { - splitterOrView->close(); + if (!m_isRoot && m_view) + CoreImpl::instance()->editorManager()->emptyView(m_view); + if (m_splitter) { + for (int i = 0; i < m_splitter->count(); ++i) { + if (SplitterOrView *splitterOrView = qobject_cast(m_splitter->widget(i))) { + splitterOrView->unsplitAll_helper(); + } } } } diff --git a/src/plugins/coreplugin/editormanager/editorview.h b/src/plugins/coreplugin/editormanager/editorview.h index e0d900f37d4..d198155ca3d 100644 --- a/src/plugins/coreplugin/editormanager/editorview.h +++ b/src/plugins/coreplugin/editormanager/editorview.h @@ -181,6 +181,7 @@ class SplitterOrView : public QWidget public: SplitterOrView(Internal::EditorModel *model = 0); // creates a splitter with an empty view SplitterOrView(Core::IEditor *editor); + ~SplitterOrView(); void split(Qt::Orientation orientation); void unsplit(); @@ -210,14 +211,15 @@ public: QSize sizeHint() const { return minimumSizeHint(); } QSize minimumSizeHint() const; + void unsplitAll(); + protected: void focusInEvent(QFocusEvent *); void paintEvent(QPaintEvent *); private: - void close(); - void closeSplitterEditors(); + void unsplitAll_helper(); SplitterOrView *findNextView_helper(SplitterOrView *view, bool *found); bool m_isRoot; QStackedLayout *m_layout; diff --git a/src/plugins/coreplugin/navigationwidget.cpp b/src/plugins/coreplugin/navigationwidget.cpp index f1940975467..091d19c2510 100644 --- a/src/plugins/coreplugin/navigationwidget.cpp +++ b/src/plugins/coreplugin/navigationwidget.cpp @@ -272,7 +272,7 @@ void NavigationWidget::restoreSettings(QSettings *settings) } else { QList sizes; sizes += 256; - for (int i = views.size()-1; i; --i) + for (int i = views.size()-1; i > 0; --i) sizes.prepend(512); setSizes(sizes); } diff --git a/src/plugins/debugger/debuggeractions.cpp b/src/plugins/debugger/debuggeractions.cpp index b8bc4dad5a1..95f9c3b1104 100644 --- a/src/plugins/debugger/debuggeractions.cpp +++ b/src/plugins/debugger/debuggeractions.cpp @@ -149,6 +149,9 @@ DebuggerSettings *theDebuggerSettings() item = new SavedAction(instance); instance->insertItem(AssignValue, item); + item = new SavedAction(instance); + instance->insertItem(AssignType, item); + item = new SavedAction(instance); instance->insertItem(ExpandItem, item); item->setText(QObject::tr("Expand item")); @@ -311,6 +314,10 @@ DebuggerSettings *theDebuggerSettings() item->setDefaultValue(20); instance->insertItem(MaximalStackDepth, item); + item = new SavedAction(instance); + item->setText(QObject::tr("Execute line")); + instance->insertItem(ExecuteCommand, item); + return instance; } diff --git a/src/plugins/debugger/debuggeractions.h b/src/plugins/debugger/debuggeractions.h index 079a879bc79..31e04199f53 100644 --- a/src/plugins/debugger/debuggeractions.h +++ b/src/plugins/debugger/debuggeractions.h @@ -75,6 +75,7 @@ enum DebuggerActionCode GdbLocation, GdbEnvironment, GdbScriptFile, + ExecuteCommand, // Stack MaximalStackDepth, @@ -86,6 +87,7 @@ enum DebuggerActionCode WatchModelUpdate, UseToolTips, AssignValue, + AssignType, ExpandItem, CollapseItem, diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp index 078692f7312..ea973c0c692 100644 --- a/src/plugins/debugger/debuggermanager.cpp +++ b/src/plugins/debugger/debuggermanager.cpp @@ -358,9 +358,6 @@ void DebuggerManager::init() m_watchAction->setText(tr("Add to Watch Window")); // For usuage hints oin focus{In,Out} - //connect(m_outputWindow, SIGNAL(statusMessageRequested(QString,int)), - // this, SLOT(showStatusMessage(QString,int))); - connect(m_continueAction, SIGNAL(triggered()), this, SLOT(continueExec())); @@ -401,8 +398,8 @@ void DebuggerManager::init() connect(m_statusTimer, SIGNAL(timeout()), this, SLOT(clearStatusMessage())); - connect(m_outputWindow, SIGNAL(commandExecutionRequested(QString)), - this, SLOT(executeDebuggerCommand(QString))); + connect(theDebuggerAction(ExecuteCommand), SIGNAL(triggered()), + this, SLOT(executeDebuggerCommand())); m_breakDock = createDockForWidget(m_breakWindow); @@ -971,6 +968,7 @@ void DebuggerManager::assignValueInDebugger() assignValueInDebugger(str.left(i), str.mid(i + 1)); } } + void DebuggerManager::assignValueInDebugger(const QString &expr, const QString &value) { QTC_ASSERT(m_engine, return); @@ -1036,6 +1034,12 @@ void DebuggerManager::nextIExec() m_engine->nextIExec(); } +void DebuggerManager::executeDebuggerCommand() +{ + if (QAction *action = qobject_cast(sender())) + executeDebuggerCommand(action->data().toString()); +} + void DebuggerManager::executeDebuggerCommand(const QString &command) { if (Debugger::Constants::Internal::debug) diff --git a/src/plugins/debugger/debuggermanager.h b/src/plugins/debugger/debuggermanager.h index fb6bc9e36cf..77150b452b2 100644 --- a/src/plugins/debugger/debuggermanager.h +++ b/src/plugins/debugger/debuggermanager.h @@ -238,6 +238,8 @@ public slots: void assignValueInDebugger(); void assignValueInDebugger(const QString &expr, const QString &value); + + void executeDebuggerCommand(); void executeDebuggerCommand(const QString &command); void showStatusMessage(const QString &msg, int timeout = -1); // -1 forever diff --git a/src/plugins/debugger/debuggeroutputwindow.cpp b/src/plugins/debugger/debuggeroutputwindow.cpp index 11b2a1fb0a3..b9d3fc9e3d2 100644 --- a/src/plugins/debugger/debuggeroutputwindow.cpp +++ b/src/plugins/debugger/debuggeroutputwindow.cpp @@ -84,6 +84,8 @@ public: menu->addAction(m_clearContentsAction); //menu->addAction(m_saveContentsAction); addContextActions(menu); + theDebuggerAction(ExecuteCommand)->setData(textCursor().block().text()); + menu->addAction(theDebuggerAction(ExecuteCommand)); menu->addSeparator(); menu->addAction(theDebuggerAction(SettingsDialog)); menu->exec(ev->globalPos()); @@ -101,35 +103,20 @@ class InputPane : public DebuggerPane { Q_OBJECT public: - InputPane(QWidget *parent) : DebuggerPane(parent) - { - m_commandExecutionAction = new QAction(this); - m_commandExecutionAction->setText("Execute line"); - m_commandExecutionAction->setEnabled(true); - //m_commandExecutionAction->setShortcut - // (Qt::ControlModifier + Qt::Key_Return); - - connect(m_commandExecutionAction, SIGNAL(triggered(bool)), - this, SLOT(executeCommand())); - } + InputPane(QWidget *parent) + : DebuggerPane(parent) + {} signals: - void commandExecutionRequested(const QString &); void clearContentsRequested(); void statusMessageRequested(const QString &, int); void commandSelected(int); -private slots: - void executeCommand() - { - emit commandExecutionRequested(textCursor().block().text()); - } - private: void keyPressEvent(QKeyEvent *ev) { if (ev->modifiers() == Qt::ControlModifier && ev->key() == Qt::Key_Return) - emit commandExecutionRequested(textCursor().block().text()); + theDebuggerAction(ExecuteCommand)->trigger(textCursor().block().text()); else if (ev->modifiers() == Qt::ControlModifier && ev->key() == Qt::Key_R) emit clearContentsRequested(); else @@ -157,7 +144,7 @@ private: void addContextActions(QMenu *menu) { - menu->addAction(m_commandExecutionAction); + menu->addAction(theDebuggerAction(ExecuteCommand)); } void focusInEvent(QFocusEvent *ev) @@ -171,8 +158,6 @@ private: emit statusMessageRequested(QString(), -1); QPlainTextEdit::focusOutEvent(ev); } - - QAction *m_commandExecutionAction; }; @@ -252,19 +237,12 @@ DebuggerOutputWindow::DebuggerOutputWindow(QWidget *parent) aggregate->add(new BaseTextFind(m_inputText)); #endif - connect(m_inputText, SIGNAL(commandExecutionRequested(QString)), - this, SIGNAL(commandExecutionRequested(QString))); connect(m_inputText, SIGNAL(statusMessageRequested(QString,int)), this, SIGNAL(statusMessageRequested(QString,int))); connect(m_inputText, SIGNAL(commandSelected(int)), m_combinedText, SLOT(gotoResult(int))); }; -void DebuggerOutputWindow::onReturnPressed() -{ - emit commandExecutionRequested(m_commandEdit->text()); -} - void DebuggerOutputWindow::showOutput(const QString &prefix, const QString &output) { if (output.isEmpty()) diff --git a/src/plugins/debugger/debuggeroutputwindow.h b/src/plugins/debugger/debuggeroutputwindow.h index 50df8f10177..904e0456199 100644 --- a/src/plugins/debugger/debuggeroutputwindow.h +++ b/src/plugins/debugger/debuggeroutputwindow.h @@ -65,10 +65,6 @@ public slots: signals: void showPage(); void statusMessageRequested(const QString &msg, int); - void commandExecutionRequested(const QString &cmd); - -private slots: - void onReturnPressed(); private: QPlainTextEdit *m_combinedText; // combined input/output diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index e6717fcbc00..f1fea3104eb 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -857,7 +857,6 @@ void GdbEngine::handleResult(const GdbResultRecord & record, int type, void GdbEngine::executeDebuggerCommand(const QString &command) { - //createGdbProcessIfNeeded(); if (m_gdbProc.state() == QProcess::NotRunning) { debugMessage("NO GDB PROCESS RUNNING, PLAIN CMD IGNORED: " + command); return; @@ -867,7 +866,6 @@ void GdbEngine::executeDebuggerCommand(const QString &command) cmd.command = command; cmd.type = -1; - emit gdbInputAvailable(QString(), cmd.command); m_gdbProc.write(cmd.command.toLatin1() + "\r\n"); } diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index af120e3a18c..b2af8278d94 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -520,9 +520,11 @@ Qt::ItemFlags WatchHandler::flags(const QModelIndex &idx) const const WatchData &data = m_displaySet.at(node); if (data.isWatcher() && idx.column() == 0) - return editable; // watcher names are - if (idx.column() == 1) - return editable; // values are editable + return editable; // watcher names are editable + if (data.isWatcher() && idx.column() == 2) + return editable; // watcher types are + if (idx.column() == 1) + return editable; // locals and watcher values are editable return notEditable; } diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp index e10d39319b6..77f09f79208 100644 --- a/src/plugins/debugger/watchwindow.cpp +++ b/src/plugins/debugger/watchwindow.cpp @@ -87,6 +87,9 @@ public: if (index.column() == 1) { // the value column theDebuggerAction(AssignValue)->trigger(exp + '=' + value); + } else if (index.column() == 2) { + // the type column + theDebuggerAction(AssignType)->trigger(exp + '=' + value); } else if (index.column() == 0) { // the watcher name column theDebuggerAction(RemoveWatchExpression)->trigger(exp); @@ -139,11 +142,16 @@ void WatchWindow::collapseNode(const QModelIndex &idx) void WatchWindow::keyPressEvent(QKeyEvent *ev) { - if (ev->key() == Qt::Key_Delete) { + if (ev->key() == Qt::Key_Delete && m_type == WatchersType) { QModelIndex idx = currentIndex(); QModelIndex idx1 = idx.sibling(idx.row(), 0); QString exp = model()->data(idx1).toString(); - theDebuggerAction(RemoveWatchExpression)->setValue(exp); + theDebuggerAction(RemoveWatchExpression)->trigger(exp); + } else if (ev->key() == Qt::Key_Return && m_type == LocalsType) { + QModelIndex idx = currentIndex(); + QModelIndex idx1 = idx.sibling(idx.row(), 0); + QString exp = model()->data(idx1).toString(); + theDebuggerAction(WatchExpression)->trigger(exp); } QTreeView::keyPressEvent(ev); } diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index 34c0080ca09..96d02733017 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -125,15 +125,16 @@ enum Mode enum SubMode { NoSubMode, - RegisterSubMode, // used for " ChangeSubMode, // used for c DeleteSubMode, // used for d FilterSubMode, // used for ! + IndentSubMode, // used for = + RegisterSubMode, // used for " ReplaceSubMode, // used for R and r - YankSubMode, // used for y ShiftLeftSubMode, // used for < ShiftRightSubMode, // used for > - IndentSubMode, // used for = + WindowSubMode, // used for Ctrl-w + YankSubMode, // used for y ZSubMode, }; @@ -260,13 +261,13 @@ public: // helper functions for indenting bool isElectricCharacter(QChar c) const { return c == '{' || c == '}' || c == '#'; } - int indentDist() const; void indentRegion(QChar lastTyped = QChar()); void shiftRegionLeft(int repeat = 1); void shiftRegionRight(int repeat = 1); void moveToFirstNonBlankOnLine(); - void moveToDesiredColumn(); + void moveToTargetColumn(); + void setTargetColumn() { m_targetColumn = leftDist(); } void moveToNextWord(bool simple); void moveToMatchingParanthesis(); void moveToWordBoundary(bool simple, bool forward); @@ -316,6 +317,7 @@ public: int m_subsubdata; QString m_input; QTextCursor m_tc; + QTextCursor m_oldTc; // copy from last event to check for external changes int m_anchor; QHash m_registers; int m_register; @@ -382,10 +384,17 @@ public: // for restoring cursor position int m_savedYankPosition; - int m_desiredColumn; + int m_targetColumn; int m_cursorWidth; + // auto-indent + void insertAutomaticIndentation(bool goingDown); + bool removeAutomaticIndentation(); // true if something removed + // number of autoindented characters + int m_justAutoIndented; + void handleStartOfLine(); + void recordJump(); void recordNewUndo(); QList m_jumpListUndo; @@ -413,13 +422,13 @@ FakeVimHandler::Private::Private(FakeVimHandler *parent, QWidget *widget) m_register = '"'; m_gflag = false; m_visualMode = NoVisualMode; - m_desiredColumn = 0; + m_targetColumn = 0; m_moveType = MoveInclusive; m_anchor = 0; m_savedYankPosition = 0; m_cursorWidth = EDITOR(cursorWidth()); m_inReplay = false; - + m_justAutoIndented = 0; } bool FakeVimHandler::Private::wantsOverride(QKeyEvent *ev) @@ -480,8 +489,12 @@ EventResult FakeVimHandler::Private::handleEvent(QKeyEvent *ev) // Fake "End of line" m_tc = EDITOR(textCursor()); - m_tc.setVisualNavigation(true); + if (m_tc.position() != m_oldTc.position()) + setTargetColumn(); + + m_tc.setVisualNavigation(true); + if (m_fakeEnd) moveRight(); @@ -492,7 +505,7 @@ EventResult FakeVimHandler::Private::handleEvent(QKeyEvent *ev) key += 32; } - m_undoCursorPosition[EDITOR(document())->revision()] = m_tc.position(); + m_undoCursorPosition[m_tc.document()->revision()] = m_tc.position(); if (m_mode == InsertMode) m_tc.joinPreviousEditBlock(); else @@ -506,6 +519,7 @@ EventResult FakeVimHandler::Private::handleEvent(QKeyEvent *ev) if (m_fakeEnd) moveLeft(); + m_oldTc = m_tc; EDITOR(setTextCursor(m_tc)); return result; } @@ -649,6 +663,8 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand) updateMiniBuffer(); } + moveToTargetColumn(); + m_moveType = MoveInclusive; m_mvcount.clear(); m_opcount.clear(); @@ -658,7 +674,6 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand) updateSelection(); updateMiniBuffer(); - m_desiredColumn = leftDist(); } void FakeVimHandler::Private::updateSelection() @@ -795,7 +810,10 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified, { EventResult handled = EventHandled; - if (m_submode == RegisterSubMode) { + if (m_submode == WindowSubMode) { + emit q->windowCommandRequested(key); + m_submode = NoSubMode; + } else if (m_submode == RegisterSubMode) { m_register = key; m_submode = NoSubMode; } else if (m_submode == ChangeSubMode && key == 'c') { @@ -979,7 +997,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified, m_moveType = MoveExclusive; finishMovement("$"); if (submode == NoSubMode) - m_desiredColumn = -1; + m_targetColumn = -1; } else if (key == ',') { // FIXME: use some other mechanism //m_passing = true; @@ -1074,7 +1092,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified, int sline = cursorLineOnScreen(); // FIXME: this should use the "scroll" option, and "count" moveDown(linesOnScreen() / 2); - moveToFirstNonBlankOnLine(); + handleStartOfLine(); scrollToLineInDocument(cursorLineInDocument() - sline); finishMovement(); } else if (key == 'e') { @@ -1103,8 +1121,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified, if (m_gflag) { m_gflag = false; m_tc.setPosition(firstPositionInLine(1), KeepAnchor); - if (hasConfig(ConfigStartOfLine)) - moveToFirstNonBlankOnLine(); + handleStartOfLine(); finishMovement(); } else { m_gflag = true; @@ -1112,8 +1129,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified, } else if (key == 'G') { int n = m_mvcount.isEmpty() ? linesInDocument() : count(); m_tc.setPosition(firstPositionInLine(n), KeepAnchor); - if (hasConfig(ConfigStartOfLine)) - moveToFirstNonBlankOnLine(); + handleStartOfLine(); finishMovement(); } else if (key == 'h' || key == Key_Left || key == Key_Backspace || key == control('h')) { @@ -1121,11 +1137,12 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified, if (m_fakeEnd && m_tc.block().length() > 1) ++n; moveLeft(n); + setTargetColumn(); finishMovement("h"); } else if (key == 'H') { m_tc = EDITOR(cursorForPosition(QPoint(0, 0))); moveDown(qMax(count() - 1, 0)); - moveToFirstNonBlankOnLine(); + handleStartOfLine(); finishMovement(); } else if (key == 'i') { m_dotCommand = "i"; //QString("%1i").arg(count()); @@ -1147,12 +1164,9 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified, setPosition(m_jumpListRedo.takeLast()); } } else if (key == 'j' || key == Key_Down) { - //qDebug() << "DESIRED COLUMN" << m_desiredColumn; - int savedColumn = m_desiredColumn; if (m_submode == NoSubMode || m_submode == ZSubMode || m_submode == RegisterSubMode) { moveDown(count()); - moveToDesiredColumn(); } else { m_moveType = MoveLineWise; moveToStartOfLine(); @@ -1160,7 +1174,6 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified, moveDown(count() + 1); } finishMovement("j"); - m_desiredColumn = savedColumn; } else if (key == 'J') { if (m_submode == NoSubMode) { for (int i = qMax(count(), 2) - 1; --i >= 0; ) { @@ -1177,11 +1190,9 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified, moveLeft(); } } else if (key == 'k' || key == Key_Up) { - int savedColumn = m_desiredColumn; if (m_submode == NoSubMode || m_submode == ZSubMode || m_submode == RegisterSubMode) { moveUp(count()); - moveToDesiredColumn(); } else { m_moveType = MoveLineWise; moveToStartOfLine(); @@ -1190,15 +1201,15 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified, moveUp(count() + 1); } finishMovement("k"); - m_desiredColumn = savedColumn; } else if (key == 'l' || key == Key_Right || key == ' ') { m_moveType = MoveExclusive; moveRight(qMin(count(), rightDist())); + setTargetColumn(); finishMovement("l"); } else if (key == 'L') { m_tc = EDITOR(cursorForPosition(QPoint(0, EDITOR(height())))); moveUp(qMax(count(), 1)); - moveToFirstNonBlankOnLine(); + handleStartOfLine(); finishMovement(); } else if (key == control('l')) { // screen redraw. should not be needed @@ -1206,7 +1217,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified, m_subsubmode = MarkSubSubMode; } else if (key == 'M') { m_tc = EDITOR(cursorForPosition(QPoint(0, EDITOR(height()) / 2))); - moveToFirstNonBlankOnLine(); + handleStartOfLine(); finishMovement(); } else if (key == 'n') { search(lastSearchString(), m_lastSearchForward); @@ -1218,16 +1229,11 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified, m_dotCommand = QString("%1o").arg(count()); enterInsertMode(); moveToFirstNonBlankOnLine(); - int numSpaces = leftDist(); if (key == 'O') moveUp(); moveToEndOfLine(); m_tc.insertText("\n"); - moveToStartOfLine(); - if (0 && hasConfig(ConfigAutoIndent)) - m_tc.insertText(QString(indentDist(), ' ')); - else - m_tc.insertText(QString(numSpaces, ' ')); + insertAutomaticIndentation(key == 'o'); } else if (key == control('o')) { if (!m_jumpListUndo.isEmpty()) { m_jumpListRedo.append(position()); @@ -1240,7 +1246,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified, //qDebug() << "LINES: " << n << text << m_register; if (n > 0) { moveToStartOfLine(); - m_desiredColumn = 0; + m_targetColumn = 0; for (int i = count(); --i >= 0; ) { if (key == 'p') moveDown(); @@ -1249,7 +1255,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified, } moveToFirstNonBlankOnLine(); } else { - m_desiredColumn = 0; + m_targetColumn = 0; for (int i = count(); --i >= 0; ) { if (key == 'p') moveRight(); @@ -1295,7 +1301,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified, int sline = cursorLineOnScreen(); // FIXME: this should use the "scroll" option, and "count" moveUp(linesOnScreen() / 2); - moveToFirstNonBlankOnLine(); + handleStartOfLine(); scrollToLineInDocument(cursorLineInDocument() - sline); finishMovement(); } else if (key == 'v') { @@ -1324,6 +1330,8 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified, m_moveType = MoveExclusive; } finishMovement("W"); + } else if (key == control('w')) { + m_submode = WindowSubMode; } else if (key == 'x' && m_visualMode == NoVisualMode) { // = "dl" m_moveType = MoveExclusive; if (atEndOfLine()) @@ -1375,12 +1383,12 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified, } else if (key == Key_PageDown || key == control('f')) { moveDown(count() * (linesOnScreen() - 2) - cursorLineOnScreen()); scrollToLineInDocument(cursorLineInDocument()); - moveToFirstNonBlankOnLine(); + handleStartOfLine(); finishMovement(); } else if (key == Key_PageUp || key == control('b')) { moveUp(count() * (linesOnScreen() - 2) + cursorLineOnScreen()); scrollToLineInDocument(cursorLineInDocument() + linesOnScreen() - 2); - moveToFirstNonBlankOnLine(); + handleStartOfLine(); finishMovement(); } else if (key == Key_Delete) { setAnchor(); @@ -1415,6 +1423,7 @@ EventResult FakeVimHandler::Private::handleInsertMode(int key, int, data += m_lastInsertion; } moveLeft(qMin(1, leftDist())); + setTargetColumn(); m_dotCommand += m_lastInsertion; m_dotCommand += QChar(27); recordNewUndo(); @@ -1423,10 +1432,12 @@ EventResult FakeVimHandler::Private::handleInsertMode(int key, int, moveLeft(count()); m_lastInsertion.clear(); } else if (key == Key_Down) { + removeAutomaticIndentation(); m_submode = NoSubMode; moveDown(count()); m_lastInsertion.clear(); } else if (key == Key_Up) { + removeAutomaticIndentation(); m_submode = NoSubMode; moveUp(count()); m_lastInsertion.clear(); @@ -1437,20 +1448,22 @@ EventResult FakeVimHandler::Private::handleInsertMode(int key, int, m_submode = NoSubMode; m_tc.insertBlock(); m_lastInsertion += "\n"; - if (0 && hasConfig(ConfigAutoIndent)) - indentRegion('\n'); + insertAutomaticIndentation(true); } else if (key == Key_Backspace || key == control('h')) { - if (!m_lastInsertion.isEmpty() || hasConfig(ConfigBackspace, "start")) { - m_tc.deletePreviousChar(); - m_lastInsertion = m_lastInsertion.left(m_lastInsertion.size() - 1); - } + if (!removeAutomaticIndentation()) + if (!m_lastInsertion.isEmpty() || hasConfig(ConfigBackspace, "start")) { + m_tc.deletePreviousChar(); + m_lastInsertion.chop(1); + } } else if (key == Key_Delete) { m_tc.deleteChar(); m_lastInsertion.clear(); } else if (key == Key_PageDown || key == control('f')) { + removeAutomaticIndentation(); moveDown(count() * (linesOnScreen() - 2)); m_lastInsertion.clear(); } else if (key == Key_PageUp || key == control('b')) { + removeAutomaticIndentation(); moveUp(count() * (linesOnScreen() - 2)); m_lastInsertion.clear(); } else if (key == Key_Tab && hasConfig(ConfigExpandTab)) { @@ -1914,14 +1927,6 @@ void FakeVimHandler::Private::moveToFirstNonBlankOnLine() } } -int FakeVimHandler::Private::indentDist() const -{ - int amount = 0; - int line = cursorLineInDocument(); - emit q->indentRegion(&amount, line, line, QChar(' ')); - return amount; -} - void FakeVimHandler::Private::indentRegion(QChar typedChar) { //int savedPos = anchor(); @@ -1993,12 +1998,12 @@ void FakeVimHandler::Private::shiftRegionLeft(int repeat) m_dotCommand = QString("%1<<").arg(endLine - beginLine + 1); } -void FakeVimHandler::Private::moveToDesiredColumn() +void FakeVimHandler::Private::moveToTargetColumn() { - if (m_desiredColumn == -1 || m_tc.block().length() <= m_desiredColumn) - m_tc.movePosition(EndOfLine, KeepAnchor); - else - m_tc.setPosition(m_tc.block().position() + m_desiredColumn, KeepAnchor); + if (m_targetColumn == -1 || m_tc.block().length() <= m_targetColumn) + m_tc.movePosition(EndOfLine, KeepAnchor); + else + m_tc.setPosition(m_tc.block().position() + m_targetColumn, KeepAnchor); } static int charClass(QChar c, bool simple) @@ -2153,7 +2158,7 @@ void FakeVimHandler::Private::scrollUp(int count) int FakeVimHandler::Private::lastPositionInDocument() const { - QTextBlock block = m_tc.block().document()->lastBlock(); + QTextBlock block = m_tc.document()->lastBlock(); return block.position() + block.length(); } @@ -2171,12 +2176,12 @@ QString FakeVimHandler::Private::selectedText() const int FakeVimHandler::Private::firstPositionInLine(int line) const { - return m_tc.block().document()->findBlockByNumber(line - 1).position(); + return m_tc.document()->findBlockByNumber(line - 1).position(); } int FakeVimHandler::Private::lastPositionInLine(int line) const { - QTextBlock block = m_tc.block().document()->findBlockByNumber(line - 1); + QTextBlock block = m_tc.document()->findBlockByNumber(line - 1); return block.position() + block.length() - 1; } @@ -2213,14 +2218,14 @@ QWidget *FakeVimHandler::Private::editor() const void FakeVimHandler::Private::undo() { - int current = EDITOR(document())->revision(); + int current = m_tc.document()->revision(); m_tc.endEditBlock(); m_needMoreUndo = false; EDITOR(undo()); if (m_needMoreUndo) EDITOR(undo()); m_tc.beginEditBlock(); - int rev = EDITOR(document())->revision(); + int rev = m_tc.document()->revision(); if (current == rev) showBlackMessage(tr("Already at oldest change")); else @@ -2231,14 +2236,14 @@ void FakeVimHandler::Private::undo() void FakeVimHandler::Private::redo() { - int current = EDITOR(document())->revision(); + int current = m_tc.document()->revision(); m_tc.endEditBlock(); m_needMoreUndo = false; EDITOR(redo()); if (m_needMoreUndo) EDITOR(redo()); m_tc.beginEditBlock(); - int rev = EDITOR(document())->revision(); + int rev = m_tc.document()->revision(); if (rev == current) showBlackMessage(tr("Already at newest change")); else @@ -2304,6 +2309,38 @@ void FakeVimHandler::Private::recordNewUndo() m_tc.beginEditBlock(); } +void FakeVimHandler::Private::insertAutomaticIndentation(bool goingDown) +{ + if (!hasConfig(ConfigAutoIndent)) + return; + QTextBlock block = goingDown ? m_tc.block().previous() : m_tc.block().next(); + QString text = block.text(); + int pos = 0, n = text.size(); + while (pos < n && text.at(pos).isSpace()) + ++pos; + text.truncate(pos); + // FIXME: handle 'smartindent' and 'cindent' + m_tc.insertText(text); + m_justAutoIndented = text.size(); +} + +bool FakeVimHandler::Private::removeAutomaticIndentation() +{ + if (!hasConfig(ConfigAutoIndent) || m_justAutoIndented == 0) + return false; + m_tc.movePosition(StartOfLine, KeepAnchor); + m_tc.removeSelectedText(); + m_lastInsertion.chop(m_justAutoIndented); + m_justAutoIndented = 0; + return true; +} + +void FakeVimHandler::Private::handleStartOfLine() +{ + if (hasConfig(ConfigStartOfLine)) + moveToFirstNonBlankOnLine(); +} + /////////////////////////////////////////////////////////////////////// // diff --git a/src/plugins/fakevim/fakevimhandler.h b/src/plugins/fakevim/fakevimhandler.h index 74ec43c9771..acb0990b777 100644 --- a/src/plugins/fakevim/fakevimhandler.h +++ b/src/plugins/fakevim/fakevimhandler.h @@ -72,6 +72,7 @@ signals: void moveToMatchingParenthesis(bool *moved, bool *forward, QTextCursor *cursor); void indentRegion(int *amount, int beginLine, int endLine, QChar typedChar); void completionRequested(); + void windowCommandRequested(int key); public: class Private; diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp index f1bcda4c84b..7f4e3eeada7 100644 --- a/src/plugins/fakevim/fakevimplugin.cpp +++ b/src/plugins/fakevim/fakevimplugin.cpp @@ -231,6 +231,7 @@ private slots: void setUseFakeVim(const QVariant &value); void quitFakeVim(); void triggerCompletions(); + void windowCommand(int key); void showSettingsDialog(); void showCommandBuffer(const QString &contents); @@ -309,6 +310,46 @@ void FakeVimPluginPrivate::showSettingsDialog() Core::ICore::instance()->showOptionsDialog("FakeVim", "General"); } +void FakeVimPluginPrivate::windowCommand(int key) +{ + #define control(n) (256 + n) + QString code; + switch (key) { + case 'c': case 'C': case control('c'): + code = Core::Constants::CLOSE; + break; + case 'n': case 'N': case control('n'): + code = Core::Constants::GOTONEXT; + break; + case 'o': case 'O': case control('o'): + code = Core::Constants::REMOVE_ALL_SPLITS; + code = Core::Constants::REMOVE_CURRENT_SPLIT; + break; + case 'p': case 'P': case control('p'): + code = Core::Constants::GOTOPREV; + break; + case 's': case 'S': case control('s'): + code = Core::Constants::SPLIT; + break; + case 'w': case 'W': case control('w'): + code = Core::Constants::GOTO_OTHER_SPLIT; + break; + } + #undef control + qDebug() << "RUNNING WINDOW COMMAND: " << key << code; + if (code.isEmpty()) { + qDebug() << "UNKNOWN WINDOWS COMMAND: " << key; + return; + } + Core::ActionManager *am = Core::ICore::instance()->actionManager(); + QTC_ASSERT(am, return); + Core::Command *cmd = am->command(code); + QTC_ASSERT(cmd, return); + QAction *action = cmd->action(); + QTC_ASSERT(action, return); + action->trigger(); +} + void FakeVimPluginPrivate::editorOpened(Core::IEditor *editor) { if (!editor) @@ -344,6 +385,8 @@ void FakeVimPluginPrivate::editorOpened(Core::IEditor *editor) this, SLOT(indentRegion(int*,int,int,QChar))); connect(handler, SIGNAL(completionRequested()), this, SLOT(triggerCompletions())); + connect(handler, SIGNAL(windowCommandRequested(int)), + this, SLOT(windowCommand(int))); handler->setCurrentFileName(editor->file()->fileName()); handler->installEventFilter(); diff --git a/src/plugins/find/findtoolwindow.cpp b/src/plugins/find/findtoolwindow.cpp index b2f17fa63d3..eec831775b5 100644 --- a/src/plugins/find/findtoolwindow.cpp +++ b/src/plugins/find/findtoolwindow.cpp @@ -40,14 +40,15 @@ using namespace Find::Internal; FindToolWindow::FindToolWindow(FindPlugin *plugin) : QDialog(Core::ICore::instance()->mainWindow()), m_plugin(plugin), - m_findCompleter(new QCompleter(this)) + m_findCompleter(new QCompleter(this)), + m_currentFilter(0) { m_ui.setupUi(this); connect(m_ui.closeButton, SIGNAL(clicked()), this, SLOT(reject())); connect(m_ui.searchButton, SIGNAL(clicked()), this, SLOT(accept())); connect(m_ui.matchCase, SIGNAL(toggled(bool)), m_plugin, SLOT(setCaseSensitive(bool))); connect(m_ui.wholeWords, SIGNAL(toggled(bool)), m_plugin, SLOT(setWholeWord(bool))); - connect(m_ui.filterList, SIGNAL(currentIndexChanged(int)), this, SLOT(setCurrentFilter(int))); + connect(m_ui.filterList, SIGNAL(activated(int)), this, SLOT(setCurrentFilter(int))); connect(this, SIGNAL(accepted()), this, SLOT(search())); m_findCompleter->setModel(m_plugin->findCompletionModel()); m_ui.searchTerm->setCompleter(m_findCompleter); @@ -74,6 +75,8 @@ void FindToolWindow::setFindFilters(const QList &filters) m_configWidgets.append(filter->createConfigWidget()); } m_ui.filterList->addItems(names); + if (m_filters.size() > 0) + setCurrentFilter(0); } void FindToolWindow::setFindText(const QString &text) @@ -83,9 +86,11 @@ void FindToolWindow::setFindText(const QString &text) void FindToolWindow::open(IFindFilter *filter) { + if (!filter) + filter = m_currentFilter; int index = m_filters.indexOf(filter); if (index >= 0) { - m_ui.filterList->setCurrentIndex(index); + setCurrentFilter(index); } m_ui.matchCase->setChecked(m_plugin->findFlags() & QTextDocument::FindCaseSensitively); m_ui.wholeWords->setChecked(m_plugin->findFlags() & QTextDocument::FindWholeWords); @@ -96,6 +101,7 @@ void FindToolWindow::open(IFindFilter *filter) void FindToolWindow::setCurrentFilter(int index) { + m_ui.filterList->setCurrentIndex(index); for (int i = 0; i < m_configWidgets.size(); ++i) { QWidget *configWidget = m_configWidgets.at(i); if (!configWidget) @@ -112,6 +118,7 @@ void FindToolWindow::setCurrentFilter(int index) configWidget->setParent(0); } } + m_currentFilter = m_filters.at(index); } void FindToolWindow::search() @@ -129,6 +136,7 @@ void FindToolWindow::writeSettings() { QSettings *settings = Core::ICore::instance()->settings(); settings->beginGroup("Find"); + settings->setValue("CurrentFilter", m_currentFilter->id()); foreach (IFindFilter *filter, m_filters) filter->writeSettings(settings); settings->endGroup(); @@ -138,7 +146,13 @@ void FindToolWindow::readSettings() { QSettings *settings = Core::ICore::instance()->settings(); settings->beginGroup("Find"); - foreach (IFindFilter *filter, m_filters) + const QString currentFilter = settings->value("CurrentFilter").toString(); + for (int i = 0; i < m_filters.size(); ++i) { + IFindFilter *filter = m_filters.at(i); filter->readSettings(settings); + if (filter->id() == currentFilter) { + setCurrentFilter(i); + } + } settings->endGroup(); } diff --git a/src/plugins/find/findtoolwindow.h b/src/plugins/find/findtoolwindow.h index d377c46a1cd..c1b8417c38b 100644 --- a/src/plugins/find/findtoolwindow.h +++ b/src/plugins/find/findtoolwindow.h @@ -67,6 +67,7 @@ private: QList m_filters; QCompleter *m_findCompleter; QList m_configWidgets; + IFindFilter *m_currentFilter; }; } // namespace Internal diff --git a/src/plugins/find/ifindfilter.h b/src/plugins/find/ifindfilter.h index 9859fd75db7..69afaa283dd 100644 --- a/src/plugins/find/ifindfilter.h +++ b/src/plugins/find/ifindfilter.h @@ -45,6 +45,7 @@ public: virtual ~IFindFilter() {} + virtual QString id() const = 0; virtual QString name() const = 0; virtual bool isEnabled() const = 0; virtual QKeySequence defaultShortcut() const = 0; diff --git a/src/plugins/projectexplorer/allprojectsfind.cpp b/src/plugins/projectexplorer/allprojectsfind.cpp index c6448c2f801..c4ce7bee588 100644 --- a/src/plugins/projectexplorer/allprojectsfind.cpp +++ b/src/plugins/projectexplorer/allprojectsfind.cpp @@ -51,6 +51,11 @@ AllProjectsFind::AllProjectsFind(ProjectExplorerPlugin *plugin, SearchResultWind connect(m_plugin, SIGNAL(fileListChanged()), this, SIGNAL(changed())); } +QString AllProjectsFind::id() const +{ + return "All Projects"; +} + QString AllProjectsFind::name() const { return tr("All Projects"); diff --git a/src/plugins/projectexplorer/allprojectsfind.h b/src/plugins/projectexplorer/allprojectsfind.h index f801dcfed09..67e64e64c5d 100644 --- a/src/plugins/projectexplorer/allprojectsfind.h +++ b/src/plugins/projectexplorer/allprojectsfind.h @@ -50,6 +50,7 @@ class AllProjectsFind : public TextEditor::BaseFileFind public: AllProjectsFind(ProjectExplorerPlugin *plugin, Find::SearchResultWindow *resultWindow); + QString id() const; QString name() const; bool isEnabled() const; diff --git a/src/plugins/projectexplorer/currentprojectfind.cpp b/src/plugins/projectexplorer/currentprojectfind.cpp index 4fcfc68642e..c830ea96932 100644 --- a/src/plugins/projectexplorer/currentprojectfind.cpp +++ b/src/plugins/projectexplorer/currentprojectfind.cpp @@ -52,6 +52,11 @@ CurrentProjectFind::CurrentProjectFind(ProjectExplorerPlugin *plugin, SearchResu this, SIGNAL(changed())); } +QString CurrentProjectFind::id() const +{ + return "Current Project"; +} + QString CurrentProjectFind::name() const { return tr("Current Project"); diff --git a/src/plugins/projectexplorer/currentprojectfind.h b/src/plugins/projectexplorer/currentprojectfind.h index e9cc264bfdf..e24b6490a32 100644 --- a/src/plugins/projectexplorer/currentprojectfind.h +++ b/src/plugins/projectexplorer/currentprojectfind.h @@ -48,6 +48,7 @@ class CurrentProjectFind : public TextEditor::BaseFileFind public: CurrentProjectFind(ProjectExplorerPlugin *plugin, Find::SearchResultWindow *resultWindow); + QString id() const; QString name() const; bool isEnabled() const; diff --git a/src/plugins/qtscripteditor/parser/javascript.g b/src/plugins/qtscripteditor/parser/javascript.g index 80dfaddcad4..33657f8a1a9 100644 --- a/src/plugins/qtscripteditor/parser/javascript.g +++ b/src/plugins/qtscripteditor/parser/javascript.g @@ -316,7 +316,7 @@ protected: { return sym_stack [tos + index - 1]; } inline Location &loc(int index) - { return location_stack [tos + index - 2]; } + { return location_stack [tos + index - 1]; } protected: int tos; @@ -336,6 +336,7 @@ protected: double yylval; Location yylloc; + Location yyprevlloc; SavedToken token_buffer[TOKEN_BUFFER_SIZE]; SavedToken *first_token; @@ -427,6 +428,8 @@ bool JavaScriptParser::parse(JavaScriptEnginePrivate *driver) _Lcheck_token: if (yytoken == -1 && -TERMINAL_COUNT != action_index[action]) { + yyprevlloc = yylloc; + if (first_token == last_token) { yytoken = lexer->lex(); yylval = lexer->dval(); @@ -2092,7 +2095,7 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ; const QString msg = QString::fromUtf8("Missing `;'"); diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, - yylloc.startLine, yylloc.startColumn, msg)); + yyprevlloc.startLine, yyprevlloc.startColumn, msg)); first_token = &token_buffer[0]; last_token = &token_buffer[1]; diff --git a/src/plugins/qtscripteditor/parser/javascriptgrammar.cpp b/src/plugins/qtscripteditor/parser/javascriptgrammar.cpp index d5b7765ebc5..abe49bf93ec 100644 --- a/src/plugins/qtscripteditor/parser/javascriptgrammar.cpp +++ b/src/plugins/qtscripteditor/parser/javascriptgrammar.cpp @@ -2,41 +2,13 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the QtCore module of the Qt Toolkit. +** This file is part of the $MODULE$ of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** $TROLLTECH_DUAL_LICENSE$ ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ****************************************************************************/ diff --git a/src/plugins/qtscripteditor/parser/javascriptgrammar_p.h b/src/plugins/qtscripteditor/parser/javascriptgrammar_p.h index 3b51d8e4242..8e62d4abd06 100644 --- a/src/plugins/qtscripteditor/parser/javascriptgrammar_p.h +++ b/src/plugins/qtscripteditor/parser/javascriptgrammar_p.h @@ -2,41 +2,13 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the QtCore module of the Qt Toolkit. +** This file is part of the $MODULE$ of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** $TROLLTECH_DUAL_LICENSE$ ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ****************************************************************************/ diff --git a/src/plugins/qtscripteditor/parser/javascriptparser.cpp b/src/plugins/qtscripteditor/parser/javascriptparser.cpp index ac8eabf0954..4026a970ce1 100644 --- a/src/plugins/qtscripteditor/parser/javascriptparser.cpp +++ b/src/plugins/qtscripteditor/parser/javascriptparser.cpp @@ -132,6 +132,8 @@ bool JavaScriptParser::parse(JavaScriptEnginePrivate *driver) _Lcheck_token: if (yytoken == -1 && -TERMINAL_COUNT != action_index[action]) { + yyprevlloc = yylloc; + if (first_token == last_token) { yytoken = lexer->lex(); yylval = lexer->dval(); @@ -1097,7 +1099,7 @@ case 266: { const QString msg = QString::fromUtf8("Missing `;'"); diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, - yylloc.startLine, yylloc.startColumn, msg)); + yyprevlloc.startLine, yyprevlloc.startColumn, msg)); first_token = &token_buffer[0]; last_token = &token_buffer[1]; diff --git a/src/plugins/qtscripteditor/parser/javascriptparser_p.h b/src/plugins/qtscripteditor/parser/javascriptparser_p.h index d3b4e70208f..f3b16f54066 100644 --- a/src/plugins/qtscripteditor/parser/javascriptparser_p.h +++ b/src/plugins/qtscripteditor/parser/javascriptparser_p.h @@ -167,7 +167,7 @@ protected: { return sym_stack [tos + index - 1]; } inline Location &loc(int index) - { return location_stack [tos + index - 2]; } + { return location_stack [tos + index - 1]; } protected: int tos; @@ -187,6 +187,7 @@ protected: double yylval; Location yylloc; + Location yyprevlloc; SavedToken token_buffer[TOKEN_BUFFER_SIZE]; SavedToken *first_token; diff --git a/src/plugins/qtscripteditor/qtscripteditor.cpp b/src/plugins/qtscripteditor/qtscripteditor.cpp index 14e77fb40ed..701f6005291 100644 --- a/src/plugins/qtscripteditor/qtscripteditor.cpp +++ b/src/plugins/qtscripteditor/qtscripteditor.cpp @@ -246,16 +246,16 @@ void ScriptEditor::updateDocumentNow() QTextEdit::ExtraSelection sel; foreach (const JavaScriptParser::DiagnosticMessage &d, parser.diagnosticMessages()) { - if (d.isWarning()) - continue; - int line = d.line; int column = d.column; if (column == 0) column = 1; - sel.format = errorFormat; + if (d.isWarning()) + sel.format = warningFormat; + else + sel.format = errorFormat; QTextCursor c(document()->findBlockByNumber(line - 1)); sel.cursor = c; diff --git a/src/plugins/subversion/subversionplugin.cpp b/src/plugins/subversion/subversionplugin.cpp index 11ad9c2531e..a66ff436932 100644 --- a/src/plugins/subversion/subversionplugin.cpp +++ b/src/plugins/subversion/subversionplugin.cpp @@ -152,8 +152,8 @@ StatusList parseStatusOutput(const QString &output) if (line.size() > 8) { const QChar state = line.at(0); if (state == QLatin1Char('A') || state == QLatin1Char('D') || state == QLatin1Char('M')) { - const QString fileName = line.mid(7); - changeSet.push_back(SubversionSubmitEditor::StatusFilePair(QString(state), fileName)); + const QString fileName = line.mid(7); // Column 8 starting from svn 1.6 + changeSet.push_back(SubversionSubmitEditor::StatusFilePair(QString(state), fileName.trimmed())); } } diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index ca9a7faf363..5ef655e7997 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -2328,13 +2328,13 @@ void BaseTextEditor::slotUpdateRequest(const QRect &r, int dy) void BaseTextEditor::saveCurrentCursorPositionForNavigation() { d->m_lastCursorChangeWasInteresting = true; - d->m_tempState = saveState(); + d->m_tempNavigationState = saveState(); } void BaseTextEditor::slotCursorPositionChanged() { if (!d->m_contentsChanged && d->m_lastCursorChangeWasInteresting) { - Core::EditorManager::instance()->addCurrentPositionToNavigationHistory(d->m_tempState); + Core::EditorManager::instance()->addCurrentPositionToNavigationHistory(d->m_tempNavigationState); d->m_lastCursorChangeWasInteresting = false; } else if (d->m_contentsChanged) { saveCurrentCursorPositionForNavigation(); diff --git a/src/plugins/texteditor/basetexteditor_p.h b/src/plugins/texteditor/basetexteditor_p.h index bed889d5a14..e7a39515f8d 100644 --- a/src/plugins/texteditor/basetexteditor_p.h +++ b/src/plugins/texteditor/basetexteditor_p.h @@ -147,6 +147,7 @@ public: QRefCountPointer m_document; QByteArray m_tempState; + QByteArray m_tempNavigationState; QString m_displayName; bool m_parenthesesMatchingEnabled; diff --git a/src/plugins/texteditor/findinfiles.cpp b/src/plugins/texteditor/findinfiles.cpp index 33514269061..e73b04e6bd9 100644 --- a/src/plugins/texteditor/findinfiles.cpp +++ b/src/plugins/texteditor/findinfiles.cpp @@ -45,6 +45,11 @@ FindInFiles::FindInFiles(SearchResultWindow *resultWindow) { } +QString FindInFiles::id() const +{ + return "Files on Disk"; +} + QString FindInFiles::name() const { return tr("Files on Disk"); diff --git a/src/plugins/texteditor/findinfiles.h b/src/plugins/texteditor/findinfiles.h index 9fc8a2bc02d..0ec9b97d5bc 100644 --- a/src/plugins/texteditor/findinfiles.h +++ b/src/plugins/texteditor/findinfiles.h @@ -51,6 +51,7 @@ class FindInFiles : public BaseFileFind public: explicit FindInFiles(Find::SearchResultWindow *resultWindow); + QString id() const; QString name() const; QKeySequence defaultShortcut() const; void findAll(const QString &txt, QTextDocument::FindFlags findFlags); diff --git a/tests/manual/gdbdebugger/simple/app.cpp b/tests/manual/gdbdebugger/simple/app.cpp index 666d4c9a708..8b51d7f8b76 100644 --- a/tests/manual/gdbdebugger/simple/app.cpp +++ b/tests/manual/gdbdebugger/simple/app.cpp @@ -116,6 +116,12 @@ private: void testArray() { + char c[20]; + c[0] = 'a'; + c[1] = 'b'; + c[2] = 'c'; + c[3] = 'd'; + QString x[20]; x[0] = "a"; x[1] = "b"; @@ -135,6 +141,14 @@ void testQByteArray() QByteArray ba = "Hello"; ba += '"'; ba += "World"; + + const char *str1 = "\356"; + const char *str2 = "\xee"; + const char *str3 = "\\ee"; + QByteArray buf1( str1 ); + QByteArray buf2( str2 ); + QByteArray buf3( str3 ); + ba += char(0); ba += 1; ba += 2; @@ -399,6 +413,10 @@ void testQObject(int &argc, char *argv[]) QAction act("xxx", &app); QString t = act.text(); t += "y"; + t += "y"; + t += "y"; + t += "y"; + t += "y"; /* QObject ob(&app); diff --git a/tests/manual/gdbdebugger/simple/app/app.pro b/tests/manual/gdbdebugger/simple/app/app.pro index ab98e906f48..2210857b6a2 100644 --- a/tests/manual/gdbdebugger/simple/app/app.pro +++ b/tests/manual/gdbdebugger/simple/app/app.pro @@ -8,4 +8,4 @@ DESTDIR = .. SOURCES += ../app.cpp QT += network -mesage("this says ") +message("this says ")