Sayonara Player
Namespaces | Classes | Typedefs | Enumerations | Functions
Util Namespace Reference

Helper functions. More...

Namespaces

 File
 FileUtils functions.
 
 Language
 language namespace
 

Classes

class  Tree
 The Tree class. More...
 
class  Filepath
 
class  Image
 The Image class. More...
 
class  Set
 A set structure. Inherited from std::set with some useful methods. For integer and String this set is ordered. More...
 

Typedefs

using Extensions = uint16_t
 

Enumerations

enum  SaveAsAnswer {
  Success ,
  InvalidName ,
  NotStorable ,
  NameAlreadyThere ,
  InvalidObject ,
  OtherError
}
 
enum  Extension {
  Soundfile =1<<0 ,
  Playlist =1<<1 ,
  Podcast =1<<2 ,
  Images =1<<3
}
 

Functions

template<typename TINT , typename T >
std::enable_if< std::is_pointer< T >::value, bool >::type between (TINT idx, const T &cont)
 
template<typename TINT , typename T >
std::enable_if< std::is_class< T >::value, bool >::type between (TINT idx, const T &cont)
 
template<typename TINT >
std::enable_if< std::is_integral< TINT >::value, bool >::type between (TINT idx, TINT max)
 
QString xdgConfigPath (const QString &appendPath=QString())
 
QString xdgSharePath (const QString &appendPath=QString())
 
QString xdgCachePath (const QString &appendPath=QString())
 
QString sharePath (const QString &appendPath=QString())
 
QString tempPath (const QString &appendPath=QString())
 
QString similarArtistsPath ()
 
QString translationsPath ()
 
QString translationsSharePath ()
 
QString coverDirectory (const QString &appendFilename=QString())
 
QString coverTempDirectory (const QString &appendFilename=QString())
 
QString lyricsPath (const QString &appendFilename=QString())
 
QString legacySayonaraPath (const QString &appendFilename=QString())
 
void copyFromLegacyLocations ()
 
uint64_t currentDateToInt ()
 
uint64_t dateToInt (const QDateTime &dateTime)
 
QDateTime intToDate (uint64_t date)
 
QString stringToFirstUpper (const QString &str)
 Transform all letters after a space to upper case. More...
 
QString stringToVeryFirstUpper (const QString &str)
 Transform only first letter to upper case. More...
 
QString msToString (MilliSeconds msec, const QString &format)
 Convert milliseconds to string. More...
 
QString convertNotNull (const QString &str)
 
QString createLink (const QString &name, bool dark=true, bool underline=true)
 create a link string More...
 
QString createLink (const QString &name, bool dark, bool underline, const QString &target)
 
QString createLink (const QString &name, const QColor &color, bool underline, const QString &target)
 
QStringList soundfileExtensions (bool withAsterisk=true)
 get all supported sound file extensions More...
 
QString soundfileFilter ()
 get filter for file reader or file chooser More...
 
QStringList playlistExtensions (bool withAsterisk=true)
 get all supported playlist file extensions More...
 
QStringList podcastExtensions (bool withAsterisk=true)
 get all supported podcast file extensions More...
 
QStringList imageExtensions (bool withAsterisk=true)
 
QString getFileFilter (Extensions extensions, const QString &name)
 get filter for file chooser dialog based on extensions More...
 
int randomNumber (int min, int max)
 get a random val between min max More...
 
QString randomString (int max_chars)
 
QString easyTagFinder (const QString &tag, const QString &xmlDocument)
 gets value out of tag More...
 
QByteArray calcHash (const QByteArray &data)
 calculate a md5 hashsum More...
 
void sleepMs (uint64_t ms)
 sleep More...
 
QStringList ipAddresses ()
 get all ip addresses of the host More...
 
QByteArray convertPixmapToByteArray (const QPixmap &pm)
 
QByteArray convertPixmapToByteArray (const QPixmap &pm, const char *format)
 
QPixmap convertByteArrayToPixmap (const QByteArray &arr)
 
void setEnvironment (const QString &key, const QString &value)
 set an environment variable. This function is platform independent More...
 
void unsetEnvironment (const QString &key)
 
QString getEnvironment (const char *key)
 

Detailed Description

Helper functions.

Function Documentation

◆ calcHash()

QByteArray Util::calcHash ( const QByteArray &  data)

calculate a md5 hashsum

Parameters
datainput data
Returns
hashsum

◆ createLink()

QString Util::createLink ( const QString &  name,
bool  dark = true,
bool  underline = true 
)

create a link string

Parameters
nameappearing name in link
targettarget url (if not given, name is taken)
underlineif link should be underlined
Returns
link string

◆ easyTagFinder()

QString Util::easyTagFinder ( const QString &  tag,
const QString &  xmlDocument 
)

gets value out of tag

Parameters
tagform: grandparent.parent.child
xmlDocumentcontent of the xml document
Returns
extracted string

◆ getFileFilter()

QString Util::getFileFilter ( Extensions  extensions,
const QString &  name 
)

get filter for file chooser dialog based on extensions

Parameters
extensionsdisjunction of Extension
namename that should appear in the file dialog
Returns
concatenated list of extensions

◆ ipAddresses()

QStringList Util::ipAddresses ( )

get all ip addresses of the host

Returns
list of ip addresses

◆ msToString()

QString Util::msToString ( MilliSeconds  msec,
const QString &  format 
)

Convert milliseconds to string.

Parameters
msecmilliseconds
format$Dfor days, $H for hours, $M for minutes $S for secods, A little 'e' behind the number will result in the unit displayed after the string
Returns
converted milliseconds

◆ playlistExtensions()

QStringList Util::playlistExtensions ( bool  withAsterisk = true)

get all supported playlist file extensions

Returns

◆ podcastExtensions()

QStringList Util::podcastExtensions ( bool  withAsterisk = true)

get all supported podcast file extensions

Returns

◆ randomNumber()

int Util::randomNumber ( int  min,
int  max 
)

get a random val between min max

Parameters
minminimum included value
maxmaximum included value
Returns
random number

◆ setEnvironment()

void Util::setEnvironment ( const QString &  key,
const QString &  value 
)

set an environment variable. This function is platform independent

Parameters
keyvariable name
valuevariable value

◆ sleepMs()

void Util::sleepMs ( uint64_t  ms)

sleep

Parameters
msmilliseconds to sleep

◆ soundfileExtensions()

QStringList Util::soundfileExtensions ( bool  withAsterisk = true)

get all supported sound file extensions

Returns

◆ soundfileFilter()

QString Util::soundfileFilter ( )

get filter for file reader or file chooser

Returns

◆ stringToFirstUpper()

QString Util::stringToFirstUpper ( const QString &  str)

Transform all letters after a space to upper case.

Parameters
strinput string
Returns
result string

◆ stringToVeryFirstUpper()

QString Util::stringToVeryFirstUpper ( const QString &  str)

Transform only first letter to upper case.

Parameters
strinput string
Returns
result string