Sayonara Player
globals.h
1 /* globals.h */
2 
3 /* Copyright (C) 2012 Lucio Carreras
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef GLOBALS_H_
22 #define GLOBALS_H_
23 
24 #include <type_traits>
25 
26 #define DARK_BLUE(x) QString("<font color=#0000FF>") + x + QString("</font>")
27 #define LIGHT_BLUE(x) QString("<font color=#8888FF>") + x + QString("</font>")
28 
29 #define CAR_RET QString("<br />")
30 #define BOLD(x) QString("<b>") + x + QString("</b>")
31 #define BLACK(x) QString("<font color=#000000>") + x + QString("</font>")
32 
33 
34 // name, target, dark, string
35 #define LINK(n, t, d, s) if(d) s=QString("<a href=\"t\">)") + LIGHT_BLUE(n) + QString("</a>"); \
36  else s=QString("<a href=\"t\">)") + DARK_BLUE(n) + QString("</a>");
37 
38 #define SAYONARA_ORANGE_STR QString("#e8841a")
39 #define SAYONARA_ORANGE_COL QColor(232, 132, 26)
40 
41 template<typename TINT, typename T>
42 typename std::enable_if<std::is_pointer<T>::value, bool>::type
43 between( TINT idx, const T& cont){
44  return (idx >= 0 && idx < static_cast<TINT>(cont->size()));
45 }
46 
47 template<typename TINT, typename T>
48 typename std::enable_if<std::is_class<T>::value, bool>::type
49 between( TINT idx, const T& cont){
50  return (idx >= 0 && idx < static_cast<TINT>(cont.size()));
51 }
52 
53 template<typename TINT>
54 typename std::enable_if<std::is_integral<TINT>::value, bool>::type
55 between( TINT idx, TINT max){
56  return (idx >= 0 && idx < max);
57 }
58 
59 #endif /* GLOBALS_H_ */