From d7568eabd2d523e465efeb763e7644ea81af4ae7 Mon Sep 17 00:00:00 2001 From: czeidler Date: Sat, 17 Mar 2012 17:16:50 +0000 Subject: [PATCH] Add IndexOf methods. --- headers/libs/alm/ALMLayout.h | 2 ++ src/libs/alm/ALMLayout.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/headers/libs/alm/ALMLayout.h b/headers/libs/alm/ALMLayout.h index f24fafd2b6..5eea243da0 100644 --- a/headers/libs/alm/ALMLayout.h +++ b/headers/libs/alm/ALMLayout.h @@ -50,6 +50,8 @@ public: int32 CountYTabs() const; XTab* XTabAt(int32 index, bool ordered = false); YTab* YTabAt(int32 index, bool ordered = false); + int32 IndexOf(XTab* tab, bool ordered = false); + int32 IndexOf(YTab* tab, bool ordered = false); Row* AddRow(YTab* top, YTab* bottom); Column* AddColumn(XTab* left, XTab* right); diff --git a/src/libs/alm/ALMLayout.cpp b/src/libs/alm/ALMLayout.cpp index a0261c4e3b..1e022acfa7 100644 --- a/src/libs/alm/ALMLayout.cpp +++ b/src/libs/alm/ALMLayout.cpp @@ -279,6 +279,30 @@ BALMLayout::YTabAt(int32 index, bool ordered) } +int32 +BALMLayout::IndexOf(XTab* tab, bool ordered) +{ + if (ordered && !fXTabsSorted) { + Layout(); + fXTabList.SortItems(CompareXTabFunc); + fXTabsSorted = true; + } + return fXTabList.IndexOf(tab); +} + + +int32 +BALMLayout::IndexOf(YTab* tab, bool ordered) +{ + if (ordered && !fYTabsSorted) { + Layout(); + fYTabList.SortItems(CompareYTabFunc); + fYTabsSorted = true; + } + return fYTabList.IndexOf(tab); +} + + int CompareXTabFunc(const XTab* tab1, const XTab* tab2) {