kexi

kexibrowseritem.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2002-2003 Lucijan Busch <lucijan@gmx.at>
3 Copyright (C) 2003-2004 Jaroslaw Staniek <js@iidea.pl>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#include "kexibrowseritem.h"
22
23#include <kdebug.h>
24#include <kiconloader.h>
25#include <core/kexipartinfo.h>
26
28 : TDEListViewItem(parent, i->groupName())
29 , m_info(i)
30 , m_item(0)
31{
32 setPixmap(0, SmallIcon(i->itemIcon()));
33 setOpen(true);
34//ugly setSelectable(false);
35 initItem();
36 m_fifoSorting = 1; //because this is top level item
37}
38
40 : TDEListViewItem(parent, item->name())
41 , m_info(i)
42 , m_item(item)
43{
44 setPixmap(0, SmallIcon(i->itemIcon()));
45 initItem();
46}
47
49 : TDEListViewItem(parent, item->name())
50 , m_info(i)
51 , m_item(item)
52{
53 setPixmap(0, SmallIcon(i->itemIcon()));
54 initItem();
55}
56
57KexiBrowserItem::~KexiBrowserItem()
58{
59}
60
61void KexiBrowserItem::initItem()
62{
63 m_fifoSorting = 0;
64 int sortKey = 0;
65 // set sorting key with FIFO order
66 if (parent()) {
67 sortKey = parent()->childCount();
68 } else if (listView()) {
69 sortKey = listView()->childCount();
70 }
71 m_sortKey.sprintf("%2.2d",sortKey);
72// kdDebug() << "m_sortKey=" << m_sortKey << endl;
73}
74
75void
76KexiBrowserItem::clearChildren()
77{
78 KexiBrowserItem* child;
79
80 while((child = static_cast<KexiBrowserItem*>(firstChild())))
81 {
82 delete child;
83 }
84}
85
86TQString KexiBrowserItem::key( int column, bool ascending ) const
87{
88// kdDebug() << "KexiBrowserItem::key() : " << (m_fifoSorting ? m_sortKey : TDEListViewItem::key(column,ascending)) << endl;
89 return m_fifoSorting ? m_sortKey : TDEListViewItem::key(column,ascending);
90}
91
KexiPart::Item * item() const
KexiBrowserItem(TDEListView *parent, KexiPart::Info *i)
Creates group item for part i.
Information about a Kexi Part (plugin).
TQString itemIcon() const
Information about a single object that can be instantiated using Kexi Part.