LP-311 Remove basic/advanced stabilization tab auto-switch (autotune/txpid lock issues)
[librepilot.git] / ground / gcs / src / libs / utils / submiteditorwidget.h
blob3782cf49c37f449cd3e47971414fbff026d31f36
1 /**
2 ******************************************************************************
4 * @file submiteditorwidget.h
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
7 * @brief
8 * @see The GNU Public License (GPL) Version 3
9 * @defgroup
10 * @{
12 *****************************************************************************/
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * for more details.
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #ifndef SUBMITEDITORWIDGET_H
30 #define SUBMITEDITORWIDGET_H
32 #include "utils_global.h"
34 #include <QWidget>
35 #include <QAbstractItemView>
37 QT_BEGIN_NAMESPACE
38 class QTextEdit;
39 class QListWidgetItem;
40 class QAction;
41 class QAbstractItemModel;
42 class QModelIndex;
43 class QLineEdit;
44 QT_END_NAMESPACE
46 namespace Utils {
47 class SubmitFieldWidget;
48 struct SubmitEditorWidgetPrivate;
50 /* The submit editor presents the commit message in a text editor and an
51 * checkable list of modified files in a list window. The user can delete
52 * files from the list by unchecking them or diff the selection
53 * by doubleclicking. A list model which contains the file in a column
54 * specified by fileNameColumn should be set using setFileModel().
56 * Additionally, standard creator actions can be registered:
57 * Undo/redo will be set up to work with the description editor.
58 * Submit will be set up to be enabled according to checkstate.
59 * Diff will be set up to trigger diffSelected().
61 * Note that the actions are connected by signals; in the rare event that there
62 * are several instances of the SubmitEditorWidget belonging to the same
63 * context active, the actions must be registered/unregistered in the editor
64 * change event.
65 * Care should be taken to ensure the widget is deleted properly when the
66 * editor closes. */
68 class QTCREATOR_UTILS_EXPORT SubmitEditorWidget : public QWidget {
69 Q_OBJECT Q_DISABLE_COPY(SubmitEditorWidget)
70 Q_PROPERTY(QString descriptionText READ descriptionText WRITE setDescriptionText DESIGNABLE true)
71 Q_PROPERTY(int fileNameColumn READ fileNameColumn WRITE setFileNameColumn DESIGNABLE false)
72 Q_PROPERTY(QAbstractItemView::SelectionMode fileListSelectionMode READ fileListSelectionMode WRITE setFileListSelectionMode DESIGNABLE true)
73 Q_PROPERTY(bool lineWrap READ lineWrap WRITE setLineWrap DESIGNABLE true)
74 Q_PROPERTY(int lineWrapWidth READ lineWrapWidth WRITE setLineWrapWidth DESIGNABLE true)
75 public:
76 explicit SubmitEditorWidget(QWidget *parent = 0);
77 virtual ~SubmitEditorWidget();
79 void registerActions(QAction *editorUndoAction, QAction *editorRedoAction,
80 QAction *submitAction = 0, QAction *diffAction = 0);
81 void unregisterActions(QAction *editorUndoAction, QAction *editorRedoAction,
82 QAction *submitAction = 0, QAction *diffAction = 0);
84 QString descriptionText() const;
85 void setDescriptionText(const QString &text);
87 int fileNameColumn() const;
88 void setFileNameColumn(int c);
90 bool lineWrap() const;
91 void setLineWrap(bool);
93 int lineWrapWidth() const;
94 void setLineWrapWidth(int);
96 QAbstractItemView::SelectionMode fileListSelectionMode() const;
97 void setFileListSelectionMode(QAbstractItemView::SelectionMode sm);
99 void setFileModel(QAbstractItemModel *model);
100 QAbstractItemModel *fileModel() const;
102 // Files to be included in submit
103 QStringList checkedFiles() const;
105 // Selected files for diff
106 QStringList selectedFiles() const;
108 QTextEdit *descriptionEdit() const;
110 void addDescriptionEditContextMenuAction(QAction *a);
111 void insertDescriptionEditContextMenuAction(int pos, QAction *a);
113 void addSubmitFieldWidget(SubmitFieldWidget *f);
114 QList<SubmitFieldWidget *> submitFieldWidgets() const;
116 signals:
117 void diffSelected(const QStringList &);
118 void fileSelectionChanged(bool someFileSelected);
119 void fileCheckStateChanged(bool someFileChecked);
121 protected:
122 virtual void changeEvent(QEvent *e);
123 void insertTopWidget(QWidget *w);
125 private slots:
126 void triggerDiffSelected();
127 void diffActivated(const QModelIndex &index);
128 void diffActivatedDelayed();
129 void updateActions();
130 void updateSubmitAction();
131 void updateDiffAction();
132 void editorCustomContextMenuRequested(const QPoint &);
134 private:
135 bool hasSelection() const;
136 bool hasCheckedFiles() const;
138 SubmitEditorWidgetPrivate *m_d;
140 } // namespace Utils
142 #endif // SUBMITEDITORWIDGET_H