Author: pulkomandy Date: 2010-02-01 20:53:43 +0100 (Mon, 01 Feb 2010) New Revision: 35383 Changeset: http://dev.haiku-os.org/changeset/35383/haiku Modified: haiku/trunk/src/preferences/locale/LocaleWindow.cpp Log: Fix some more bugs in the locale preflet lists. Dragging from one list to the other should now always work, while drawing inside a list is not finished, working on it now. Modified: haiku/trunk/src/preferences/locale/LocaleWindow.cpp =================================================================== --- haiku/trunk/src/preferences/locale/LocaleWindow.cpp 2010-02-01 19:11:19 UTC (rev 35382) +++ haiku/trunk/src/preferences/locale/LocaleWindow.cpp 2010-02-01 19:53:43 UTC (rev 35383) @@ -100,6 +100,8 @@ if (message->FindPointer("list", (void**)&list) == B_OK) { // It comes from a list if (list == this) { + // TODO : parent item should stay at top level and childs should not + // move under another parent. // It comes from ourselves : move the item around in the list int32 count = CountItems(); if (fDropIndex < 0 || fDropIndex > count) @@ -122,6 +124,16 @@ if (fDropIndex < 0 || fDropIndex > count) fDropIndex = count; + // ensure we always drop things at top-level and not + // in the middle of another outline + if (Superitem(FullListItemAt(fDropIndex))) { + // Item has a parent + fDropIndex = FullListIndexOf(Superitem(FullListItemAt(fDropIndex))); + } + + // Item is now a top level one - we must insert just below its last child + fDropIndex += CountItemsUnder(FullListItemAt(fDropIndex),false); + int32 index; for (int32 i = 0; message->FindInt32("index", i, &index) == B_OK; i++) { @@ -182,8 +194,8 @@ // Check that the node we are going to move is a top-level one. // If not, we want his parent instead - LanguageListItem* itemToMove = static_cast<LanguageListItem*>(origin->Superitem( - origin->FullListItemAt(index))); + LanguageListItem* itemToMove = static_cast<LanguageListItem*>( + origin->Superitem(origin->FullListItemAt(index))); if (itemToMove == NULL) { itemToMove = static_cast<LanguageListItem*>( origin->FullListItemAt(index)); @@ -221,7 +233,6 @@ msg.AddPointer("list",(void*)(this)); int32 index; for (int32 i = 0; (index = FullListCurrentSelection(i)) >= 0; i++) { - // TODO : include all childs and parents as needed msg.AddInt32("index", index); } // figure out drag rect