| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| #ifndef LC_UCSLIST_H |
| #define LC_UCSLIST_H |
|
|
| #include <QList> |
| #include <memory> |
| #include "lc_ucs.h" |
|
|
| class LC_UCSListListener { |
| public: |
| virtual void ucsListModified([[maybe_unused]]bool changed) {} |
| virtual ~LC_UCSListListener() = default; |
| }; |
|
|
|
|
| class LC_UCSList{ |
| public: |
| LC_UCSList(); |
| virtual ~LC_UCSList() = default; |
| void clear(); |
|
|
| |
| |
| |
| unsigned int count() const { |
| return m_ucsList.count(); |
| } |
|
|
| |
| |
| |
| LC_UCS *at(unsigned int i) { |
| return m_ucsList.at(i); |
| } |
|
|
| void add(LC_UCS *ucs); |
| void addNew(LC_UCS *ucs); |
| void remove(LC_UCS *ucs); |
| void remove(const QString &name); |
| void edited(LC_UCS *ucs); |
| void rename(LC_UCS* ucs, const QString& newName); |
| LC_UCS *find(const QString &name) const; |
| int getIndex(const QString &name) const; |
| int getIndex(LC_UCS *ucs) const; |
| |
| |
| |
| void setModified(bool m); |
|
|
| |
| |
| |
| |
| virtual bool isModified() const { |
| return m_modified; |
| } |
|
|
| void addListener(LC_UCSListListener *listener) { |
| if (listener != nullptr) { |
| m_ucsListListeners.push_back(listener); |
| } |
| } |
|
|
| void removeListener(LC_UCSListListener *listener) { |
| if (listener != nullptr) { |
| m_ucsListListeners.removeOne(listener); |
| } |
| } |
|
|
| void fireModified(bool value) { |
| for (auto l: m_ucsListListeners) { |
| l->ucsListModified(value); |
| } |
| } |
|
|
| LC_UCS *tryAddUCS(LC_UCS *candidate); |
| LC_UCS *findExisting(LC_UCS *candidate); |
| LC_UCS *getWCS() const; |
| LC_UCS* getActive() const {return m_activeUCS;} |
| void tryToSetActive(LC_UCS *ucs); |
| protected: |
| QList<LC_UCS *> m_ucsList; |
| QList<LC_UCSListListener *> m_ucsListListeners; |
| LC_UCS* m_activeUCS = nullptr; |
| bool m_modified = false; |
| std::unique_ptr<LC_WCS> m_wcs = std::make_unique<LC_WCS>(); |
| }; |
|
|
| #endif |
|
|