comparison hgtabwidget.cpp @ 106:729438d70af8

* Retrieve and store current branch and heads; some refactoring
author Chris Cannam
date Thu, 25 Nov 2010 17:54:35 +0000
parents 0bd32aedc6f6
children 8ae3b44c0073
comparison
equal deleted inserted replaced
105:1928f9b408e6 106:729438d70af8
32 #include <iostream> 32 #include <iostream>
33 33
34 HgTabWidget::HgTabWidget(QWidget *parent, 34 HgTabWidget::HgTabWidget(QWidget *parent,
35 QString remoteRepo, 35 QString remoteRepo,
36 QString workFolderPath) : 36 QString workFolderPath) :
37 QTabWidget(parent) 37 QTabWidget(parent)
38 { 38 {
39 // Work page 39 // Work page
40 fileStatusWidget = new FileStatusWidget; 40 fileStatusWidget = new FileStatusWidget;
41 fileStatusWidget->setLocalPath(workFolderPath); 41 fileStatusWidget->setLocalPath(workFolderPath);
42 fileStatusWidget->setRemoteURL(remoteRepo); 42 fileStatusWidget->setRemoteURL(remoteRepo);
138 QGraphicsScene *scene = new QGraphicsScene(); 138 QGraphicsScene *scene = new QGraphicsScene();
139 Changesets csets = parseChangeSets(hgLogList); 139 Changesets csets = parseChangeSets(hgLogList);
140 if (csets.empty()) return; 140 if (csets.empty()) return;
141 Grapher g(scene); 141 Grapher g(scene);
142 try { 142 try {
143 g.layout(csets); 143 g.layout(csets);
144 } catch (std::string s) { 144 } catch (std::string s) {
145 std::cerr << "Internal error: Layout failed: " << s << std::endl; 145 std::cerr << "Internal error: Layout failed: " << s << std::endl;
146 } 146 }
147 QGraphicsScene *oldScene = panned->scene(); 147 QGraphicsScene *oldScene = panned->scene();
148 panned->setScene(scene); 148 panned->setScene(scene);
149 panner->setScene(scene); 149 panner->setScene(scene);
150 if (oldScene) delete oldScene; 150 if (oldScene) delete oldScene;
155 Changesets HgTabWidget::parseChangeSets(QString changeSetsStr) 155 Changesets HgTabWidget::parseChangeSets(QString changeSetsStr)
156 { 156 {
157 Changesets csets; 157 Changesets csets;
158 LogList log = LogParser(changeSetsStr).parse(); 158 LogList log = LogParser(changeSetsStr).parse();
159 foreach (LogEntry e, log) { 159 foreach (LogEntry e, log) {
160 Changeset *cs = new Changeset(); 160 Changeset *cs = new Changeset(e);
161 foreach (QString key, e.keys()) {
162 if (key == "parents") {
163 QStringList parents = e.value(key).split
164 (" ", QString::SkipEmptyParts);
165 cs->setParents(parents);
166 } else if (key == "timestamp") {
167 cs->setTimestamp(e.value(key).split(" ")[0].toULongLong());
168 } else {
169 cs->setProperty(key.toLocal8Bit().data(), e.value(key));
170 }
171 }
172 csets.push_back(cs); 161 csets.push_back(cs);
173 } 162 }
174 for (int i = 0; i+1 < csets.size(); ++i) { 163 for (int i = 0; i+1 < csets.size(); ++i) {
175 Changeset *cs = csets[i]; 164 Changeset *cs = csets[i];
176 if (cs->parents().empty()) { 165 if (cs->parents().empty()) {
177 QStringList list; 166 QStringList list;
178 list.push_back(csets[i+1]->id()); 167 list.push_back(csets[i+1]->id());
179 cs->setParents(list); 168 cs->setParents(list);
180 } 169 }
181 } 170 }
182 return csets; 171 return csets;
183 } 172 }
184 173
185 void HgTabWidget::setWorkFolderAndRepoNames(QString workFolderPath, QString remoteRepoPath) 174 void HgTabWidget::setWorkFolderAndRepoNames(QString workFolderPath, QString remoteRepoPath)
186 { 175 {
187 fileStatusWidget->setLocalPath(workFolderPath); 176 fileStatusWidget->setLocalPath(workFolderPath);
188 fileStatusWidget->setRemoteURL(remoteRepoPath); 177 fileStatusWidget->setRemoteURL(remoteRepoPath);
189 } 178 }
179
180 void HgTabWidget::setBranch(QString branch)
181 {
182 fileStatusWidget->setBranch(branch);
183 }