Reorder stuff
authorManuel Nickschas <sputnick@quassel-irc.org>
Thu, 10 Jul 2008 23:39:28 +0000 (01:39 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sat, 2 Aug 2008 13:17:10 +0000 (15:17 +0200)
src/qtui/chatitem.cpp

index dfb069e..cef2598 100644 (file)
@@ -65,51 +65,6 @@ int ChatItem::heightForWidth(int width) {
   return _lines * fontMetrics()->lineSpacing();
 }
 
   return _lines * fontMetrics()->lineSpacing();
 }
 
-ChatItem::WrapColumnFinder::WrapColumnFinder(ChatItem *_item) : item(_item) {
-  wrapList = item->data(ChatLineModel::WrapListRole).value<ChatLineModel::WrapList>();
-  wordidx = 0;
-  layout = 0;
-  lastwrapcol = 0;
-  lastwrappos = 0;
-  w = 0;
-}
-
-ChatItem::WrapColumnFinder::~WrapColumnFinder() {
-  delete layout;
-}
-
-int ChatItem::WrapColumnFinder::nextWrapColumn() {
-  while(wordidx < wrapList.count()) {
-    w += wrapList.at(wordidx).width;
-    if(w >= item->width()) {
-      if(lastwrapcol >= wrapList.at(wordidx).start) {
-        // first word, and it doesn't fit
-        if(!line.isValid()) {
-          layout = item->createLayout(QTextOption::NoWrap);
-          layout->beginLayout();
-          line = layout->createLine();
-          line.setLineWidth(item->width());
-          layout->endLayout();
-        }
-        int idx = line.xToCursor(lastwrappos + item->width(), QTextLine::CursorOnCharacter);
-        qreal x = line.cursorToX(idx, QTextLine::Trailing);
-        w = w - wrapList.at(wordidx).width - (x - lastwrappos);
-        lastwrappos = x;
-        lastwrapcol = idx;
-        return idx;
-      }
-      // not the first word, so just wrap before this
-      lastwrapcol = wrapList.at(wordidx).start;
-      lastwrappos = lastwrappos + w - wrapList.at(wordidx).width;
-      w = 0;
-      return lastwrapcol;
-    }
-    w += wrapList.at(wordidx).trailing;
-    wordidx++;
-  }
-  return -1;
-}
-
 QTextLayout *ChatItem::createLayout(QTextOption::WrapMode wrapMode) {
   QTextLayout *layout = new QTextLayout(data(MessageModel::DisplayRole).toString());
 
 QTextLayout *ChatItem::createLayout(QTextOption::WrapMode wrapMode) {
   QTextLayout *layout = new QTextLayout(data(MessageModel::DisplayRole).toString());
 
@@ -181,3 +136,50 @@ void ChatItem::mouseMoveEvent ( QGraphicsSceneMouseEvent * event ) {
   } else QGraphicsTextItem::mouseMoveEvent(event);
 }
 */
   } else QGraphicsTextItem::mouseMoveEvent(event);
 }
 */
+
+/*************************************************************************************************/
+
+ChatItem::WrapColumnFinder::WrapColumnFinder(ChatItem *_item) : item(_item) {
+  wrapList = item->data(ChatLineModel::WrapListRole).value<ChatLineModel::WrapList>();
+  wordidx = 0;
+  layout = 0;
+  lastwrapcol = 0;
+  lastwrappos = 0;
+  w = 0;
+}
+
+ChatItem::WrapColumnFinder::~WrapColumnFinder() {
+  delete layout;
+}
+
+int ChatItem::WrapColumnFinder::nextWrapColumn() {
+  while(wordidx < wrapList.count()) {
+    w += wrapList.at(wordidx).width;
+    if(w >= item->width()) {
+      if(lastwrapcol >= wrapList.at(wordidx).start) {
+        // first word, and it doesn't fit
+        if(!line.isValid()) {
+          layout = item->createLayout(QTextOption::NoWrap);
+          layout->beginLayout();
+          line = layout->createLine();
+          line.setLineWidth(item->width());
+          layout->endLayout();
+        }
+        int idx = line.xToCursor(lastwrappos + item->width(), QTextLine::CursorOnCharacter);
+        qreal x = line.cursorToX(idx, QTextLine::Trailing);
+        w = w - wrapList.at(wordidx).width - (x - lastwrappos);
+        lastwrappos = x;
+        lastwrapcol = idx;
+        return idx;
+      }
+      // not the first word, so just wrap before this
+      lastwrapcol = wrapList.at(wordidx).start;
+      lastwrappos = lastwrappos + w - wrapList.at(wordidx).width;
+      w = 0;
+      return lastwrapcol;
+    }
+    w += wrapList.at(wordidx).trailing;
+    wordidx++;
+  }
+  return -1;
+}