kpilot/lib

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 ** Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
00007 **
00008 ** This file defines some global constants and macros for KPilot.
00009 ** In particular, KDE2 is defined when KDE2 seems to be the environment
00010 ** (is there a better way to do this?). Use of KDE2 to #ifdef sections
00011 ** of code is deprecated though.
00012 **
00013 ** Many debug functions are defined as well.
00014 */
00015 
00016 /*
00017 ** This program is free software; you can redistribute it and/or modify
00018 ** it under the terms of the GNU Lesser General Public License as published by
00019 ** the Free Software Foundation; either version 2.1 of the License, or
00020 ** (at your option) any later version.
00021 **
00022 ** This program is distributed in the hope that it will be useful,
00023 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00024 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00025 ** GNU Lesser General Public License for more details.
00026 **
00027 ** You should have received a copy of the GNU Lesser General Public License
00028 ** along with this program in a file called COPYING; if not, write to
00029 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00030 ** MA 02110-1301, USA.
00031 */
00032 
00033 /*
00034 ** Bug reports and questions can be sent to kde-pim@kde.org
00035 */
00036 
00037 // the hex edit widget is in cvs now, so we can enable it globally.
00038 // I still leave this flag here so one can always easily disable
00039 // the generic DB viewer, which uses the widget.
00040 #define USE_KHEXEDIT
00041 
00042 // Want to be as careful as possible about casting QStrings back and
00043 // forth, because of the potential for putting UTF-8 encoded data on the HH.
00044 // KHexEdit headers are not safe, though, so don't use this in general.
00045 #ifndef QT_NO_ASCII_CAST
00046 // #define QT_NO_ASCII_CAST     (1)
00047 #endif
00048 #ifndef QT_NO_CAST_ASCII
00049 // #define QT_NO_CAST_ASCII     (1)
00050 #endif
00051 
00052 
00053 // Switch _on_ debugging if it's not off.
00054 //
00055 #undef NDEBUG
00056 
00057 // Switch on debugging explicitly. Perhaps send debug to stderr instead
00058 // of to the KDE debugging facility (it does lose some niftiness then), but
00059 // it seems to be required with FC6 and others possibly.
00060 //
00061 #ifndef DEBUG
00062 #define DEBUG           (1)
00063 #endif
00064 #define DEBUG_CERR      (1)
00065 
00066 #ifdef HAVE_CONFIG_H
00067 #include "config.h"
00068 #endif
00069 
00070 #include <unistd.h>     /* For size_t for pilot-link */
00071 #include <qglobal.h>
00072 
00073 #if (QT_VERSION < 0x030300)
00074 #error "This is KPilot for KDE3.5 and won't compile with Qt < 3.3.0"
00075 #endif
00076 
00077 #ifndef KDE_VERSION
00078 #include <kdeversion.h>
00079 #endif
00080 
00081 #if !(KDE_IS_VERSION(3,4,0))
00082 #error "This is KPilot for (really) KDE 3.5 and won't compile with KDE < 3.4.0"
00083 #endif
00084 
00085 #if !(KDE_IS_VERSION(3,5,0))
00086 #warning "This is KPilot for KDE 3.5 and might not compile with KDE < 3.5.0"
00087 #endif
00088 
00089 #include "pilotLinkVersion.h"
00090 
00091 // For QString, and everything else needs it anyway.
00092 #include <qstring.h>
00093 // Dunno, really. Probably because everything needs it.
00094 #include <klocale.h>
00095 // For the debug stuff.
00096 #ifdef DEBUG
00097 #undef NDEBUG
00098 #undef NO_DEBUG
00099 #endif
00100 #include <kdebug.h>
00101 
00102 
00103 
00104 extern KDE_EXPORT int debug_level;
00105 
00106 #ifdef DEBUG
00107 #ifdef __GNUC__
00108 #define KPILOT_FNAMEDEF(l)  KPilotDepthCount fname(DEBUGAREA,l,__FUNCTION__)
00109 #else
00110 #define KPILOT_FNAMEDEF(l)  KPilotDepthCount fname(DEBUGAREA,l,__FILE__ ":" "__LINE__")
00111 #endif
00112 
00113 #define FUNCTIONSETUP       KPILOT_FNAMEDEF(1)
00114 #define FUNCTIONSETUPL(l)   KPILOT_FNAMEDEF(l)
00115 #define DEBUGAREA       0
00116 
00117 #define DEBUGAREA_KPILOT    5510
00118 #define DEBUGAREA_LIBRARY   5511
00119 #define DEBUGAREA_CONDUIT   5512
00120 #define DEBUGAREA_DB        5513
00121 
00122 #ifdef DEBUG_CERR
00123 #include <iostream>
00124 #endif
00125 
00126 class KDE_EXPORT KPilotDepthCount
00127 {
00128 public:
00129     KPilotDepthCount(int area, int level, const char *s);
00130     ~KPilotDepthCount();
00131     QString indent() const;
00132     const char *name() const { return fName; } ;
00133     // if DEBUG_CERR is defined, we can't return std::cerr (by value),
00134     // since the copy constructor is private!
00135 #ifndef DEBUG_CERR
00136     inline kdbgstream debug(int area=0)
00137     { return kdDebug(debug_level >= fLevel, area); }
00138 #endif
00139 
00140 protected:
00141     static int depth;
00142     int fDepth;
00143     int fLevel;
00144     const char *fName;
00145 } ;
00146 
00147 // stderr / iostream-based debugging.
00148 //
00149 //
00150 #ifdef DEBUG_CERR
00151 #include <iostream>
00152 #define DEBUGKPILOT std::cerr
00153 #define DEBUGLIBRARY    std::cerr
00154 #define DEBUGCONDUIT    std::cerr
00155 #define DEBUGDB     std::cerr
00156 using namespace std;
00157 
00158 inline std::ostream& operator <<(std::ostream &o, const QString &s)
00159     { if (s.isEmpty()) return o<<"<empty>"; else return o<<s.latin1(); }
00160 inline std::ostream& operator <<(std::ostream &o, const QCString &s)
00161     { if (s.isEmpty()) return o<<"<empty>"; else return o << *s; }
00162 
00163 
00164 
00165 inline std::ostream& operator <<(std::ostream &o, const KPilotDepthCount &d)
00166     { return o << d.indent() << ' ' << d.name(); }
00167 
00168 #else
00169 
00170 // kddebug based debugging
00171 //
00172 //
00173 #define DEBUGKPILOT fname.debug(DEBUGAREA_KPILOT)
00174 #define DEBUGLIBRARY    fname.debug(DEBUGAREA_LIBRARY)
00175 #define DEBUGCONDUIT    fname.debug(DEBUGAREA_CONDUIT)
00176 #define DEBUGDB         fname.debug(DEBUGAREA_DB)
00177 
00178 inline kdbgstream& operator <<(kdbgstream o, const KPilotDepthCount &d)
00179     { return o << d.indent() ; }
00180 
00181 #endif
00182 
00183 
00184 // no debugging at all
00185 //
00186 #else
00187 #define DEBUGSTREAM kndbgstream
00188 #define DEBUGKPILOT kndDebug()
00189 #define DEBUGLIBRARY    kndDebug()
00190 #define DEBUGCONDUIT    kndDebug()
00191 #define DEBUGDB         kndDebug()
00192 
00193 // With debugging turned off, FUNCTIONSETUP doesn't do anything.
00194 //
00195 //
00196 #define FUNCTIONSETUP const int fname = 0; Q_UNUSED(fname);
00197 #define FUNCTIONSETUPL(a) const int fname = a; Q_UNUSED(fname);
00198 #endif
00199 
00200 #define KPILOT_VERSION  "4.9.0 (depth9)"
00201 
00202 
00203 // Function to expand newlines in rich text to <br>\n
00204 QString rtExpand(const QString &s, bool richText=true);
00205 
00206 
00207 
00211 KDE_EXPORT QDateTime readTm(const struct tm &t);
00215 KDE_EXPORT struct tm writeTm(const QDateTime &dt);
00216 KDE_EXPORT struct tm writeTm(const QDate &dt);
00217 
00218 
00219 // Some layout macros
00220 //
00221 // SPACING is a generic distance between visual elements;
00222 // 10 seems reasonably good even at high resolutions.
00223 //
00224 //
00225 #define SPACING     (10)
00226 
00227 // Semi-Standard safe-free expression. Argument a may be evaluated more
00228 // than once though, so be careful.
00229 //
00230 //
00231 #define KPILOT_FREE(a)  { if (a) { ::free(a); a=0L; } }
00232 #define KPILOT_DELETE(a) { if (a) { delete a; a=0L; } }
00233 
00234 
00235 // This marks strings that need to be i18n()ed in future,
00236 // but cannot be done now due to message freeze. The _P
00237 // variant is to handle plurals and is wrong, but unavoidable.
00238 //
00239 //
00240 #define TODO_I18N(a)    QString::fromLatin1(a)
00241 #define TODO_I18N_P(a,b,c) ((c>1) ? a : b)
00242 
00243 // Handle some cases for QT_NO_CAST_ASCII and NO_ASCII_CAST.
00244 // Where possible in the source, known constant strings in
00245 // latin1 encoding are marked with CSL1(), to avoid gobs
00246 // of latin1() or fromlatin1() calls which might obscure
00247 // those places where the code really is translating
00248 // user data from latin1.
00249 //
00250 // The extra "" in CSL1 is to enforce that it's only called
00251 // with constant strings.
00252 //
00253 //
00254 #define CSL1(a)     QString::fromLatin1(a "")
00255 
00256 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys