diff options
-rw-r--r-- | framework/domain/maillistmodel.cpp | 21 | ||||
-rw-r--r-- | framework/domain/maillistmodel.h | 6 |
2 files changed, 1 insertions, 26 deletions
diff --git a/framework/domain/maillistmodel.cpp b/framework/domain/maillistmodel.cpp index a995451e..c96f6dd1 100644 --- a/framework/domain/maillistmodel.cpp +++ b/framework/domain/maillistmodel.cpp | |||
@@ -27,8 +27,6 @@ MailListModel::MailListModel(QObject *parent) | |||
27 | { | 27 | { |
28 | setDynamicSortFilter(true); | 28 | setDynamicSortFilter(true); |
29 | sort(0, Qt::DescendingOrder); | 29 | sort(0, Qt::DescendingOrder); |
30 | connect(&mFetchTimer, &QTimer::timeout, this, &MailListModel::fetch); | ||
31 | mFetchTimer.setSingleShot(true); | ||
32 | } | 30 | } |
33 | 31 | ||
34 | MailListModel::~MailListModel() | 32 | MailListModel::~MailListModel() |
@@ -78,24 +76,7 @@ void MailListModel::fetchMail(Sink::ApplicationDomain::Mail::Ptr mail) | |||
78 | if (mail && !mail->getFullPayloadAvailable() && !mFetchedMails.contains(mail->identifier())) { | 76 | if (mail && !mail->getFullPayloadAvailable() && !mFetchedMails.contains(mail->identifier())) { |
79 | qDebug() << "Fetching mail: " << mail->identifier() << mail->getSubject(); | 77 | qDebug() << "Fetching mail: " << mail->identifier() << mail->getSubject(); |
80 | mFetchedMails.insert(mail->identifier()); | 78 | mFetchedMails.insert(mail->identifier()); |
81 | mMailsToFetch << *mail; | 79 | Sink::Store::synchronize(Sink::SyncScope{*mail}).exec(); |
82 | //TODO it would be nicer if Sink could just transparently merge synchronization requeusts. | ||
83 | if (!mFetchTimer.isActive()) { | ||
84 | mFetchTimer.start(50); | ||
85 | } | ||
86 | } | ||
87 | } | ||
88 | |||
89 | void MailListModel::fetch() | ||
90 | { | ||
91 | if (!mMailsToFetch.isEmpty()) { | ||
92 | auto first = mMailsToFetch.first(); | ||
93 | auto scope = Sink::SyncScope{first}; | ||
94 | for (const auto &m : mMailsToFetch) { | ||
95 | scope.filter(m.identifier()); | ||
96 | } | ||
97 | Sink::Store::synchronize(scope).exec(); | ||
98 | mMailsToFetch.clear(); | ||
99 | } | 80 | } |
100 | } | 81 | } |
101 | 82 | ||
diff --git a/framework/domain/maillistmodel.h b/framework/domain/maillistmodel.h index 1fd0ef5e..96cf98f2 100644 --- a/framework/domain/maillistmodel.h +++ b/framework/domain/maillistmodel.h | |||
@@ -25,7 +25,6 @@ | |||
25 | #include <QSortFilterProxyModel> | 25 | #include <QSortFilterProxyModel> |
26 | #include <QSharedPointer> | 26 | #include <QSharedPointer> |
27 | #include <QStringList> | 27 | #include <QStringList> |
28 | #include <QTimer> | ||
29 | 28 | ||
30 | class MailListModel : public QSortFilterProxyModel | 29 | class MailListModel : public QSortFilterProxyModel |
31 | { | 30 | { |
@@ -70,16 +69,11 @@ public: | |||
70 | void setMail(const QVariant &mail); | 69 | void setMail(const QVariant &mail); |
71 | QVariant mail() const; | 70 | QVariant mail() const; |
72 | 71 | ||
73 | private slots: | ||
74 | void fetch(); | ||
75 | |||
76 | private: | 72 | private: |
77 | void fetchMail(Sink::ApplicationDomain::Mail::Ptr mail); | 73 | void fetchMail(Sink::ApplicationDomain::Mail::Ptr mail); |
78 | 74 | ||
79 | QSharedPointer<QAbstractItemModel> m_model; | 75 | QSharedPointer<QAbstractItemModel> m_model; |
80 | bool mFetchMails = false; | 76 | bool mFetchMails = false; |
81 | QSet<QByteArray> mFetchedMails; | 77 | QSet<QByteArray> mFetchedMails; |
82 | QList<Sink::ApplicationDomain::Mail> mMailsToFetch; | ||
83 | QByteArray mCurrentQueryItem; | 78 | QByteArray mCurrentQueryItem; |
84 | QTimer mFetchTimer; | ||
85 | }; | 79 | }; |