| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
#ifndef MAILBOXSEARCH_H |
| 19 |
#define MAILBOXSEARCH_H |
| 20 |
|
| 21 |
#include <QObject> |
| 22 |
#include <QmlObjectListModel.h> |
| 23 |
#include "Message.h" |
| 24 |
#include <qmailmessage.h> |
| 25 |
#include <qmailmessagekey.h> |
| 26 |
#include <qmailmessagesortkey.h> |
| 27 |
#include <qmailserviceaction.h> |
| 28 |
#include "SearchService.h" |
| 29 |
|
| 30 |
class MailboxSearch : public QObject |
| 31 |
{ |
| 32 |
Q_OBJECT |
| 33 |
|
| 34 |
Q_PROPERTY(QObject *results READ result NOTIFY modelChanged) |
| 35 |
|
| 36 |
Q_PROPERTY(QVariant messageKey READ messageKey WRITE setMessageKey NOTIFY messageKeyChanged) |
| 37 |
|
| 38 |
Q_PROPERTY(Location location READ location WRITE setLocation NOTIFY locationChanged) |
| 39 |
|
| 40 |
Q_PROPERTY(int limit READ limit WRITE setLimit NOTIFY limitChanged) |
| 41 |
|
| 42 |
Q_PROPERTY(Qt::SortOrder sortOrder READ sortOrder WRITE setSortOrder NOTIFY sortOrderChanged) |
| 43 |
|
| 44 |
Q_PROPERTY(SortBy sortBy READ sortBy WRITE setSortBy NOTIFY sortByChanged) |
| 45 |
|
| 46 |
Q_PROPERTY(bool searchBody READ searchBody WRITE setSearchBody NOTIFY searchBodyChanged) |
| 47 |
|
| 48 |
Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged) |
| 49 |
|
| 50 |
Q_PROPERTY(bool globalSearch READ globalSearch WRITE setGlobalSearch NOTIFY globalSearchChanged) |
| 51 |
|
| 52 |
Q_ENUMS(SortBy) |
| 53 |
Q_ENUMS(Location) |
| 54 |
|
| 55 |
public: |
| 56 |
explicit MailboxSearch(QObject *parent = 0); |
| 57 |
|
| 58 |
enum Location { |
| 59 |
Local, |
| 60 |
Remote, |
| 61 |
LocalAndRemote |
| 62 |
}; |
| 63 |
|
| 64 |
enum SortBy { |
| 65 |
Id, |
| 66 |
Sender, |
| 67 |
Subject, |
| 68 |
Recipients, |
| 69 |
TimeStamp, |
| 70 |
ListId |
| 71 |
}; |
| 72 |
|
| 73 |
QObject *result() const; |
| 74 |
QVariant messageKey() const; |
| 75 |
void setMessageKey(QVariant &key); |
| 76 |
Location location() const; |
| 77 |
int limit() const; |
| 78 |
Qt::SortOrder sortOrder() const; |
| 79 |
SortBy sortBy() const; |
| 80 |
bool searchBody() const; |
| 81 |
QString searchQuery() const; |
| 82 |
bool globalSearch() const; |
| 83 |
QMailMessageSortKey querySortKey(); |
| 84 |
QMailSearchAction::SearchSpecification querySpec(); |
| 85 |
QMailMessageKey searchKey(); |
| 86 |
|
| 87 |
signals: |
| 88 |
void modelChanged(QObject * results); |
| 89 |
void messageKeyChanged(); |
| 90 |
void locationChanged(Location location); |
| 91 |
void limitChanged(int limit); |
| 92 |
void sortOrderChanged(Qt::SortOrder sortOrder); |
| 93 |
void sortByChanged(SortBy sortBy); |
| 94 |
void searchBodyChanged(bool searchBody); |
| 95 |
void searchQueryChanged(QString searchQuery); |
| 96 |
void globalSearchChanged(bool globalSearch); |
| 97 |
void statusChanged(int status, const QString &msg); |
| 98 |
|
| 99 |
public slots: |
| 100 |
|
| 101 |
void search(const QString &query); |
| 102 |
|
| 103 |
void cancelSearch(); |
| 104 |
void setLocation(const Location &location); |
| 105 |
void setLimit(const int &limit); |
| 106 |
void setSortOrder(const Qt::SortOrder &sortOrder); |
| 107 |
void setSortBy(const SortBy &sortBy); |
| 108 |
void setSearchBody(const bool searchBody); |
| 109 |
void setSearchQuery(const QString &searchQuery); |
| 110 |
void setGlobalSearch(const bool globalSearch); |
| 111 |
|
| 112 |
void handleMatchedResults(const QMailMessageIdList &idList); |
| 113 |
|
| 114 |
private: |
| 115 |
QQmlObjectListModel<MinimalMessage> *m_results; |
| 116 |
SearchService *m_service; |
| 117 |
QMailMessageKey m_msgKey; |
| 118 |
QMailMessageSortKey m_sortKey; |
| 119 |
Location m_location; |
| 120 |
int m_limit; |
| 121 |
Qt::SortOrder m_sortOrder; |
| 122 |
SortBy m_sortBy; |
| 123 |
bool m_searchBody; |
| 124 |
QString m_searchQuery; |
| 125 |
bool m_globalSearch; |
| 126 |
}; |
| 127 |
|
| 128 |
#endif |