kpilot/lib
options.cc00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include "options.h"
00032
00033
00034 #include <iostream>
00035
00036 #include <qsize.h>
00037
00038 #include <kconfig.h>
00039 #include <kdebug.h>
00040 #include <kcmdlineargs.h>
00041
00042 #ifdef DEBUG
00043 int debug_level = 1;
00044 #else
00045 int debug_level = 0;
00046 #endif
00047
00048
00049
00050
00051
00052 const char *debug_spaces =
00053 " ";
00054
00055
00056 QString rtExpand(const QString &s, bool richText)
00057 {
00058 if (richText)
00059 {
00060 QString t(s);
00061 return t.replace(CSL1("\n"), CSL1("<br>\n"));
00062 }
00063 else
00064 return s;
00065
00066 }
00067
00068 QDateTime readTm(const struct tm &t)
00069 {
00070 QDateTime dt;
00071 dt.setDate(QDate(1900 + t.tm_year, t.tm_mon + 1, t.tm_mday));
00072 dt.setTime(QTime(t.tm_hour, t.tm_min, t.tm_sec));
00073 return dt;
00074 }
00075
00076
00077
00078 struct tm writeTm(const QDateTime &dt)
00079 {
00080 struct tm t;
00081
00082 t.tm_wday = 0;
00083 t.tm_yday = 0;
00084 t.tm_isdst = 0;
00085 #ifdef HAVE_STRUCT_TM_TM_ZONE
00086 t.tm_zone = 0;
00087 #endif
00088
00089 t.tm_year = dt.date().year() - 1900;
00090 t.tm_mon = dt.date().month() - 1;
00091 t.tm_mday = dt.date().day();
00092 t.tm_hour = dt.time().hour();
00093 t.tm_min = dt.time().minute();
00094 t.tm_sec = dt.time().second();
00095
00096 return t;
00097 }
00098
00099
00100
00101 struct tm writeTm(const QDate &d)
00102 {
00103 QDateTime dt(d);
00104 return writeTm(dt);
00105 }
00106
00107 KPilotDepthCount::KPilotDepthCount(int area, int level, const char *s) :
00108 fDepth(depth),
00109 fLevel(level),
00110 fName(s)
00111 {
00112 if (debug_level>=fLevel)
00113 {
00114 #ifdef DEBUG_CERR
00115 Q_UNUSED(area);
00116 DEBUGLIBRARY
00117 #else
00118 debug(area)
00119 #endif
00120 << indent() << ">" << name() << endl;
00121 }
00122 depth++;
00123 }
00124
00125 KPilotDepthCount::~KPilotDepthCount()
00126 {
00127 depth--;
00128 }
00129
00130 QString KPilotDepthCount::indent() const
00131 {
00132 QString s;
00133 s.fill(' ',fDepth);
00134 return s+s+' ';
00135 }
00136
00137 int KPilotDepthCount::depth = 0;
00138
|