Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
jlib
Commits
0759f146
Commit
0759f146
authored
Apr 03, 2018
by
captainwong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add space & QtUtils
parent
6410185f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
0 deletions
+53
-0
signal_slot.h
QtUtils/signal_slot.h
+7
-0
space.h
space.h
+46
-0
No files found.
QtUtils/signal_slot.h
0 → 100644
View file @
0759f146
#pragma once
#include <QObject>
//#define DEFINE_SIGNAL(f) signals:void sig_##f; public void connect_to_sigslot_##f;
#define CONNECT_SIG_SLOT(f) connect(this, SIGNAL(sig_##f), obj, SLOT(slot_##f));
space.h
0 → 100644
View file @
0759f146
#pragma once
#include <string>
namespace
jlib
{
static
std
::
string
format_space
(
uintmax_t
bytes
)
{
static
constexpr
uintmax_t
FACTOR
=
1024
;
static
constexpr
uintmax_t
KB
=
FACTOR
;
static
constexpr
uintmax_t
MB
=
KB
*
FACTOR
;
static
constexpr
uintmax_t
GB
=
MB
*
FACTOR
;
static
constexpr
uintmax_t
TB
=
GB
*
FACTOR
;
uintmax_t
kb
=
bytes
/
FACTOR
;
uintmax_t
mb
=
kb
/
FACTOR
;
uintmax_t
gb
=
mb
/
FACTOR
;
uintmax_t
tb
=
gb
/
FACTOR
;
std
::
string
s
;
if
(
tb
>
0
)
{
gb
-=
tb
*
FACTOR
;
gb
=
gb
*
1000
/
FACTOR
;
gb
/=
10
;
return
std
::
to_string
(
tb
)
+
"."
+
std
::
to_string
(
gb
)
+
"T"
;
}
else
if
(
gb
>
0
)
{
mb
-=
gb
*
FACTOR
;
mb
=
mb
*
1000
/
FACTOR
;
mb
/=
10
;
return
std
::
to_string
(
gb
)
+
"."
+
std
::
to_string
(
mb
)
+
"G"
;
}
else
if
(
mb
>
0
)
{
kb
-=
mb
*
FACTOR
;
kb
=
kb
*
1000
/
FACTOR
;
kb
/=
10
;
return
std
::
to_string
(
mb
)
+
"."
+
std
::
to_string
(
kb
)
+
"M"
;
}
else
if
(
kb
>
0
)
{
bytes
-=
kb
*
FACTOR
;
bytes
=
bytes
*
1000
/
FACTOR
;
bytes
/=
10
;
return
std
::
to_string
(
kb
)
+
"."
+
std
::
to_string
(
bytes
)
+
"K"
;
}
else
{
return
std
::
to_string
(
bytes
)
+
"B"
;
}
}
}
Write
Preview
Markdown
is supported
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