~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to kexi/core/kexipartitem.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2006-04-20 21:38:53 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060420213853-j5lxluqvymxt2zny
Tags: 1:1.5.0-0ubuntu2
UbuntuĀ uploadĀ 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* This file is part of the KDE project
2
2
   Copyright (C) 2002, 2003 Lucijan Busch <lucijan@gmx.at>
 
3
   Copyright (C) 2005 Jaroslaw Staniek <js@iidea.pl>
3
4
 
4
5
   This library is free software; you can redistribute it and/or
5
6
   modify it under the terms of the GNU Library General Public
13
14
 
14
15
   You should have received a copy of the GNU Library General Public License
15
16
   along with this library; see the file COPYING.LIB.  If not, write to
16
 
   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
 
   Boston, MA 02111-1307, USA.
 
17
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
18
 * Boston, MA 02110-1301, USA.
18
19
*/
19
20
 
20
21
#ifndef KEXIPROJECTPARTITEM_H
22
23
 
23
24
#include <qobject.h>
24
25
#include <qintdict.h>
 
26
#include <qptrlist.h>
25
27
 
26
28
namespace KexiDB
27
29
{
33
35
 
34
36
class Info;
35
37
 
36
 
/** Project Part Item stores:
 
38
/*!
 
39
 @short Information about a single object that can be instantiated using Kexi Part
 
40
 
 
41
 KexiPart::Item stores:
37
42
        - identifier ident (low-level name, for example: table name)
38
43
        - mime type name, eg. "kexi/table"
39
44
        - caption (visible, i18n'd hight level name, eg. table or query title)
40
45
*/
41
 
//! Data that identifies a single part object (not necessary instantiated)
42
46
class KEXICORE_EXPORT Item
43
47
{
44
48
        public:
49
53
                int identifier() const { return m_id; }
50
54
                void setIdentifier(int id) { m_id = id; }
51
55
 
52
 
                QCString mime() const { return m_mime; }
53
 
                void setMime(const QCString &mime) { m_mime = mime; }
 
56
                QCString mimeType() const { return m_mime; }
 
57
                void setMimeType(const QCString &mime) { m_mime = mime; }
54
58
 
55
59
                QString name() const { return m_name; }
56
60
                void setName(const QString &name) { m_name = name; }
74
78
 
75
79
                bool isNull() const { return m_id==0; }
76
80
 
 
81
                //! \return caption if not empty, else returns name.
 
82
                inline QString captionOrName() const { return m_caption.isEmpty() ? m_name : m_caption; }
 
83
 
77
84
        private:
78
 
                QCString                m_mime;
79
 
                QString         m_name;
80
 
                QString         m_caption;
81
 
                QString         m_desc;
82
 
                int             m_id;
 
85
                QCString m_mime;
 
86
                QString m_name;
 
87
                QString m_caption;
 
88
                QString m_desc;
 
89
                int m_id;
83
90
                bool m_neverSaved : 1;
84
91
};
85
92
 
86
 
//typedef QValueList<Item> ItemList;
87
93
typedef QIntDict<KexiPart::Item> ItemDict;
88
94
typedef QIntDictIterator<KexiPart::Item> ItemDictIterator;
 
95
typedef QPtrListIterator<KexiPart::Item> ItemListIterator;
 
96
 
 
97
/*! 
 
98
 @short Part item list with reimplemented compareItems() method.
 
99
 
 
100
 Such a list is returend by KexiProject::getSortedItems(KexiPart::ItemList& list, KexiPart::Info *i);
 
101
 so you can call sort() on the list to sort it by item name. 
 
102
*/
 
103
class KEXICORE_EXPORT ItemList : public QPtrList<KexiPart::Item> {
 
104
        public:
 
105
                ItemList() {}
 
106
        protected:
 
107
                virtual int compareItems( QPtrCollection::Item item1, QPtrCollection::Item item2 ) {
 
108
                        return QString::compare(
 
109
                                static_cast<KexiPart::Item*>(item1)->name(), 
 
110
                                static_cast<KexiPart::Item*>(item2)->name());
 
111
                }
 
112
};
89
113
 
90
114
}
91
115