Exemplo n.º 1
0
void MembersBox::Inner::selectSkip(int32 dir) {
	_time = unixtime();
	_mouseSelection = false;

	int cur = -1;
	if (_selected >= 0) {
		cur = _selected;
	}
	cur += dir;
	if (cur <= 0) {
		_selected = _rows.isEmpty() ? -1 : 0;
	} else if (cur >= _rows.size()) {
		_selected = -1;
	} else {
		_selected = cur;
	}
	if (dir > 0) {
		if (_selected < 0 || _selected >= _rows.size()) {
			_selected = -1;
		}
	} else {
		if (!_rows.isEmpty()) {
			if (_selected < 0) _selected = _rows.size() - 1;
		}
	}
	if (_selected >= 0) {
		emit mustScrollTo(st::membersMarginTop + _selected * _rowHeight, st::membersMarginTop + (_selected + 1) * _rowHeight);
	}

	update();
}
Exemplo n.º 2
0
void ContactsInner::selectSkip(int32 dir) {
	_mouseSel = false;
	int32 rh = st::profileListPhotoSize + st::profileListPadding.height() * 2, origDir = dir;
	if (_filter.isEmpty()) {
		if (_sel) {
			if (dir > 0) {
				while (dir && _sel->next->next) {
					_sel = _sel->next;
					--dir;
				}
			} else {
				while (dir && _sel->prev) {
					_sel = _sel->prev;
					++dir;
				}
			}
		} else if (dir > 0 && _contacts->list.count) {
			_sel = _contacts->list.begin;
		}
		if (_sel) {
			emit mustScrollTo(_sel->pos * rh, (_sel->pos + 1) * rh + st::contactsClose.height);
		}
	} else {
		if (dir > 0) {
			if (_filteredSel < 0 && dir > 1) {
				_filteredSel = 0;
			}
			_filteredSel += dir;
			if (_filteredSel >= _filtered.size()) {
				_filteredSel = _filtered.size() - 1;
			}
		} else if (_filteredSel > 0) {
			_filteredSel += dir;
			if (_filteredSel < 0) {
				_filteredSel = 0;
			}
		}
		if (_filteredSel >= 0) {
			emit mustScrollTo(_filteredSel * rh, (_filteredSel + 1) * rh + st::contactsClose.height);
		}
	}
	parentWidget()->update();
}
Exemplo n.º 3
0
void CountryList::setSelected(int newSelected) {
	_mouseSel = false;
	if (newSelected >= countriesNow->size()) {
		newSelected = countriesNow->size() - 1;
	}
	if (newSelected < 0) {
		newSelected = 0;
	}
	_sel = newSelected;
	emit mustScrollTo(_sel * _st.rowHeight, (_sel + 1) * _st.rowHeight);
	update();
}
Exemplo n.º 4
0
void CountrySelectInner::selectSkip(int32 dir) {
	_mouseSel = false;

	int cur = (_sel >= 0) ? _sel : -1;
	cur += dir;
	if (cur <= 0) {
		_sel = countriesNow->isEmpty() ? -1 : 0;
	} else if (cur >= countriesNow->size()) {
		_sel = -1;
	} else {
		_sel = cur;
	}
	if (_sel >= 0) {
		emit mustScrollTo(st::countriesSkip + _sel * _rowHeight, st::countriesSkip + (_sel + 1) * _rowHeight);
	}
	update();
}
Exemplo n.º 5
0
void AddParticipantInner::selectSkip(int32 dir) {
	_time = unixtime();
	_mouseSel = false;
	int32 rh = st::profileListPhotoSize + st::profileListPadding.height() * 2, origDir = dir;
	if (_filter.isEmpty()) {
		if (_sel) {
			if (dir > 0) {
				while (dir && _sel->next->next) {
					_sel = _sel->next;
					--dir;
				}
				while (contactData(_sel)->inchat && _sel->next->next) {
					_sel = _sel->next;
				}
				if (contactData(_sel)->inchat) {
					while (contactData(_sel)->inchat && _sel->prev) {
						_sel = _sel->prev;
					}
				}
			} else {
				while (dir && _sel->prev) {
					_sel = _sel->prev;
					++dir;
				}
				while (contactData(_sel)->inchat && _sel->prev) {
					_sel = _sel->prev;
				}
				if (contactData(_sel)->inchat) {
					while (contactData(_sel)->inchat && _sel->next->next) {
						_sel = _sel->next;
					}
				}
			}
		} else if (dir > 0 && _contacts->list.count) {
			_sel = _contacts->list.begin;
			while (contactData(_sel)->inchat && _sel->next->next) {
				_sel = _sel->next;
			}
		}
		if (_sel) {
			if (contactData(_sel)->inchat) {
				_sel = 0;
			} else {
				emit mustScrollTo(_sel->pos * rh, (_sel->pos + 1) * rh);
			}
		}
	} else {
		if (dir > 0) {
			if (_filteredSel < 0 && dir > 1) {
				_filteredSel = 0;
			}
			_filteredSel += dir;
			while (_filteredSel < _filtered.size() - 1 && contactData(_filtered[_filteredSel])->inchat) {
				++_filteredSel;
			}
			if (_filteredSel >= _filtered.size()) {
				_filteredSel = _filtered.size() - 1;
			}
			while (_filteredSel > 0 && contactData(_filtered[_filteredSel])->inchat) {
				--_filteredSel;
			}
		} else if (_filteredSel > 0) {
			_filteredSel += dir;
			if (_filteredSel < 0) {
				_filteredSel = 0;
			}
			if (_filteredSel < _filtered.size() - 1) {
				while (_filteredSel > 0 && contactData(_filtered[_filteredSel])->inchat) {
					--_filteredSel;
				}
			}
			while (_filteredSel < _filtered.size() - 1 && contactData(_filtered[_filteredSel])->inchat) {
				++_filteredSel;
			}
		}
		if (_filteredSel >= 0) {
			if (contactData(_filtered[_filteredSel])->inchat) {
				_filteredSel = -1;
			} else {
				emit mustScrollTo(_filteredSel * rh, (_filteredSel + 1) * rh);
			}
		}
	}
	parentWidget()->update();
}