~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to kinfocenter/Modules/devinfo/soldevicetypes.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/*
 
3
 *  soldevicetypes.cpp
 
4
 *
 
5
 *  Copyright (C) 2009 David Hubner <hubnerd@ntlworld.com>
 
6
 *
 
7
 *  This program is free software; you can redistribute it and/or modify
 
8
 *  it under the terms of the GNU General Public License as published by
 
9
 *  the Free Software Foundation; either version 2 of the License, or
 
10
 *  (at your option) any later version.
 
11
 *
 
12
 *  This program is distributed in the hope that it will be useful,
 
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 *  GNU General Public License for more details.
 
16
 *
 
17
 *  You should have received a copy of the GNU General Public License
 
18
 *  along with this program; if not, write to the Free Software
 
19
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
20
 *
 
21
 */
 
22
 
 
23
#include "soldevicetypes.h"
 
24
 
 
25
#include <kcapacitybar.h>
 
26
// ---- Processor
 
27
 
 
28
SolProcessorDevice::SolProcessorDevice(QTreeWidgetItem *parent, const Solid::Device &device) :
 
29
  SolDevice(parent, device)
 
30
{
 
31
    deviceTypeHolder = Solid::DeviceInterface::Processor;
 
32
    setDefaultDeviceText();
 
33
}
 
34
 
 
35
SolProcessorDevice::SolProcessorDevice(const Solid::DeviceInterface::Type &type) :
 
36
  SolDevice(type)
 
37
 
38
  deviceTypeHolder = Solid::DeviceInterface::Processor;
 
39
  
 
40
  setDeviceIcon(KIcon("cpu"));
 
41
  setDeviceText(i18n("Processors"));
 
42
  setDefaultListing(type);
 
43
}
 
44
 
 
45
void SolProcessorDevice::setDefaultListing(const Solid::DeviceInterface::Type &type)
 
46
{
 
47
  createDeviceChildren<SolProcessorDevice>(this,QString(),type);
 
48
}
 
49
 
 
50
void SolProcessorDevice::setDefaultDeviceText() 
 
51
{
 
52
  const Solid::Processor *prodev = interface<const Solid::Processor>(); 
 
53
  
 
54
  if(!prodev) return;
 
55
  setText(0,i18n("Processor %1", QString::number(prodev->number())));
 
56
}
 
57
 
 
58
QVListLayout *SolProcessorDevice::infoPanelLayout() 
 
59
{
 
60
  QStringList labels;
 
61
  const Solid::Processor *prodev = interface<const Solid::Processor>(); 
 
62
  
 
63
  if(!prodev) return NULL;
 
64
  deviceInfoLayout = new QVListLayout();
 
65
  
 
66
  QStringList extensions;
 
67
  const Solid::Processor::InstructionSets insSets = prodev->instructionSets();
 
68
  
 
69
  if (insSets & Solid::Processor::IntelMmx) extensions << i18n("Intel MMX");
 
70
  if (insSets & Solid::Processor::IntelSse) extensions << i18n("Intel SSE");
 
71
  if (insSets & Solid::Processor::IntelSse2) extensions << i18n("Intel SSE2");
 
72
  if (insSets & Solid::Processor::IntelSse3) extensions << i18n("Intel SSE3");
 
73
  if (insSets & Solid::Processor::IntelSse4) extensions << i18n("Intel SSE4");
 
74
  if (insSets & Solid::Processor::Amd3DNow) extensions << i18n("AMD 3DNow");
 
75
  if (insSets & Solid::Processor::AltiVec) extensions << i18n("ATI IVEC");
 
76
  if(extensions.isEmpty()) extensions << i18n("None");
 
77
  
 
78
  labels << i18n("Processor Number: ")
 
79
  << InfoPanel::friendlyString(QString::number(prodev->number())) 
 
80
  << i18n("Max Speed: ") 
 
81
  << InfoPanel::friendlyString(QString::number(prodev->maxSpeed()))
 
82
  << i18n("Supported Instruction Sets: ")
 
83
  << extensions.join("\n");
 
84
  
 
85
  deviceInfoLayout->applyQListToLayout(labels);
 
86
  return deviceInfoLayout;
 
87
}
 
88
 
 
89
// ---- Storage
 
90
 
 
91
SolStorageDevice::SolStorageDevice(QTreeWidgetItem *parent, const Solid::Device &device, const storageChildren &c) :
 
92
  SolDevice(parent, device)
 
93
{
 
94
  deviceTypeHolder = Solid::DeviceInterface::StorageDrive;
 
95
  setDefaultDeviceText();
 
96
   
 
97
  if(c == CREATECHILDREN) 
 
98
  {
 
99
    createDeviceChildren<SolVolumeDevice>(this,device.udi(),Solid::DeviceInterface::StorageVolume);
 
100
  }
 
101
}
 
102
 
 
103
SolStorageDevice::SolStorageDevice(const Solid::DeviceInterface::Type &type) :
 
104
  SolDevice(type)
 
105
 
106
  deviceTypeHolder = Solid::DeviceInterface::StorageDrive;
 
107
  
 
108
  setDeviceIcon(KIcon("drive-harddisk"));
 
