summaryrefslogtreecommitdiffstats
path: root/libtdepim/broadcaststatus.h
blob: af8b383c53413e1ba94d313cf15e380c83f22208 (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
/*
  broadcaststatus.h

  This file is part of TDEPIM.

  Copyright (C) 2000 Don Sanders <sanders@kde.org>

  License GPL
*/

#ifndef __kpim_broadcast_status_h
#define __kpim_broadcast_status_h

#include <tqobject.h>
#include <tqmap.h>

#include <kdemacros.h>

#undef None

namespace KPIM {

class ProgressItem;

/**
    Provides a singleton which broadcasts status messages by emitting
    signals. Interested mainwindows can connect to the statusMsg()
    signal and update statusBars or whatever they use for showing status.
  */


class KDE_EXPORT BroadcastStatus : public TQObject
{

  Q_OBJECT
  

public:
  virtual ~BroadcastStatus();

  /** Return the instance of the singleton object for this class */
  static BroadcastStatus *instance();

  /** Return the last status message from setStatusMsg() */
  TQString statusMsg() const { return mStatusMsg; }
  /** Sets a status bar message with timestamp */
  void setStatusMsgWithTimestamp( const TQString& message );
  /** Sets a transmission completed status bar message */
  void setStatusMsgTransmissionCompleted( int numMessages,
                                          int numBytes = -1,
                                          int numBytesRead = -1,
                                          int numBytesToRead = -1,
                                          bool mLeaveOnServer = false,
                                          KPIM::ProgressItem* progressItem = 0 ); // set the same status in this progress item
  void setStatusMsgTransmissionCompleted( const TQString& account,
                                          int numMessages,
                                          int numBytes = -1,
                                          int numBytesRead = -1,
                                          int numBytesToRead = -1,
                                          bool mLeaveOnServer = false,
                                          KPIM::ProgressItem* progressItem = 0 ); // set the same status in this progress item

public slots:
  /** Emit an update status bar signal. It's a slot so it can be hooked up
      to other signals. */
  void setStatusMsg( const TQString& message );

  /**
      Set a status message that will go away again with the next call of
      reset().
   */
  void setTransienStatusMsg( const TQString& msg );
  /**
      Reset the status message to what ever non-transient message was last
      active or has since been set.
   */
  void reset();

signals:

  /** Emitted when setStatusMsg is called. */
  void statusMsg( const TQString& );

protected:

  BroadcastStatus();
  TQString mStatusMsg;
  bool mTransientActive;
  static BroadcastStatus* instance_;
};


}
#endif