Chris@57
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@57
|
2
|
Chris@57
|
3 /*
|
Chris@57
|
4 EasyMercurial
|
Chris@57
|
5
|
Chris@57
|
6 Based on HgExplorer by Jari Korhonen
|
Chris@57
|
7 Copyright (c) 2010 Jari Korhonen
|
Chris@57
|
8 Copyright (c) 2010 Chris Cannam
|
Chris@57
|
9 Copyright (c) 2010 Queen Mary, University of London
|
Chris@57
|
10
|
Chris@57
|
11 This program is free software; you can redistribute it and/or
|
Chris@57
|
12 modify it under the terms of the GNU General Public License as
|
Chris@57
|
13 published by the Free Software Foundation; either version 2 of the
|
Chris@57
|
14 License, or (at your option) any later version. See the file
|
Chris@57
|
15 COPYING included with this distribution for more information.
|
Chris@57
|
16 */
|
jtkorhonen@0
|
17
|
Chris@96
|
18 #include "hgtabwidget.h"
|
jtkorhonen@0
|
19 #include "common.h"
|
Chris@88
|
20 #include "filestatuswidget.h"
|
Chris@116
|
21 #include "historywidget.h"
|
Chris@44
|
22
|
Chris@50
|
23 #include <QClipboard>
|
Chris@50
|
24 #include <QContextMenuEvent>
|
Chris@50
|
25 #include <QApplication>
|
Chris@50
|
26
|
Chris@44
|
27 #include <iostream>
|
jtkorhonen@0
|
28
|
Chris@96
|
29 HgTabWidget::HgTabWidget(QWidget *parent,
|
Chris@95
|
30 QString remoteRepo,
|
Chris@95
|
31 QString workFolderPath) :
|
Chris@117
|
32 QTabWidget(parent)
|
jtkorhonen@0
|
33 {
|
Chris@91
|
34 // Work page
|
Chris@116
|
35 m_fileStatusWidget = new FileStatusWidget;
|
Chris@116
|
36 m_fileStatusWidget->setLocalPath(workFolderPath);
|
Chris@116
|
37 m_fileStatusWidget->setRemoteURL(remoteRepo);
|
Chris@116
|
38 connect(m_fileStatusWidget, SIGNAL(selectionChanged()),
|
Chris@95
|
39 this, SIGNAL(selectionChanged()));
|
Chris@116
|
40 addTab(m_fileStatusWidget, tr("My work"));
|
Chris@88
|
41
|
Chris@43
|
42 // History graph page
|
Chris@116
|
43 m_historyWidget = new HistoryWidget;
|
Chris@116
|
44 addTab(m_historyWidget, tr("History"));
|
Chris@141
|
45
|
Chris@141
|
46 connect(m_historyWidget, SIGNAL(commit()),
|
Chris@141
|
47 this, SIGNAL(commit()));
|
Chris@141
|
48
|
Chris@141
|
49 connect(m_historyWidget, SIGNAL(revert()),
|
Chris@141
|
50 this, SIGNAL(revert()));
|
Chris@141
|
51
|
Chris@141
|
52 connect(m_historyWidget, SIGNAL(diffWorkingFolder()),
|
Chris@141
|
53 this, SIGNAL(diffWorkingFolder()));
|
Chris@141
|
54
|
Chris@153
|
55 connect(m_historyWidget, SIGNAL(showWork()),
|
Chris@153
|
56 this, SLOT(showWorkTab()));
|
Chris@153
|
57
|
Chris@141
|
58 connect(m_historyWidget, SIGNAL(updateTo(QString)),
|
Chris@141
|
59 this, SIGNAL(updateTo(QString)));
|
Chris@141
|
60
|
Chris@141
|
61 connect(m_historyWidget, SIGNAL(diffToCurrent(QString)),
|
Chris@141
|
62 this, SIGNAL(diffToCurrent(QString)));
|
Chris@141
|
63
|
Chris@148
|
64 connect(m_historyWidget, SIGNAL(diffToParent(QString, QString)),
|
Chris@148
|
65 this, SIGNAL(diffToParent(QString, QString)));
|
Chris@141
|
66
|
Chris@141
|
67 connect(m_historyWidget, SIGNAL(mergeFrom(QString)),
|
Chris@141
|
68 this, SIGNAL(mergeFrom(QString)));
|
Chris@141
|
69
|
Chris@141
|
70 connect(m_historyWidget, SIGNAL(tag(QString)),
|
Chris@141
|
71 this, SIGNAL(tag(QString)));
|
jtkorhonen@32
|
72 }
|
jtkorhonen@32
|
73
|
Chris@96
|
74 void HgTabWidget::clearSelections()
|
Chris@94
|
75 {
|
Chris@116
|
76 m_fileStatusWidget->clearSelections();
|
Chris@94
|
77 }
|
Chris@94
|
78
|
Chris@153
|
79 void HgTabWidget::setCurrent(QStringList ids, QString branch)
|
Chris@128
|
80 {
|
Chris@163
|
81 bool showUncommitted = false;
|
Chris@163
|
82 if (canRevert()) showUncommitted = true;
|
Chris@163
|
83 m_historyWidget->setCurrent(ids, branch, showUncommitted);
|
Chris@129
|
84 }
|
Chris@129
|
85
|
Chris@154
|
86 void HgTabWidget::updateHistory()
|
Chris@154
|
87 {
|
Chris@154
|
88 m_historyWidget->update();
|
Chris@154
|
89 }
|
Chris@154
|
90
|
Chris@163
|
91 bool HgTabWidget::canDiff() const
|
Chris@163
|
92 {
|
Chris@163
|
93 if (!m_fileStatusWidget->getSelectedAddableFiles().empty()) return false;
|
Chris@163
|
94 return m_fileStatusWidget->haveChangesToCommit() ||
|
Chris@163
|
95 !m_fileStatusWidget->getAllUnresolvedFiles().empty();
|
Chris@163
|
96 }
|
Chris@163
|
97
|
Chris@96
|
98 bool HgTabWidget::canCommit() const
|
Chris@90
|
99 {
|
Chris@116
|
100 if (!m_fileStatusWidget->getSelectedAddableFiles().empty()) return false;
|
Chris@163
|
101 return m_fileStatusWidget->haveChangesToCommit() &&
|
Chris@163
|
102 m_fileStatusWidget->getAllUnresolvedFiles().empty();
|
Chris@90
|
103 }
|
jtkorhonen@0
|
104
|
Chris@109
|
105 bool HgTabWidget::canRevert() const
|
Chris@109
|
106 {
|
Chris@163
|
107 if (!m_fileStatusWidget->getSelectedAddableFiles().empty()) return false;
|
Chris@116
|
108 return m_fileStatusWidget->haveChangesToCommit() ||
|
Chris@163
|
109 !m_fileStatusWidget->getAllUnresolvedFiles().empty();
|
Chris@109
|
110 }
|
Chris@109
|
111
|
Chris@96
|
112 bool HgTabWidget::canAdd() const
|
Chris@95
|
113 {
|
Chris@116
|
114 if (m_fileStatusWidget->getSelectedAddableFiles().empty()) return false;
|
Chris@116
|
115 if (!m_fileStatusWidget->getSelectedCommittableFiles().empty()) return false;
|
Chris@116
|
116 if (!m_fileStatusWidget->getSelectedRemovableFiles().empty()) return false;
|
Chris@95
|
117 return true;
|
Chris@95
|
118 }
|
Chris@95
|
119
|
Chris@96
|
120 bool HgTabWidget::canRemove() const
|
Chris@95
|
121 {
|
Chris@116
|
122 if (m_fileStatusWidget->getSelectedRemovableFiles().empty()) return false;
|
Chris@116
|
123 if (!m_fileStatusWidget->getSelectedAddableFiles().empty()) return false;
|
Chris@95
|
124 return true;
|
Chris@95
|
125 }
|
Chris@95
|
126
|
Chris@163
|
127 bool HgTabWidget::canResolve() const
|
Chris@95
|
128 {
|
Chris@163
|
129 return !m_fileStatusWidget->getSelectedUnresolvedFiles().empty();
|
Chris@95
|
130 }
|
Chris@95
|
131
|
Chris@96
|
132 QStringList HgTabWidget::getAllSelectedFiles() const
|
Chris@95
|
133 {
|
Chris@116
|
134 return m_fileStatusWidget->getAllSelectedFiles();
|
Chris@95
|
135 }
|
Chris@95
|
136
|
Chris@109
|
137 QStringList HgTabWidget::getAllCommittableFiles() const
|
Chris@109
|
138 {
|
Chris@116
|
139 return m_fileStatusWidget->getAllCommittableFiles();
|
Chris@109
|
140 }
|
Chris@109
|
141
|
Chris@96
|
142 QStringList HgTabWidget::getSelectedCommittableFiles() const
|
Chris@95
|
143 {
|
Chris@116
|
144 return m_fileStatusWidget->getSelectedCommittableFiles();
|
Chris@95
|
145 }
|
Chris@95
|
146
|
Chris@109
|
147 QStringList HgTabWidget::getAllRevertableFiles() const
|
Chris@109
|
148 {
|
Chris@116
|
149 return m_fileStatusWidget->getAllRevertableFiles();
|
Chris@109
|
150 }
|
Chris@109
|
151
|
Chris@109
|
152 QStringList HgTabWidget::getSelectedRevertableFiles() const
|
Chris@109
|
153 {
|
Chris@116
|
154 return m_fileStatusWidget->getSelectedRevertableFiles();
|
Chris@109
|
155 }
|
Chris@109
|
156
|
Chris@96
|
157 QStringList HgTabWidget::getSelectedAddableFiles() const
|
Chris@95
|
158 {
|
Chris@116
|
159 return m_fileStatusWidget->getSelectedAddableFiles();
|
Chris@95
|
160 }
|
Chris@95
|
161
|
Chris@109
|
162 QStringList HgTabWidget::getAllRemovableFiles() const
|
Chris@109
|
163 {
|
Chris@116
|
164 return m_fileStatusWidget->getAllRemovableFiles();
|
Chris@109
|
165 }
|
Chris@109
|
166
|
Chris@96
|
167 QStringList HgTabWidget::getSelectedRemovableFiles() const
|
Chris@95
|
168 {
|
Chris@116
|
169 return m_fileStatusWidget->getSelectedRemovableFiles();
|
Chris@95
|
170 }
|
Chris@95
|
171
|
Chris@163
|
172 QStringList HgTabWidget::getAllUnresolvedFiles() const
|
Chris@163
|
173 {
|
Chris@163
|
174 return m_fileStatusWidget->getAllUnresolvedFiles();
|
Chris@163
|
175 }
|
Chris@163
|
176
|
Chris@163
|
177 QStringList HgTabWidget::getSelectedUnresolvedFiles() const
|
Chris@163
|
178 {
|
Chris@163
|
179 return m_fileStatusWidget->getSelectedUnresolvedFiles();
|
Chris@163
|
180 }
|
Chris@163
|
181
|
Chris@96
|
182 void HgTabWidget::updateWorkFolderFileList(QString fileList)
|
jtkorhonen@0
|
183 {
|
Chris@116
|
184 m_fileStates.parseStates(fileList);
|
Chris@116
|
185 m_fileStatusWidget->setFileStates(m_fileStates);
|
jtkorhonen@0
|
186 }
|
jtkorhonen@0
|
187
|
Chris@120
|
188 void HgTabWidget::setNewLog(QString hgLogList)
|
jtkorhonen@0
|
189 {
|
Chris@120
|
190 m_historyWidget->parseNewLog(hgLogList);
|
Chris@134
|
191 if (m_historyWidget->haveNewItems()) {
|
Chris@153
|
192 showHistoryTab();
|
Chris@134
|
193 }
|
Chris@120
|
194 }
|
Chris@120
|
195
|
Chris@120
|
196 void HgTabWidget::addIncrementalLog(QString hgLogList)
|
Chris@120
|
197 {
|
Chris@120
|
198 m_historyWidget->parseIncrementalLog(hgLogList);
|
Chris@134
|
199 if (m_historyWidget->haveNewItems()) {
|
Chris@153
|
200 showHistoryTab();
|
Chris@134
|
201 }
|
jtkorhonen@0
|
202 }
|
jtkorhonen@0
|
203
|
Chris@96
|
204 void HgTabWidget::setWorkFolderAndRepoNames(QString workFolderPath, QString remoteRepoPath)
|
jtkorhonen@0
|
205 {
|
Chris@116
|
206 m_fileStatusWidget->setLocalPath(workFolderPath);
|
Chris@116
|
207 m_fileStatusWidget->setRemoteURL(remoteRepoPath);
|
jtkorhonen@0
|
208 }
|
Chris@106
|
209
|
Chris@115
|
210 void HgTabWidget::setState(QString state)
|
Chris@106
|
211 {
|
Chris@116
|
212 m_fileStatusWidget->setState(state);
|
Chris@106
|
213 }
|
Chris@153
|
214
|
Chris@153
|
215 void HgTabWidget::showWorkTab()
|
Chris@153
|
216 {
|
Chris@153
|
217 setCurrentWidget(m_fileStatusWidget);
|
Chris@153
|
218 }
|
Chris@153
|
219
|
Chris@153
|
220 void HgTabWidget::showHistoryTab()
|
Chris@153
|
221 {
|
Chris@153
|
222 setCurrentWidget(m_historyWidget);
|
Chris@153
|
223 }
|
Chris@153
|
224
|