109
  setDeviceText(i18n("Storage Drives"));
 
110
  setDefaultListing(type);
 
111
}
 
112
 
 
113
void SolStorageDevice::setDefaultListing(const Solid::DeviceInterface::Type &type) 
 
114
 
115
  createDeviceChildren<SolStorageDevice>(this,QString(),type);
 
116
}
 
117
 
 
118
void SolStorageDevice::setDefaultDeviceText() 
 
119
{  
 
120
  const Solid::StorageDrive *stodev = interface<const Solid::StorageDrive>();
 
121
  if(!stodev) return;
 
122
  
 
123
  QString storageType;
 
124
  switch (stodev->driveType())
 
125
  {
 
126
    case Solid::StorageDrive::HardDisk: 
 
127
      storageType = i18n("Hard Disk Drive");  break;
 
128
    case Solid::StorageDrive::CompactFlash:
 
129
      storageType = i18n("Compact Flash Reader");  break;
 
130
    case Solid::StorageDrive::SmartMedia:
 
131
      storageType = i18n("Smart Media Reader");  break;
 
132
    case Solid::StorageDrive::SdMmc:
 
133
      storageType = i18n("SD/MMC Reader"); break;
 
134
    case Solid::StorageDrive::CdromDrive:
 
135
      storageType = i18n("Optical Drive"); break;
 
136
    case Solid::StorageDrive::MemoryStick:
 
137
      storageType = i18n("Memory Stick Reader"); break;
 
138
    case Solid::StorageDrive::Xd:
 
139
      storageType = i18n("xD Reader"); break;
 
140
    default:
 
141
      storageType = i18n("Unknown Drive"); 
 
142
  }
 
143
  
 
144
  QString deviceText = storageType;
 
145
  setDeviceText(deviceText);
 
146
}
 
147
 
 
148
QVListLayout *SolStorageDevice::infoPanelLayout() 
 
149
{  
 
150
  QStringList labels;
 
151
  const Solid::StorageDrive *stodev = interface<const Solid::StorageDrive>(); 
 
152
  
 
153
  if(!stodev) return NULL;
 
154
  deviceInfoLayout = new QVListLayout();
 
155
  
 
156
  QString bus;
 
157
  switch(stodev->bus())
 
158
  {
 
159
    case Solid::StorageDrive::Ide:
 
160
      bus = i18n("IDE"); break;
 
161
    case Solid::StorageDrive::Usb:
 
162
      bus = i18n("USB"); break;
 
163
    case Solid::StorageDrive::Ieee1394:
 
164
      bus = i18n("IEEE1394"); break;
 
165
    case Solid::StorageDrive::Scsi:
 
166
      bus = i18n("SCSI"); break;
 
167
    case Solid::StorageDrive::Sata:
 
168
      bus = i18n("SATA"); break;
 
169
    case Solid::StorageDrive::Platform:
 
170
      bus = i18n("Platform"); break;
 
171
    default:
 
172
      bus = i18n("Unknown"); 
 
173
  }
 
174
  
 
175
  labels << i18n("Bus: ")
 
176
  << bus
 
177
  << i18n("Hotpluggable?")
 
178
  << InfoPanel::convertTf(stodev->isHotpluggable())
 
179
  << i18n("Removable?") 
 
180
  << InfoPanel::convertTf(stodev->isRemovable());
 
181
  
 
182
  deviceInfoLayout->applyQListToLayout(labels);
 
183
  return deviceInfoLayout;
 
184
}
 
185
 
 
186
// ---- Network
 
187
 
 
188
SolNetworkDevice::SolNetworkDevice(QTreeWidgetItem *parent, const Solid::Device &device) :
 
189
  SolDevice(parent, device) 
 
190
{
 
191
  deviceTypeHolder = Solid::DeviceInterface::NetworkInterface;
 
192
  
 
193
  setDefaultDeviceText();
 
194
  setDefaultDeviceIcon();
 
195
}
 
196
 
 
197
SolNetworkDevice::SolNetworkDevice(const Solid::DeviceInterface::Type &type) :
 
198
  SolDevice(type)
 
199
 
200
  deviceTypeHolder = Solid::DeviceInterface::NetworkInterface;
 
201
  
 
202
  setDeviceIcon(KIcon("network-wired"));
 
203
  setDeviceText(i18n("Network Interfaces"));
 
204
  setDefaultListing(type);
 
205
}
 
206
 
 
207
void SolNetworkDevice::setDefaultListing(const Solid::DeviceInterface::Type &type) 
 
208
 
209
  createDeviceChildren<SolNetworkDevice>(this,QString(),type);
 
210
}
 
211
 
 
212
void SolNetworkDevice::setDefaultDeviceText() 
 
213
{    
 
214
  QString actTog = i18n("Connected");
 
215
  const Solid::NetworkInterface *netdev = interface<const Solid::NetworkInterface>(); 
 
216
  if(!netdev) return;
 
217
  
 
218
  QString deviceText = netdev->ifaceName()
 
219
  + " (" 
 
220
  + (netdev->isWireless() ? i18n("Wireless") : i18n("Wired")) 
 
221
  + ") ";
 
222
  
 
223
  setDeviceText(deviceText);
 
224
}
 
