kpilot/lib

options.cc

00001 /* KPilot
00002 **
00003 ** Copyright (C) 2000-2001 by Adriaan de Groot
00004 ** Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
00005 **
00006 ** This is a file of odds and ends, with debugging functions and stuff.
00007 */
00008 
00009 /*
00010 ** This program is free software; you can redistribute it and/or modify
00011 ** it under the terms of the GNU Lesser General Public License as published by
00012 ** the Free Software Foundation; either version 2.1 of the License, or
00013 ** (at your option) any later version.
00014 **
00015 ** This program is distributed in the hope that it will be useful,
00016 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00018 ** GNU Lesser General Public License for more details.
00019 **
00020 ** You should have received a copy of the GNU Lesser General Public License
00021 ** along with this program in a file called COPYING; if not, write to
00022 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00023 ** MA 02110-1301, USA.
00024 */
00025 
00026 /*
00027 ** Bug reports and questions can be sent to kde-pim@kde.org
00028 */
00029 
00030 
00031 static const char *options_id =
00032     "$Id: options.cc 449050 2005-08-14 05:03:22Z vanrijn $";
00033 
00034 #include "options.h"
00035 
00036 
00037 #include <iostream>
00038 
00039 #if TIME_WITH_SYS_TIME
00040 # include <sys/time.h>
00041 # include <time.h>
00042 #else
00043 # if HAVE_SYS_TIME_H
00044 #  include <sys/time.h>
00045 # else
00046 #  include <time.h>
00047 # endif
00048 #endif
00049 
00050 #include <qsize.h>
00051 
00052 #include <kconfig.h>
00053 #include <kdebug.h>
00054 #include <kcmdlineargs.h>
00055 
00056 // The daemon also has a debug level; debug_spaces is 60 spaces,
00057 // to align FUNCTIONSETUP output.
00058 //
00059 //
00060 int debug_level = 0;
00061 const char *debug_spaces =
00062     "                                                    ";
00063 QString rtExpand(const QString &s, bool richText)
00064 {
00065     if (richText)
00066     {
00067         QString t(s);
00068         return t.replace(CSL1("\n"), CSL1("<br>\n"));
00069     }
00070     else
00071         return s;
00072 
00073     Q_UNUSED(options_id);
00074 }
00075 
00076 QDateTime readTm(const struct tm &t)
00077 {
00078   QDateTime dt;
00079   dt.setDate(QDate(1900 + t.tm_year, t.tm_mon + 1, t.tm_mday));
00080   dt.setTime(QTime(t.tm_hour, t.tm_min, t.tm_sec));
00081   return dt;
00082 }
00083 
00084 
00085 
00086 struct tm writeTm(const QDateTime &dt)
00087 {
00088   struct tm t;
00089 
00090   t.tm_wday = 0; // unimplemented
00091   t.tm_yday = 0; // unimplemented
00092   t.tm_isdst = 0; // unimplemented
00093   t.tm_zone = 0; // unimplemented
00094 
00095   t.tm_year = dt.date().year() - 1900;
00096   t.tm_mon = dt.date().month() - 1;
00097   t.tm_mday = dt.date().day();
00098   t.tm_hour = dt.time().hour();
00099   t.tm_min = dt.time().minute();
00100   t.tm_sec = dt.time().second();
00101 
00102   return t;
00103 }
00104 
00105 
00106 
00107 struct tm writeTm(const QDate &dt)
00108 {
00109   struct tm t;
00110 
00111   t.tm_wday = 0; // unimplemented
00112   t.tm_yday = 0; // unimplemented
00113   t.tm_isdst = 0; // unimplemented
00114 
00115   t.tm_year = dt.year() - 1900;
00116   t.tm_mon = dt.month() - 1;
00117   t.tm_mday = dt.day();
00118   t.tm_hour = 0;
00119   t.tm_min = 0;
00120   t.tm_sec = 0;
00121 
00122   return t;
00123 }
00124 
00125 #ifdef DEBUG
00126 KPilotDepthCount::KPilotDepthCount(int area, int level, const char *s) :
00127     fDepth(depth),
00128     fLevel(level),
00129     fName(s)
00130 {
00131     if (debug_level>=fLevel)
00132     {
00133 #ifdef DEBUG_CERR
00134         DEBUGKPILOT
00135 #else
00136         debug(area)
00137 #endif
00138         << indent() << ">" << name() << endl;
00139     }
00140     depth++;
00141 }
00142 
00143 KPilotDepthCount::~KPilotDepthCount()
00144 {
00145     depth--;
00146 }
00147 
00148 QString KPilotDepthCount::indent() const
00149 {
00150     QString s;
00151     s.fill(' ',fDepth);
00152     return s+s+' ';
00153 }
00154 
00155 int KPilotDepthCount::depth = 0;
00156 #endif
00157 
KDE Home | KDE Accessibility Home | Description of Access Keys