예제 #1
0
void NewGroupInner::changeCheckState(DialogRow *row) {
	if (contactData(row)->check) {
		contactData(row)->check = false;
		--_selCount;
	} else if (_selCount < cMaxGroupCount()) {
		contactData(row)->check = true;
		++_selCount;
	}
}
예제 #2
0
void AddParticipantInner::changeCheckState(DialogRow *row) {
	if (contactData(row)->check) {
		contactData(row)->check = false;
		--_selCount;
	} else if (_selCount + _chat->count < cMaxGroupCount()) {
		contactData(row)->check = true;
		++_selCount;
	}
}
예제 #3
0
void NewGroupInner::paintDialog(QPainter &p, DialogRow *row, bool sel) {
	int32 left = st::profileListPadding.width();

	UserData *user = row->history->peer->asUser();
	ContactData *data = contactData(row);

	if (_selCount >= cMaxGroupCount() && !data->check) {
		sel = false;
	}

	if (sel || data->check) {
		p.fillRect(0, 0, width(), 2 * st::profileListPadding.height() + st::profileListPhotoSize, (data->check ? st::profileActiveBG : st::profileHoverBG)->b);
	}

	p.drawPixmap(left, st::profileListPadding.height(), user->photo->pix(st::profileListPhotoSize));

	if (data->check) {
		p.setPen(st::white->p);
	} else {
		p.setPen(st::profileListNameColor->p);
	}
	data->name.drawElided(p, left + st::profileListPhotoSize + st::participantDelta, st::profileListNameTop, width() - st::profileListPadding.width() - st::profileListPhotoSize - st::profileListPadding.width() - st::participantDelta - st::scrollDef.width - st::profileCheckRect.pxWidth());

	if (sel || data->check) {
		p.drawPixmap(QPoint(width() - st::profileCheckRect.pxWidth() - st::profileCheckDeltaX, st::profileListPadding.height() + (st::profileListPhotoSize - st::profileCheckRect.pxHeight()) / 2 - st::profileCheckDeltaY), App::sprite(), (data->check ? st::profileCheckActiveRect : st::profileCheckRect));
	}

	p.setFont(st::profileSubFont->f);
	if (data->check) {
		p.setPen(st::white->p);
	} else {
		p.setPen((user->onlineTill >= _time ? st::profileOnlineColor : st::profileOfflineColor)->p);
	}
	p.drawText(left + st::profileListPhotoSize + st::participantDelta, st::profileListPadding.height() + st::profileListPhotoSize - 6, data->online);
}
예제 #4
0
void AddParticipantInner::chooseParticipant() {
	_time = unixtime();
	int32 rh = st::profileListPhotoSize + st::profileListPadding.height() * 2, from;
	if (_filter.isEmpty()) {
		if (!_sel || contactData(_sel)->inchat) return;
		changeCheckState(_sel);
	} else {
		if (_filteredSel < 0 || _filteredSel >= _filtered.size() || contactData(_filtered[_filteredSel])->inchat) return;

		DialogRow *row = _filtered[_filteredSel];
		changeCheckState(row);

		PeerData *peer = row->history->peer;
		emit selectAllQuery();
	}
	parentWidget()->update();
}
예제 #5
0
void ContactsInner::paintDialog(QPainter &p, DialogRow *row, bool sel) {
	int32 left = st::profileListPadding.width();

	UserData *user = row->history->peer->asUser();
	ContactData *data = contactData(row);

	if (sel) {
		p.fillRect(0, 0, width(), 2 * st::profileListPadding.height() + st::profileListPhotoSize, st::profileHoverBG->b);
	}

	p.drawPixmap(left, st::profileListPadding.height(), user->photo->pix(st::profileListPhotoSize));

	p.setPen(st::profileListNameColor->p);
	data->name.drawElided(p, left + st::profileListPhotoSize + st::participantDelta, st::profileListNameTop, width() - st::profileListPadding.width() - st::profileListPhotoSize - st::profileListPadding.width() - st::participantDelta - st::scrollDef.width - st::contactsImg.pxWidth());

	if (sel) {
		p.drawPixmap(QPoint(width() - st::contactsImg.pxWidth() - st::profileCheckDeltaX, st::profileListPadding.height() + (st::profileListPhotoSize - st::contactsImg.pxHeight()) / 2 - st::profileCheckDeltaY), App::sprite(), st::contactsImg);
	}

	p.setFont(st::profileSubFont->f);
	p.setPen((user->onlineTill >= _time ? st::profileOnlineColor : st::profileOfflineColor)->p);

	p.drawText(left + st::profileListPhotoSize + st::participantDelta, st::profileListPadding.height() + st::profileListPhotoSize - st::profileListStatusBottom, data->online);
}
예제 #6
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();
}
예제 #7
0
void AddParticipantInner::updateFilter(QString filter) {
	_time = unixtime();
	QStringList f;
	if (!filter.isEmpty()) {
		QStringList filterList = filter.split(cWordSplit(), QString::SkipEmptyParts);
		int l = filterList.size();

		f.reserve(l);
		for (int i = 0; i < l; ++i) {
			QString filterName = filterList[i].trimmed();
			if (filterName.isEmpty()) continue;
			f.push_back(filterName);
		}
		filter = f.join(' ');
	}
	if (_filter != filter) {
		int32 rh = (st::profileListPhotoSize + st::profileListPadding.height() * 2);
		_filter = filter;
		if (_filter.isEmpty()) {
			resize(width(), _contacts->list.count * rh);
			if (_contacts->list.count) {
				_sel = _contacts->list.begin;
				while (_sel->next->next &&& contactData(_sel)->inchat) {
					_sel = _sel->next;
				}
			}
		} else {
			QStringList::const_iterator fb = f.cbegin(), fe = f.cend(), fi;

			_filtered.clear();
			if (!f.isEmpty()) {
				DialogsList *dialogsToFilter = 0;
				if (_contacts->list.count) {
					for (fi = fb; fi != fe; ++fi) {
						DialogsIndexed::DialogsIndex::iterator i = _contacts->index.find(fi->at(0));
						if (i == _contacts->index.cend()) {
							dialogsToFilter = 0;
							break;
						}
						if (!dialogsToFilter || dialogsToFilter->count > i.value()->count) {
							dialogsToFilter = i.value();
						}
					}
				}
				if (dialogsToFilter && dialogsToFilter->count) {
					_filtered.reserve(dialogsToFilter->count);
					for (DialogRow *i = dialogsToFilter->begin, *e = dialogsToFilter->end; i != e; i = i->next) {
						const PeerData::Names &names(i->history->peer->names);
						PeerData::Names::const_iterator nb = names.cbegin(), ne = names.cend(), ni;
						for (fi = fb; fi != fe; ++fi) {
							QString filterName(*fi);
							for (ni = nb; ni != ne; ++ni) {
								if (ni->startsWith(*fi)) {
									break;
								}
							}
							if (ni == ne) {
								break;
							}
						}
						if (fi == fe) {
							i->attached = 0;
							_filtered.push_back(i);
						}
					}
				}
			}
			_filteredSel = _filtered.isEmpty() ? -1 : 0;
			while (_filteredSel < _filtered.size() - 1 && contactData(_filtered[_filteredSel])->inchat) {
				++_filteredSel;
			}

			resize(width(), _filtered.size() * rh);
		}
		if (parentWidget()) parentWidget()->update();
		loadProfilePhotos(0);
	}
}