kpilot Library API Documentation

options.cc

00001 /* options.cc KPilot 00002 ** 00003 ** Copyright (C) 2000-2001 by Adriaan de Groot 00004 ** 00005 ** This is a file of odds and ends, with debugging functions and stuff. 00006 */ 00007 00008 /* 00009 ** This program is free software; you can redistribute it and/or modify 00010 ** it under the terms of the GNU Lesser General Public License as published by 00011 ** the Free Software Foundation; either version 2.1 of the License, or 00012 ** (at your option) any later version. 00013 ** 00014 ** This program is distributed in the hope that it will be useful, 00015 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 ** GNU Lesser General Public License for more details. 00018 ** 00019 ** You should have received a copy of the GNU Lesser General Public License 00020 ** along with this program in a file called COPYING; if not, write to 00021 ** the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 00022 ** MA 02111-1307, USA. 00023 */ 00024 00025 /* 00026 ** Bug reports and questions can be sent to kde-pim@kde.org 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 // The daemon also has a debug level; debug_spaces is 60 spaces, 00056 // to align FUNCTIONSETUP output. 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; // unimplemented 00124 t.tm_yday = 0; // unimplemented 00125 t.tm_isdst = 0; // unimplemented 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; // unimplemented 00144 t.tm_yday = 0; // unimplemented 00145 t.tm_isdst = 0; // unimplemented 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
KDE Logo
This file is part of the documentation for kpilot Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jul 28 23:57:49 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003