225
 
 
226
void SolNetworkDevice::setDefaultDeviceIcon()
 
227
{  
 
228
  const Solid::NetworkInterface *netdev = interface<const Solid::NetworkInterface>(); 
 
229
  if(!netdev) return;
 
230
  
 
231
  if(netdev->isWireless() == true)
 
232
  {
 
233
    setDeviceIcon(KIcon("network-wireless"));
 
234
  } else {
 
235
    setDeviceIcon(KIcon("network-wired"));
 
236
  }
 
237
}
 
238
 
 
239
QVListLayout *SolNetworkDevice::infoPanelLayout() 
 
240
 
241
  QStringList labels;
 
242
  const Solid::NetworkInterface *netdev = interface<const Solid::NetworkInterface>(); 
 
243
  
 
244
  if(!netdev) return NULL;
 
245
  deviceInfoLayout = new QVListLayout();
 
246
  
 
247
  labels << i18n("Hardware Address: ")
 
248
  << InfoPanel::friendlyString(netdev->hwAddress())
 
249
  << i18n("Wireless?")
 
250
  << InfoPanel::convertTf(netdev->isWireless());
 
251
  
 
252
  deviceInfoLayout->applyQListToLayout(labels); 
 
253
  return deviceInfoLayout;
 
254
}
 
255
 
 
256
void SolNetworkDevice::refreshName() 
 
257
 
258
  setDefaultDeviceText();
 
259
}
 
260
 
 
261
// ---- Volume
 
262
 
 
263
SolVolumeDevice::SolVolumeDevice(QTreeWidgetItem *parent, const Solid::Device &device) :
 
264
  SolDevice(parent, device) 
 
265
{
 
266
  deviceTypeHolder = Solid::DeviceInterface::StorageVolume;
 
267
}
 
268
 
 
269
SolVolumeDevice::SolVolumeDevice(const Solid::DeviceInterface::Type &type) :
 
270
  SolDevice(type)
 
271
 
272
  deviceTypeHolder = Solid::DeviceInterface::StorageVolume;
 
273
  
 
274
  setDefaultListing(type);
 
275
}
 
276
 
 
277
void SolVolumeDevice::setDefaultListing(const Solid::DeviceInterface::Type &type) 
 
278
 
279
  createDeviceChildren<SolVolumeDevice>(this,QString(),type);
 
280
}
 
281
 
 
282
QVListLayout *SolVolumeDevice::infoPanelLayout() 
 
283
{
 
284
  QStringList labels;
 
285
  KCapacityBar *usageBar = NULL;
 
286
  
 
287
  const Solid::StorageVolume *voldev = interface<const Solid::StorageVolume>();
 
288
  const Solid::StorageAccess *accdev = interface<const Solid::StorageAccess>();
 
289
  
 
290
  if(!voldev) return NULL;
 
291
  deviceInfoLayout = new QVListLayout();
 
292
  
 
293
  QString usage;
 
294
  switch(voldev->usage()) 
 
295
  {
 
296
    case Solid::StorageVolume::Unused:
 
297
      usage = i18n("Unused"); break;
 
298
    case Solid::StorageVolume::FileSystem:
 
299
      usage = i18n("File System"); break;
 
300
    case Solid::StorageVolume::PartitionTable:
 
301
      usage = i18n("Partition Table"); break;   
 
302
    case Solid::StorageVolume::Raid:
 
303
      usage = i18n("Raid"); break;
 
304
    case Solid::StorageVolume::Encrypted:
 
305
      usage = i18n("Encrypted"); break;
 
306
    default: 
 
307
      usage = i18n("Unknown");
 
308
  }
 
309
  
 
310
  labels << i18n("File System Type: ") 
 
311
  << InfoPanel::friendlyString(voldev->fsType())
 
312
  << i18n("Label: ")
 
313
  << InfoPanel::friendlyString(voldev->label(),i18n("Not Set"))
 
314
  << i18n("Volume Usage: ")
 
315
  << usage
 
316
  << i18n("UUID: ")
 
317
  << InfoPanel::friendlyString(voldev->uuid());
 
318
  
 
319
  if(accdev) 
 
320
  {  
 
321
    labels << "--"
 
322
    << i18n("Mounted At: ") 
 
323
    << InfoPanel::friendlyString(accdev->filePath(),i18n("Not Mounted"));
 
324
    
 
325
    if(!accdev->filePath().isEmpty()) 
 
326
    {  
 
327
      KDiskFreeSpaceInfo mountSpaceInfo = KDiskFreeSpaceInfo::freeSpaceInfo(accdev->filePath());
 
328
      
 
329
      labels << i18n("Volume Space:");
 
330
      
 
331
      usageBar = new KCapacityBar();
 
332
      usageBar->setValue(static_cast<int>((mountSpaceInfo.used() * 100) / mountSpaceInfo.size()));
 
333
      usageBar->setText(
 
334
            i18nc("Available space out of total partition size (percent used)",
 
335
                  "%1 free of %2 (%3% used)",
 
336
                  KGlobal::locale()->formatByteSize(mountSpaceInfo.available()),
 
337
                  KGlobal::locale()->formatByteSize(mountSpaceInfo.size()),
 
338
                  usageBar->value()));
 
339
    }
 
340
 
 
341
  }
 
342
  
 
343
  deviceInfoLayout->applyQListToLayout(labels);
 
344
  if(usageBar) deviceInfoLayout->addWidget(usageBar);
 
345
    
 
346
  return deviceInfoLayout;
 
347
}
 
