Ticket #10332: MythUIButtonListItem_disable.diff
| File MythUIButtonListItem_disable.diff, 9.4 KB (added by , 15 years ago) |
|---|
-
mythtv/libs/libmythui/mythuibuttonlist.cpp
diff --git a/mythtv/libs/libmythui/mythuibuttonlist.cpp b/mythtv/libs/libmythui/mythuibuttonlist.cpp index 3601fab..d61ee24 100644
a b void MythUIButtonList::SetValueByData(QVariant data) 1498 1498 1499 1499 void MythUIButtonList::SetItemCurrent(MythUIButtonListItem *item) 1500 1500 { 1501 if (!item->isEnabled()) return; 1501 1502 int newIndex = m_itemList.indexOf(item); 1502 1503 SetItemCurrent(newIndex); 1503 1504 } … … void MythUIButtonList::SetItemCurrent(int current, int topPosition) 1510 1511 if (current == -1 || current >= m_itemList.size()) 1511 1512 return; 1512 1513 1514 if (!m_itemList.at(current)->isEnabled()) return; 1515 1513 1516 if (current == m_selPosition && 1514 1517 (topPosition == -1 || topPosition == m_topPosition)) 1515 1518 return; … … bool MythUIButtonList::MoveUp(MovementUnit unit, uint amount) 1886 1889 else if (m_wrapStyle == WrapCaptive) 1887 1890 return true; 1888 1891 1892 findEnabledUp(unit); 1893 1889 1894 break; 1890 1895 1891 1896 case MoveColumn: … … bool MythUIButtonList::MoveUp(MovementUnit unit, uint amount) 1900 1905 m_selPosition = pos + (m_columns - 1); 1901 1906 else if (m_wrapStyle == WrapCaptive) 1902 1907 return true; 1908 findEnabledUp(unit); 1903 1909 1904 1910 break; 1905 1911 … … bool MythUIButtonList::MoveUp(MovementUnit unit, uint amount) 1928 1934 } 1929 1935 else if (m_wrapStyle == WrapCaptive) 1930 1936 return true; 1937 findEnabledUp(unit); 1931 1938 1932 1939 break; 1933 1940 … … bool MythUIButtonList::MoveUp(MovementUnit unit, uint amount) 1936 1943 m_selPosition = qMax(0, m_selPosition - (int)m_itemsVisible); 1937 1944 else 1938 1945 m_selPosition = PageUp(); 1946 findEnabledUp(unit); 1939 1947 1940 1948 break; 1941 1949 1942 1950 case MoveMid: 1943 1951 m_selPosition = (int)(m_itemList.size() / 2); 1952 findEnabledDown(unit); 1944 1953 break; 1945 1954 1946 1955 case MoveMax: 1947 1956 m_selPosition = 0; 1957 findEnabledDown(unit); 1948 1958 break; 1949 1959 1950 1960 case MoveByAmount: … … bool MythUIButtonList::MoveUp(MovementUnit unit, uint amount) 1955 1965 else if (m_wrapStyle > WrapNone) 1956 1966 m_selPosition = m_itemList.size() - 1; 1957 1967 } 1968 findEnabledUp(unit); 1958 1969 1959 1970 break; 1960 1971 } … … bool MythUIButtonList::MoveUp(MovementUnit unit, uint amount) 1972 1983 return true; 1973 1984 } 1974 1985 1986 1987 /** 1988 * If the current item is not enabled, find the next enabled one 1989 */ 1990 void MythUIButtonList::findEnabledDown(MovementUnit unit) 1991 { 1992 if (m_selPosition<0 || m_selPosition >= m_itemList.size() 1993 || m_itemList.at(m_selPosition)->isEnabled()) 1994 return; 1995 1996 int step = (unit=MoveRow)?m_columns:1; 1997 if (unit == MoveRow && m_wrapStyle == WrapFlowing)unit=MoveItem; 1998 if (unit == MoveColumn) 1999 { 2000 while ((m_selPosition + 1) % m_columns > 0 && !m_itemList.at(m_selPosition)->isEnabled()) 2001 ++m_selPosition; 2002 2003 if (m_itemList.at(m_selPosition)->isEnabled()) return; 2004 if (m_wrapStyle > WrapNone) 2005 { 2006 m_selPosition = m_selPosition - (m_columns - 1); 2007 while ((m_selPosition + 1) % m_columns > 0 && !m_itemList.at(m_selPosition)->isEnabled()) 2008 ++m_selPosition; 2009 } 2010 } 2011 else 2012 { 2013 2014 while (!m_itemList.at(m_selPosition)->isEnabled() 2015 && (m_selPosition < m_itemList.size() - step)) 2016 m_selPosition+=step; 2017 2018 if (!m_itemList.at(m_selPosition)->isEnabled() && m_wrapStyle > WrapNone) 2019 { 2020 m_selPosition=(m_selPosition+step)%m_itemList.size(); 2021 2022 while (!m_itemList.at(m_selPosition)->isEnabled() 2023 && (m_selPosition < m_itemList.size() - step)) 2024 m_selPosition+=step; 2025 } 2026 } 2027 } 2028 2029 void MythUIButtonList::findEnabledUp(MovementUnit unit) 2030 { 2031 if (m_selPosition<0 || m_selPosition >= m_itemList.size() 2032 || m_itemList.at(m_selPosition)->isEnabled()) 2033 return; 2034 2035 int step = (unit=MoveRow)?m_columns:1; 2036 if (unit == MoveRow && m_wrapStyle == WrapFlowing)unit=MoveItem; 2037 if (unit == MoveColumn) 2038 { 2039 while ((m_selPosition + 1) % m_columns > 0 && !m_itemList.at(m_selPosition)->isEnabled()) 2040 ++m_selPosition; 2041 2042 if (m_itemList.at(m_selPosition)->isEnabled()) return; 2043 if (m_wrapStyle > WrapNone) 2044 { 2045 m_selPosition = m_selPosition - (m_columns - 1); 2046 while ((m_selPosition + 1) % m_columns > 0 && !m_itemList.at(m_selPosition)->isEnabled()) 2047 ++m_selPosition; 2048 } 2049 } 2050 else 2051 { 2052 while (!m_itemList.at(m_selPosition)->isEnabled() 2053 && (m_selPosition < m_itemList.size() - step)) 2054 m_selPosition-=step; 2055 2056 if (!m_itemList.at(m_selPosition)->isEnabled() && m_wrapStyle > WrapNone) 2057 { 2058 m_selPosition=(m_selPosition+step)%m_itemList.size(); 2059 2060 while (!m_itemList.at(m_selPosition)->isEnabled() 2061 && (m_selPosition < m_itemList.size() - step)) 2062 m_selPosition+=step; 2063 } 2064 } 2065 } 2066 2067 1975 2068 bool MythUIButtonList::MoveDown(MovementUnit unit, uint amount) 1976 2069 { 1977 2070 int pos = m_selPosition; … … bool MythUIButtonList::MoveDown(MovementUnit unit, uint amount) 1988 2081 m_selPosition = 0; 1989 2082 else if (m_wrapStyle == WrapCaptive) 1990 2083 return true; 2084 findEnabledDown(unit); 1991 2085 1992 2086 break; 1993 2087 … … bool MythUIButtonList::MoveDown(MovementUnit unit, uint amount) 2003 2097 m_selPosition = pos - (m_columns - 1); 2004 2098 else if (m_wrapStyle == WrapCaptive) 2005 2099 return true; 2100 findEnabledDown(unit); 2006 2101 2007 2102 break; 2008 2103 … … bool MythUIButtonList::MoveDown(MovementUnit unit, uint amount) 2023 2118 m_selPosition = (pos % m_columns); 2024 2119 else if (m_wrapStyle == WrapCaptive) 2025 2120 return true; 2026 2121 findEnabledDown(unit); 2027 2122 break; 2028 2123 2029 2124 case MovePage: … … bool MythUIButtonList::MoveDown(MovementUnit unit, uint amount) 2032 2127 m_selPosition + (int)m_itemsVisible); 2033 2128 else 2034 2129 m_selPosition = PageDown(); 2035 2130 findEnabledDown(unit); 2036 2131 break; 2037 2132 2038 2133 case MoveMax: 2039 2134 m_selPosition = m_itemCount - 1; 2135 findEnabledUp(unit); 2040 2136 break; 2041 2137 2042 2138 case MoveByAmount: … … bool MythUIButtonList::MoveDown(MovementUnit unit, uint amount) 2047 2143 else if (m_wrapStyle > WrapNone) 2048 2144 m_selPosition = 0; 2049 2145 } 2146 findEnabledDown(unit); 2050 2147 2051 2148 break; 2052 2149 } … … bool MythUIButtonList::keyPressEvent(QKeyEvent *e) 2385 2482 { 2386 2483 MythUIButtonListItem *item = GetItemCurrent(); 2387 2484 2388 if (item )2485 if (item && item->isEnabled()) 2389 2486 emit itemClicked(item); 2390 2487 } 2391 2488 else if (action == "SEARCH") … … MythUIButtonListItem::MythUIButtonListItem(MythUIButtonList *lbtype, 2886 2983 m_checkable = checkable; 2887 2984 m_state = state; 2888 2985 m_showArrow = showArrow; 2986 m_enabled = true; 2987 2889 2988 m_data = 0; 2890 2989 2891 2990 if (state >= NotChecked) … … MythUIButtonListItem::MythUIButtonListItem(MythUIButtonList *lbtype, 2911 3010 m_checkable = false; 2912 3011 m_state = CantCheck; 2913 3012 m_showArrow = false; 3013 m_enabled = true; 2914 3014 2915 3015 if (m_parent) 2916 3016 m_parent->InsertItem(this, listPosition); … … void MythUIButtonListItem::setDrawArrow(bool flag) 3225 3325 m_showArrow = flag; 3226 3326 } 3227 3327 3328 bool MythUIButtonListItem::isEnabled() const 3329 { 3330 return m_enabled; 3331 } 3332 void MythUIButtonListItem::setEnabled(bool flag) 3333 { 3334 m_enabled = flag; 3335 } 3336 3228 3337 void MythUIButtonListItem::SetData(QVariant data) 3229 3338 { 3230 3339 m_data = data; … … void MythUIButtonListItem::SetToRealButton(MythUIStateType *button, bool selecte 3250 3359 3251 3360 QString state; 3252 3361 3253 if (selected) 3362 if (!m_enabled) 3363 { 3364 state = m_parent->m_active ? "disabledactive" : "disabledinactive"; 3365 } 3366 else if (selected) 3254 3367 { 3255 3368 button->MoveToTop(); 3256 3369 state = m_parent->m_active ? "selectedactive" : "selectedinactive"; -
mythtv/libs/libmythui/mythuibuttonlist.h
diff --git a/mythtv/libs/libmythui/mythuibuttonlist.h b/mythtv/libs/libmythui/mythuibuttonlist.h index 81115ee..bf6e850 100644
a b class MUI_PUBLIC MythUIButtonListItem 72 72 bool checkable() const; 73 73 void setCheckable(bool flag); 74 74 75 bool isEnabled() const; 76 void setEnabled(bool flag); 77 75 78 CheckState state() const; 76 79 void setChecked(CheckState state); 77 80 … … class MUI_PUBLIC MythUIButtonListItem 94 97 CheckState m_state; 95 98 QVariant m_data; 96 99 bool m_showArrow; 100 bool m_enabled; 97 101 98 102 QMap<QString, TextProperties> m_strings; 99 103 QMap<QString, MythImage*> m_images; … … class MUI_PUBLIC MythUIButtonList : public MythUIType 234 238 235 239 bool DoFind(bool doMove, bool searchForward); 236 240 241 void findEnabledUp(MovementUnit unit); 242 void findEnabledDown(MovementUnit unit); 243 237 244 /* methods for subclasses to override */ 238 245 virtual void CalculateVisibleItems(void); 239 246 virtual QPoint GetButtonPosition(int column, int row) const;
