summaryrefslogtreecommitdiffstats
path: root/smb4k/searchdlg/smb4ksearchdialog.h
blob: 636d731e5f823ef6bad9df1f8de11cd441f1a1a8 (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
/***************************************************************************
    smb4ksearchdialog  -  The search dialog widget of Smb4K.
                             -------------------
    begin                : Sa Jun 2 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 SMB4KSEARCHDIALOG_H
#define SMB4KSEARCHDIALOG_H

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

// TQt includes
#include <tqwidget.h>
#include <tqstring.h>

// KDE includes
#include <klistview.h>
#include <ktoolbar.h>

// forward declarations
class Smb4KHostItem;


/**
 * This is the search dialog. It enables the user to find servers,
 * that were not found by the regular network scan.
 *
 * @author Alexander Reinholdt <dustpuppy@users.berlios.de>
 */


class Smb4KSearchDialog : public TQWidget
{
  Q_OBJECT
  

  public:
    /**
     * The constructor.
     *
     * @param parent      The parent widget
     *
     * @param name        The name of this widget
     */
    Smb4KSearchDialog( TQWidget *parent = 0, const char *name = 0 );

    /**
     * The destructor.
     */
    ~Smb4KSearchDialog();

    /**
     * This enumeration determines the place where the tool bar
     * widgets are located.
     */
    enum ToolBarWidgets { Combo = 0, Search, Clear, Add };

    /**
     * Returns the search string the user entered. It's the current
     * text of the combo box.
     *
     * @returns the search string.
     */
    const TQString &searchString();

    /**
     * This function returns a pointer to the list view of this widget.
     *
     * @returns a pointer to the list view of this widget.
     */
    KListView *listView() { return m_list_view; }

    /**
     * This function returns a pointer to the tool bar of this widget.
     *
     * @returns a pointer to the tool bar of this widget.
     */
    KToolBar *toolBar() { return m_tool_bar; }

  signals:
    /**
     * This signal is emitted everytime a button of the tool bar
     * or the return key has been clicked. It passes the button id
     * according to the ToolBarWidgets enumeration.
     *
     * @param button_id   The button id
     */
    void buttonPressed( int button_id );

  protected slots:
    /**
     * This slot is called when the search text has been entered
     * and the return key has been pressed.
     */
    void slotReturnPressed();

    /**
     * This slot is activated when the text in the edit line of the
     * combo box changed. It is used to enable and disable buttons.
     *
     * @param text        The text input
     */
    void slotTextChanged( const TQString &text );

    /**
     * This slot is activated when a button in the tool bar is pressed.
     * It emits the buttonPressed() signal that can be processed by the
     * KPart or other widgets. Additionally, it also executes those things
     * that need not be done outside the widget, like clearing all the
     * list box and the combo box.
     *
     * @param button_id   The button id according to the ToolBarWidgets
     *                    enumeration.
     */
    void slotButtonPressed( int button_id );

    /**
     * This slot is activated when the user clicked into the list view. It
     * is used to disable the "Add" button in the tool bar when no item is
     * selected, i.e. the user clicked on the viewport. The rest is done by
     * slotSelectionChanged().
     *
     * @param item        The list box item that the user clicked or NULL if
     *                    he clicked onto the viewport.
     */
    void slotItemClicked( TQListViewItem *item );

    /**
     * This slot is activated when the selection changed in the list view.
     * It is used to enable/disable the "Add" button in the tool bar.
     *
     * @param item        The list box item that's currently selected
     */
    void slotSelectionChanged( TQListViewItem *item );

  private:
    /**
     * The current search string
     */
    TQString m_search_string;

    /**
     * The list box of this widget
     */
    KListView *m_list_view;

    /**
     * The tool bar of this widget
     */
    KToolBar *m_tool_bar;
};

#endif