Exemplo n.º 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());
}
Exemplo n.º 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>());
}
Exemplo n.º 3
0
void ShowHistoryAction::showDaysMessages(QAction *action, int days)
{
	Action *act = qobject_cast<Action *>(action);
	Chat actionChat = act ? act->context()->chat() : Chat::null;

	ChatWidget *chatWidget = action->data().value<ChatWidget *>();
	if (!chatWidget)
	{
		m_historyWindowService->show(actionChat);
		return;
	}

	WebkitMessagesView *chatMessagesView = chatWidget->chatMessagesView();
	if (!chatMessagesView)
	{
		m_historyWindowService->show(actionChat);
		return;
	}

	chatMessagesView->setForcePruneDisabled(0 != days);

	if (-1 == days)
	{
		m_historyWindowService->show(chatWidget->chat());
		return;
	}

	const Chat &buddyChat = m_buddyChatManager->buddyChat(chatWidget->chat());
	const Chat &messagesChat = buddyChat ? buddyChat : chatWidget->chat();
	HistoryStorage *historyStorage = m_history->currentStorage();

	if (!historyStorage)
		return;

	HistoryQuery query;
	query.setTalkable(messagesChat);

	if (0 == days)
		query.setLimit(configuration()->deprecatedApi()->readUnsignedNumEntry("History", "ChatHistoryCitation", 10));
	else
		query.setFromDate(QDate::currentDate().addDays(-days));

	new HistoryMessagesPrepender(historyStorage->messages(query), chatMessagesView);
}
Exemplo n.º 4
0
void HistoryMessagesTab::displayTalkable(const Talkable &talkable, bool force)
{
	if (!force && CurrentTalkable == talkable)
		return;

	CurrentTalkable = talkable;
	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);

	HistoryQuery query;
	query.setTalkable(CurrentTalkable);

	if (Storage && !CurrentTalkable.isEmpty())
		TimelineView->setFutureResults(Storage->dates(query));
	else
		TimelineView->setResults(QVector<HistoryQueryResult>());
}
Exemplo n.º 5
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));
}