summaryrefslogtreecommitdiffstats
path: root/tdeio/tdeio/defaultprogress.h
blob: de0dfd093dc1737dae34dd7b4170a9de345e84f6 (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
/* This file is part of the KDE libraries
   Copyright (C) 2000 Matej Koss <koss@miesto.sk>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License version 2 as published by the Free Software Foundation.

   This library 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
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/
#ifndef __defaultprogress_h__
#define __defaultprogress_h__

#include <tqlabel.h>

#include <tdeio/global.h>

#include <kprogress.h>

#include "progressbase.h"

class KLineEdit;

namespace TDEIO {

/*
 * A default implementation of the progress dialog ProgressBase.
 * ProgressBase
 */
class TDEIO_EXPORT DefaultProgress : public ProgressBase {

  Q_OBJECT

public:
  /**
   * Creates a new default progress dialog.
   * @param showNow true to show immediately, false to show when
   *                needed
   */
  DefaultProgress( bool showNow = true );
  /**
   * Creates a new default progress dialog.
   * @param parent the parent of the dialog (or 0 for top-level)
   * @param name the name of the dialog, can be 0
   * @since 3.1
   */
  DefaultProgress( TQWidget* parent, const char* name = 0 );
  ~DefaultProgress();

  bool keepOpen() const;

  /// Shared with uiserver.cpp
  static TQString makePercentString( unsigned long percent,
                                    TDEIO::filesize_t totalSize,
                                    unsigned long totalFiles );

public slots:
  virtual void slotTotalSize( TDEIO::Job *job, TDEIO::filesize_t size );
  virtual void slotTotalFiles( TDEIO::Job *job, unsigned long files );
  virtual void slotTotalDirs( TDEIO::Job *job, unsigned long dirs );

  virtual void slotProcessedSize( TDEIO::Job *job, TDEIO::filesize_t bytes );
  virtual void slotProcessedFiles( TDEIO::Job *job, unsigned long files );
  virtual void slotProcessedDirs( TDEIO::Job *job, unsigned long dirs );

  virtual void slotSpeed( TDEIO::Job *job, unsigned long speed );
  virtual void slotPercent( TDEIO::Job *job, unsigned long percent );
  /**
   * Called to set an information message.
   * @param job the TDEIO::Job
   * @param msg the message to set
   */
  virtual void slotInfoMessage( TDEIO::Job *job, const TQString & msg );

  virtual void slotCopying( TDEIO::Job* job, const KURL& src, const KURL& dest );
  virtual void slotMoving( TDEIO::Job* job, const KURL& src, const KURL& dest );
  virtual void slotDeleting( TDEIO::Job* job, const KURL& url );
  /**
   * Called when the job is transferring.
   * @param job the TDEIO::Job
   * @param url the url to transfer
   * @since 3.1
   */
  void slotTransferring( TDEIO::Job* job, const KURL& url );
  virtual void slotCreatingDir( TDEIO::Job* job, const KURL& dir );
  /**
   * Called when the job is requesting a stat.
   * @param job the TDEIO::Job
   * @param dir the dir to stat
   * @since 3.1
   */
  virtual void slotStating( TDEIO::Job* job, const KURL& dir );
  /**
   * Called when the job is mounting.
   * @param job the TDEIO::Job
   * @param dev the device to mount
   * @param point the mount point
   */
  virtual void slotMounting( TDEIO::Job* job, const TQString & dev, const TQString & point );
  /**
   * Called when the job is unmounting.
   * @param job the TDEIO::Job
   * @param point the mount point
   */
  virtual void slotUnmounting( TDEIO::Job* job, const TQString & point );
  virtual void slotCanResume( TDEIO::Job* job, TDEIO::filesize_t from);

  /**
   * Called when the job is cleaned.
   * @since 3.1
   */
  void slotClean();

protected:
  /// @since 3.1
  void init();
  void showTotals();
  void setDestVisible( bool visible );
  /// @since 3.1
  void checkDestination( const KURL& dest);

  KLineEdit* sourceEdit;
  KLineEdit* destEdit;
  TQLabel* progressLabel;
  TQLabel* destInvite;
  TQLabel* speedLabel;
  TQLabel* sizeLabel;
  TQLabel* resumeLabel;

  KProgress* m_pProgressBar;

  TDEIO::filesize_t m_iTotalSize;
  unsigned long m_iTotalFiles;
  unsigned long m_iTotalDirs;

  TDEIO::filesize_t m_iProcessedSize;
  unsigned long m_iProcessedDirs;
  unsigned long m_iProcessedFiles;

  enum ModeType { Copy, Move, Delete, Create, Done };
  ModeType mode;

protected:
  virtual void virtual_hook( int id, void* data );
private:
  class DefaultProgressPrivate;
  DefaultProgressPrivate* d;
private slots:
  void slotKeepOpenToggled(bool);
  void slotOpenFile();
  void slotOpenLocation();
};

} /* namespace */

#endif // __defaultprogress_h__