changeset 307:5b4aa1c24407 new-branches-with-status-outside-tabs

Merge branch status_outside_tabs into branch new-branches, and make a new branch
author Chris Cannam
date Mon, 28 Feb 2011 13:09:37 +0000
parents f7cdd5b31aed (diff) b280a2dc0512 (current diff)
children 7f50c040e13d
files changesetitem.cpp changesetitem.h changesetscene.cpp changesetscene.h hgaction.h hgtabwidget.cpp hgtabwidget.h historywidget.cpp historywidget.h mainwindow.cpp mainwindow.h
diffstat 11 files changed, 53 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/changesetitem.cpp	Sat Feb 26 23:04:18 2011 +0000
+++ b/changesetitem.cpp	Mon Feb 28 13:09:37 2011 +0000
@@ -189,6 +189,10 @@
 
     menu->addSeparator();
 
+    QAction *branch = menu->addAction(tr("Start new branch..."));
+    branch->setEnabled(m_current);
+    connect(branch, SIGNAL(triggered()), this, SLOT(newBranchActivated()));
+
     QAction *tag = menu->addAction(tr("Add tag..."));
     connect(tag, SIGNAL(triggered()), this, SLOT(tagActivated()));
 
@@ -231,6 +235,7 @@
 void ChangesetItem::diffToCurrentActivated() { emit diffToCurrent(getId()); }
 void ChangesetItem::mergeActivated() { emit mergeFrom(getId()); }
 void ChangesetItem::tagActivated() { emit tag(getId()); }
+void ChangesetItem::newBranchActivated() { emit newBranch(getId()); }
 
 void
 ChangesetItem::paint(QPainter *paint, const QStyleOptionGraphicsItem *, QWidget *)
--- a/changesetitem.h	Sat Feb 26 23:04:18 2011 +0000
+++ b/changesetitem.h	Mon Feb 28 13:09:37 2011 +0000
@@ -65,6 +65,7 @@
     void diffToParent(QString child, QString parent);
     void showSummary(Changeset *);
     void mergeFrom(QString);
+    void newBranch(QString);
     void tag(QString);
 
 public slots:
@@ -79,6 +80,7 @@
     void diffToCurrentActivated();
     void mergeActivated();
     void tagActivated();
+    void newBranchActivated();
 
 protected:
     virtual void mousePressEvent(QGraphicsSceneMouseEvent *);
--- a/changesetscene.cpp	Sat Feb 26 23:04:18 2011 +0000
+++ b/changesetscene.cpp	Mon Feb 28 13:09:37 2011 +0000
@@ -51,6 +51,9 @@
     connect(item, SIGNAL(mergeFrom(QString)),
             this, SIGNAL(mergeFrom(QString)));
 
+    connect(item, SIGNAL(newBranch(QString)),
+            this, SIGNAL(newBranch(QString)));
+
     connect(item, SIGNAL(tag(QString)),
             this, SIGNAL(tag(QString)));
 }
--- a/changesetscene.h	Sat Feb 26 23:04:18 2011 +0000
+++ b/changesetscene.h	Mon Feb 28 13:09:37 2011 +0000
@@ -50,6 +50,7 @@
     void showSummary(Changeset *);
     void diffToCurrent(QString id);
     void mergeFrom(QString id);
+    void newBranch(QString id);
     void tag(QString id);
 
 private slots:
--- a/hgaction.h	Sat Feb 26 23:04:18 2011 +0000
+++ b/hgaction.h	Mon Feb 28 13:09:37 2011 +0000
@@ -54,6 +54,7 @@
     ACT_RESOLVE_MARK,
     ACT_RETRY_MERGE,
     ACT_TAG,
+    ACT_NEW_BRANCH,
     ACT_HG_IGNORE,
 };
 
--- a/hgtabwidget.cpp	Sat Feb 26 23:04:18 2011 +0000
+++ b/hgtabwidget.cpp	Mon Feb 28 13:09:37 2011 +0000
@@ -73,6 +73,9 @@
     connect(m_historyWidget, SIGNAL(mergeFrom(QString)),
             this, SIGNAL(mergeFrom(QString)));
 
+    connect(m_historyWidget, SIGNAL(newBranch(QString)),
+            this, SIGNAL(newBranch(QString)));
+
     connect(m_historyWidget, SIGNAL(tag(QString)),
             this, SIGNAL(tag(QString)));
 }
