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@141
|
55 connect(m_historyWidget, SIGNAL(updateTo(QString)),
|
Chris@141
|
56 this, SIGNAL(updateTo(QString)));
|
Chris@141
|
57
|
Chris@141
|
58 connect(m_historyWidget, SIGNAL(diffToCurrent(QString)),
|
Chris@141
|
59 this, SIGNAL(diffToCurrent(QString)));
|
Chris@141
|
60
|
Chris@148
|
61 connect(m_historyWidget, SIGNAL(diffToParent(QString, QString)),
|
Chris@148
|
62 this, SIGNAL(diffToParent(QString, QString)));
|
Chris@141
|
63
|
Chris@141
|
64 connect(m_historyWidget, SIGNAL(mergeFrom(QString)),
|
Chris@141
|
65 this, SIGNAL(mergeFrom(QString)));
|
Chris@141
|
66
|
Chris@141
|
67 connect(m_historyWidget, SIGNAL(tag(QString)),
|
Chris@141
|
68 this, SIGNAL(tag(QString)));
|
jtkorhonen@32
|
69 }
|
jtkorhonen@32
|
70
|
Chris@96
|
71 void HgTabWidget::clearSelections()
|
Chris@94
|
72 {
|
Chris@116
|
73 m_fileStatusWidget->clearSelections();
|
Chris@94
|
74 }
|
Chris@94
|
75
|
Chris@145
|
76 void HgTabWidget::setCurrent(QStringList ids, bool showUncommittedChanges)
|
Chris@128
|
77 {
|
Chris@145
|
78 m_historyWidget->setCurrent(ids, showUncommittedChanges);
|
Chris@129
|
79 }
|
Chris@129
|
80
|
Chris@96
|
81 bool HgTabWidget::canCommit() const
|
Chris@90
|
82 {
|
Chris@116
|
83 if (!m_fileStatusWidget->getSelectedAddableFiles().empty()) return false;
|
Chris@116
|
84 return m_fileStatusWidget->haveChangesToCommit();
|
Chris@90
|
85 }
|
jtkorhonen@0
|
86
|
Chris@109
|
87 bool HgTabWidget::canRevert() const
|
Chris@109
|
88 {
|
Chris@116
|
89 return m_fileStatusWidget->haveChangesToCommit() ||
|
Chris@116
|
90 !m_fileStatusWidget->getSelectedRevertableFiles().empty();
|
Chris@109
|
91 }
|
Chris@109
|
92
|
Chris@96
|
93 bool HgTabWidget::canAdd() const
|
Chris@95
|
94 {
|
Chris@116
|
95 if (m_fileStatusWidget->getSelectedAddableFiles().empty()) return false;
|
Chris@116
|
96 if (!m_fileStatusWidget->getSelectedCommittableFiles().empty()) return false;
|
Chris@116
|
97 if (!m_fileStatusWidget->getSelectedRemovableFiles().empty()) return false;
|
Chris@95
|
98 return true;
|
Chris@95
|
99 }
|
Chris@95
|
100
|
Chris@96
|
101 bool HgTabWidget::canRemove() const
|
Chris@95
|
102 {
|
Chris@116
|
103 if (m_fileStatusWidget->getSelectedRemovableFiles().empty()) return false;
|
Chris@116
|
104 if (!m_fileStatusWidget->getSelectedAddableFiles().empty()) return false;
|
Chris@95
|
105 return true;
|
Chris@95
|
106 }
|
Chris@95
|
107
|
Chris@96
|
108 bool HgTabWidget::canDoDiff() const
|
Chris@95
|
109 {
|
Chris@95
|
110 return canCommit();
|
Chris@95
|
111 }
|
Chris@95
|
112
|
Chris@96
|
113 QStringList HgTabWidget::getAllSelectedFiles() const
|
Chris@95
|
114 {
|
Chris@116
|
115 return m_fileStatusWidget->getAllSelectedFiles();
|
Chris@95
|
116 }
|
Chris@95
|
117
|
Chris@109
|
118 QStringList HgTabWidget::getAllCommittableFiles() const
|
Chris@109
|
119 {
|
Chris@116
|
120 return m_fileStatusWidget->getAllCommittableFiles();
|
Chris@109
|
121 }
|
Chris@109
|
122
|
Chris@96
|
123 QStringList HgTabWidget::getSelectedCommittableFiles() const
|
Chris@95
|
124 {
|
Chris@116
|
125 return m_fileStatusWidget->getSelectedCommittableFiles();
|
Chris@95
|
126 }
|
Chris@95
|
127
|
Chris@109
|
128 QStringList HgTabWidget::getAllRevertableFiles() const
|
Chris@109
|
129 {
|
Chris@116
|
130 return m_fileStatusWidget->getAllRevertableFiles();
|
Chris@109
|
131 }
|
Chris@109
|
132
|
Chris@109
|
133 QStringList HgTabWidget::getSelectedRevertableFiles() const
|
Chris@109
|
134 {
|
Chris@116
|
135 return m_fileStatusWidget->getSelectedRevertableFiles();
|
Chris@109
|
136 }
|
Chris@109
|
137
|
Chris@96
|
138 QStringList HgTabWidget::getSelectedAddableFiles() const
|
Chris@95
|
139 {
|
Chris@116
|
140 return m_fileStatusWidget->getSelectedAddableFiles();
|
Chris@95
|
141 }
|
Chris@95
|
142
|
Chris@109
|
143 QStringList HgTabWidget::getAllRemovableFiles() const
|
Chris@109
|
144 {
|
Chris@116
|
145 return m_fileStatusWidget->getAllRemovableFiles();
|
Chris@109
|
146 }
|
Chris@109
|
147
|
Chris@96
|
148 QStringList HgTabWidget::getSelectedRemovableFiles() const
|
Chris@95
|
149 {
|
Chris@116
|
150 return m_fileStatusWidget->getSelectedRemovableFiles();
|
Chris@95
|
151 }
|
Chris@95
|
152
|
Chris@96
|
153 void HgTabWidget::updateWorkFolderFileList(QString fileList)
|
jtkorhonen@0
|
154 {
|
Chris@116
|
155 m_fileStates.parseStates(fileList);
|
Chris@116
|
156 m_fileStatusWidget->setFileStates(m_fileStates);
|
jtkorhonen@0
|
157 }
|
jtkorhonen@0
|
158
|
Chris@120
|
159 void HgTabWidget::setNewLog(QString hgLogList)
|
jtkorhonen@0
|
160 {
|
Chris@120
|
161 m_historyWidget->parseNewLog(hgLogList);
|
Chris@134
|
162 if (m_historyWidget->haveNewItems()) {
|
Chris@134
|
163 setCurrentWidget(m_historyWidget);
|
Chris@134
|
164 }
|
Chris@120
|
165 }
|
Chris@120
|
166
|
Chris@120
|
167 void HgTabWidget::addIncrementalLog(QString hgLogList)
|
Chris@120
|
168 {
|
Chris@120
|
169 m_historyWidget->parseIncrementalLog(hgLogList);
|
Chris@134
|
170 if (m_historyWidget->haveNewItems()) {
|
Chris@134
|
171 setCurrentWidget(m_historyWidget);
|
Chris@134
|
172 }
|
jtkorhonen@0
|
173 }
|
jtkorhonen@0
|
174
|
Chris@96
|
175 void HgTabWidget::setWorkFolderAndRepoNames(QString workFolderPath, QString remoteRepoPath)
|
jtkorhonen@0
|
176 {
|
Chris@116
|
177 m_fileStatusWidget->setLocalPath(workFolderPath);
|
Chris@116
|
178 m_fileStatusWidget->setRemoteURL(remoteRepoPath);
|
jtkorhonen@0
|
179 }
|
Chris@106
|
180
|
Chris@115
|
181 void HgTabWidget::setState(QString state)
|
Chris@106
|
182 {
|
Chris@116
|
183 m_fileStatusWidget->setState(state);
|
Chris@106
|
184 }
|