AccountRoomList keyboard up/down
Item activation or proper scrolling not reimplemented yet
This commit is contained in:
		@@ -9,11 +9,12 @@ ListView {
 | 
				
			|||||||
    currentIndex: -1
 | 
					    currentIndex: -1
 | 
				
			||||||
    keyNavigationWraps: true
 | 
					    keyNavigationWraps: true
 | 
				
			||||||
    highlightMoveDuration: theme.animationDuration
 | 
					    highlightMoveDuration: theme.animationDuration
 | 
				
			||||||
 | 
					    highlightResizeDuration: theme.animationDuration
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Keep highlighted delegate at the center
 | 
					    // Keep highlighted delegate at the center
 | 
				
			||||||
    highlightRangeMode: ListView.ApplyRange
 | 
					    highlightRangeMode: ListView.ApplyRange
 | 
				
			||||||
    preferredHighlightBegin: height / 2 - currentItemHeight
 | 
					    preferredHighlightBegin: height / 2 - currentItemHeight / 2
 | 
				
			||||||
    preferredHighlightEnd: height / 2 + currentItemHeight
 | 
					    preferredHighlightEnd: height / 2 + currentItemHeight / 2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    maximumFlickVelocity: 4000
 | 
					    maximumFlickVelocity: 4000
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -65,11 +66,8 @@ ListView {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    property bool allowDragging: true
 | 
					    property bool allowDragging: true
 | 
				
			||||||
 | 
					 | 
				
			||||||
    property alias cursorShape: mouseArea.cursorShape
 | 
					    property alias cursorShape: mouseArea.cursorShape
 | 
				
			||||||
 | 
					    property int currentItemHeight: currentItem ? currentItem.height : 0
 | 
				
			||||||
    readonly property int currentItemHeight:
 | 
					 | 
				
			||||||
        currentItem ? currentItem.height : 0
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Connections {
 | 
					    Connections {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,6 +17,10 @@ Column {
 | 
				
			|||||||
        roomList.model.count < 1 &&
 | 
					        roomList.model.count < 1 &&
 | 
				
			||||||
        ! utils.filterMatches(mainPane.filter, model.display_name)
 | 
					        ! utils.filterMatches(mainPane.filter, model.display_name)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    readonly property alias account: account
 | 
				
			||||||
 | 
					    readonly property alias collapsed: account.collapsed
 | 
				
			||||||
 | 
					    readonly property alias roomList: roomList
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Account {
 | 
					    Account {
 | 
				
			||||||
        id: account
 | 
					        id: account
 | 
				
			||||||
@@ -63,6 +67,8 @@ Column {
 | 
				
			|||||||
            userId: delegate.userId
 | 
					            userId: delegate.userId
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        highlight: null  // managed by the AccountRoomsList
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Behavior on height { HNumberAnimation {} }
 | 
					        Behavior on height { HNumberAnimation {} }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,15 +14,97 @@ HListView {
 | 
				
			|||||||
        height: childrenRect.height
 | 
					        height: childrenRect.height
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    highlightFollowsCurrentItem: false
 | 
				
			||||||
 | 
					    currentItemHeight:
 | 
				
			||||||
 | 
					        selectedRoom ? selectedRoom.height :
 | 
				
			||||||
 | 
					        currentItem ? currentItem.account.height : 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    highlight: Rectangle {
 | 
				
			||||||
 | 
					        y:
 | 
				
			||||||
 | 
					            selectedRoom ?
 | 
				
			||||||
 | 
					            currentItem.y + currentItem.account.height +
 | 
				
			||||||
 | 
					            currentItem.roomList.currentItem.y :
 | 
				
			||||||
 | 
					            currentItem.y
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        width: mainPaneList.width
 | 
				
			||||||
 | 
					        height:
 | 
				
			||||||
 | 
					            selectedRoom ?
 | 
				
			||||||
 | 
					            currentItem.roomList.currentItem.height :
 | 
				
			||||||
 | 
					            currentItem.account.height
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        color: theme.controls.listView.highlight
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Behavior on y { HNumberAnimation {} }
 | 
				
			||||||
 | 
					        Behavior on height { HNumberAnimation {} }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    readonly property Room selectedRoom:
 | 
				
			||||||
 | 
					        currentItem ? currentItem.roomList.currentItem : null
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function previous(activate=true) {
 | 
					    function previous(activate=true) {
 | 
				
			||||||
 | 
					        let currentAccount = currentItem
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Nothing is selected
 | 
				
			||||||
 | 
					        if (! currentAccount) {
 | 
				
			||||||
            decrementCurrentIndex()
 | 
					            decrementCurrentIndex()
 | 
				
			||||||
        if (activate) activateLimiter.restart()
 | 
					            return
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        let roomList = currentAccount.roomList
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // An account is selected
 | 
				
			||||||
 | 
					        if (! roomList.currentItem) {
 | 
				
			||||||
 | 
					            decrementCurrentIndex()
 | 
				
			||||||
 | 
					            // Select the last room of the previous account that's now selected
 | 
				
			||||||
 | 
					            currentItem.roomList.decrementCurrentIndex()
 | 
				
			||||||
 | 
					            return
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // A room is selected
 | 
				
			||||||
 | 
					        const selectedIsFirst = roomList.currentIndex === 0
 | 
				
			||||||
 | 
					        const noRooms         = roomList.count === 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (currentAccount.collapsed || selectedIsFirst || noRooms) {
 | 
				
			||||||
 | 
					            // Have the account itself be selected
 | 
				
			||||||
 | 
					            roomList.currentIndex = -1
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            roomList.decrementCurrentIndex()
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function next(activate=true) {
 | 
					    function next(activate=true) {
 | 
				
			||||||
 | 
					        const currentAccount = currentItem
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Nothing is selected
 | 
				
			||||||
 | 
					        if (! currentAccount) {
 | 
				
			||||||
            incrementCurrentIndex()
 | 
					            incrementCurrentIndex()
 | 
				
			||||||
        if (activate) activateLimiter.restart()
 | 
					            return
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        const roomList = currentAccount.roomList
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // An account is selected
 | 
				
			||||||
 | 
					        if (! roomList.currentItem) {
 | 
				
			||||||
 | 
					            if (currentAccount.collapsed || roomList.count === 0) {
 | 
				
			||||||
 | 
					                incrementCurrentIndex()
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                roomList.incrementCurrentIndex()
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // A room is selected
 | 
				
			||||||
 | 
					        const selectedIsLast = roomList.currentIndex >= roomList.count - 1
 | 
				
			||||||
 | 
					        const noRooms        = roomList.count === 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (currentAccount.collapsed || selectedIsLast || noRooms) {
 | 
				
			||||||
 | 
					            roomList.currentIndex = -1
 | 
				
			||||||
 | 
					            mainPaneList.incrementCurrentIndex()
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            roomList.incrementCurrentIndex()
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function activate() {
 | 
					    function activate() {
 | 
				
			||||||
@@ -31,42 +113,20 @@ HListView {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    function accountSettings() {
 | 
					    function accountSettings() {
 | 
				
			||||||
        if (! currentItem) incrementCurrentIndex()
 | 
					        if (! currentItem) incrementCurrentIndex()
 | 
				
			||||||
 | 
					        currentItem.roomList.currentIndex = -1
 | 
				
			||||||
        pageLoader.showPage(
 | 
					        currentItem.account.activated()
 | 
				
			||||||
            "AccountSettings/AccountSettings",
 | 
					 | 
				
			||||||
            {userId: currentItem.item.delegateModel.user_id},
 | 
					 | 
				
			||||||
        )
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function addNewChat() {
 | 
					    function addNewChat() {
 | 
				
			||||||
        if (! currentItem) incrementCurrentIndex()
 | 
					        if (! currentItem) incrementCurrentIndex()
 | 
				
			||||||
 | 
					        currentItem.roomList.currentIndex = -1
 | 
				
			||||||
        pageLoader.showPage(
 | 
					        currentItem.account.activated()
 | 
				
			||||||
            "AddChat/AddChat",
 | 
					 | 
				
			||||||
            {userId: currentItem.item.delegateModel.user_id},
 | 
					 | 
				
			||||||
        )
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function toggleCollapseAccount() {
 | 
					    function toggleCollapseAccount() {
 | 
				
			||||||
        if (mainPane.filter) return
 | 
					        if (mainPane.filter) return
 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (! currentItem) incrementCurrentIndex()
 | 
					        if (! currentItem) incrementCurrentIndex()
 | 
				
			||||||
 | 
					        currentItem.account.toggleCollapse()
 | 
				
			||||||
        if (currentItem.item.delegateModel.type === "Account") {
 | 
					 | 
				
			||||||
            currentItem.item.toggleCollapse()
 | 
					 | 
				
			||||||
            return
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        for (let i = 0;  i < model.source.length; i++) {
 | 
					 | 
				
			||||||
            let item = model.source[i]
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (item.type === "Account" && item.user_id ==
 | 
					 | 
				
			||||||
                currentItem.item.delegateModel.user_id)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                currentIndex = i
 | 
					 | 
				
			||||||
                currentItem.item.toggleCollapse()
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user