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@168
|
52 connect(m_historyWidget, SIGNAL(showSummary()),
|
Chris@168
|
53 this, SIGNAL(showSummary()));
|
Chris@168
|
54
|
Chris@141
|
55 connect(m_historyWidget, SIGNAL(diffWorkingFolder()),
|
Chris@141
|
56 this, SIGNAL(diffWorkingFolder()));
|
Chris@141
|
57
|
Chris@153
|
58 connect(m_historyWidget, SIGNAL(showWork()),
|
Chris@153
|
59 this, SLOT(showWorkTab()));
|
Chris@153
|
60
|
Chris@141
|
61 connect(m_historyWidget, SIGNAL(updateTo(QString)),
|
Chris@141
|
62 this, SIGNAL(updateTo(QString)));
|
Chris@141
|
63
|
Chris@141
|
64 connect(m_historyWidget, SIGNAL(diffToCurrent(QString)),
|
Chris@141
|
65 this, SIGNAL(diffToCurrent(QString)));
|
Chris@141
|
66
|
Chris@148
|
67 connect(m_historyWidget, SIGNAL(diffToParent(QString, QString)),
|
Chris@148
|
68 this, SIGNAL(diffToParent(QString, QString)));
|
Chris@141
|
69
|
Chris@141
|
70 connect(m_historyWidget, SIGNAL(mergeFrom(QString)),
|
Chris@141
|
71 this, SIGNAL(mergeFrom(QString)));
|
Chris@141
|
72
|
Chris@141
|
73 connect(m_historyWidget, SIGNAL(tag(QString)),
|
Chris@141
|
74 this, SIGNAL(tag(QString)));
|
jtkorhonen@32
|
75 }
|
jtkorhonen@32
|
76
|
Chris@96
|
77 void HgTabWidget::clearSelections()
|
Chris@94
|
78 {
|
Chris@116
|
79 m_fileStatusWidget->clearSelections();
|
Chris@94
|
80 }
|
Chris@94
|
81
|
Chris@153
|
82 void HgTabWidget::setCurrent(QStringList ids, QString branch)
|
Chris@128
|
83 {
|
Chris@172
|
84 bool showUncommitted = haveChangesToCommit();
|
Chris@163
|
85 m_historyWidget->setCurrent(ids, branch, showUncommitted);
|
Chris@129
|
86 }
|
Chris@129
|
87
|
Chris@154
|
88 void HgTabWidget::updateHistory()
|
Chris@154
|
89 {
|
Chris@154
|
90 m_historyWidget->update();
|
Chris@154
|
91 }
|
Chris@154
|
92
|
Chris@163
|
93 bool HgTabWidget::canDiff() const
|
Chris@163
|
94 {
|
Chris@163
|
95 if (!m_fileStatusWidget->getSelectedAddableFiles().empty()) return false;
|
Chris@163
|
96 return m_fileStatusWidget->haveChangesToCommit() ||
|
Chris@163
|
97 !m_fileStatusWidget->getAllUnresolvedFiles().empty();
|
Chris@163
|
98 }
|
Chris@163
|
99
|
Chris@96
|
100 bool HgTabWidget::canCommit() const
|
Chris@90
|
101 {
|
Chris@116
|
102 if (!m_fileStatusWidget->getSelectedAddableFiles().empty()) return false;
|
Chris@163
|
103 return m_fileStatusWidget->haveChangesToCommit() &&
|
Chris@163
|
104 m_fileStatusWidget->getAllUnresolvedFiles().empty();
|
Chris@90
|
105 }
|
jtkorhonen@0
|
106
|
Chris@109
|
107 bool HgTabWidget::canRevert() const
|
Chris@109
|
108 {
|
Chris@163
|
109 if (!m_fileStatusWidget->getSelectedAddableFiles().empty()) return false;
|
Chris@116
|
110 return m_fileStatusWidget->haveChangesToCommit() ||
|
Chris@163
|
111 !m_fileStatusWidget->getAllUnresolvedFiles().empty();
|
Chris@109
|
112 }
|
Chris@109
|
113
|
Chris@96
|
114 bool HgTabWidget::canAdd() const
|
Chris@95
|
115 {
|
Chris@116
|
116 if (m_fileStatusWidget->getSelectedAddableFiles().empty()) return false;
|
Chris@116
|
117 if (!m_fileStatusWidget->getSelectedCommittableFiles().empty()) return false;
|
Chris@116
|
118 if (!m_fileStatusWidget->getSelectedRemovableFiles().empty()) return false;
|
Chris@95
|
119 return true;
|
Chris@95
|
120 }
|
Chris@95
|
121
|
Chris@96
|
122 bool HgTabWidget::canRemove() const
|
Chris@95
|
123 {
|
Chris@116
|
124 if (m_fileStatusWidget->getSelectedRemovableFiles().empty()) return false;
|
Chris@116
|
125 if (!m_fileStatusWidget->getSelectedAddableFiles().empty()) return false;
|
Chris@95
|
126 return true;
|
Chris@95
|
127 }
|
Chris@95
|
128
|
Chris@163
|
129 bool HgTabWidget::canResolve() const
|
Chris@95
|
130 {
|
Chris@163
|
131 return !m_fileStatusWidget->getSelectedUnresolvedFiles().empty();
|
Chris@95
|
132 }
|
Chris@95
|
133
|
Chris@172
|
134 bool HgTabWidget::haveChangesToCommit() const
|
Chris@172
|
135 {
|
Chris@172
|
136 return m_fileStatusWidget->haveChangesToCommit();
|
Chris@172
|
137 }
|
Chris@172
|
138
|
Chris@96
|
139 QStringList HgTabWidget::getAllSelectedFiles() const
|
Chris@95
|
140 {
|
Chris@116
|
141 return m_fileStatusWidget->getAllSelectedFiles();
|
Chris@95
|
142 }
|
Chris@95
|
143
|
Chris@109
|
144 QStringList HgTabWidget::getAllCommittableFiles() const
|
Chris@109
|
145 {
|
Chris@116
|
146 return m_fileStatusWidget->getAllCommittableFiles();
|
Chris@109
|
147 }
|
Chris@109
|
148
|
Chris@96
|
149 QStringList HgTabWidget::getSelectedCommittableFiles() const
|
Chris@95
|
150 {
|
Chris@116
|
151 return m_fileStatusWidget->getSelectedCommittableFiles();
|
Chris@95
|
152 }
|
Chris@95
|
153
|
Chris@109
|
154 QStringList HgTabWidget::getAllRevertableFiles() const
|
Chris@109
|
155 {
|
Chris@116
|
156 return m_fileStatusWidget->getAllRevertableFiles();
|
Chris@109
|
157 }
|
Chris@109
|
158
|
Chris@109
|
159 QStringList HgTabWidget::getSelectedRevertableFiles() const
|
Chris@109
|
160 {
|
Chris@116
|
161 return m_fileStatusWidget->getSelectedRevertableFiles();
|
Chris@109
|
162 }
|
Chris@109
|
163
|
Chris@96
|
164 QStringList HgTabWidget::getSelectedAddableFiles() const
|
Chris@95
|
165 {
|
Chris@116
|
166 return m_fileStatusWidget->getSelectedAddableFiles();
|
Chris@95
|
167 }
|
Chris@95
|
168
|
Chris@109
|
169 QStringList HgTabWidget::getAllRemovableFiles() const
|
Chris@109
|
170 {
|
Chris@116
|
171 return m_fileStatusWidget->getAllRemovableFiles();
|
Chris@109
|
172 }
|
Chris@109
|
173
|
Chris@96
|
174 QStringList HgTabWidget::getSelectedRemovableFiles() const
|
Chris@95
|
175 {
|
Chris@116
|
176 return m_fileStatusWidget->getSelectedRemovableFiles();
|
Chris@95
|
177 }
|
Chris@95
|
178
|
Chris@163
|
179 QStringList HgTabWidget::getAllUnresolvedFiles() const
|
Chris@163
|
180 {
|
Chris@163
|
181 return m_fileStatusWidget->getAllUnresolvedFiles();
|
Chris@163
|
182 }
|
Chris@163
|
183
|
Chris@163
|
184 QStringList HgTabWidget::getSelectedUnresolvedFiles() const
|
Chris@163
|
185 {
|
Chris@163
|
186 return m_fileStatusWidget->getSelectedUnresolvedFiles();
|
Chris@163
|
187 }
|
Chris@163
|
188
|
Chris@96
|
189 void HgTabWidget::updateWorkFolderFileList(QString fileList)
|
jtkorhonen@0
|
190 {
|
Chris@116
|
191 m_fileStates.parseStates(fileList);
|
Chris@116
|
192 m_fileStatusWidget->setFileStates(m_fileStates);
|
jtkorhonen@0
|
193 }
|
jtkorhonen@0
|
194
|
Chris@120
|
195 void HgTabWidget::setNewLog(QString hgLogList)
|
jtkorhonen@0
|
196 {
|
Chris@120
|
197 m_historyWidget->parseNewLog(hgLogList);
|
Chris@134
|
198 if (m_historyWidget->haveNewItems()) {
|
Chris@153
|
199 showHistoryTab();
|
Chris@134
|
200 }
|
Chris@120
|
201 }
|
Chris@120
|
202
|
Chris@120
|
203 void HgTabWidget::addIncrementalLog(QString hgLogList)
|
Chris@120
|
204 {
|
Chris@120
|
205 m_historyWidget->parseIncrementalLog(hgLogList);
|
Chris@134
|
206 if (m_historyWidget->haveNewItems()) {
|
Chris@153
|
207 showHistoryTab();
|
Chris@134
|
208 }
|
jtkorhonen@0
|
209 }
|
jtkorhonen@0
|
210
|
Chris@96
|
211 void HgTabWidget::setWorkFolderAndRepoNames(QString workFolderPath, QString remoteRepoPath)
|
jtkorhonen@0
|
212 {
|
Chris@116
|
213 m_fileStatusWidget->setLocalPath(workFolderPath);
|
Chris@116
|
214 m_fileStatusWidget->setRemoteURL(remoteRepoPath);
|
jtkorhonen@0
|
215 }
|
Chris@106
|
216
|
Chris@115
|
217 void HgTabWidget::setState(QString state)
|
Chris@106
|
218 {
|
Chris@116
|
219 m_fileStatusWidget->setState(state);
|
Chris@106
|
220 }
|
Chris@153
|
221
|
Chris@153
|
222 void HgTabWidget::showWorkTab()
|
Chris@153
|
223 {
|
Chris@153
|
224 setCurrentWidget(m_fileStatusWidget);
|
Chris@153
|
225 }
|
Chris@153
|
226
|
Chris@153
|
227 void HgTabWidget::showHistoryTab()
|
Chris@153
|
228 {
|
Chris@153
|
229 setCurrentWidget(m_historyWidget);
|
Chris@153
|
230 }
|
Chris@153
|
231
|