summaryrefslogtreecommitdiff
authorzecke <zecke>2003-02-25 20:51:11 (UTC)
committer zecke <zecke>2003-02-25 20:51:11 (UTC)
commite6b5b28a59f5b2bf1812f5d84203f42a7d5d6916 (patch) (unidiff)
treebb6a4d52de61e1ae871ad10a302c1b140d079bb7
parent2971a56b1e30af0e1604d898e5a56c6f81f2daf0 (diff)
downloadopie-e6b5b28a59f5b2bf1812f5d84203f42a7d5d6916.zip
opie-e6b5b28a59f5b2bf1812f5d84203f42a7d5d6916.tar.gz
opie-e6b5b28a59f5b2bf1812f5d84203f42a7d5d6916.tar.bz2
Honor the clicking of the (X)-Button
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/obex/obexsend.cpp4
-rw-r--r--core/obex/obexsend.h3
2 files changed, 7 insertions, 0 deletions
diff --git a/core/obex/obexsend.cpp b/core/obex/obexsend.cpp
index 0da57ca..1b19c6b 100644
--- a/core/obex/obexsend.cpp
+++ b/core/obex/obexsend.cpp
@@ -1,291 +1,295 @@
1#include <qpushbutton.h> 1#include <qpushbutton.h>
2#include <qlabel.h> 2#include <qlabel.h>
3#include <qhbox.h> 3#include <qhbox.h>
4#include <qlayout.h> 4#include <qlayout.h>
5#include <qtimer.h> 5#include <qtimer.h>
6#include <qtl.h> 6#include <qtl.h>
7 7
8#include <qcopchannel_qws.h> 8#include <qcopchannel_qws.h>
9 9
10#include <qpe/resource.h> 10#include <qpe/resource.h>
11#include <qpe/qcopenvelope_qws.h> 11#include <qpe/qcopenvelope_qws.h>
12 12
13#include "obex.h" 13#include "obex.h"
14#include "obexsend.h" 14#include "obexsend.h"
15 15
16using namespace OpieObex; 16using namespace OpieObex;
17 17
18 18
19SendWidget::SendWidget( QWidget* parent, const char* name ) 19SendWidget::SendWidget( QWidget* parent, const char* name )
20 : QWidget( parent, name ) { 20 : QWidget( parent, name ) {
21 initUI(); 21 initUI();
22} 22}
23SendWidget::~SendWidget() { 23SendWidget::~SendWidget() {
24} 24}
25void SendWidget::initUI() { 25void SendWidget::initUI() {
26 m_obex = new Obex(this, "obex"); 26 m_obex = new Obex(this, "obex");
27 connect(m_obex, SIGNAL(error(int) ), 27 connect(m_obex, SIGNAL(error(int) ),
28 this, SLOT(slotIrError(int) ) ); 28 this, SLOT(slotIrError(int) ) );
29 connect(m_obex, SIGNAL(sent(bool) ), 29 connect(m_obex, SIGNAL(sent(bool) ),
30 this, SLOT(slotIrSent(bool) ) ); 30 this, SLOT(slotIrSent(bool) ) );
31 connect(m_obex, SIGNAL(currentTry(unsigned int ) ), 31 connect(m_obex, SIGNAL(currentTry(unsigned int ) ),
32 this, SLOT(slotIrTry(unsigned int ) ) ); 32 this, SLOT(slotIrTry(unsigned int ) ) );
33 33
34 QCopChannel* chan = new QCopChannel("QPE/IrDaAppletBack", this ); 34 QCopChannel* chan = new QCopChannel("QPE/IrDaAppletBack", this );
35 connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ), 35 connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ),
36 this, SLOT(dispatchIrda(const QCString&, const QByteArray& ) ) ); 36 this, SLOT(dispatchIrda(const QCString&, const QByteArray& ) ) );
37 37
38 chan = new QCopChannel("QPE/BluetoothBack", this ); 38 chan = new QCopChannel("QPE/BluetoothBack", this );
39 connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ), 39 connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ),
40 this, SLOT(dispatchBt(const QCString&, const QByteArray& ) ) ); 40 this, SLOT(dispatchBt(const QCString&, const QByteArray& ) ) );
41 41
42 QVBoxLayout* lay = new QVBoxLayout(this); 42 QVBoxLayout* lay = new QVBoxLayout(this);
43 43
44 QHBox* nameBox = new QHBox(this); 44 QHBox* nameBox = new QHBox(this);
45 QLabel* name = new QLabel(nameBox); 45 QLabel* name = new QLabel(nameBox);
46 name->setText( tr("<qt><h1>Sending:</h1></qt>") ); 46 name->setText( tr("<qt><h1>Sending:</h1></qt>") );
47 name->setAlignment( AlignLeft | AlignTop ); 47 name->setAlignment( AlignLeft | AlignTop );
48 m_lblFile = new QLabel(nameBox); 48 m_lblFile = new QLabel(nameBox);
49 lay->addWidget(nameBox, 0); 49 lay->addWidget(nameBox, 0);
50 50
51 QFrame* frame = new QFrame(this); 51 QFrame* frame = new QFrame(this);
52 frame->setFrameShape( QFrame::HLine ); 52 frame->setFrameShape( QFrame::HLine );
53 frame->setFrameShadow( QFrame::Sunken ); 53 frame->setFrameShadow( QFrame::Sunken );
54 lay->addWidget(frame, 10); 54 lay->addWidget(frame, 10);
55 55
56 QLabel* devices = new QLabel(this); 56 QLabel* devices = new QLabel(this);
57 devices->setText("<qt><b>Devices:</b></qt>"); 57 devices->setText("<qt><b>Devices:</b></qt>");
58 devices->setAlignment( AlignLeft | AlignTop ); 58 devices->setAlignment( AlignLeft | AlignTop );
59 lay->addWidget( devices,10 ); 59 lay->addWidget( devices,10 );
60 60
61 m_devBox = new DeviceBox(this); 61 m_devBox = new DeviceBox(this);
62 lay->addWidget( m_devBox, 50 ); 62 lay->addWidget( m_devBox, 50 );
63 connect(m_devBox, SIGNAL(selectedDevice(int, int ) ), 63 connect(m_devBox, SIGNAL(selectedDevice(int, int ) ),
64 this, SLOT(slotSelectedDevice(int, int) ) ); 64 this, SLOT(slotSelectedDevice(int, int) ) );
65 65
66 QPushButton *but = new QPushButton(this); 66 QPushButton *but = new QPushButton(this);
67 but->setText(tr("Done") ); 67 but->setText(tr("Done") );
68 connect(but, SIGNAL(clicked() ), 68 connect(but, SIGNAL(clicked() ),
69 this, SLOT(slotDone() ) ); 69 this, SLOT(slotDone() ) );
70 70
71 lay->addWidget( but ); 71 lay->addWidget( but );
72 m_lay = lay; 72 m_lay = lay;
73 73
74 // QT does not like if you add items to an layout which already exits.... 74 // QT does not like if you add items to an layout which already exits....
75 // and was layouted invalidate() does not help too 75 // and was layouted invalidate() does not help too
76 // so we use RichText.... 76 // so we use RichText....
77} 77}
78 78
79/* 79/*
80 * in send we'll first set everything up 80 * in send we'll first set everything up
81 * and then wait for a list of devices. 81 * and then wait for a list of devices.
82 */ 82 */
83void SendWidget::send( const QString& file, const QString& desc ) { 83void SendWidget::send( const QString& file, const QString& desc ) {
84 m_file = file; 84 m_file = file;
85 m_irDa.clear(); 85 m_irDa.clear();
86 m_start = 0; 86 m_start = 0;
87 m_lblFile->setText(desc.isEmpty() ? file : desc ); 87 m_lblFile->setText(desc.isEmpty() ? file : desc );
88 88
89 if ( !QCopChannel::isRegistered("QPE/IrDaApplet") ) { 89 if ( !QCopChannel::isRegistered("QPE/IrDaApplet") ) {
90 m_irDeSearch = m_devBox->addDevice( tr("IrDa is not enabled!"), DeviceBox::Error ); 90 m_irDeSearch = m_devBox->addDevice( tr("IrDa is not enabled!"), DeviceBox::Error );
91 m_start++; 91 m_start++;
92 }else 92 }else
93 m_irDeSearch = m_devBox->addDevice( tr("Searching for IrDa Devices."), DeviceBox::Search ); 93 m_irDeSearch = m_devBox->addDevice( tr("Searching for IrDa Devices."), DeviceBox::Search );
94 94
95 if ( !QCopChannel::isRegistered("QPE/Bluetooth") ) { 95 if ( !QCopChannel::isRegistered("QPE/Bluetooth") ) {
96 m_btDeSearch = m_devBox->addDevice( tr("Bluetooth is not available"), DeviceBox::Error ); 96 m_btDeSearch = m_devBox->addDevice( tr("Bluetooth is not available"), DeviceBox::Error );
97 m_start++; 97 m_start++;
98 }else 98 }else
99 m_btDeSearch = m_devBox->addDevice( tr("Searching for bluetooth Devices."), DeviceBox::Search ); 99 m_btDeSearch = m_devBox->addDevice( tr("Searching for bluetooth Devices."), DeviceBox::Search );
100 100
101 if (m_start != 2 ) { 101 if (m_start != 2 ) {
102 QCopEnvelope e0("QPE/IrDaApplet", "enableIrda()"); 102 QCopEnvelope e0("QPE/IrDaApplet", "enableIrda()");
103 QCopEnvelope e1("QPE/Bluetooth", "enableBluetooth()"); 103 QCopEnvelope e1("QPE/Bluetooth", "enableBluetooth()");
104 QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); 104 QCopEnvelope e2("QPE/IrDaApplet", "listDevices()");
105 QCopEnvelope e3("QPE/Bluetooth", "listDevices()"); 105 QCopEnvelope e3("QPE/Bluetooth", "listDevices()");
106 } 106 }
107} 107}
108void SendWidget::slotIrDaDevices( const QStringList& list) { 108void SendWidget::slotIrDaDevices( const QStringList& list) {
109 qWarning("slot it irda devices "); 109 qWarning("slot it irda devices ");
110 for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it ) { 110 for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it ) {
111 int id = m_devBox->addDevice( (*it), DeviceBox::IrDa, tr("Scheduling for beam.") ); 111 int id = m_devBox->addDevice( (*it), DeviceBox::IrDa, tr("Scheduling for beam.") );
112 m_irDa.insert( id, (*it) ); 112 m_irDa.insert( id, (*it) );
113 } 113 }
114 m_devBox->removeDevice( m_irDeSearch ); 114 m_devBox->removeDevice( m_irDeSearch );
115 m_irDaIt = m_irDa.begin(); 115 m_irDaIt = m_irDa.begin();
116 116
117 slotStartIrda(); 117 slotStartIrda();
118} 118}
119 119
120void SendWidget::slotBTDevices( const QMap<QString, QString>& str ) { 120void SendWidget::slotBTDevices( const QMap<QString, QString>& str ) {
121 for(QMap<QString, QString>::ConstIterator it = str.begin(); it != str.end(); ++it ) { 121 for(QMap<QString, QString>::ConstIterator it = str.begin(); it != str.end(); ++it ) {
122 int id = m_devBox->addDevice( it.key(), DeviceBox::BT, tr("Click to beam") ); 122 int id = m_devBox->addDevice( it.key(), DeviceBox::BT, tr("Click to beam") );
123 m_bt.insert( id, Pair( it.key(), it.data() ) ); 123 m_bt.insert( id, Pair( it.key(), it.data() ) );
124 } 124 }
125 m_devBox->removeDevice( m_btDeSearch ); 125 m_devBox->removeDevice( m_btDeSearch );
126} 126}
127void SendWidget::slotSelectedDevice( int name, int dev ) { 127void SendWidget::slotSelectedDevice( int name, int dev ) {
128 qWarning("Start beam? %d %d", name, dev ); 128 qWarning("Start beam? %d %d", name, dev );
129 if ( name == m_irDeSearch ) { 129 if ( name == m_irDeSearch ) {
130 for (QMap<int, QString>::Iterator it= m_irDa.begin(); it != m_irDa.end(); ++it ) 130 for (QMap<int, QString>::Iterator it= m_irDa.begin(); it != m_irDa.end(); ++it )
131 m_devBox->removeDevice( it.key() ); 131 m_devBox->removeDevice( it.key() );
132 132
133 QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); 133 QCopEnvelope e2("QPE/IrDaApplet", "listDevices()");
134 } 134 }
135} 135}
136void SendWidget::dispatchIrda( const QCString& str, const QByteArray& ar ) { 136void SendWidget::dispatchIrda( const QCString& str, const QByteArray& ar ) {
137 qWarning("dispatch irda %s", str.data() ); 137 qWarning("dispatch irda %s", str.data() );
138 if ( str == "devices(QStringList)" ) { 138 if ( str == "devices(QStringList)" ) {
139 QDataStream stream( ar, IO_ReadOnly ); 139 QDataStream stream( ar, IO_ReadOnly );
140 QStringList list; 140 QStringList list;
141 stream >> list; 141 stream >> list;
142 slotIrDaDevices( list ); 142 slotIrDaDevices( list );
143 } 143 }
144} 144}
145void SendWidget::dispatchBt( const QCString&, const QByteArray& ) { 145void SendWidget::dispatchBt( const QCString&, const QByteArray& ) {
146 146
147} 147}
148void SendWidget::slotIrError( int ) { 148void SendWidget::slotIrError( int ) {
149 149
150} 150}
151void SendWidget::slotIrSent( bool b) { 151void SendWidget::slotIrSent( bool b) {
152 qWarning("irda sent!!"); 152 qWarning("irda sent!!");
153 QString text = b ? tr("Sent") : tr("Failure"); 153 QString text = b ? tr("Sent") : tr("Failure");
154 m_devBox->setStatus( m_irDaIt.key(), text ); 154 m_devBox->setStatus( m_irDaIt.key(), text );
155 ++m_irDaIt; 155 ++m_irDaIt;
156 slotStartIrda(); 156 slotStartIrda();
157} 157}
158void SendWidget::slotIrTry(unsigned int trI) { 158void SendWidget::slotIrTry(unsigned int trI) {
159 m_devBox->setStatus( m_irDaIt.key(), tr("Try %1").arg( QString::number( trI ) ) ); 159 m_devBox->setStatus( m_irDaIt.key(), tr("Try %1").arg( QString::number( trI ) ) );
160} 160}
161void SendWidget::slotStartIrda() { 161void SendWidget::slotStartIrda() {
162 if (m_irDaIt == m_irDa.end() ) { 162 if (m_irDaIt == m_irDa.end() ) {
163 m_irDeSearch = m_devBox->addDevice(tr("Search again for IrDa."), DeviceBox::Search ); 163 m_irDeSearch = m_devBox->addDevice(tr("Search again for IrDa."), DeviceBox::Search );
164 return; 164 return;
165 } 165 }
166 m_devBox->setStatus( m_irDaIt.key(), tr("Start sending") ); 166 m_devBox->setStatus( m_irDaIt.key(), tr("Start sending") );
167 m_obex->send( m_file ); 167 m_obex->send( m_file );
168} 168}
169void SendWidget::closeEvent( QCloseEvent* e) {
170 e->accept(); // make sure
171 QTimer::singleShot(0, this, SLOT(slotDone() ) );
172}
169void SendWidget::slotDone() { 173void SendWidget::slotDone() {
170 QCopEnvelope e0("QPE/IrDaApplet", "disableIrda()"); 174 QCopEnvelope e0("QPE/IrDaApplet", "disableIrda()");
171 QCopEnvelope e1("QPE/Bluetooth", "disableBluetooth()"); 175 QCopEnvelope e1("QPE/Bluetooth", "disableBluetooth()");
172 emit done(); 176 emit done();
173} 177}
174QString SendWidget::file()const { 178QString SendWidget::file()const {
175 return m_file; 179 return m_file;
176} 180}
177DeviceBox::DeviceBox( QWidget* parent ) 181DeviceBox::DeviceBox( QWidget* parent )
178 : QTextBrowser( parent ) { 182 : QTextBrowser( parent ) {
179 183
180} 184}
181DeviceBox::~DeviceBox() { 185DeviceBox::~DeviceBox() {
182 186
183} 187}
184int DeviceBox::addDevice( const QString& name, int dev, const QString& status ) { 188int DeviceBox::addDevice( const QString& name, int dev, const QString& status ) {
185 /* return a id for a range of devices */ 189 /* return a id for a range of devices */
186 int id = idFor ( dev ); 190 int id = idFor ( dev );
187 DeviceItem item( name, status, dev,id ); 191 DeviceItem item( name, status, dev,id );
188 m_dev.insert( id, item ); 192 m_dev.insert( id, item );
189 setText( allText() ); 193 setText( allText() );
190 194
191 return id; 195 return id;
192} 196}
193void DeviceBox::removeDevice( int id ) { 197void DeviceBox::removeDevice( int id ) {
194 if (!m_dev.contains(id) ) return; 198 if (!m_dev.contains(id) ) return;
195 199
196 m_dev.remove( id ); 200 m_dev.remove( id );
197 setText( allText() ); 201 setText( allText() );
198} 202}
199void DeviceBox::setStatus( int id, const QString& status ) { 203void DeviceBox::setStatus( int id, const QString& status ) {
200 if ( !m_dev.contains(id) ) return; 204 if ( !m_dev.contains(id) ) return;
201 m_dev[id].setStatus(status ); 205 m_dev[id].setStatus(status );
202 setText( allText() ); 206 setText( allText() );
203} 207}
204void DeviceBox::setSource( const QString& str ) { 208void DeviceBox::setSource( const QString& str ) {
205 qWarning("SetSource:%d", str.toInt() ); 209 qWarning("SetSource:%d", str.toInt() );
206 int id = str.toInt(); 210 int id = str.toInt();
207 emit selectedDevice( id, m_dev[id].device() ); 211 emit selectedDevice( id, m_dev[id].device() );
208} 212}
209int DeviceBox::idFor ( int id ) { 213int DeviceBox::idFor ( int id ) {
210 static int irId = 1501; 214 static int irId = 1501;
211 static int irBT = 1001; 215 static int irBT = 1001;
212 static int irSr = 501; 216 static int irSr = 501;
213 static int irEr = 0; 217 static int irEr = 0;
214 218
215 int ret = -1; 219 int ret = -1;
216 switch(id ) { 220 switch(id ) {
217 case IrDa: 221 case IrDa:
218 ret = irId; 222 ret = irId;
219 irId++; 223 irId++;
220 break; 224 break;
221 case BT: 225 case BT:
222 ret = irBT; 226 ret = irBT;
223 irBT++; 227 irBT++;
224 break; 228 break;
225 case Search: 229 case Search:
226 ret = irSr; 230 ret = irSr;
227 irSr++; 231 irSr++;
228 break; 232 break;
229 case Error: 233 case Error:
230 ret = irEr; 234 ret = irEr;
231 irEr++; 235 irEr++;
232 break; 236 break;
233 } 237 }
234 return ret; 238 return ret;
235} 239}
236QString DeviceBox::allText() { 240QString DeviceBox::allText() {
237 QString str; 241 QString str;
238 typedef QMap<int, DeviceItem> DeviceMap; 242 typedef QMap<int, DeviceItem> DeviceMap;
239 243
240 for (QMap<int, DeviceItem>::Iterator it = m_dev.begin(); it != m_dev.end(); ++it ) { 244 for (QMap<int, DeviceItem>::Iterator it = m_dev.begin(); it != m_dev.end(); ++it ) {
241 str += it.data().toString() + "<br>"; 245 str += it.data().toString() + "<br>";
242 } 246 }
243 return str; 247 return str;
244} 248}
245 249
246DeviceItem::DeviceItem( const QString& name, 250DeviceItem::DeviceItem( const QString& name,
247 const QString& status, int dev, int id) 251 const QString& status, int dev, int id)
248{ 252{
249 m_name = name; 253 m_name = name;
250 m_status = status; 254 m_status = status;
251 m_dev = dev; 255 m_dev = dev;
252 m_id = id; 256 m_id = id;
253} 257}
254int DeviceItem::id()const { 258int DeviceItem::id()const {
255 return m_id; 259 return m_id;
256} 260}
257QString DeviceItem::name()const { 261QString DeviceItem::name()const {
258 return m_name; 262 return m_name;
259} 263}
260QString DeviceItem::status()const { 264QString DeviceItem::status()const {
261 return m_status; 265 return m_status;
262} 266}
263int DeviceItem::device()const { 267int DeviceItem::device()const {
264 return m_dev; 268 return m_dev;
265} 269}
266QString DeviceItem::pixmap()const{ 270QString DeviceItem::pixmap()const{
267 QString str; 271 QString str;
268 switch(m_dev) { 272 switch(m_dev) {
269 case DeviceBox::IrDa: 273 case DeviceBox::IrDa:
270 str ="obex/irda"; 274 str ="obex/irda";
271 break; 275 break;
272 case DeviceBox::BT: 276 case DeviceBox::BT:
273 str ="obex/bt"; 277 str ="obex/bt";
274 break; 278 break;
275 case DeviceBox::Search: 279 case DeviceBox::Search:
276 str = "obex/search"; 280 str = "obex/search";
277 break; 281 break;
278 case DeviceBox::Error: 282 case DeviceBox::Error:
279 str = "editdelete"; 283 str = "editdelete";
280 break; 284 break;
281 }; 285 };
282 return str; 286 return str;
283} 287}
284DeviceItem::~DeviceItem() { 288DeviceItem::~DeviceItem() {
285} 289}
286void DeviceItem::setStatus(const QString& status ) { 290void DeviceItem::setStatus(const QString& status ) {
287 m_status = status; 291 m_status = status;
288} 292}
289QString DeviceItem::toString()const { 293QString DeviceItem::toString()const {
290 return "<p><a href=\""+QString::number(m_id) +"\" ><img src=\""+pixmap()+"\" >"+m_name+" "+m_status+" </a></p>" ; 294 return "<p><a href=\""+QString::number(m_id) +"\" ><img src=\""+pixmap()+"\" >"+m_name+" "+m_status+" </a></p>" ;
291} 295}
diff --git a/core/obex/obexsend.h b/core/obex/obexsend.h
index 02100f7..bf901cb 100644
--- a/core/obex/obexsend.h
+++ b/core/obex/obexsend.h
@@ -1,122 +1,125 @@
1#ifndef OPIE_OBEX_SEND_WIDGET_H 1#ifndef OPIE_OBEX_SEND_WIDGET_H
2#define OPIE_OBEX_SEND_WIDGET_H 2#define OPIE_OBEX_SEND_WIDGET_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5#include <qstringlist.h> 5#include <qstringlist.h>
6#include <qwidget.h> 6#include <qwidget.h>
7#include <qvbox.h> 7#include <qvbox.h>
8#include <qmap.h> 8#include <qmap.h>
9#include <qtextbrowser.h> 9#include <qtextbrowser.h>
10 10
11class QLabel; 11class QLabel;
12class QVBoxLayout; 12class QVBoxLayout;
13/** 13/**
14 * This is the new sending widget for Obex 14 * This is the new sending widget for Obex
15 * It will attemp to smart and be able to send 15 * It will attemp to smart and be able to send
16 * it to multiple devices. 16 * it to multiple devices.
17 * It'll support BT + IrDa 17 * It'll support BT + IrDa
18 */ 18 */
19namespace OpieObex { 19namespace OpieObex {
20 class DeviceBox; 20 class DeviceBox;
21 class Obex; 21 class Obex;
22 22
23 struct Pair { 23 struct Pair {
24 Pair(const QString& first = QString::null, 24 Pair(const QString& first = QString::null,
25 const QString& second = QString::null) 25 const QString& second = QString::null)
26 : m_first(first), m_second(second ) { 26 : m_first(first), m_second(second ) {
27 } 27 }
28 QString first()const{ return m_first; } 28 QString first()const{ return m_first; }
29 QString second()const { return m_second; } 29 QString second()const { return m_second; }
30 private: 30 private:
31 QString m_first; 31 QString m_first;
32 QString m_second; 32 QString m_second;
33 }; 33 };
34 class SendWidget : public QWidget{ 34 class SendWidget : public QWidget{
35 Q_OBJECT 35 Q_OBJECT
36 public: 36 public:
37 SendWidget( QWidget* parent = 0, const char* name = 0); 37 SendWidget( QWidget* parent = 0, const char* name = 0);
38 ~SendWidget(); 38 ~SendWidget();
39 39
40 QString file()const; 40 QString file()const;
41 41
42 protected:
43 void closeEvent( QCloseEvent* );
44
42 public slots: 45 public slots:
43 void send( const QString& file, const QString& desc ); 46 void send( const QString& file, const QString& desc );
44 47
45 signals: 48 signals:
46 void done(); 49 void done();
47 50
48 private slots: // QCOP slots 51 private slots: // QCOP slots
49 /* IrDa Names*/ 52 /* IrDa Names*/
50 void slotIrDaDevices( const QStringList& ); 53 void slotIrDaDevices( const QStringList& );
51 /* Bt Names + BD-Addr */ 54 /* Bt Names + BD-Addr */
52 void slotBTDevices( const QMap<QString, QString>& ); 55 void slotBTDevices( const QMap<QString, QString>& );
53 void slotSelectedDevice( int id, int dev ); 56 void slotSelectedDevice( int id, int dev );
54 void dispatchIrda( const QCString& str, const QByteArray& ar ); 57 void dispatchIrda( const QCString& str, const QByteArray& ar );
55 void dispatchBt( const QCString& str, const QByteArray& ar ); 58 void dispatchBt( const QCString& str, const QByteArray& ar );
56 59
57 void slotIrError( int ); 60 void slotIrError( int );
58 void slotIrSent(bool); 61 void slotIrSent(bool);
59 void slotIrTry(unsigned int ); 62 void slotIrTry(unsigned int );
60 void slotStartIrda(); 63 void slotStartIrda();
61 void slotDone(); 64 void slotDone();
62 private: 65 private:
63 void initUI(); 66 void initUI();
64 QLabel* m_lblFile; 67 QLabel* m_lblFile;
65 DeviceBox* m_devBox; 68 DeviceBox* m_devBox;
66 QVBoxLayout* m_lay; 69 QVBoxLayout* m_lay;
67 int m_start; 70 int m_start;
68 QMap<int, QString> m_irDa; 71 QMap<int, QString> m_irDa;
69 QMap<int, QString>::Iterator m_irDaIt; 72 QMap<int, QString>::Iterator m_irDaIt;
70 QMap<int, Pair > m_bt; 73 QMap<int, Pair > m_bt;
71 QString m_file; 74 QString m_file;
72 Obex* m_obex; 75 Obex* m_obex;
73 int m_irDeSearch; // search of irda and bt devices 76 int m_irDeSearch; // search of irda and bt devices
74 int m_btDeSearch; 77 int m_btDeSearch;
75 }; 78 };
76 class DeviceItem { 79 class DeviceItem {
77 public: 80 public:
78 DeviceItem( const QString& name = QString::null, 81 DeviceItem( const QString& name = QString::null,
79 const QString& status = QString::null, int dev = 3, int id = -1); 82 const QString& status = QString::null, int dev = 3, int id = -1);
80 ~DeviceItem(); 83 ~DeviceItem();
81 void setStatus( const QString& text ); 84 void setStatus( const QString& text );
82 85
83 QString name()const; 86 QString name()const;
84 QString status()const; 87 QString status()const;
85 QString pixmap()const; 88 QString pixmap()const;
86 int device()const; 89 int device()const;
87 int id()const; 90 int id()const;
88 QString toString()const; 91 QString toString()const;
89 private: 92 private:
90 QString m_name; 93 QString m_name;
91 QString m_status; 94 QString m_status;
92 int m_dev; 95 int m_dev;
93 int m_id; 96 int m_id;
94 }; 97 };
95 98
96 /* 99 /*
97 * The text field which contains the information about sending... 100 * The text field which contains the information about sending...
98 * 101 *
99 */ 102 */
100 class DeviceBox : public QTextBrowser { 103 class DeviceBox : public QTextBrowser {
101 Q_OBJECT 104 Q_OBJECT
102 public: 105 public:
103 enum Device { IrDa, BT, Search, Error }; 106 enum Device { IrDa, BT, Search, Error };
104 DeviceBox( QWidget* parent ); 107 DeviceBox( QWidget* parent );
105 ~DeviceBox(); 108 ~DeviceBox();
106 109
107 void setSource( const QString& str ); 110 void setSource( const QString& str );
108 int addDevice( const QString& name, int dev, 111 int addDevice( const QString& name, int dev,
109 const QString& status = QString::null ); 112 const QString& status = QString::null );
110 void removeDevice( int ); 113 void removeDevice( int );
111 void setStatus( int, const QString& ); 114 void setStatus( int, const QString& );
112 signals: 115 signals:
113 void selectedDevice( int id, int dev ); 116 void selectedDevice( int id, int dev );
114 private: 117 private:
115 /* returns a id for a device from a device range */ 118 /* returns a id for a device from a device range */
116 int idFor (int deviceType ); 119 int idFor (int deviceType );
117 QString allText(); 120 QString allText();
118 QMap<int, DeviceItem> m_dev; 121 QMap<int, DeviceItem> m_dev;
119 }; 122 };
120} 123}
121 124
122#endif 125#endif