MCPcopy Create free account
hub / github.com/KDE/kdevelop / updateCache

Method updateCache

plugins/cmake/settings/cmakepreferences.cpp:198–242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

196}
197
198void CMakePreferences::updateCache(const Path &newBuildDir)
199{
200 const Path file = newBuildDir.isValid() ? Path(newBuildDir, QStringLiteral("CMakeCache.txt")) : Path();
201 if(QFile::exists(file.toLocalFile()))
202 {
203 if (m_currentModel) {
204 m_currentModel->deleteLater();
205 }
206 m_currentModel = new CMakeCacheModel(this, file);
207
208 configureCacheView();
209 connect(m_currentModel, &CMakeCacheModel::itemChanged,
210 this, &CMakePreferences::cacheEdited);
211 connect(m_currentModel, &CMakeCacheModel::modelReset,
212 this, &CMakePreferences::configureCacheView);
213 connect(m_prefsUi->cacheList->selectionModel(), &QItemSelectionModel::currentChanged,
214 this, &CMakePreferences::listSelectionChanged);
215 connect(m_currentModel, &CMakeCacheModel::valueChanged, this,
216 [this](const QString& name, const QString& value) {
217 if (name == QLatin1String("CMAKE_BUILD_TYPE")) {
218 setBuildType(value);
219 }
220 });
221 connect(m_prefsUi->buildType, &QComboBox::currentTextChanged, m_currentModel, [this](const QString& value) {
222 if (!m_currentModel)
223 return;
224 const auto items = m_currentModel->findItems(QStringLiteral("CMAKE_BUILD_TYPE"));
225 for (auto* item : items) {
226 m_currentModel->setData(m_currentModel->index(item->row(), 2), value);
227 }
228 });
229 }
230 else
231 {
232 disconnect(m_prefsUi->cacheList->selectionModel(), &QItemSelectionModel::currentChanged, this, nullptr);
233 if (m_currentModel) {
234 m_currentModel->deleteLater();
235 m_currentModel = nullptr;
236 }
237 configureCacheView();
238 }
239
240 if( !m_currentModel )
241 emit changed();
242}
243
244void CMakePreferences::listSelectionChanged(const QModelIndex & index, const QModelIndex& )
245{

Callers

nothing calls this directly

Calls 6

toLocalFileMethod · 0.80
PathClass · 0.50
isValidMethod · 0.45
setDataMethod · 0.45
indexMethod · 0.45
rowMethod · 0.45

Tested by

no test coverage detected