Commit e123f5a4 authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Limit length of file names in DiffEditorDocument::suggestedFileName().



Change-Id: I168831b24bcece5ef825825c448edf684f4f536d
Reviewed-by: default avatarOrgad Shaneh <orgads@gmail.com>
parent e0149612
......@@ -129,6 +129,7 @@ bool DiffEditorDocument::open(QString *errorString, const QString &fileName)
QString DiffEditorDocument::suggestedFileName() const
{
enum { maxSubjectLength = 50 };
QString result = QStringLiteral("0001");
const QString description = m_controller->description();
if (!description.isEmpty()) {
......@@ -144,6 +145,10 @@ QString DiffEditorDocument::suggestedFileName() const
subject[i] = space;
}
subject = subject.simplified();
if (subject.size() > maxSubjectLength) {
const int lastSpace = subject.lastIndexOf(space, maxSubjectLength);
subject.truncate(lastSpace > 0 ? lastSpace : maxSubjectLength);
}
subject.replace(space, dash);
result += dash;
result += subject;
......
Markdown is supported
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