×
Namespaces

Variants
Actions
(Difference between revisions)

Working with QSystemStorageInfo - System Information API

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot addition of Template:ArticleMetaData)
hamishwillee (Talk | contribs)
m (Hamishwillee - Subedit)
Line 1: Line 1:
 +
[[Category:Qt Mobility]][[Category:Code Examples]]
 
{{ArticleMetaData
 
{{ArticleMetaData
 
|sourcecode=[[Media:SystemStorageInfo.zip]]  
 
|sourcecode=[[Media:SystemStorageInfo.zip]]  
 
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
|devices= <!-- Devices tested against - e.g. ''devices=Nokia 6131 NFC, Nokia C7-00'') -->
+
|devices=Nokia 5800 xPressMusic
 
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
 
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
|platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later -->
+
|platform=S60 3rd Edition, FP1, FP2
 
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
 
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
 
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->  
 
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->  
|signing=<!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
+
|signing=Self-Signed
|capabilities=<!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
+
|capabilities=None
|keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase -->
+
|keywords=QSystemStorageInfo, QString, QStringList, QButton, QLabel, QComboBox
 
|id= <!-- Article Id (Knowledge base articles only) -->
 
|id= <!-- Article Id (Knowledge base articles only) -->
 
|language=<!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 
|language=<!-- Language category code for non-English topics - e.g. Lang-Chinese -->
Line 18: Line 19:
 
|creationdate=20100310
 
|creationdate=20100310
 
|author=[[User:Kiran10182]]
 
|author=[[User:Kiran10182]]
}}[[Category:Qt Mobility]]
 
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"
 
|-
 
|'''ID''' ||
 
|'''Creation date''' || 9-March-2010
 
|-
 
|'''Platform''' || S60 3rd Edition, FP1, FP2
 
S60 5th Edition
 
|'''Tested on devices''' || Nokia 5800 xPressMusic
 
|-
 
|'''Category''' || Qt for Symbian
 
|'''Subcategory''' || Qt Mobility API
 
|-
 
|}
 
 
 
 
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"
 
|-
 
|'''Keywords (APIs, classes, methods, functions)''': QSystemStorageInfo, QString, QStringList, QButton, QLabel, QComboBox
 
|}
 
 
 
{{Tip|<b></b>
 
* Please read this article before moving forward: [[Setting up environment for Qt Mobility API]]
 
* Setup Carbide.c++ IDE as explained in this article: [[Working with Carbide.c++ IDE for Qt Mobility APIs]]
 
 
}}
 
}}
  
 +
== Overview ==
 +
{{Abstract|This article shows how to use {{Icode|QSystemStorageInfo}} API which is a part of the ''System Information API'' from ''Qt Mobility project''.}}
  
= Overview =
 
{{Abstract|This article shows how to use '''''QSystemStorageInfo API''''' which is a part of the '''''System Information API''''' from '''''Qt Mobility project'''''.}}
 
  
 
+
== What is covered in QSystemStorageInfo API ==
= What is covered in QSystemStorageInfo API =
+
 
* It is a part of the System Information API.
 
* It is a part of the System Information API.
 
* This article covers information about
 
* This article covers information about
Line 60: Line 34:
  
  
= Capabilities required =
+
== Capabilities required ==
 
* None
 
* None
  
 
+
== UI design (.ui file) ==
= UI design (.ui file) =
+
 
[[File:QSystemStorageInfo_UI.png]]
 
[[File:QSystemStorageInfo_UI.png]]
  
 
+
== Project configuration file (.Pro file) ==
 
+
= Project configuration file (.Pro file) =
+
 
* Add the Qt Mobility project configuration option in the .Pro file as shown below
 
* Add the Qt Mobility project configuration option in the .Pro file as shown below
 
<code cpp>
 
<code cpp>
Line 76: Line 47:
 
</code>
 
</code>
  
= Implementing QSystemStorageInfo API =
+
== Implementing QSystemStorageInfo API ==
 
