Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plasma
libksysguard
Commits
50f09ede
Commit
50f09ede
authored
Jul 31, 2020
by
David Redondo
🏎
Committed by
Arjen Hiemstra
Apr 20, 2021
Browse files
Use Formatter Units instead of having a copy of the enum
parent
b96b18c4
Changes
5
Hide whitespace changes
Inline
Side-by-side
systemstats/AggregateSensor.cpp
View file @
50f09ede
...
...
@@ -210,7 +210,7 @@ void AggregateSensor::delayedEmitDataChanged()
PercentageSensor
::
PercentageSensor
(
SensorObject
*
provider
,
const
QString
&
id
,
const
QString
&
name
)
:
SensorProperty
(
id
,
name
,
provider
)
{
setUnit
(
KSysGuard
::
utils
::
UnitPercent
);
setUnit
(
KSysGuard
::
UnitPercent
);
setMax
(
100
);
}
...
...
systemstats/CMakeLists.txt
View file @
50f09ede
...
...
@@ -9,7 +9,7 @@ set(ksgrdbackend_LIB_SRCS
add_library
(
ksgrdbackend
${
ksgrdbackend_LIB_SRCS
}
)
add_library
(
KSysGuard::StatsBackend ALIAS ksgrdbackend
)
target_link_libraries
(
ksgrdbackend PUBLIC Qt5::Core Qt5::DBus
)
target_link_libraries
(
ksgrdbackend PUBLIC Qt5::Core Qt5::DBus
KSysGuard::Formatter
)
set_target_properties
(
ksgrdbackend PROPERTIES
EXPORT_NAME SysGuardBackend
...
...
systemstats/SensorProperty.cpp
View file @
50f09ede
...
...
@@ -142,7 +142,7 @@ void SensorProperty::setMax(SensorProperty *other)
});
}
void
SensorProperty
::
setUnit
(
KSysGuard
::
utils
::
Unit
unit
)
void
SensorProperty
::
setUnit
(
KSysGuard
::
Unit
unit
)
{
if
(
m_info
.
unit
==
unit
)
{
return
;
...
...
systemstats/SensorProperty.h
View file @
50f09ede
...
...
@@ -74,7 +74,7 @@ public:
* For example to mark the usedSpace of a disk to be the same as the disk capacity
*/
void
setMax
(
SensorProperty
*
other
);
void
setUnit
(
KSysGuard
::
utils
::
Unit
unit
);
void
setUnit
(
KSysGuard
::
Unit
unit
);
void
setVariantType
(
QVariant
::
Type
type
);
bool
isSubscribed
()
const
;
...
...
systemstats/types.h
View file @
50f09ede
...
...
@@ -25,72 +25,7 @@
#include <QDBusArgument>
namespace
KSysGuard
{
namespace
utils
{
/**
* This enum type is used to specify metric prefixes.
*/
enum
MetricPrefix
{
MetricPrefixAutoAdjust
=
-
1
,
MetricPrefixUnity
=
0
,
MetricPrefixKilo
,
MetricPrefixMega
,
MetricPrefixGiga
,
MetricPrefixTera
,
MetricPrefixPeta
,
MetricPrefixLast
=
MetricPrefixPeta
};
/**
* This enum types is used to specify units.
*/
enum
Unit
{
UnitInvalid
=
-
1
,
UnitNone
=
0
,
// Byte size units.
UnitByte
=
100
,
UnitKiloByte
=
MetricPrefixKilo
+
UnitByte
,
UnitMegaByte
=
MetricPrefixMega
+
UnitByte
,
UnitGigaByte
=
MetricPrefixGiga
+
UnitByte
,
UnitTeraByte
=
MetricPrefixTera
+
UnitByte
,
UnitPetaByte
=
MetricPrefixPeta
+
UnitByte
,
// Data rate units.
UnitByteRate
=
200
,
UnitKiloByteRate
=
MetricPrefixKilo
+
UnitByteRate
,
UnitMegaByteRate
=
MetricPrefixMega
+
UnitByteRate
,
UnitGigaByteRate
=
MetricPrefixGiga
+
UnitByteRate
,
UnitTeraByteRate
=
MetricPrefixTera
+
UnitByteRate
,
UnitPetaByteRate
=
MetricPrefixPeta
+
UnitByteRate
,
// Frequency.
UnitHertz
=
300
,
UnitKiloHertz
=
MetricPrefixKilo
+
UnitHertz
,
UnitMegaHertz
=
MetricPrefixMega
+
UnitHertz
,
UnitGigaHertz
=
MetricPrefixGiga
+
UnitHertz
,
UnitTeraHertz
=
MetricPrefixTera
+
UnitHertz
,
UnitPetaHertz
=
MetricPrefixPeta
+
UnitHertz
,
// Time units.
UnitBootTimestamp
=
400
,
UnitSecond
,
UnitTime
,
// Misc units.
UnitCelsius
=
500
,
UnitDecibelMilliWatts
,
UnitPercent
,
UnitRate
,
UnitRpm
,
UnitVolt
,
UnitWatt
,
};
}
}
#include <ksysguard/formatter/Unit.h>
//Data that is static for the lifespan of the sensor
class
SensorInfo
...
...
@@ -101,7 +36,7 @@ public:
QString
shortName
;
QString
description
;
// translated
QVariant
::
Type
variantType
=
QVariant
::
Invalid
;
KSysGuard
::
utils
::
Unit
unit
=
KSysGuard
::
utils
::
UnitInvalid
;
//Both a format hint and implies data type (i.e double/string)
KSysGuard
::
Unit
unit
=
KSysGuard
::
UnitInvalid
;
//Both a format hint and implies data type (i.e double/string)
qreal
min
=
0
;
qreal
max
=
0
;
};
...
...
@@ -151,7 +86,7 @@ inline const QDBusArgument &operator>>(const QDBusArgument &argument, SensorInfo
argument
>>
t
;
s
.
variantType
=
static_cast
<
QVariant
::
Type
>
(
t
);
argument
>>
t
;
s
.
unit
=
static_cast
<
KSysGuard
::
utils
::
Unit
>
(
t
);
s
.
unit
=
static_cast
<
KSysGuard
::
Unit
>
(
t
);
argument
>>
s
.
min
;
argument
>>
s
.
max
;
argument
.
endStructure
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment