summaryrefslogtreecommitdiffstats
path: root/kradio3/plugins/gui-standard-display/radioview.h
blob: c884099863d5a4abd502b8e56dde3c1261091c2d (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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/***************************************************************************
                          radioview.h  -  description
                             -------------------
    begin                : Mit Mai 28 2003
    copyright            : (C) 2003 by Martin Witte
    email                : witte@kawo1.rwth-aachen.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.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef KRADIO_RADIOVIEW_H
#define KRADIO_RADIOVIEW_H

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

#include <tqobjectlist.h>

#include "../../src/include/radio_interfaces.h"
#include "../../src/include/radiodevicepool_interfaces.h"
#include "../../src/include/soundstreamclient_interfaces.h"
#include "../../src/include/timecontrol_interfaces.h"
#include "../../src/include/widgetplugins.h"
#include "radioview_element.h"

class TQWidgetStack;
class TQToolButton;
class KComboBox;
class TQTabWidget;
class KPopupMenu;



class RadioView : public TQWidget,
                  public WidgetPluginBase,
                  public IRadioClient,
                  public IRadioDevicePoolClient,
                  public ISoundStreamClient,
                  public ITimeControlClient
{
Q_OBJECT
  TQ_OBJECT
public:

    RadioView(const TQString &name);
    virtual ~RadioView();

    virtual TQString pluginClassName() const { return "RadioView"; }

    const TQString &name() const { return PluginBase::name(); }
          TQString &name()       { return PluginBase::name(); }

    // WidgetPluginBase

public:
    virtual void   saveState (KConfig *) const;
    virtual void   restoreState (KConfig *);

    virtual bool   connectI(Interface *i);
    virtual bool   disconnectI(Interface *i);

    virtual void   noticeWidgetPluginShown(WidgetPluginBase *p, bool shown);
    virtual void   noticePluginsChanged(const PluginList &);

    virtual ConfigPageInfo  createConfigurationPage();
    virtual AboutPageInfo   createAboutPage();

public slots:
    // connects destroy-msg with remove-function
    bool addElement    (RadioViewElement *);
    bool removeElement (TQObject *);

protected:
    void selectTopWidgets();


    // IRadioClient

RECEIVERS:
    bool noticePowerChanged(bool on);
    bool noticeStationChanged (const RadioStation &, int idx);
    bool noticeStationsChanged(const StationList &sl);
    bool noticePresetFileChanged(const TQString &/*f*/)           { return false; }

    bool noticeCurrentSoundStreamIDChanged(SoundStreamID id);

    // IRadioDevicePoolClient

RECEIVERS:
    bool noticeActiveDeviceChanged(IRadioDevice *rd);
    bool noticeDevicesChanged(const TQPtrList<IRadioDevice> &)  { return false; }
    bool noticeDeviceDescriptionChanged(const TQString &) { return false; }

    // ISoundStreamClient

RECEIVERS:
    void noticeConnectedI (ISoundStreamServer *s, bool pointer_valid);

    bool startRecordingWithFormat(SoundStreamID /*id*/,
                      const SoundFormat &/*proposed_format*/,
                      SoundFormat       &/*real_format*/);
    bool stopRecording(SoundStreamID /*id*/);

    bool noticeSoundStreamChanged(SoundStreamID id);

    // ITimeControlClient

RECEIVERS:
    bool noticeAlarmsChanged(const AlarmVector &)     { return false; }
    bool noticeAlarm(const Alarm &)                   { return false; }
    bool noticeNextAlarmChanged(const Alarm *)        { return false; }
    bool noticeCountdownStarted(const TQDateTime &end);
    bool noticeCountdownStopped();
    bool noticeCountdownZero();
    bool noticeCountdownSecondsChanged(int)           { return false; }

protected slots:

    void slotPower (bool on);
    void slotPause();
    void slotConfigure (bool show);
    void slotRecord ();
    void slotSnooze (bool start);
    void slotSnooze (int time);
    void slotRecordingMenu(int i);
    void slotBtnPluginsClicked();
    void slotComboStationSelected(int);

    void slotConfigPageDeleted(TQObject*);
    void slotElementConfigPageDeleted(TQObject*);

public slots:

    void    toggleShown() { WidgetPluginBase::pToggleShown(); }
    void    showOnOrgDesktop();
    void    show();
    void    hide();

protected:
    virtual void showEvent(TQShowEvent *);
    virtual void hideEvent(TQHideEvent *);

    virtual void autoSetCaption();

    const TQWidget *getWidget() const { return this; }
          TQWidget *getWidget()       { return this; }

    void    addConfigurationTabFor(RadioViewElement *, TQTabWidget *);
    void    addCommonConfigurationTab(TQTabWidget *);

protected:
    bool                  enableToolbarFlag;

    TQToolButton          *btnPower;
    TQToolButton          *btnConfigure;
    TQToolButton          *btnQuit;
    TQToolButton          *btnRecording;
    TQToolButton          *btnSnooze;
    TQToolButton          *btnPlugins;
    KComboBox            *comboStations;

    struct ElementCfg
    {
        RadioViewElement *element;
        TQObject          *cfg;
        ElementCfg()                                : element(NULL), cfg(NULL) {}
        ElementCfg(RadioViewElement *e, TQObject *w) : element(e), cfg(w) {}
        ElementCfg(RadioViewElement *e)             : element(e), cfg(NULL) {}
        ElementCfg(TQObject *w)                      : element(NULL), cfg(w) {}
        bool operator == (const ElementCfg &x) const;
    };

    typedef  TQPtrList<RadioViewElement>         ElementList;
    typedef  TQPtrListIterator<RadioViewElement> ElementListIterator;
    typedef  TQValueList<ElementCfg>             ElementCfgList;
    typedef  TQValueListIterator<ElementCfg>     ElementCfgListIterator;

    ElementList           elements;
    ElementCfgList        elementConfigPages;
    TQObjectList           configPages;
    TQWidgetStack *        widgetStacks[clsClassMAX];
    float                 maxUsability[clsClassMAX];

    IRadioDevice         *currentDevice;

    KPopupMenu                    *m_RecordingMenu;
    KPopupMenu                    *m_pauseMenu;
    KPopupMenu                    *m_SnoozeMenu;
    int                            m_NextRecordingMenuID;
    TQMap<int, SoundStreamID>       m_MenuID2StreamID;
    TQMap<SoundStreamID, int>       m_StreamID2MenuID;

    KPopupMenu                    *m_PluginMenu;
    TQMap<WidgetPluginBase *, int>  m_Plugins2MenuID;
};




#endif