summaryrefslogtreecommitdiffstats
path: root/src/k3bfiletreeview.h
blob: b44af669119e4319367f60e8a199828f792c7909 (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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
/*
 *
 * $Id: k3bfiletreeview.h 619556 2007-01-03 17:38:12Z trueg $
 * Copyright (C) 2003 Sebastian Trueg <trueg@k3b.org>
 *
 * This file is part of the K3b project.
 * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.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.
 * See the file "COPYING" for the exact licensing terms.
 */


#ifndef K3BFILETREEVIEW_H
#define K3BFILETREEVIEW_H


#include <kfiletreeview.h>

class KFileTreeBranch;
class KActionCollection;
class KActionMenu;
class TQPoint;
class TQDropEvent;
class TQDragEnterEvent;

namespace K3bDevice {
  class Device;
  class DeviceManager;
}

namespace KIO {
  class Job;
}


class K3bDeviceBranch : public KFileTreeBranch
{
  Q_OBJECT
  TQ_OBJECT

 public:
  K3bDeviceBranch( KFileTreeView*, K3bDevice::Device* dev, KFileTreeViewItem* item = 0 );

  K3bDevice::Device* device() const { return m_device; }

  /**
   * Adds or removes the blockdevicename from the branch name
   */
  void showBlockDeviceName( bool b );

 public slots:
  void setCurrent( bool );

  bool populate( const KURL& url,  KFileTreeViewItem *currItem );

 private slots:
  void slotMediumChanged( K3bDevice::Device* );

 private:
  void updateLabel();

  K3bDevice::Device* m_device;
  bool m_showBlockDeviceName;
};


class K3bFileTreeBranch : public KFileTreeBranch
{
 public:
  K3bFileTreeBranch( KFileTreeView*,
		     const KURL& url,
		     const TQString& name,
		     const TQPixmap& pix,
		     bool showHidden = false,
		     KFileTreeViewItem* item = 0 );
};


class K3bDeviceBranchViewItem : public KFileTreeViewItem
{
 public:
  K3bDeviceBranchViewItem( KFileTreeViewItem*, K3bDevice::Device*, K3bDeviceBranch* );
  K3bDeviceBranchViewItem( KFileTreeView*, K3bDevice::Device*, K3bDeviceBranch* );

  TQString key( int column, bool ascending ) const;

  void setCurrent( bool );

  void paintCell( TQPainter* p, const TQColorGroup& cg, int col, int width, int align );

  int widthHint() const;

 private:
  bool m_bCurrent;

  K3bDevice::Device* m_device;
};


class K3bFileTreeViewItem : public KFileTreeViewItem
{
 public:
  K3bFileTreeViewItem( KFileTreeViewItem*, KFileItem*, KFileTreeBranch* );
  K3bFileTreeViewItem( KFileTreeView *, KFileItem*, KFileTreeBranch* );

  TQString key( int column, bool ascending ) const;
};


/**
  *@author Sebastian Trueg
  */
class K3bFileTreeView : public KFileTreeView
{
  Q_OBJECT
  TQ_OBJECT

 public: 
  K3bFileTreeView( TQWidget *tqparent = 0, const char *name = 0 );
  ~K3bFileTreeView();


  virtual KFileTreeBranch* addBranch( KFileTreeBranch* );
  virtual KFileTreeBranch* addBranch( const KURL& url, const TQString& name, const TQPixmap& , bool showHidden = false );

  K3bDeviceBranch* branch( K3bDevice::Device* dev );

  /**
   * returns 0 if no device is selected 
   */
  K3bDevice::Device* selectedDevice() const;

  /** 
   * returnes an empty url if no url is selected
   */
  KURL selectedUrl() const;

 public slots:
  /**
   * adds home and root dir branch
   */
  void addDefaultBranches();
  void addCdDeviceBranches( K3bDevice::DeviceManager* );
  void addDeviceBranch( K3bDevice::Device* dev );

  /**
   * Make dev the current device. This does not mean that the device entry
   * will be highlighted but marked otherwise since this means that it is the
   * current device in the application and not the treeview.
   */
  void setCurrentDevice( K3bDevice::Device* dev );

  /**
   * his will highlight the device and also make it the current device.
   */
  void setSelectedDevice( K3bDevice::Device* dev );

  void followUrl( const KURL& url );
  void setTreeDirOnlyMode( bool b );
  void enablePopupMenu( bool b ) { m_menuEnabled = b; }

  /**
   * @reimplemented
   */
  virtual void clear();

  void updateMinimumWidth();

 signals:
  void urlExecuted( const KURL& url );
  void deviceExecuted( K3bDevice::Device* dev );

  /** only gets emitted if the menu is disabled */
  void contextMenu( K3bDevice::Device*, const TQPoint& );
  /** only gets emitted if the menu is disabled */
  void contextMenu( const KURL& url, const TQPoint& );
  
 private slots:
  void slotItemExecuted( TQListViewItem* item );
  void slotContextMenu( KListView*, TQListViewItem*, const TQPoint& );
  void slotSettingsChangedK3b(int category);
  void slotMouseButtonClickedK3b( int btn, TQListViewItem *item, const TQPoint &pos, int c );

 private:
  void initActions();

  class Private;
  Private* d;

  bool m_dirOnlyMode;
  KActionCollection* m_actionCollection;
  KActionMenu* m_devicePopupMenu;
  KActionMenu* m_urlPopupMenu;
  bool m_menuEnabled;
};

#endif