File indexing completed on 2025-01-19 06:54:49
0001 // 0002 // C++ Interface: clistmanager 0003 // 0004 // Description: 0005 // 0006 /* 0007 Copyright 2007-2011 Tomas Mecir <kmuddy@kmuddy.com> 0008 0009 This program is free software; you can redistribute it and/or 0010 modify it under the terms of the GNU General Public License as 0011 published by the Free Software Foundation; either version 2 of 0012 the License, or (at your option) any later version. 0013 0014 This program is distributed in the hope that it will be useful, 0015 but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0017 GNU General Public License for more details. 0018 0019 You should have received a copy of the GNU General Public License 0020 along with this program. If not, see <http://www.gnu.org/licenses/>. 0021 */ 0022 0023 #ifndef CLISTMANAGER_H 0024 #define CLISTMANAGER_H 0025 0026 #include <kmuddy_export.h> 0027 0028 #include <cactionbase.h> 0029 0030 class cList; 0031 class cListObject; 0032 class QStandardItemModel; 0033 0034 /** cListManager - manages all the existing lists */ 0035 class KMUDDY_EXPORT cListManager: public cActionBase { 0036 public: 0037 static cListManager *self(); 0038 ~cListManager () override; 0039 0040 /** Register a new list type. Factory should point to the newList method of a cList-inherited class. */ 0041 void registerType (const QString &name, const QString &visibleName, cList *(*factory)()); 0042 /** Unregister a list type. Also remove all lists of this type. */ 0043 void unregisterType (const QString &name); 0044 0045 /** A model containing all the registered types. */ 0046 QStandardItemModel *typeModel () const; 0047 0048 /** Returns the given list, creating it if needed. */ 0049 cList *getList (int sessId, const QString &name); 0050 void addSession (int sessId); 0051 /** Remove all lists belonging to the given session. */ 0052 void removeSession (int sessId); 0053 0054 int registerObject (cListObject *obj); 0055 void unregisterObject (cListObject *obj); 0056 int objectId (cListObject *obj) const; 0057 cListObject *object (int id) const; 0058 0059 void saveList (int sessId, cList *list); 0060 void saveAll (int sessId); 0061 protected: 0062 cListManager (); 0063 static cListManager *_self; 0064 0065 void loadList (int sessId, cList *list); 0066 void eventNothingHandler (QString event, int session) override; 0067 void eventStringHandler (QString event, int session, QString &par1, const QString &) override; 0068 0069 struct Private; 0070 Private *d; 0071 }; 0072 0073 #endif // CLISTMANAGER_H