changeset 96:87ef2fa9ee8b

* Rename HgExpWidget to HgTabWidget
author Chris Cannam
date Wed, 24 Nov 2010 16:40:57 +0000
parents d1be9712818a
children 05203e53b92a
files easyhg.pro hgexpwidget.cpp hgexpwidget.h hgtabwidget.cpp hgtabwidget.h mainwindow.cpp mainwindow.h
diffstat 7 files changed, 257 insertions(+), 257 deletions(-) [+]
line wrap: on
line diff
--- a/easyhg.pro	Wed Nov 24 16:29:05 2010 +0000
+++ b/easyhg.pro	Wed Nov 24 16:40:57 2010 +0000
@@ -11,7 +11,7 @@
 MOC_DIR = o
 
 HEADERS = mainwindow.h \
-    hgexpwidget.h \
+    hgtabwidget.h \
     common.h \
     grapher.h \
     hgrunner.h \
@@ -35,7 +35,7 @@
     filestatuswidget.h
 SOURCES = main.cpp \
     mainwindow.cpp \
-    hgexpwidget.cpp \
+    hgtabwidget.cpp \
     hgrunner.cpp \
     grapher.cpp \
     settingsdialog.cpp \
--- a/hgexpwidget.cpp	Wed Nov 24 16:29:05 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,174 +0,0 @@
-/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
-
-/*
-    EasyMercurial
-
-    Based on HgExplorer by Jari Korhonen
-    Copyright (c) 2010 Jari Korhonen
-    Copyright (c) 2010 Chris Cannam
-    Copyright (c) 2010 Queen Mary, University of London
-    
-    This program is free software; you can redistribute it and/or
-    modify it under the terms of the GNU General Public License as
-    published by the Free Software Foundation; either version 2 of the
-    License, or (at your option) any later version.  See the file
-    COPYING included with this distribution for more information.
-*/
-
-#include "hgexpwidget.h"
-#include "common.h"
-#include "logparser.h"
-#include "changeset.h"
-#include "changesetitem.h"
-#include "grapher.h"
-#include "panner.h"
-#include "panned.h"
-#include "filestatuswidget.h"
-
-#include <QClipboard>
-#include <QContextMenuEvent>
-#include <QApplication>
-
-#include <iostream>
-
-HgExpWidget::HgExpWidget(QWidget *parent,
-                         QString remoteRepo,
-                         QString workFolderPath) :
-    QTabWidget(parent)
-{
-    // Work page
-    fileStatusWidget = new FileStatusWidget;
-    fileStatusWidget->setLocalPath(workFolderPath);
-    fileStatusWidget->setRemoteURL(remoteRepo);
-    connect(fileStatusWidget, SIGNAL(selectionChanged()),
-            this, SIGNAL(selectionChanged()));
-    addTab(fileStatusWidget, tr("My work"));
-
-    // History graph page
-    historyGraphPageWidget = new QWidget;
-    Panned *panned = new Panned;
-    Panner *panner = new Panner;
-    historyGraphWidget = panned;
-    historyGraphPanner = panner;
-    QGridLayout *layout = new QGridLayout;
-    layout->addWidget(historyGraphWidget, 0, 0);
-    layout->addWidget(historyGraphPanner, 0, 1);
-    panner->setMaximumWidth(80);
-    panner->connectToPanned(panned);
-    historyGraphPageWidget->setLayout(layout);
-    addTab(historyGraphPageWidget, tr("History"));
-}
-
-void HgExpWidget::clearSelections()
-{
-    fileStatusWidget->clearSelections();
-}
-
-bool HgExpWidget::canCommit() const
-{
-    return fileStatusWidget->haveChangesToCommit();
-}
-
-bool HgExpWidget::canAdd() const
-{
-    if (fileStatusWidget->getSelectedAddableFiles().empty()) return false;
-    if (!fileStatusWidget->getSelectedCommittableFiles().empty()) return false;
-    if (!fileStatusWidget->getSelectedRemovableFiles().empty()) return false;
-    return true;
-}
-
-bool HgExpWidget::canRemove() const
-{
-    if (fileStatusWidget->getSelectedRemovableFiles().empty()) return false;
-    if (!fileStatusWidget->getSelectedAddableFiles().empty()) return false;
-    return true;
-}
-
-bool HgExpWidget::canDoDiff() const
-{
-    return canCommit();
-}
-
-QStringList HgExpWidget::getAllSelectedFiles() const
-{
-    return fileStatusWidget->getAllSelectedFiles();
-}
-
-QStringList HgExpWidget::getSelectedCommittableFiles() const
-{
-    return fileStatusWidget->getSelectedCommittableFiles();
-}
-
-QStringList HgExpWidget::getSelectedAddableFiles() const
-{
-    return fileStatusWidget->getSelectedAddableFiles();
-}
-
-QStringList HgExpWidget::getSelectedRemovableFiles() const
-{
-    return fileStatusWidget->getSelectedRemovableFiles();
-}
-
-void HgExpWidget::updateWorkFolderFileList(QString fileList)
-{
-    fileStates.parseStates(fileList);
-    fileStatusWidget->setFileStates(fileStates);
-}
-
-void HgExpWidget::updateLocalRepoHgLogList(QString hgLogList)
-{
-    //!!!
-    Panned *panned = static_cast<Panned *>(historyGraphWidget);
-    Panner *panner = static_cast<Panner *>(historyGraphPanner);
-    QGraphicsScene *scene = new QGraphicsScene();
-    Changesets csets = parseChangeSets(hgLogList);
-    if (csets.empty()) return;
-    Grapher g(scene);
-    try {
-	g.layout(csets);
-    } catch (std::string s) {
-	std::cerr << "Internal error: Layout failed: " << s << std::endl;
-    }
-    QGraphicsScene *oldScene = panned->scene();
-    panned->setScene(scene);
-    panner->setScene(scene);
-    if (oldScene) delete oldScene;
-    ChangesetItem *tipItem = g.getItemFor(csets[0]);
-    if (tipItem) tipItem->ensureVisible();
-}
-
-Changesets HgExpWidget::parseChangeSets(QString changeSetsStr)
-{
-    Changesets csets;
-    LogList log = LogParser(changeSetsStr).parse();
-    foreach (LogEntry e, log) {
-        Changeset *cs = new Changeset();
-        foreach (QString key, e.keys()) {
-	    if (key == "parents") {
-		QStringList parents = e.value(key).split
-		    (" ", QString::SkipEmptyParts);
-		cs->setParents(parents);
-	    } else if (key == "timestamp") {
-		cs->setTimestamp(e.value(key).split(" ")[0].toULongLong());
-	    } else {
-		cs->setProperty(key.toLocal8Bit().data(), e.value(key));
-	    }
-        }
-        csets.push_back(cs);
-    }
-    for (int i = 0; i+1 < csets.size(); ++i) {
-	Changeset *cs = csets[i];
-	if (cs->parents().empty()) {
-	    QStringList list;
-	    list.push_back(csets[i+1]->id());
-	    cs->setParents(list);
-	}
-    }
-    return csets;
-}
-
-void HgExpWidget::setWorkFolderAndRepoNames(QString workFolderPath, QString remoteRepoPath)
-{
-    fileStatusWidget->setLocalPath(workFolderPath);
-    fileStatusWidget->setRemoteURL(remoteRepoPath);
-}
--- a/hgexpwidget.h	Wed Nov 24 16:29:05 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
-
-/*
-    EasyMercurial
-
-    Based on HgExplorer by Jari Korhonen
-    Copyright (c) 2010 Jari Korhonen
-    Copyright (c) 2010 Chris Cannam
-    Copyright (c) 2010 Queen Mary, University of London
-    
-    This program is free software; you can redistribute it and/or
-    modify it under the terms of the GNU General Public License as
-    published by the Free Software Foundation; either version 2 of the
-    License, or (at your option) any later version.  See the file
-    COPYING included with this distribution for more information.
-*/
-
-#ifndef HGEXPWIDGET_H
-#define HGEXPWIDGET_H
-
-#include "changeset.h"
-#include "common.h"
-#include "filestates.h"
-
-#include <QMenu>
-#include <QListWidget>
-#include <QGroupBox>
-#include <QVBoxLayout>
-#include <QCheckBox>
-#include <QLabel>
-#include <QTabWidget>
-
-class FileStatusWidget;
-
-
-class HgExpWidget: public QTabWidget
-{
-    Q_OBJECT
-
-public:
-    HgExpWidget(QWidget *parent, QString remoteRepo, QString workFolderPath);
-
-    void updateWorkFolderFileList(QString fileList);
-    void updateLocalRepoHgLogList(QString hgLogList);
-    void setWorkFolderAndRepoNames(QString workFolderPath, QString remoteRepoPath);
-
-    FileStates getFileStates() { return fileStates; }
-
-    bool canCommit() const;
-    bool canAdd() const;
-    bool canRemove() const;
-    bool canDoDiff() const;
-
-    QStringList getAllSelectedFiles() const;
-    QStringList getSelectedCommittableFiles() const;
-    QStringList getSelectedAddableFiles() const;
-    QStringList getSelectedRemovableFiles() const;
-
-signals:
-    void selectionChanged();
-
-public slots:
-    void clearSelections();
-
-private:
-    FileStatusWidget *fileStatusWidget;
-
-    QWidget *historyGraphPageWidget;
-    QWidget *historyGraphWidget;
-    QWidget *historyGraphPanner;
-    QWidget *historyPageWidget;
-
-    FileStates fileStates;
-
-    Changesets parseChangeSets(QString changeSetsStr);
-};
-
-#endif // HGEXPWIDGET_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgtabwidget.cpp	Wed Nov 24 16:40:57 2010 +0000
@@ -0,0 +1,174 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
+
+/*
+    EasyMercurial
+
+    Based on HgExplorer by Jari Korhonen
+    Copyright (c) 2010 Jari Korhonen
+    Copyright (c) 2010 Chris Cannam
+    Copyright (c) 2010 Queen Mary, University of London
+    
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License as
+    published by the Free Software Foundation; either version 2 of the
+    License, or (at your option) any later version.  See the file
+    COPYING included with this distribution for more information.
+*/
+
+#include "hgtabwidget.h"
+#include "common.h"
+#include "logparser.h"
+#include "changeset.h"
+#include "changesetitem.h"
+#include "grapher.h"
+#include "panner.h"
+#include "panned.h"
+#include "filestatuswidget.h"
+
+#include <QClipboard>
+#include <QContextMenuEvent>
+#include <QApplication>
+
+#include <iostream>
+
+HgTabWidget::HgTabWidget(QWidget *parent,
+                         QString remoteRepo,
+                         QString workFolderPath) :
+    QTabWidget(parent)
+{
+    // Work page
+    fileStatusWidget = new FileStatusWidget;
+    fileStatusWidget->setLocalPath(workFolderPath);
+    fileStatusWidget->setRemoteURL(remoteRepo);
+    connect(fileStatusWidget, SIGNAL(selectionChanged()),
+            this, SIGNAL(selectionChanged()));
+    addTab(fileStatusWidget, tr("My work"));
+
+    // History graph page
+    historyGraphPageWidget = new QWidget;
+    Panned *panned = new Panned;
+    Panner *panner = new Panner;
+    historyGraphWidget = panned;
+    historyGraphPanner = panner;
+    QGridLayout *layout = new QGridLayout;
+    layout->addWidget(historyGraphWidget, 0, 0);
+    layout->addWidget(historyGraphPanner, 0, 1);
+    panner->setMaximumWidth(80);
+    panner->connectToPanned(panned);
+    historyGraphPageWidget->setLayout(layout);
+    addTab(historyGraphPageWidget, tr("History"));
+}
+
+void HgTabWidget::clearSelections()
+{
+    fileStatusWidget->clearSelections();
+}
+
+bool HgTabWidget::canCommit() const
+{
+    return fileStatusWidget->haveChangesToCommit();
+}
+
+bool HgTabWidget::canAdd() const
+{
+    if (fileStatusWidget->getSelectedAddableFiles().empty()) return false;
+    if (!fileStatusWidget->getSelectedCommittableFiles().empty()) return false;
+    if (!fileStatusWidget->getSelectedRemovableFiles().empty()) return false;
+    return true;
+}
+
+bool HgTabWidget::canRemove() const
+{
+    if (fileStatusWidget->getSelectedRemovableFiles().empty()) return false;
+    if (!fileStatusWidget->getSelectedAddableFiles().empty()) return false;
+    return true;
+}
+
+bool HgTabWidget::canDoDiff() const
+{
+    return canCommit();
+}
+
+QStringList HgTabWidget::getAllSelectedFiles() const
+{
+    return fileStatusWidget->getAllSelectedFiles();
+}
+
+QStringList HgTabWidget::getSelectedCommittableFiles() const
+{
+    return fileStatusWidget->getSelectedCommittableFiles();
+}
+
+QStringList HgTabWidget::getSelectedAddableFiles() const
+{
+    return fileStatusWidget->getSelectedAddableFiles();
+}
+
+QStringList HgTabWidget::getSelectedRemovableFiles() const
+{
+    return fileStatusWidget->getSelectedRemovableFiles();
+}
+
+void HgTabWidget::updateWorkFolderFileList(QString fileList)
+{
+    fileStates.parseStates(fileList);
+    fileStatusWidget->setFileStates(fileStates);
+}
+
+void HgTabWidget::updateLocalRepoHgLogList(QString hgLogList)
+{
+    //!!!
+    Panned *panned = static_cast<Panned *>(historyGraphWidget);
+    Panner *panner = static_cast<Panner *>(historyGraphPanner);
+    QGraphicsScene *scene = new QGraphicsScene();
+    Changesets csets = parseChangeSets(hgLogList);
+    if (csets.empty()) return;
+    Grapher g(scene);
+    try {
+	g.layout(csets);
+    } catch (std::string s) {
+	std::cerr << "Internal error: Layout failed: " << s << std::endl;
+    }
+    QGraphicsScene *oldScene = panned->scene();
+    panned->setScene(scene);
+    panner->setScene(scene);
+    if (oldScene) delete oldScene;
+    ChangesetItem *tipItem = g.getItemFor(csets[0]);
+    if (tipItem) tipItem->ensureVisible();
+}
+
+Changesets HgTabWidget::parseChangeSets(QString changeSetsStr)
+{
+    Changesets csets;
+    LogList log = LogParser(changeSetsStr).parse();
+    foreach (LogEntry e, log) {
+        Changeset *cs = new Changeset();
+        foreach (QString key, e.keys()) {
+	    if (key == "parents") {
+		QStringList parents = e.value(key).split
+		    (" ", QString::SkipEmptyParts);
+		cs->setParents(parents);
+	    } else if (key == "timestamp") {
+		cs->setTimestamp(e.value(key).split(" ")[0].toULongLong());
+	    } else {
+		cs->setProperty(key.toLocal8Bit().data(), e.value(key));
+	    }
+        }
+        csets.push_back(cs);
+    }
+    for (int i = 0; i+1 < csets.size(); ++i) {
+	Changeset *cs = csets[i];
+	if (cs->parents().empty()) {
+	    QStringList list;
+	    list.push_back(csets[i+1]->id());
+	    cs->setParents(list);
+	}
+    }
+    return csets;
+}
+
+void HgTabWidget::setWorkFolderAndRepoNames(QString workFolderPath, QString remoteRepoPath)
+{
+    fileStatusWidget->setLocalPath(workFolderPath);
+    fileStatusWidget->setRemoteURL(remoteRepoPath);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgtabwidget.h	Wed Nov 24 16:40:57 2010 +0000
@@ -0,0 +1,78 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
+
+/*
+    EasyMercurial
+
+    Based on HgExplorer by Jari Korhonen
+    Copyright (c) 2010 Jari Korhonen
+    Copyright (c) 2010 Chris Cannam
+    Copyright (c) 2010 Queen Mary, University of London
+    
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License as
+    published by the Free Software Foundation; either version 2 of the
+    License, or (at your option) any later version.  See the file
+    COPYING included with this distribution for more information.
+*/
+
+#ifndef HGTABWIDGET_H
+#define HGTABWIDGET_H
+
+#include "changeset.h"
+#include "common.h"
+#include "filestates.h"
+
+#include <QMenu>
+#include <QListWidget>
+#include <QGroupBox>
+#include <QVBoxLayout>
+#include <QCheckBox>
+#include <QLabel>
+#include <QTabWidget>
+
+class FileStatusWidget;
+
+
+class HgTabWidget: public QTabWidget
+{
+    Q_OBJECT
+
+public:
+    HgTabWidget(QWidget *parent, QString remoteRepo, QString workFolderPath);
+
+    void updateWorkFolderFileList(QString fileList);
+    void updateLocalRepoHgLogList(QString hgLogList);
+    void setWorkFolderAndRepoNames(QString workFolderPath, QString remoteRepoPath);
+
+    FileStates getFileStates() { return fileStates; }
+
+    bool canCommit() const;
+    bool canAdd() const;
+    bool canRemove() const;
+    bool canDoDiff() const;
+
+    QStringList getAllSelectedFiles() const;
+    QStringList getSelectedCommittableFiles() const;
+    QStringList getSelectedAddableFiles() const;
+    QStringList getSelectedRemovableFiles() const;
+
+signals:
+    void selectionChanged();
+
+public slots:
+    void clearSelections();
+
+private:
+    FileStatusWidget *fileStatusWidget;
+
+    QWidget *historyGraphPageWidget;
+    QWidget *historyGraphWidget;
+    QWidget *historyGraphPanner;
+    QWidget *historyPageWidget;
+
+    FileStates fileStates;
+
+    Changesets parseChangeSets(QString changeSetsStr);
+};
+
+#endif // HGTABWIDGET_H
--- a/mainwindow.cpp	Wed Nov 24 16:29:05 2010 +0000
+++ b/mainwindow.cpp	Wed Nov 24 16:40:57 2010 +0000
@@ -67,7 +67,7 @@
 
     tabPage = 0;
     justMerged = false;
-    hgExp = new HgExpWidget((QWidget *) this, remoteRepoPath, workFolderPath);
+    hgExp = new HgTabWidget((QWidget *) this, remoteRepoPath, workFolderPath);
     setCentralWidget(hgExp);
 
     connect(hgExp, SIGNAL(selectionChanged()),
--- a/mainwindow.h	Wed Nov 24 16:29:05 2010 +0000
+++ b/mainwindow.h	Wed Nov 24 16:40:57 2010 +0000
@@ -18,7 +18,7 @@
 #ifndef MAINWINDOW_H
 #define MAINWINDOW_H
 
-#include "hgexpwidget.h"
+#include "hgtabwidget.h"
 #include "hgrunner.h"
 #include "common.h"
 
@@ -69,7 +69,7 @@
 
 public:
     MainWindow();
-    HgExpWidget *hgExp;
+    HgTabWidget *hgExp;
     void writeSettings();
 
     //Paths to remote repo & workfolder