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