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