summaryrefslogtreecommitdiffstats
path: root/src/directorylist.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/directorylist.cpp')
-rw-r--r--src/directorylist.cpp97
1 files changed, 48 insertions, 49 deletions
diff --git a/src/directorylist.cpp b/src/directorylist.cpp
index c24d552..aae909d 100644
--- a/src/directorylist.cpp
+++ b/src/directorylist.cpp
@@ -38,14 +38,9 @@
using Collection::Item;
using Collection::DeviceItem;
-CollectionSetup* CollectionSetup::s_instance;
-
-
CollectionSetup::CollectionSetup( TQWidget *parent, bool recursive, bool fullMode, TQStringList dirs )
: TQVBox( parent )
{
- s_instance = this;
-
m_dirs = dirs;
// (new TQLabel( i18n(
@@ -70,9 +65,9 @@ CollectionSetup::CollectionSetup( TQWidget *parent, bool recursive, bool fullMod
m_view->addColumn( TQString::null );
m_view->setRootIsDecorated( true );
reinterpret_cast<TQWidget*>(m_view->header())->hide();
- new Item( m_view, i18n( "System Folder" ), "/", "folder_red" );
- new Item( m_view, i18n( "Home Folder" ), TQDir::homeDirPath(), "folder_home" );
- if( fullMode ) new DeviceItem( m_view );
+ new Item( m_view, this, i18n( "System Folder" ), "/", "folder_red" );
+ new Item( m_view, this, i18n( "Home Folder" ), TQDir::homeDirPath(), "folder_home" );
+ if( fullMode ) new DeviceItem( m_view, this);
setSpacing( 6 );
}
@@ -86,12 +81,13 @@ void CollectionSetup::slotRecursiveToggled(bool on)
//////////////////////////////////////////////////////////////////////////////////////////
// CLASS Item
//////////////////////////////////////////////////////////////////////////////////////////
-Item::Item( TQListView *parent , const TQString &name, const TQString &path, const TQString &icon )
+Item::Item( TQListView *parent, CollectionSetup *collection, const TQString &name, const TQString &path, const TQString &icon )
: TQCheckListItem( parent, name, TQCheckListItem::CheckBox )
, m_lister( true )
, m_url( "file:" + path )
, m_listed( false )
{
+ collectionSetup = collection;
m_lister.setDirOnlyMode( true );
m_lister.setShowingDotFiles( true );
connect( &m_lister, SIGNAL(newItems( const KFileItemList& )), SLOT(newItems( const KFileItemList& )) );
@@ -105,12 +101,13 @@ Item::Item( TQListView *parent , const TQString &name, const TQString &path, co
}
-Item::Item( TQListViewItem *parent, const KURL &url )
+Item::Item( TQListViewItem *parent, CollectionSetup *collection, const KURL &url )
: TQCheckListItem( parent, url.fileName(), TQCheckListItem::CheckBox )
, m_lister( true )
, m_url( url )
, m_listed( false )
{
+ collectionSetup = collection;
m_lister.setDirOnlyMode( true );
m_lister.setShowingDotFiles( true );
setText( 1, url.fileName() );
@@ -151,28 +148,28 @@ Item::setOpen( bool b )
void
Item::stateChange( bool b )
{
- if( CollectionSetup::instance()->recursive() )
+ if( collectionSetup->recursive() )
for( TQListViewItem *item = firstChild(); item; item = item->nextSibling() )
static_cast<TQCheckListItem*>(item)->TQCheckListItem::setOn( b );
// Update folder list
- TQStringList::Iterator it = CollectionSetup::instance()->m_dirs.find( m_url.path() );
+ TQStringList::Iterator it = collectionSetup->m_dirs.find( m_url.path() );
if ( isOn() ) {
- if ( it == CollectionSetup::instance()->m_dirs.end() )
+ if ( it == collectionSetup->m_dirs.end() )
{
- CollectionSetup::instance()->m_dirs << m_url.path();
- CollectionSetup::instance()->m_refcount[ m_url.path() ] = 1;
+ collectionSetup->m_dirs << m_url.path();
+ collectionSetup->m_refcount[ m_url.path() ] = 1;
}
else
- CollectionSetup::instance()->m_refcount[ m_url.path() ]++;
+ collectionSetup->m_refcount[ m_url.path() ]++;
}
- else if ( CollectionSetup::instance()->m_refcount.find( m_url.path() ) != CollectionSetup::instance()->m_refcount.end() )
+ else if ( collectionSetup->m_refcount.find( m_url.path() ) != collectionSetup->m_refcount.end() )
{
- if ( --CollectionSetup::instance()->m_refcount[ m_url.path() ] == 0 )
- {
- CollectionSetup::instance()->m_dirs.erase( it );
- CollectionSetup::instance()->m_refcount.remove( m_url.path() );
- }
+ if ( --collectionSetup->m_refcount[ m_url.path() ] == 0 )
+ {
+ collectionSetup->m_dirs.erase( it );
+ collectionSetup->m_refcount.remove( m_url.path() );
+ }
}
// Redraw parent items
@@ -193,10 +190,10 @@ Item::newItems( const KFileItemList &list ) //SLOT
{
for( KFileItemListIterator it( list ); *it; ++it )
{
- Item *item = new Item( this, (*it)->url() );
+ Item *item = new Item( this, collectionSetup, (*it)->url() );
- item->setOn( CollectionSetup::instance()->recursive() && isOn() ||
- CollectionSetup::instance()->m_dirs.contains( item->fullPath() ) );
+ item->setOn( collectionSetup->recursive() && isOn() ||
+ collectionSetup->m_dirs.contains( item->fullPath() ) );
item->setPixmap( 0, (*it)->pixmap( TDEIcon::SizeSmall ) );
}
@@ -209,13 +206,13 @@ Item::paintCell( TQPainter * p, const TQColorGroup & cg, int column, int width,
bool dirty = false;
// Figure out if a child folder is activated
- for ( uint i = 0; i < CollectionSetup::instance()->m_dirs.count(); i++ )
+ for ( uint i = 0; i < collectionSetup->m_dirs.count(); i++ )
{
- if ( CollectionSetup::instance()->m_dirs[ i ] == m_url.path() )
+ if ( collectionSetup->m_dirs[ i ] == m_url.path() )
{
dirty = true;
}
- else if ( CollectionSetup::instance()->m_dirs[ i ].startsWith( m_url.path() ) )
+ else if ( collectionSetup->m_dirs[ i ].startsWith( m_url.path() ) )
dirty = true;
}
@@ -232,11 +229,12 @@ Item::paintCell( TQPainter * p, const TQColorGroup & cg, int column, int width,
// CLASS DeviceItem
//////////////////////////////////////////////////////////////////////////////////////////
-DeviceItem::DeviceItem( TQListView *parent )
+DeviceItem::DeviceItem( TQListView *parent, CollectionSetup *collection )
: TQCheckListItem( parent, i18n("Devices"), TQCheckListItem::CheckBox )
, m_lister( true )
, m_listed( false )
{
+ collectionSetup = collection;
m_lister.setDirOnlyMode( true );
connect( &m_lister, SIGNAL(newItems( const KFileItemList& )), SLOT(newItems( const KFileItemList& )) );
@@ -254,12 +252,13 @@ DeviceItem::DeviceItem( TQListView *parent )
}
-DeviceItem::DeviceItem( TQListViewItem *parent, const TQString &name, const KURL &url )
+DeviceItem::DeviceItem( TQListViewItem *parent, CollectionSetup *collection, const TQString &name, const KURL &url )
: TQCheckListItem( parent, name, TQCheckListItem::CheckBox )
, m_lister( true )
, m_url( url )
, m_listed( false )
{
+ collectionSetup = collection;
if (!kapp->dcopClient()->isAttached())
kapp->dcopClient()->attach();
@@ -329,31 +328,31 @@ DeviceItem::setOpen( bool b )
void
DeviceItem::stateChange( bool b )
{
- if( CollectionSetup::instance()->recursive() )
+ if( collectionSetup->recursive() )
for( TQListViewItem *item = firstChild(); item; item = item->nextSibling() )
static_cast<TQCheckListItem*>(item)->TQCheckListItem::setOn( b );
if (text(1) != "devices")
{
// Update folder list
- TQStringList::Iterator it = CollectionSetup::instance()->m_dirs.find( text(1) );
+ TQStringList::Iterator it = collectionSetup->m_dirs.find( text(1) );
if ( isOn() ) {
- if ( it == CollectionSetup::instance()->m_dirs.end() )
+ if ( it == collectionSetup->m_dirs.end() )
{
- CollectionSetup::instance()->m_dirs << text(1);
+ collectionSetup->m_dirs << text(1);
mountDevice(text(2));
- CollectionSetup::instance()->m_refcount[text(1)] = 1;
+ collectionSetup->m_refcount[text(1)] = 1;
}
else
- CollectionSetup::instance()->m_refcount[text(1)]++;
+ collectionSetup->m_refcount[text(1)]++;
}
- else if ( CollectionSetup::instance()->m_refcount.find(text(1)) != CollectionSetup::instance()->m_refcount.end() )
+ else if ( collectionSetup->m_refcount.find(text(1)) != collectionSetup->m_refcount.end() )
{
- if ( --CollectionSetup::instance()->m_refcount[text(1)] == 0 )
+ if ( --collectionSetup->m_refcount[text(1)] == 0 )
{
- CollectionSetup::instance()->m_dirs.erase( it );
- CollectionSetup::instance()->m_refcount.remove(text(1));
+ collectionSetup->m_dirs.erase( it );
+ collectionSetup->m_refcount.remove(text(1));
}
}
}
@@ -378,10 +377,10 @@ DeviceItem::newItems( const KFileItemList &list ) //SLOT
{
kdDebug() << (*it)->name() << " " << (*it)->url() << " " << (*it)->text() << endl;
if (this->listView()->findItem((*it)->name(),0) == 0){
- DeviceItem *item = new DeviceItem( this, (*it)->name(), (*it)->url() );
+ DeviceItem *item = new DeviceItem( this, collectionSetup, (*it)->name(), (*it)->url() );
- item->setOn( CollectionSetup::instance()->recursive() && isOn() ||
- CollectionSetup::instance()->m_dirs.contains( item->fullPath() ) );
+ item->setOn( collectionSetup->recursive() && isOn() ||
+ collectionSetup->m_dirs.contains( item->fullPath() ) );
item->setPixmap( 0, (*it)->pixmap( TDEIcon::SizeSmall ) );
}
@@ -400,13 +399,13 @@ DeviceItem::paintCell( TQPainter * p, const TQColorGroup & cg, int column, int w
if (text(1) != "devices")
{
// Figure out if a child folder is activated
- for ( uint i = 0; i < CollectionSetup::instance()->m_dirs.count(); i++ )
+ for ( uint i = 0; i < collectionSetup->m_dirs.count(); i++ )
{
- if ( CollectionSetup::instance()->m_dirs[i] == text(1) )
+ if ( collectionSetup->m_dirs[i] == text(1) )
{
dirty = true;
}
- else if ( CollectionSetup::instance()->m_dirs[i].startsWith( text(1) + "/" ) )
+ else if ( collectionSetup->m_dirs[i].startsWith( text(1) + "/" ) )
dirty = true;
}
@@ -416,14 +415,14 @@ DeviceItem::paintCell( TQPainter * p, const TQColorGroup & cg, int column, int w
for( TQListViewItem *item = firstChild(); item; item = item->nextSibling() )
{
DeviceItem *itm = dynamic_cast<DeviceItem*>(item);
- for ( uint i = 0; i < CollectionSetup::instance()->m_dirs.count(); i++ )
+ for ( uint i = 0; i < collectionSetup->m_dirs.count(); i++ )
{
- if ( CollectionSetup::instance()->m_dirs[i] == itm->fullPath() )
+ if ( collectionSetup->m_dirs[i] == itm->fullPath() )
{
dirty = true;
break;
}
- else if ( CollectionSetup::instance()->m_dirs[i].startsWith( itm->fullPath() ) )
+ else if ( collectionSetup->m_dirs[i].startsWith( itm->fullPath() ) )
{
dirty = true;
break;