File indexing completed on 2024-07-14 07:17:20

0001 /*
0002     SPDX-FileCopyrightText: 2008 Jerome SONRIER <jsid@emor3j.fr.eu.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "culturelist.h"
0008 #include "ksfilereader.h"
0009 #include "Options.h"
0010 
0011 CultureList::CultureList()
0012 {
0013     KSFileReader fileReader;
0014     if (!fileReader.open("cnames.dat"))
0015         return;
0016 
0017     while (fileReader.hasMoreLines())
0018     {
0019         QString line = fileReader.readLine();
0020         if (line.size() < 1)
0021             continue;
0022 
0023         QChar mode = line.at(0);
0024         if (mode == 'C')
0025             m_CultureList << line.mid(2).trimmed();
0026     }
0027 
0028     m_CurrentCulture = m_CultureList.at(0);
0029     m_CultureList.sort();
0030     for (int i = 0; i < m_CultureList.size(); ++i)
0031     {
0032         if (m_CultureList.at(i) == Options::skyCulture())
0033         {
0034             m_CurrentCulture = m_CultureList.at(i);
0035         }
0036     }
0037 }
0038 
0039 void CultureList::setCurrent(QString newName)
0040 {
0041     m_CurrentCulture = newName;
0042 }
0043 
0044 QString CultureList::getName(int index) const
0045 {
0046     return m_CultureList.value(index);
0047 }