options.cc
00001
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 static const char *options_id =
00031 "$Id: options.cc,v 1.17 2003/10/01 10:24:05 kainhofe Exp $";
00032
00033 #include "options.h"
00034
00035
00036 #include <iostream>
00037
00038 #if TIME_WITH_SYS_TIME
00039 # include <sys/time.h>
00040 # include <time.h>
00041 #else
00042 # if HAVE_SYS_TIME_H
00043 # include <sys/time.h>
00044 # else
00045 # include <time.h>
00046 # endif
00047 #endif
00048
00049 #include <qsize.h>
00050
00051 #include <kconfig.h>
00052 #include <kdebug.h>
00053 #include <kcmdlineargs.h>
00054
00055
00056
00057
00058
00059 #ifdef DEBUG
00060 int debug_level = 1;
00061 #else
00062 int debug_level = 0;
00063 #endif
00064 const char *debug_spaces =
00065 " ";
00066
00067 QString rtExpand(const QString &s, bool richText)
00068 {
00069 if (richText)
00070 {
00071 QString t(s);
00072 return t.replace(CSL1("\n"), CSL1("<br>\n"));
00073 }
00074 else
00075 return s;
00076 }
00077
00078 QString qstringExpansion(const QString & s)
00079 {
00080 QString t;
00081
00082 for (unsigned i = 0; i < s.length(); i++)
00083 {
00084 t += s[i];
00085 t += ' ';
00086 t += QString::number((int) s[i].unicode());
00087 t += ' ';
00088 }
00089
00090 return t;
00091 }
00092
00093 QString charExpansion(const char *s)
00094 {
00095 QString t;
00096
00097 while (*s)
00098 {
00099 t += QChar(*s);
00100 t += ' ';
00101 t += QString::number(*s);
00102 t += ' ';
00103 s++;
00104 }
00105
00106 return t;
00107 }
00108
00109 QDateTime readTm(const struct tm &t)
00110 {
00111 QDateTime dt;
00112 dt.setDate(QDate(1900 + t.tm_year, t.tm_mon + 1, t.tm_mday));
00113 dt.setTime(QTime(t.tm_hour, t.tm_min, t.tm_sec));
00114 return dt;
00115 }
00116
00117
00118
00119 struct tm writeTm(const QDateTime &dt)
00120 {
00121 struct tm t;
00122
00123 t.tm_wday = 0;
00124 t.tm_yday = 0;
00125 t.tm_isdst = 0;
00126
00127 t.tm_year = dt.date().year() - 1900;
00128 t.tm_mon = dt.date().month() - 1;
00129 t.tm_mday = dt.date().day();
00130 t.tm_hour = dt.time().hour();
00131 t.tm_min = dt.time().minute();
00132 t.tm_sec = dt.time().second();
00133
00134 return t;
00135 }
00136
00137
00138
00139 struct tm writeTm(const QDate &dt)
00140 {
00141 struct tm t;
00142
00143 t.tm_wday = 0;
00144 t.tm_yday = 0;
00145 t.tm_isdst = 0;
00146
00147 t.tm_year = dt.year() - 1900;
00148 t.tm_mon = dt.month() - 1;
00149 t.tm_mday = dt.day();
00150 t.tm_hour = 0;
00151 t.tm_min = 0;
00152 t.tm_sec = 0;
00153
00154 return t;
00155 }
00156
00157 int const fname = ((int) options_id);
00158
00159
This file is part of the documentation for kpilot Library Version 3.2.2.