2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2010-03-05 11:25:49 +01:00
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-06-17 00:01:27 +10:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Commercial Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Alternatively, 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.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** If you are unsure which license is appropriate for your use, please
|
2009-08-14 09:30:56 +02:00
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#ifndef SUBMITEDITORWIDGET_H
|
|
|
|
|
#define SUBMITEDITORWIDGET_H
|
|
|
|
|
|
|
|
|
|
#include "utils_global.h"
|
|
|
|
|
|
|
|
|
|
#include <QtGui/QWidget>
|
2009-01-13 10:06:06 +01:00
|
|
|
#include <QtGui/QAbstractItemView>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
2009-03-20 14:20:28 +01:00
|
|
|
class QTextEdit;
|
2008-12-02 12:01:29 +01:00
|
|
|
class QListWidgetItem;
|
|
|
|
|
class QAction;
|
2009-01-12 17:44:04 +01:00
|
|
|
class QAbstractItemModel;
|
|
|
|
|
class QModelIndex;
|
2009-03-19 17:40:01 +01:00
|
|
|
class QLineEdit;
|
2008-12-02 12:01:29 +01:00
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
|
|
namespace Utils {
|
|
|
|
|
|
2009-03-23 12:03:20 +01:00
|
|
|
class SubmitFieldWidget;
|
2008-12-02 12:01:29 +01:00
|
|
|
struct SubmitEditorWidgetPrivate;
|
|
|
|
|
|
|
|
|
|
/* The submit editor presents the commit message in a text editor and an
|
|
|
|
|
* checkable list of modified files in a list window. The user can delete
|
2009-01-12 17:44:04 +01:00
|
|
|
* files from the list by unchecking them or diff the selection
|
|
|
|
|
* by doubleclicking. A list model which contains the file in a column
|
|
|
|
|
* specified by fileNameColumn should be set using setFileModel().
|
2008-12-02 12:01:29 +01:00
|
|
|
*
|
|
|
|
|
* Additionally, standard creator actions can be registered:
|
|
|
|
|
* Undo/redo will be set up to work with the description editor.
|
|
|
|
|
* Submit will be set up to be enabled according to checkstate.
|
|
|
|
|
* Diff will be set up to trigger diffSelected().
|
|
|
|
|
*
|
|
|
|
|
* Note that the actions are connected by signals; in the rare event that there
|
|
|
|
|
* are several instances of the SubmitEditorWidget belonging to the same
|
|
|
|
|
* context active, the actions must be registered/unregistered in the editor
|
|
|
|
|
* change event.
|
|
|
|
|
* Care should be taken to ensure the widget is deleted properly when the
|
|
|
|
|
* editor closes. */
|
|
|
|
|
|
2009-05-08 12:09:21 +02:00
|
|
|
class QTCREATOR_UTILS_EXPORT SubmitEditorWidget : public QWidget
|
2008-12-02 14:09:21 +01:00
|
|
|
{
|
2008-12-02 12:01:29 +01:00
|
|
|
Q_OBJECT
|
|
|
|
|
Q_DISABLE_COPY(SubmitEditorWidget)
|
|
|
|
|
Q_PROPERTY(QString descriptionText READ descriptionText WRITE setDescriptionText DESIGNABLE true)
|
2009-01-12 17:44:04 +01:00
|
|
|
Q_PROPERTY(int fileNameColumn READ fileNameColumn WRITE setFileNameColumn DESIGNABLE false)
|
2009-01-13 10:06:06 +01:00
|
|
|
Q_PROPERTY(QAbstractItemView::SelectionMode fileListSelectionMode READ fileListSelectionMode WRITE setFileListSelectionMode DESIGNABLE true)
|
2009-03-20 14:20:28 +01:00
|
|
|
Q_PROPERTY(bool lineWrap READ lineWrap WRITE setLineWrap DESIGNABLE true)
|
|
|
|
|
Q_PROPERTY(int lineWrapWidth READ lineWrapWidth WRITE setLineWrapWidth DESIGNABLE true)
|
2008-12-02 12:01:29 +01:00
|
|
|
public:
|
|
|
|
|
explicit SubmitEditorWidget(QWidget *parent = 0);
|
|
|
|
|
virtual ~SubmitEditorWidget();
|
|
|
|
|
|
|
|
|
|
void registerActions(QAction *editorUndoAction, QAction *editorRedoAction,
|
|
|
|
|
QAction *submitAction = 0, QAction *diffAction = 0);
|
|
|
|
|
void unregisterActions(QAction *editorUndoAction, QAction *editorRedoAction,
|
|
|
|
|
QAction *submitAction = 0, QAction *diffAction = 0);
|
|
|
|
|
|
|
|
|
|
QString descriptionText() const;
|
|
|
|
|
void setDescriptionText(const QString &text);
|
|
|
|
|
|
2009-01-12 17:44:04 +01:00
|
|
|
int fileNameColumn() const;
|
|
|
|
|
void setFileNameColumn(int c);
|
|
|
|
|
|
2009-03-20 14:20:28 +01:00
|
|
|
bool lineWrap() const;
|
|
|
|
|
void setLineWrap(bool);
|
|
|
|
|
|
|
|
|
|
int lineWrapWidth() const;
|
|
|
|
|
void setLineWrapWidth(int);
|
|
|
|
|
|
2009-01-13 10:06:06 +01:00
|
|
|
QAbstractItemView::SelectionMode fileListSelectionMode() const;
|
|
|
|
|
void setFileListSelectionMode(QAbstractItemView::SelectionMode sm);
|
|
|
|
|
|
2009-01-12 17:44:04 +01:00
|
|
|
void setFileModel(QAbstractItemModel *model);
|
|
|
|
|
QAbstractItemModel *fileModel() const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
// Files to be included in submit
|
|
|
|
|
QStringList checkedFiles() const;
|
|
|
|
|
|
|
|
|
|
// Selected files for diff
|
|
|
|
|
QStringList selectedFiles() const;
|
|
|
|
|
|
2009-03-20 14:20:28 +01:00
|
|
|
QTextEdit *descriptionEdit() const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-03-19 17:40:01 +01:00
|
|
|
void addDescriptionEditContextMenuAction(QAction *a);
|
|
|
|
|
void insertDescriptionEditContextMenuAction(int pos, QAction *a);
|
|
|
|
|
|
2009-03-23 12:03:20 +01:00
|
|
|
void addSubmitFieldWidget(SubmitFieldWidget *f);
|
|
|
|
|
QList<SubmitFieldWidget *> submitFieldWidgets() const;
|
2009-03-19 17:40:01 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
signals:
|
|
|
|
|
void diffSelected(const QStringList &);
|
|
|
|
|
void fileSelectionChanged(bool someFileSelected);
|
|
|
|
|
void fileCheckStateChanged(bool someFileChecked);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual void changeEvent(QEvent *e);
|
|
|
|
|
void insertTopWidget(QWidget *w);
|
|
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
void triggerDiffSelected();
|
2009-01-12 17:44:04 +01:00
|
|
|
void diffActivated(const QModelIndex &index);
|
|
|
|
|
void diffActivatedDelayed();
|
|
|
|
|
void updateActions();
|
|
|
|
|
void updateSubmitAction();
|
|
|
|
|
void updateDiffAction();
|
2009-03-19 17:40:01 +01:00
|
|
|
void editorCustomContextMenuRequested(const QPoint &);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
private:
|
2009-01-12 17:44:04 +01:00
|
|
|
bool hasSelection() const;
|
|
|
|
|
bool hasCheckedFiles() const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
SubmitEditorWidgetPrivate *m_d;
|
|
|
|
|
};
|
|
|
|
|
|
2008-12-02 14:09:21 +01:00
|
|
|
} // namespace Utils
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#endif // SUBMITEDITORWIDGET_H
|