Correctly resize ChatView height on disconnect
[quassel.git] / src / qtui / chatscene.cpp
index e04784c..681996a 100644 (file)
@@ -140,6 +140,7 @@ void ChatScene::modelReset() {
   }
   _lines.clear();
   setSceneRect(QRectF(0, 0, _width, 0));
+  emit heightChanged(0);
 }
 
 void ChatScene::setWidth(qreal w) {
@@ -239,6 +240,8 @@ void ChatScene::updateSelection(const QPointF &pos) {
   if(newstart == newend && minColumn == ChatLineModel::ContentsColumn) {
     _lines[curRow]->setSelected(false);
     _isSelecting = false;
+    Q_ASSERT(_selectingItem); // this seems to not always be true, but I have no idea why
+                              // adding this assert to make sure the occasional segfault is caused by this
     _selectingItem->continueSelecting(_selectingItem->mapFromScene(pos));
   }
 }
@@ -266,12 +269,7 @@ void ChatScene::mousePressEvent(QGraphicsSceneMouseEvent *event) {
 
 void ChatScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
   if(_isSelecting && !event->buttons() & Qt::LeftButton) {
-#   ifdef Q_WS_X11
-      QApplication::clipboard()->setText(selectionToString(), QClipboard::Selection);
-#   endif
-//# else
-      QApplication::clipboard()->setText(selectionToString());
-//# endif
+    putToClipboard(selectionToString());
     _isSelecting = false;
     event->accept();
   } else {
@@ -279,6 +277,16 @@ void ChatScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
   }
 }
 
+void ChatScene::putToClipboard(const QString &selection) {
+  // TODO Configure clipboards
+#   ifdef Q_WS_X11
+  QApplication::clipboard()->setText(selection, QClipboard::Selection);
+#   endif
+//# else
+  QApplication::clipboard()->setText(selection);
+//# endif
+}
+
 //!\brief Convert current selection to human-readable string.
 QString ChatScene::selectionToString() const {
   //TODO Make selection format configurable!