Changeset View
Changeset View
Standalone View
Standalone View
kdevplatform/tests/testfile.cpp
Show First 20 Lines • Show All 104 Lines • ▼ Show 20 Line(s) | 104 | TestFile::TestFile(const QString& contents, const QString& fileExtension, const TestFile* base) | |||
---|---|---|---|---|---|
105 | : d(new TestFilePrivate) | 105 | : d(new TestFilePrivate) | ||
106 | { | 106 | { | ||
107 | QString fileName = base->d->file.mid(0, base->d->file.length() - base->d->suffix.length()); | 107 | QString fileName = base->d->file.mid(0, base->d->file.length() - base->d->suffix.length()); | ||
108 | d->suffix = QLatin1Char('.') + fileExtension; | 108 | d->suffix = QLatin1Char('.') + fileExtension; | ||
109 | fileName += d->suffix; | 109 | fileName += d->suffix; | ||
110 | d->init(fileName, contents, base->d->project); | 110 | d->init(fileName, contents, base->d->project); | ||
111 | } | 111 | } | ||
112 | 112 | | |||
113 | TestFile::TestFile(const QString& contents, const QString& fileExtension, const QString& fileName, | ||||
114 | KDevelop::TestProject* project, const QString& dir) | ||||
115 | : d(new TestFilePrivate) | ||||
116 | { | ||||
117 | d->suffix = QLatin1Char('.') + fileExtension; | ||||
118 | const QString file = (!dir.isEmpty() ? dir : QDir::tempPath()) | ||||
119 | + QLatin1Char('/') + fileName + d->suffix; | ||||
120 | d->init(file, contents, project); | ||||
121 | } | ||||
122 | | ||||
123 | | ||||
113 | TestFile::~TestFile() | 124 | TestFile::~TestFile() | ||
114 | { | 125 | { | ||
115 | if (d->topContext && !d->keepDUChainData) { | 126 | if (d->topContext && !d->keepDUChainData) { | ||
116 | DUChainWriteLocker lock; | 127 | DUChainWriteLocker lock; | ||
117 | DUChain::self()->removeDocumentChain(d->topContext.data()); | 128 | DUChain::self()->removeDocumentChain(d->topContext.data()); | ||
118 | } | 129 | } | ||
119 | QFile::remove(d->file); | 130 | QFile::remove(d->file); | ||
120 | } | 131 | } | ||
▲ Show 20 Lines • Show All 68 Lines • Show Last 20 Lines |