File indexing completed on 2024-05-12 05:39:51
0001 /*************************************************************************** 0002 * Copyright (C) 2020 by Renaud Guezennec * 0003 * http://www.rolisteam.org/contact * 0004 * * 0005 * This software is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; if not, write to the * 0017 * Free Software Foundation, Inc., * 0018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0019 ***************************************************************************/ 0020 #ifndef VMAPITEMMODEL_H 0021 #define VMAPITEMMODEL_H 0022 0023 #include "controller/item_controllers/visualitemcontroller.h" 0024 #include <QAbstractListModel> 0025 #include <core_global.h> 0026 #include <memory> 0027 #include <vector> 0028 namespace vmap 0029 { 0030 0031 class CORE_EXPORT VmapItemModel : public QAbstractListModel 0032 { 0033 Q_OBJECT 0034 public: 0035 enum CustomRole 0036 { 0037 IdRole= Qt::UserRole + 1, 0038 SelectedRole, 0039 EditableRole, 0040 SelectableRole, 0041 VisibleRole, 0042 OpacityRole, 0043 RotationRole, 0044 LayerRole, 0045 PositionRole, 0046 LocalGmRole, 0047 ColorRole, 0048 LockedRole, 0049 ToolRole, 0050 TypeRole, 0051 InitializedRole, 0052 ControllerRole 0053 }; 0054 Q_ENUM(CustomRole); 0055 explicit VmapItemModel(QObject* parent= nullptr); 0056 virtual ~VmapItemModel(); 0057 0058 // Basic functionality: 0059 int rowCount(const QModelIndex& parent= QModelIndex()) const override; 0060 QVariant data(const QModelIndex& index, int role= Qt::DisplayRole) const override; 0061 0062 bool appendItemController(vmap::VisualItemController* item); 0063 bool removeItemController(const QSet<QString>& ids, bool fromNetwork= false); 0064 0065 void clearData(); 0066 0067 std::vector<vmap::VisualItemController*> items() const; 0068 vmap::VisualItemController* item(const QString& id) const; 0069 0070 public slots: 0071 void setModifiedToAllItem(); 0072 signals: 0073 void itemControllerAdded(vmap::VisualItemController* ctrl); 0074 void npcAdded(); 0075 void itemControllersRemoved(const QStringList& ids); 0076 void modifiedChanged(); 0077 0078 private: 0079 std::vector<std::unique_ptr<vmap::VisualItemController>> m_items; 0080 }; 0081 } // namespace vmap 0082 0083 #endif // VMAPITEMMODEL_H