Add ChatLine item
authorManuel Nickschas <sputnick@quassel-irc.org>
Thu, 11 Aug 2011 21:31:20 +0000 (23:31 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Thu, 11 Aug 2011 21:31:20 +0000 (23:31 +0200)
src/qmlui/qml/ChatLine.qml [new file with mode: 0644]
src/qmlui/qml/ChatView.qml
src/qmlui/qml/qml.qrc
src/qmlui/qmlmessagemodel.h

diff --git a/src/qmlui/qml/ChatLine.qml b/src/qmlui/qml/ChatLine.qml
new file mode 100644 (file)
index 0000000..1cf3ae8
--- /dev/null
@@ -0,0 +1,11 @@
+import QtQuick 1.1
+
+Item {
+  Row {
+    id: chatLine
+    Text { text: timestamp; wrapMode: Text.NoWrap; width: 100 }
+    Text { text: sender; wrapMode: Text.NoWrap; width: 100 }
+    Text { text: contents; wrapMode: Text.Wrap; width: chatView.width-200}
+  }
+  height: chatLine.height
+}
index 6996873..5781fc7 100644 (file)
@@ -4,41 +4,26 @@ import QtQuick 1.0
 Rectangle {
   id: container
 
-  Component {
-      id: msgDelegate
-      Item {
-        id: msgDelegateItem
-        Row {
-          id: chatline
-          Text { text: timestamp; wrapMode: Text.NoWrap; width: 100 }
-          Text { text: sender; wrapMode: Text.NoWrap; width: 100 }
-          Text { text: contents; wrapMode: Text.Wrap; width: flickable.width-200}
-        }
-        height: chatline.height
-      }
-  }
-
   ListView {
-    id: flickable
+    id: chatView
     anchors.fill: parent
-
-
     model: msgModel
-
-    delegate: msgDelegate
+    delegate: Component {
+      ChatLine { }
+    }
 
     Connections {
       target: msgModel
-      onRowsInserted: flickable.positionViewAtEnd();
+      onRowsInserted: chatView.positionViewAtEnd();
     }
 
     Rectangle {
       id: scrollbar
-      anchors.right: flickable.right
-      y: flickable.visibleArea.yPosition * flickable.height
+      anchors.right: chatView.right
+      y: chatView.visibleArea.yPosition * chatView.height
       width: 10
-      height: flickable.visibleArea.heightRatio * flickable.height
-      color: "black"
+      height: chatView.visibleArea.heightRatio * chatView.height
+      color: "grey"
     }
   }
 }
index d58f0f6..9da2458 100644 (file)
@@ -1,6 +1,7 @@
 <!DOCTYPE RCC>
 <RCC version="1.0">
   <qresource prefix="/qml" >
+    <file>ChatLine.qml</file>
     <file>ChatView.qml</file>
   </qresource>
 </RCC>
index c5af010..052db04 100644 (file)
@@ -37,7 +37,7 @@ public:
     UserRole
   };
 
-  QmlMessageModel(QObject *parent);
+  QmlMessageModel(QObject *parent = 0);
   virtual QVariant data(const QModelIndex &index, int role) const;
 
   virtual inline const MessageModelItem *messageItemAt(int i) const { return &_messageList[i]; }