#include <QGraphicsSceneMouseEvent>
#include <QMenu>
#include <QPersistentModelIndex>
-#include <QWebView>
+
+#ifdef HAVE_WEBKIT
+# include <QWebView>
+#endif
#include "chatitem.h"
#include "chatline.h"
#include "client.h"
#include "clientbacklogmanager.h"
#include "columnhandleitem.h"
+#include "contextmenuactionprovider.h"
#include "iconloader.h"
#include "messagefilter.h"
#include "qtui.h"
this, SLOT(rowsInserted(const QModelIndex &, int, int)));
connect(model, SIGNAL(rowsAboutToBeRemoved(const QModelIndex &, int, int)),
this, SLOT(rowsAboutToBeRemoved(const QModelIndex &, int, int)));
+ connect(model, SIGNAL(dataChanged(QModelIndex, QModelIndex)), SLOT(dataChanged(QModelIndex, QModelIndex)));
if(model->rowCount() > 0)
rowsInserted(QModelIndex(), 0, model->rowCount() - 1);
updateSceneRect();
}
+void ChatScene::dataChanged(const QModelIndex &tl, const QModelIndex &br) {
+ // This should only be sent (currently) if the style is reloaded -> re-layout the whole scene
+ // TODO: Check range and only do partial relayouts, if appropriate
+
+ layout();
+}
+
void ChatScene::updateForViewport(qreal width, qreal height) {
_viewportHeight = height;
setWidth(width);
void ChatScene::setWidth(qreal width) {
if(width == _sceneRect.width())
return;
+ layout(width);
+}
+void ChatScene::layout(qreal width) {
// clock_t startT = clock();
+ if(width < 0)
+ width = _sceneRect.width();
+
// disabling the index while doing this complex updates is about
// 2 to 10 times faster!
//setItemIndexMethod(QGraphicsScene::NoIndex);
item->addActionsToMenu(&menu, item->mapFromScene(pos));
else
// no item -> default scene actions
- Client::mainUi()->actionProvider()->addActions(&menu, filter(), BufferId());
+ GraphicalUi::contextMenuActionProvider()->addActions(&menu, filter(), BufferId());
menu.exec(event->screenPos());
stringToClipboard(selection(), mode);
}
-void ChatScene::stringToClipboard(const QString &str, QClipboard::Mode mode) {
+void ChatScene::stringToClipboard(const QString &str_, QClipboard::Mode mode) {
+ QString str = str_;
+ // remove trailing linefeeds
+ if(str.endsWith('\n'))
+ str.chop(1);
+
switch(mode) {
case QClipboard::Clipboard:
QApplication::clipboard()->setText(str);