diff src/changesetitem.cpp @ 600:641ccce7c771

Avoid messing with font size when zooming, let it zoom naturally; don't delete detail item when removing it, just let it wait to be shown again (and do delete it when deleting main item)
author Chris Cannam
date Fri, 11 May 2012 17:44:33 +0100
parents 1e76d1009167
children ae67ea0af696
line wrap: on
line diff
--- a/src/changesetitem.cpp	Tue Apr 24 16:56:29 2012 +0100
+++ b/src/changesetitem.cpp	Fri May 11 17:44:33 2012 +0100
@@ -36,7 +36,7 @@
 QImage *ChangesetItem::m_star = 0;
 
 ChangesetItem::ChangesetItem(Changeset *cs) :
-    m_changeset(cs), m_detail(0),
+    m_changeset(cs), m_detail(0), m_detailVisible(false),
     m_showBranch(false), m_column(0), m_row(0), m_wide(false),
     m_current(false), m_closing(false), m_new(false), m_searchMatches(false)
 {
@@ -49,6 +49,11 @@
     if (!m_star) m_star = new QImage(":images/star.png");
 }
 
+ChangesetItem::~ChangesetItem()
+{
+    if (m_detail && !m_detailVisible) delete m_detail;
+}
+
 QString
 ChangesetItem::getId()
 {
@@ -66,28 +71,28 @@
 void
 ChangesetItem::showDetail()
 {
-    if (m_detail) return;
-    m_detail = new ChangesetDetailItem(m_changeset);
-    m_detail->setZValue(zValue() + 1);
+    if (m_detailVisible) return;
+    if (!m_detail) {
+        m_detail = new ChangesetDetailItem(m_changeset);
+        m_detail->setZValue(zValue() + 1);
+    }
     scene()->addItem(m_detail);
     int w = 100;
     if (m_wide) w = 180;
     if (isMerge() || isClosingCommit()) w = 60;
     int h = 80;
-//    m_detail->moveBy(x() - (m_detail->boundingRect().width() - 50) / 2,
-//                     y() + 60);
-    m_detail->moveBy(x() + (w + 50) / 2 + 10 + 0.5,
+    m_detail->setPos(x() + (w + 50) / 2 + 10 + 0.5,
                      y() - (m_detail->boundingRect().height() - h) / 3 + 0.5);
+    m_detailVisible = true;
     emit detailShown();
 }    
 
 void
 ChangesetItem::hideDetail()
 {
-    if (!m_detail) return;
+    if (!m_detailVisible) return;
     scene()->removeItem(m_detail);
-    delete m_detail;
-    m_detail = 0;
+    m_detailVisible = false;
     emit detailHidden();
 }    
 
@@ -112,7 +117,7 @@
 {
     DEBUG << "ChangesetItem::mousePressEvent" << endl;
     if (e->button() == Qt::LeftButton) {
-        if (m_detail) {
+        if (m_detailVisible) {
             hideDetail();
         } else {
             showDetail();
@@ -303,11 +308,6 @@
 
     QTransform t = paint->worldTransform();
     float scale = std::min(t.m11(), t.m22());
-    if (scale > 1.0) {
-	int ps = int((f.pixelSize() / scale) + 0.5);
-	if (ps < 8) ps = 8;
-	f.setPixelSize(ps);
-    }
 
     bool showText = (scale >= 0.2);
     bool showProperLines = (scale >= 0.1);