summaryrefslogtreecommitdiffstats
path: root/quanta/treeviews/uploadtreefolder.cpp
blob: 123eaf35a0cfde1dcbc9ba630f0f42fcda595bed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/***************************************************************************
                          uploadtreefolder.cpp  -  description
                             -------------------
    begin                : Sun Aug 25 2002
    copyright            : (C) 2002 by 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; version 2 of the License.               *
 *                                                                         *
 ***************************************************************************/

// QT includes
#include <tqdir.h>
#include <tqdragobject.h>
#include <tqevent.h>
#include <tqpixmap.h>

// KDE includes
#include <kiconloader.h>

// app includes
#include "uploadtreefolder.h"
#include "uploadtreefile.h"
#include "resource.h"

UploadTreeFolder::UploadTreeFolder(const KURL &a_url, UploadTreeFolder * parent, const char * name )
    : KListViewItem( parent, name, "", "", "" )
{
  parentFolder = parent;
  m_url = a_url;
  m_url.adjustPath(1);

  setPixmap( 0, SmallIcon("folder") );
  setPixmap( 1, SmallIcon("check") );
  setText(0, m_url.fileName());

}

UploadTreeFolder::UploadTreeFolder(const KURL &a_url, TQListView * parent, const char * name )
    : KListViewItem( parent, name, "", "", "" )
{
  parentFolder = 0L;
  m_url = a_url;
  m_url.adjustPath(1);

  setPixmap( 0, SmallIcon("folder") );
  setPixmap( 1, SmallIcon("check") );
  setText(0, m_url.fileName());
}


void UploadTreeFolder::setOpen( bool open )
{
  TQListViewItem::setOpen( open );
}

/** retun full name of the folder */
//TODO: This should go away. Use url() instead.
TQString UploadTreeFolder::fullName()
{
  TQString s="";

  if ( parentFolder )
  {
    s = parentFolder->fullName();
    s += m_url.fileName()+"/";
  }
  else {
    s = m_url.fileName();
  }

  return s;
}

/** setup */
void UploadTreeFolder::setup()
{
    setExpandable( true );
    TQListViewItem::setup();
}

/** reload file list */
void UploadTreeFolder::reloadList()
{
  setOpen( false );

  TQListViewItem *child;
  while ( (child = firstChild()) )
    removeItem( child );

  setOpen( true );
}

/** need for sorting */
TQString UploadTreeFolder::key ( int, bool ) const
{
  static TQString key;

  key = TQString("0") + text(0);

  return key;
}

UploadTreeFolder::~UploadTreeFolder()
{
}

void UploadTreeFolder::setWhichPixmap(const TQString& pixmap )
{
  setPixmap( 1, SmallIcon(pixmap) );
}