MCPcopy Create free account
hub / github.com/KDE/labplot / loadSettings

Method loadSettings

src/frontend/SettingsDatasetsPage.cpp:63–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63void SettingsDatasetsPage::loadSettings() {
64 auto group = Settings::group(QStringLiteral("Settings_Datasets"));
65 ui.leKagglePath->setText(group.readEntry(QLatin1String("KaggleCLIPath"), QString()));
66
67 if (ui.leKagglePath->text().isEmpty()) {
68 QString kagglePath = QStandardPaths::findExecutable(QStringLiteral("kaggle"));
69 if (!kagglePath.isEmpty()) {
70 ui.leKagglePath->setText(kagglePath);
71 group.writeEntry(QLatin1String("KaggleCLIPath"), ui.leKagglePath->text());
72 }
73 }
74
75 QDir dir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QLatin1String("/datasets_local/"));
76 if (dir.exists()) {
77 int count = 0;
78 int size = 0;
79 QDirIterator dirIterator(dir.path(), QDir::Files, QDirIterator::Subdirectories);
80 while (dirIterator.hasNext()) {
81 dirIterator.next();
82 size += dirIterator.fileInfo().size();
83 count++;
84 }
85 ui.lFiles->setText(i18n("Files - %1", count));
86
87 if (count > 0)
88 ui.bClearCache->setEnabled(true);
89
90 const auto numberLocale = QLocale();
91 QString sizeStr;
92 if (size > 1024 * 1024)
93 sizeStr = numberLocale.toString(size / 1024 / 1024) + QLatin1String("MB");
94 else if (size > 1024)
95 sizeStr = numberLocale.toString(size / 1024) + QLatin1String("kB");
96 else
97 sizeStr = numberLocale.toString(size) + QLatin1String("B");
98
99 ui.lSize->setText(i18n("Total size - %1", sizeStr));
100 }
101}
102
103void SettingsDatasetsPage::clearCache() {
104 QDir dir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QLatin1String("/datasets_local/"));

Callers

nothing calls this directly

Calls 11

groupFunction · 0.85
existsMethod · 0.80
nextMethod · 0.80
QStringClass · 0.50
setTextMethod · 0.45
isEmptyMethod · 0.45
textMethod · 0.45
pathMethod · 0.45
sizeMethod · 0.45
setEnabledMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected