Changeset View
Changeset View
Standalone View
Standalone View
plugins/scratchpad/scratchpad.cpp
Show First 20 Lines • Show All 183 Lines • ▼ Show 20 Line(s) | |||||
184 | void Scratchpad::createScratch(const QString& name) | 184 | void Scratchpad::createScratch(const QString& name) | ||
185 | { | 185 | { | ||
186 | if (!m_model->findItems(name).isEmpty()) { | 186 | if (!m_model->findItems(name).isEmpty()) { | ||
187 | emit actionFailed(i18n("Failed to create scratch: Name already in use")); | 187 | emit actionFailed(i18n("Failed to create scratch: Name already in use")); | ||
188 | return; | 188 | return; | ||
189 | } | 189 | } | ||
190 | 190 | | |||
191 | QFile file(dataDirectory() + name); | 191 | QFile file(dataDirectory() + name); | ||
192 | if (file.open(QIODevice::NewOnly)) { // create a new file | 192 | if (!file.exists() && file.open(QIODevice::WriteOnly)) { // create a new file if it doesn't exist | ||
193 | file.close(); | 193 | file.close(); | ||
194 | } | 194 | } | ||
195 | 195 | | |||
196 | if (file.exists()) { | 196 | if (file.exists()) { | ||
197 | addFileToModel(file); | 197 | addFileToModel(file); | ||
198 | } else { | 198 | } else { | ||
199 | emit actionFailed(i18n("Failed to create new scratch")); | 199 | emit actionFailed(i18n("Failed to create new scratch")); | ||
200 | } | 200 | } | ||
▲ Show 20 Lines • Show All 61 Lines • Show Last 20 Lines |