* QSystemStorageInfo API is a part of the QtMobility namespace. So declare the QtMobility namespace as shown below:
 
* QSystemStorageInfo API is a part of the QtMobility namespace. So declare the QtMobility namespace as shown below:
 
<code cpp>
 
<code cpp>
Line 227: Line 198:
  
  
= Useful functions =
+
== Useful functions ==
 
* QStringList logicalDrives ();
 
* QStringList logicalDrives ();
 
* qlonglong availableDiskSpace ( const QString & volumeDrive );
 
* qlonglong availableDiskSpace ( const QString & volumeDrive );
 
* qlonglong totalDiskSpace ( const QString & volumeDrive );
 
* qlonglong totalDiskSpace ( const QString & volumeDrive );
 
* QSystemStorageInfo::DriveType typeForDrive ( const QString & driveVolume );
 
* QSystemStorageInfo::DriveType typeForDrive ( const QString & driveVolume );
 
= Keywords =
 
  
 
==Headers==
 
==Headers==
Line 247: Line 216:
  
  
= Example Application=
+
== Example Application ==
 
* A working example application is available to download from here: [[Media:SystemStorageInfo.zip|QSystemStorageInfo.zip]]
 
* A working example application is available to download from here: [[Media:SystemStorageInfo.zip|QSystemStorageInfo.zip]]
  
  
= Related articles =  
+
== Related articles ==  
 
* [[Getting started with Qt Mobility APIs]]
 
* [[Getting started with Qt Mobility APIs]]
 
* [[Setting up environment for Qt Mobility API]]
 
* [[Setting up environment for Qt Mobility API]]
Line 262: Line 231:
 
* [[Working with QSystemNetworkInfo - System Information API - Part 2]]
 
* [[Working with QSystemNetworkInfo - System Information API - Part 2]]
  
= Reference links=
+
== Reference links==
 
