File indexing completed on 2024-05-12 04:42:51

0001 /*
0002     SPDX-FileCopyrightText: 2019 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef KPUBLICTRANSPORT_ABSTRACTQUERYMODEL_P_H
0008 #define KPUBLICTRANSPORT_ABSTRACTQUERYMODEL_P_H
0009 
0010 #include <QAbstractListModel>
0011 #include <QTimer>
0012 
0013 #include <chrono>
0014 
0015 namespace KPublicTransport {
0016 
0017 class Manager;
0018 class Reply;
0019 
0020 class AbstractQueryModelPrivate
0021 {
0022 public:
0023     virtual ~AbstractQueryModelPrivate();
0024 
0025     void setLoading(bool l);
0026     void setErrorMessage(const QString &msg);
0027     void monitorReply(Reply *reply);
0028 
0029     /** Compresses query execution calls by one event loop.
0030      *  This helps with direct writes to the request property from QML, which shows up as
0031      *  multiple calls to the request setter.
0032      */
0033     void query();
0034     virtual void doQuery() = 0;
0035     virtual void doClearResults() = 0;
0036 
0037     AbstractQueryModel *q_ptr = nullptr;
0038     Manager *m_manager = nullptr;
0039     Reply *m_reply = nullptr;
0040 
0041     std::vector<Attribution> m_attributions;
0042 
0043     QTimer m_queryTimer;
0044     std::chrono::milliseconds m_queryDelay = std::chrono::milliseconds(0);
0045 
0046     QString m_errorMessage;
0047     bool m_loading = false;
0048 };
0049 
0050 }
0051 
0052 #endif // KPUBLICTRANSPORT_ABSTRACTQUERYMODEL_H
0053