348
  
 
349
// -- Audio
 
350
 
 
351
SolAudioDevice::SolAudioDevice(QTreeWidgetItem *parent, const Solid::Device &device) :
 
352
  SolDevice(parent, device) 
 
353
{
 
354
  deviceTypeHolder = Solid::DeviceInterface::AudioInterface;
 
355
}
 
356
 
 
357
SolAudioDevice::SolAudioDevice(const Solid::DeviceInterface::Type &type) :
 
358
  SolDevice(type)
 
359
 
360
  deviceTypeHolder = Solid::DeviceInterface::AudioInterface;
 
361
  
 
362
  setDeviceIcon(KIcon("audio-card"));
 
363
  setDeviceText(i18n("Audio Interfaces"));
 
364
  setDefaultListing(type);
 
365
}
 
366
 
 
367
void SolAudioDevice::setDefaultListing(const Solid::DeviceInterface::Type &type) 
 
368
 
369
  Q_UNUSED(type);
 
370
  alsaSubItem = NULL; ossSubItem = NULL;
 
371
  
 
372
  listAlsa();
 
373
  listOss();
 
374
}
 
375
 
 
376
void SolAudioDevice::listAlsa() 
 
377
 
378
  const Solid::Predicate alsaPred =
 
379
    Solid::Predicate(Solid::DeviceInterface::AudioInterface,"driver", "Alsa",Solid::Predicate::Equals);
 
380
  const QList<Solid::Device> list = Solid::Device::listFromQuery(alsaPred, QString());
 
381
  
 
382
  if(list.count() <= 0) return;
 
383
  
 
384
  createSubItems(ALSA);
 
385
  foreach(const Solid::Device &dev, list) addItem(dev);
 
386
}
 
387
 
 
388
void SolAudioDevice::listOss() 
 
389
{  
 
390
  const Solid::Predicate ossPred =
 
391
    Solid::Predicate(Solid::DeviceInterface::AudioInterface,"driver", "OpenSoundSystem",Solid::Predicate::Equals);
 
392
  const QList<Solid::Device> list = Solid::Device::listFromQuery(ossPred, QString());
 
393
  
 
394
  if(list.count() <= 0) return;
 
395
  
 
396
  createSubItems(OSS);
 
397
  foreach(const Solid::Device &dev, list) addItem(dev);
 
398
}
 
399
 
 
400
void SolAudioDevice::createSubItems(const SubMenus &menus)
 
401
{  
 
402
  if(menus == ALSA)
 
403
  {
 
404
    alsaSubItem = new SolDevice(this);
 
405
    alsaSubItem->setDeviceIcon(KIcon("audio-card"));
 
406
    alsaSubItem->setText(0,i18n("Alsa Interfaces"));
 
407
  } else {
 
408
    ossSubItem = new SolDevice(this);
 
409
    ossSubItem->setDeviceIcon(KIcon("audio-card"));
 
410
    ossSubItem->setText(0,i18n("Open Sound System Interfaces"));
 
411
  }
 
412
}
 
413
 
 
414
void SolAudioDevice::addItem(Solid::Device dev) 
 
415
{  
 
416
   const Solid::AudioInterface *auddev = interface<const Solid::AudioInterface>(dev);
 
417
   if(!auddev) return;
 
418
  
 
419
    switch(auddev->driver())
 
420
    {
 
421
      case Solid::AudioInterface::Alsa:
 
422
        if(!alsaSubItem) createSubItems(ALSA);
 
423
        new SolAudioDevice(alsaSubItem,dev);
 
424
        break;
 
425
      case Solid::AudioInterface::OpenSoundSystem:
 
426
        if(!ossSubItem) createSubItems(OSS);
 
427
        new SolAudioDevice(ossSubItem,dev);
 
428
        break;
 
429
      default:
 
430
        new SolAudioDevice(this,dev);
 
431
    }
 
432
}
 
433
 
 
434
QVListLayout *SolAudioDevice::infoPanelLayout() 
 
