File indexing completed on 2025-01-12 06:47:27
0001 // 0002 // C++ Interface: clistgroup 0003 // 0004 // Description: List group. 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 CLISTGROUP_H 0024 #define CLISTGROUP_H 0025 0026 #include <clistobject.h> 0027 #include <kmuddy_export.h> 0028 #include <list> 0029 0030 /** 0031 A group in the list, base class for all types of groups (most probably won't need to subclass). 0032 The constructor is protected - only cList will want to create these objects. 0033 0034 @author Tomas Mecir <kmuddy@kmuddy.com> 0035 */ 0036 class KMUDDY_EXPORT cListGroup : public cListObject 0037 { 0038 public: 0039 void addObject (cListObject *obj); 0040 void removeObject (cListObject *obj); 0041 void objectChanged (cListObject *obj); 0042 0043 bool isGroup () override { return true; } 0044 0045 /** Returns the list of objects in this group. */ 0046 const std::list<cListObject *> *objectList (); 0047 0048 /** Returns the list of objects in this group, sorted by priority. */ 0049 const std::list<cListObject *> *priorityList (); 0050 0051 /** Assign a tag to this group. */ 0052 void setTag (const QString &tag); 0053 /** Return tag assigned to this group. */ 0054 QString tag (); 0055 0056 cListObject *objectAt (int pos); 0057 int objectPosition (cListObject *obj); 0058 0059 /** Move object upwards. */ 0060 void moveObjectUp (int pos); 0061 /** Move object downwards. */ 0062 void moveObjectDown (int pos); 0063 /** Move object to a specified position. */ 0064 void moveObjectToPosition (cListObject *obj, int pos); 0065 /** Number of objects within this group. */ 0066 int objectCount () const; 0067 protected: 0068 /** constructor */ 0069 cListGroup (cList *list); 0070 /** destructor */ 0071 ~cListGroup () override; 0072 friend class cList; 0073 0074 void updateVisibleName () override; 0075 0076 /** Load the group from the XML reader. */ 0077 void load (QXmlStreamReader *reader) override; 0078 /** Save the group into a XML writer, including all nested groups. */ 0079 void save (QXmlStreamWriter *writer) override; 0080 0081 /** regenerate the list of objects stored by priority */ 0082 void generatePriorityList (); 0083 0084 /** Recursive traversal of the list, called by cList::traverse */ 0085 cList::TraverseAction traverse (int traversalType) override; 0086 0087 /** helper function used by generatePriorityList */ 0088 static bool compareObjects (cListObject *a, cListObject *b); 0089 0090 struct Private; 0091 Private *d; 0092 }; 0093 0094 #endif