forked from qt-creator/qt-creator
- Add translator's comments. - Capitalize Dialog titles. - Replace Qt Designer's generated rich text (hardcoded font) by simple HTML. - Remove exclamation marks (do not shout at users). Change-Id: I01623a336dfd7bdf24f7d5c0d3a2ed48454d8205 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
114 lines
3.6 KiB
C++
114 lines
3.6 KiB
C++
/**************************************************************************
|
|
**
|
|
** This file is part of Qt Creator
|
|
**
|
|
** Copyright (c) 2012 AudioCodes Ltd.
|
|
**
|
|
** Author: Orgad Shaneh <orgad.shaneh@audiocodes.com>
|
|
**
|
|
** Contact: http://www.qt-project.org/
|
|
**
|
|
**
|
|
** GNU Lesser General Public License Usage
|
|
**
|
|
** This file may be used under the terms of the GNU Lesser General Public
|
|
** License version 2.1 as published by the Free Software Foundation and
|
|
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
|
** Please review the following information to ensure the GNU Lesser General
|
|
** Public License version 2.1 requirements will be met:
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
**
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
**
|
|
** Other Usage
|
|
**
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
**
|
|
**
|
|
**************************************************************************/
|
|
|
|
#include "versionselector.h"
|
|
#include "ui_versionselector.h"
|
|
|
|
#include <QRegExp>
|
|
#include <QTextStream>
|
|
|
|
namespace ClearCase {
|
|
namespace Internal {
|
|
|
|
VersionSelector::VersionSelector(const QString &fileName, const QString &message, QWidget *parent) :
|
|
QDialog(parent),
|
|
ui(new Ui::VersionSelector)
|
|
{
|
|
ui->setupUi(this);
|
|
ui->headerLabel->setText(ui->headerLabel->text().arg(fileName));
|
|
ui->loadedText->setHtml(tr("<html><head/><body><p><b>NOTE: You will not be able to check in "
|
|
"this file without merging the changes (not supported by the "
|
|
"plugin)</b></p></body></html>"));
|
|
m_stream = new QTextStream(message.toLocal8Bit(), QIODevice::ReadOnly | QIODevice::Text);
|
|
QString line;
|
|
while (!m_stream->atEnd() && !line.contains(QLatin1String("1) Loaded version")))
|
|
line = m_stream->readLine();
|
|
if (!readValues())
|
|
return;
|
|
ui->loadedLabel->setText(m_versionID);
|
|
ui->loadedCreatedByLabel->setText(m_createdBy);
|
|
ui->loadedCreatedOnLabel->setText(m_createdOn);
|
|
ui->loadedText->insertPlainText(m_message + QLatin1Char(' '));
|
|
|
|
line = m_stream->readLine(); // 2) Version after update
|
|
if (!readValues())
|
|
return;
|
|
ui->updatedLabel->setText(m_versionID);
|
|
ui->updatedCreatedByLabel->setText(m_createdBy);
|
|
ui->updatedCreatedOnLabel->setText(m_createdOn);
|
|
ui->updatedText->setPlainText(m_message);
|
|
}
|
|
|
|
VersionSelector::~VersionSelector()
|
|
{
|
|
delete m_stream;
|
|
delete ui;
|
|
}
|
|
|
|
bool VersionSelector::readValues()
|
|
{
|
|
QString line;
|
|
line = m_stream->readLine();
|
|
QRegExp id(QLatin1String("Version ID: (.*)"));
|
|
if (id.indexIn(line) == -1)
|
|
return false;
|
|
m_versionID = id.cap(1);
|
|
line = m_stream->readLine();
|
|
QRegExp owner(QLatin1String("Created by: (.*)"));
|
|
if (owner.indexIn(line) == -1)
|
|
return false;
|
|
m_createdBy = owner.cap(1);
|
|
line = m_stream->readLine();
|
|
QRegExp dateTimeRE(QLatin1String("Created on: (.*)"));
|
|
if (dateTimeRE.indexIn(line) == -1)
|
|
return false;
|
|
m_createdOn = dateTimeRE.cap(1);
|
|
QStringList messageLines;
|
|
do
|
|
{
|
|
line = m_stream->readLine().trimmed();
|
|
if (line.isEmpty())
|
|
break;
|
|
messageLines << line;
|
|
} while (!m_stream->atEnd());
|
|
m_message = messageLines.join(QLatin1String(" "));
|
|
return true;
|
|
}
|
|
|
|
bool VersionSelector::isUpdate() const
|
|
{
|
|
return (ui->updatedRadioButton->isChecked());
|
|
}
|
|
|
|
} // namespace Internal
|
|
} // namespace ClearCase
|