projectinfo.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /***************************************************************************
  2. projectinfo.h - ProjectInfo
  3. ---------------------
  4. begin : 14.2.2021
  5. copyright : (C) 2021 by Mathieu Pellerin
  6. email : nirvn dot asia at gmail dot com
  7. ***************************************************************************
  8. * *
  9. * This program is free software; you can redistribute it and/or modify *
  10. * it under the terms of the GNU General Public License as published by *
  11. * the Free Software Foundation; either version 2 of the License, or *
  12. * (at your option) any later version. *
  13. * *
  14. ***************************************************************************/
  15. #ifndef PROJECTINFO_H
  16. #define PROJECTINFO_H
  17. #include "layertreemodel.h"
  18. #include "qgsquickmapsettings.h"
  19. #include <QObject>
  20. #include <QTimer>
  21. /**
  22. * This class stores current projection information such as
  23. * extent and map theme in order for those to be saved and
  24. * afterwards restored when the project is re-opened
  25. */
  26. class ProjectInfo : public QObject
  27. {
  28. Q_OBJECT
  29. Q_PROPERTY( QString filePath READ filePath WRITE setFilePath NOTIFY filePathChanged )
  30. Q_PROPERTY( QgsQuickMapSettings *mapSettings READ mapSettings WRITE setMapSettings NOTIFY mapSettingsChanged )
  31. Q_PROPERTY( FlatLayerTreeModel *layerTree READ layerTree WRITE setLayerTree NOTIFY layerTreeChanged )
  32. public:
  33. explicit ProjectInfo( QObject *parent = nullptr );
  34. virtual ~ProjectInfo() = default;
  35. void setFilePath( const QString &filePath );
  36. QString filePath() const;
  37. void setMapSettings( QgsQuickMapSettings *mapSettings );
  38. QgsQuickMapSettings *mapSettings() const;
  39. void setLayerTree( FlatLayerTreeModel *layerTree );
  40. FlatLayerTreeModel *layerTree() const;
  41. signals:
  42. void filePathChanged();
  43. void mapSettingsChanged();
  44. void layerTreeChanged();
  45. private slots:
  46. void extentChanged();
  47. void mapThemeChanged();
  48. private:
  49. QString mFilePath;
  50. QgsQuickMapSettings *mMapSettings = nullptr;
  51. QTimer mSaveExtentTimer;
  52. FlatLayerTreeModel *mLayerTree = nullptr;
  53. };
  54. #endif // PROJECTINFO_H