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 #include "config.h"
00054 
00055 #include <unistd.h>     /* For size_t for pilot-link */
00056 #include <qglobal.h>
00057 
00058 #if (QT_VERSION < 0x030300)
00059 #error "This is KPilot for KDE3.5 and won't compile with Qt < 3.3.0"
00060 #endif
00061 
00062 #ifndef KDE_VERSION
00063 #include <kdeversion.h>
00064 #endif
00065 
00066 #if !(KDE_IS_VERSION(3,4,0))
00067 #error "This is KPilot for (really) KDE 3.5 and won't compile with KDE < 3.4.0"
00068 #endif
00069 
00070 #if !(KDE_IS_VERSION(3,5,0))
00071 #warning "This is KPilot for KDE 3.5 and might not compile with KDE < 3.5.0"
00072 #endif
00073 
00074 #include "pilotLinkVersion.h"
00075 
00076 // For QString, and everything else needs it anyway.
00077 #include <qstring.h>
00078 // Dunno, really. Probably because everything needs it.
00079 #include <klocale.h>
00080 // For the debug stuff.
00081 #ifdef DEBUG
00082 #undef NDEBUG
00083 #undef NO_DEBUG
00084 #ifndef DEBUG_CERR
00085 #define DEBUG_CERR
00086 #endif
00087 #endif
00088 #include <kdebug.h>
00089 
00090 extern KDE_EXPORT int debug_level;
00091 
00092 class KDE_EXPORT KPilotDepthCount
00093 {
00094 public:
00095     KPilotDepthCount(int area, int level, const char *s);
00096     ~KPilotDepthCount();
00097     QString indent() const;
00098     const char *name() const { return fName; } ;
00099     // if DEBUG_CERR is defined, we can't return std::cerr (by value),
00100     // since the copy constructor is private!
00101 #ifndef DEBUG_CERR
00102 #ifdef NDEBUG
00103     inline kndbgstream debug(int area=0)
00104 #else
00105     inline kdbgstream debug(int area=0)
00106 #endif
00107     { return kdDebug(debug_level >= fLevel, area); }
00108 #endif
00109 
00110 protected:
00111     static int depth;
00112     int fDepth;
00113     int fLevel;
00114     const char *fName;
00115 } ;
00116 
00117 
00118 #ifdef DEBUG
00119 #ifdef __GNUC__
00120 #define KPILOT_FNAMEDEF(l)  KPilotDepthCount fname(DEBUGAREA,l,__FUNCTION__)
00121 #else
00122 #define KPILOT_FNAMEDEF(l)  KPilotDepthCount fname(DEBUGAREA,l,__FILE__ ":" "__LINE__")
00123 #endif
00124 
00125 #define FUNCTIONSETUP       KPILOT_FNAMEDEF(1)
00126 #define FUNCTIONSETUPL(l)   KPILOT_FNAMEDEF(l)
00127 #define DEBUGAREA       0
00128 
00129 #define DEBUGAREA_KPILOT    5510
00130 #define DEBUGAREA_LIBRARY   5511
00131 #define DEBUGAREA_CONDUIT   5512
00132 #define DEBUGAREA_DB        5513
00133 
00134 #ifdef DEBUG_CERR
00135 #include <iostream>
00136 #endif
00137 
00138 // stderr / iostream-based debugging.
00139 //
00140 //
00141 #ifdef DEBUG_CERR
00142 #include <iostream>
00143 #define DEBUGKPILOT std::cerr
00144 #define DEBUGLIBRARY    std::cerr
00145 #define DEBUGCONDUIT    std::cerr
00146 #define DEBUGDB     std::cerr
00147 using namespace std;
00148 
00149 inline std::ostream& operator <<(std::ostream &o, const QString &s)
00150     { if (s.isEmpty()) return o<<"<empty>"; else return o<<s.latin1(); }
00151 inline std::ostream& operator <<(std::ostream &o, const QCString &s)
00152     { if (s.isEmpty()) return o<<"<empty>"; else return o << *s; }
00153 
00154 
00155 
00156 inline std::ostream& operator <<(std::ostream &o, const KPilotDepthCount &d)
00157     { return o << d.indent() << ' ' << d.name(); }
00158 
00159 #else
00160 
00161 #warning "kdDebug()-based debugging is deprecated"
00162 
00163 // kddebug based debugging
00164 //
00165 //
00166 #define DEBUGKPILOT fname.debug(DEBUGAREA_KPILOT)
00167 #define DEBUGLIBRARY    fname.debug(DEBUGAREA_LIBRARY)
00168 #define DEBUGCONDUIT    fname.debug(DEBUGAREA_CONDUIT)
00169 #define DEBUGDB         fname.debug(DEBUGAREA_DB)
00170 
00171 inline kdbgstream& operator <<(kdbgstream o, const KPilotDepthCount &d)
00172     { return o << d.indent() ; }
00173 
00174 #endif
00175 
00176 
00177 // no debugging at all
00178 //
00179 #else
00180 #define DEBUGSTREAM kndbgstream
00181 #define DEBUGKPILOT kndDebug()
00182 #define DEBUGLIBRARY    kndDebug()
00183 #define DEBUGCONDUIT    kndDebug()
00184 #define DEBUGDB         kndDebug()
00185 
00186 // With debugging turned off, FUNCTIONSETUP doesn't do anything.
00187 //
00188 //
00189 #define FUNCTIONSETUP const int fname = 0; Q_UNUSED(fname);
00190 #define FUNCTIONSETUPL(a) const int fname = a; Q_UNUSED(fname);
00191 #endif
00192 
00193 #define KPILOT_VERSION  "4.9.0 (deepsix)"
00194 
00195 
00196 // Function to expand newlines in rich text to <br>\n
00197 QString rtExpand(const QString &s, bool richText=true);
00198 
00199 
00200 
00204 KDE_EXPORT QDateTime readTm(const struct tm &t);
00208 KDE_EXPORT struct tm writeTm(const QDateTime &dt);
00209 KDE_EXPORT struct tm writeTm(const QDate &dt);
00210 
00211 
00212 // Some layout macros
00213 //
00214 // SPACING is a generic distance between visual elements;
00215 // 10 seems reasonably good even at high resolutions.
00216 //
00217 //
00218 #define SPACING     (10)
00219 
00220 // Semi-Standard safe-free expression. Argument a may be evaluated more
00221 // than once though, so be careful.
00222 //
00223 //
00224 #define KPILOT_FREE(a)  { if (a) { ::free(a); a=0L; } }
00225 #define KPILOT_DELETE(a) { if (a) { delete a; a=0L; } }
00226 
00227 
00228 // This marks strings that need to be i18n()ed in future,
00229 // but cannot be done now due to message freeze. The _P
00230 // variant is to handle plurals and is wrong, but unavoidable.
00231 //
00232 //
00233 #define TODO_I18N(a)    QString::fromLatin1(a)
00234 #define TODO_I18N_P(a,b,c) ((c>1) ? a : b)
00235 
00236 // Handle some cases for QT_NO_CAST_ASCII and NO_ASCII_CAST.
00237 // Where possible in the source, known constant strings in
00238 // latin1 encoding are marked with CSL1(), to avoid gobs
00239 // of latin1() or fromlatin1() calls which might obscure
00240 // those places where the code really is translating
00241 // user data from latin1.
00242 //
00243 // The extra "" in CSL1 is to enforce that it's only called
00244 // with constant strings.
00245 //
00246 //
00247 #define CSL1(a)     QString::fromLatin1(a "")
00248 
00249 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys