00001 00002 // 00003 // YASA list 00004 // 00005 // Project: Yasa 2 00006 // Author : Jan Blumenthal 00007 // Start : 2002/02/28 00008 // $Header: /sources/yasa/yasagui/list.h,v 1.5 2003/01/24 15:47:41 bj Exp $ 00009 // 00011 // 00012 // This program is free software; you can redistribute it and/or modify 00013 // it under the terms of the GNU General Public License as published by 00014 // the Free Software Foundation; either version 2 of the License, or 00015 // (at your option) any later version. 00016 // 00017 // This program is distributed in the hope that it will be useful, 00018 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 // GNU General Public License for more details. 00021 // 00022 // You should have received a copy of the GNU General Public License 00023 // along with this program (See the included file COPYING); 00024 // if not, write to the Free Software Foundation, Inc., 00025 // 675 Mass Ave, Cambridge, MA 02139, USA. 00026 // 00028 #ifndef YASAGUI_LIST_INCLUDE 00029 #define YASAGUI_LIST_INCLUDE 00030 00031 #include <yasagui/yasagui.h> 00032 #include <qobject.h> 00033 #include <qlist.h> 00034 #include <qstrlist.h> 00035 #include "datatypes.h" 00036 00037 00039 class YInputParser; 00040 class YOutputParser; 00041 00043 00047 class YSet : public YObject, protected QList<YObject> 00048 { Q_OBJECT 00050 const CONFIG_STRING sectionkey; 00052 YObject *parent; 00054 QString uniquename; 00055 // bool childnotify; //! If true the YSet is able to receive signals from childs, if they are changed and they will be forwarded to SIGNAL(ItemChanged) 00056 public: YSet(const CONFIG_STRING key, const QString &defaultname, const YObjectArgs &args=YObjectArgs(), YObject *p=0 ); 00057 void RemoveItem(YObject *item); 00058 void GetUniqueEntryName(QString &) const; 00060 const CONFIG_STRING GetSectionKey() const { return sectionkey; } 00061 YObject* CreateNewItem(const QString &name=QString::null ); 00062 virtual int SetConfig(YInputParser &parser) { return YObject::SetConfig(parser); } 00063 virtual int GetConfig(YOutputParser &parser) { return YObject::GetConfig(parser); } 00064 void ClearSet(); 00065 void SetParent(YObject *); 00067 YObject* GetParent() const { return parent; } 00068 00069 //virtual unsigned int GetCount() const { return QList<YObject>::count(); } 00071 unsigned int GetCount() const { return QList<YObject>::count(); } 00073 virtual YObject* At(unsigned int n) { return QList<YObject>::at(n); } 00074 // void EnableChildNotify(bool state=true) { childnotify=state; } 00075 int FillStringList(QStringList &list, bool sort=true); 00077 //\return Index of item or -1 if no item could be found 00078 unsigned int FindItemIndex(const YObject *object) { return findRef(object); } 00079 00080 protected: 00082 virtual void AppendItem(YObject *object) { if (object) 00083 QList<YObject>::append(object); } 00086 virtual YActions* GetItemActions() const { return 0; } 00089 virtual YObject* AllocNewItem(const YObjectArgs &id) =0; 00090 signals: 00092 void UpdateItem(YObject *); 00094 void NewItem(YObject *object); 00097 void ItemRemoved(YObject *object); 00098 public slots: 00100 void ItemChanged(YObject *); 00101 00102 }; 00103 00104 00105 00106 00107 00109 #endif // ifndef YASAGUI_LIST_INCLUDE