source: tspsg/src/globals.h @ 8dcf4701e6

0.1.4.170-beta2-bb10appveyorimgbotreadme
Last change on this file since 8dcf4701e6 was bfe1e5e2ea, checked in by Oleksii Serdiuk, 14 years ago

Changed 2010 to 2011 in the source code copyrights.

  • Property mode set to 100644
File size: 4.6 KB
RevLine 
[2bbe924ad8]1/*!
2 * \file globals.h
[bfe1e5e2ea]3 * \author Copyright &copy; 2007-2011 Lёppa <contacts[at]oleksii[dot]name>
[2bbe924ad8]4 *
5 *  $Id$
6 *  $URL$
7 *
8 * \brief Contains TSPSG global defines.
9 *
10 *  <b>TSPSG: TSP Solver and Generator</b>
11 *
12 *  This file is part of TSPSG.
13 *
14 *  TSPSG is free software: you can redistribute it and/or modify
15 *  it under the terms of the GNU General Public License as published by
16 *  the Free Software Foundation, either version 3 of the License, or
17 *  (at your option) any later version.
18 *
19 *  TSPSG is distributed in the hope that it will be useful,
20 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
21 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 *  GNU General Public License for more details.
23 *
24 *  You should have received a copy of the GNU General Public License
25 *  along with TSPSG.  If not, see <http://www.gnu.org/licenses/>.
26 */
27
28#ifndef GLOBALS_H
29#define GLOBALS_H
30
31// INCLUDES
32#include <QtCore>
[2a436ea693]33#if QT_VERSION < 0x040500
[9eb63a1598]34#   error You are using Qt version < 4.5 but minimum required version is 4.5.0. Compilation aborted.
[2a436ea693]35#endif
[9adbc413c7]36#if defined(Q_WS_WINCE_WM) || defined(Q_WS_S60) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
[9eb63a1598]37    //! This is defined on handheld devices (e.g., Windows Mobile, Symbian).
38#   define HANDHELD
39#   define QT_NO_STATUSTIP
[2a436ea693]40#endif
[2bbe924ad8]41#include <QtGui>
[9adbc413c7]42#if defined(QT_NO_SVG) && !defined(NOSVG)
[9eb63a1598]43#   define NOSVG
[9adbc413c7]44#endif
[2a436ea693]45#if !defined(NOSVG)
[9eb63a1598]46#   include <QtSvg>
[2a436ea693]47#endif // NOSVG
[7bb19df196]48
49#ifndef HANDHELD
[9eb63a1598]50#   include "qttoolbardialog.h"
[7bb19df196]51#endif
[2bbe924ad8]52
53// Version info
54#include "version.h"
55// OS and ARCH detection
56#include "os.h"
57// TSPSG Defaults
58#include "defaults.h"
59// TSPSolver
60#include "tspsolver.h"
[b8a2a118c4]61#ifndef HANDHELD
62    // Eyecandy
[9eb63a1598]63#   include "qtwin.h"
[b8a2a118c4]64#endif // HANDHELD
[2bbe924ad8]65
66// DEFINES
67//! Maximum available number of cities
68#define MAX_NUM_CITIES 50
69//! Maximum allowed value for random generation limits
70#define MAX_RAND_VALUE 1000
71
72// Paths
73/*!
74 * \def PATH_L10N
75 * \brief Path to internationalization files.
76 */
77#ifndef PATH_L10N
[9eb63a1598]78#   define PATH_L10N "l10n"
[2bbe924ad8]79#endif // PATH_L10N
80/*!
81 * \def PATH_DOCS
82 * \brief Bath to documentation files.
83 */
84#ifndef PATH_DOCS
[9eb63a1598]85#   define PATH_DOCS "help"
[2bbe924ad8]86#endif // PATH_DOCS
87
88//! TSPSG Task file signature - letters \c TSPT
89#define TSPT quint32(0x54535054)
90//! TSPSG Task file version
91#define TSPT_VERSION quint8(1)
92//! TSPSG Task file metadata version
93#define TSPT_META_VERSION quint8(1)
94//! TSPSG Task file metadata size in bytes (incl. version)
95#define TSPT_META_SIZE 2
96//! ZKomModRd Task file signature - letters \c ZK
97#define ZKT quint16(0x5A4B)
98//! ZKomModRd Task file version
99#define ZKT_VERSION quint8(1)
100
101//! This string represents infinite value in the table
102#define INFSTR "---"
103
104// FUNCTIONS
105/*!
106 * \brief Checks whether \a x contains an integer value.
107 * \param x A value to check.
108 * \return \c true if \a x countains an integer, oherwise \c false.
109 */
110inline bool isInteger(double x)
111{
112double i;
[9eb63a1598]113    return (modf(x, &i) == 0.0);
[2bbe924ad8]114}
115
[f5c945d7ac]116/*!
117 * \brief Checks whether the updater app is installed/available.
118 * \return \c true if updater app is available, oherwise \c false.
119 * \note The updater app is only available under Windows at this moment.
120 *  On other systems this function always returns \c false.
121 */
122inline bool hasUpdater()
123{
[97e90f9be6]124#ifdef Q_WS_WIN32
[9eb63a1598]125    return QFile::exists("updater/Update.exe");
[97e90f9be6]126#else // Q_WS_WIN32
[9eb63a1598]127    return false;
[97e90f9be6]128#endif // Q_WS_WIN32
[f5c945d7ac]129}
130
[b8a2a118c4]131#ifndef HANDHELD
[2bbe924ad8]132/*!
133 * \brief Enables or disables a mask for the \a widget.
134 * \param widget A widget to toggle mask on.
135 * \param enable Set to \c true to enable mask or \c false to disable it.
136 *
137 *  This function is used to enable an outlined font effect for \c QLabel with a static text.
138 */
139void toggleStyle(QWidget *widget, bool enable);
[b8a2a118c4]140#endif // HANDHELD
[2bbe924ad8]141
[cac8759dba]142#ifndef DOXYGEN_EXCLUDE
143
144#ifdef HANDHELD
[9eb63a1598]145#   define ICON_SIZE "32x32"
146#   define ICON_FORMAT "png"
[cac8759dba]147#else
[9eb63a1598]148#   define ICON_SIZE "128x128"
149#   define ICON_FORMAT "png"
[cac8759dba]150#endif
151
[2a436ea693]152#if QT_VERSION >= 0x040600
[9eb63a1598]153#   define GET_ICON(x) QIcon::fromTheme(x, QIcon(":/images/icons/"ICON_SIZE"/"x"."ICON_FORMAT))
[2a436ea693]154#else
[9eb63a1598]155#   define GET_ICON(x) QIcon(":/images/icons/"ICON_SIZE"/"x"."ICON_FORMAT)
[2a436ea693]156#endif
157
[2bbe924ad8]158// Sanity checks
159// Check that default number of cities is sane (<= MAX_NUM_CITIES)
160#if DEF_NUM_CITIES > MAX_NUM_CITIES
[9eb63a1598]161#   undef DEF_NUM_CITIES
162#   define DEF_NUM_CITIES MAX_NUM_CITIES
[2bbe924ad8]163#endif
164// Check that maximum for random generation is sane (<= MAX_RAND_VALUE)
165#if DEF_RAND_MAX > MAX_RAND_VALUE
[9eb63a1598]166#   undef DEF_RAND_MAX
167#   define DEF_RAND_MAX MAX_RAND_VALUE
[2bbe924ad8]168#endif
169// Check that DEF_RAND_MIN <= DEF_RAND_MAX
170#if DEF_RAND_MIN > DEF_RAND_MAX
[9eb63a1598]171#   undef DEF_RAND_MIN
172#   define DEF_RAND_MIN DEF_RAND_MAX
[2bbe924ad8]173#endif
174
[cac8759dba]175#endif // DOXYGEN_EXCLUDE
176
[2bbe924ad8]177#endif // GLOBALS_H
Note: See TracBrowser for help on using the repository browser.