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