The next unread button in forums search for child items and start at the top when the end of the list is reached.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5716 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-10-23 20:51:35 +00:00
parent 232af8e71e
commit c1c9894daf
2 changed files with 52 additions and 30 deletions

View File

@ -1226,23 +1226,34 @@ void ForumsDialog::downloadAllFiles()
void ForumsDialog::nextUnreadMessage() void ForumsDialog::nextUnreadMessage()
{ {
QTreeWidgetItem* currentItem = ui.threadTreeWidget->currentItem(); QTreeWidgetItem *currentItem = ui.threadTreeWidget->currentItem();
if( !currentItem )
{ while (TRUE) {
currentItem = ui.threadTreeWidget->topLevelItem(0); QTreeWidgetItemIterator itemIterator = currentItem ? QTreeWidgetItemIterator(currentItem, QTreeWidgetItemIterator::NotHidden) : QTreeWidgetItemIterator(ui.threadTreeWidget, QTreeWidgetItemIterator::NotHidden);
if( !currentItem )
return; QTreeWidgetItem *item;
while ((item = *itemIterator) != NULL) {
itemIterator++;
if (item == currentItem) {
continue;
} }
do uint32_t status = item->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt();
{ if (IS_UNREAD(status)) {
uint32_t status = currentItem->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt(); ui.threadTreeWidget->setCurrentItem(item);
if( IS_UNREAD(status) ) ui.threadTreeWidget->scrollToItem(item, QAbstractItemView::EnsureVisible);
{
ui.threadTreeWidget->setCurrentItem(currentItem);
return; return;
} }
} while( (currentItem = ui.threadTreeWidget->itemBelow(currentItem)) != NULL ); }
if (currentItem == NULL) {
break;
}
/* start from top */
currentItem = NULL;
}
} }
// TODO // TODO

View File

@ -1238,23 +1238,34 @@ void ForumsV2Dialog::downloadAllFiles()
void ForumsV2Dialog::nextUnreadMessage() void ForumsV2Dialog::nextUnreadMessage()
{ {
QTreeWidgetItem* currentItem = ui.threadTreeWidget->currentItem(); QTreeWidgetItem *currentItem = ui.threadTreeWidget->currentItem();
if( !currentItem )
{ while (TRUE) {
currentItem = ui.threadTreeWidget->topLevelItem(0); QTreeWidgetItemIterator itemIterator = currentItem ? QTreeWidgetItemIterator(currentItem, QTreeWidgetItemIterator::NotHidden) : QTreeWidgetItemIterator(ui.threadTreeWidget, QTreeWidgetItemIterator::NotHidden);
if( !currentItem )
return; QTreeWidgetItem *item;
while ((item = *itemIterator) != NULL) {
itemIterator++;
if (item == currentItem) {
continue;
} }
do uint32_t status = item->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt();
{ if (IS_UNREAD(status)) {
uint32_t status = currentItem->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt(); ui.threadTreeWidget->setCurrentItem(item);
if( IS_MSG_UNREAD(status) ) ui.threadTreeWidget->scrollToItem(item, QAbstractItemView::EnsureVisible);
{
ui.threadTreeWidget->setCurrentItem(currentItem);
return; return;
} }
} while( (currentItem = ui.threadTreeWidget->itemBelow(currentItem)) != NULL ); }
if (currentItem == NULL) {
break;
}
/* start from top */
currentItem = NULL;
}
} }
// TODO // TODO