From cd74595290599d5147edf1a12b86c60025d57773 Mon Sep 17 00:00:00 2001 From: Mikko Ahlroth Date: Mon, 29 Sep 2014 18:32:40 +0300 Subject: [PATCH] Backup backup --- qml/js/buffers.js | 19 +++++++++++++++++++ qml/pages/BufferList.qml | 9 ++++++++- qml/pages/BufferView.qml | 5 +++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/qml/js/buffers.js b/qml/js/buffers.js index 0e7a778..fdd6ad0 100644 --- a/qml/js/buffers.js +++ b/qml/js/buffers.js @@ -21,6 +21,10 @@ function Buffer(pointer, number, name, title) { this.number = number; this.name = name; this.title = title; + this.visible = false; + + // Amount of unread lines in this buffer + this.unreadCount = 0; // A listmodel where we put the messages of this buffer this.textList = Qt.createQmlObject('import QtQuick 2.0; ListModel {}', @@ -33,8 +37,23 @@ function Buffer(pointer, number, name, title) { prefix: prefix, str: str }); + + if (!this.active) { + ++this.unreadCount; + } }; + // This buffer has become visible to the user + this.activate = function() { + this.active = true; + this.unreadCount = 0; + } + + // This buffer will be hidden from the user + this.deactivate = function() { + this.active = false; + } + // Send input into this buffer this.input = function(str) { EQ.command('input 0x' + this.pointer + ' ' + str); diff --git a/qml/pages/BufferList.qml b/qml/pages/BufferList.qml index f0b0008..2cd2c81 100644 --- a/qml/pages/BufferList.qml +++ b/qml/pages/BufferList.qml @@ -30,7 +30,8 @@ Page { bufferListModel.append({ pointer: buffers[i].pointer, number: buffers[i].number, - name: buffers[i].name + name: buffers[i].name, + unreadCount: buffers[i].unreadCount }); } } @@ -77,6 +78,12 @@ Page { color: listItem.highlighted ? Theme.highlightColor : Theme.primaryColor; } + + Label { + text: unreadCount + color: listItem.highlighted ? Theme.highlightColor + : Theme.primaryColor; + } } Component { diff --git a/qml/pages/BufferView.qml b/qml/pages/BufferView.qml index 462c1cf..2130ff2 100644 --- a/qml/pages/BufferView.qml +++ b/qml/pages/BufferView.qml @@ -27,11 +27,16 @@ Page { } function changeBuffer(newBuffer) { + if (buffer !== null) { + buffer.deactivate(); + } + // Replace current list model with new list D.c('Changing buffer to ' + newBuffer.name); buffer = newBuffer; topic.title = newBuffer.title; textList.model = newBuffer.textList; + buffer.activate(); } SilicaFlickable {