~ubuntu-branches/ubuntu/warty/kdebase/warty

« back to all changes in this revision

Viewing changes to konqueror/listview/konq_treeviewitem.cc

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2004-09-16 04:51:45 UTC
  • Revision ID: james.westby@ubuntu.com-20040916045145-9vr63kith3k1cpza
Tags: upstream-3.2.2
ImportĀ upstreamĀ versionĀ 3.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the KDE project
 
2
   Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
 
3
                 2001, 2002 Michael Brade <brade@kde.org>
 
4
 
 
5
   This program is free software; you can redistribute it and/or
 
6
   modify it under the terms of the GNU General Public
 
7
   License as published by the Free Software Foundation; either
 
8
   version 2 of the License, or (at your option) any later version.
 
9
 
 
10
   This program is distributed in the hope that it will be useful,
 
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
    General Public License for more details.
 
14
 
 
15
   You should have received a copy of the GNU General Public License
 
16
   along with this program; see the file COPYING.  If not, write to
 
17
   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
18
   Boston, MA 02111-1307, USA.
 
19
*/
 
20
 
 
21
#include "konq_treeviewwidget.h"
 
22
#include "konq_listview.h"
 
23
 
 
24
 
 
25
/**************************************************************
 
26
 *
 
27
 * KonqListViewDir
 
28
 *
 
29
 **************************************************************/
 
30
 
 
31
KonqListViewDir::KonqListViewDir( KonqTreeViewWidget *_parent, KFileItem* _fileitem )
 
32
:KonqListViewItem( _parent, _fileitem )
 
33
{
 
34
  setExpandable( true );
 
35
  m_bComplete = false;
 
36
  _parent->addSubDir( this );
 
37
}
 
38
 
 
39
KonqListViewDir::KonqListViewDir( KonqTreeViewWidget *_treeview, KonqListViewDir * _parent, KFileItem* _fileitem )
 
40
:KonqListViewItem(_treeview,_parent,_fileitem)
 
41
{
 
42
  setExpandable( true );
 
43
  m_bComplete = false;
 
44
  _treeview->addSubDir( this );
 
45
}
 
46
 
 
47
KonqListViewDir::~KonqListViewDir()
 
48
{
 
49
  static_cast<KonqTreeViewWidget*>(m_pListViewWidget)->m_dictSubDirs.remove(url(-1));
 
50
}
 
51
 
 
52
void KonqListViewDir::setOpen( bool _open )
 
53
{
 
54
  open( _open, false );
 
55
}
 
56
 
 
57
void KonqListViewDir::open( bool _open, bool _reload )
 
58
{
 
59
  if ( _open != isOpen() || _reload )
 
60
  {
 
61
    KonqTreeViewWidget* treeView = static_cast<KonqTreeViewWidget *>(listView());
 
62
 
 
63
    if ( _open )
 
64
    {
 
65
      if ( !m_bComplete || _reload ) // complete it before opening
 
66
        treeView->openSubFolder( this, _reload );
 
67
      else
 
68
      {
 
69
        // we need to add the items to the counts for the statusbar
 
70
        KFileItemList lst;
 
71
        lst.setAutoDelete( false );
 
72
 
 
73
        QListViewItem* it = firstChild();
 
74
        while ( it )
 
75
        {
 
76
          lst.append( static_cast<KonqListViewItem*>(it)->item() );
 
77
          it = it->nextSibling();
 
78
        }
 
79
 
 
80
        // tell the view about the new items to count
 
81
        treeView->m_pBrowserView->newItems( lst );
 
82
      }
 
83
    }
 
84
    else
 
85
    {
 
86
      treeView->stopListingSubFolder( this );
 
87
 
 
88
      QListViewItem* it = firstChild();
 
89
      while ( it )
 
90
      {
 
91
        // unselect the items in the closed folder
 
92
        treeView->setSelected( it, false );
 
93
        // delete the item from the counts for the statusbar
 
94
        KFileItem* item = static_cast<KonqListViewItem*>(it)->item();
 
95
        treeView->m_pBrowserView->deleteItem( item );
 
96
        it = it->nextSibling();
 
97
      }
 
98
    }
 
99
 
 
100
    QListViewItem::setOpen( _open );
 
101
    treeView->slotOnViewport();
 
102
  }
 
103
}
 
104
 
 
105
QString KonqListViewDir::url( int _trailing )
 
106
{
 
107
  return m_fileitem->url().url( _trailing );
 
108
}
 
109