Commit 8e75e611 authored by Daniel Teske's avatar Daniel Teske

Move TextEditor::ToolTip to Utils

To enabled reuse from all plugins.

Change-Id: I1de68c8e6ed017d45f1248b2043f9611becc3b54
Reviewed-by: default avatarDavid Schulz <david.schulz@digia.com>
parent d26ec504
......@@ -36,7 +36,7 @@
#include <QApplication>
#include <QDesktopWidget>
namespace TextEditor {
namespace Utils {
namespace Internal {
inline int screenNumber(const QPoint &pos, QWidget *w)
......@@ -57,6 +57,6 @@ inline QRect screenGeometry(const QPoint &pos, QWidget *w)
}
} // namespace Internal
} // namespace TextEditor
} // namespace Utils
#endif // TOOLTIPREUSE_H
......@@ -35,7 +35,7 @@
#include <QtGlobal>
namespace TextEditor {
namespace Utils {
TipContent::TipContent()
{}
......@@ -192,4 +192,4 @@ bool WidgetContent::pinToolTip(QWidget *w)
return false;
}
} // namespace TextEditor
} // namespace Utils
......@@ -30,14 +30,14 @@
#ifndef TIPCONTENTS_H
#define TIPCONTENTS_H
#include "texteditor/texteditor_global.h"
#include "../utils_global.h"
#include <QString>
#include <QColor>
namespace TextEditor {
namespace Utils {
class TEXTEDITOR_EXPORT TipContent
class QTCREATOR_UTILS_EXPORT TipContent
{
protected:
TipContent();
......@@ -53,7 +53,7 @@ public:
virtual bool equals(const TipContent &tipContent) const = 0;
};
class TEXTEDITOR_EXPORT ColorContent : public TipContent
class QTCREATOR_UTILS_EXPORT ColorContent : public TipContent
{
public:
ColorContent(const QColor &color);
......@@ -74,7 +74,7 @@ private:
QColor m_color;
};
class TEXTEDITOR_EXPORT TextContent : public TipContent
class QTCREATOR_UTILS_EXPORT TextContent : public TipContent
{
public:
TextContent(const QString &text);
......@@ -96,7 +96,7 @@ private:
};
// A content for displaying any widget (with a layout).
class TEXTEDITOR_EXPORT WidgetContent : public TipContent
class QTCREATOR_UTILS_EXPORT WidgetContent : public TipContent
{
public:
explicit WidgetContent(QWidget *w, bool interactive = false);
......@@ -123,6 +123,6 @@ private:
bool m_interactive;
};
} // namespace TextEditor
} // namespace Utils
#endif // TIPCONTENTS_H
......@@ -30,11 +30,11 @@
#include "tipfactory.h"
#include "tipcontents.h"
#include "tips.h"
#include <utils/qtcassert.h>
#include "qtcassert.h"
#include <QVBoxLayout>
using namespace TextEditor;
using namespace Utils;
using namespace Internal;
TipFactory::TipFactory()
......
......@@ -32,7 +32,7 @@
#include <QWidget>
namespace TextEditor {
namespace Utils {
class TipContent;
......@@ -50,6 +50,6 @@ public:
};
} // namespace Internal
} // namespace TextEditor
} // namespace Utils
#endif // TIPFACTORY_H
......@@ -31,7 +31,7 @@
#include "tipcontents.h"
#include "reuse.h"
#include <utils/qtcassert.h>
#include "qtcassert.h"
#include <QRect>
#include <QColor>
......@@ -47,7 +47,7 @@
#include <QPaintEvent>
#include <QVBoxLayout>
namespace TextEditor {
namespace Utils {
namespace Internal {
namespace {
......@@ -82,7 +82,7 @@ bool QTipLabel::isInteractive() const
void QTipLabel::setContent(const TipContent &content)
{
TextEditor::TipContent *tmpTipContent = m_tipContent;
Utils::TipContent *tmpTipContent = m_tipContent;
m_tipContent = content.clone();
delete tmpTipContent;
}
......@@ -266,4 +266,4 @@ bool WidgetTip::canHandleContentReplacement(const TipContent & ) const
#include "moc_tips.cpp"
} // namespace Internal
} // namespace TextEditor
} // namespace Utils
......@@ -36,12 +36,12 @@
QT_FORWARD_DECLARE_CLASS(QVBoxLayout)
namespace TextEditor {
namespace Utils {
class TipContent;
}
#ifndef Q_MOC_RUN
namespace TextEditor {
namespace Utils {
namespace Internal {
#endif
......@@ -55,16 +55,16 @@ protected:
public:
virtual ~QTipLabel();
void setContent(const TextEditor::TipContent &content);
const TextEditor::TipContent &content() const;
void setContent(const Utils::TipContent &content);
const Utils::TipContent &content() const;
virtual void configure(const QPoint &pos, QWidget *w) = 0;
virtual bool canHandleContentReplacement(const TextEditor::TipContent &content) const = 0;
virtual bool canHandleContentReplacement(const Utils::TipContent &content) const = 0;
bool isInteractive() const;
private:
TextEditor::TipContent *m_tipContent;
Utils::TipContent *m_tipContent;
};
class ColorTip : public QTipLabel
......@@ -118,7 +118,7 @@ private:
#ifndef Q_MOC_RUN
} // namespace Internal
} // namespace TextEditor
} // namespace Utils
#endif
#endif // TIPS_H
......@@ -34,7 +34,7 @@
#include "effects.h"
#include "reuse.h"
#include <utils/hostosinfo.h>
#include "hostosinfo.h"
#include <QString>
#include <QColor>
......@@ -45,7 +45,7 @@
#include <QDebug>
using namespace TextEditor;
using namespace Utils;
using namespace Internal;
ToolTip::ToolTip() : m_tipFactory(new TipFactory), m_tip(0), m_widget(0)
......
......@@ -30,7 +30,7 @@
#ifndef TOOLTIP_H
#define TOOLTIP_H
#include "texteditor/texteditor_global.h"
#include "../utils_global.h"
#include <QSharedPointer>
#include <QObject>
......@@ -52,7 +52,7 @@ class QPoint;
class QWidget;
QT_END_NAMESPACE
namespace TextEditor {
namespace Utils {
namespace Internal {
class TipFactory;
......@@ -61,7 +61,7 @@ class QTipLabel;
class TipContent;
class TEXTEDITOR_EXPORT ToolTip : public QObject
class QTCREATOR_UTILS_EXPORT ToolTip : public QObject
{
Q_OBJECT
private:
......@@ -103,6 +103,6 @@ private:
QTimer m_hideDelayTimer;
};
} // namespace TextEditor
} // namespace Utils
#endif // TOOLTIP_H
......@@ -4,7 +4,7 @@ dll {
DEFINES += QTCREATOR_UTILS_STATIC_LIB
}
INCLUDEPATH += $$PWD
INCLUDEPATH += $$PWD $$PWD/tooltip
QT += script network
CONFIG += exceptions # used by portlist.cpp, textfileformat.cpp, and ssh/*
......@@ -82,6 +82,10 @@ SOURCES += $$PWD/environment.cpp \
$$PWD/bracematcher.cpp \
$$PWD/proxyaction.cpp \
$$PWD/elidinglabel.cpp \
$$PWD/tooltip/tooltip.cpp \
$$PWD/tooltip/tips.cpp \
$$PWD/tooltip/tipcontents.cpp \
$$PWD/tooltip/tipfactory.cpp
win32 {
SOURCES += \
......@@ -168,7 +172,13 @@ HEADERS += \
$$PWD/bracematcher.h \
$$PWD/proxyaction.h \
$$PWD/hostosinfo.h \
$$PWD/elidinglabel.h
$$PWD/elidinglabel.h \
$$PWD/tooltip/tooltip.h \
$$PWD/tooltip/tips.h \
$$PWD/tooltip/tipcontents.h \
$$PWD/tooltip/reuse.h \
$$PWD/tooltip/effects.h \
$$PWD/tooltip/tipfactory.h
FORMS += $$PWD/filewizardpage.ui \
$$PWD/projectintropage.ui \
......
......@@ -5,6 +5,9 @@ QtcLibrary {
name: "Utils"
cpp.defines: base.concat(["QTCREATOR_UTILS_LIB", "QT_NO_CAST_FROM_ASCII"])
cpp.includePaths: base.concat([
"tooltip"
])
Properties {
condition: qbs.targetOS == "windows"
......@@ -178,6 +181,22 @@ QtcLibrary {
"images/triangle_vert.png",
]
Group {
prefix: "tooltip/"
files: [
"effects.h",
"reuse.h",
"tipcontents.cpp",
"tipcontents.h",
"tipfactory.cpp",
"tipfactory.h",
"tips.cpp",
"tips.h",
"tooltip.cpp",
"tooltip.h",
]
}
Group {
condition: qbs.targetOS == "windows"
files: [
......
......@@ -40,8 +40,8 @@
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/session.h>
#include <texteditor/basetexteditor.h>
#include <texteditor/tooltip/tooltip.h>
#include <texteditor/tooltip/tipcontents.h>
#include <utils/tooltip/tooltip.h>
#include <utils/tooltip/tipcontents.h>
#include <utils/qtcassert.h>
#include <QDebug>
......@@ -804,9 +804,9 @@ void BookmarkManager::operateTooltip(TextEditor::ITextEditor *textEditor, const
return;
if (mark->note().isEmpty())
TextEditor::ToolTip::instance()->hide();
Utils::ToolTip::instance()->hide();
else
TextEditor::ToolTip::instance()->show(pos, TextEditor::TextContent(mark->note()), textEditor->widget());
Utils::ToolTip::instance()->show(pos, Utils::TextContent(mark->note()), textEditor->widget());
}
/* Loads the bookmarks from the session settings. */
......
......@@ -44,8 +44,8 @@
#include <cpptools/cpprefactoringchanges.h>
#include <cpptools/symbolfinder.h>
#include <texteditor/refactoroverlay.h>
#include <texteditor/tooltip/tooltip.h>
#include <texteditor/tooltip/tipcontents.h>
#include <utils/tooltip/tooltip.h>
#include <utils/tooltip/tipcontents.h>
#include <utils/qtcassert.h>
#include <utils/proxyaction.h>
#include <coreplugin/actionmanager/actionmanager.h>
......@@ -313,9 +313,9 @@ void FunctionDeclDefLink::apply(CPPEditorWidget *editor, bool jumpToMatch)
}
newTargetFile->apply();
} else {
TextEditor::ToolTip::instance()->show(
Utils::ToolTip::instance()->show(
editor->toolTipPosition(linkSelection),
TextEditor::TextContent(
Utils::TextContent(
tr("Target file was changed, could not apply changes")));
}
}
......
......@@ -44,9 +44,9 @@
#include <coreplugin/editormanager/editormanager.h>
#include <texteditor/itexteditor.h>
#include <texteditor/basetexteditor.h>
#include <texteditor/tooltip/tooltip.h>
#include <texteditor/tooltip/tipcontents.h>
#include <utils/tooltip/tooltip.h>
#include <utils/tooltip/tipcontents.h>
#include <utils/qtcassert.h>
#include <QToolButton>
......@@ -515,7 +515,7 @@ void DebuggerToolTipWidget::pin()
if (parentWidget()) {
// We are currently within a text editor tooltip:
// Rip out of parent widget and re-show as a tooltip
WidgetContent::pinToolTip(this);
Utils::WidgetContent::pinToolTip(this);
} else {
// We have just be restored from session data.
setWindowFlags(Qt::ToolTip);
......@@ -1128,8 +1128,8 @@ void DebuggerToolTipManager::showToolTip(const QPoint &p, IEditor *editor,
QWidget *widget = editor->widget();
if (debugToolTipPositioning)
qDebug() << "DebuggerToolTipManager::showToolTip" << p << " Mouse at " << QCursor::pos();
const WidgetContent widgetContent(toolTipWidget, true);
ToolTip::instance()->show(p, widgetContent, widget);
const Utils::WidgetContent widgetContent(toolTipWidget, true);
Utils::ToolTip::instance()->show(p, widgetContent, widget);
registerToolTip(toolTipWidget);
}
......
......@@ -57,7 +57,6 @@
#include <texteditor/texteditorsettings.h>
#include <texteditor/syntaxhighlighter.h>
#include <texteditor/refactoroverlay.h>
#include <texteditor/tooltip/tooltip.h>
#include <qmldesigner/qmldesignerconstants.h>
#include <utils/changeset.h>
#include <utils/uncommentselection.h>
......
......@@ -64,7 +64,6 @@
#include <texteditor/texteditorsettings.h>
#include <texteditor/syntaxhighlighter.h>
#include <texteditor/refactoroverlay.h>
#include <texteditor/tooltip/tooltip.h>
#include <texteditor/codeassist/genericproposal.h>
#include <texteditor/codeassist/basicproposalitemlistmodel.h>
#include <qmldesigner/qmldesignerconstants.h>
......
......@@ -46,8 +46,8 @@
#include <texteditor/itexteditor.h>
#include <texteditor/basetexteditor.h>
#include <texteditor/helpitem.h>
#include <texteditor/tooltip/tooltip.h>
#include <texteditor/tooltip/tipcontents.h>
#include <utils/tooltip/tooltip.h>
#include <utils/tooltip/tipcontents.h>
#include <QDir>
#include <QList>
......@@ -265,15 +265,15 @@ void HoverHandler::reset()
void HoverHandler::operateTooltip(TextEditor::ITextEditor *editor, const QPoint &point)
{
if (toolTip().isEmpty())
TextEditor::ToolTip::instance()->hide();
Utils::ToolTip::instance()->hide();
else {
if (m_colorTip.isValid()) {
TextEditor::ToolTip::instance()->show(point,
TextEditor::ColorContent(m_colorTip),
Utils::ToolTip::instance()->show(point,
Utils::ColorContent(m_colorTip),
editor->widget());
} else {
TextEditor::ToolTip::instance()->show(point,
TextEditor::TextContent(toolTip()),
Utils::ToolTip::instance()->show(point,
Utils::TextContent(toolTip()),
editor->widget());
}
}
......
......@@ -38,7 +38,6 @@
#include <texteditor/itexteditor.h>
#include <texteditor/basetexteditor.h>
#include <texteditor/helpitem.h>
#include <texteditor/tooltip/tooltip.h>
#include <utils/htmldocextractor.h>
#include <QTextCursor>
......
......@@ -31,14 +31,14 @@
#include "itexteditor.h"
#include "basetexteditor.h"
#include "displaysettings.h"
#include "tooltip.h"
#include "tipcontents.h"
#include <coreplugin/icore.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/helpmanager.h>
#include <coreplugin/id.h>
#include <debugger/debuggerconstants.h>
#include <utils/tooltip/tooltip.h>
#include <utils/tooltip/tipcontents.h>
#include <QPoint>
......@@ -89,7 +89,7 @@ void BaseHoverHandler::updateContextHelpId(TextEditor::ITextEditor *editor, int
// If the tooltip is visible and there is a help match, this match is used to update
// the help id. Otherwise, let the identification process happen.
if (!ToolTip::instance()->isVisible() || !lastHelpItemIdentified().isValid())
if (!Utils::ToolTip::instance()->isVisible() || !lastHelpItemIdentified().isValid())
process(editor, pos);
if (lastHelpItemIdentified().isValid())
......@@ -162,9 +162,9 @@ void BaseHoverHandler::decorateToolTip()
void BaseHoverHandler::operateTooltip(ITextEditor *editor, const QPoint &point)
{
if (m_toolTip.isEmpty())
ToolTip::instance()->hide();
Utils::ToolTip::instance()->hide();
else
ToolTip::instance()->show(point, TextContent(m_toolTip), editor->widget());
Utils::ToolTip::instance()->show(point, Utils::TextContent(m_toolTip), editor->widget());
}
BaseTextEditorWidget *BaseHoverHandler::baseTextEditor(ITextEditor *editor)
......
......@@ -41,8 +41,6 @@
#include "texteditorconstants.h"
#include "texteditorplugin.h"
#include "syntaxhighlighter.h"
#include "tooltip.h"
#include "tipcontents.h"
#include "indenter.h"
#include "autocompleter.h"
#include "snippet.h"
......@@ -70,6 +68,8 @@
#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <utils/stylehelper.h>
#include <utils/tooltip/tooltip.h>
#include <utils/tooltip/tipcontents.h>
#include <QCoreApplication>
#include <QTextCodec>
......@@ -6388,7 +6388,7 @@ QString BaseTextEditor::contextHelpId() const
return m_contextHelpId;
}
Internal::RefactorMarkers BaseTextEditorWidget::refactorMarkers() const
RefactorMarkers BaseTextEditorWidget::refactorMarkers() const
{
return d->m_refactorOverlay->markers();
}
......@@ -6414,7 +6414,7 @@ void BaseTextEditorWidget::doFoo() {
#endif
}
void Internal::BaseTextBlockSelection::moveAnchor(int blockNumber, int visualColumn)
void BaseTextBlockSelection::moveAnchor(int blockNumber, int visualColumn)
{
if (visualColumn >= 0) {
if (anchor % 2) {
......@@ -6451,7 +6451,7 @@ void Internal::BaseTextBlockSelection::moveAnchor(int blockNumber, int visualCol
lastBlock.movePosition(QTextCursor::EndOfBlock);
}
QTextCursor Internal::BaseTextBlockSelection::selection(const TabSettings &ts) const
QTextCursor BaseTextBlockSelection::selection(const TabSettings &ts) const
{
QTextCursor cursor = firstBlock;
if (anchor <= TopRight) {
......@@ -6466,7 +6466,7 @@ QTextCursor Internal::BaseTextBlockSelection::selection(const TabSettings &ts) c
return cursor;
}
void Internal::BaseTextBlockSelection::fromSelection(const TabSettings &ts, const QTextCursor &selection)
void BaseTextBlockSelection::fromSelection(const TabSettings &ts, const QTextCursor &selection)
{
firstBlock = selection;
firstBlock.setPosition(selection.selectionStart());
......
......@@ -7,7 +7,6 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += printsupport
include(../../qtcreatorplugin.pri)
include(texteditor_dependencies.pri)
INCLUDEPATH += generichighlighter \
tooltip \
snippets \
codeassist
SOURCES += texteditorplugin.cpp \
......@@ -65,10 +64,6 @@ SOURCES += texteditorplugin.cpp \
refactoringchanges.cpp \
refactoroverlay.cpp \
outlinefactory.cpp \
tooltip/tooltip.cpp \
tooltip/tips.cpp \
tooltip/tipcontents.cpp \
tooltip/tipfactory.cpp \
basehoverhandler.cpp \
helpitem.cpp \
autocompleter.cpp \
......@@ -180,12 +175,6 @@ HEADERS += texteditorplugin.h \
refactoroverlay.h \
outlinefactory.h \
ioutlinewidget.h \
tooltip/tooltip.h \
tooltip/tips.h \
tooltip/tipcontents.h \
tooltip/reuse.h \
tooltip/effects.h \
tooltip/tipfactory.h \
basehoverhandler.h \
helpitem.h \
autocompleter.h \
......@@ -253,12 +242,3 @@ FORMS += \
RESOURCES += texteditor.qrc
OTHER_FILES += TextEditor.mimetypes.xml
......@@ -14,7 +14,6 @@ QtcPlugin {
cpp.defines: base.concat(["QT_NO_CAST_FROM_ASCII"])
cpp.includePaths: base.concat([
"generichighlighter",
"tooltip",
"snippets",
"codeassist"
])
......@@ -269,22 +268,6 @@ QtcPlugin {
]
}
Group {
prefix: "tooltip/"
files: [
"effects.h",
"reuse.h",
"tipcontents.cpp",
"tipcontents.h",
"tipfactory.cpp",
"tipfactory.h",
"tips.cpp",
"tips.h",
"tooltip.cpp",
"tooltip.h",
]
}
ProductModule {
Depends { name: "Find" }
Depends { name: "Locator" }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment