kexi

kexipartitem.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2002, 2003 Lucijan Busch <lucijan@gmx.at>
00003    Copyright (C) 2005 Jaroslaw Staniek <js@iidea.pl>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef KEXIPROJECTPARTITEM_H
00022 #define KEXIPROJECTPARTITEM_H
00023 
00024 #include <qobject.h>
00025 #include <qintdict.h>
00026 #include <qptrlist.h>
00027 
00028 namespace KexiDB
00029 {
00030     class Connection;
00031 }
00032 
00033 namespace KexiPart
00034 {
00035 
00036 class Info;
00037 
00046 class KEXICORE_EXPORT Item
00047 {
00048     public:
00049 
00050         Item();
00051         ~Item();
00052 
00053         int identifier() const { return m_id; }
00054         void setIdentifier(int id) { m_id = id; }
00055 
00056         QCString mimeType() const { return m_mime; }
00057         void setMimeType(const QCString &mime) { m_mime = mime; }
00058 
00059         QString name() const { return m_name; }
00060         void setName(const QString &name) { m_name = name; }
00061 
00062         QString caption() const { return m_caption; }
00063         void setCaption(const QString &c) { m_caption = c; }
00064 
00065         QString description() const { return m_desc; }
00066         void setDescription(const QString &d) { m_desc = d; }
00067 
00073         bool neverSaved() const { return m_neverSaved; }
00074 
00077         void setNeverSaved(bool set) { m_neverSaved = set; }
00078 
00079         bool isNull() const { return m_id==0; }
00080 
00082         inline QString captionOrName() const { return m_caption.isEmpty() ? m_name : m_caption; }
00083 
00084     private:
00085         QCString m_mime;
00086         QString m_name;
00087         QString m_caption;
00088         QString m_desc;
00089         int m_id;
00090         bool m_neverSaved : 1;
00091 };
00092 
00093 typedef QIntDict<KexiPart::Item> ItemDict;
00094 typedef QIntDictIterator<KexiPart::Item> ItemDictIterator;
00095 typedef QPtrListIterator<KexiPart::Item> ItemListIterator;
00096 
00103 class KEXICORE_EXPORT ItemList : public QPtrList<KexiPart::Item> {
00104     public:
00105         ItemList() {}
00106     protected:
00107         virtual int compareItems( QPtrCollection::Item item1, QPtrCollection::Item item2 ) {
00108             return QString::compare(
00109                 static_cast<KexiPart::Item*>(item1)->name(), 
00110                 static_cast<KexiPart::Item*>(item2)->name());
00111         }
00112 };
00113 
00114 }
00115 
00116 #endif
00117 
KDE Home | KDE Accessibility Home | Description of Access Keys