OSDN Git Service

46aaefb462eab027b645efef6a810fc95e983eb1
[qt-creator-jp/qt-creator-jp.git] / src / plugins / git / stashdialog.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 **
9 ** No Commercial Usage
10 **
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
14 ** this package.
15 **
16 ** GNU Lesser General Public License Usage
17 **
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights.  These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
31 **
32 **************************************************************************/
33
34 #ifndef STASHDIALOG_H
35 #define STASHDIALOG_H
36
37 #include <QtGui/QDialog>
38
39 QT_BEGIN_NAMESPACE
40 class QSortFilterProxyModel;
41 class QPushButton;
42 class QModelIndex;
43 QT_END_NAMESPACE
44
45 namespace Git {
46 namespace Internal {
47
48 namespace Ui {
49     class StashDialog;
50 }
51 class StashModel;
52
53 /* StashDialog: Non-modal dialog that manages the list of stashes
54  * of the repository. Offers to show, restore, restore to branch
55  * (in case restore fails due to conflicts) on current and
56  * delete on selection/all. */
57
58 class StashDialog : public QDialog {
59     Q_OBJECT
60 public:
61     explicit StashDialog(QWidget *parent = 0);
62     ~StashDialog();
63
64     static QString msgRepositoryLabel(const QString &repository);
65
66 public slots:
67     void refresh(const QString &repository, bool force);
68
69 protected:
70     void changeEvent(QEvent *e);
71
72 private slots:
73     void deleteAll();
74     void deleteSelection();
75     void showCurrent();
76     void restoreCurrent();
77     void restoreCurrentInBranch();
78     void enableButtons();
79     void forceRefresh();
80
81 private:
82     // Prompt dialog for modified repositories. Ask to undo or stash away.
83     enum ModifiedRepositoryAction {
84         ModifiedRepositoryCancel,
85         ModifiedRepositoryStash,
86         ModifiedRepositoryDiscard
87     };
88
89     ModifiedRepositoryAction promptModifiedRepository(const QString &stash);
90     bool promptForRestore(QString *stash, QString *branch /* = 0 */, QString *errorMessage);
91     bool ask(const QString &title, const QString &what, bool defaultButton = true);
92     void warning(const QString &title, const QString &what, const QString &details = QString());
93     int currentRow() const;
94     QList<int> selectedRows() const;    \
95
96     Ui::StashDialog *ui;
97     StashModel *m_model;
98     QSortFilterProxyModel *m_proxyModel;
99     QPushButton *m_deleteAllButton;
100     QPushButton *m_deleteSelectionButton;
101     QPushButton *m_showCurrentButton;
102     QPushButton *m_restoreCurrentButton;
103     QPushButton *m_restoreCurrentInBranchButton;
104     QPushButton *m_refreshButton;
105     QString m_repository;
106 };
107
108 } // namespace Internal
109 } // namespace Git
110
111 #endif // STASHDIALOG_H