Wizards: Improve list of files displayed.

Extract the common root directory and display in separate
line. Use the routine from
the cvs plugin for that, moving it to stringutils.h.
This commit is contained in:
Friedemann Kleint
2009-11-25 12:34:56 +01:00
parent efdd8ceaa0
commit 7cbbada3f0
6 changed files with 87 additions and 48 deletions

View File

@@ -31,6 +31,8 @@
#include "ui_projectwizardpage.h"
#include "projectnodes.h"
#include <utils/stringutils.h>
#include <QtCore/QDebug>
#include <QtCore/QFileInfo>
#include <QtCore/QTextStream>
@@ -134,13 +136,21 @@ void ProjectWizardPage::setVCSDisplay(const QString &vcsName)
void ProjectWizardPage::setFilesDisplay(const QStringList &files)
{
QString fileMessage;
const QString commonPath = Utils::commonPath(files);
{
QTextStream str(&fileMessage);
str << "<qt>" << tr("Files to be added:");
str << "<pre>";
const QStringList::const_iterator cend = files.constEnd();
for (QStringList::const_iterator it = files.constBegin(); it != cend; ++it)
str << *it << '\n';
str << "<qt>"
<< (commonPath.isEmpty() ? tr("Files to be added:") : tr("Files to be added in"))
<< "<pre>";
if (commonPath.isEmpty()) {
foreach(const QString &f, files)
str << f << '\n';
} else {
str << commonPath << ":\n\n";
const int prefixSize = commonPath.size() + 1;
foreach(const QString &f, files)
str << f.right(f.size() - prefixSize) << '\n';
}
str << "</pre>";
}
m_ui->filesLabel->setText(fileMessage);