From 8c325f80977d57d60de0872685f93707504cae03 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Mon, 1 Feb 2010 19:53:43 +0000 Subject: [PATCH] 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. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35383 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/preferences/locale/LocaleWindow.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/preferences/locale/LocaleWindow.cpp b/src/preferences/locale/LocaleWindow.cpp index 49071d0c76..c4dc5b3e09 100644 --- a/src/preferences/locale/LocaleWindow.cpp +++ b/src/preferences/locale/LocaleWindow.cpp @@ -100,6 +100,8 @@ class LanguageListView: public BOutlineListView 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 @@ class LanguageListView: public BOutlineListView 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 @@ LanguageListView::MoveItemFrom(BOutlineListView* origin, int32 index, // 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(origin->Superitem( - origin->FullListItemAt(index))); + LanguageListItem* itemToMove = static_cast( + origin->Superitem(origin->FullListItemAt(index))); if (itemToMove == NULL) { itemToMove = static_cast( origin->FullListItemAt(index)); @@ -221,7 +233,6 @@ LanguageListView::InitiateDrag(BPoint point, int32 index, bool) 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