435
{
 
436
  QStringList labels;
 
437
  const Solid::AudioInterface *auddev = interface<const Solid::AudioInterface>(); 
 
438
  
 
439
  if(!auddev) return NULL;
 
440
  deviceInfoLayout = new QVListLayout();
 
441
 
 
442
  QString AiType;
 
443
  switch(auddev->deviceType()) 
 
444
  {
 
445
    case Solid::AudioInterface::AudioControl:
 
446
      AiType = i18n("Control"); break;
 
447
    case Solid::AudioInterface::AudioInput:
 
448
      AiType = i18n("Input"); break;
 
449
    case Solid::AudioInterface::AudioOutput:
 
450
      AiType = i18n("Output"); break;
 
451
    default:
 
452
      AiType = i18n("Unknown");
 
453
  }
 
454
  
 
455
  QString ScType;
 
456
  switch(auddev->soundcardType())
 
457
  {
 
458
    case Solid::AudioInterface::InternalSoundcard:
 
459
      ScType = i18n("Internal Soundcard"); break;
 
460
    case Solid::AudioInterface::UsbSoundcard:
 
461
      ScType = i18n("USB Soundcard"); break;
 
462
    case Solid::AudioInterface::FirewireSoundcard:
 
463
      ScType = i18n("Firewire Soundcard"); break;
 
464
    case Solid::AudioInterface::Headset:
 
465
      ScType = i18n("Headset"); break;
 
466
    case Solid::AudioInterface::Modem:
 
467
      ScType = i18n("Modem"); break;
 
468
    default:
 
469
      ScType = i18n("Unknown"); 
 
470
  }
 
471
  
 
472
  labels << i18n("Audio Interface Type: ")
 
473
  << AiType
 
474
  << i18n("Soundcard Type: ")
 
475
  << ScType;
 
476
  
 
477
  deviceInfoLayout->applyQListToLayout(labels);
 
478
  return deviceInfoLayout;
 
479
}
 
480
 
 
481
// Button
 
482
 
 
483
SolButtonDevice::SolButtonDevice(QTreeWidgetItem *parent, const Solid::Device &device) :
 
484
  SolDevice(parent, device) 
 
485
{
 
486
  deviceTypeHolder = Solid::DeviceInterface::Button;
 
487
  
 
488
  setDefaultDeviceIcon();
 
489
}
 
490
 
 
491
SolButtonDevice::SolButtonDevice(const Solid::DeviceInterface::Type &type) :
 
492
  SolDevice(type)
 
493
 
494
  deviceTypeHolder = Solid::DeviceInterface::Button;
 
495
  
 
496
  setDeviceIcon(KIcon("insert-button"));
 
497
  setDeviceText(i18n("Device Buttons"));
 
498
  setDefaultListing(type);
 
499
}
 
500
 
 
501
void SolButtonDevice::setDefaultListing(const Solid::DeviceInterface::Type &type) 
 
502
 
503
  createDeviceChildren<SolButtonDevice>(this,QString(),type);
 
504
}
 
505
 
 
506
void SolButtonDevice::setDefaultDeviceIcon() 
 
507
{
 
508
  setDeviceIcon(KIcon("insert-button"));
 
509
}
 
510
 
 
511
QVListLayout *SolButtonDevice::infoPanelLayout() 
 
512
{
 
513
  QStringList labels;
 
514
  const Solid::Button *butdev = interface<const Solid::Button>();
 
515
  
 
516
  if(!butdev) return NULL;
 
517
  deviceInfoLayout = new QVListLayout();
 
518
 
 
519
  QString type;
 
520
  switch(butdev->type()) 
 
521
  {
 
522
    case Solid::Button::LidButton:
 
523
      type = i18n("Lid Button"); break;
 
524
    case Solid::Button::PowerButton:
 
525
      type = i18n("Power Button"); break;
 
526
    case Solid::Button::SleepButton:
 
527
      type = i18n("Sleep Button"); break;
 
528
    case Solid::Button::TabletButton:
 
529
      type = i18n("Tablet Button"); break;
 
530
    default:
 
531
      type = i18n("Unknown Button"); 
 
532
  }
 
533
    
 
534
  labels << i18n("Button type: ")
 
535
  << type
 
536
  << i18n("Has State?")
 
537
  << InfoPanel::convertTf(butdev->hasState());
 
538
    
 
539
  deviceInfoLayout->applyQListToLayout(labels);
 
540
  return deviceInfoLayout;
 
541
}
 
542
 
 
543
// Media Player
 
544
 
 
545
SolMediaPlayerDevice::SolMediaPlayerDevice(QTreeWidgetItem *parent, const Solid::Device &device) :
 
546
  SolDevice(parent, device) 
 
547
{
 
548
  deviceTypeHolder = Solid::DeviceInterface::PortableMediaPlayer;
 
549
}
 
550
 
 
551
SolMediaPlayerDevice::SolMediaPlayerDevice(const Solid::DeviceInterface::Type &type) :
 
552
  SolDevice(type)
 
553
 
554
  deviceTypeHolder = Solid::DeviceInterface::PortableMediaPlayer;
 
555
 
 
556
  setDeviceIcon(KIcon("multimedia-player"));
 
557
  setDeviceText(i18n("Multimedia Players"));
 
558
  setDefaultListing(type);
 
559
}
 
560
 
 
561
void SolMediaPlayerDevice::setDefaultListing(const Solid::DeviceInterface::Type &type) 
 
562
 
563
  createDeviceChildren<SolMediaPlayerDevice>(this,QString(),type);
 
564
}
 
565
 
 
566
QVListLayout *SolMediaPlayerDevice::infoPanelLayout() 
 
567
{
 
568
  QStringList labels;
 
569
  const Solid::PortableMediaPlayer *mpdev = interface<const Solid::PortableMediaPlayer>(); 
 
570
  
 
571
  if(!mpdev) return NULL;
 
572
  deviceInfoLayout = new QVListLayout();
 
573
  
 
574
  labels << i18n("Supported Drivers: ")
 
575
  << mpdev->supportedDrivers()
 
576
  << i18n("Supported Protocols: ")
 
577
  << mpdev->supportedProtocols();
 
578
 
 
579
  deviceInfoLayout->applyQListToLayout(labels);
 
580
  return deviceInfoLayout;
 
581
}
 
