Use a less lazy method to update the threads list view (use the table model
listener mechanism to inform about the exact changes instead of rebuilding the complete list). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31084 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -43,23 +43,47 @@ public:
|
|||||||
|
|
||||||
bool Update()
|
bool Update()
|
||||||
{
|
{
|
||||||
for (int32 i = 0; Thread* thread = fThreads.ItemAt(i); i++)
|
if (fTeam == NULL) {
|
||||||
thread->RemoveReference();
|
for (int32 i = 0; Thread* thread = fThreads.ItemAt(i); i++)
|
||||||
fThreads.MakeEmpty();
|
thread->RemoveReference();
|
||||||
|
fThreads.MakeEmpty();
|
||||||
|
|
||||||
if (fTeam == NULL)
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
AutoLocker<Team> locker(fTeam);
|
AutoLocker<Team> locker(fTeam);
|
||||||
|
|
||||||
for (ThreadList::ConstIterator it = fTeam->Threads().GetIterator();
|
ThreadList::ConstIterator it = fTeam->Threads().GetIterator();
|
||||||
Thread* thread = it.Next();) {
|
Thread* newThread = it.Next();
|
||||||
if (!fThreads.AddItem(thread))
|
int32 index = 0;
|
||||||
|
|
||||||
|
// remove no longer existing threads
|
||||||
|
while (Thread* oldThread = fThreads.ItemAt(index)) {
|
||||||
|
if (oldThread == newThread) {
|
||||||
|
index++;
|
||||||
|
newThread = it.Next();
|
||||||
|
} else {
|
||||||
|
// TODO: Not particularly efficient!
|
||||||
|
fThreads.RemoveItemAt(index);
|
||||||
|
oldThread->RemoveReference();
|
||||||
|
NotifyRowsRemoved(index, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// add new threads
|
||||||
|
int32 countBefore = fThreads.CountItems();
|
||||||
|
while (newThread != NULL) {
|
||||||
|
if (!fThreads.AddItem(newThread))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
thread->AddReference();
|
newThread->AddReference();
|
||||||
|
newThread = it.Next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32 count = fThreads.CountItems();
|
||||||
|
if (count > countBefore)
|
||||||
|
NotifyRowsAdded(countBefore, count - countBefore);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,11 +193,8 @@ ThreadListView::MessageReceived(BMessage* message)
|
|||||||
{
|
{
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
case MSG_SYNC_THREAD_LIST:
|
case MSG_SYNC_THREAD_LIST:
|
||||||
if (fThreadsTableModel != NULL) {
|
if (fThreadsTableModel != NULL)
|
||||||
fThreadsTable->SetTableModel(NULL);
|
|
||||||
fThreadsTableModel->Update();
|
fThreadsTableModel->Update();
|
||||||
fThreadsTable->SetTableModel(fThreadsTableModel);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
BGroupView::MessageReceived(message);
|
BGroupView::MessageReceived(message);
|
||||||
|
|||||||
Reference in New Issue
Block a user