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:
parent
b15883863d
commit
2898a353e2
@ -43,23 +43,47 @@ public:
|
||||
|
||||
bool Update()
|
||||
{
|
||||
for (int32 i = 0; Thread* thread = fThreads.ItemAt(i); i++)
|
||||
thread->RemoveReference();
|
||||
fThreads.MakeEmpty();
|
||||
if (fTeam == NULL) {
|
||||
for (int32 i = 0; Thread* thread = fThreads.ItemAt(i); i++)
|
||||
thread->RemoveReference();
|
||||
fThreads.MakeEmpty();
|
||||
|
||||
if (fTeam == NULL)
|
||||
return true;
|
||||
}
|
||||
|
||||
AutoLocker<Team> locker(fTeam);
|
||||
|
||||
for (ThreadList::ConstIterator it = fTeam->Threads().GetIterator();
|
||||
Thread* thread = it.Next();) {
|
||||
if (!fThreads.AddItem(thread))
|
||||
ThreadList::ConstIterator it = fTeam->Threads().GetIterator();
|
||||
Thread* newThread = it.Next();
|
||||
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;
|
||||
|
||||
thread->AddReference();
|
||||
newThread->AddReference();
|
||||
newThread = it.Next();
|
||||
}
|
||||
|
||||
int32 count = fThreads.CountItems();
|
||||
if (count > countBefore)
|
||||
NotifyRowsAdded(countBefore, count - countBefore);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -169,11 +193,8 @@ ThreadListView::MessageReceived(BMessage* message)
|
||||
{
|
||||
switch (message->what) {
|
||||
case MSG_SYNC_THREAD_LIST:
|
||||
if (fThreadsTableModel != NULL) {
|
||||
fThreadsTable->SetTableModel(NULL);
|
||||
if (fThreadsTableModel != NULL)
|
||||
fThreadsTableModel->Update();
|
||||
fThreadsTable->SetTableModel(fThreadsTableModel);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
BGroupView::MessageReceived(message);
|
||||
|
Loading…
Reference in New Issue
Block a user