1
/***************************************************************************
2
smb4kpreviewer_p - Private helper classes for Smb4KPreviewer class.
5
copyright : (C) 2008-2011 by Alexander Reinholdt
6
email : alexander.reinholdt@kdemail.net
7
***************************************************************************/
9
/***************************************************************************
10
* This program is free software; you can redistribute it and/or modify *
11
* it under the terms of the GNU General Public License as published by *
12
* the Free Software Foundation; either version 2 of the License, or *
13
* (at your option) any later version. *
15
* This program is distributed in the hope that it will be useful, but *
16
* WITHOUT ANY WARRANTY; without even the implied warranty of *
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
18
* General Public License for more details. *
20
* You should have received a copy of the GNU General Public License *
21
* along with this program; if not, write to the *
22
* Free Software Foundation, 51 Franklin Street, Suite 500, Boston, *
23
* MA 02110-1335, USA *
24
***************************************************************************/
26
#ifndef SMB4KPREVIEWER_P_H
27
#define SMB4KPREVIEWER_P_H
34
#include <QStringList>
35
#include <QListIterator>
40
#include <klistwidget.h>
41
#include <khistorycombobox.h>
44
// application specific includes
45
#include <smb4kpreviewer.h>
46
#include <smb4kprocess.h>
48
// forward declarations
52
#define HiddenFileItem 101
53
#define DirectoryItem 102
54
#define HiddenDirectoryItem 103
56
// Use this as follows:
57
// - The integer defines the type of the item (see above)
58
// - The key of the map is one of the following entries:
59
// + name - The name of the file or directory (mandatory)
60
// + date - The modification date of the file or directory (optional)
61
// + size - The file size (optional)
62
typedef QPair< int,QMap<QString,QString> > Item;
64
class Smb4KPreviewJob : public KJob
72
Smb4KPreviewJob( QObject *parent = 0 );
80
* Returns TRUE if the job has been started and FALSE otherwise
82
* @returns TRUE if the job has been started
84
bool isStarted() { return m_started; }
92
* This function sets up the preview job.
94
* You must run this function before start() is called.
96
* @param share The share for which the preview should be acquired
98
* @param url The location that should be listed
100
* @param parent The parent widget
102
void setupPreview( Smb4KShare *share,
107
* Returns the share object
109
* @returns the share object
111
Smb4KShare *share() { return m_share; }
114
* Returns the parent widget
116
* @returns the parent widget
118
QWidget *parentWidget() { return m_parent_widget; }
125
const QUrl &location() { return m_url; }
129
* Emitted when an authentication error happened.
131
void authError( Smb4KPreviewJob *job );
134
* Emitted when the printing is about to begin.
136
void aboutToStart( Smb4KShare *share,
140
* Emitted after the printing finished.
142
void finished( Smb4KShare *share,
146
* Emits the contents of the directory just listed
148
* @param url The URL that should be previewed
150
* @param contents The contents of the URL
152
void preview( const QUrl &url,
153
const QList<Item> &contents );
159
void slotStartPreview();
160
void slotReadStandardOutput();
161
void slotReadStandardError();
162
void slotProcessFinished( int exitCode, QProcess::ExitStatus status );
167
QWidget *m_parent_widget;
168
Smb4KProcess *m_proc;
173
class KDE_EXPORT Smb4KPreviewDialog : public KDialog
179
* This is the constructor of the preview dialog.
181
* @param share The Smb4KShare object.
183
* @param parent The parent of this widget
185
Smb4KPreviewDialog( Smb4KShare *share,
186
QWidget *parent = 0 );
191
~Smb4KPreviewDialog();
194
* Returns the share for which the preview is to be generated
198
Smb4KShare *share() { return m_share; }
202
* Emitted when the dialog closes.
204
* @param dialog This dialog
206
void aboutToClose( Smb4KPreviewDialog *dialog );
209
* This signal requests a preview for the given share and URL.
210
* Use the share for identification and authentication and the
211
* URL to determine the path.
213
* @param share The share
215
* @param url The location
217
* @param parent The parent widget that should be used
219
void requestPreview( Smb4KShare *share,
221
QWidget *parent = 0 );
224
* This signal is emitted when the user wants to abort the acquisition
225
* of the preview for the share.
227
* @param share The share
229
void abortPreview( Smb4KShare *share );
233
* This slot is called when an action has been triggered.
235
* @param action The triggered action
237
void slotActionTriggered( QAction *action );
240
* This slot can be called to request a preview. However, it only
241
* can use the current URL.
243
void slotRequestPreview();
246
* This slot takes the contents of a certain directory and displays
247
* the list of files and directories.
249
* @param url The URL that was queried
251
* @param contents The contents of a certain directory
253
void slotDisplayPreview( const QUrl &url,
254
const QList<Item> &contents );
257
* This slot is called when the preview process is about to start.
259
* @param item The Smb4KShare item
261
* @param url The location for which the preview should be
264
void slotAboutToStart( Smb4KShare *share,
268
* This slot is called when the preview process finished.
270
* @param item The Smb4KShare item
272
* @param url The location for which the preview should be
275
void slotFinished( Smb4KShare *share,
279
* Is called, if an item has been executed.
281
* @param item The item that has been exected.
283
void slotItemExecuted( QListWidgetItem *item );
286
* Is called, if an item in the combo box is activated.
288
void slotItemActivated( const QString &item );
291
* This slot is called when the close button was clicked.
293
void slotCloseClicked();
296
* This slot is called if the icon size was changed.
298
* @param group The icon group
300
void slotIconSizeChanged( int group );
314
* Enumeration for the items in the list view.
316
enum ItemType{ File = 1000,
320
* Sets up the file view.
332
KHistoryComboBox *m_combo;
360
* The current history
362
QStringList m_history;
365
* The current position in the history.
367
QStringListIterator m_iterator;
371
class Smb4KPreviewerPrivate
374
Smb4KPreviewerPrivate();
375
~Smb4KPreviewerPrivate();
376
Smb4KPreviewer instance;