From e9ae80694875f869892f13f4fcaf1170a00dea41 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdewebdev@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- quanta/treeviews/docfolder.cpp | 126 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 quanta/treeviews/docfolder.cpp (limited to 'quanta/treeviews/docfolder.cpp') diff --git a/quanta/treeviews/docfolder.cpp b/quanta/treeviews/docfolder.cpp new file mode 100644 index 00000000..02669a1e --- /dev/null +++ b/quanta/treeviews/docfolder.cpp @@ -0,0 +1,126 @@ +/*************************************************************************** + docfolder.cpp - description + ------------------- + begin : Fri Mar 3 2000 + copyright : (C) 2000 by Yacovlev Alexander & Dmitry Poplavsky + (C) 2002 Andras Mantia + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 +#include + +// KDE includes +#include +#include +#include + +// app includes +#include "docfolder.h" +#include "docitem.h" + +DocFolder::DocFolder(QListViewItem *parent, const QString &_name, KConfig *config, const QString &basePath) + : KListViewItem(parent) +{ + name = _name; + topLevel = false; + url = ""; + + QStrList list; + + config->readListEntry( name, list ); + + char *item; + + for ( list.last(); ( item = list.current() ) ; list.prev() ) { + if ( item[0] != '#' ) { + QString url = config->readEntry( item ); + DocItem *el = new DocItem( this, QString(item), basePath+url); + el->setPixmap( 0, SmallIcon("info") ); + } else + if ( item[0] == '#' ) { // current item is folder + item++; // remove leading # + QString l_url = config->readEntry( QString("folder_")+item, "" ); + DocFolder *el = new DocFolder(this, QString(item), config, basePath); + if ( ! l_url.isEmpty() ) + el->url = basePath+l_url; + el->setPixmap( 0, UserIcon("mini-book1") ); + el->setOpen( false ); + } + } +} + +DocFolder::DocFolder(QListView *parent, const QString &_name, KConfig *config, const QString &basePath) + : KListViewItem(parent) +{ + name = _name; + topLevel = false; + url = ""; + QStrList list; + + config->readListEntry( name, list ); + + char *item; + + for ( list.last(); ( item = list.current() ) ; list.prev() ) { + if ( item[0] != '#' ) { + QString url = config->readEntry( item ); + DocItem *el = new DocItem( this, QString(item), basePath+url); + el->setPixmap( 0, SmallIcon("info") ); + } else + if ( item[0] == '#' ) { // current item is folder + item++; // remove leading # + QString l_url = config->readEntry( QString("folder_")+item, "" ); + DocFolder *el = new DocFolder(this, QString(item), config, basePath); + if ( ! l_url.isEmpty() ) + el->url = basePath+l_url; + el->setPixmap( 0, UserIcon("mini-book1") ); + el->setOpen( false ); + } + } +} + + + +DocFolder::~DocFolder(){ +} + + +QString DocFolder::text( int i) const +{ + if (i == 0) + return name; + else + return ""; +} + +void DocFolder::setup() +{ + setExpandable( true ); + QListViewItem::setup(); +} +/** */ +void DocFolder::setOpen( bool o) +{ + QListViewItem::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") ); + } +} -- cgit v1.2.1