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@153
|
81 m_historyWidget->setCurrent(ids, branch, canCommit());
|
Chris@129
|
82 }
|
Chris@129
|
83
|
Chris@154
|
84 void HgTabWidget::updateHistory()
|
Chris@154
|
85 {
|
Chris@154
|
86 m_historyWidget->update();
|
Chris@154
|
87 }
|
Chris@154
|
88
|
Chris@96
|
89 bool HgTabWidget::canCommit() const
|
Chris@90
|
90 {
|
Chris@116
|
91 if (!m_fileStatusWidget->getSelectedAddableFiles().empty()) return false;
|
Chris@116
|
92 return m_fileStatusWidget->haveChangesToCommit();
|
Chris@90
|
93 }
|
jtkorhonen@0
|
94
|
Chris@109
|
95 bool HgTabWidget::canRevert() const
|
Chris@109
|
96 {
|
Chris@116
|
97 return m_fileStatusWidget->haveChangesToCommit() ||
|
Chris@116
|
98 !m_fileStatusWidget->getSelectedRevertableFiles().empty();
|
Chris@109
|
99 }
|
Chris@109
|
100
|
Chris@96
|
101 bool HgTabWidget::canAdd() const
|
Chris@95
|
102 {
|
Chris@116
|
103 if (m_fileStatusWidget->getSelectedAddableFiles().empty()) return false;
|
Chris@116
|
104 if (!m_fileStatusWidget->getSelectedCommittableFiles().empty()) return false;
|
Chris@116
|
105 if (!m_fileStatusWidget->getSelectedRemovableFiles().empty()) return false;
|
Chris@95
|
106 return true;
|
Chris@95
|
107 }
|
Chris@95
|
108
|
Chris@96
|
109 bool HgTabWidget::canRemove() const
|
Chris@95
|
110 {
|
Chris@116
|
111 if (m_fileStatusWidget->getSelectedRemovableFiles().empty()) return false;
|
Chris@116
|
112 if (!m_fileStatusWidget->getSelectedAddableFiles().empty()) return false;
|
Chris@95
|
113 return true;
|
Chris@95
|
114 }
|
Chris@95
|
115
|
Chris@96
|
116 bool HgTabWidget::canDoDiff() const
|
Chris@95
|
117 {
|
Chris@95
|
118 return canCommit();
|
Chris@95
|
119 }
|
Chris@95
|
120
|
Chris@96
|
121 QStringList HgTabWidget::getAllSelectedFiles() const
|
Chris@95
|
122 {
|
Chris@116
|
123 return m_fileStatusWidget->getAllSelectedFiles();
|
Chris@95
|
124 }
|
Chris@95
|
125
|
Chris@109
|
126 QStringList HgTabWidget::getAllCommittableFiles() const
|
Chris@109
|
127 {
|
Chris@116
|
128 return m_fileStatusWidget->getAllCommittableFiles();
|
Chris@109
|
129 }
|
Chris@109
|
130
|
Chris@96
|
131 QStringList HgTabWidget::getSelectedCommittableFiles() const
|
Chris@95
|
132 {
|
Chris@116
|
133 return m_fileStatusWidget->getSelectedCommittableFiles();
|
Chris@95
|
134 }
|
Chris@95
|
135
|
Chris@109
|
136 QStringList HgTabWidget::getAllRevertableFiles() const
|
Chris@109
|
137 {
|
Chris@116
|
138 return m_fileStatusWidget->getAllRevertableFiles();
|
Chris@109
|
139 }
|
Chris@109
|
140
|
Chris@109
|
141 QStringList HgTabWidget::getSelectedRevertableFiles() const
|
Chris@109
|
142 {
|
Chris@116
|
143 return m_fileStatusWidget->getSelectedRevertableFiles();
|
Chris@109
|
144 }
|
Chris@109
|
145
|
Chris@96
|
146 QStringList HgTabWidget::getSelectedAddableFiles() const
|
Chris@95
|
147 {
|
Chris@116
|
148 return m_fileStatusWidget->getSelectedAddableFiles();
|
Chris@95
|
149 }
|
Chris@95
|
150
|
Chris@109
|
151 QStringList HgTabWidget::getAllRemovableFiles() const
|
Chris@109
|
152 {
|
Chris@116
|
153 return m_fileStatusWidget->getAllRemovableFiles();
|
Chris@109
|
154 }
|
Chris@109
|
155
|
Chris@96
|
156 QStringList HgTabWidget::getSelectedRemovableFiles() const
|
Chris@95
|
157 {
|
Chris@116
|
158 return m_fileStatusWidget->getSelectedRemovableFiles();
|
Chris@95
|
159 }
|
Chris@95
|
160
|
Chris@96
|
161 void HgTabWidget::updateWorkFolderFileList(QString fileList)
|
jtkorhonen@0
|
162 {
|
Chris@116
|
163 m_fileStates.parseStates(fileList);
|
Chris@116
|
164 m_fileStatusWidget->setFileStates(m_fileStates);
|
jtkorhonen@0
|
165 }
|
jtkorhonen@0
|
166
|
Chris@120
|
167 void HgTabWidget::setNewLog(QString hgLogList)
|
jtkorhonen@0
|
168 {
|
Chris@120
|
169 m_historyWidget->parseNewLog(hgLogList);
|
Chris@134
|
170 if (m_historyWidget->haveNewItems()) {
|
Chris@153
|
171 showHistoryTab();
|
Chris@134
|
172 }
|
Chris@120
|
173 }
|
Chris@120
|
174
|
Chris@120
|
175 void HgTabWidget::addIncrementalLog(QString hgLogList)
|
Chris@120
|
176 {
|
Chris@120
|
177 m_historyWidget->parseIncrementalLog(hgLogList);
|
Chris@134
|
178 if (m_historyWidget->haveNewItems()) {
|
Chris@153
|
179 showHistoryTab();
|
Chris@134
|
180 }
|
jtkorhonen@0
|
181 }
|
jtkorhonen@0
|
182
|
Chris@96
|
183 void HgTabWidget::setWorkFolderAndRepoNames(QString workFolderPath, QString remoteRepoPath)
|
jtkorhonen@0
|
184 {
|
Chris@116
|
185 m_fileStatusWidget->setLocalPath(workFolderPath);
|
Chris@116
|
186 m_fileStatusWidget->setRemoteURL(remoteRepoPath);
|
jtkorhonen@0
|
187 }
|
Chris@106
|
188
|
Chris@115
|
189 void HgTabWidget::setState(QString state)
|
Chris@106
|
190 {
|
Chris@116
|
191 m_fileStatusWidget->setState(state);
|
Chris@106
|
192 }
|
Chris@153
|
193
|
Chris@153
|
194 void HgTabWidget::showWorkTab()
|
Chris@153
|
195 {
|
Chris@153
|
196 setCurrentWidget(m_fileStatusWidget);
|
Chris@153
|
197 }
|
Chris@153
|
198
|
Chris@153
|
199 void HgTabWidget::showHistoryTab()
|
Chris@153
|
200 {
|
Chris@153
|
201 setCurrentWidget(m_historyWidget);
|
Chris@153
|
202 }
|
Chris@153
|
203
|