Kstars

culturelist.cpp
1 /*
2  SPDX-FileCopyrightText: 2008 Jerome SONRIER <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #include "culturelist.h"
8 #include "ksfilereader.h"
9 #include "Options.h"
10 
12 {
13  KSFileReader fileReader;
14  if (!fileReader.open("cnames.dat"))
15  return;
16 
17  while (fileReader.hasMoreLines())
18  {
19  QString line = fileReader.readLine();
20  if (line.size() < 1)
21  continue;
22 
23  QChar mode = line.at(0);
24  if (mode == 'C')
25  m_CultureList << line.mid(2).trimmed();
26  }
27 
28  m_CurrentCulture = m_CultureList.at(0);
29  m_CultureList.sort();
30  for (int i = 0; i < m_CultureList.size(); ++i)
31  {
32  if (m_CultureList.at(i) == Options::skyCulture())
33  {
34  m_CurrentCulture = m_CultureList.at(i);
35  }
36  }
37 }
38 
40 {
41  m_CurrentCulture = newName;
42 }
43 
44 QString CultureList::getName(int index) const
45 {
46  return m_CultureList.value(index);
47 }
void setCurrent(QString newName)
Set the current culture name.
Definition: culturelist.cpp:39
int size() const const
bool open(const QString &fname)
opens the file fname from the QStandardPaths::AppLocalDataLocation directory and uses that file for t...
QString trimmed() const const
int size() const const
bool hasMoreLines() const
Definition: ksfilereader.h:100
QString getName(int index) const
Return the name of the culture at index.
Definition: culturelist.cpp:44
const T & at(int i) const const
QString readLine()
increments the line number and returns the next line from the file as a QString.
Definition: ksfilereader.h:105
const QChar at(int position) const const
CultureList()
Create culture list and load its content from file.
Definition: culturelist.cpp:11
QString mid(int position, int n) const const
T value(int i) const const
void sort(Qt::CaseSensitivity cs)
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri Aug 19 2022 03:57:50 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.