You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tdewebdev/quanta/treeviews/docfolder.cpp

127 lines
3.6 KiB

/***************************************************************************
docfolder.cpp - description
-------------------
begin : Fri Mar 3 2000
copyright : (C) 2000 by Yacovlev Alexander & Dmitry Poplavsky <pdima@mail.univ.kiev.ua>
(C) 2002 Andras Mantia <amantia@kde.org>
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
// QT includes
#include <tqstrlist.h>
#include <tqpixmap.h>
// KDE includes
#include <tdeconfig.h>
#include <kstandarddirs.h>
#include <kiconloader.h>
// app includes
#include "docfolder.h"
#include "docitem.h"
DocFolder::DocFolder(TQListViewItem *parent, const TQString &_name, TDEConfig *config, const TQString &basePath)
: KListViewItem(parent)
{
name = _name;
topLevel = false;
url = "";
TQStrList list;
config->readListEntry( name, list );
char *item;
for ( list.last(); ( item = list.current() ) ; list.prev() ) {
if ( item[0] != '#' ) {
TQString url = config->readEntry( item );
DocItem *el = new DocItem( this, TQString(item), basePath+url);
el->setPixmap( 0, SmallIcon("info") );
} else
if ( item[0] == '#' ) { // current item is folder
item++; // remove leading #
TQString l_url = config->readEntry( TQString("folder_")+item, "" );
DocFolder *el = new DocFolder(this, TQString(item), config, basePath);
if ( ! l_url.isEmpty() )
el->url = basePath+l_url;
el->setPixmap( 0, UserIcon("mini-book1") );
el->setOpen( false );
}
}
}
DocFolder::DocFolder(TQListView *parent, const TQString &_name, TDEConfig *config, const TQString &basePath)
: KListViewItem(parent)
{
name = _name;
topLevel = false;
url = "";
TQStrList list;
config->readListEntry( name, list );
char *item;
for ( list.last(); ( item = list.current() ) ; list.prev() ) {
if ( item[0] != '#' ) {
TQString url = config->readEntry( item );
DocItem *el = new DocItem( this, TQString(item), basePath+url);
el->setPixmap( 0, SmallIcon("info") );
} else
if ( item[0] == '#' ) { // current item is folder
item++; // remove leading #
TQString l_url = config->readEntry( TQString("folder_")+item, "" );
DocFolder *el = new DocFolder(this, TQString(item), config, basePath);
if ( ! l_url.isEmpty() )
el->url = basePath+l_url;
el->setPixmap( 0, UserIcon("mini-book1") );
el->setOpen( false );
}
}
}
DocFolder::~DocFolder(){
}
TQString DocFolder::text( int i) const
{
if (i == 0)
return name;
else
return "";
}
void DocFolder::setup()
{
setExpandable( true );
TQListViewItem::setup();
}
/** */
void DocFolder::setOpen( bool o)
{
TQListViewItem::setOpen( o );
if ( !topLevel ) {
if (o)
setPixmap( 0, UserIcon("mini-book2") );
else
setPixmap( 0, UserIcon("mini-book1") );
} else {
if (o)
setPixmap( 0, SmallIcon("folder_open") );
else
setPixmap( 0, SmallIcon("folder") );
}
}