22 #include <QGraphicsWidget>
24 #include <QTextDocument>
26 #include <kiconloader.h>
31 struct ToolTipResource
49 class ToolTipContentPrivate
52 ToolTipContentPrivate()
63 QList<WId> windowsToPreview;
64 QHash<QString, ToolTipResource> resources;
65 QWeakPointer<QGraphicsWidget> graphicsWidget;
67 bool instantPopup : 1;
73 : d(new ToolTipContentPrivate)
78 : d(new ToolTipContentPrivate(*other.d))
94 const QString &subText,
96 : d(new ToolTipContentPrivate)
104 const QString &subText,
106 : d(new ToolTipContentPrivate)
115 return d->mainText.isEmpty() &&
116 d->subText.isEmpty() &&
118 (d->windowsToPreview.size() == 0);
123 d->mainText = text.trimmed();
128 QString text = d->mainText;
135 d->subText = text.trimmed();
140 QString text = d->subText;
162 d->windowsToPreview.clear();
163 d->windowsToPreview.append(
id);
168 if (d->windowsToPreview.size() == 1) {
169 return d->windowsToPreview.first();
177 d->windowsToPreview = ids;
182 return d->windowsToPreview;
187 d->highlightWindows = highlight;
192 return d->highlightWindows;
207 d->instantPopup = enabled;
212 return d->instantPopup;
217 d->resources.insert(path.toString(), ToolTipResource(type, resource));
226 QHashIterator<QString, ToolTipResource> it(d->resources);
227 while (it.hasNext()) {
229 const ToolTipResource &r = it.value();
230 QTextDocument::ResourceType t = QTextDocument::ImageResource;
236 t = QTextDocument::HtmlResource;
239 t = QTextDocument::StyleSheetResource;
243 document->addResource(t, it.key(), r.data);
249 d->clickable = clickable;
259 d->graphicsWidget = widget;
264 return d->graphicsWidget.data();