示例#1
0
void SearchTab::currentDateChanged()
{
	const QModelIndex &currentIndex = TimelineView->timeline()->currentIndex();
	if (!currentIndex.isValid())
	{
		TimelineView->messagesView()->setChat(Chat::null);
		TimelineView->messagesView()->clearMessages();
		return;
	}

	const Talkable talkable = currentIndex.data(TalkableRole).value<Talkable>();
	const QDate date = currentIndex.data(DateRole).value<QDate>();

	auto chat = m_talkableConverter->toChat(talkable);
	if (!chat)
	{
		chat = m_chatStorage->create();
		chat.setDisplay("?");
	}
	TimelineView->messagesView()->setChat(chat);

	if (SearchedStorage && *SearchedStorage)
	{
		HistoryQuery query;
		query.setTalkable(talkable);
		query.setFromDate(date);
		query.setToDate(date);

		TimelineView->setFutureMessages((*SearchedStorage)->messages(query));
	}
	else
		TimelineView->setMessages(SortedMessages());
}
示例#2
0
void SearchTab::performSearch()
{
	HistoryQuery query;
	query.setString(Query->text());

	if (SearchByDate->isChecked())
	{
		query.setFromDate(FromDate->date());
		query.setToDate(ToDate->date());
	}

	if (SearchInChats->isChecked())
	{
		query.setTalkable(SelectChat->currentTalkable());
		SearchedStorage = &m_historyChatStorage;
		TimelineView->setTalkableHeader(tr("Chat"));
	}
	else if (SearchInStatuses->isChecked())
	{
		query.setTalkable(SelectStatusBuddy->currentTalkable());
		SearchedStorage = &StatusStorage;
		TimelineView->setTalkableHeader(tr("Buddy"));
	}
	else if (SearchInSmses->isChecked())
	{
		query.setTalkable(SelectSmsRecipient->currentTalkable());
		SearchedStorage = &SmsStorage;
		TimelineView->setTalkableHeader(tr("Recipient"));
	}

	if (SearchedStorage && *SearchedStorage)
		TimelineView->setFutureResults((*SearchedStorage)->dates(query));
	else
		TimelineView->setResults(QVector<HistoryQueryResult>());
}
示例#3
0
void HistoryMessagesTab::currentDateChanged()
{
	QDate date = timelineView()->currentDate();

	if (!Storage || !date.isValid())
	{
		TimelineView->setMessages(SortedMessages());
		return;
	}

	HistoryQuery query;
	query.setTalkable(CurrentTalkable);
	query.setFromDate(date);
	query.setToDate(date);

	Chat chat = CurrentTalkable.toChat();
	// if buddy do not have any contact we have to create chat manually
	if (!chat)
		chat = BuddyChatManager::instance()->buddyChat(CurrentTalkable.toBuddy());

	timelineView()->messagesView()->setChat(chat);
	TimelineView->setFutureMessages(Storage->messages(query));
}