Centering the Hour Model
111 onCurrentIndexChanged: { 112 var centerIndex = model.count / 2 113 if (currentIndex > centerIndex) { 114 for (var i = 0; i < currentIndex - centerIndex; ++i) { 115 hourModel.append(hourModel.get(0)) 116 hourModel.remove(0) 117 } 118 } else { 119 for (var i = 0; i < centerIndex - currentIndex; ++i) { 120 hourModel.insert(0, hourModel.get(hourModel.count - 1)) 121 hourModel.remove(hourModel.count - 1) 122 } 123 } 124 currentIndex = centerIndex 125 }
A screenshot of code handling a change to the current index by repeatedly moving items in an hour model until the selected item reaches the center. The joke is the overly manual, loop-based approach to rotating a list, making it relatable to programmers dealing with awkward UI logic or legacy code. EN: A screenshot of code handling a change to the current index by repeatedly moving items in an hour model until the selected item reaches the center. The joke is the overly manual, loop-based approach to rotating a list, making it relatable to programmers dealing with awkward UI logic or legacy code.
code editor / редактор кодаprogramming code / программный кодline numbers / номера строкtext cursor area / область текстаwhite background / белый фонgreen syntax highlighting / зелёная подсветка синтаксисаpurple syntax highlighting / фиолетовая подсветка синтаксисаhour model / модель часовcurly braces / фигурные скобкиloop / цикл
- @ithueti / 16742 2025-09-01
- Type
- image
- Size
- 800×367 · 45.7 KiB
- Mood
- sarcastic, relatable
- Language
- en
- Added