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"));
|
jtkorhonen@32
|
45 }
|
jtkorhonen@32
|
46
|
Chris@96
|
47 void HgTabWidget::clearSelections()
|
Chris@94
|
48 {
|
Chris@116
|
49 m_fileStatusWidget->clearSelections();
|
Chris@94
|
50 }
|
Chris@94
|
51
|
Chris@128
|
52 void HgTabWidget::setCurrent(QStringList ids)
|
Chris@128
|
53 {
|
Chris@128
|
54 m_historyWidget->setCurrent(ids);
|
Chris@128
|
55 }
|
Chris@128
|
56
|
Chris@129
|
57 void HgTabWidget::showUncommittedChanges(bool u)
|
Chris@129
|
58 {
|
Chris@129
|
59 m_historyWidget->showUncommittedChanges(u);
|
Chris@129
|
60 }
|
Chris@129
|
61
|
Chris@96
|
62 bool HgTabWidget::canCommit() const
|
Chris@90
|
63 {
|
Chris@116
|
64 if (!m_fileStatusWidget->getSelectedAddableFiles().empty()) return false;
|
Chris@116
|
65 return m_fileStatusWidget->haveChangesToCommit();
|
Chris@90
|
66 }
|
jtkorhonen@0
|
67
|
Chris@109
|
68 bool HgTabWidget::canRevert() const
|
Chris@109
|
69 {
|
Chris@116
|
70 return m_fileStatusWidget->haveChangesToCommit() ||
|
Chris@116
|
71 !m_fileStatusWidget->getSelectedRevertableFiles().empty();
|
Chris@109
|
72 }
|
Chris@109
|
73
|
Chris@96
|
74 bool HgTabWidget::canAdd() const
|
Chris@95
|
75 {
|
Chris@116
|
76 if (m_fileStatusWidget->getSelectedAddableFiles().empty()) return false;
|
Chris@116
|
77 if (!m_fileStatusWidget->getSelectedCommittableFiles().empty()) return false;
|
Chris@116
|
78 if (!m_fileStatusWidget->getSelectedRemovableFiles().empty()) return false;
|
Chris@95
|
79 return true;
|
Chris@95
|
80 }
|
Chris@95
|
81
|
Chris@96
|
82 bool HgTabWidget::canRemove() const
|
Chris@95
|
83 {
|
Chris@116
|
84 if (m_fileStatusWidget->getSelectedRemovableFiles().empty()) return false;
|
Chris@116
|
85 if (!m_fileStatusWidget->getSelectedAddableFiles().empty()) return false;
|
Chris@95
|
86 return true;
|
Chris@95
|
87 }
|
Chris@95
|
88
|
Chris@96
|
89 bool HgTabWidget::canDoDiff() const
|
Chris@95
|
90 {
|
Chris@95
|
91 return canCommit();
|
Chris@95
|
92 }
|
Chris@95
|
93
|
Chris@96
|
94 QStringList HgTabWidget::getAllSelectedFiles() const
|
Chris@95
|
95 {
|
Chris@116
|
96 return m_fileStatusWidget->getAllSelectedFiles();
|
Chris@95
|
97 }
|
Chris@95
|
98
|
Chris@109
|
99 QStringList HgTabWidget::getAllCommittableFiles() const
|
Chris@109
|
100 {
|
Chris@116
|
101 return m_fileStatusWidget->getAllCommittableFiles();
|
Chris@109
|
102 }
|
Chris@109
|
103
|
Chris@96
|
104 QStringList HgTabWidget::getSelectedCommittableFiles() const
|
Chris@95
|
105 {
|
Chris@116
|
106 return m_fileStatusWidget->getSelectedCommittableFiles();
|
Chris@95
|
107 }
|
Chris@95
|
108
|
Chris@109
|
109 QStringList HgTabWidget::getAllRevertableFiles() const
|
Chris@109
|
110 {
|
Chris@116
|
111 return m_fileStatusWidget->getAllRevertableFiles();
|
Chris@109
|
112 }
|
Chris@109
|
113
|
Chris@109
|
114 QStringList HgTabWidget::getSelectedRevertableFiles() const
|
Chris@109
|
115 {
|
Chris@116
|
116 return m_fileStatusWidget->getSelectedRevertableFiles();
|
Chris@109
|
117 }
|
Chris@109
|
118
|
Chris@96
|
119 QStringList HgTabWidget::getSelectedAddableFiles() const
|
Chris@95
|
120 {
|
Chris@116
|
121 return m_fileStatusWidget->getSelectedAddableFiles();
|
Chris@95
|
122 }
|
Chris@95
|
123
|
Chris@109
|
124 QStringList HgTabWidget::getAllRemovableFiles() const
|
Chris@109
|
125 {
|
Chris@116
|
126 return m_fileStatusWidget->getAllRemovableFiles();
|
Chris@109
|
127 }
|
Chris@109
|
128
|
Chris@96
|
129 QStringList HgTabWidget::getSelectedRemovableFiles() const
|
Chris@95
|
130 {
|
Chris@116
|
131 return m_fileStatusWidget->getSelectedRemovableFiles();
|
Chris@95
|
132 }
|
Chris@95
|
133
|
Chris@96
|
134 void HgTabWidget::updateWorkFolderFileList(QString fileList)
|
jtkorhonen@0
|
135 {
|
Chris@116
|
136 m_fileStates.parseStates(fileList);
|
Chris@116
|
137 m_fileStatusWidget->setFileStates(m_fileStates);
|
jtkorhonen@0
|
138 }
|
jtkorhonen@0
|
139
|
Chris@120
|
140 void HgTabWidget::setNewLog(QString hgLogList)
|
jtkorhonen@0
|
141 {
|
Chris@120
|
142 m_historyWidget->parseNewLog(hgLogList);
|
Chris@120
|
143 }
|
Chris@120
|
144
|
Chris@120
|
145 void HgTabWidget::addIncrementalLog(QString hgLogList)
|
Chris@120
|
146 {
|
Chris@120
|
147 m_historyWidget->parseIncrementalLog(hgLogList);
|
jtkorhonen@0
|
148 }
|
jtkorhonen@0
|
149
|
Chris@96
|
150 void HgTabWidget::setWorkFolderAndRepoNames(QString workFolderPath, QString remoteRepoPath)
|
jtkorhonen@0
|
151 {
|
Chris@116
|
152 m_fileStatusWidget->setLocalPath(workFolderPath);
|
Chris@116
|
153 m_fileStatusWidget->setRemoteURL(remoteRepoPath);
|
jtkorhonen@0
|
154 }
|
Chris@106
|
155
|
Chris@115
|
156 void HgTabWidget::setState(QString state)
|
Chris@106
|
157 {
|
Chris@116
|
158 m_fileStatusWidget->setState(state);
|
Chris@106
|
159 }
|