summaryrefslogtreecommitdiffstats
path: root/smb4k/searchdlg/smb4ksearchdialog_part.h
blob: ed60782207445eb89d711afac1629ff88de774ca (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
/***************************************************************************
    smb4ksearchdialog_part  -  This Part encapsulates the search dialog
    of Smb4K.
                             -------------------
    begin                : Fr Jun 1 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 SMB4KSEARCHDIALOGPART_H
#define SMB4KSEARCHDIALOGPART_H

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

// TQt includes
#include <tqlistview.h>

// KDE includes
#include <kparts/part.h>
#include <kparts/factory.h>

// forward declarations
class Smb4KSearchDialog;
class Smb4KHostItem;


/**
 * This is one of the parts of Smb4K. It contains the search dialog.
 *
 * @author Alexander Reinholdt <dustpuppy@users.berlios.de>
 */

class Smb4KSearchDialogPart : public KParts::Part
{
  Q_OBJECT
  

  public:
    /**
     * The constructor.
     *
     * @param parentWidget        The parent widget
     *
     * @param widgetName          The name the widget should have
     *
     * @param parent              The parent object
     *
     * @param name                The name this object should have
     */
    Smb4KSearchDialogPart( TQWidget *parentWidget = 0, const char *widgetName = 0,
                           TQObject *parent = 0, const char *name = 0 );

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

  protected:
    /**
     * Reimplemented from KParts::Part.
     */
    void customEvent( TQCustomEvent *e );

  protected slots:
    /**
     * This slot is connected to the Smb4KSearchDialog::buttonPressed()
     * signal. It initializes the search process, etc.
     *
     * @param button_id           The button id according to
     *                            Smb4KSearchDialog::ToolBarWidgets.
     */
    void slotButtonPressed( int button_id );

    /**
     * This slot retrieves the search result and puts it into the search
     * dialog.
     *
     * @param item                A Smb4KHostItem object
     */
    void slotReceivedSearchResult( Smb4KHostItem *item );

    /**
     * This slot is connected to the Smb4KScanner::hostListChanged() signal
     * and checks whether the host is already known, i.e. it is in the browser,
     * or if it is "new". If it is already known, this slot will change the icon
     * of the host item from the default one to one with a tick layed over.
     */
    void slotCheckItemIsKnown();

    /**
     * This slot is invoked, when a user double clicks an item. It adds the item
     * to the list of known hosts (if necessary).
     *
     * @param item                The item that has been double clicked.
     */
    void slotItemDoubleClicked( TQListViewItem *item );

  private:
    /**
     * This is the actual search dialog widget.
     */
    Smb4KSearchDialog *m_widget;

    /**
     * Work around insertion "problems" of the search dialog items.
     */
    int m_serial_number;
};


class KInstance;
class KAboutData;

class Smb4KSearchDialogPartFactory : public KParts::Factory
{
  Q_OBJECT
  

  public:
    /**
     * The constructor
     */
    Smb4KSearchDialogPartFactory();

    /**
     * The destructor
     */
    virtual ~Smb4KSearchDialogPartFactory();

    /**
     * Reimplemented from KParts::Factory
     */
    virtual KParts::Part *createPartObject( TQWidget *parentWidget, const char *widgetName,
                                            TQObject *parent, const char *name,
                                            const char *classname, const TQStringList &args );

    /**
     * The instance
     */
    static KInstance *instance();

  private:
    /**
     * The factory's instance.
     */
    static KInstance *m_instance;

    /**
     * The factory's KAboutData object
     */
    static KAboutData *m_about;
};

#endif