tempmodel.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * <one line to give the library's name and an idea of what it does.>
  3. * Copyright 2015 Malte Veerman maldela@halloarsch.de
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License or (at your option) version 3 or any later version
  9. * accepted by the membership of KDE e.V. (or its successor approved
  10. * by the membership of KDE e.V.), which shall act as a proxy
  11. * defined in Section 14 of version 3 of the license.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #ifndef TEMPMODEL_H
  23. #define TEMPMODEL_H
  24. #include <QtCore/QStringListModel>
  25. namespace Fancontrol {
  26. class Temp;
  27. class TempModel : public QStringListModel
  28. {
  29. Q_OBJECT
  30. Q_PROPERTY(QList<QObject *> temps READ temps NOTIFY tempsChanged)
  31. public:
  32. TempModel(QObject *parent = Q_NULLPTR);
  33. void setTemps(const QList<Temp *> &temps);
  34. void addTemps(QList<Temp *> newTemps);
  35. QList<QObject *> temps() const;
  36. protected:
  37. QString composeText(Temp *temp);
  38. public slots:
  39. void updateTemp(Temp *temp);
  40. void setUnit(const QString &unit) { if (unit != m_unit) { m_unit = unit; updateAll(); } }
  41. protected slots:
  42. void updateAll();
  43. private slots:
  44. void updateTemp();
  45. signals:
  46. void tempsChanged();
  47. private:
  48. QList<Temp *> m_temps;
  49. QString m_unit;
  50. };
  51. }
  52. #endif //TEMPMODEL_H