kexi

kexibrowseritem.cpp

00001 /* This file is part of the KDE project
00002    Copyright (C) 2002-2003 Lucijan Busch <lucijan@gmx.at>
00003    Copyright (C) 2003-2004 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 #include "kexibrowseritem.h"
00022 
00023 #include <kdebug.h>
00024 #include <kiconloader.h>
00025 #include <core/kexipartinfo.h>
00026 
00027 KexiBrowserItem::KexiBrowserItem(KListView *parent, KexiPart::Info *i)
00028  : KListViewItem(parent, i->groupName())
00029  , m_info(i)
00030  , m_item(0)
00031 {
00032     setPixmap(0, SmallIcon(i->itemIcon()));
00033     setOpen(true);
00034 //ugly  setSelectable(false);
00035     initItem();
00036     m_fifoSorting = 1; //because this is top level item
00037 }
00038 
00039 KexiBrowserItem::KexiBrowserItem(KListViewItem *parent, KexiPart::Info *i, KexiPart::Item *item)
00040  : KListViewItem(parent, item->name())
00041  , m_info(i)
00042  , m_item(item)
00043 {
00044     setPixmap(0, SmallIcon(i->itemIcon()));
00045     initItem();
00046 }
00047 
00048 KexiBrowserItem::KexiBrowserItem(KListView *parent, KexiPart::Info *i, KexiPart::Item *item)
00049  : KListViewItem(parent, item->name())
00050  , m_info(i)
00051  , m_item(item)
00052 {
00053     setPixmap(0, SmallIcon(i->itemIcon()));
00054     initItem();
00055 }
00056 
00057 KexiBrowserItem::~KexiBrowserItem()
00058 {
00059 }
00060 
00061 void KexiBrowserItem::initItem()
00062 {
00063     m_fifoSorting = 0;
00064     int sortKey = 0;
00065     // set sorting key with FIFO order
00066     if (parent()) {
00067         sortKey = parent()->childCount();
00068     } else if (listView()) {
00069         sortKey = listView()->childCount();
00070     }
00071     m_sortKey.sprintf("%2.2d",sortKey);
00072 //  kdDebug() << "m_sortKey=" << m_sortKey << endl;
00073 }
00074 
00075 void
00076 KexiBrowserItem::clearChildren()
00077 {
00078     KexiBrowserItem* child;
00079     
00080     while((child = static_cast<KexiBrowserItem*>(firstChild())))
00081     {
00082         delete child;
00083     }
00084 }
00085 
00086 QString KexiBrowserItem::key( int column, bool ascending ) const
00087 {
00088 //  kdDebug() << "KexiBrowserItem::key() : " << (m_fifoSorting ? m_sortKey : KListViewItem::key(column,ascending)) << endl;
00089     return m_fifoSorting ? m_sortKey : KListViewItem::key(column,ascending);
00090 }
00091 
KDE Home | KDE Accessibility Home | Description of Access Keys