File indexing completed on 2023-05-30 09:06:29
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2011 Dennis Nienhüser <nienhueser@kde.org> 0004 // 0005 0006 #include "region.h" 0007 0008 0009 Region::Region() 0010 { 0011 // nothing to do 0012 } 0013 0014 QString Region::name() const 0015 { 0016 return m_name; 0017 } 0018 0019 QString Region::continent() const 0020 { 0021 return m_continent; 0022 } 0023 0024 QString Region::country() const 0025 { 0026 return m_country; 0027 } 0028 0029 void Region::setName(const QString& arg) 0030 { 0031 m_name = arg; 0032 } 0033 0034 void Region::setContinent(const QString& arg) 0035 { 0036 m_continent = arg; 0037 } 0038 0039 void Region::setCountry(const QString& arg) 0040 { 0041 m_country = arg; 0042 } 0043 0044 QString Region::id() const 0045 { 0046 return m_id; 0047 } 0048 0049 void Region::setId(const QString &id) 0050 { 0051 m_id = id; 0052 } 0053 0054 QString Region::pbfFile() const 0055 { 0056 return m_pbfFile; 0057 } 0058 0059 void Region::setPbfFile(const QString &pbfFile) 0060 { 0061 m_pbfFile = pbfFile; 0062 } 0063 0064 QString Region::path() const 0065 { 0066 return m_path; 0067 } 0068 0069 void Region::setPath(const QString &path) 0070 { 0071 m_path = path; 0072 } 0073 0074 bool Region::operator ==(const Region &other) const 0075 { 0076 return m_continent == other.m_continent && 0077 m_country == other.m_country && 0078 m_name == other.m_name && 0079 m_id == other.m_id && 0080 m_path == other.m_path && 0081 m_pbfFile == other.m_pbfFile; 0082 } 0083 0084 QString Region::fileSize(const QFileInfo &file) 0085 { 0086 qint64 size = file.size(); 0087 if (size < 1000) { 0088 return QString("%1 Byte").arg(size); 0089 } 0090 0091 int dec = 0; 0092 double value = size / 1000.0; 0093 while (value >= 1000.0 && dec<7) { 0094 value /= 1000.0; 0095 ++dec; 0096 } 0097 0098 QString unit = "kB"; 0099 switch (dec) { 0100 case 0: unit = "kB"; break; 0101 case 1: unit = "MB"; break; 0102 case 2: unit = "GB"; break; 0103 case 3: unit = "TB"; break; 0104 case 4: unit = "PB"; break; 0105 case 5: unit = "EB"; break; 0106 case 6: unit = "ZB"; break; 0107 case 7: unit = "YB"; break; 0108 default: Q_ASSERT(false); 0109 } 0110 0111 return QString("%1 %2").arg(value, 0, 'f', 1).arg(unit); 0112 }