File indexing completed on 2024-04-21 03:41:51

0001 /***************************************************************************
0002  *   Copyright (C) 2004-2007 by Albert Astals Cid                          *
0003  *   aacid@kde.org                                                         *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  ***************************************************************************/
0010 
0011 #include "division.h"
0012 
0013 #include <QFile>
0014 
0015 division::division() : p_askMode(eClick | eCapital | eFlag)
0016 {
0017 }
0018 
0019 bool division::canAsk(askMode am) const
0020 {
0021     bool can = p_askMode & am;
0022     
0023     switch(am)
0024     {
0025         case eClick:
0026             can = can && !p_name.isEmpty();
0027         break;
0028         
0029         case eCapital:
0030             can = can && !p_capital.isEmpty();
0031         break;
0032         
0033         case eFlag:
0034             can = can && !p_flagFile.isEmpty();
0035         break;
0036         
0037         default:
0038             can = false;
0039         break;
0040     }
0041     return can;
0042 }
0043 
0044 QString division::getUntranslatedName() const
0045 {
0046     return p_untranslatedName;
0047 }
0048 
0049 QString division::getName() const
0050 {
0051     return p_name;
0052 }
0053 
0054 QRgb division::getRGB() const
0055 {
0056     return p_color;
0057 }
0058 
0059 QString division::getFlagFile() const
0060 {
0061     return p_flagFile;
0062 }
0063 
0064 QString division::getBlurredFlagFile() const
0065 {
0066     return p_blurredFlagFile;
0067 }
0068 
0069 QString division::getCapital() const
0070 {
0071     return p_capital;
0072 }
0073 
0074 QStringList division::getFalseCapitals() const
0075 {
0076     return p_falseCapitals;
0077 }
0078 
0079 void division::setCapital(const QString &name)
0080 {
0081     p_capital = name;
0082 }
0083 
0084 void division::setFalseCapitals(const QStringList &falseCapitals)
0085 {
0086     p_falseCapitals = falseCapitals;
0087 }
0088 
0089 void division::setCanAsk(int askMode)
0090 {
0091     p_askMode = askMode;
0092 }
0093 
0094 void division::setUntranslatedName(const QString &name)
0095 {
0096     p_untranslatedName = name;
0097 }
0098 
0099 void division::setName(const QString &name)
0100 {
0101     p_name = name;
0102 }
0103 
0104 void division::setRGB(int r, int g, int b)
0105 {
0106     p_color = qRgb(r, g, b);
0107 }
0108 
0109 bool division::setFlagFile(const QString &path)
0110 {
0111     p_flagFile = path;
0112     return QFile::exists(path);
0113 }
0114 
0115 bool division::setBlurredFlagFile(const QString &path)
0116 {
0117     p_blurredFlagFile = path;
0118     return QFile::exists(path);
0119 }
0120 
0121 QString division::getFlagForQuestion() const
0122 {
0123     return p_blurredFlagFile.isNull() ? p_flagFile : p_blurredFlagFile;
0124 }