diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp index 71ac3bb1e6ca47b297da0b22fe59c1ec1ec08d02..7484b29e34543e03c5b91b66958aa5f23a904927 100644 --- a/src/plugins/debugger/watchwindow.cpp +++ b/src/plugins/debugger/watchwindow.cpp @@ -122,6 +122,9 @@ WatchWindow::WatchWindow(Type type, QWidget *parent) setIndentation(indentation() * 9/10); setUniformRowHeights(true); setItemDelegate(new WatchDelegate(this)); + setDragEnabled(true); + setAcceptDrops(true); + setDropIndicatorShown(true); connect(this, SIGNAL(expanded(QModelIndex)), this, SLOT(expandNode(QModelIndex))); @@ -161,6 +164,35 @@ void WatchWindow::keyPressEvent(QKeyEvent *ev) QTreeView::keyPressEvent(ev); } +void WatchWindow::dragEnterEvent(QDragEnterEvent *ev) +{ + //QTreeView::dragEnterEvent(ev); + if (ev->mimeData()->hasFormat("text/plain")) { + ev->setDropAction(Qt::CopyAction); + ev->accept(); + } +} + +void WatchWindow::dragMoveEvent(QDragMoveEvent *ev) +{ + //QTreeView::dragMoveEvent(ev); + if (ev->mimeData()->hasFormat("text/plain")) { + ev->setDropAction(Qt::CopyAction); + ev->accept(); + } +} + +void WatchWindow::dropEvent(QDropEvent *ev) +{ + if (ev->mimeData()->hasFormat("text/plain")) { + theDebuggerAction(WatchExpression)->trigger(ev->mimeData()->text()); + //ev->acceptProposedAction(); + ev->setDropAction(Qt::CopyAction); + ev->accept(); + } + //QTreeView::dropEvent(ev); +} + void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) { QMenu menu; diff --git a/src/plugins/debugger/watchwindow.h b/src/plugins/debugger/watchwindow.h index 715507f8b16df9cef441cebd960581a11e02d9e4..adf4e06347e99268b29355a8822c527a2bd2f9e3 100644 --- a/src/plugins/debugger/watchwindow.h +++ b/src/plugins/debugger/watchwindow.h @@ -64,6 +64,10 @@ private: void keyPressEvent(QKeyEvent *ev); void contextMenuEvent(QContextMenuEvent *ev); + void dragEnterEvent(QDragEnterEvent *ev); + void dropEvent(QDropEvent *ev); + void dragMoveEvent(QDragMoveEvent *ev); + void editItem(const QModelIndex &idx); void reset(); /* reimpl */ diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index bca53785fafc368c2916f2eda1f087551926241e..7d611193001a6ce0ce76020a8549b36ce6366ca3 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -1216,21 +1216,6 @@ bool BaseTextEditor::lineSeparatorsAllowed() const return d->m_lineSeparatorsAllowed; } -void BaseTextEditor::setHighlightBlocks(bool b) -{ - if (d->m_highlightBlocks == b) - return; - d->m_highlightBlocks = b; - d->extraAreaHighlightCollapseBlockNumber = -1; - _q_highlightBlocks(); -} - -bool BaseTextEditor::highlightBlocks() const -{ - return d->m_highlightBlocks; -} - - void BaseTextEditor::setCodeFoldingVisible(bool b) { d->m_codeFoldingVisible = b && d->m_codeFoldingSupported; @@ -1293,7 +1278,6 @@ BaseTextEditorPrivate::BaseTextEditorPrivate() m_marksVisible(false), m_codeFoldingVisible(false), m_codeFoldingSupported(false), - m_highlightBlocks(false), m_revisionsVisible(false), m_lineNumbersVisible(true), m_highlightCurrentLine(true), @@ -2498,7 +2482,7 @@ void BaseTextEditor::slotCursorPositionChanged() setExtraSelections(CurrentLineSelection, extraSelections); - if (d->m_highlightBlocks) { + if (d->m_displaySettings.m_highlightBlocks) { QTextCursor cursor = textCursor(); d->extraAreaHighlightCollapseBlockNumber = cursor.blockNumber(); d->extraAreaHighlightCollapseColumn = cursor.position() - cursor.block().position(); @@ -2633,7 +2617,7 @@ void BaseTextEditor::extraAreaMouseEvent(QMouseEvent *e) d->extraAreaHighlightCollapseBlockNumber = -1; d->extraAreaHighlightCollapseColumn = -1; - if (d->m_highlightBlocks) { + if (d->m_displaySettings.m_highlightBlocks) { QTextCursor cursor = textCursor(); d->extraAreaHighlightCollapseBlockNumber = cursor.blockNumber(); d->extraAreaHighlightCollapseColumn = cursor.position() - cursor.block().position(); @@ -3224,7 +3208,7 @@ bool TextBlockUserData::findPreviousOpenParenthesis(QTextCursor *cursor, bool se bool TextBlockUserData::findPreviousBlockOpenParenthesis(QTextCursor *cursor, bool checkStartPosition) { QTextBlock block = cursor->block(); - int position = cursor->position() + (checkStartPosition ? 1 : 0 ); + int position = cursor->position(); int ignore = 0; while (block.isValid()) { Parentheses parenList = TextEditDocumentLayout::parentheses(block); @@ -3234,9 +3218,12 @@ bool TextBlockUserData::findPreviousBlockOpenParenthesis(QTextCursor *cursor, bo if (paren.chr != QLatin1Char('{') && paren.chr != QLatin1Char('}') && paren.chr != QLatin1Char('+') && paren.chr != QLatin1Char('-')) continue; - if (block == cursor->block() && - (position - block.position() <= paren.pos + (paren.type == Parenthesis::Closed ? 1 : 0))) + if (block == cursor->block()) { + if (position - block.position() <= paren.pos + (paren.type == Parenthesis::Closed ? 1 : 0)) continue; + if (checkStartPosition && paren.type == Parenthesis::Opened && position == cursor->position()) + return true; + } if (paren.type == Parenthesis::Closed) { ++ignore; } else if (ignore > 0) { @@ -3389,7 +3376,7 @@ BaseTextEditorAnimator::BaseTextEditorAnimator(QObject *parent) :QObject(parent) { m_value = 0; - m_timeline = new QTimeLine(500, this); + m_timeline = new QTimeLine(256, this); m_timeline->setCurveShape(QTimeLine::SineCurve); connect(m_timeline, SIGNAL(valueChanged(qreal)), this, SLOT(step(qreal))); connect(m_timeline, SIGNAL(finished()), this, SLOT(deleteLater())); @@ -3410,7 +3397,7 @@ void BaseTextEditorAnimator::draw(QPainter *p, const QPointF &pos) { p->setPen(m_palette.text().color()); QFont f = m_font; - f.setPointSizeF(f.pointSizeF() * (1.0 + m_value)); + f.setPointSizeF(f.pointSizeF() * (1.0 + m_value/2)); QFontMetrics fm(f); int width = fm.width(m_text); QRectF r((m_size.width()-width)/2, (m_size.height() - fm.height())/2, width, fm.height()); @@ -3428,7 +3415,7 @@ bool BaseTextEditorAnimator::isRunning() const QRectF BaseTextEditorAnimator::rect() const { QFont f = m_font; - f.setPointSizeF(f.pointSizeF() * (1.0 + m_value)); + f.setPointSizeF(f.pointSizeF() * (1.0 + m_value/2)); QFontMetrics fm(f); int width = fm.width(m_text); return QRectF((m_size.width()-width)/2, (m_size.height() - fm.height())/2, width, fm.height()); @@ -3474,12 +3461,13 @@ void BaseTextEditor::_q_matchParentheses() sel.format = d->m_mismatchFormat; } else { -// if (d->m_formatRange) { -// sel.cursor = backwardMatch; -// sel.format = d->m_rangeFormat; -// extraSelections.append(sel); -// } - animatePosition = backwardMatch.selectionStart(); + if (d->m_displaySettings.m_animateMatchingParentheses) { + animatePosition = backwardMatch.selectionStart(); + } else if (d->m_formatRange) { + sel.cursor = backwardMatch; + sel.format = d->m_rangeFormat; + extraSelections.append(sel); + } sel.cursor = backwardMatch; sel.format = d->m_matchFormat; @@ -3501,13 +3489,13 @@ void BaseTextEditor::_q_matchParentheses() sel.format = d->m_mismatchFormat; } else { - animatePosition = forwardMatch.selectionEnd()-1; - -// if (d->m_formatRange) { -// sel.cursor = forwardMatch; -// sel.format = d->m_rangeFormat; -// extraSelections.append(sel); -// } + if (d->m_displaySettings.m_animateMatchingParentheses) { + animatePosition = forwardMatch.selectionEnd()-1; + } else if (d->m_formatRange) { + sel.cursor = forwardMatch; + sel.format = d->m_rangeFormat; + extraSelections.append(sel); + } sel.cursor = forwardMatch; sel.format = d->m_matchFormat; @@ -3535,7 +3523,7 @@ void BaseTextEditor::_q_matchParentheses() d->m_animator->setData(font(), pal, characterAt(d->m_animator->position())); connect(d->m_animator, SIGNAL(updateRequest(int,QRectF)), this, SLOT(_q_animateUpdate(int,QRectF))); - } + } } @@ -3550,7 +3538,7 @@ void BaseTextEditor::_q_highlightBlocks() QTextCursor cursor(block); if (d->extraAreaHighlightCollapseColumn >= 0) cursor.setPosition(cursor.position() + qMin(d->extraAreaHighlightCollapseColumn, - block.length())); + block.length()-1)); QTextCursor closeCursor; bool firstRun = true; while (TextBlockUserData::findPreviousBlockOpenParenthesis(&cursor, firstRun)) { @@ -3740,7 +3728,6 @@ void BaseTextEditor::setDisplaySettings(const DisplaySettings &ds) setVisibleWrapColumn(ds.m_showWrapColumn ? ds.m_wrapColumn : 0); setCodeFoldingVisible(ds.m_displayFoldingMarkers); setHighlightCurrentLine(ds.m_highlightCurrentLine); - setHighlightBlocks(ds.m_highlightBlocks); if (d->m_displaySettings.m_visualizeWhitespace != ds.m_visualizeWhitespace) { if (QSyntaxHighlighter *highlighter = baseTextDocument()->syntaxHighlighter()) diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h index 5ed1fc91b7a4d244980ba96f38b6c6c9641c4d3c..1c02c6ce4a679a0eb014874aa04ce3decda6b75e 100644 --- a/src/plugins/texteditor/basetexteditor.h +++ b/src/plugins/texteditor/basetexteditor.h @@ -310,9 +310,6 @@ public: void setHighlightCurrentLine(bool b); bool highlightCurrentLine() const; - void setHighlightBlocks(bool b); - bool highlightBlocks() const; - void setLineNumbersVisible(bool b); bool lineNumbersVisible() const; diff --git a/src/plugins/texteditor/basetexteditor_p.h b/src/plugins/texteditor/basetexteditor_p.h index 7d3f15402e64c282e65e07e4000abd46b2a13fe5..80422f88a61c5030b15f6dcc25573928f545801b 100644 --- a/src/plugins/texteditor/basetexteditor_p.h +++ b/src/plugins/texteditor/basetexteditor_p.h @@ -195,7 +195,6 @@ public: uint m_marksVisible : 1; uint m_codeFoldingVisible : 1; uint m_codeFoldingSupported : 1; - uint m_highlightBlocks : 1; uint m_revisionsVisible : 1; uint m_lineNumbersVisible : 1; uint m_highlightCurrentLine : 1; diff --git a/src/plugins/texteditor/displaysettings.cpp b/src/plugins/texteditor/displaysettings.cpp index 22b85d4f841870b4395ac9235c52166c1a0a66cf..b0273a2c887a264124f1a016dabb080cce93490e 100644 --- a/src/plugins/texteditor/displaysettings.cpp +++ b/src/plugins/texteditor/displaysettings.cpp @@ -42,6 +42,7 @@ static const char * const visualizeWhitespaceKey = "VisualizeWhitespace"; static const char * const displayFoldingMarkersKey = "DisplayFoldingMarkers"; static const char * const highlightCurrentLineKey = "HighlightCurrentLineKeyV2"; static const char * const highlightBlocksKey = "HighlightBlocksKey"; +static const char * const animateMatchingParenthesesKey= "AnimateMatchingParenthesesKey"; static const char * const groupPostfix = "DisplaySettings"; namespace TextEditor { @@ -54,7 +55,8 @@ DisplaySettings::DisplaySettings() : m_visualizeWhitespace(false), m_displayFoldingMarkers(true), m_highlightCurrentLine(false), - m_highlightBlocks(false) + m_highlightBlocks(false), + m_animateMatchingParentheses(true) { } @@ -72,6 +74,7 @@ void DisplaySettings::toSettings(const QString &category, QSettings *s) const s->setValue(QLatin1String(displayFoldingMarkersKey), m_displayFoldingMarkers); s->setValue(QLatin1String(highlightCurrentLineKey), m_highlightCurrentLine); s->setValue(QLatin1String(highlightBlocksKey), m_highlightBlocks); + s->setValue(QLatin1String(animateMatchingParenthesesKey), m_animateMatchingParentheses); s->endGroup(); } @@ -92,6 +95,7 @@ void DisplaySettings::fromSettings(const QString &category, const QSettings *s) m_displayFoldingMarkers = s->value(group + QLatin1String(displayFoldingMarkersKey), m_displayFoldingMarkers).toBool(); m_highlightCurrentLine = s->value(group + QLatin1String(highlightCurrentLineKey), m_highlightCurrentLine).toBool(); m_highlightBlocks = s->value(group + QLatin1String(highlightBlocksKey), m_highlightBlocks).toBool(); + m_animateMatchingParentheses = s->value(group + QLatin1String(animateMatchingParenthesesKey), m_animateMatchingParentheses).toBool(); } bool DisplaySettings::equals(const DisplaySettings &ds) const @@ -104,6 +108,7 @@ bool DisplaySettings::equals(const DisplaySettings &ds) const && m_displayFoldingMarkers == ds.m_displayFoldingMarkers && m_highlightCurrentLine == ds.m_highlightCurrentLine && m_highlightBlocks == ds.m_highlightBlocks + && m_animateMatchingParentheses == ds.m_animateMatchingParentheses ; } diff --git a/src/plugins/texteditor/displaysettings.h b/src/plugins/texteditor/displaysettings.h index 0601f905b9f5126108e7215d2593dfaf460bd27b..06a7d0fa381381458aba1f1780c490cdf49c6fa2 100644 --- a/src/plugins/texteditor/displaysettings.h +++ b/src/plugins/texteditor/displaysettings.h @@ -53,6 +53,7 @@ struct TEXTEDITOR_EXPORT DisplaySettings bool m_displayFoldingMarkers; bool m_highlightCurrentLine; bool m_highlightBlocks; + bool m_animateMatchingParentheses; bool equals(const DisplaySettings &ds) const; }; diff --git a/src/plugins/texteditor/displaysettingspage.cpp b/src/plugins/texteditor/displaysettingspage.cpp index b1ba03ce7fc1f7210e1cefcaa279aa35f3fa0758..ec7ae6a221093855a563e6512a92181ec4a3c2ce 100644 --- a/src/plugins/texteditor/displaysettingspage.cpp +++ b/src/plugins/texteditor/displaysettingspage.cpp @@ -123,6 +123,7 @@ void DisplaySettingsPage::settingsFromUI(DisplaySettings &displaySettings) const displaySettings.m_displayFoldingMarkers = m_d->m_page.displayFoldingMarkers->isChecked(); displaySettings.m_highlightCurrentLine = m_d->m_page.highlightCurrentLine->isChecked(); displaySettings.m_highlightBlocks = m_d->m_page.highlightBlocks->isChecked(); + displaySettings.m_animateMatchingParentheses= m_d->m_page.animateMatchingParentheses->isChecked(); } void DisplaySettingsPage::settingsToUI() @@ -136,6 +137,7 @@ void DisplaySettingsPage::settingsToUI() m_d->m_page.displayFoldingMarkers->setChecked(displaySettings.m_displayFoldingMarkers); m_d->m_page.highlightCurrentLine->setChecked(displaySettings.m_highlightCurrentLine); m_d->m_page.highlightBlocks->setChecked(displaySettings.m_highlightBlocks); + m_d->m_page.animateMatchingParentheses->setChecked(displaySettings.m_animateMatchingParentheses); } DisplaySettings DisplaySettingsPage::displaySettings() const diff --git a/src/plugins/texteditor/displaysettingspage.ui b/src/plugins/texteditor/displaysettingspage.ui index eb6caa2a211211da04833604f47d01cc07f83fbe..5524172fcfb3471dc64561f483e2ffa2afad08c5 100644 --- a/src/plugins/texteditor/displaysettingspage.ui +++ b/src/plugins/texteditor/displaysettingspage.ui @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>381</width> - <height>279</height> + <height>302</height> </rect> </property> <property name="windowTitle"> @@ -28,7 +28,7 @@ </spacer> </item> <item row="1" column="0"> - <widget class="QGroupBox" name="groupBox"> + <widget class="QGroupBox" name="groupBoxDisplay"> <property name="title"> <string>Display</string> </property> @@ -71,11 +71,18 @@ </property> </widget> </item> + <item row="5" column="0"> + <widget class="QCheckBox" name="animateMatchingParentheses"> + <property name="text"> + <string>Animate matching parentheses</string> + </property> + </widget> + </item> </layout> </widget> </item> <item row="0" column="0"> - <widget class="QGroupBox" name="groupBoxDisplaySettings"> + <widget class="QGroupBox" name="groupBoxText"> <property name="title"> <string>Text Wrapping</string> </property>