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