File indexing completed on 2024-04-21 05:41:00
0001 /* 0002 SPDX-FileCopyrightText: 2011 Vishesh Yadav <vishesh3y@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef HGCOMMITINFOWIDGET_H 0008 #define HGCOMMITINFOWIDGET_H 0009 0010 #include <QWidget> 0011 #include <QAbstractItemView> 0012 #include <QList> 0013 0014 namespace KTextEditor { 0015 class View; 0016 class Document; 0017 }; 0018 0019 class QListWidget; 0020 class QListWidgetItem; 0021 0022 /** 0023 * Shows Changesets using a custom deltegate CommitItemDelegate. Shows 0024 * changeset information in a KTextEditor widget when a changeset entry is 0025 * highlighted. 0026 * */ 0027 class HgCommitInfoWidget : public QWidget 0028 { 0029 Q_OBJECT 0030 public: 0031 explicit HgCommitInfoWidget(QWidget *parent=nullptr); 0032 0033 /** 0034 * Adds a new entry in the ListWidget with the chageset parameters 0035 * provided in its parameter. 0036 * 0037 * @param revision Revision number of changeset 0038 * @param changeset Changeset identification hash (shortened) 0039 * @param author Author of the CommitItemDelegate 0040 * @param log Commit Message of that changeset 0041 * 0042 */ 0043 void addItem(const QString &revision, 0044 const QString &changeset, 0045 const QString &branch, 0046 const QString &author, 0047 const QString &log); 0048 0049 /** 0050 * Adds a new QListWidgetItem into list. Expects the changeset information 0051 * in stored in different roles of data. 0052 * 0053 * DisplayRole => Changeset Identification Hash 0054 * UserRole + 1 => Revision Number 0055 * UserRole + 2 => Branch 0056 * UserRole + 3 => Author 0057 * UserRole + 4 => Log/Commit Message 0058 * 0059 * @param item Pointer to the QListWidgetItem object to be added 0060 */ 0061 void addItem(QListWidgetItem *item); 0062 0063 /** 0064 * Returns changeset identification hash of selected changeset in ListWidget. 0065 * 0066 * @return String containing the changeset identification hash of selected 0067 * chageset 0068 * 0069 */ 0070 const QString selectedChangeset() const; 0071 0072 /** 0073 * @return Returns a list of selected changesets 0074 */ 0075 QList<QListWidgetItem*> selectedItems() const; 0076 0077 /** 0078 * @return Returns pointer to QListWidgetItem of selected changeset. 0079 */ 0080 QListWidgetItem* currentItem() const; 0081 0082 /** 0083 * Calls QListWidget::setSelectionMode(QAbstractItemView::SelectionMode) 0084 * on the m_commitListWidget 0085 */ 0086 void setSelectionMode(QAbstractItemView::SelectionMode mode); 0087 0088 /** 0089 * Clears all entries in m_commitListWidget 0090 */ 0091 void clear() const; 0092 0093 private Q_SLOTS: 0094 /** 0095 * Show selected changeset information when an entry is selected 0096 */ 0097 void slotUpdateInfo(); 0098 0099 private: 0100 void setupUI(); 0101 0102 private: 0103 KTextEditor::View *m_editorView; 0104 KTextEditor::Document *m_editorDoc; 0105 QListWidget *m_commitListWidget; 0106 }; 0107 0108 #endif /* HGCOMMITINFOWIDGET_H */ 0109