Beispiel #1
0
//! [7]
void PgcMessages::filterMessages()
{
    if (!m_currentAccount.isValid())
        return;

    // Use the entered filter string as search value
    MessageSearchFilter filter;
    filter.setFolderId(m_folderid);
    filter.addSearchCriteria(SearchFilterCriteria::Any, m_filter);

    const QList<Message> messages = m_messageService->searchLocal(m_currentAccount.id(), filter);

    // Clear the old message information from the model
    m_model->clear();

    // Iterate over the list of message IDs
    foreach (const Message &message, messages) {
        // Copy the data into a model entry
        QVariantMap entry;
        entry["messageId"] = message.id();
        entry["subject"] = message.subject();
        entry["time"] = message.serverTimestamp().toString();

        // Add the entry to the model
        m_model->insert(entry);
    }
Beispiel #2
0
void MainScreen::workDone()
{
	if(m_worker)
	{
		delete m_worker;
		m_worker = NULL;
	}
	if(!m_cancelled)
	{
		AccountService* as = new AccountService();
		Account account = as->defaultAccount(Service::Messages);

		MessageSearchFilter filter;
		filter.setAccountId(account.id());
		MessageService messageService;

		QList<MessageFolder> folders = messageService.folders(account.id());
		MessageFolder sentFolder;
		for(int i = 0; i < folders.size(); ++i)
		{
			if(folders[i].type() == MessageFolder::Sent)
			{
				sentFolder = folders[i];
				break;
			}
		}

		filter.setFolderId(sentFolder.id());
		filter.addSearchCriteria(SearchFilterCriteria::Subject, m_subject);

		QList<Message> messagesToDelete = messageService.searchLocal(account.id(), filter);
		messagesToDelete.append(messageService.searchRemote(account.id(), filter));

		for(int i = 0; i < messagesToDelete.size(); ++i)
		{
			messageService.remove(account.id(), messagesToDelete[i].id());
		}



		m_mainPage->setProperty("allDone", true);
	}
	m_mainPage->setProperty("workInProgress", false);
}