| 169 | } |
| 170 | |
| 171 | QString ChatFileManager::generateIntermediateFileName(const QString &originalPath) |
| 172 | { |
| 173 | const QFileInfo fileInfo(originalPath); |
| 174 | const QString extension = fileInfo.suffix(); |
| 175 | QString baseName = fileInfo.completeBaseName().left(30); |
| 176 | |
| 177 | static const QRegularExpression specialChars("[^a-zA-Z0-9_-]"); |
| 178 | baseName.replace(specialChars, "_"); |
| 179 | |
| 180 | if (baseName.isEmpty()) { |
| 181 | baseName = "file"; |
| 182 | } |
| 183 | |
| 184 | const QString timestamp = QDateTime::currentDateTime().toString("yyyyMMdd_HHmmss"); |
| 185 | const QString uuid = QUuid::createUuid().toString(QUuid::WithoutBraces).left(8); |
| 186 | |
| 187 | return QString("%1_%2_%3.%4").arg(baseName, timestamp, uuid, extension); |
| 188 | } |
| 189 | |
| 190 | } // namespace QodeAssist::Chat |
| 191 | |