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
00043
00044
00045
00046 #ifdef DEBUG
00047 int debug_level = 1;
00048 #else
00049 int debug_level = 0;
00050 #endif
00051 const char *debug_spaces =
00052 " ";
00053 QString rtExpand(const QString &s, bool richText)
00054 {
00055 if (richText)
00056 {
00057 QString t(s);
00058 return t.replace(CSL1("\n"), CSL1("<br>\n"));
00059 }
00060 else
00061 return s;
00062
00063 }
00064
00065 QDateTime readTm(const struct tm &t)
00066 {
00067 QDateTime dt;
00068 dt.setDate(QDate(1900 + t.tm_year, t.tm_mon + 1, t.tm_mday));
00069 dt.setTime(QTime(t.tm_hour, t.tm_min, t.tm_sec));
00070 return dt;
00071 }
00072
00073
00074
00075 struct tm writeTm(const QDateTime &dt)
00076 {
00077 struct tm t;
00078
00079 t.tm_wday = 0;
00080 t.tm_yday = 0;
00081 t.tm_isdst = 0;
00082 #ifdef HAVE_STRUCT_TM_TM_ZONE
00083 t.tm_zone = 0;
00084 #endif
00085
00086 t.tm_year = dt.date().year() - 1900;
00087 t.tm_mon = dt.date().month() - 1;
00088 t.tm_mday = dt.date().day();
00089 t.tm_hour = dt.time().hour();
00090 t.tm_min = dt.time().minute();
00091 t.tm_sec = dt.time().second();
00092
00093 return t;
00094 }
00095
00096
00097
00098 struct tm writeTm(const QDate &d)
00099 {
00100 QDateTime dt(d);
00101 return writeTm(dt);
00102 }
00103
00104 #ifdef DEBUG
00105 KPilotDepthCount::KPilotDepthCount(int area, int level, const char *s) :
00106 fDepth(depth),
00107 fLevel(level),
00108 fName(s)
00109 {
00110 if (debug_level>=fLevel)
00111 {
00112 #ifdef DEBUG_CERR
00113 Q_UNUSED(area);
00114 DEBUGLIBRARY
00115 #else
00116 debug(area)
00117 #endif
00118 << indent() << ">" << name() << endl;
00119 }
00120 depth++;
00121 }
00122
00123 KPilotDepthCount::~KPilotDepthCount()
00124 {
00125 depth--;
00126 }
00127
00128 QString KPilotDepthCount::indent() const
00129 {
00130 QString s;
00131 s.fill(' ',fDepth);
00132 return s+s+' ';
00133 }
00134
00135 int KPilotDepthCount::depth = 0;
00136 #endif
00137
|