582
 
 
583
// Camera
 
584
 
 
585
SolCameraDevice::SolCameraDevice(QTreeWidgetItem *parent, const Solid::Device &device) :
 
586
  SolDevice(parent, device) 
 
587
{
 
588
  deviceTypeHolder = Solid::DeviceInterface::Camera;
 
589
}
 
590
 
 
591
SolCameraDevice::SolCameraDevice(const Solid::DeviceInterface::Type &type) :
 
592
  SolDevice(type)
 
593
 
594
  deviceTypeHolder = Solid::DeviceInterface::Camera;
 
595
 
 
596
  setDeviceIcon(KIcon("camera-web"));
 
597
  setDeviceText(i18n("Cameras"));
 
598
  setDefaultListing(type);
 
599
}
 
600
 
 
601
void SolCameraDevice::setDefaultListing(const Solid::DeviceInterface::Type &type) 
 
602
 
603
  createDeviceChildren<SolCameraDevice>(this,QString(),type);
 
604
}
 
605
 
 
606
QVListLayout *SolCameraDevice::infoPanelLayout() 
 
607
{
 
608
  QStringList labels;
 
609
  const Solid::Camera *camdev = interface<const Solid::Camera>(); 
 
610
 
 
611
  if(!camdev) return NULL;
 
612
  deviceInfoLayout = new QVListLayout();
 
613
  
 
614
  labels << i18n("Supported Drivers: ")
 
615
  << camdev->supportedDrivers()
 
616
  << i18n("Supported Protocols: ")
 
617
  << camdev->supportedProtocols();
 
618
  
 
619
  deviceInfoLayout->applyQListToLayout(labels);
 
620
  return deviceInfoLayout;
 
621
}
 
622
  
 
623
// Battery
 
624
 
 
625
SolBatteryDevice::SolBatteryDevice(QTreeWidgetItem *parent, const Solid::Device &device) :
 
626
  SolDevice(parent, device) 
 
627
{
 
628
  deviceTypeHolder = Solid::DeviceInterface::Battery;
 
629
}
 
630
 
 
631
SolBatteryDevice::SolBatteryDevice(const Solid::DeviceInterface::Type &type) :
 
632
  SolDevice(type)
 
633
 
634
  deviceTypeHolder = Solid::DeviceInterface::Battery;
 
635
 
 
636
  setDeviceIcon(KIcon("battery"));
 
637
  setDeviceText(i18n("Batteries"));
 
638
  setDefaultListing(type);
 
639
}
 
640
 
 
641
void SolBatteryDevice::setDefaultListing(const Solid::DeviceInterface::Type &type) 
 
642
 
643
  createDeviceChildren<SolBatteryDevice>(this,QString(),type);
 
644
}
 
645
 
 
646
QVListLayout *SolBatteryDevice::infoPanelLayout() 
 
647
{  
 
648
  QStringList labels;
 
649
  const Solid::Battery *batdev = interface<const Solid::Battery>(); 
 
650
 
 
651
  if(!batdev) return NULL;
 
652
  deviceInfoLayout = new QVListLayout();
 
653
  
 
654
  QString type;
 
655
  switch(batdev->type()) 
 
656
  {
 
657
      case Solid::Battery::PdaBattery:
 
658
        type = i18n("PDA"); break;
 
659
      case Solid::Battery::UpsBattery:
 
660
        type = i18n("UPS"); break;
 
661
      case Solid::Battery::MouseBattery:
 
662
        type = i18n("Mouse"); break;
 
663
      case Solid::Battery::PrimaryBattery:
 
664
        type = i18n("Primary"); break;
 
665
      case Solid::Battery::KeyboardBattery:
 
666
        type = i18n("Keyboard"); break;
 
667
      case Solid::Battery::KeyboardMouseBattery:
 
668
        type = i18n("Keyboard + Mouse"); break;
 
669
      case Solid::Battery::CameraBattery:
 
670
        type = i18n("Camera"); break;
 
671
      default:
 
672
        type = i18n("Unknown");
 
673
  }
 
674
  
 
675
  QString state;
 
676
    switch(batdev->type())
 
677
    {
 
678
      case Solid::Battery::Charging:
 
679
        state = i18n("Charging"); break;
 
680
      case Solid::Battery::Discharging:
 
681
        state = i18n("Discharging"); break;
 
682
      default:
 
683
        state = i18n("No Charge"); 
 
684
    }
 
685
  
 
686
  labels << i18n("Battery Type: ")
 
687
  << type
 
688
  << i18n("Charge Status: ")
 
689
  << state;
 
690
  
 
691
  deviceInfoLayout->applyQListToLayout(labels);
 
692
  return deviceInfoLayout;
 
693
}
 
694
  
 
695
// Ac Adapter
 
696
 
 
697
SolAcAdapterDevice::SolAcAdapterDevice(QTreeWidgetItem *parent, const Solid::Device &device) :
 
698
  SolDevice(parent, device) 
 
