summaryrefslogtreecommitdiffstats
path: root/smb4k/browser/smb4knetworkbrowseritem.h
blob: 75b10e36a036e9b91990dc41d4c3e0ad291dae21 (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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
/***************************************************************************
    smb4knetworkbrowseritem  -  Smb4K's network browser list item.
                             -------------------
    begin                : Mo Jan 8 2007
    copyright            : (C) 2007 by Alexander Reinholdt
    email                : dustpuppy@users.berlios.de
 ***************************************************************************/

/***************************************************************************
 *   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.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful, but   *
 *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
 *   General Public License for more details.                              *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,   *
 *   MA  02110-1301 USA                                                    *
 ***************************************************************************/

#ifndef SMB4KNETWORKBROWSERITEM_H
#define SMB4KNETWORKBROWSERITEM_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

// TQt includes
#include <tqpixmap.h>

// KDE includes
#include <tdelistview.h>

// application specific includes
#include "../core/smb4knetworkitems.h"

class Smb4KNetworkBrowser;
class Smb4KNetworkBrowserItem : public TDEListViewItem
{
  public:
    /**
     * The constructor for toplevel (workgroup) items.
     *
     * @param parent        The parent list view.
     *
     * @param item          The Smb4KWorkgroupItem that carries all the data
     *                      needed to set up a "workgroup item".
     */
    Smb4KNetworkBrowserItem( TQListView *parent, Smb4KWorkgroupItem *item );

    /**
     * The constructor for the host items.
     *
     * @param parent        The parent list view item.
     *
     * @param item          The Smb4KHostItem that carries all the data.
     */
    Smb4KNetworkBrowserItem( TQListViewItem *parent, Smb4KHostItem *item );

    /**
     * The constructor for the share items.
     *
     * @param parent        The parent list view item.
     *
     * @param item          The Smb4KShareItem that carries all the data.
     */
    Smb4KNetworkBrowserItem( TQListViewItem *parent, Smb4KShareItem *item );

    /**
     * The destructor.
     */
    virtual ~Smb4KNetworkBrowserItem();

    /**
     * Enumeration that determines the type of the item.
     */
    enum ItemType{ Workgroup, Host, Share };

    /**
     * This function returns the type of the item according to the ItemType
     * enumeration.
     *
     * @returns the type of the item.
     */
    Smb4KNetworkBrowserItem::ItemType type();

    /**
     * This function returns a pointer to the Smb4KWorkgroupItem object if it
     * is present or NULL if it is not.
     *
     * @returns a pointer to the workgroup item or NULL.
     */
    Smb4KWorkgroupItem *workgroupItem();

    /**
     * This function returns a pointer to the Smb4KHostItem object if it
     * is present or NULL if it is not.
     *
     * @returns a pointer to the host item or NULL.
     */
    Smb4KHostItem *hostItem();

    /**
     * This function returns a pointer to the Smb4KShareItem object if it
     * is present or NULL if it is not.
     *
     * @returns a pointer to the share item or NULL.
     */
    Smb4KShareItem *shareItem();

    /**
     * This function updates the internal Smb4KWorkgroupItem object.
     *
     * @param item          A Smb4KWorkgroupItem object
     */
    void update( Smb4KWorkgroupItem *item );

    /**
     * This function updates the internal Smb4KHostItem object and
     * changes the text that's being displayed in the browser. Use this,
     * if you have to alter the item in the browser.
     *
     * @param item          A Smb4KHostItem
     */
    void update( Smb4KHostItem *item );

    /**
     * This function updates the internal Smb4KShareItem object and
     * changes the text that's being displayed in the browser. Use this,
     * if you have to alter the item in the browser.
     *
     * @param item          A Smb4KShareItem
     */
    void update( Smb4KShareItem *item );

    /**
     * This is a convenience function. It returns TRUE if the item is a
     * printer share and FALSE otherwise.
     *
     * @returns TRUE if the item is a printer share and FALSE otherwise.
     */
    bool isPrinter();

    /**
     * Tell the item that the share it represents is mounted. The icon will be
     * changed by this function and the item text will be set to italic by
     * Smb4KNetworkBrowserItem::paintCell().
     *
     * @param mounted       TRUE if the share is mounted and FALSE otherwise
     */
    void setMounted( bool mounted = true );

    /**
     * Tells whether the respective share is shown as mounted or not. For non-share
     * items this function will always return FALSE.
     *
     * @returns TRUE if the share is mounted and FALSE otherwise.
     */
    bool isMounted();

    /**
     * Returns the icon of this item in "Desktop" size.
     *
     * @returns a pixmap
     */
    const TQPixmap &desktopIcon() { return m_desktop_icon; }

  protected:
    /**
     * Reimplemented from TQListViewItem.
     */
    void paintCell( TQPainter *p, const TQColorGroup &cg, int column, int width, int align );

  private:
    /**
     * This function sets the icon of the item according to
     * the type and other factors.
     */
    void setIcon();

    /**
     * The type of the item.
     */
    ItemType m_type;

    /**
     * This enumeration enumerates the columns of the item.
     */
    enum Columns{ Network = 0, Type = 1, IP = 2, Comment = 3 };

    /**
     * The workgroup item
     */
    Smb4KWorkgroupItem m_workgroup;

    /**
     * The host item
     */
    Smb4KHostItem m_host;

    /**
     * The share item
     */
    Smb4KShareItem m_share;

    /**
     * Tells us that the share item is mounted
     */
    bool m_mounted;

    /**
     * The icon in "DesktopIcon" format
     */
    TQPixmap m_desktop_icon;
};

#endif