fix webpreview for urls with url-encoded chars
[quassel.git] / src / qtui / chatscene.cpp
index b159dc9..86a461b 100644 (file)
@@ -92,15 +92,15 @@ ChatScene::ChatScene(QAbstractItemModel *model, const QString &idString, qreal w
 
   setHandleXLimits();
 
+  if(model->rowCount() > 0)
+    rowsInserted(QModelIndex(), 0, model->rowCount() - 1);
+
   connect(model, SIGNAL(rowsInserted(const QModelIndex &, int, int)),
           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);
-
 #ifdef HAVE_WEBKIT
   webPreview.timer.setSingleShot(true);
   connect(&webPreview.timer, SIGNAL(timeout()), this, SLOT(webPreviewNextStep()));
@@ -438,7 +438,7 @@ void ChatScene::firstHandlePositionChanged(qreal xpos) {
   if(_firstColHandlePos == xpos)
     return;
 
-  _firstColHandlePos = xpos;
+  _firstColHandlePos = xpos >= 0 ? xpos : 0;
   ChatViewSettings viewSettings(this);
   viewSettings.setValue("FirstColumnHandlePos", _firstColHandlePos);
   ChatViewSettings defaultSettings;
@@ -882,7 +882,7 @@ bool ChatScene::event(QEvent *e) {
 //  Webkit Only stuff
 // ========================================
 #ifdef HAVE_WEBKIT
-void ChatScene::loadWebPreview(ChatItem *parentItem, const QString &url, const QRectF &urlRect) {
+void ChatScene::loadWebPreview(ChatItem *parentItem, const QUrl &url, const QRectF &urlRect) {
   if(!_showWebPreview)
     return;
 
@@ -967,7 +967,7 @@ void ChatScene::webPreviewNextStep() {
       webPreview.previewItem = 0;
     }
     webPreview.parentItem = 0;
-    webPreview.url = QString();
+    webPreview.url = QUrl();
     webPreview.urlRect = QRectF();
     webPreview.previewState = WebPreview::NoPreview;
   }