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@244
|
8 Copyright (c) 2011 Chris Cannam
|
Chris@244
|
9 Copyright (c) 2011 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 workFolderPath) :
|
Chris@117
|
31 QTabWidget(parent)
|
jtkorhonen@0
|
32 {
|
Chris@326
|
33 // Work tab
|
Chris@116
|
34 m_fileStatusWidget = new FileStatusWidget;
|
Chris@116
|
35 m_fileStatusWidget->setLocalPath(workFolderPath);
|
Chris@326
|
36
|
Chris@116
|
37 connect(m_fileStatusWidget, SIGNAL(selectionChanged()),
|
Chris@95
|
38 this, SIGNAL(selectionChanged()));
|
Chris@326
|
39
|
Chris@199
|
40 connect(m_fileStatusWidget, SIGNAL(showAllChanged(bool)),
|
Chris@199
|
41 this, SIGNAL(showAllChanged(bool)));
|
Chris@326
|
42
|
Chris@326
|
43 connect(m_fileStatusWidget, SIGNAL(annotateFiles(QStringList)),
|
Chris@326
|
44 this, SIGNAL(annotateFiles(QStringList)));
|
Chris@326
|
45
|
Chris@326
|
46 connect(m_fileStatusWidget, SIGNAL(diffFiles(QStringList)),
|
Chris@326
|
47 this, SIGNAL(diffFiles(QStringList)));
|
Chris@326
|
48
|
Chris@326
|
49 connect(m_fileStatusWidget, SIGNAL(commitFiles(QStringList)),
|
Chris@326
|
50 this, SIGNAL(commitFiles(QStringList)));
|
Chris@326
|
51
|
Chris@326
|
52 connect(m_fileStatusWidget, SIGNAL(revertFiles(QStringList)),
|
Chris@326
|
53 this, SIGNAL(revertFiles(QStringList)));
|
Chris@326
|
54
|
Chris@326
|
55 connect(m_fileStatusWidget, SIGNAL(addFiles(QStringList)),
|
Chris@326
|
56 this, SIGNAL(addFiles(QStringList)));
|
Chris@326
|
57
|
Chris@326
|
58 connect(m_fileStatusWidget, SIGNAL(removeFiles(QStringList)),
|
Chris@326
|
59 this, SIGNAL(removeFiles(QStringList)));
|
Chris@326
|
60
|
Chris@326
|
61 connect(m_fileStatusWidget, SIGNAL(redoFileMerges(QStringList)),
|
Chris@326
|
62 this, SIGNAL(redoFileMerges(QStringList)));
|
Chris@326
|
63
|
Chris@326
|
64 connect(m_fileStatusWidget, SIGNAL(markFilesResolved(QStringList)),
|
Chris@326
|
65 this, SIGNAL(markFilesResolved(QStringList)));
|
Chris@326
|
66
|
Chris@326
|
67 connect(m_fileStatusWidget, SIGNAL(ignoreFiles(QStringList)),
|
Chris@326
|
68 this, SIGNAL(ignoreFiles(QStringList)));
|
Chris@326
|
69
|
Chris@326
|
70 connect(m_fileStatusWidget, SIGNAL(unIgnoreFiles(QStringList)),
|
Chris@326
|
71 this, SIGNAL(unIgnoreFiles(QStringList)));
|
Chris@326
|
72
|
Chris@116
|
73 addTab(m_fileStatusWidget, tr("My work"));
|
Chris@88
|
74
|
Chris@326
|
75 // History graph tab
|
Chris@116
|
76 m_historyWidget = new HistoryWidget;
|
Chris@116
|
77 addTab(m_historyWidget, tr("History"));
|
Chris@141
|
78
|
Chris@141
|
79 connect(m_historyWidget, SIGNAL(commit()),
|
Chris@141
|
80 this, SIGNAL(commit()));
|
Chris@141
|
81
|
Chris@141
|
82 connect(m_historyWidget, SIGNAL(revert()),
|
Chris@141
|
83 this, SIGNAL(revert()));
|
Chris@141
|
84
|
Chris@168
|
85 connect(m_historyWidget, SIGNAL(showSummary()),
|
Chris@168
|
86 this, SIGNAL(showSummary()));
|
Chris@168
|
87
|
Chris@311
|
88 connect(m_historyWidget, SIGNAL(newBranch()),
|
Chris@311
|
89 this, SIGNAL(newBranch()));
|
Chris@311
|
90
|
Chris@311
|
91 connect(m_historyWidget, SIGNAL(noBranch()),
|
Chris@311
|
92 this, SIGNAL(noBranch()));
|
Chris@311
|
93
|
Chris@141
|
94 connect(m_historyWidget, SIGNAL(diffWorkingFolder()),
|
Chris@141
|
95 this, SIGNAL(diffWorkingFolder()));
|
Chris@141
|
96
|
Chris@153
|
97 connect(m_historyWidget, SIGNAL(showWork()),
|
Chris@153
|
98 this, SLOT(showWorkTab()));
|
Chris@153
|
99
|
Chris@141
|
100 connect(m_historyWidget, SIGNAL(updateTo(QString)),
|
Chris@141
|
101 this, SIGNAL(updateTo(QString)));
|
Chris@141
|
102
|
Chris@141
|
103 connect(m_historyWidget, SIGNAL(diffToCurrent(QString)),
|
Chris@141
|
104 this, SIGNAL(diffToCurrent(QString)));
|
Chris@141
|
105
|
Chris@148
|
106 connect(m_historyWidget, SIGNAL(diffToParent(QString, QString)),
|
Chris@148
|
107 this, SIGNAL(diffToParent(QString, QString)));
|
Chris@141
|
108
|
Chris@289
|
109 connect(m_historyWidget, SIGNAL(showSummary(Changeset *)),
|
Chris@289
|
110 this, SIGNAL(showSummary(Changeset *)));
|
Chris@288
|
111
|
Chris@141
|
112 connect(m_historyWidget, SIGNAL(mergeFrom(QString)),
|
Chris@141
|
113 this, SIGNAL(mergeFrom(QString)));
|
Chris@141
|
114
|
Chris@278
|
115 connect(m_historyWidget, SIGNAL(newBranch(QString)),
|
Chris@278
|
116 this, SIGNAL(newBranch(QString)));
|
Chris@278
|
117
|
Chris@141
|
118 connect(m_historyWidget, SIGNAL(tag(QString)),
|
Chris@141
|
119 this, SIGNAL(tag(QString)));
|
jtkorhonen@32
|
120 }
|
jtkorhonen@32
|
121
|
Chris@96
|
122 void HgTabWidget::clearSelections()
|
Chris@94
|
123 {
|
Chris@116
|
124 m_fileStatusWidget->clearSelections();
|
Chris@94
|
125 }
|
Chris@94
|
126
|
Chris@153
|
127 void HgTabWidget::setCurrent(QStringList ids, QString branch)
|
Chris@128
|
128 {
|
Chris@172
|
129 bool showUncommitted = haveChangesToCommit();
|
Chris@163
|
130 m_historyWidget->setCurrent(ids, branch, showUncommitted);
|
Chris@129
|
131 }
|
Chris@129
|
132
|
Chris@230
|
133 void HgTabWidget::updateFileStates()
|
Chris@230
|
134 {
|
Chris@230
|
135 m_fileStatusWidget->updateWidgets();
|
Chris@230
|
136 }
|
Chris@230
|
137
|
Chris@154
|
138 void HgTabWidget::updateHistory()
|
Chris@154
|
139 {
|
Chris@154
|
140 m_historyWidget->update();
|
Chris@154
|
141 }
|
Chris@154
|
142
|
Chris@163
|
143 bool HgTabWidget::canDiff() const
|
Chris@163
|
144 {
|
Chris@237
|
145 return canRevert();
|
Chris@163
|
146 }
|
Chris@163
|
147
|
Chris@96
|
148 bool HgTabWidget::canCommit() const
|
Chris@90
|
149 {
|
Chris@237
|
150 if (!m_fileStatusWidget->haveChangesToCommit()) return false;
|
Chris@237
|
151 if (!m_fileStatusWidget->getAllUnresolvedFiles().empty()) return false;
|
Chris@326
|
152 return true;
|
Chris@90
|
153 }
|
jtkorhonen@0
|
154
|
Chris@109
|
155 bool HgTabWidget::canRevert() const
|
Chris@109
|
156 {
|
Chris@237
|
157 // Not the same as canCommit() -- we can revert (and diff)
|
Chris@237
|
158 // unresolved files, but we can't commit them
|
Chris@237
|
159 if (!m_fileStatusWidget->haveChangesToCommit() &&
|
Chris@237
|
160 m_fileStatusWidget->getAllUnresolvedFiles().empty()) return false;
|
Chris@326
|
161 return true;
|
Chris@109
|
162 }
|
Chris@109
|
163
|
Chris@96
|
164 bool HgTabWidget::canAdd() const
|
Chris@95
|
165 {
|
Chris@204
|
166 QStringList addable = m_fileStatusWidget->getSelectedAddableFiles();
|
Chris@204
|
167 if (addable.empty()) return false;
|
Chris@204
|
168
|
Chris@204
|
169 QStringList removable = m_fileStatusWidget->getSelectedRemovableFiles();
|
Chris@204
|
170 if (!removable.empty()) return false;
|
Chris@204
|
171
|
Chris@326
|
172 return true;
|
Chris@95
|
173 }
|
Chris@95
|
174
|
Chris@96
|
175 bool HgTabWidget::canRemove() const
|
Chris@95
|
176 {
|
Chris@116
|
177 if (m_fileStatusWidget->getSelectedRemovableFiles().empty()) return false;
|
Chris@116
|
178 if (!m_fileStatusWidget->getSelectedAddableFiles().empty()) return false;
|
Chris@95
|
179 return true;
|
Chris@95
|
180 }
|
Chris@95
|
181
|
Chris@163
|
182 bool HgTabWidget::canResolve() const
|
Chris@95
|
183 {
|
Chris@326
|
184 return !m_fileStatusWidget->getAllUnresolvedFiles().empty();
|
Chris@95
|
185 }
|
Chris@95
|
186
|
Chris@172
|
187 bool HgTabWidget::haveChangesToCommit() const
|
Chris@172
|
188 {
|
Chris@172
|
189 return m_fileStatusWidget->haveChangesToCommit();
|
Chris@172
|
190 }
|
Chris@172
|
191
|
Chris@109
|
192 QStringList HgTabWidget::getAllCommittableFiles() const
|
Chris@109
|
193 {
|
Chris@116
|
194 return m_fileStatusWidget->getAllCommittableFiles();
|
Chris@109
|
195 }
|
Chris@109
|
196
|
Chris@109
|
197 QStringList HgTabWidget::getAllRevertableFiles() const
|
Chris@109
|
198 {
|
Chris@116
|
199 return m_fileStatusWidget->getAllRevertableFiles();
|
Chris@109
|
200 }
|
Chris@109
|
201
|
Chris@96
|
202 QStringList HgTabWidget::getSelectedAddableFiles() const
|
Chris@95
|
203 {
|
Chris@116
|
204 return m_fileStatusWidget->getSelectedAddableFiles();
|
Chris@95
|
205 }
|
Chris@95
|
206
|
Chris@96
|
207 QStringList HgTabWidget::getSelectedRemovableFiles() const
|
Chris@95
|
208 {
|
Chris@116
|
209 return m_fileStatusWidget->getSelectedRemovableFiles();
|
Chris@95
|
210 }
|
Chris@95
|
211
|
Chris@163
|
212 QStringList HgTabWidget::getAllUnresolvedFiles() const
|
Chris@163
|
213 {
|
Chris@163
|
214 return m_fileStatusWidget->getAllUnresolvedFiles();
|
Chris@163
|
215 }
|
Chris@163
|
216
|
Chris@96
|
217 void HgTabWidget::updateWorkFolderFileList(QString fileList)
|
jtkorhonen@0
|
218 {
|
Chris@116
|
219 m_fileStates.parseStates(fileList);
|
Chris@116
|
220 m_fileStatusWidget->setFileStates(m_fileStates);
|
jtkorhonen@0
|
221 }
|
jtkorhonen@0
|
222
|
Chris@120
|
223 void HgTabWidget::setNewLog(QString hgLogList)
|
jtkorhonen@0
|
224 {
|
Chris@120
|
225 m_historyWidget->parseNewLog(hgLogList);
|
Chris@134
|
226 if (m_historyWidget->haveNewItems()) {
|
Chris@153
|
227 showHistoryTab();
|
Chris@134
|
228 }
|
Chris@120
|
229 }
|
Chris@120
|
230
|
Chris@120
|
231 void HgTabWidget::addIncrementalLog(QString hgLogList)
|
Chris@120
|
232 {
|
Chris@120
|
233 m_historyWidget->parseIncrementalLog(hgLogList);
|
Chris@134
|
234 if (m_historyWidget->haveNewItems()) {
|
Chris@153
|
235 showHistoryTab();
|
Chris@134
|
236 }
|
jtkorhonen@0
|
237 }
|
jtkorhonen@0
|
238
|
Chris@287
|
239 void HgTabWidget::setLocalPath(QString workFolderPath)
|
jtkorhonen@0
|
240 {
|
Chris@116
|
241 m_fileStatusWidget->setLocalPath(workFolderPath);
|
Chris@106
|
242 }
|
Chris@153
|
243
|
Chris@153
|
244 void HgTabWidget::showWorkTab()
|
Chris@153
|
245 {
|
Chris@153
|
246 setCurrentWidget(m_fileStatusWidget);
|
Chris@153
|
247 }
|
Chris@153
|
248
|
Chris@153
|
249 void HgTabWidget::showHistoryTab()
|
Chris@153
|
250 {
|
Chris@153
|
251 setCurrentWidget(m_historyWidget);
|
Chris@153
|
252 }
|
Chris@153
|
253
|