File indexing completed on 2024-05-19 04:07:48

0001 /*
0002     SPDX-FileCopyrightText: 2010 Stefan Majewsky <majewsky@gmx.net>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef PALAPELI_SLICERSELECTOR_H
0008 #define PALAPELI_SLICERSELECTOR_H
0009 
0010 #include <QTreeWidget>
0011 
0012 namespace Pala
0013 {
0014     class Slicer;
0015     class SlicerMode;
0016 }
0017 
0018 namespace Palapeli
0019 {
0020     struct SlicerSelection
0021     {
0022         SlicerSelection() : slicer(nullptr), mode(nullptr) {}
0023         SlicerSelection(const QString& n, const Pala::Slicer* s, const Pala::SlicerMode* m = nullptr) : slicerPluginName(n), slicer(s), mode(m) {}
0024 
0025         QString slicerPluginName;
0026         const Pala::Slicer* slicer;
0027         const Pala::SlicerMode* mode; //== 0 for mode-less slicers
0028     };
0029 
0030     class SlicerSelector : public QTreeWidget
0031     {
0032         Q_OBJECT
0033         public:
0034             explicit SlicerSelector(QWidget* parent = nullptr);
0035             ~SlicerSelector() override;
0036 
0037             QList<const Pala::Slicer*> slicers() const;
0038             //NOTE: The objects pointed to by the SlicerSelection instance will be destroyed when this class is deleted.
0039             SlicerSelection currentSelection() const;
0040         Q_SIGNALS:
0041             void currentSelectionChanged(const Palapeli::SlicerSelection& selection);
0042         private Q_SLOTS:
0043             void slotSelectionChanged();
0044         private:
0045             QList<Pala::Slicer*> m_slicerInstances;
0046             QList<Palapeli::SlicerSelection> m_knownSelections;
0047     };
0048 }
0049 
0050 Q_DECLARE_METATYPE(Palapeli::SlicerSelection)
0051 
0052 #endif // PALAPELI_SLICERSELECTOR_H