Commit 647071d8 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by hjk

Introduce ClearCase plugin

Change-Id: Ib2cebaff0f035f48ca958cad16dedfdd80f4bff9
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 0fcf5515
......@@ -35,6 +35,7 @@ Project {
"src/plugins/bineditor/bineditor.qbs",
"src/plugins/bookmarks/bookmarks.qbs",
"src/plugins/classview/classview.qbs",
"src/plugins/clearcase/clearcase.qbs",
"src/plugins/cmakeprojectmanager/cmakeprojectmanager.qbs",
"src/plugins/coreplugin/coreplugin.qbs",
"src/plugins/coreplugin/images/logo/logo.qbs",
......
<?xml version="1.0"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
<mime-type type="application/vnd.audc.text.clearcase.submit">
<comment>ClearCase submit template</comment>
<sub-class-of type="text/plain"/>
</mime-type>
</mime-info>
<plugin name=\"ClearCase\" version=\"$$QTCREATOR_VERSION\" compatVersion=\"$$QTCREATOR_VERSION\">
<vendor>AudioCodes</vendor>
<copyright>(C) 2012 AudioCodes Ltd.</copyright>
<license>
GNU Lesser General Public License Usage
this plugin may be used under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation. 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.
</license>
<category>Version Control</category>
<description>ClearCase integration.</description>
<url>http://www.qt-project.org</url>
<dependencyList>
<dependency name=\"TextEditor\" version=\"$$QTCREATOR_VERSION\"/>
<dependency name=\"ProjectExplorer\" version=\"$$QTCREATOR_VERSION\"/>
<dependency name=\"Core\" version=\"$$QTCREATOR_VERSION\"/>
<dependency name=\"VcsBase\" version=\"$$QTCREATOR_VERSION\"/>
</dependencyList>
</plugin>
/**************************************************************************
**
** 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 "activityselector.h"
#include "clearcaseconstants.h"
#include "clearcaseplugin.h"
#include <utils/qtcassert.h>
#include <QComboBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QToolButton>
using namespace ClearCase;
using namespace ClearCase::Internal;
ActivitySelector::ActivitySelector(QWidget *parent) :
QWidget(parent),
m_plugin(ClearCasePlugin::instance()),
m_changed(false)
{
QHBoxLayout *hboxLayout = new QHBoxLayout(this);
hboxLayout->setContentsMargins(0, 0, 0, 0);
QLabel *lblActivity = new QLabel(tr("Select &Activity:"));
lblActivity->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
hboxLayout->addWidget(lblActivity);
m_cmbActivity = new QComboBox(this);
m_cmbActivity->setMinimumSize(QSize(350, 0));
hboxLayout->addWidget(m_cmbActivity);
QString addText = tr("Add");
if (!m_plugin->settings().autoAssignActivityName)
addText.append(QLatin1String("..."));
QToolButton *btnAdd = new QToolButton;
btnAdd->setText(addText);
hboxLayout->addWidget(btnAdd);
#ifndef QT_NO_SHORTCUT
lblActivity->setBuddy(m_cmbActivity);
#endif // QT_NO_SHORTCUT
connect(btnAdd, SIGNAL(clicked()), this, SLOT(newActivity()));
refresh();
connect(m_cmbActivity, SIGNAL(currentIndexChanged(int)), this, SLOT(userChanged()));
}
void ActivitySelector::userChanged()
{
m_changed = true;
}
bool ActivitySelector::refresh()
{
int current;
QList<QStringPair> activities = m_plugin->activities(&current);
m_cmbActivity->clear();
foreach (QStringPair activity, activities)
m_cmbActivity->addItem(activity.second, activity.first);
m_cmbActivity->setCurrentIndex(current);
m_cmbActivity->updateGeometry();
resize(size());
return !activities.isEmpty();
}
void ActivitySelector::addKeep()
{
m_cmbActivity->insertItem(0, tr("Keep item activity"), QLatin1String(Constants::KEEP_ACTIVITY));
setActivity(QLatin1String(Constants::KEEP_ACTIVITY));
}
QString ActivitySelector::activity() const
{
return m_cmbActivity->itemData(m_cmbActivity->currentIndex()).toString();
}
void ActivitySelector::setActivity(const QString &act)
{
int index = m_cmbActivity->findData(act);
if (index != -1) {
disconnect(m_cmbActivity, SIGNAL(currentIndexChanged(int)), this, SLOT(userChanged()));
m_cmbActivity->setCurrentIndex(index);
connect(m_cmbActivity, SIGNAL(currentIndexChanged(int)), this, SLOT(userChanged()));
}
}
void ActivitySelector::newActivity()
{
if (m_plugin->newActivity())
refresh();
}
/**************************************************************************
**
** 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.
**
**
**************************************************************************/
#ifndef ACTIVITYSELECTOR_H
#define ACTIVITYSELECTOR_H
#include <QWidget>
QT_BEGIN_NAMESPACE
class QComboBox;
QT_END_NAMESPACE
namespace ClearCase {
namespace Internal {
class ClearCasePlugin;
class ActivitySelector : public QWidget
{
Q_OBJECT
public:
explicit ActivitySelector(QWidget *parent = 0);
QString activity() const;
void setActivity(const QString &act);
void addKeep();
bool refresh();
bool changed() { return m_changed; }
public slots:
void newActivity();
private slots:
void userChanged();
private:
ClearCasePlugin *m_plugin;
bool m_changed;
QComboBox *m_cmbActivity;
};
} // namespace Internal
} // namespace ClearCase
#endif // ACTIVITYSELECTOR_H
/**************************************************************************
**
** 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 "annotationhighlighter.h"
using namespace ClearCase;
using namespace ClearCase::Internal;
ClearCaseAnnotationHighlighter::ClearCaseAnnotationHighlighter(const ChangeNumbers &changeNumbers,
const QColor &bg,
QTextDocument *document) :
VcsBase::BaseAnnotationHighlighter(changeNumbers, bg, document),
m_separator(QLatin1Char('|'))
{
}
QString ClearCaseAnnotationHighlighter::changeNumber(const QString &block) const
{
const int pos = block.indexOf(m_separator);
return pos > 1 ? block.left(pos) : QString();
}
/**************************************************************************
**
** 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.
**
**
**************************************************************************/
#ifndef ANNOTATIONHIGHLIGHTER_H
#define ANNOTATIONHIGHLIGHTER_H
#include <vcsbase/baseannotationhighlighter.h>
namespace ClearCase {
namespace Internal {
// Annotation highlighter for clearcase triggering on 'changenumber '
class ClearCaseAnnotationHighlighter : public VcsBase::BaseAnnotationHighlighter
{
Q_OBJECT
public:
explicit ClearCaseAnnotationHighlighter(const ChangeNumbers &changeNumbers, const QColor &bg,
QTextDocument *document = 0);
private:
virtual QString changeNumber(const QString &block) const;
const QChar m_separator;
};
} // namespace Internal
} // namespace ClearCase
#endif // ANNOTATIONHIGHLIGHTER_H
/**************************************************************************
**
** 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 "checkoutdialog.h"
#include "clearcaseplugin.h"
#include "ui_checkoutdialog.h"
#include <QList>
#include <QPair>
#include <QPalette>
namespace ClearCase {
namespace Internal {
CheckOutDialog::CheckOutDialog(const QString &fileName, QWidget *parent) :
QDialog(parent), ui(new Ui::CheckOutDialog)
{
ui->setupUi(this);
ui->lblFileName->setText(fileName);
}
CheckOutDialog::~CheckOutDialog()
{
delete ui;
}
QString CheckOutDialog::activity() const
{
return ui->actSelector->activity();
}
QString CheckOutDialog::comment() const
{
return ui->txtComment->toPlainText();
}
bool CheckOutDialog::isReserved() const
{
return ui->chkReserved->isChecked();
}
bool CheckOutDialog::isUnreserved() const
{
return ui->chkUnreserved->isChecked();
}
bool CheckOutDialog::isPreserveTime() const
{
return ui->chkPTime->isChecked();
}
bool CheckOutDialog::isUseHijacked() const
{
return ui->hijackedCheckBox->isChecked();
}
void CheckOutDialog::hideHijack()
{
ui->hijackedCheckBox->setVisible(false);
ui->hijackedCheckBox->setChecked(false);
}
void CheckOutDialog::toggleUnreserved(bool checked)
{
ui->chkUnreserved->setEnabled(checked);
if (!checked)
ui->chkUnreserved->setChecked(false);
}
} // namespace Internal
} // namespace ClearCase
/**************************************************************************
**
** 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.
**
**
**************************************************************************/
#ifndef CHECKOUTDIALOG_H
#define CHECKOUTDIALOG_H
#include <QDialog>
namespace ClearCase {
namespace Internal {
namespace Ui {
class CheckOutDialog;
}
class CheckOutDialog : public QDialog
{
Q_OBJECT
public:
explicit CheckOutDialog(const QString &fileName, QWidget *parent = 0);
~CheckOutDialog();
QString activity() const;
QString comment() const;
bool isReserved() const;
bool isUnreserved() const;
bool isPreserveTime() const;
bool isUseHijacked() const;
void hideHijack();
private slots:
void toggleUnreserved(bool checked);
private:
Ui::CheckOutDialog *ui;
};
} // namespace Internal
} // namespace ClearCase
#endif // CHECKOUTDIALOG_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ClearCase::Internal::CheckOutDialog</class>
<widget class="QDialog" name="ClearCase::Internal::CheckOutDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>352</width>
<height>317</height>
</rect>
</property>
<property name="windowTitle">
<string>Check Out</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="lblFileName">
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>
<widget class="ActivitySelector" name="actSelector" native="true"/>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblComment">
<property name="text">
<string>&amp;Checkout Comment:</string>
</property>
<property name="buddy">
<cstring>txtComment</cstring>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="txtComment"/>
</item>
<item>
<widget class="QCheckBox" name="chkReserved">
<property name="text">
<string>&amp;Reserved</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>16</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="chkUnreserved">
<property name="text">
<string>&amp;Unreserved if already reserved</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="chkPTime">
<property name="text">
<string>&amp;Preserve file modification time</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="hijackedCheckBox">
<property name="text">
<string>Use &amp;Hijacked file</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>ActivitySelector</class>
<extends>QWidget</extends>
<header>activityselector.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>ClearCase::Internal::CheckOutDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>ClearCase::Internal::CheckOutDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>chkReserved</sender>
<signal>toggled(bool)</signal>