Commit 6f9d9e24 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

In the cmake preferences, after reconfiguring the project, reread the CMakeCache.txt file.

BUG: 283979
parent b2e124fa
......@@ -37,8 +37,18 @@ CMakeCacheModel::CMakeCacheModel(QObject *parent, const KUrl &path)
labels.append(i18n("Comment"));
labels.append(i18n("Advanced"));
setHorizontalHeaderLabels(labels);
QFile file(path.toLocalFile());
}
void CMakeCacheModel::reset()
{
clear();
m_internal.clear();
read();
}
void CMakeCacheModel::read()
{
QFile file(m_filePath.toLocalFile());
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
kDebug(9032) << "error. Could not find the file";
......@@ -48,6 +58,7 @@ CMakeCacheModel::CMakeCacheModel(QObject *parent, const KUrl &path)
int currentIdx=0;
QStringList currentComment;
QTextStream in(&file);
QHash<QString, int> variablePos;
while (!in.atEnd())
{
QString line = in.readLine().trimmed();
......@@ -76,9 +87,9 @@ CMakeCacheModel::CMakeCacheModel(QObject *parent, const KUrl &path)
m_internal.insert(name);
} else if(flag=="ADVANCED")
{
if(m_variablePos.contains(name))
if(variablePos.contains(name))
{
int pos=m_variablePos[name];
int pos=variablePos[name];
QStandardItem *p = item(pos, 4);
if(!p)
{
......@@ -101,7 +112,7 @@ CMakeCacheModel::CMakeCacheModel(QObject *parent, const KUrl &path)
lineItems[0]->setText(lineItems[0]->text()+'-'+flag);
}
insertRow(currentIdx, lineItems);
m_variablePos[name]=currentIdx;
variablePos[name]=currentIdx;
currentIdx++;
currentComment.clear();
}
......@@ -206,6 +217,7 @@ bool CMakeCacheModel::isAdvanced(int i) const
p=item(i, 1);
isAdv = p->text()=="INTERNAL" || p->text()=="STATIC";
}
if(!isAdv)
{
m_internal.contains(item(i,0)->text());
......
......@@ -48,8 +48,11 @@ class CMakeCacheModel : public QStandardItemModel
QList<QModelIndex> persistentIndices() const;
KUrl filePath() const;
void read();
private slots:
void edited() { m_changed=true; }
void reset();
private:
bool writeBack(const KUrl& path) const;
......@@ -57,7 +60,6 @@ class CMakeCacheModel : public QStandardItemModel
KUrl m_filePath;
bool m_changed;
int m_internalBegin;
QHash<QString, int> m_variablePos;
QSet<QString> m_internal;
};
......
......@@ -334,6 +334,7 @@ void CMakePreferences::configure()
KDevelop::ProjectFolderItem* it=p->projectItem();
KDevelop::IProjectBuilder *b=p->buildSystemManager()->builder(it);
KJob* job=b->configure(p);
connect(job, SIGNAL(finished(KJob*)), m_currentModel, SLOT(reset()));
KDevelop::ICore::self()->runController()->registerJob(job);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment