~ubuntu-branches/ubuntu/feisty/kdetv/feisty

« back to all changes in this revision

Viewing changes to kdetv/libkdetv/channelpropertiesdialogimpl.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2005-09-17 23:25:16 UTC
  • Revision ID: james.westby@ubuntu.com-20050917232516-9wdsn3ckagbqieh8
Tags: upstream-0.8.8
ImportĀ upstreamĀ versionĀ 0.8.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- c++ -*-
 
2
/***************************************************************************
 
3
                           channelpropertiesdialogimpl.cpp
 
4
                           -------------------------------
 
5
    begin                : Sat Apr 10 2004
 
6
    copyright            : (C) 2004 by Dirk Ziegelmeier
 
7
    email                : dziegel@gmx.de
 
8
***************************************************************************/
 
9
 
 
10
/*
 
11
 * This library is free software; you can redistribute it and/or
 
12
 * modify it under the terms of the GNU Library General Public
 
13
 * License as published by the Free Software Foundation; either
 
14
 * version 2 of the License, or (at your option) any later version.
 
15
 *
 
16
 * This library is distributed in the hope that it will be useful,
 
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
19
 * Library General Public License for more details.
 
20
 *
 
21
 * You should have received a copy of the GNU Library General Public License
 
22
 * along with this library; see the file COPYING.LIB.  If not, write to
 
23
 * the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
 
24
 * Boston, MA 02110-1301, USA.
 
25
 */
 
26
 
 
27
#include <kdebug.h>
 
28
#include <klocale.h>
 
29
#include <knuminput.h>
 
30
 
 
31
#include <qcheckbox.h>
 
32
#include <qstring.h>
 
33
#include <qcombobox.h>
 
34
#include <qlcdnumber.h>
 
35
#include <qlineedit.h>
 
36
#include <qpushbutton.h>
 
37
 
 
38
#include "channel.h"
 
39
#include "channelpropertiesdialogimpl.h"
 
40
#include "kdetv.h"
 
41
#include "sourcemanager.h"
 
42
 
 
43
 
 
44
ChannelPropertiesDialogImpl::ChannelPropertiesDialogImpl( Channel* channel,
 
45
                                                          SourceManager* srcm,
 
46
                                                          QWidget* parent, 
 
47
                                                          const char* name,
 
48
                                                          bool modal,
 
49
                                                          WFlags fl )
 
50
    : ChannelPropertiesDialog(parent, name, modal, fl),
 
51
      _c(channel),
 
52
      _srcm(srcm)
 
53
{
 
54
    _enabled->setChecked(_c->enabled());
 
55
    _number->display(_c->number());
 
56
    _name->setText(_c->name());
 
57
    _freq->setValue(((double)_c->getChannelProperty("frequency").toULongLong())/1000);
 
58
    _url->setText(_c->url());
 
59
    _description->setText(_c->description());
 
60
    _globalControls->setChecked(!_c->hasControls(_srcm->device()));
 
61
 
 
62
    // add sources to listbox
 
63
    _source->insertStringList(_srcm->sourcesFor(_srcm->device()));
 
64
    // select current source
 
65
    for (int i = 0; i < _source->count(); i++) {
 
66
        if (_c->getChannelProperty("source").toString() == _source->text(i)) {
 
67
            _source->setCurrentItem(i);
 
68
            break;
 
69
        }
 
70
    }
 
71
 
 
72
    // add norms to listbox
 
73
    _encoding->insertStringList(_srcm->encodingsFor(_srcm->device()));
 
74
    // select current norm
 
75
    for (int i = 0; i < _encoding->count(); i++) {
 
76
        if (_c->getChannelProperty("encoding").toString() == _encoding->text(i)) {
 
77
            _encoding->setCurrentItem(i);
 
78
            break;
 
79
        }
 
80
    }
 
81
 
 
82
    connect(_freq, SIGNAL( valueChanged(double) ),
 
83
            this,  SLOT( freqChanged(double) ));
 
84
    connect(_source, SIGNAL( activated(const QString&) ),
 
85
            _srcm,   SLOT( setSource(const QString&) ));
 
86
    connect(_encoding, SIGNAL( activated(const QString&) ),
 
87
            _srcm,     SLOT( setEncoding(const QString&) ));
 
88
    connect(_freqUp, SIGNAL( clicked() ),
 
89
            this,    SLOT( freqUp() ));
 
90
    connect(_freqDown, SIGNAL( clicked() ),
 
91
            this,      SLOT( freqDown() ));
 
92
    connect(_guess, SIGNAL( clicked() ),
 
93
            this,   SLOT( guessClicked() ));
 
94
}
 
95
 
 
96
ChannelPropertiesDialogImpl::~ChannelPropertiesDialogImpl()
 
97
{
 
98
}
 
99
 
 
100
void ChannelPropertiesDialogImpl::freqChanged(double f)
 
101
{
 
102
    _srcm->setFrequency((long)(f*1000));
 
103
}
 
104
 
 
105
void ChannelPropertiesDialogImpl::freqUp()
 
106
{
 
107
    _freq->setValue( QMIN(_freq->value()+0.25, 1000.0) );
 
108
}
 
109
 
 
110
void ChannelPropertiesDialogImpl::freqDown()
 
111
{
 
112
    _freq->setValue( QMAX(_freq->value()-0.25, 0.0) );
 
113
}
 
114
 
 
115
void ChannelPropertiesDialogImpl::guessClicked()
 
116
{
 
117
    _url->setText("http://www." + _name->text().remove(" ") + ".com");
 
118
}
 
119
 
 
120
void ChannelPropertiesDialogImpl::accept()
 
121
{
 
122
    _c->updateValues( _name->text(), _c->number(), _enabled->isChecked() );
 
123
    _c->setChannelProperty("frequency", (Q_ULLONG)(_freq->value()*1000));
 
124
    _c->setChannelProperty("source", _source->currentText());
 
125
    _c->setChannelProperty("encoding", _encoding->currentText());
 
126
    _c->setDescription(_description->text());
 
127
    _c->setURL(_url->text());
 
128
    _c->setHasControls(_srcm->device(), !_globalControls->isChecked());
 
129
    QDialog::accept();
 
130
    emit accepted();
 
131
}
 
132
 
 
133
void ChannelPropertiesDialogImpl::reject()
 
134
{
 
135
    QDialog::reject();
 
136
    emit rejected();
 
137
}
 
138
 
 
139
#include "channelpropertiesdialogimpl.moc"