void eListBoxBase::endAtomic() { if (!--in_atomic) { if (atomic_redraw == arAll) invalidateContent(); else if (atomic_redraw == arCurrentOld) { if (atomic_new != -1) invalidateEntry(atomic_new); if (atomic_old != -1) invalidateEntry(atomic_old); } if (atomic_selchanged) if (!entries) /*emit*/ SendSelChanged(0); else /*emit*/ SendSelChanged(*current); if (atomic_selected) if (!entries) /*emit*/ SendSelected(0); else /*emit*/ SendSelected(*current); } }
void Cache::invalidateEntry(Socket *socket, const QString &path) { KUrl url = socket->getCurrentUrl(); url.setPath(path); invalidateEntry(url); }
void eListBoxBase::lostFocus() { #ifndef DISABLE_LCD if ( descr ) { delete LCDTmp; LCDTmp=0; delete tmpDescr; tmpDescr=0; } #endif --have_focus; if (entries) if ( newFocus() ) //recalced ? { ePtrList<eListBoxEntry>::iterator it = current; init(); setCurrent(it); } else if ( isVisible() ) { int i = 0; for (ePtrList<eListBoxEntry>::iterator entry(top); entry != bottom; ++i, ++entry) if (entry == current) invalidateEntry(i); } #ifndef DISABLE_LCD if (parent && parent->LCDElement) parent->LCDElement->setText(""); #endif }
void eListBoxBase::setActiveColor(gColor back, gColor front) { if (back) colorActiveB=back; if (front) colorActiveF=front; if ((back || front) && current != childs.end()) { int i = 0; for (ePtrList<eListBoxEntry>::iterator it(top); it != bottom; ++i, ++it) { if (it == current) { invalidateEntry(i); break; } } } }
void eListBoxBase::gotFocus() { #ifndef DISABLE_LCD if (parent && parent->LCDElement) // detect if LCD Avail if (descr) { parent->LCDElement->setText(""); LCDTmp = new eLabel(parent->LCDElement); LCDTmp->hide(); eSize s = parent->LCDElement->getSize(); LCDTmp->move(ePoint(0,s.height()/2)); LCDTmp->resize(eSize(s.width(), s.height()/2)); LCDTmp->show(); tmpDescr = new eLabel(parent->LCDElement); tmpDescr->hide(); tmpDescr->move(ePoint(0,0)); tmpDescr->resize(eSize(s.width(), s.height()/2)); tmpDescr->setText( descr->getText() ); tmpDescr->show(); } #endif ++have_focus; if (entries) { if ( newFocus() ) // recalced ? { ePtrList<eListBoxEntry>::iterator it = current; init(); setCurrent(it); } else if ( isVisible() ) { int i=0; for (ePtrList<eListBoxEntry>::iterator entry(top); entry != bottom; ++i, ++entry) if (entry == current) invalidateEntry(i); } } if (flags & flagShowEntryHelp) setHelpText( current != childs.end() ? current->getHelpText(): eString(" ")); // eString(_("no description available"))); }
int eListBoxBase::moveSelection(int dir, bool sendSelected) { int direction=0, forceredraw=0; if (!entries) return 0; ePtrList<eListBoxEntry>::iterator oldptr=current, oldtop=top; switch (dir) { case dirPageDown: direction=+1; for (int i = 0; i < MaxEntries; ++i) { ++currentPos; if (++current == bottom) // unten (rechts) angekommen? page down { if (bottom == childs.end()) // einzige ausnahme: unten (rechts) angekommen { --currentPos; --current; break; } for (int i = 0; i < MaxEntries * columns; ++i) { if (bottom != childs.end()) ++bottom; if (top != childs.end()) ++top; } } } /* when we didn't find a selectable item, keep scrolling down till we find one */ while ( !current->isSelectable() && current != --childs.end()) { ++current; ++currentPos; } /* when we couldn't find a selectable item below, find the nearest one above */ while ( !current->isSelectable() && current != childs.begin()) { --current; --currentPos; } break; case dirPageUp: direction=-1; for (int i = 0; i < MaxEntries; ++i) { if (current == childs.begin()) break; --currentPos; if (current-- == top/* && current != childs.begin()*/ ) // oben (links) angekommen? page up { for (int i = 0; i < MaxEntries * columns; ++i) { if (--top == childs.begin()) // einzige ausnahme: oben (links) angekommen break; } // und einmal bottom neuberechnen :) bottom=top; for (int i = 0; i < MaxEntries*columns; ++i) if (bottom != childs.end()) ++bottom; } } /* when we didn't find a selectable item, keep scrolling up till we find one */ while ( !current->isSelectable() && current != childs.begin()) { --current; --currentPos; } /* when we couldn't find a selectable item above, find the nearest one below */ while ( !current->isSelectable() && current != --childs.end()) { ++current; ++currentPos; } break; case dirUp: { bool first=true; while (first || !current->isSelectable() ) { first=false; if ( current == childs.begin() ) // wrap around? { direction=+1; top = bottom = current = childs.end(); --current; currentPos=entries-1; int cnt = entries%(MaxEntries*columns); for (int i = 0; i < (cnt?cnt:MaxEntries*columns); ++i, --top) if (top == childs.begin()) break; } else { direction=-1; --currentPos; if (current-- == top) // new top must set { for (int i = 0; i < MaxEntries*columns; ++i, --top) if (top == childs.begin()) break; bottom=top; for (int i = 0; i < MaxEntries*columns; ++i, ++bottom) if (bottom == childs.end()) break; } } } } break; case dirDown: { bool first=true; while (first || !current->isSelectable() ) { first=false; if ( current == --ePtrList<eListBoxEntry>::iterator(childs.end()) ) // wrap around? { direction=-1; currentPos=0; top = current = bottom = childs.begin(); // goto first for (int i = 0; i < MaxEntries * columns; ++i, ++bottom) if ( bottom == childs.end() ) break; } else { direction=+1; ++currentPos; if (++current == bottom) // ++current ?? { for (int i = 0; i<MaxEntries * columns; ++i) { if (bottom != childs.end() ) ++bottom; if (top != childs.end() ) ++top; } } } } break; } case dirFirst: direction=-1; currentPos=0; top = current = bottom = childs.begin(); // goto first; for (int i = 0; i < MaxEntries * columns; ++i, ++bottom) if ( bottom == childs.end() ) break; /* when the first item isn't a selectable item, keep scrolling down till we find one */ while ( !current->isSelectable() && current != --childs.end()) { ++current; ++currentPos; } break; case dirLast: { direction=1; top = bottom = current = childs.end(); --current; currentPos=entries-1; int cnt = entries%(MaxEntries*columns); for (int i = 0; i < (cnt?cnt:MaxEntries*columns); ++i, --top) if (top == childs.begin()) break; /* when the last item isn't a selectable item, keep scrolling up till we find one */ while ( !current->isSelectable() && current != childs.begin()) { --current; --currentPos; } break; } default: return 0; } if (current != oldptr) // current has changed { if (movemode) { // feel free to rewrite using stl::copy[_backward], but i didn't succeed. std::list<eListBoxEntry*>::iterator o=oldptr, c=current, curi=current, oldi=oldptr; int count=0; eListBoxEntry* old=*o; if (direction > 0) { ++o; ++c; while (o != c) { *oldi++=*o++; ++count; } } else { while (o != curi) { *oldi--=*--o; ++count; } } if (count > 1) forceredraw=1; *curi=old; } } if (flags & flagShowEntryHelp) setHelpText( current != childs.end() ? current->getHelpText():eString(_("no description available"))); if (!in_atomic) { /*emit*/ SendSelChanged(*current); if ( sendSelected ) /*emit*/ SendSelected(*current); } else { atomic_selchanged=1; if ( sendSelected ) atomic_selected=1; } if (isVisible()) { if ((oldtop != top) || forceredraw) { if (in_atomic) atomic_redraw=arAll; else invalidateContent(); } else if ( current != oldptr) { int i=0; int old=-1, cur=-1; for (ePtrList<eListBoxEntry>::iterator entry(top); entry != bottom; ++i, ++entry) if ( entry == oldptr) old=i; else if ( entry == current ) cur=i; if (in_atomic) { if (atomic_redraw == arNothing) { atomic_old=old; atomic_redraw = arCurrentOld; } if (atomic_redraw == arCurrentOld) atomic_new=cur; } else { if (old != -1) invalidateEntry(old); if (cur != -1) invalidateEntry(cur); } } } return 1; }
int eListBoxBase::setCurrent(const eListBoxEntry *c, bool sendSelected ) { /* if (childs.empty() || ((current != childs.end()) && (*current == c))) // no entries or current is equal the entry to search return E_ALLREADY_SELECTED; // do nothing*/ if ( !entries ) return E_COULDNT_FIND; ePtrList<eListBoxEntry>::iterator item(childs.begin()), it(childs.begin()); int cnt=0; for ( ; item != childs.end(); ++item, ++cnt) if ( *item == c ) break; if ( item == childs.end() ) // entry not in listbox... do nothing return E_COULDNT_FIND; currentPos=cnt; int newCurPos=-1; int oldCurPos=-1; ePtrList<eListBoxEntry>::iterator oldCur(current); int i = 0; for (it=top; it != bottom; ++it, ++i) // check if entry to set between bottom and top { if (it == item) { newCurPos=i; current = it; } if ( it == oldCur) oldCurPos=i; } if (newCurPos != -1) // found on current screen, so redraw only old and new { if (isVisible()) { if (in_atomic) { if (atomic_redraw == arNothing) { atomic_redraw = arCurrentOld; atomic_old = oldCurPos; } if (atomic_redraw == arCurrentOld) atomic_new = newCurPos; }else { invalidateEntry(newCurPos); if (oldCurPos != -1) invalidateEntry(oldCurPos); } } } else // then we start to search from begin { bottom = childs.begin(); while (newCurPos == -1 && MaxEntries) // MaxEntries is already checked above... { if ( bottom != childs.end() ) top = bottom; // n鋍hster Durchlauf for (i = 0; (i < (MaxEntries*columns) ) && (bottom != childs.end()); ++bottom, ++i) { if (bottom == item) { current = bottom; // we have found ++newCurPos; } } } if (isVisible()) { if (!in_atomic) invalidateContent(); // Draw all else atomic_redraw=arAll; } } if (!in_atomic) { /*emit*/ SendSelChanged(*current); if ( sendSelected ) /*emit*/ SendSelected(*current); }else { atomic_selchanged=1; if ( sendSelected ) atomic_selected=1; } return OK; }