699
{
 
700
  deviceTypeHolder = Solid::DeviceInterface::AcAdapter;
 
701
}
 
702
 
 
703
SolAcAdapterDevice::SolAcAdapterDevice(const Solid::DeviceInterface::Type &type) :
 
704
  SolDevice(type)
 
705
 
706
  deviceTypeHolder = Solid::DeviceInterface::AcAdapter;
 
707
 
 
708
  setDeviceIcon(KIcon("kde"));
 
709
  setDeviceText(i18n("AC Adapters"));
 
710
  setDefaultListing(type);
 
711
}
 
712
 
 
713
void SolAcAdapterDevice::setDefaultListing(const Solid::DeviceInterface::Type &type) 
 
714
 
715
  createDeviceChildren<SolAcAdapterDevice>(this,QString(),type);
 
716
}
 
717
 
 
718
QVListLayout *SolAcAdapterDevice::infoPanelLayout() 
 
719
{  
 
720
  QStringList labels;
 
721
  const Solid::AcAdapter *acdev = interface<const Solid::AcAdapter>(); 
 
722
  
 
723
  if(!acdev) return NULL;
 
724
  deviceInfoLayout = new QVListLayout();
 
725
  
 
726
  labels << i18n("Is plugged in?")
 
727
  << InfoPanel::convertTf(acdev->isPlugged());
 
728
  
 
729
  deviceInfoLayout->applyQListToLayout(labels);
 
730
  return deviceInfoLayout;
 
731
}
 
732
 
 
733
// DVB
 
734
 
 
735
SolDvbDevice::SolDvbDevice(QTreeWidgetItem *parent, const Solid::Device &device) :
 
736
  SolDevice(parent, device) 
 
737
{
 
738
  deviceTypeHolder = Solid::DeviceInterface::DvbInterface;
 
739
}
 
740
 
 
741
SolDvbDevice::SolDvbDevice(const Solid::DeviceInterface::Type &type) :
 
742
  SolDevice(type)
 
743
 
744
  deviceTypeHolder = Solid::DeviceInterface::DvbInterface;
 
745
 
 
746
  setDeviceIcon(KIcon("kde"));
 
747
  setDeviceText(i18n("Digital Video Broadcasting Devices"));
 
748
  setDefaultListing(type);
 
749
}
 
750
 
 
751
void SolDvbDevice::setDefaultListing(const Solid::DeviceInterface::Type &type) 
 
752
 
753
  createDeviceChildren<SolDvbDevice>(this,QString(),type);
 
754
}
 
755
 
 
756
QVListLayout *SolDvbDevice::infoPanelLayout() 
 
757
{  
 
758
  QStringList labels;
 
759
  const Solid::DvbInterface *dvbdev = interface<const Solid::DvbInterface>(); 
 
760
  
 
761
  if(!dvbdev) return NULL;
 
762
  deviceInfoLayout = new QVListLayout();
 
763
  
 
764
  QString type;
 
765
  switch(dvbdev->deviceType()) 
 
766
  {
 
767
    case Solid::DvbInterface::DvbAudio:
 
768
      type = i18n("Audio"); break;
 
769
    case Solid::DvbInterface::DvbCa:
 
770
      type = i18n("Conditional access system"); break;
 
771
    case Solid::DvbInterface::DvbDemux:
 
772
      type = i18n("Demux"); break;
 
773
    case Solid::DvbInterface::DvbDvr:
 
774
      type = i18n("Digital video recorder"); break;
 
775
    case Solid::DvbInterface::DvbFrontend:
 
776
      type = i18n("Front end"); break;
 
777
    case Solid::DvbInterface::DvbNet:
 
778
      type = i18n("Network"); break;
 
779
    case Solid::DvbInterface::DvbOsd:
 
780
      type = i18n("On-Screen display"); break;
 
781
    case Solid::DvbInterface::DvbSec:
 
782
      type = i18n("Security and content protection"); break;
 
783
    case Solid::DvbInterface::DvbVideo:
 
784
      type = i18n("Video"); break;
 
785
    case Solid::DvbInterface::DvbUnknown:
 
786
    default:
 
787
      type = i18n("Unknown"); 
 
788
  }
 
789
  
 
790
  labels << i18n("Device Type: ")
 
791
  << type;
 
792
  
 
793
  deviceInfoLayout->applyQListToLayout(labels);
 
794
  return deviceInfoLayout;
 
795
}
 
796
 
 
797
// Serial
 
798
 
 
799
SolSerialDevice::SolSerialDevice(QTreeWidgetItem *parent, const Solid::Device &device) :
 
800
  SolDevice(parent, device) 
 
801
{
 
802
  deviceTypeHolder = Solid::DeviceInterface::SerialInterface;
 
803
}
 
804
 
 
805
SolSerialDevice::SolSerialDevice(const Solid::DeviceInterface::Type &type) :
 
806
  SolDevice(type)
 
807
 
808
  deviceTypeHolder = Solid::DeviceInterface::SerialInterface;
 
809
  
 
810
  setDeviceIcon(KIcon("printer"));
 
811
  setDeviceText(i18n("Serial Devices"));
 
812
  setDefaultListing(type);
 
813
}
 
