| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | /****************************************************************************
 | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2015-01-14 18:07:15 +01:00
										 |  |  | ** Copyright (C) 2015 The Qt Company Ltd. | 
					
						
							|  |  |  | ** Contact: http://www.qt.io/licensing
 | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | ** This file is part of Qt Creator. | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | ** Commercial License Usage | 
					
						
							|  |  |  | ** Licensees holding valid commercial Qt licenses may use this file in | 
					
						
							|  |  |  | ** accordance with the commercial license agreement provided with the | 
					
						
							|  |  |  | ** Software or, alternatively, in accordance with the terms contained in | 
					
						
							| 
									
										
										
										
											2015-01-14 18:07:15 +01:00
										 |  |  | ** a written agreement between you and The Qt Company.  For licensing terms and | 
					
						
							|  |  |  | ** conditions see http://www.qt.io/terms-conditions.  For further information
 | 
					
						
							| 
									
										
										
										
											2014-10-01 13:21:18 +02:00
										 |  |  | ** use the contact form at http://www.qt.io/contact-us.
 | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | ** | 
					
						
							|  |  |  | ** GNU Lesser General Public License Usage | 
					
						
							| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
					
						
							| 
									
										
										
										
											2014-10-01 13:21:18 +02:00
										 |  |  | ** General Public License version 2.1 or version 3 as published by the Free | 
					
						
							|  |  |  | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | 
					
						
							|  |  |  | ** LICENSE.LGPLv3 included in the packaging of this file.  Please review the | 
					
						
							|  |  |  | ** following information to ensure the GNU Lesser General Public License | 
					
						
							|  |  |  | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
 | 
					
						
							|  |  |  | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 | 
					
						
							| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2015-01-14 18:07:15 +01:00
										 |  |  | ** In addition, as a special exception, The Qt Company gives you certain additional | 
					
						
							|  |  |  | ** rights.  These rights are described in The Qt Company LGPL Exception | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | 
					
						
							|  |  |  | ** | 
					
						
							| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | ****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "debuggertooltipmanager.h"
 | 
					
						
							| 
									
										
										
										
											2012-05-18 02:28:41 +02:00
										 |  |  | #include "debuggerinternalconstants.h"
 | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | #include "debuggerengine.h"
 | 
					
						
							| 
									
										
										
										
											2015-02-26 15:29:28 +01:00
										 |  |  | #include "debuggerprotocol.h"
 | 
					
						
							| 
									
										
										
										
											2011-02-17 10:08:57 +01:00
										 |  |  | #include "debuggeractions.h"
 | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | #include "stackhandler.h"
 | 
					
						
							|  |  |  | #include "debuggercore.h"
 | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  | #include "watchhandler.h"
 | 
					
						
							|  |  |  | #include "watchwindow.h"
 | 
					
						
							|  |  |  | #include "sourceutils.h"
 | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <coreplugin/icore.h>
 | 
					
						
							| 
									
										
										
										
											2011-02-21 16:45:07 +01:00
										 |  |  | #include <coreplugin/coreconstants.h>
 | 
					
						
							| 
									
										
										
										
											2013-07-09 12:14:33 +02:00
										 |  |  | #include <coreplugin/editormanager/documentmodel.h>
 | 
					
						
							| 
									
										
										
										
											2015-02-26 13:22:35 +01:00
										 |  |  | #include <coreplugin/editormanager/editormanager.h>
 | 
					
						
							| 
									
										
										
										
											2015-03-06 13:36:42 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <cpptools/cppprojectfile.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-26 09:14:03 +02:00
										 |  |  | #include <texteditor/texteditor.h>
 | 
					
						
							| 
									
										
										
										
											2015-02-26 13:22:35 +01:00
										 |  |  | #include <texteditor/textdocument.h>
 | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-10 15:07:17 +01:00
										 |  |  | #include <utils/tooltip/tooltip.h>
 | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  | #include <utils/treemodel.h>
 | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | #include <utils/qtcassert.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  | #include <QAbstractItemModel>
 | 
					
						
							| 
									
										
										
										
											2012-02-15 10:42:41 +01:00
										 |  |  | #include <QApplication>
 | 
					
						
							| 
									
										
										
										
											2014-07-08 18:16:54 +02:00
										 |  |  | #include <QClipboard>
 | 
					
						
							|  |  |  | #include <QDebug>
 | 
					
						
							| 
									
										
										
										
											2012-02-15 10:42:41 +01:00
										 |  |  | #include <QDesktopWidget>
 | 
					
						
							| 
									
										
										
										
											2014-11-14 13:42:51 +01:00
										 |  |  | #include <QFileInfo>
 | 
					
						
							| 
									
										
										
										
											2014-07-08 18:16:54 +02:00
										 |  |  | #include <QLabel>
 | 
					
						
							| 
									
										
										
										
											2012-02-15 10:42:41 +01:00
										 |  |  | #include <QScrollBar>
 | 
					
						
							|  |  |  | #include <QSortFilterProxyModel>
 | 
					
						
							|  |  |  | #include <QStack>
 | 
					
						
							| 
									
										
										
										
											2014-07-08 18:16:54 +02:00
										 |  |  | #include <QStandardItemModel>
 | 
					
						
							|  |  |  | #include <QToolBar>
 | 
					
						
							|  |  |  | #include <QToolButton>
 | 
					
						
							|  |  |  | #include <QVBoxLayout>
 | 
					
						
							|  |  |  | #include <QXmlStreamReader>
 | 
					
						
							|  |  |  | #include <QXmlStreamWriter>
 | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-22 18:02:29 +01:00
										 |  |  | using namespace Core; | 
					
						
							|  |  |  | using namespace TextEditor; | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  | using namespace Utils; | 
					
						
							| 
									
										
										
										
											2011-02-22 18:02:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-07 13:50:09 +01:00
										 |  |  | namespace Debugger { | 
					
						
							|  |  |  | namespace Internal { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  | //#define DEBUG(x) qDebug() << x
 | 
					
						
							|  |  |  | #define DEBUG(x)
 | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | // Expire tooltips after n days on (no longer load them) in order
 | 
					
						
							|  |  |  | // to avoid them piling up.
 | 
					
						
							|  |  |  | enum { toolTipsExpiryDays = 6 }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-07 13:50:09 +01:00
										 |  |  | const char sessionSettingsKeyC[] = "DebuggerToolTips"; | 
					
						
							|  |  |  | const char sessionDocumentC[] = "DebuggerToolTips"; | 
					
						
							|  |  |  | const char sessionVersionAttributeC[] = "version"; | 
					
						
							|  |  |  | const char toolTipElementC[] = "DebuggerToolTip"; | 
					
						
							| 
									
										
										
										
											2014-11-15 12:13:08 +01:00
										 |  |  | //const char toolTipClassAttributeC[] = "class";
 | 
					
						
							| 
									
										
										
										
											2014-11-07 13:50:09 +01:00
										 |  |  | const char fileNameAttributeC[] = "name"; | 
					
						
							|  |  |  | const char functionAttributeC[] = "function"; | 
					
						
							|  |  |  | const char textPositionAttributeC[] = "position"; | 
					
						
							|  |  |  | const char textLineAttributeC[] = "line"; | 
					
						
							|  |  |  | const char textColumnAttributeC[] = "column"; | 
					
						
							|  |  |  | const char offsetXAttributeC[] = "offset_x"; | 
					
						
							|  |  |  | const char offsetYAttributeC[] = "offset_y"; | 
					
						
							|  |  |  | const char engineTypeAttributeC[] = "engine"; | 
					
						
							|  |  |  | const char dateAttributeC[] = "date"; | 
					
						
							|  |  |  | const char treeElementC[] = "tree"; | 
					
						
							|  |  |  | const char treeExpressionAttributeC[] = "expression"; | 
					
						
							|  |  |  | const char treeInameAttributeC[] = "iname"; | 
					
						
							| 
									
										
										
										
											2015-02-10 09:07:47 +01:00
										 |  |  | // const char modelElementC[] = "model";
 | 
					
						
							|  |  |  | // const char modelColumnCountAttributeC[] = "columncount";
 | 
					
						
							|  |  |  | // const char modelRowElementC[] = "row";
 | 
					
						
							| 
									
										
										
										
											2014-11-07 13:50:09 +01:00
										 |  |  | const char modelItemElementC[] = "item"; | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  | static void purgeClosedToolTips(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class DebuggerToolTipHolder; | 
					
						
							| 
									
										
										
										
											2015-03-23 17:25:04 +01:00
										 |  |  | static QVector<DebuggerToolTipHolder *> m_tooltips; | 
					
						
							|  |  |  | static bool m_debugModeActive; | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | // Forward a stream reader across end elements looking for the
 | 
					
						
							|  |  |  | // next start element of a desired type.
 | 
					
						
							| 
									
										
										
										
											2011-02-22 18:02:29 +01:00
										 |  |  | static bool readStartElement(QXmlStreamReader &r, const char *name) | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2011-02-22 18:02:29 +01:00
										 |  |  |     while (r.tokenType() != QXmlStreamReader::StartElement | 
					
						
							|  |  |  |             || r.name() != QLatin1String(name)) | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  |         switch (r.readNext()) { | 
					
						
							|  |  |  |         case QXmlStreamReader::EndDocument: | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         case QXmlStreamReader::NoToken: | 
					
						
							|  |  |  |         case QXmlStreamReader::Invalid: | 
					
						
							|  |  |  |             qWarning("'%s'/'%s' encountered while looking for start element '%s'.", | 
					
						
							| 
									
										
										
										
											2011-02-22 18:02:29 +01:00
										 |  |  |                     qPrintable(r.tokenString()), | 
					
						
							|  |  |  |                     qPrintable(r.name().toString()), name); | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  |             return false; | 
					
						
							|  |  |  |         default: | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  | // A label that can be dragged to drag something else.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-27 11:02:57 +02:00
										 |  |  | class DraggableLabel : public QLabel | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  |     explicit DraggableLabel(QWidget *target) | 
					
						
							|  |  |  |         : m_target(target), m_moveStartPos(-1, -1), active(false) | 
					
						
							|  |  |  |     {} | 
					
						
							| 
									
										
										
										
											2011-05-27 11:02:57 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  |     void mousePressEvent(QMouseEvent *event); | 
					
						
							|  |  |  |     void mouseReleaseEvent(QMouseEvent *event); | 
					
						
							|  |  |  |     void mouseMoveEvent(QMouseEvent *event); | 
					
						
							| 
									
										
										
										
											2011-05-27 11:02:57 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  | public: | 
					
						
							|  |  |  |     QWidget *m_target; | 
					
						
							| 
									
										
										
										
											2011-05-27 11:02:57 +02:00
										 |  |  |     QPoint m_moveStartPos; | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  |     QPoint m_offset; | 
					
						
							|  |  |  |     bool active; | 
					
						
							| 
									
										
										
										
											2011-05-27 11:02:57 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void DraggableLabel::mousePressEvent(QMouseEvent * event) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  |     if (active && event->button() == Qt::LeftButton) { | 
					
						
							| 
									
										
										
										
											2011-05-27 11:02:57 +02:00
										 |  |  |         m_moveStartPos = event->globalPos(); | 
					
						
							|  |  |  |         event->accept(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     QLabel::mousePressEvent(event); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void DraggableLabel::mouseReleaseEvent(QMouseEvent * event) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  |     if (active && event->button() == Qt::LeftButton) | 
					
						
							| 
									
										
										
										
											2011-05-27 11:02:57 +02:00
										 |  |  |         m_moveStartPos = QPoint(-1, -1); | 
					
						
							|  |  |  |     QLabel::mouseReleaseEvent(event); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void DraggableLabel::mouseMoveEvent(QMouseEvent * event) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  |     if (active && (event->buttons() & Qt::LeftButton)) { | 
					
						
							| 
									
										
										
										
											2011-05-27 11:02:57 +02:00
										 |  |  |         if (m_moveStartPos != QPoint(-1, -1)) { | 
					
						
							|  |  |  |             const QPoint newPos = event->globalPos(); | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  |             const QPoint offset = newPos - m_moveStartPos; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             m_target->move(m_target->pos() + offset); | 
					
						
							|  |  |  |             m_offset += offset; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-27 11:02:57 +02:00
										 |  |  |             m_moveStartPos = newPos; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         event->accept(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     QLabel::mouseMoveEvent(event); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  | /////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // ToolTipWatchItem
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | /////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  | class ToolTipWatchItem : public Utils::TreeItem | 
					
						
							| 
									
										
										
										
											2011-02-22 18:02:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |     ToolTipWatchItem() : expandable(false) {} | 
					
						
							|  |  |  |     ToolTipWatchItem(WatchItem *item); | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |     bool hasChildren() const { return expandable; } | 
					
						
							| 
									
										
										
										
											2015-04-22 14:49:14 +02:00
										 |  |  |     bool canFetchMore() const { return childCount() == 0 && expandable && model(); } | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |     void fetchMore() {} | 
					
						
							|  |  |  |     QVariant data(int column, int role) const; | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |     QString name; | 
					
						
							|  |  |  |     QString value; | 
					
						
							|  |  |  |     QString type; | 
					
						
							| 
									
										
										
										
											2015-02-24 18:51:28 +01:00
										 |  |  |     QString expression; | 
					
						
							| 
									
										
										
										
											2015-03-16 13:14:28 +01:00
										 |  |  |     QColor valueColor; | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |     bool expandable; | 
					
						
							|  |  |  |     QByteArray iname; | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  | ToolTipWatchItem::ToolTipWatchItem(WatchItem *item) | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |     name = item->displayName(); | 
					
						
							|  |  |  |     value = item->displayValue(); | 
					
						
							|  |  |  |     type = item->displayType(); | 
					
						
							| 
									
										
										
										
											2015-03-19 12:42:53 +01:00
										 |  |  |     iname = item->iname; | 
					
						
							| 
									
										
										
										
											2015-04-15 18:48:32 +02:00
										 |  |  |     valueColor = item->valueColor(1); | 
					
						
							| 
									
										
										
										
											2015-03-19 12:42:53 +01:00
										 |  |  |     expandable = item->hasChildren(); | 
					
						
							| 
									
										
										
										
											2015-02-24 18:51:28 +01:00
										 |  |  |     expression = item->expression(); | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |     foreach (TreeItem *child, item->children()) | 
					
						
							|  |  |  |         appendChild(new ToolTipWatchItem(static_cast<WatchItem *>(child))); | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  | /////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // ToolTipModel
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | /////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  | class ToolTipModel : public TreeModel | 
					
						
							| 
									
										
										
										
											2011-02-22 18:02:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |     ToolTipModel() | 
					
						
							| 
									
										
										
										
											2011-02-14 09:40:43 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |         QStringList headers; | 
					
						
							| 
									
										
										
										
											2015-03-23 12:41:06 +03:00
										 |  |  |         headers.append(DebuggerToolTipManager::tr("Name")); | 
					
						
							|  |  |  |         headers.append(DebuggerToolTipManager::tr("Value")); | 
					
						
							|  |  |  |         headers.append(DebuggerToolTipManager::tr("Type")); | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |         setHeader(headers); | 
					
						
							|  |  |  |         m_enabled = true; | 
					
						
							|  |  |  |         auto item = new ToolTipWatchItem; | 
					
						
							|  |  |  |         item->expandable = true; | 
					
						
							|  |  |  |         setRootItem(item); | 
					
						
							| 
									
										
										
										
											2011-02-14 09:40:43 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |     void expandNode(const QModelIndex &idx) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         m_expandedINames.insert(idx.data(LocalsINameRole).toByteArray()); | 
					
						
							|  |  |  |         if (canFetchMore(idx)) | 
					
						
							|  |  |  |             fetchMore(idx); | 
					
						
							| 
									
										
										
										
											2011-02-14 09:40:43 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |     void collapseNode(const QModelIndex &idx) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         m_expandedINames.remove(idx.data(LocalsINameRole).toByteArray()); | 
					
						
							| 
									
										
										
										
											2011-02-14 09:40:43 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |     void fetchMore(const QModelIndex &idx) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (!idx.isValid()) | 
					
						
							|  |  |  |             return; | 
					
						
							| 
									
										
										
										
											2015-04-22 12:37:39 +02:00
										 |  |  |         auto item = dynamic_cast<ToolTipWatchItem *>(itemForIndex(idx)); | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |         if (!item) | 
					
						
							|  |  |  |             return; | 
					
						
							|  |  |  |         QByteArray iname = item->iname; | 
					
						
							|  |  |  |         if (!m_engine) | 
					
						
							|  |  |  |             return; | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |         WatchItem *it = m_engine->watchHandler()->findItem(iname); | 
					
						
							|  |  |  |         QTC_ASSERT(it, return); | 
					
						
							|  |  |  |         it->fetchMore(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-07-08 18:16:54 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |     void restoreTreeModel(QXmlStreamReader &r); | 
					
						
							| 
									
										
										
										
											2014-07-08 18:16:54 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |     QPointer<DebuggerEngine> m_engine; | 
					
						
							|  |  |  |     QSet<QByteArray> m_expandedINames; | 
					
						
							|  |  |  |     bool m_enabled; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2014-07-08 18:16:54 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  | QVariant ToolTipWatchItem::data(int column, int role) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     switch (role) { | 
					
						
							|  |  |  |         case Qt::DisplayRole: { | 
					
						
							|  |  |  |             switch (column) { | 
					
						
							|  |  |  |                 case 0: | 
					
						
							|  |  |  |                     return name; | 
					
						
							|  |  |  |                 case 1: | 
					
						
							|  |  |  |                     return value; | 
					
						
							|  |  |  |                 case 2: | 
					
						
							|  |  |  |                     return type; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2014-07-08 18:16:54 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |         case LocalsINameRole: | 
					
						
							|  |  |  |             return iname; | 
					
						
							| 
									
										
										
										
											2014-07-08 18:16:54 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |         case Qt::ForegroundRole: | 
					
						
							|  |  |  |             if (model() && static_cast<ToolTipModel *>(model())->m_enabled) { | 
					
						
							|  |  |  |                 if (column == 1) | 
					
						
							| 
									
										
										
										
											2015-03-16 13:14:28 +01:00
										 |  |  |                     return valueColor; | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |                 return QVariant(); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             return QColor(140, 140, 140); | 
					
						
							| 
									
										
										
										
											2014-07-08 18:16:54 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |         default: | 
					
						
							|  |  |  |             break; | 
					
						
							| 
									
										
										
										
											2014-07-08 18:16:54 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |     return QVariant(); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2014-07-08 18:16:54 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  | void ToolTipModel::restoreTreeModel(QXmlStreamReader &r) | 
					
						
							| 
									
										
										
										
											2011-02-22 18:02:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |     Q_UNUSED(r); | 
					
						
							|  |  |  | #if 0
 | 
					
						
							|  |  |  | // Helper for building a QStandardItemModel of a tree form (see TreeModelVisitor).
 | 
					
						
							|  |  |  | // The recursion/building is based on the scheme: \code
 | 
					
						
							|  |  |  | // <row><item1><item2>
 | 
					
						
							|  |  |  | //     <row><item11><item12></row>
 | 
					
						
							|  |  |  | // </row>
 | 
					
						
							|  |  |  | // \endcode
 | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |     bool withinModel = true; | 
					
						
							|  |  |  |     while (withinModel && !r.atEnd()) { | 
					
						
							|  |  |  |         const QXmlStreamReader::TokenType token = r.readNext(); | 
					
						
							|  |  |  |         switch (token) { | 
					
						
							|  |  |  |         case QXmlStreamReader::StartElement: { | 
					
						
							|  |  |  |             const QStringRef element = r.name(); | 
					
						
							|  |  |  |             // Root model element with column count.
 | 
					
						
							|  |  |  |             if (element == QLatin1String(modelElementC)) { | 
					
						
							|  |  |  |                 if (const int cc = r.attributes().value(QLatin1String(modelColumnCountAttributeC)).toString().toInt()) | 
					
						
							|  |  |  |                     columnCount = cc; | 
					
						
							|  |  |  |                 m->setColumnCount(columnCount); | 
					
						
							|  |  |  |             } else if (element == QLatin1String(modelRowElementC)) { | 
					
						
							|  |  |  |                 builder.startRow(); | 
					
						
							|  |  |  |             } else if (element == QLatin1String(modelItemElementC)) { | 
					
						
							|  |  |  |                 builder.addItem(r.readElementText()); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |             break; // StartElement
 | 
					
						
							|  |  |  |         case QXmlStreamReader::EndElement: { | 
					
						
							|  |  |  |             const QStringRef element = r.name(); | 
					
						
							|  |  |  |             // Row closing: pop off parent.
 | 
					
						
							|  |  |  |             if (element == QLatin1String(modelRowElementC)) | 
					
						
							|  |  |  |                 builder.endRow(); | 
					
						
							|  |  |  |             else if (element == QLatin1String(modelElementC)) | 
					
						
							|  |  |  |                 withinModel = false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |             break; // EndElement
 | 
					
						
							|  |  |  |         default: | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         } // switch
 | 
					
						
							|  |  |  |     } // while
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  | /*!
 | 
					
						
							|  |  |  |     \class Debugger::Internal::DebuggerToolTipTreeView | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     \brief The DebuggerToolTipTreeView class is a treeview that adapts its size | 
					
						
							|  |  |  |     to the model contents (also while expanding) | 
					
						
							|  |  |  |     to be used within DebuggerTreeViewToolTipWidget. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
										
											2014-10-22 11:36:34 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-10 17:11:43 +01:00
										 |  |  | class DebuggerToolTipTreeView : public QTreeView | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2015-02-24 18:51:28 +01:00
										 |  |  |     explicit DebuggerToolTipTreeView(QWidget *parent) | 
					
						
							|  |  |  |         : QTreeView(parent) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         setHeaderHidden(true); | 
					
						
							|  |  |  |         setEditTriggers(NoEditTriggers); | 
					
						
							|  |  |  |         setUniformRowHeights(true); | 
					
						
							|  |  |  |         setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | 
					
						
							|  |  |  |         setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  |     QSize sizeHint() const { return m_size; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-24 18:51:28 +01:00
										 |  |  |     int sizeHintForColumn(int column) const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return QTreeView::sizeHintForColumn(column); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-24 18:51:28 +01:00
										 |  |  |     int computeHeight(const QModelIndex &index) const | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2015-02-24 18:51:28 +01:00
										 |  |  |         int s = rowHeight(index); | 
					
						
							|  |  |  |         const int rowCount = model()->rowCount(index); | 
					
						
							|  |  |  |         for (int i = 0; i < rowCount; ++i) | 
					
						
							|  |  |  |             s += computeHeight(model()->index(i, 0, index)); | 
					
						
							|  |  |  |         return s; | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  |     QSize m_size; | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-08 18:16:54 +02:00
										 |  |  | /////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // DebuggerToolTipWidget
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | /////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class DebuggerToolTipWidget : public QWidget | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |     DebuggerToolTipWidget(); | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-24 18:51:28 +01:00
										 |  |  |     ~DebuggerToolTipWidget() { DEBUG("DESTROY DEBUGGERTOOLTIP WIDGET"); } | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     void closeEvent(QCloseEvent *) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         DEBUG("CLOSE DEBUGGERTOOLTIP WIDGET"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     void enterEvent(QEvent *) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         DEBUG("ENTER DEBUGGERTOOLTIP WIDGET"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     void leaveEvent(QEvent *) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         DEBUG("LEAVE DEBUGGERTOOLTIP WIDGET"); | 
					
						
							|  |  |  |         if (BaseTextEditor *editor = BaseTextEditor::currentTextEditor()) | 
					
						
							|  |  |  |             editor->editorWidget()->activateWindow(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     void pin() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (isPinned) | 
					
						
							|  |  |  |             return; | 
					
						
							|  |  |  |         isPinned = true; | 
					
						
							|  |  |  |         pinButton->setIcon(style()->standardIcon(QStyle::SP_DockWidgetCloseButton)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (parentWidget()) { | 
					
						
							|  |  |  |             // We are currently within a text editor tooltip:
 | 
					
						
							|  |  |  |             // Rip out of parent widget and re-show as a tooltip
 | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |             ToolTip::pinToolTip(this, ICore::mainWindow()); | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |         } else { | 
					
						
							|  |  |  |             // We have just be restored from session data.
 | 
					
						
							|  |  |  |             setWindowFlags(Qt::ToolTip); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         titleLabel->active = true; // User can now drag
 | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-07-08 18:16:54 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-24 18:51:28 +01:00
										 |  |  |     void computeSize(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     void setContents(ToolTipWatchItem *item) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         titleLabel->setText(item->expression); | 
					
						
							|  |  |  |         //treeView->setEnabled(true);
 | 
					
						
							|  |  |  |         model.m_enabled = true; | 
					
						
							|  |  |  |         if (item) { | 
					
						
							|  |  |  |             model.rootItem()->removeChildren(); | 
					
						
							|  |  |  |             model.rootItem()->appendChild(item); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         reexpand(QModelIndex()); | 
					
						
							|  |  |  |         computeSize(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     WatchHandler *watchHandler() const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return model.m_engine->watchHandler(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     void setEngine(DebuggerEngine *engine) { model.m_engine = engine; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     void reexpand(const QModelIndex &idx) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2015-04-22 12:37:39 +02:00
										 |  |  |         TreeItem *item = model.itemForIndex(idx); | 
					
						
							| 
									
										
										
										
											2015-02-24 18:51:28 +01:00
										 |  |  |         QTC_ASSERT(item, return); | 
					
						
							|  |  |  |         QByteArray iname = item->data(0, LocalsINameRole).toByteArray(); | 
					
						
							|  |  |  |         bool shouldExpand = model.m_expandedINames.contains(iname); | 
					
						
							|  |  |  |         if (shouldExpand) { | 
					
						
							|  |  |  |             if (!treeView->isExpanded(idx)) { | 
					
						
							|  |  |  |                 treeView->expand(idx); | 
					
						
							|  |  |  |                 for (int i = 0, n = model.rowCount(idx); i != n; ++i) { | 
					
						
							|  |  |  |                     QModelIndex idx1 = model.index(i, 0, idx); | 
					
						
							|  |  |  |                     reexpand(idx1); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             if (treeView->isExpanded(idx)) | 
					
						
							|  |  |  |                 treeView->collapse(idx); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  | public: | 
					
						
							|  |  |  |     bool isPinned; | 
					
						
							|  |  |  |     QToolButton *pinButton; | 
					
						
							|  |  |  |     DraggableLabel *titleLabel; | 
					
						
							|  |  |  |     DebuggerToolTipTreeView *treeView; | 
					
						
							| 
									
										
										
										
											2015-02-24 18:51:28 +01:00
										 |  |  |     ToolTipModel model; | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2014-07-08 18:16:54 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  | DebuggerToolTipWidget::DebuggerToolTipWidget() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     setAttribute(Qt::WA_DeleteOnClose); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     isPinned = false; | 
					
						
							|  |  |  |     const QIcon pinIcon(QLatin1String(":/debugger/images/pin.xpm")); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     pinButton = new QToolButton; | 
					
						
							|  |  |  |     pinButton->setIcon(pinIcon); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     auto copyButton = new QToolButton; | 
					
						
							| 
									
										
										
										
											2015-02-10 17:38:14 +01:00
										 |  |  |     copyButton->setToolTip(DebuggerToolTipManager::tr("Copy Contents to Clipboard")); | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |     copyButton->setIcon(QIcon(QLatin1String(Core::Constants::ICON_COPY))); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     titleLabel = new DraggableLabel(this); | 
					
						
							|  |  |  |     titleLabel->setMinimumWidth(40); // Ensure a draggable area even if text is empty.
 | 
					
						
							|  |  |  |     titleLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     auto toolBar = new QToolBar(this); | 
					
						
							|  |  |  |     toolBar->setProperty("_q_custom_style_disabled", QVariant(true)); | 
					
						
							|  |  |  |     const QList<QSize> pinIconSizes = pinIcon.availableSizes(); | 
					
						
							|  |  |  |     if (!pinIconSizes.isEmpty()) | 
					
						
							|  |  |  |         toolBar->setIconSize(pinIconSizes.front()); | 
					
						
							|  |  |  |     toolBar->addWidget(pinButton); | 
					
						
							|  |  |  |     toolBar->addWidget(copyButton); | 
					
						
							|  |  |  |     toolBar->addWidget(titleLabel); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     treeView = new DebuggerToolTipTreeView(this); | 
					
						
							|  |  |  |     treeView->setFocusPolicy(Qt::NoFocus); | 
					
						
							| 
									
										
										
										
											2015-02-24 18:51:28 +01:00
										 |  |  |     treeView->setModel(&model); | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto mainLayout = new QVBoxLayout(this); | 
					
						
							|  |  |  |     mainLayout->setSizeConstraint(QLayout::SetFixedSize); | 
					
						
							| 
									
										
										
										
											2015-02-10 17:11:43 +01:00
										 |  |  |     mainLayout->setContentsMargins(0, 0, 0, 0); | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |     mainLayout->addWidget(toolBar); | 
					
						
							|  |  |  |     mainLayout->addWidget(treeView); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     connect(copyButton, &QAbstractButton::clicked, [this] { | 
					
						
							|  |  |  |         QString text; | 
					
						
							|  |  |  |         QTextStream str(&text); | 
					
						
							| 
									
										
										
										
											2015-02-24 18:51:28 +01:00
										 |  |  |         model.rootItem()->walkTree([&str](TreeItem *item) { | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |             auto titem = static_cast<ToolTipWatchItem *>(item); | 
					
						
							|  |  |  |             str << QString(item->level(), QLatin1Char('\t')) | 
					
						
							|  |  |  |                 << titem->name << '\t' << titem->value << '\t' << titem->type << '\n'; | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |         QClipboard *clipboard = QApplication::clipboard(); | 
					
						
							|  |  |  |         clipboard->setText(text, QClipboard::Selection); | 
					
						
							|  |  |  |         clipboard->setText(text, QClipboard::Clipboard); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2015-02-24 18:51:28 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     connect(treeView, &QTreeView::expanded, &model, &ToolTipModel::expandNode); | 
					
						
							|  |  |  |     connect(treeView, &QTreeView::collapsed, &model, &ToolTipModel::collapseNode); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     connect(treeView, &QTreeView::collapsed, this, &DebuggerToolTipWidget::computeSize, | 
					
						
							|  |  |  |         Qt::QueuedConnection); | 
					
						
							|  |  |  |     connect(treeView, &QTreeView::expanded, this, &DebuggerToolTipWidget::computeSize, | 
					
						
							|  |  |  |         Qt::QueuedConnection); | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |     DEBUG("CREATE DEBUGGERTOOLTIP WIDGET"); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-24 18:51:28 +01:00
										 |  |  | void DebuggerToolTipWidget::computeSize() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     int columns = 30; // Decoration
 | 
					
						
							|  |  |  |     int rows = 0; | 
					
						
							|  |  |  |     bool rootDecorated = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     reexpand(model.index(0, 0, QModelIndex())); | 
					
						
							|  |  |  |     const int columnCount = model.columnCount(QModelIndex()); | 
					
						
							|  |  |  |     rootDecorated = model.rowCount() > 0; | 
					
						
							|  |  |  |     if (rootDecorated) { | 
					
						
							|  |  |  |         for (int i = 0; i < columnCount; ++i) { | 
					
						
							|  |  |  |             treeView->resizeColumnToContents(i); | 
					
						
							|  |  |  |             columns += treeView->sizeHintForColumn(i); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (columns < 100) | 
					
						
							|  |  |  |         columns = 100; // Prevent toolbar from shrinking when displaying 'Previous'
 | 
					
						
							|  |  |  |     rows += treeView->computeHeight(QModelIndex()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Fit tooltip to screen, showing/hiding scrollbars as needed.
 | 
					
						
							|  |  |  |     // Add a bit of space to account for tooltip border, and not
 | 
					
						
							|  |  |  |     // touch the border of the screen.
 | 
					
						
							|  |  |  |     QPoint pos(x(), y()); | 
					
						
							|  |  |  |     QTC_ASSERT(QApplication::desktop(), return); | 
					
						
							|  |  |  |     QRect desktopRect = QApplication::desktop()->availableGeometry(pos); | 
					
						
							|  |  |  |     const int maxWidth = desktopRect.right() - pos.x() - 5 - 5; | 
					
						
							|  |  |  |     const int maxHeight = desktopRect.bottom() - pos.y() - 5 - 5; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (columns > maxWidth) | 
					
						
							|  |  |  |         rows += treeView->horizontalScrollBar()->height(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (rows > maxHeight) { | 
					
						
							|  |  |  |         treeView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); | 
					
						
							|  |  |  |         rows = maxHeight; | 
					
						
							|  |  |  |         columns += treeView->verticalScrollBar()->width(); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         treeView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (columns > maxWidth) { | 
					
						
							|  |  |  |         treeView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); | 
					
						
							|  |  |  |         columns = maxWidth; | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         treeView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     treeView->m_size = QSize(columns + 5, rows + 5); | 
					
						
							|  |  |  |     treeView->setMinimumSize(treeView->m_size); | 
					
						
							|  |  |  |     treeView->setMaximumSize(treeView->m_size); | 
					
						
							|  |  |  |     treeView->setRootIsDecorated(rootDecorated); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  | /////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // DebuggerToolTipHolder
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | /////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-26 08:29:08 +01:00
										 |  |  | enum DebuggerTooltipState | 
					
						
							| 
									
										
										
										
											2014-11-15 17:08:22 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     New, // All new, widget not shown, not async (yet)
 | 
					
						
							|  |  |  |     PendingUnshown, // Widget not (yet) shown, async.
 | 
					
						
							|  |  |  |     PendingShown, // Widget shown, async
 | 
					
						
							| 
									
										
										
										
											2015-03-23 17:25:04 +01:00
										 |  |  |     Acquired, // Widget shown sync, engine attached
 | 
					
						
							| 
									
										
										
										
											2014-11-15 17:08:22 +01:00
										 |  |  |     Released // Widget shown, engine released
 | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-23 17:25:04 +01:00
										 |  |  | class DebuggerToolTipHolder | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     DebuggerToolTipHolder(const DebuggerToolTipContext &context); | 
					
						
							| 
									
										
										
										
											2015-03-23 17:25:04 +01:00
										 |  |  |     ~DebuggerToolTipHolder() { delete widget; } | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |     void acquireEngine(DebuggerEngine *engine); | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  |     void releaseEngine(); | 
					
						
							| 
									
										
										
										
											2014-07-08 18:16:54 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  |     void saveSessionData(QXmlStreamWriter &w) const; | 
					
						
							|  |  |  |     void handleStackFrameCompleted(const QString &frameFile, const QString &frameFunction); | 
					
						
							| 
									
										
										
										
											2014-07-08 18:16:54 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-07 13:50:09 +01:00
										 |  |  |     void positionShow(const TextEditorWidget *editorWidget); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |     void updateTooltip(DebuggerEngine *engine); | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-26 08:29:08 +01:00
										 |  |  |     void setState(DebuggerTooltipState newState); | 
					
						
							| 
									
										
										
										
											2014-11-15 17:08:22 +01:00
										 |  |  |     void destroy(); | 
					
						
							| 
									
										
										
										
											2014-07-08 18:16:54 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |     QPointer<DebuggerToolTipWidget> widget; | 
					
						
							|  |  |  |     QDate creationDate; | 
					
						
							|  |  |  |     DebuggerToolTipContext context; | 
					
						
							| 
									
										
										
										
											2015-02-26 08:29:08 +01:00
										 |  |  |     DebuggerTooltipState state; | 
					
						
							| 
									
										
										
										
											2014-07-08 18:16:54 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-07 15:57:19 +01:00
										 |  |  | static void hideAllToolTips() | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     purgeClosedToolTips(); | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |     foreach (const DebuggerToolTipHolder *tooltip, m_tooltips) | 
					
						
							|  |  |  |         tooltip->widget->hide(); | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | /*!
 | 
					
						
							| 
									
										
										
										
											2011-03-28 14:58:12 +02:00
										 |  |  |     \class Debugger::Internal::DebuggerToolTipContext | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-05 14:29:24 +02:00
										 |  |  |     \brief The DebuggerToolTipContext class specifies the file name and | 
					
						
							|  |  |  |     position where the tooltip is anchored. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Uses redundant position or line column information to detect whether | 
					
						
							|  |  |  |     the underlying file has been changed | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  |     on restoring. | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  | DebuggerToolTipContext::DebuggerToolTipContext() | 
					
						
							| 
									
										
										
										
											2015-03-06 13:36:42 +01:00
										 |  |  |     : position(0), line(0), column(0), scopeFromLine(0), scopeToLine(0), isCppEditor(true) | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-14 13:42:51 +01:00
										 |  |  | static bool filesMatch(const QString &file1, const QString &file2) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2015-05-21 12:49:02 +02:00
										 |  |  |     return FileName::fromString(QFileInfo(file1).canonicalFilePath()) | 
					
						
							|  |  |  |             == FileName::fromString(QFileInfo(file2).canonicalFilePath()); | 
					
						
							| 
									
										
										
										
											2014-11-14 13:42:51 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-15 13:33:40 +01:00
										 |  |  | bool DebuggerToolTipContext::matchesFrame(const StackFrame &frame) const | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-11-15 13:33:40 +01:00
										 |  |  |     return (fileName.isEmpty() || frame.file.isEmpty() || filesMatch(fileName, frame.file)) | 
					
						
							|  |  |  |             //&& (function.isEmpty() || frame.function.isEmpty() || function == frame.function);
 | 
					
						
							|  |  |  |             && (frame.line <= 0 || (scopeFromLine <= frame.line && frame.line <= scopeToLine)); | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool DebuggerToolTipContext::isSame(const DebuggerToolTipContext &other) const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2015-03-23 17:25:04 +01:00
										 |  |  |     return iname == other.iname | 
					
						
							|  |  |  |         && scopeFromLine == other.scopeFromLine | 
					
						
							|  |  |  |         && scopeToLine == other.scopeToLine | 
					
						
							|  |  |  |         && filesMatch(fileName, other.fileName); | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-13 15:28:56 +01:00
										 |  |  | void DebuggerToolTipContext::appendFormatRequest(DebuggerCommand *cmd) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     cmd->arg("expression", expression); | 
					
						
							|  |  |  |     cmd->arg("fileName", fileName); | 
					
						
							|  |  |  |     cmd->arg("iname", iname); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  | QString DebuggerToolTipContext::toolTip() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return DebuggerToolTipManager::tr("Expression %1 in function %2 from line %3 to %4") | 
					
						
							|  |  |  |             .arg(expression).arg(function).arg(scopeFromLine).arg(scopeToLine); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | QDebug operator<<(QDebug d, const DebuggerToolTipContext &c) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QDebug nsp = d.nospace(); | 
					
						
							| 
									
										
										
										
											2014-11-15 13:33:40 +01:00
										 |  |  |     nsp << c.fileName << '@' << c.line << ',' << c.column << " (" << c.position << ')' | 
					
						
							|  |  |  |         << "INAME: " << c.iname << " EXP: " << c.expression << " FUNCTION: " << c.function; | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  |     return d; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*!
 | 
					
						
							| 
									
										
										
										
											2011-05-27 11:02:57 +02:00
										 |  |  |     \class Debugger::Internal::DebuggerToolTipWidget | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-05 14:29:24 +02:00
										 |  |  |     \brief The DebuggerToolTipWidget class is a pinnable debugger tool tip | 
					
						
							|  |  |  |     widget. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     The debugger tooltip goes from the unpinned state (button | 
					
						
							| 
									
										
										
										
											2011-05-27 11:02:57 +02:00
										 |  |  |     showing 'Pin') to the pinned state (button showing 'Close'). | 
					
						
							|  |  |  |     It consists of a title toolbar and a vertical main layout. | 
					
						
							|  |  |  |     The widget has the ability to save/restore tree model contents to XML. | 
					
						
							|  |  |  |     With the engine acquired, it sets a filter model (by expression) on | 
					
						
							| 
									
										
										
										
											2012-05-09 13:45:55 +02:00
										 |  |  |     one of the engine's models (debuggerModel). | 
					
						
							| 
									
										
										
										
											2011-05-27 11:02:57 +02:00
										 |  |  |     On release, it serializes and restores the data to a QStandardItemModel | 
					
						
							|  |  |  |     (defaultModel) and displays that. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     It is associated with file name and position with functionality to | 
					
						
							| 
									
										
										
										
											2013-09-06 17:16:18 +02:00
										 |  |  |     acquire and release the engine. When the debugger stops at a file, all | 
					
						
							| 
									
										
										
										
											2011-05-27 11:02:57 +02:00
										 |  |  |     matching tooltips acquire the engine, that is, display the engine data. | 
					
						
							|  |  |  |     When continuing or switching away from the frame, the tooltips release the | 
					
						
							|  |  |  |     engine, that is, store the data internally and keep displaying them | 
					
						
							|  |  |  |     marked as 'previous'. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  |     When restoring the data from a session, all tooltips start in 'released' mode. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Stored tooltips expire after toolTipsExpiryDays while loading to prevent | 
					
						
							|  |  |  |     them accumulating. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     In addition, if the stored line number diverges too much from the current line | 
					
						
							|  |  |  |     number in positionShow(), the tooltip is also closed/discarded. | 
					
						
							| 
									
										
										
										
											2011-02-21 16:45:07 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     The widget is that is first shown by the TextEditor's tooltip | 
					
						
							|  |  |  |     class and typically closed by it unless the user pins it. | 
					
						
							|  |  |  |     In that case, it is removed from the tip's layout, added to the DebuggerToolTipManager's | 
					
						
							|  |  |  |     list of pinned tooltips and re-shown as a global tooltip widget. | 
					
						
							|  |  |  |     As the debugger stop and continues, it shows the debugger values or a copy | 
					
						
							|  |  |  |     of them. On closing or session changes, the contents it saved. | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  | DebuggerToolTipHolder::DebuggerToolTipHolder(const DebuggerToolTipContext &context_) | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |     widget = new DebuggerToolTipWidget; | 
					
						
							|  |  |  |     widget->setObjectName(QLatin1String("DebuggerTreeViewToolTipWidget: ") + QLatin1String(context_.iname)); | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |     context = context_; | 
					
						
							|  |  |  |     context.creationDate = QDate::currentDate(); | 
					
						
							| 
									
										
										
										
											2011-05-27 11:02:57 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |     state = New; | 
					
						
							| 
									
										
										
										
											2011-05-27 11:02:57 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |     QObject::connect(widget->pinButton, &QAbstractButton::clicked, [this] { | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |         if (widget->isPinned) | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |             widget->close(); | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |         else | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |             widget->pin(); | 
					
						
							| 
									
										
										
										
											2014-09-02 16:37:19 +02:00
										 |  |  |     }); | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-23 17:25:04 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-15 17:08:22 +01:00
										 |  |  | // This is called back from the engines after they populated the
 | 
					
						
							|  |  |  | // WatchModel. If the populating result from evaluation of this
 | 
					
						
							|  |  |  | // tooltip here, we are in "PendingUnshown" state (no Widget show yet),
 | 
					
						
							|  |  |  | // or "PendingShown" state (old widget reused).
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // If we are in "Acquired" or "Released", this is an update
 | 
					
						
							|  |  |  | // after normal WatchModel update.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  | void DebuggerToolTipHolder::updateTooltip(DebuggerEngine *engine) | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2015-02-24 18:51:28 +01:00
										 |  |  |     widget->setEngine(engine); | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (!engine) { | 
					
						
							|  |  |  |         setState(Released); | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     StackFrame frame = engine->stackHandler()->currentFrame(); | 
					
						
							| 
									
										
										
										
											2015-02-24 18:51:28 +01:00
										 |  |  |     WatchItem *item = engine->watchHandler()->findItem(context.iname); | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-13 15:28:56 +01:00
										 |  |  |     // FIXME: The engine should decide on whether it likes
 | 
					
						
							|  |  |  |     // the context.
 | 
					
						
							|  |  |  |     const bool sameFrame = context.matchesFrame(frame) | 
					
						
							|  |  |  |         || context.fileName.endsWith(QLatin1String(".py")); | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |     DEBUG("UPDATE TOOLTIP: STATE " << state << context.iname | 
					
						
							| 
									
										
										
										
											2014-11-15 12:13:08 +01:00
										 |  |  |           << "PINNED: " << widget->isPinned | 
					
						
							|  |  |  |           << "SHOW NEEDED: " << widget->isPinned | 
					
						
							|  |  |  |           << "SAME FRAME: " << sameFrame); | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-15 17:08:22 +01:00
										 |  |  |     if (state == PendingUnshown) { | 
					
						
							|  |  |  |         setState(PendingShown); | 
					
						
							| 
									
										
										
										
											2015-03-23 17:25:04 +01:00
										 |  |  |         ToolTip::show(context.mousePosition, widget, Internal::mainWindow()); | 
					
						
							| 
									
										
										
										
											2014-11-15 17:08:22 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-24 18:51:28 +01:00
										 |  |  |     if (item && sameFrame) { | 
					
						
							|  |  |  |         DEBUG("ACQUIRE ENGINE: STATE " << state); | 
					
						
							|  |  |  |         widget->setContents(new ToolTipWatchItem(item)); | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |         releaseEngine(); | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |     widget->titleLabel->setToolTip(context.toolTip()); | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2014-07-08 18:16:54 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-26 08:29:08 +01:00
										 |  |  | void DebuggerToolTipHolder::setState(DebuggerTooltipState newState) | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-11-15 17:08:22 +01:00
										 |  |  |     bool ok = (state == New && newState == PendingUnshown) | 
					
						
							| 
									
										
										
										
											2015-03-23 17:25:04 +01:00
										 |  |  |         || (state == New && newState == Acquired) | 
					
						
							| 
									
										
										
										
											2014-11-15 17:08:22 +01:00
										 |  |  |         || (state == PendingUnshown && newState == PendingShown) | 
					
						
							| 
									
										
										
										
											2015-03-23 17:25:04 +01:00
										 |  |  |         || newState == Released; | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     DEBUG("TRANSITION STATE FROM " << state << " TO " << newState); | 
					
						
							|  |  |  |     QTC_ASSERT(ok, qDebug() << "Unexpected tooltip state transition from " | 
					
						
							|  |  |  |                             << state << " to " << newState); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     state = newState; | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-15 17:08:22 +01:00
										 |  |  | void DebuggerToolTipHolder::destroy() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (widget) { | 
					
						
							|  |  |  |         widget->close(); | 
					
						
							|  |  |  |         widget = 0; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  | void DebuggerToolTipHolder::releaseEngine() | 
					
						
							| 
									
										
										
										
											2011-02-14 09:40:43 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2015-03-20 14:44:02 +01:00
										 |  |  |     DEBUG("RELEASE ENGINE: STATE " << state); | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |     if (state == Released) | 
					
						
							|  |  |  |         return; | 
					
						
							| 
									
										
										
										
											2015-03-20 14:44:02 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-23 17:25:04 +01:00
										 |  |  |     QTC_ASSERT(widget, return); | 
					
						
							| 
									
										
										
										
											2015-03-20 14:44:02 +01:00
										 |  |  |     if (state == PendingShown) { | 
					
						
							| 
									
										
										
										
											2015-03-23 17:25:04 +01:00
										 |  |  |         setState(Released); | 
					
						
							| 
									
										
										
										
											2015-03-20 14:44:02 +01:00
										 |  |  |         // This happens after hovering over something that looks roughly like
 | 
					
						
							|  |  |  |         // a valid expression but can't be resolved by the debugger backend.
 | 
					
						
							|  |  |  |         // (Out of scope items, keywords, ...)
 | 
					
						
							|  |  |  |         ToolTip::show(context.mousePosition, | 
					
						
							|  |  |  |                       DebuggerToolTipManager::tr("No valid expression"), | 
					
						
							|  |  |  |                       Internal::mainWindow()); | 
					
						
							|  |  |  |         widget->deleteLater(); | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |     setState(Released); | 
					
						
							| 
									
										
										
										
											2015-02-24 18:51:28 +01:00
										 |  |  |     widget->model.m_enabled = false; | 
					
						
							|  |  |  |     widget->model.layoutChanged(); | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |     widget->titleLabel->setText(DebuggerToolTipManager::tr("%1 (Previous)").arg(context.expression)); | 
					
						
							| 
									
										
										
										
											2011-02-14 09:40:43 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  | void DebuggerToolTipHolder::positionShow(const TextEditorWidget *editorWidget) | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     // Figure out new position of tooltip using the text edit.
 | 
					
						
							|  |  |  |     // If the line changed too much, close this tip.
 | 
					
						
							| 
									
										
										
										
											2014-09-02 16:37:19 +02:00
										 |  |  |     QTC_ASSERT(editorWidget, return); | 
					
						
							|  |  |  |     QTextCursor cursor = editorWidget->textCursor(); | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |     cursor.setPosition(context.position); | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  |     const int line = cursor.blockNumber(); | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |     if (qAbs(context.line - line) > 2) { | 
					
						
							|  |  |  |         widget->close(); | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  |         return ; | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-02-21 16:45:07 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |     const QPoint screenPos = editorWidget->toolTipPosition(cursor) + widget->titleLabel->m_offset; | 
					
						
							|  |  |  |     const QRect toolTipArea = QRect(screenPos, QSize(widget->sizeHint())); | 
					
						
							| 
									
										
										
										
											2014-09-02 16:37:19 +02:00
										 |  |  |     const QRect plainTextArea = QRect(editorWidget->mapToGlobal(QPoint(0, 0)), editorWidget->size()); | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  |     const bool visible = plainTextArea.intersects(toolTipArea); | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |     //    DEBUG("DebuggerToolTipWidget::positionShow() " << this << m_context
 | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  |     //             << " line: " << line << " plainTextPos " << toolTipArea
 | 
					
						
							|  |  |  |     //             << " offset: " << m_titleLabel->m_offset
 | 
					
						
							|  |  |  |     //             << " Area: " << plainTextArea << " Screen pos: "
 | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |     //             << screenPos << te.widget << " visible=" << visible);
 | 
					
						
							| 
									
										
										
										
											2011-02-17 10:57:04 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |     if (visible) { | 
					
						
							|  |  |  |         widget->move(screenPos); | 
					
						
							|  |  |  |         widget->show(); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         widget->hide(); | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  | //// Parse a 'yyyyMMdd' date
 | 
					
						
							| 
									
										
										
										
											2011-02-22 18:02:29 +01:00
										 |  |  | static QDate dateFromString(const QString &date) | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     return date.size() == 8 ? | 
					
						
							|  |  |  |         QDate(date.left(4).toInt(), date.mid(4, 2).toInt(), date.mid(6, 2).toInt()) : | 
					
						
							|  |  |  |         QDate(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  | void DebuggerToolTipHolder::saveSessionData(QXmlStreamWriter &w) const | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     w.writeStartElement(QLatin1String(toolTipElementC)); | 
					
						
							|  |  |  |     QXmlStreamAttributes attributes; | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  | //    attributes.append(QLatin1String(toolTipClassAttributeC), QString::fromLatin1(metaObject()->className()));
 | 
					
						
							|  |  |  |     attributes.append(QLatin1String(fileNameAttributeC), context.fileName); | 
					
						
							|  |  |  |     if (!context.function.isEmpty()) | 
					
						
							|  |  |  |         attributes.append(QLatin1String(functionAttributeC), context.function); | 
					
						
							|  |  |  |     attributes.append(QLatin1String(textPositionAttributeC), QString::number(context.position)); | 
					
						
							|  |  |  |     attributes.append(QLatin1String(textLineAttributeC), QString::number(context.line)); | 
					
						
							|  |  |  |     attributes.append(QLatin1String(textColumnAttributeC), QString::number(context.column)); | 
					
						
							|  |  |  |     attributes.append(QLatin1String(dateAttributeC), creationDate.toString(QLatin1String("yyyyMMdd"))); | 
					
						
							|  |  |  |     QPoint offset = widget->titleLabel->m_offset; | 
					
						
							|  |  |  |     if (offset.x()) | 
					
						
							|  |  |  |         attributes.append(QLatin1String(offsetXAttributeC), QString::number(offset.x())); | 
					
						
							|  |  |  |     if (offset.y()) | 
					
						
							|  |  |  |         attributes.append(QLatin1String(offsetYAttributeC), QString::number(offset.y())); | 
					
						
							|  |  |  |     attributes.append(QLatin1String(engineTypeAttributeC), context.engineType); | 
					
						
							|  |  |  |     attributes.append(QLatin1String(treeExpressionAttributeC), context.expression); | 
					
						
							|  |  |  |     attributes.append(QLatin1String(treeInameAttributeC), QLatin1String(context.iname)); | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  |     w.writeAttributes(attributes); | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |     w.writeStartElement(QLatin1String(treeElementC)); | 
					
						
							| 
									
										
										
										
											2015-02-24 18:51:28 +01:00
										 |  |  |     widget->model.rootItem()->walkTree([&w](TreeItem *item) { | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |         const QString modelItemElement = QLatin1String(modelItemElementC); | 
					
						
							|  |  |  |         for (int i = 0; i < 3; ++i) { | 
					
						
							|  |  |  |             const QString value = item->data(i, Qt::DisplayRole).toString(); | 
					
						
							|  |  |  |             if (value.isEmpty()) | 
					
						
							|  |  |  |                 w.writeEmptyElement(modelItemElement); | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |                 w.writeTextElement(modelItemElement, value); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |     w.writeEndElement(); | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  |     w.writeEndElement(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*!
 | 
					
						
							| 
									
										
										
										
											2011-03-28 14:58:12 +02:00
										 |  |  |     \class Debugger::Internal::DebuggerToolTipManager | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-05 14:29:24 +02:00
										 |  |  |     \brief The DebuggerToolTipManager class manages the pinned tooltip widgets, | 
					
						
							|  |  |  |     listens on editor scroll and main window move | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  |     events and takes care of repositioning the tooltips. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-06 17:16:18 +02:00
										 |  |  |     Listens to editor change and mode change. In debug mode, if there are tooltips | 
					
						
							|  |  |  |     for the current editor (by file name), positions and shows them. | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-21 16:45:07 +01:00
										 |  |  |     In addition, listens on state change and stack frame completed signals | 
					
						
							| 
									
										
										
										
											2013-09-06 17:16:18 +02:00
										 |  |  |     of the engine. If a stack frame is completed, has all matching tooltips | 
					
						
							| 
									
										
										
										
											2011-02-21 16:45:07 +01:00
										 |  |  |     (by file name and function) acquire the engine, others release. | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  | static DebuggerToolTipManager *m_instance = 0; | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-07 13:50:09 +01:00
										 |  |  | DebuggerToolTipManager::DebuggerToolTipManager() | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |     m_instance = this; | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | DebuggerToolTipManager::~DebuggerToolTipManager() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |     m_instance = 0; | 
					
						
							| 
									
										
										
										
											2013-10-11 17:04:56 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-08 19:09:16 +02:00
										 |  |  | void DebuggerToolTipManager::slotUpdateVisibleToolTips() | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     purgeClosedToolTips(); | 
					
						
							|  |  |  |     if (m_tooltips.isEmpty()) | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     if (!m_debugModeActive) { | 
					
						
							| 
									
										
										
										
											2014-11-07 15:57:19 +01:00
										 |  |  |         hideAllToolTips(); | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     BaseTextEditor *toolTipEditor = BaseTextEditor::currentTextEditor(); | 
					
						
							|  |  |  |     if (!toolTipEditor) { | 
					
						
							| 
									
										
										
										
											2014-11-07 15:57:19 +01:00
										 |  |  |         hideAllToolTips(); | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-21 21:54:30 +02:00
										 |  |  |     const QString fileName = toolTipEditor->textDocument()->filePath().toString(); | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  |     if (fileName.isEmpty()) { | 
					
						
							| 
									
										
										
										
											2014-11-07 15:57:19 +01:00
										 |  |  |         hideAllToolTips(); | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Reposition and show all tooltips of that file.
 | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |     foreach (DebuggerToolTipHolder *tooltip, m_tooltips) { | 
					
						
							|  |  |  |         if (tooltip->context.fileName == fileName) | 
					
						
							|  |  |  |             tooltip->positionShow(toolTipEditor->editorWidget()); | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  |         else | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |             tooltip->widget->hide(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  | void DebuggerToolTipManager::updateEngine(DebuggerEngine *engine) | 
					
						
							| 
									
										
										
										
											2013-10-11 17:04:56 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  |     QTC_ASSERT(engine, return); | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  |     purgeClosedToolTips(); | 
					
						
							|  |  |  |     if (m_tooltips.isEmpty()) | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  |         return; | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  |     // Stack frame changed: All tooltips of that file acquire the engine,
 | 
					
						
							|  |  |  |     // all others release (arguable, this could be more precise?)
 | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |     foreach (DebuggerToolTipHolder *tooltip, m_tooltips) | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |         tooltip->updateTooltip(engine); | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |     slotUpdateVisibleToolTips(); // Move tooltip when stepping in same file.
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void DebuggerToolTipManager::registerEngine(DebuggerEngine *engine) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |     Q_UNUSED(engine) | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |     DEBUG("REGISTER ENGINE"); | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  | void DebuggerToolTipManager::deregisterEngine(DebuggerEngine *engine) | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |     DEBUG("DEREGISTER ENGINE"); | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  |     QTC_ASSERT(engine, return); | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     purgeClosedToolTips(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     foreach (DebuggerToolTipHolder *tooltip, m_tooltips) | 
					
						
							|  |  |  |         if (tooltip->context.engineType == engine->objectName()) | 
					
						
							|  |  |  |             tooltip->releaseEngine(); | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  |     saveSessionData(); | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // FIXME: For now remove all.
 | 
					
						
							|  |  |  |     foreach (DebuggerToolTipHolder *tooltip, m_tooltips) | 
					
						
							|  |  |  |         tooltip->destroy(); | 
					
						
							|  |  |  |     purgeClosedToolTips(); | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  | bool DebuggerToolTipManager::hasToolTips() | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  |     return !m_tooltips.isEmpty(); | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void DebuggerToolTipManager::sessionAboutToChange() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     closeAllToolTips(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void DebuggerToolTipManager::loadSessionData() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2015-03-23 17:25:04 +01:00
										 |  |  |     closeAllToolTips(); | 
					
						
							| 
									
										
										
										
											2014-07-28 14:23:52 +02:00
										 |  |  |     const QString data = sessionValue(sessionSettingsKeyC).toString(); | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  |     QXmlStreamReader r(data); | 
					
						
							|  |  |  |     r.readNextStartElement(); | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |     if (r.tokenType() == QXmlStreamReader::StartElement && r.name() == QLatin1String(sessionDocumentC)) { | 
					
						
							|  |  |  |         while (!r.atEnd()) { | 
					
						
							|  |  |  |             if (readStartElement(r, toolTipElementC)) { | 
					
						
							|  |  |  |                 const QXmlStreamAttributes attributes = r.attributes(); | 
					
						
							|  |  |  |                 DebuggerToolTipContext context; | 
					
						
							|  |  |  |                 context.fileName = attributes.value(QLatin1String(fileNameAttributeC)).toString(); | 
					
						
							|  |  |  |                 context.position = attributes.value(QLatin1String(textPositionAttributeC)).toString().toInt(); | 
					
						
							|  |  |  |                 context.line = attributes.value(QLatin1String(textLineAttributeC)).toString().toInt(); | 
					
						
							|  |  |  |                 context.column = attributes.value(QLatin1String(textColumnAttributeC)).toString().toInt(); | 
					
						
							|  |  |  |                 context.function = attributes.value(QLatin1String(functionAttributeC)).toString(); | 
					
						
							|  |  |  |                 QPoint offset; | 
					
						
							|  |  |  |                 const QString offsetXAttribute = QLatin1String(offsetXAttributeC); | 
					
						
							|  |  |  |                 const QString offsetYAttribute = QLatin1String(offsetYAttributeC); | 
					
						
							|  |  |  |                 if (attributes.hasAttribute(offsetXAttribute)) | 
					
						
							|  |  |  |                     offset.setX(attributes.value(offsetXAttribute).toString().toInt()); | 
					
						
							|  |  |  |                 if (attributes.hasAttribute(offsetYAttribute)) | 
					
						
							|  |  |  |                     offset.setY(attributes.value(offsetYAttribute).toString().toInt()); | 
					
						
							|  |  |  |                 context.mousePosition = offset; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 context.iname = attributes.value(QLatin1String(treeInameAttributeC)).toString().toLatin1(); | 
					
						
							|  |  |  |                 context.expression = attributes.value(QLatin1String(treeExpressionAttributeC)).toString(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 //    const QStringRef className = attributes.value(QLatin1String(toolTipClassAttributeC));
 | 
					
						
							|  |  |  |                 context.engineType = attributes.value(QLatin1String(engineTypeAttributeC)).toString(); | 
					
						
							|  |  |  |                 context.creationDate = dateFromString(attributes.value(QLatin1String(dateAttributeC)).toString()); | 
					
						
							|  |  |  |                 bool readTree = context.isValid(); | 
					
						
							|  |  |  |                 if (!context.creationDate.isValid() || context.creationDate.daysTo(QDate::currentDate()) > toolTipsExpiryDays) { | 
					
						
							|  |  |  |                     // DEBUG("Expiring tooltip " << context.fileName << '@' << context.position << " from " << creationDate)
 | 
					
						
							|  |  |  |                     //readTree = false;
 | 
					
						
							|  |  |  |                 } else { //if (className != QLatin1String("Debugger::Internal::DebuggerToolTipWidget")) {
 | 
					
						
							|  |  |  |                     //qWarning("Unable to create debugger tool tip widget of class %s", qPrintable(className.toString()));
 | 
					
						
							|  |  |  |                     //readTree = false;
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 if (readTree) { | 
					
						
							| 
									
										
										
										
											2015-03-23 17:25:04 +01:00
										 |  |  |                     auto tw = new DebuggerToolTipHolder(context); | 
					
						
							|  |  |  |                     m_tooltips.push_back(tw); | 
					
						
							| 
									
										
										
										
											2015-02-24 18:51:28 +01:00
										 |  |  |                     tw->widget->model.restoreTreeModel(r); | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |                     tw->widget->pin(); | 
					
						
							|  |  |  |                     tw->widget->titleLabel->setText(DebuggerToolTipManager::tr("%1 (Restored)").arg(context.expression)); | 
					
						
							|  |  |  |                     tw->widget->treeView->expandAll(); | 
					
						
							|  |  |  |                 } else { | 
					
						
							|  |  |  |                     r.readElementText(QXmlStreamReader::SkipChildElements); // Skip
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 r.readNext(); // Skip </tree>
 | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void DebuggerToolTipManager::saveSessionData() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QString data; | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  |     purgeClosedToolTips(); | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     QXmlStreamWriter w(&data); | 
					
						
							|  |  |  |     w.writeStartDocument(); | 
					
						
							|  |  |  |     w.writeStartElement(QLatin1String(sessionDocumentC)); | 
					
						
							|  |  |  |     w.writeAttribute(QLatin1String(sessionVersionAttributeC), QLatin1String("1.0")); | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |     foreach (DebuggerToolTipHolder *tooltip, m_tooltips) | 
					
						
							|  |  |  |         if (tooltip->widget->isPinned) | 
					
						
							|  |  |  |             tooltip->saveSessionData(w); | 
					
						
							| 
									
										
										
										
											2014-07-10 18:10:56 +02:00
										 |  |  |     w.writeEndDocument(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |     return; // FIXME
 | 
					
						
							| 
									
										
										
										
											2014-07-28 14:23:52 +02:00
										 |  |  |     setSessionValue(sessionSettingsKeyC, QVariant(data)); | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void DebuggerToolTipManager::closeAllToolTips() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |     foreach (DebuggerToolTipHolder *tooltip, m_tooltips) | 
					
						
							| 
									
										
										
										
											2014-11-15 17:08:22 +01:00
										 |  |  |         tooltip->destroy(); | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  |     m_tooltips.clear(); | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  | void DebuggerToolTipManager::resetLocation() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     purgeClosedToolTips(); | 
					
						
							|  |  |  |     foreach (DebuggerToolTipHolder *tooltip, m_tooltips) | 
					
						
							|  |  |  |         tooltip->widget->pin(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  | static void slotTooltipOverrideRequested | 
					
						
							|  |  |  |     (TextEditorWidget *editorWidget, const QPoint &point, int pos, bool *handled) | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  |     QTC_ASSERT(handled, return); | 
					
						
							|  |  |  |     QTC_ASSERT(editorWidget, return); | 
					
						
							|  |  |  |     *handled = false; | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  |     if (!boolSetting(UseToolTipsInMainEditor)) | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  |         return; | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-06 13:36:42 +01:00
										 |  |  |     const TextDocument *document = editorWidget->textDocument(); | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  |     DebuggerEngine *engine = currentEngine(); | 
					
						
							|  |  |  |     if (!engine || !engine->canDisplayTooltip()) | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  |         return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  |     DebuggerToolTipContext context; | 
					
						
							|  |  |  |     context.engineType = engine->objectName(); | 
					
						
							| 
									
										
										
										
											2015-03-06 13:36:42 +01:00
										 |  |  |     context.fileName = document->filePath().toString(); | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  |     context.position = pos; | 
					
						
							|  |  |  |     editorWidget->convertPosition(pos, &context.line, &context.column); | 
					
						
							| 
									
										
										
										
											2014-11-15 13:33:40 +01:00
										 |  |  |     QString raw = cppExpressionAt(editorWidget, context.position, &context.line, &context.column, | 
					
						
							|  |  |  |                                   &context.function, &context.scopeFromLine, &context.scopeToLine); | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  |     context.expression = fixCppExpression(raw); | 
					
						
							| 
									
										
										
										
											2015-03-06 13:36:42 +01:00
										 |  |  |     context.isCppEditor = CppTools::ProjectFile::classify(document->filePath().toString()) | 
					
						
							|  |  |  |                             != CppTools::ProjectFile::Unclassified; | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (context.expression.isEmpty()) { | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |         ToolTip::show(point, DebuggerToolTipManager::tr("No valid expression"), | 
					
						
							| 
									
										
										
										
											2014-12-08 10:57:05 +01:00
										 |  |  |                              Internal::mainWindow()); | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  |         *handled = true; | 
					
						
							| 
									
										
										
										
											2014-09-02 16:37:19 +02:00
										 |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-23 17:25:04 +01:00
										 |  |  |     purgeClosedToolTips(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  |     // Prefer a filter on an existing local variable if it can be found.
 | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |     const WatchData *localVariable = engine->watchHandler()->findCppLocalVariable(context.expression); | 
					
						
							|  |  |  |     if (localVariable) { | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  |         context.expression = QLatin1String(localVariable->exp); | 
					
						
							|  |  |  |         if (context.expression.isEmpty()) | 
					
						
							|  |  |  |             context.expression = localVariable->name; | 
					
						
							|  |  |  |         context.iname = localVariable->iname; | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-23 17:25:04 +01:00
										 |  |  |         auto reusable = [context] (DebuggerToolTipHolder *tooltip) { | 
					
						
							|  |  |  |             return tooltip->context.isSame(context); | 
					
						
							|  |  |  |         }; | 
					
						
							|  |  |  |         DebuggerToolTipHolder *tooltip = Utils::findOrDefault(m_tooltips, reusable); | 
					
						
							|  |  |  |         if (tooltip) { | 
					
						
							|  |  |  |             DEBUG("REUSING LOCALS TOOLTIP"); | 
					
						
							|  |  |  |             tooltip->context.mousePosition = point; | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |             ToolTip::move(point, Internal::mainWindow()); | 
					
						
							| 
									
										
										
										
											2015-03-23 17:25:04 +01:00
										 |  |  |         } else { | 
					
						
							|  |  |  |             DEBUG("CREATING LOCALS, WAITING..."); | 
					
						
							|  |  |  |             tooltip = new DebuggerToolTipHolder(context); | 
					
						
							|  |  |  |             tooltip->setState(Acquired); | 
					
						
							|  |  |  |             m_tooltips.push_back(tooltip); | 
					
						
							|  |  |  |             ToolTip::show(point, tooltip->widget, Internal::mainWindow()); | 
					
						
							| 
									
										
										
										
											2014-11-15 17:08:22 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2015-03-23 17:25:04 +01:00
										 |  |  |         DEBUG("SYNC IN STATE" << tooltip->state); | 
					
						
							| 
									
										
										
										
											2015-02-09 09:00:21 +01:00
										 |  |  |         tooltip->updateTooltip(engine); | 
					
						
							| 
									
										
										
										
											2015-03-23 17:25:04 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         *handled = true; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2015-03-23 17:25:04 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         context.iname = "tooltip." + context.expression.toLatin1().toHex(); | 
					
						
							|  |  |  |         auto reusable = [context] (DebuggerToolTipHolder *tooltip) { | 
					
						
							|  |  |  |             return tooltip->context.isSame(context); | 
					
						
							|  |  |  |         }; | 
					
						
							|  |  |  |         DebuggerToolTipHolder *tooltip = Utils::findOrDefault(m_tooltips, reusable); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (tooltip) { | 
					
						
							|  |  |  |             //tooltip->destroy();
 | 
					
						
							|  |  |  |             tooltip->context.mousePosition = point; | 
					
						
							|  |  |  |             ToolTip::move(point, Internal::mainWindow()); | 
					
						
							|  |  |  |             DEBUG("UPDATING DELAYED."); | 
					
						
							|  |  |  |             *handled = true; | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             DEBUG("CREATING DELAYED."); | 
					
						
							|  |  |  |             tooltip = new DebuggerToolTipHolder(context); | 
					
						
							|  |  |  |             tooltip->context.mousePosition = point; | 
					
						
							|  |  |  |             m_tooltips.push_back(tooltip); | 
					
						
							| 
									
										
										
										
											2014-11-15 17:08:22 +01:00
										 |  |  |             tooltip->setState(PendingUnshown); | 
					
						
							| 
									
										
										
										
											2015-03-23 17:25:04 +01:00
										 |  |  |             *handled = engine->setToolTipExpression(context); | 
					
						
							|  |  |  |             if (!*handled) { | 
					
						
							|  |  |  |                 ToolTip::show(point, DebuggerToolTipManager::tr("Expression too complex"), | 
					
						
							|  |  |  |                               Internal::mainWindow()); | 
					
						
							|  |  |  |                 tooltip->destroy(); | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  | static void slotEditorOpened(IEditor *e) | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     // Move tooltip along when scrolled.
 | 
					
						
							| 
									
										
										
										
											2014-09-02 16:37:19 +02:00
										 |  |  |     if (BaseTextEditor *textEditor = qobject_cast<BaseTextEditor *>(e)) { | 
					
						
							| 
									
										
										
										
											2014-09-26 11:37:54 +02:00
										 |  |  |         TextEditorWidget *widget = textEditor->editorWidget(); | 
					
						
							| 
									
										
										
										
											2014-11-07 13:50:09 +01:00
										 |  |  |         QObject::connect(widget->verticalScrollBar(), &QScrollBar::valueChanged, | 
					
						
							| 
									
										
										
										
											2014-11-08 19:09:16 +02:00
										 |  |  |                          &DebuggerToolTipManager::slotUpdateVisibleToolTips); | 
					
						
							| 
									
										
										
										
											2014-11-07 13:50:09 +01:00
										 |  |  |         QObject::connect(widget, &TextEditorWidget::tooltipOverrideRequested, | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  |                          slotTooltipOverrideRequested); | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void DebuggerToolTipManager::debugModeEntered() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     // Hook up all signals in debug mode.
 | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  |     if (!m_debugModeActive) { | 
					
						
							|  |  |  |         m_debugModeActive = true; | 
					
						
							| 
									
										
										
										
											2012-01-24 15:36:40 +01:00
										 |  |  |         QWidget *topLevel = ICore::mainWindow()->topLevelWidget(); | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  |         topLevel->installEventFilter(this); | 
					
						
							| 
									
										
										
										
											2014-09-02 16:37:19 +02:00
										 |  |  |         EditorManager *em = EditorManager::instance(); | 
					
						
							| 
									
										
										
										
											2014-11-08 19:09:16 +02:00
										 |  |  |         connect(em, &EditorManager::currentEditorChanged, | 
					
						
							|  |  |  |                 &DebuggerToolTipManager::slotUpdateVisibleToolTips); | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  |         connect(em, &EditorManager::editorOpened, slotEditorOpened); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-07 16:25:04 +02:00
										 |  |  |         foreach (IEditor *e, DocumentModel::editorsForOpenedDocuments()) | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  |             slotEditorOpened(e); | 
					
						
							|  |  |  |         // Position tooltips delayed once all the editor placeholder layouting is done.
 | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  |         if (!m_tooltips.isEmpty()) | 
					
						
							| 
									
										
										
										
											2014-11-08 19:09:16 +02:00
										 |  |  |             QTimer::singleShot(0, this, SLOT(slotUpdateVisibleToolTips())); | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void DebuggerToolTipManager::leavingDebugMode() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     // Remove all signals in debug mode.
 | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  |     if (m_debugModeActive) { | 
					
						
							|  |  |  |         m_debugModeActive = false; | 
					
						
							| 
									
										
										
										
											2014-11-07 15:57:19 +01:00
										 |  |  |         hideAllToolTips(); | 
					
						
							| 
									
										
										
										
											2012-01-24 15:36:40 +01:00
										 |  |  |         if (QWidget *topLevel = ICore::mainWindow()->topLevelWidget()) | 
					
						
							| 
									
										
										
										
											2011-02-17 10:08:57 +01:00
										 |  |  |             topLevel->removeEventFilter(this); | 
					
						
							| 
									
										
										
										
											2014-05-07 16:25:04 +02:00
										 |  |  |         foreach (IEditor *e, DocumentModel::editorsForOpenedDocuments()) { | 
					
						
							| 
									
										
										
										
											2014-09-02 16:37:19 +02:00
										 |  |  |             if (BaseTextEditor *toolTipEditor = qobject_cast<BaseTextEditor *>(e)) { | 
					
						
							|  |  |  |                 toolTipEditor->editorWidget()->verticalScrollBar()->disconnect(this); | 
					
						
							|  |  |  |                 toolTipEditor->disconnect(this); | 
					
						
							| 
									
										
										
										
											2011-02-17 10:08:57 +01:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2013-07-09 12:14:33 +02:00
										 |  |  |         EditorManager::instance()->disconnect(this); | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  | DebuggerToolTipContexts DebuggerToolTipManager::pendingTooltips(DebuggerEngine *engine) | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |     StackFrame frame = engine->stackHandler()->currentFrame(); | 
					
						
							| 
									
										
										
										
											2013-10-11 16:56:25 +02:00
										 |  |  |     DebuggerToolTipContexts rc; | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |     foreach (DebuggerToolTipHolder *tooltip, m_tooltips) { | 
					
						
							| 
									
										
										
										
											2014-11-15 13:33:40 +01:00
										 |  |  |         const DebuggerToolTipContext &context = tooltip->context; | 
					
						
							|  |  |  |         if (context.iname.startsWith("tooltip") && context.matchesFrame(frame)) | 
					
						
							|  |  |  |             rc.push_back(context); | 
					
						
							| 
									
										
										
										
											2011-05-27 11:02:57 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  |     return rc; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  | bool DebuggerToolTipManager::eventFilter(QObject *o, QEvent *e) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (m_tooltips.isEmpty()) | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     switch (e->type()) { | 
					
						
							|  |  |  |     case QEvent::Move: { // Move along with parent (toplevel)
 | 
					
						
							|  |  |  |         const QMoveEvent *me = static_cast<const QMoveEvent *>(e); | 
					
						
							|  |  |  |         const QPoint dist = me->pos() - me->oldPos(); | 
					
						
							|  |  |  |         purgeClosedToolTips(); | 
					
						
							| 
									
										
										
										
											2015-03-23 17:25:04 +01:00
										 |  |  |         foreach (DebuggerToolTipHolder *tooltip, m_tooltips) { | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |             if (tooltip->widget && tooltip->widget->isVisible()) | 
					
						
							|  |  |  |                 tooltip->widget->move(tooltip->widget->pos() + dist); | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  |         } | 
					
						
							|  |  |  |         break; | 
					
						
							| 
									
										
										
										
											2015-03-23 17:25:04 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  |     case QEvent::WindowStateChange: { // Hide/Show along with parent (toplevel)
 | 
					
						
							|  |  |  |         const QWindowStateChangeEvent *se = static_cast<const QWindowStateChangeEvent *>(e); | 
					
						
							|  |  |  |         const bool wasMinimized = se->oldState() & Qt::WindowMinimized; | 
					
						
							|  |  |  |         const bool isMinimized  = static_cast<const QWidget *>(o)->windowState() & Qt::WindowMinimized; | 
					
						
							|  |  |  |         if (wasMinimized ^ isMinimized) { | 
					
						
							|  |  |  |             purgeClosedToolTips(); | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |             foreach (DebuggerToolTipHolder *tooltip, m_tooltips) | 
					
						
							|  |  |  |                 tooltip->widget->setVisible(!isMinimized); | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  |         } | 
					
						
							|  |  |  |         break; | 
					
						
							| 
									
										
										
										
											2015-03-23 17:25:04 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-11-07 15:00:45 +01:00
										 |  |  |     default: | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  | static void purgeClosedToolTips() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     for (int i = m_tooltips.size(); --i >= 0; ) { | 
					
						
							|  |  |  |         DebuggerToolTipHolder *tooltip = m_tooltips.at(i); | 
					
						
							| 
									
										
										
										
											2015-03-23 17:25:04 +01:00
										 |  |  |         if (!tooltip->widget) { | 
					
						
							| 
									
										
										
										
											2014-11-11 11:00:32 +01:00
										 |  |  |             DEBUG("PURGE TOOLTIP, LEFT: "  << m_tooltips.size()); | 
					
						
							|  |  |  |             m_tooltips.removeAt(i); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-11 15:00:13 +01:00
										 |  |  | } // namespace Internal
 | 
					
						
							|  |  |  | } // namespace Debugger
 |