mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-15 02:44:20 -05:00
removed call to :clone in refill of threads in ForumsDialog
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2937 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
4380251c08
commit
42f728a483
@ -325,7 +325,9 @@ static void CleanupItems (QList<QTreeWidgetItem *> &Items)
|
|||||||
{
|
{
|
||||||
QList<QTreeWidgetItem *>::iterator Item;
|
QList<QTreeWidgetItem *>::iterator Item;
|
||||||
for (Item = Items.begin (); Item != Items.end (); Item++) {
|
for (Item = Items.begin (); Item != Items.end (); Item++) {
|
||||||
delete (*Item);
|
if (*Item) {
|
||||||
|
delete (*Item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -550,7 +552,7 @@ void ForumsDialog::FillForums(QTreeWidgetItem *Forum, QList<QTreeWidgetItem *> &
|
|||||||
|
|
||||||
QTreeWidgetItem *Child;
|
QTreeWidgetItem *Child;
|
||||||
|
|
||||||
// iterate all new childs
|
// iterate all new children
|
||||||
QList<QTreeWidgetItem *>::iterator NewChild;
|
QList<QTreeWidgetItem *>::iterator NewChild;
|
||||||
for (NewChild = ChildList.begin (); NewChild != ChildList.end (); NewChild++) {
|
for (NewChild = ChildList.begin (); NewChild != ChildList.end (); NewChild++) {
|
||||||
// search existing child
|
// search existing child
|
||||||
@ -565,7 +567,7 @@ void ForumsDialog::FillForums(QTreeWidgetItem *Forum, QList<QTreeWidgetItem *> &
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ChildIndexFound >= 0) {
|
if (ChildIndexFound >= 0) {
|
||||||
// delete all childs between
|
// delete all children between
|
||||||
while (ChildIndexCur < ChildIndexFound) {
|
while (ChildIndexCur < ChildIndexFound) {
|
||||||
Child = Forum->takeChild (ChildIndexCur);
|
Child = Forum->takeChild (ChildIndexCur);
|
||||||
delete (Child);
|
delete (Child);
|
||||||
@ -583,10 +585,11 @@ void ForumsDialog::FillForums(QTreeWidgetItem *Forum, QList<QTreeWidgetItem *> &
|
|||||||
} else {
|
} else {
|
||||||
// insert new child
|
// insert new child
|
||||||
if (ChildIndexCur < ChildCount) {
|
if (ChildIndexCur < ChildCount) {
|
||||||
Forum->insertChild (ChildIndexCur, (*NewChild)->clone ());
|
Forum->insertChild (ChildIndexCur, *NewChild);
|
||||||
} else {
|
} else {
|
||||||
Forum->addChild ((*NewChild)->clone ());
|
Forum->addChild (*NewChild);
|
||||||
}
|
}
|
||||||
|
*NewChild = NULL;
|
||||||
}
|
}
|
||||||
ChildIndexCur++;
|
ChildIndexCur++;
|
||||||
}
|
}
|
||||||
@ -857,9 +860,29 @@ void ForumsDialog::FillThreads(QList<QTreeWidgetItem *> &ThreadList)
|
|||||||
{
|
{
|
||||||
int Index = 0;
|
int Index = 0;
|
||||||
QTreeWidgetItem *Thread;
|
QTreeWidgetItem *Thread;
|
||||||
|
QList<QTreeWidgetItem *>::iterator NewThread;
|
||||||
|
|
||||||
|
// delete not existing
|
||||||
|
while (Index < ui.threadTreeWidget->topLevelItemCount ()) {
|
||||||
|
Thread = ui.threadTreeWidget->topLevelItem (Index);
|
||||||
|
|
||||||
|
// search existing new thread
|
||||||
|
int Found = -1;
|
||||||
|
for (NewThread = ThreadList.begin (); NewThread != ThreadList.end (); NewThread++) {
|
||||||
|
if (Thread->text (5) == (*NewThread)->text (5)) {
|
||||||
|
// found it
|
||||||
|
Found = Index;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Found >= 0) {
|
||||||
|
Index++;
|
||||||
|
} else {
|
||||||
|
delete (ui.threadTreeWidget->takeTopLevelItem (Index));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// iterate all new threads
|
// iterate all new threads
|
||||||
QList<QTreeWidgetItem *>::iterator NewThread;
|
|
||||||
for (NewThread = ThreadList.begin (); NewThread != ThreadList.end (); NewThread++) {
|
for (NewThread = ThreadList.begin (); NewThread != ThreadList.end (); NewThread++) {
|
||||||
// search existing thread
|
// search existing thread
|
||||||
int Found = -1;
|
int Found = -1;
|
||||||
@ -882,28 +905,8 @@ void ForumsDialog::FillThreads(QList<QTreeWidgetItem *> &ThreadList)
|
|||||||
FillChildren (Thread, *NewThread);
|
FillChildren (Thread, *NewThread);
|
||||||
} else {
|
} else {
|
||||||
// add new thread
|
// add new thread
|
||||||
ui.threadTreeWidget->addTopLevelItem ((*NewThread)->clone ());
|
ui.threadTreeWidget->addTopLevelItem (*NewThread);
|
||||||
}
|
*NewThread = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
// delete rest
|
|
||||||
while (Index < ui.threadTreeWidget->topLevelItemCount ()) {
|
|
||||||
Thread = ui.threadTreeWidget->topLevelItem (Index);
|
|
||||||
|
|
||||||
// search existing new thread
|
|
||||||
int Found = -1;
|
|
||||||
for (NewThread = ThreadList.begin (); NewThread != ThreadList.end (); NewThread++) {
|
|
||||||
if (Thread->text (5) == (*NewThread)->text (5)) {
|
|
||||||
// found it
|
|
||||||
Found = Index;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (Found >= 0) {
|
|
||||||
Index++;
|
|
||||||
} else {
|
|
||||||
Thread = ui.threadTreeWidget->takeTopLevelItem (Index);
|
|
||||||
delete (Thread);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -917,6 +920,28 @@ void ForumsDialog::FillChildren(QTreeWidgetItem *Parent, QTreeWidgetItem *NewPar
|
|||||||
QTreeWidgetItem *Child;
|
QTreeWidgetItem *Child;
|
||||||
QTreeWidgetItem *NewChild;
|
QTreeWidgetItem *NewChild;
|
||||||
|
|
||||||
|
// delete not existing
|
||||||
|
while (Index < Parent->childCount ()) {
|
||||||
|
Child = Parent->child (Index);
|
||||||
|
|
||||||
|
// search existing new child
|
||||||
|
int Found = -1;
|
||||||
|
int Count = NewParent->childCount();
|
||||||
|
for (NewIndex = 0; NewIndex < Count; NewIndex++) {
|
||||||
|
NewChild = NewParent->child (NewIndex);
|
||||||
|
if (NewChild->text (5) == Child->text (5)) {
|
||||||
|
// found it
|
||||||
|
Found = Index;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Found >= 0) {
|
||||||
|
Index++;
|
||||||
|
} else {
|
||||||
|
delete (Parent->takeChild (Index));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// iterate all new children
|
// iterate all new children
|
||||||
for (NewIndex = 0; NewIndex < NewCount; NewIndex++) {
|
for (NewIndex = 0; NewIndex < NewCount; NewIndex++) {
|
||||||
NewChild = NewParent->child (NewIndex);
|
NewChild = NewParent->child (NewIndex);
|
||||||
@ -942,30 +967,9 @@ void ForumsDialog::FillChildren(QTreeWidgetItem *Parent, QTreeWidgetItem *NewPar
|
|||||||
FillChildren (Child, NewChild);
|
FillChildren (Child, NewChild);
|
||||||
} else {
|
} else {
|
||||||
// add new child
|
// add new child
|
||||||
Parent->addChild (NewChild->clone ());
|
Parent->addChild (NewParent->takeChild(NewIndex));
|
||||||
}
|
NewIndex--;
|
||||||
}
|
NewCount--;
|
||||||
|
|
||||||
// delete rest
|
|
||||||
while (Index < Parent->childCount ()) {
|
|
||||||
Child = Parent->child (Index);
|
|
||||||
|
|
||||||
// search existing new child
|
|
||||||
int Found = -1;
|
|
||||||
int Count = NewParent->childCount();
|
|
||||||
for (NewIndex = 0; NewIndex < Count; NewIndex++) {
|
|
||||||
NewChild = NewParent->child (NewIndex);
|
|
||||||
if (NewChild->text (5) == Child->text (5)) {
|
|
||||||
// found it
|
|
||||||
Found = Index;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (Found >= 0) {
|
|
||||||
Index++;
|
|
||||||
} else {
|
|
||||||
Child = Parent->takeChild (Index);
|
|
||||||
delete (Child);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user