00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef UTILS_H
00023 #define UTILS_H
00024
00025 #include "defines.h"
00026 #include <QPixmap>
00027 #include <QDateTime>
00028
00029 #define QS_C(x) x.toUtf8().data()
00030
00031 class QString;
00032
00033 QString timeref_to_hms(const TimeRef& ref);
00034 QString timeref_to_ms(const TimeRef& ref);
00035 QString timeref_to_ms_2 (const TimeRef& ref);
00036 QString timeref_to_ms_3 (const TimeRef& ref);
00037 QString timeref_to_text(const TimeRef& ref, int scalefactor);
00038 QString timeref_to_cd(const TimeRef& ref);
00039 QString timeref_to_cd_including_hours(const TimeRef& ref);
00040
00041 TimeRef msms_to_timeref(QString str);
00042 TimeRef cd_to_timeref(QString str);
00043 TimeRef cd_to_timeref_including_hours(QString str);
00044 QString coefficient_to_dbstring(float coeff);
00045 QDateTime extract_date_time(qint64 id);
00046
00047 qint64 create_id();
00048
00049 QStringList find_qm_files();
00050 QString language_name_from_qm_file(const QString& lang);
00051
00052
00053 static inline unsigned int is_power_of_two (unsigned int n)
00054 {
00055 return !(n & (n - 1));
00056 }
00057
00058 static inline int cnt_bits(unsigned long val, int & highbit)
00059 {
00060 int cnt = 0;
00061 highbit = 0;
00062 while (val) {
00063 if (val & 1) cnt++;
00064 val>>=1;
00065 highbit++;
00066 }
00067 return cnt;
00068 }
00069
00070
00071 static inline long nearest_power_of_two(unsigned long val, int& highbit)
00072 {
00073 if (cnt_bits(val, highbit) > 1) {
00074 return 1<<highbit;
00075 }
00076 return val;
00077 }
00078
00079 QPixmap find_pixmap(const QString& pixname);
00080
00081 #endif