--- a/hgtabwidget.h	Sat Feb 26 23:04:18 2011 +0000
+++ b/hgtabwidget.h	Mon Feb 28 13:09:37 2011 +0000
@@ -93,6 +93,7 @@
     void showSummary(Changeset *);
     void diffToCurrent(QString id);
     void mergeFrom(QString id);
+    void newBranch(QString id);
     void tag(QString id);
 
 public slots:
--- a/historywidget.cpp	Sat Feb 26 23:04:18 2011 +0000
+++ b/historywidget.cpp	Mon Feb 28 13:09:37 2011 +0000
@@ -284,6 +284,9 @@
     connect(scene, SIGNAL(mergeFrom(QString)),
             this, SIGNAL(mergeFrom(QString)));
 
+    connect(scene, SIGNAL(newBranch(QString)),
+            this, SIGNAL(newBranch(QString)));
+
     connect(scene, SIGNAL(tag(QString)),
             this, SIGNAL(tag(QString)));
 }
--- a/historywidget.h	Sat Feb 26 23:04:18 2011 +0000
+++ b/historywidget.h	Mon Feb 28 13:09:37 2011 +0000
@@ -57,6 +57,7 @@
     void showSummary(Changeset *);
     void diffToCurrent(QString id);
     void mergeFrom(QString id);
+    void newBranch(QString id);
     void tag(QString id);
     
 private:
--- a/mainwindow.cpp	Sat Feb 26 23:04:18 2011 +0000
+++ b/mainwindow.cpp	Mon Feb 28 13:09:37 2011 +0000
@@ -460,14 +460,11 @@
 
 QString MainWindow::filterTag(QString tag)
 {
-    for(int i = 0; i < tag.size(); i++)
-    {
-        if (tag[i].isLower() || tag[i].isUpper() || tag[i].isDigit() || (tag[i] == QChar('.')))
-        {
+    for(int i = 0; i < tag.size(); i++) {
+        if (tag[i].isLower() || tag[i].isUpper() ||
+            tag[i].isDigit() || (tag[i] == QChar('.'))) {
             //ok
-        }
-        else
-        {
+        } else {
             tag[i] = QChar('_');
         }
     }
@@ -475,6 +472,26 @@
 }
 
 
+void MainWindow::hgNewBranch(QString id)
+{
+    QStringList params;
+    QString branch;
+
+    if (ConfirmCommentDialog::confirmAndGetShortComment
+        (this,
+         tr("New Branch"),
+         tr("Enter new branch name:"),
+         branch,
+         tr("Start Branch"))) {
+        if (!branch.isEmpty()) {//!!! do something better if it is empty
+
+            params << "branch" << filterTag(branch);
+            m_runner->requestAction(HgAction(ACT_NEW_BRANCH, m_workFolderPath, params));
+        }
+    }
+}
+
+
 void MainWindow::hgTag(QString id)
 {
     QStringList params;
@@ -1949,6 +1966,11 @@
         m_shouldHgStat = true;
         break;
 
+    case ACT_NEW_BRANCH:
+        m_shouldHgStat = true;
+        m_hgTabs->showWorkTab();
+        break;
+
     case ACT_UNCOMMITTED_SUMMARY:
         QMessageBox::information(this, tr("Change summary"),
                                  format3(tr("Summary of uncommitted changes"),
@@ -2168,6 +2190,9 @@
     connect(m_hgTabs, SIGNAL(mergeFrom(QString)),
             this, SLOT(hgMergeFrom(QString)));
 
+    connect(m_hgTabs, SIGNAL(newBranch(QString)),
+            this, SLOT(hgNewBranch(QString)));
+
     connect(m_hgTabs, SIGNAL(tag(QString)),
             this, SLOT(hgTag(QString)));
 }    
--- a/mainwindow.h	Sat Feb 26 23:04:18 2011 +0000
+++ b/mainwindow.h	Mon Feb 28 13:09:37 2011 +0000
@@ -90,6 +90,7 @@
     void hgAnnotate();
     void hgResolveList();
     void hgTag(QString);
+    void hgNewBranch(QString);
     void hgServe();
     void hgIgnore();