814
 
 
815
void SolSerialDevice::setDefaultListing(const Solid::DeviceInterface::Type &type) 
 
816
 
817
  createDeviceChildren<SolSerialDevice>(this,QString(),type);
 
818
}
 
819
 
 
820
QVListLayout *SolSerialDevice::infoPanelLayout() 
 
821
{  
 
822
  QStringList labels;
 
823
  const Solid::SerialInterface *serdev = interface<const Solid::SerialInterface>(); 
 
824
  
 
825
  if(!serdev) return NULL;
 
826
  deviceInfoLayout = new QVListLayout();
 
827
  
 
828
  QString type;
 
829
  switch(serdev->serialType())
 
830
  {
 
831
    case Solid::SerialInterface::Platform:
 
832
      type = i18n("Platform"); break;
 
833
    case Solid::SerialInterface::Usb:
 
834
      type = i18n("USB"); break;
 
835
    default:
 
836
      type = i18n("Unknown"); 
 
837
  }
 
838
  
 
839
  QString port = i18n("Unknown");
 
840
  if(serdev->port() != -1) port = QString::number(serdev->port());
 
841
 
 
842
  labels << i18n("Serial Type: ")
 
843
  << type
 
844
  << i18n("Port: ")
 
845
  << port;
 
846
  
 
847
  deviceInfoLayout->applyQListToLayout(labels);
 
848
  return deviceInfoLayout;
 
849
}
 
850
 
 
851
//  Smartcard
 
852
 
 
853
SolSmartCardDevice::SolSmartCardDevice(QTreeWidgetItem *parent, const Solid::Device &device) :
 
854
  SolDevice(parent, device) 
 
855
{
 
856
  deviceTypeHolder = Solid::DeviceInterface::SmartCardReader;
 
857
}
 
858
 
 
859
SolSmartCardDevice::SolSmartCardDevice(const Solid::DeviceInterface::Type &type) :
 
860
  SolDevice(type)
 
861
 
862
  deviceTypeHolder = Solid::DeviceInterface::SmartCardReader;
 
863
 
 
864
  setDeviceIcon(KIcon("kde"));
 
865
  setDeviceText(i18n("Smart Card Devices"));
 
866
  setDefaultListing(type);
 
867
}
 
868
 
 
869
void SolSmartCardDevice::setDefaultListing(const Solid::DeviceInterface::Type &type) 
 
870
 
871
  createDeviceChildren<SolSmartCardDevice>(this,QString(),type);
 
872
}
 
873
 
 
874
QVListLayout *SolSmartCardDevice::infoPanelLayout() 
 
875
{  
 
876
  QStringList labels;
 
877
  const Solid::SmartCardReader *scdev = interface<const Solid::SmartCardReader>(); 
 
878
  
 
879
  if(!scdev) return NULL;
 
880
  deviceInfoLayout = new QVListLayout();
 
881
  
 
882
  QString type;
 
883
  switch(scdev->readerType())
 
884
  {
 
885
    case Solid::SmartCardReader::CardReader:
 
886
      type = i18n("Card Reader"); break;
 
887
    case Solid::SmartCardReader::CryptoToken:
 
888
      type = i18n("Crypto Token"); break;
 
889
    default:
 
890
      type = i18n("Unknown"); 
 
891
  }
 
892
 
 
893
  labels << i18n("Smart Card Type: ")
 
894
  << type;
 
895
  
 
896
  deviceInfoLayout->applyQListToLayout(labels);
 
897
  return deviceInfoLayout;
 
898
}
 
899
 
 
900
// Video
 
901
 
 
902
SolVideoDevice::SolVideoDevice(QTreeWidgetItem *parent, const Solid::Device &device) :
 
903
  SolDevice(parent, device) 
 
904
{
 
905
  deviceTypeHolder = Solid::DeviceInterface::Video;
 
906
}
 
907
 
 
908
SolVideoDevice::SolVideoDevice(const Solid::DeviceInterface::Type &type) :
 
909
  SolDevice(type)
 
910
 
911
  deviceTypeHolder = Solid::DeviceInterface::Video;
 
912
  
 
913
  setDeviceIcon(KIcon("video-display"));
 
914
  setDeviceText(i18n("Video Devices"));
 
915
  setDefaultListing(type);
 
916
}
 
917
 
 
918
void SolVideoDevice::setDefaultListing(const Solid::DeviceInterface::Type &type) 
 
919
 
920
  createDeviceChildren<SolVideoDevice>(this,QString(),type);
 
921
}
 
922
 
 
923
QVListLayout *SolVideoDevice::infoPanelLayout() 
 
924
{  
 
925
  QStringList labels;
 
926
  const Solid::Video *viddev = interface<const Solid::Video>(); 
 
927
  
 
928
  if(!viddev) return NULL;
 
929
  deviceInfoLayout = new QVListLayout();
 
930
  
 
931
  labels << i18n("Supported Drivers: ")
 
932
  << viddev->supportedDrivers()
 
933
  << i18n("Supported Protocols: ")
 
934
  << viddev->supportedProtocols();
 
935
  
 
936
  deviceInfoLayout->applyQListToLayout(labels);
 
937
  return deviceInfoLayout;
 
938
}