* [http://qt.nokia.com/ Qt - cross-platform application and UI framework]
 
* [http://qt.nokia.com/ Qt - cross-platform application and UI framework]
 
* [http://labs.trolltech.com/page/Projects/QtMobility Qt Mobility API]
 
* [http://labs.trolltech.com/page/Projects/QtMobility Qt Mobility API]
 
* [http://qt.nokia.com/developer/qt-roadmap New Qt APIs Beta - Mobility Project]
 
* [http://qt.nokia.com/developer/qt-roadmap New Qt APIs Beta - Mobility Project]
* SDK help[[Category:Code Examples]]
+
* SDK help

Revision as of 02:31, 4 November 2011

Article Metadata
Code ExampleTested with
Devices(s): Nokia 5800 xPressMusic
Compatibility
Platform(s): S60 3rd Edition, FP1, FP2
Symbian
Platform Security
Signing Required: Self-Signed
Capabilities: None
Article
Keywords: QSystemStorageInfo, QString, QStringList, QButton, QLabel, QComboBox
Created: kiran10182 (10 Mar 2010)
Last edited: hamishwillee (04 Nov 2011)

Contents

Overview

This article shows how to use QSystemStorageInfo API which is a part of the System Information API from Qt Mobility project.


What is covered in QSystemStorageInfo API

  • It is a part of the System Information API.
  • This article covers information about
    • Available drives of the device
    • Available disc space of the particular drive
    • Total disc space of the particular drive
    • Type of the particular drive


Capabilities required

  • None

UI design (.ui file)

QSystemStorageInfo UI.png

Project configuration file (.Pro file)

  • Add the Qt Mobility project configuration option in the .Pro file as shown below
CONFIG += mobility
MOBILITY += systeminfo

Implementing QSystemStorageInfo API

  • QSystemStorageInfo API is a part of the QtMobility namespace. So declare the QtMobility namespace as shown below:
using namespace QtMobility;

Header file

#ifndef SYSTEMSTORAGEINFO_H
#define SYSTEMSTORAGEINFO_H
 
#include <QtGui/QWidget>
#include "ui_SystemStorageInfo.h"
#include <qsysteminfo.h>
 
using namespace QtMobility;
class SystemStorageInfo : public QWidget
{
Q_OBJECT
 
public:
SystemStorageInfo(QWidget *parent = 0);
~SystemStorageInfo();
 
public slots:
void listLogicalDrives();
void listDriveInformation(int aDriveIndex);
void resetAllFields();
 
private:
Ui::SystemStorageInfo ui;
QSystemStorageInfo* storageInfo;
};
 
#endif // SYSTEMSTORAGEINFO_H


Source file

#include "SystemStorageInfo.h"
 
SystemStorageInfo::SystemStorageInfo(QWidget *parent)
: QWidget(parent), storageInfo(NULL)
{
ui.setupUi(this);
 
storageInfo = new QSystemStorageInfo();
 
QObject::connect(ui.driveComboBox,
SIGNAL(currentIndexChanged(int)),
this,
SLOT(listDriveInformation(int)));
QObject::connect(ui.storageInfoButton,
SIGNAL(clicked()),
this,
SLOT(listLogicalDrives()));
QObject::connect(ui.resetButton,
SIGNAL(clicked()),
this,
SLOT(resetAllFields()));
}
 
SystemStorageInfo::~SystemStorageInfo()
{
delete storageInfo;
}
 
void SystemStorageInfo::listLogicalDrives()
{
if(ui.driveComboBox->count() > 1)
{
//this has been called previously and combo box contains data already
ui.driveComboBox->showPopup();
return;
}
QStringList list = storageInfo->logicalDrives();
ui.driveComboBox->addItems(list);
ui.driveComboBox->showPopup();
}
 
void SystemStorageInfo::listDriveInformation(int aDriveIndex)
{
if(aDriveIndex == 0)
{
resetAllFields();
return;
}
// Set available disc space label
QString textValue = ui.driveComboBox->itemText(aDriveIndex);
qlonglong availableSpace = storageInfo->availableDiskSpace(textValue);
QString str = QString::number(availableSpace);
ui.availabelDiscSpaceLabel->setText(str);
 
// Set total disc space label
qlonglong totalSpace = storageInfo->totalDiskSpace(textValue);
str = QString::number(totalSpace);
ui.totalDiscSpaceLabel->setText(str);
 
// Set drive type label
QString labelValue;
QSystemStorageInfo::DriveType drvType = storageInfo->typeForDrive(textValue);
switch(drvType)
{
case QSystemStorageInfo::NoDrive:
{
labelValue = ("No drive");
break;
}
case QSystemStorageInfo::InternalDrive:
{
labelValue = ("Internal Drive");
break;
}
case QSystemStorageInfo::RemovableDrive:
{
labelValue = ("Removable Drive");
break;
}
case QSystemStorageInfo::RemoteDrive:
{
labelValue = ("Remote Drive");
break;
}
case QSystemStorageInfo::CdromDrive:
{
labelValue = ("CD ROM Drive");
break;
}
default:
{
break;
}
}
ui.driveTypeLabel->setText(labelValue);
}
 
void SystemStorageInfo::resetAllFields()
{
ui.driveComboBox->setCurrentIndex(0);
ui.availabelDiscSpaceLabel->clear();
ui.totalDiscSpaceLabel->clear();
ui.driveTypeLabel->clear();
}

Output

QSystemStorageInfo device.jpg


Useful functions

  • QStringList logicalDrives ();
  • qlonglong availableDiskSpace ( const QString & volumeDrive );
  • qlonglong totalDiskSpace ( const QString & volumeDrive );
  • QSystemStorageInfo::DriveType typeForDrive ( const QString & driveVolume );

Headers

  • #include <qsysteminfo.h>

Classes

  • QSystemStorageInfo
  • QString
  • QStringList
  • QButton
  • QLabel
  • QComboBox


Example Application


Related articles

Reference links

125 page views in the last 30 days.
×