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

« back to all changes in this revision

Viewing changes to kinfocenter/Modules/infosummary/infosum.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
 *  infosum.cpp
 
4
 *
 
5
 *  Copyright (C) 2010 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 "infosum.h"
 
24
 
 
25
K_PLUGIN_FACTORY(devInfoModuleFactory, registerPlugin<InfoSumPlugin>();)
 
26
K_EXPORT_PLUGIN(devInfoModuleFactory("kcm_infosummary"))
 
27
 
 
28
InfoSumPlugin::InfoSumPlugin(QWidget *parent, const QVariantList &)  : 
 
29
  KCModule(devInfoModuleFactory::componentData(), parent)
 
30
{
 
31
  
 
32
  const KAboutData *about =
 
33
  new KAboutData(I18N_NOOP("kcm_infosummary"), 0, ki18n("Hardware Summary Information"),
 
34
                  "0.10", KLocalizedString(), KAboutData::License_GPL,
 
35
                  ki18n("(c) 2010 David Hubner"));
 
36
                  
 
37
  setAboutData(about);
 
38
  createDisplay();
 
39
}
 
40
 
 
41
InfoSumPlugin::~InfoSumPlugin() 
 
42
{  
 
43
}
 
44
  
 
45
void InfoSumPlugin::createDisplay()
 
46
{  
 
47
  m_layout = new QVBoxLayout(this);
 
48
  m_layout->setAlignment(Qt::AlignTop);
 
49
  m_layout->setSpacing(10);
 
50
  
 
51
  createOsBox();
 
52
  createCpuBox();
 
53
  //createMemBox(); // Awaiting Mem class from kdereview 
 
54
  createHdBox();
 
55
  m_layout->addStretch();
 
56
}
 
57
 
 
58
void InfoSumPlugin::createOsBox()
 
59
{  
 
60
  DefaultBoxWidget *osWidget = new DefaultBoxWidget();
 
61
  osWidget->setIcon(KIcon("kde"));
 
62
  osWidget->setLabelTitles(i18n("OS Version"),i18n("KDE SC Version"), i18n("Hostname"));
 
63
  
 
64
  OsDepInfo *osInfo = new OsDepInfo();
 
65
  
 
66
  osWidget->setLabelOne(osInfo->osVersion());
 
67
  osWidget->setLabelTwo(QString(KDE_VERSION_STRING));
 
68
  osWidget->setLabelThree(osInfo->hostName());
 
69
  osWidget->setWhatsThis(i18nc("OS whats this","This shows information about your Operating System"));
 
70
  
 
71
  m_layout->addWidget(osWidget);
 
72
  
 
73
  delete osInfo;
 
74
}
 
75
 
 
76
void InfoSumPlugin::createCpuBox() 
 
77
{
 
78
  const QList<Solid::Device> list = Solid::Device::listFromType(Solid::DeviceInterface::Processor);
 
79
 
 
80
  foreach(const Solid::Device &dev, list)
 
81
  {
 
82
    const Solid::Processor *prodev = dev.as<const Solid::Processor>();
 
83
    if(!prodev) return;
 
84
    
 
85
    DefaultBoxWidget *cpuWidget = new DefaultBoxWidget();
 
86
    cpuWidget->setLabelTitles(i18n("Processor"), i18n("Processor Number"), i18n("Processor Max Speed"));
 
87
    cpuWidget->setIcon(KIcon("cpu"));
 
88
    
 
89
    cpuWidget->setLabelOne(dev.product());
 
90
    cpuWidget->setLabelTwo(QString::number(prodev->number()));
 
91
    cpuWidget->setLabelThree(QString::number(prodev->maxSpeed()));   
 
92
    cpuWidget->setWhatsThis(i18nc("CPU whats this","This shows information about a specific CPU in your computer"));
 
93
    
 
94
    m_layout->addWidget(cpuWidget);
 
95
  }
 
96
}
 
97
 
 
98
void InfoSumPlugin::createMemBox()
 
99
{
 
100
  ProgressBoxWidget *memWidget = new ProgressBoxWidget();
 
101
  
 
102
  memWidget->setIcon(KIcon("memory"));
 
103
  memWidget->setLabelTitles(i18n("Memory Amount"),i18n("Memory Used/Free"));
 
104
  m_layout->addWidget(memWidget);
 
105
}
 
106
 
 
107
void InfoSumPlugin::createHdBox() 
 
108
{
 
109
  const Solid::Predicate stoPred =
 
110
    Solid::Predicate(Solid::DeviceInterface::StorageDrive,"driveType", "HardDisk",Solid::Predicate::Equals);
 
111
  const QList<Solid::Device> list = Solid::Device::listFromQuery(stoPred, QString());
 
112
  
 
113
  foreach(const Solid::Device &dev, list)
 
114
  {
 
115
    const Solid::StorageDrive *stodev = dev.as<const Solid::StorageDrive>();
 
116
    if(!stodev) return;
 
117
   
 
118
    DefaultBoxWidget *stoWidget = new DefaultBoxWidget();
 
119
    stoWidget->setIcon(KIcon("drive-harddisk"));
 
120
    
 
121
    stoWidget->setLabelTitles(i18n("Drive Title"),i18n("Storage Size"),i18n("Bus"));
 
122
    stoWidget->setLabelOne(dev.product());
 
123
    stoWidget->setLabelTwo(KGlobal::locale()->formatByteSize(stodev->size()));
 
124
    
 
125
    QString bus;
 
126
    switch(stodev->bus())
 
127
      {
 
128
      case Solid::StorageDrive::Ide:
 
129
        bus = i18n("IDE"); break;
 
130
      case Solid::StorageDrive::Usb:
 
131
        bus = i18n("USB"); break;
 
132
      case Solid::StorageDrive::Ieee1394:
 
133
        bus = i18n("IEEE1394"); break;
 
134
      case Solid::StorageDrive::Scsi:
 
135
        bus = i18n("SCSI"); break;
 
136
      case Solid::StorageDrive::Sata:
 
137
        bus = i18n("SATA"); break;
 
138
      case Solid::StorageDrive::Platform:
 
139
        bus = i18n("Platform"); break;
 
140
      default:
 
141
        bus = i18nc("Unknown device","Unknown"); 
 
142
    }
 
143
    
 
144
    stoWidget->setLabelThree(bus);
 
145
    stoWidget->setWhatsThis(i18nc("Hard Drive Whats This","This shows information about a specific hard drive in your computer"));
 
146
    
 
147
    m_layout->addWidget(stoWidget);
 
148
  }
 
149
}