options.h
00001 #ifndef _KPILOT_OPTIONS_H 00002 #define _KPILOT_OPTIONS_H 00003 /* options.h KPilot 00004 ** 00005 ** Copyright (C) 1998-2001,2002,2003 by Dan Pilone 00006 ** 00007 ** This file defines some global constants and macros for KPilot. 00008 ** In particular, KDE2 is defined when KDE2 seems to be the environment 00009 ** (is there a better way to do this?). Use of KDE2 to #ifdef sections 00010 ** of code is deprecated though. 00011 ** 00012 ** Many debug functions are defined as well. 00013 */ 00014 00015 /* 00016 ** This program is free software; you can redistribute it and/or modify 00017 ** it under the terms of the GNU Lesser General Public License as published by 00018 ** the Free Software Foundation; either version 2.1 of the License, or 00019 ** (at your option) any later version. 00020 ** 00021 ** This program is distributed in the hope that it will be useful, 00022 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00023 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00024 ** GNU Lesser General Public License for more details. 00025 ** 00026 ** You should have received a copy of the GNU Lesser General Public License 00027 ** along with this program in a file called COPYING; if not, write to 00028 ** the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 00029 ** MA 02111-1307, USA. 00030 */ 00031 00032 /* 00033 ** Bug reports and questions can be sent to kde-pim@kde.org 00034 */ 00035 00036 // the hex edit widget is in cvs now, so we can enable it globally. 00037 // I still leave this flag here so one can always easily disable 00038 // the generic DB viewer, which uses the widget. 00039 #define USE_KHEXEDIT 00040 00041 // #define QT_NO_ASCII_CAST (1) 00042 // #define QT_NO_CAST_ASCII (1) 00043 00044 00045 #ifdef HAVE_CONFIG_H 00046 #include "config.h" 00047 #endif 00048 00049 #ifndef QT_VERSION 00050 #include <qglobal.h> 00051 #endif 00052 00053 #if (QT_VERSION < 223) 00054 #error "This is KPilot for KDE2 and won't compile with Qt < 2.2.3" 00055 #endif 00056 00057 #ifndef KDE_VERSION 00058 #include <kdeversion.h> 00059 #endif 00060 00061 #if KDE_VERSION > 289 00062 #define KDE3 00063 #undef KDE2 00064 #else 00065 #undef KDE3 00066 #define KDE2 00067 #endif 00068 00069 // Turn ON as much debugging as possible with -DDEBUG -DDEBUG_CERR 00070 // Some systems have changed kdWarning() and kdDebug() into nops, 00071 // so DEBUG_CERR changes them into cerr again. Odd and disturbing. 00072 // 00073 00074 00075 #ifdef DEBUG_CERR 00076 #define DEBUGFUNC cerr 00077 #else 00078 #define DEBUGFUNC kdDebug() 00079 #endif 00080 00081 // For ostream 00082 #include <iostream> 00083 // For QString, and everything else needs it anyway. 00084 #include <qstring.h> 00085 // Dunno, really. Probably because everything needs it. 00086 #include <klocale.h> 00087 // For the debug stuff. 00088 #include <kdebug.h> 00089 00090 using namespace std; 00091 00092 // KPilot will move towards the *standard* way of doing 00093 // debug messages soon. This means that we need some 00094 // debug areas. 00095 // 00096 // 00097 #define KPILOT_AREA 5510 00098 #define DAEMON_AREA 5511 00099 #define CONDUIT_AREA 5512 00100 #define LIBPILOTDB_AREA 5513 00101 00102 #ifdef DEBUG_CERR 00103 #define DEBUGSTREAM ostream 00104 #define DEBUGKPILOT cerr 00105 #define DEBUGDAEMON cerr 00106 #define DEBUGCONDUIT cerr 00107 #define DEBUGDB cerr 00108 #else 00109 #define DEBUGSTREAM kdbgstream 00110 #define DEBUGKPILOT kdDebug(KPILOT_AREA) 00111 #define DEBUGDAEMON kdDebug(DAEMON_AREA) 00112 #define DEBUGCONDUIT kdDebug(CONDUIT_AREA) 00113 #define DEBUGDB kdDebug(LIBPILOTDB_AREA) 00114 #endif 00115 00116 #define KPILOT_VERSION "4.4.1" 00117 00118 // * KPilot debugging code looks like: 00119 // 00120 // DEBUGKPILOT << fname << ": Creating dialog window." << endl; 00121 // 00122 // This uses KDE's debug areas (accessible through kdebugdialog) 00123 // to keep track of what to print. No extra #if or if(), since the 00124 // global NDEBUG flag changes all the kdDebug() calls into nops and 00125 // the compiler optimizes them away. There are four DEBUG* macros, 00126 // defined above. Use the areas *_AREA in calls to kdWarning() or 00127 // kdError() to make sure the right output is generated. 00128 00129 00130 extern int debug_level; 00131 extern const char *debug_spaces; 00132 00133 // Function to expand newlins in rich text to <br>\n 00134 QString rtExpand(const QString &s, bool richText=true); 00135 00136 00137 #ifdef DEBUG 00138 // Both old and new-style debugging suggest (insist?) that 00139 // every function be started with the macro FUNCTIONSETUP, 00140 // which outputs function and line information on every call. 00141 // 00142 // 00143 #ifdef __GNUC__ 00144 #define KPILOT_FNAMEDEF static const char *fname=__FUNCTION__ 00145 #define KPILOT_LOCNDEF debug_spaces+(::strlen(fname)) \ 00146 << "(" << __FILE__ << ":" << \ 00147 __LINE__ << ")\n" 00148 #else 00149 #define KPILOT_FNAMEDEF static const char *fname=__FILE__ ":" "__LINE__" 00150 #define KPILOT_LOCNDEF "\n" 00151 #endif 00152 00153 #define FUNCTIONSETUP KPILOT_FNAMEDEF; \ 00154 if (debug_level) { DEBUGFUNC << \ 00155 fname << KPILOT_LOCNDEF ; } 00156 #define FUNCTIONSETUPL(l) KPILOT_FNAMEDEF; \ 00157 if (debug_level>l) { DEBUGFUNC << \ 00158 fname << KPILOT_LOCNDEF; } 00159 00160 class KConfig; 00161 00162 // Next all kinds of specialty debugging functions, 00163 // added in an ad-hoc fashion. 00164 // 00165 // 00166 QString qstringExpansion(const QString &); 00167 QString charExpansion(const char *); 00168 00169 #else 00170 // With debugging turned off, FUNCTIONSETUP doesn't do anything. 00171 // In particular it doesn't give functions a local variable fname, 00172 // like FUNCTIONSETUP does in the debugging case. Since code like 00173 // 00174 // DEBUGKPILOT << fname << ": Help! I'm descructing" << endl; 00175 // 00176 // is still visible in KPilot (it isn't all bracketed by #ifdef DEBUG 00177 // and it doesn't *need* to be, that's the whole point of kdDebug()) 00178 // we still need *something* with the name fname. So we'll declare a 00179 // single extern fname here. 00180 // 00181 // fname gets a weird type that is 00182 // incompatible with kdWarning() and kdError(), leading to warnings 00183 // if you mix them. Use k_funcinfo instead. 00184 // 00185 // 00186 #define FUNCTIONSETUP 00187 #define FUNCTIONSETUPL(a) 00188 #endif 00189 00190 class KConfig; 00191 00192 // Next all kinds of specialty debugging functions, 00193 // added in an ad-hoc fashion. 00194 // 00195 // 00196 QString qstringExpansion(const QString &); 00197 QString charExpansion(const char *); 00198 00199 inline ostream& operator <<(ostream &o,const QString &s) { if (s.isEmpty()) return o; else return o<<s.latin1(); } 00200 inline ostream& operator <<(ostream &o,const QCString &s) { return (o << *s ); } 00201 00205 QDateTime readTm(const struct tm &t); 00209 struct tm writeTm(const QDateTime &dt); 00210 struct tm writeTm(const QDate &dt); 00211 00212 00213 // Some layout macros 00214 // 00215 // SPACING is a generic distance between visual elements; 00216 // 10 seems reasonably good even at high resolutions. 00217 // 00218 // 00219 #define SPACING (10) 00220 00221 // Semi-Standard safe-free expression. Argument a may be evaluated more 00222 // than once though, so be careful. 00223 // 00224 // 00225 #define KPILOT_FREE(a) { if (a) { ::free(a); a=0L; } } 00226 #define KPILOT_DELETE(a) { if (a) { delete a; a=0L; } } 00227 00228 00229 // This marks strings that need to be i18n()ed in future, 00230 // but cannot be done now due to message freeze. 00231 // 00232 // 00233 #define TODO_I18N(a) QString::fromLatin1(a) 00234 00235 // Handle some cases for QT_NO_CAST_ASCII and NO_ASCII_CAST. 00236 // Where possible in the source, known constant strings in 00237 // latin1 encoding are marked with CSL1(), to avoid gobs 00238 // of latin1() or fromlatin1() calls which might obscure 00239 // those places where the code really is translating 00240 // user data from latin1. 00241 // 00242 // The extra "" in CSL1 is to enforce that it's only called 00243 // with constant strings. 00244 // 00245 // 00246 #define CSL1(a) QString::fromLatin1(a "") 00247 00248 #endif