Changeset View
Changeset View
Standalone View
Standalone View
plugins/cmake/settings/cmakecachemodel.cpp
Show First 20 Lines • Show All 65 Lines • ▼ Show 20 Line(s) | 47 | { | |||
---|---|---|---|---|---|
66 | int currentIdx=0; | 66 | int currentIdx=0; | ||
67 | QStringList currentComment; | 67 | QStringList currentComment; | ||
68 | QTextStream in(&file); | 68 | QTextStream in(&file); | ||
69 | QHash<QString, int> variablePos; | 69 | QHash<QString, int> variablePos; | ||
70 | while (!in.atEnd()) | 70 | while (!in.atEnd()) | ||
71 | { | 71 | { | ||
72 | QString line = in.readLine().trimmed(); | 72 | QString line = in.readLine().trimmed(); | ||
73 | if(line.startsWith(QLatin1String("//"))) | 73 | if(line.startsWith(QLatin1String("//"))) | ||
74 | currentComment += line.mid(2); | 74 | { | ||
75 | else if(!line.isEmpty() && !line.startsWith(QLatin1Char('#'))) //it is a variable | 75 | line.remove(0, 2); | ||
76 | currentComment += line; | ||||
mwolff: would be easier to just write
currentComment += line.midRef(2); | |||||
Since "line" itself goes away after this loop there isn't anything to ref anymore, and I honestly don't know if this will work then. currentComment is a QStringList, no QString. dakon: Since "line" itself goes away after this loop there isn't anything to ref anymore, and I… | |||||
77 | } else if(!line.isEmpty() && !line.startsWith(QLatin1Char('#'))) //it is a variable | ||||
76 | { | 78 | { | ||
77 | CacheLine c; | 79 | CacheLine c; | ||
78 | c.readLine(line); | 80 | c.readLine(line); | ||
79 | 81 | | |||
80 | if(c.isCorrect()) | 82 | if(c.isCorrect()) | ||
81 | { | 83 | { | ||
82 | QString name=c.name(), flag=c.flag(); | 84 | QString name=c.name(), flag=c.flag(); | ||
83 | 85 | | |||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | |||||
132 | currentComment.clear(); | 134 | currentComment.clear(); | ||
133 | } | 135 | } | ||
134 | } | 136 | } | ||
135 | else if(line.startsWith(QLatin1Char('#')) && line.contains(QLatin1String("INTERNAL"))) | 137 | else if(line.startsWith(QLatin1Char('#')) && line.contains(QLatin1String("INTERNAL"))) | ||
136 | { | 138 | { | ||
137 | m_internalBegin=currentIdx; | 139 | m_internalBegin=currentIdx; | ||
138 | // qCDebug(CMAKE) << "Comment: " << line << " -.- " << currentIdx; | 140 | // qCDebug(CMAKE) << "Comment: " << line << " -.- " << currentIdx; | ||
139 | } | 141 | } | ||
140 | else if(!line.startsWith(QLatin1Char('#')) && !line.isEmpty()) | | |||
141 | { | | |||
142 | qCDebug(CMAKE) << "unrecognized cache line: " << line; | | |||
143 | } | | |||
144 | } | 142 | } | ||
145 | } | 143 | } | ||
146 | 144 | | |||
147 | bool CMakeCacheModel::setData(const QModelIndex& index, const QVariant& value, int role) | 145 | bool CMakeCacheModel::setData(const QModelIndex& index, const QVariant& value, int role) | ||
148 | { | 146 | { | ||
149 | bool ret = QStandardItemModel::setData(index, value, role); | 147 | bool ret = QStandardItemModel::setData(index, value, role); | ||
150 | if (ret) { | 148 | if (ret) { | ||
151 | m_modifiedRows.insert(index.row()); | 149 | m_modifiedRows.insert(index.row()); | ||
▲ Show 20 Lines • Show All 75 Lines • Show Last 20 Lines |
would be easier to just write