Libksysguard

SensorQuery.h
1 /*
2  Copyright (C) 2020 Arjen Hiemstra <[email protected]>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #pragma once
21 
22 #include "sensors_export.h"
23 #include <QObject>
24 #include <memory>
25 
26 namespace KSysGuard
27 {
28 class SensorInfo;
29 
30 /**
31  * An object to query the daemon for a list of sensors and their metadata.
32  *
33  * This class will request a list of sensors from the daemon, then filter them
34  * based on the supplied path. The path can include the wildcard "*" to get a
35  * list of all sensors matching the specified part of their path. In addition,
36  * if left empty, all sensors will be returned.
37  */
38 class SENSORS_EXPORT SensorQuery : public QObject
39 {
40  Q_OBJECT
41 
42 public:
43  SensorQuery(const QString &path = QString{}, QObject *parent = nullptr);
44  ~SensorQuery() override;
45 
46  QString path() const;
47  void setPath(const QString &path);
48 
49  /**
50  * A list of sensors ids that match the query.
51  */
52  QStringList sensorIds() const;
53  /**
54  * Sort the retrieved sensors by their user visible names.
55  */
56  void sortByName();
57 
58  /**
59  * Start processing the query.
60  */
61  bool execute();
62  /**
63  * Wait for the query to finish.
64  *
65  * Mostly useful for code that needs the result to be available before
66  * continuing. Ideally the finished() signal should be used instead.
67  */
68  bool waitForFinished();
69 
70  Q_SIGNAL void finished(const SensorQuery *query);
71 
72 private:
73  friend class Sensor;
74  friend class SensorTreeModel;
75  QVector<QPair<QString, SensorInfo>> result() const;
76 
77  class Private;
78  const std::unique_ptr<Private> d;
79 };
80 
81 } // namespace KSysGuard
An object encapsulating a backend sensor.
Definition: Sensor.h:46
A model representing a tree of sensors that are available from the daemon.
An object to query the daemon for a list of sensors and their metadata.
Definition: SensorQuery.h:38
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Mar 4 2021 23:09:25 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.