# HG changeset patch # User Chris Cannam # Date 1292347210 0 # Node ID 4bad3c5c053a75cafe8350b14b9ed75aa5752f79 # Parent 94be1e218655aaf50e6f7c3d4a267abe3e1bb0cf * Add "Show summary" feature * Add simplistic kinetic scrolling to history widget diff -r 94be1e218655 -r 4bad3c5c053a changesetitem.cpp --- a/changesetitem.cpp Wed Dec 08 16:57:18 2010 +0000 +++ b/changesetitem.cpp Tue Dec 14 17:20:10 2010 +0000 @@ -41,6 +41,7 @@ m_font.setPixelSize(11); m_font.setBold(false); m_font.setItalic(false); + setCursor(Qt::ArrowCursor); } QString diff -r 94be1e218655 -r 4bad3c5c053a changesetitem.h --- a/changesetitem.h Wed Dec 08 16:57:18 2010 +0000 +++ b/changesetitem.h Tue Dec 14 17:20:10 2010 +0000 @@ -18,7 +18,7 @@ #ifndef CHANGESETITEM_H #define CHANGESETITEM_H -#include +#include #include class Changeset; @@ -26,10 +26,9 @@ class QAction; -class ChangesetItem : public QObject, public QGraphicsItem +class ChangesetItem : public QGraphicsObject { Q_OBJECT - Q_INTERFACES(QGraphicsItem) public: ChangesetItem(Changeset *cs); diff -r 94be1e218655 -r 4bad3c5c053a changesetscene.cpp --- a/changesetscene.cpp Wed Dec 08 16:57:18 2010 +0000 +++ b/changesetscene.cpp Tue Dec 14 17:20:10 2010 +0000 @@ -18,6 +18,7 @@ #include "changesetscene.h" #include "changesetitem.h" #include "uncommitteditem.h" +#include "dateitem.h" ChangesetScene::ChangesetScene() : QGraphicsScene(), m_detailShown(0) @@ -32,6 +33,9 @@ connect(item, SIGNAL(detailShown()), this, SLOT(changesetDetailShown())); + connect(item, SIGNAL(detailHidden()), + this, SLOT(changesetDetailHidden())); + connect(item, SIGNAL(updateTo(QString)), this, SIGNAL(updateTo(QString))); @@ -62,11 +66,23 @@ connect(item, SIGNAL(diff()), this, SIGNAL(diffWorkingFolder())); + connect(item, SIGNAL(showSummary()), + this, SIGNAL(showSummary())); + connect(item, SIGNAL(showWork()), this, SIGNAL(showWork())); } void +ChangesetScene::addDateItem(DateItem *item) +{ + addItem(item); + + connect(item, SIGNAL(clicked()), + this, SLOT(dateItemClicked())); +} + +void ChangesetScene::changesetDetailShown() { ChangesetItem *csi = qobject_cast(sender()); @@ -78,3 +94,17 @@ m_detailShown = csi; } +void +ChangesetScene::changesetDetailHidden() +{ + m_detailShown = 0; +} + +void +ChangesetScene::dateItemClicked() +{ + if (m_detailShown) { + m_detailShown->hideDetail(); + } +} + diff -r 94be1e218655 -r 4bad3c5c053a changesetscene.h --- a/changesetscene.h Wed Dec 08 16:57:18 2010 +0000 +++ b/changesetscene.h Tue Dec 14 17:20:10 2010 +0000 @@ -22,6 +22,7 @@ class ChangesetItem; class UncommittedItem; +class DateItem; class ChangesetScene : public QGraphicsScene { @@ -32,11 +33,13 @@ void addChangesetItem(ChangesetItem *item); void addUncommittedItem(UncommittedItem *item); + void addDateItem(DateItem *item); signals: void commit(); void revert(); void diffWorkingFolder(); + void showSummary(); void showWork(); void updateTo(QString id); @@ -45,8 +48,10 @@ void mergeFrom(QString id); void tag(QString id); -public slots: +private slots: void changesetDetailShown(); + void changesetDetailHidden(); + void dateItemClicked(); private: ChangesetItem *m_detailShown; diff -r 94be1e218655 -r 4bad3c5c053a dateitem.cpp --- a/dateitem.cpp Wed Dec 08 16:57:18 2010 +0000 +++ b/dateitem.cpp Tue Dec 14 17:20:10 2010 +0000 @@ -17,9 +17,19 @@ #include "dateitem.h" +#include "debug.h" + #include #include #include +#include + +DateItem::DateItem() : + m_minrow(0), m_maxrow(0), + m_mincol(0), m_maxcol(0), + m_even(false) +{ +} void DateItem::setRows(int minrow, int n) @@ -37,6 +47,16 @@ setX(m_mincol * 100); } +void +DateItem::mousePressEvent(QGraphicsSceneMouseEvent *e) +{ + DEBUG << "DateItem::mousePressEvent" << endl; + if (e->button() == Qt::LeftButton) { + emit clicked(); + } + e->ignore(); +} + QRectF DateItem::boundingRect() const { diff -r 94be1e218655 -r 4bad3c5c053a dateitem.h --- a/dateitem.h Wed Dec 08 16:57:18 2010 +0000 +++ b/dateitem.h Tue Dec 14 17:20:10 2010 +0000 @@ -18,15 +18,14 @@ #ifndef DATEITEM_H #define DATEITEM_H -#include +#include -class DateItem : public QGraphicsItem +class DateItem : public QGraphicsObject { + Q_OBJECT + public: - DateItem() : - m_minrow(0), m_maxrow(0), - m_mincol(0), m_maxcol(0), - m_even(false) {} + DateItem(); virtual QRectF boundingRect() const; virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); @@ -39,6 +38,12 @@ QString dateString() const { return m_dateString; } void setDateString(QString s) { m_dateString = s; } +signals: + void clicked(); + +protected: + virtual void mousePressEvent(QGraphicsSceneMouseEvent *); + private: QString m_dateString; int m_minrow; diff -r 94be1e218655 -r 4bad3c5c053a easyhg_en.qm Binary file easyhg_en.qm has changed diff -r 94be1e218655 -r 4bad3c5c053a easyhg_en.ts --- a/easyhg_en.ts Wed Dec 08 16:57:18 2010 +0000 +++ b/easyhg_en.ts Tue Dec 14 17:20:10 2010 +0000 @@ -4,42 +4,42 @@ ChangesetItem - - <qt>&nbsp;<b>Revision: </b>%1</qt> + + <qt><b>&nbsp;Revision: </b>%1</qt> - + Copy identifier to clipboard - + Diff to parent %1 - + Diff to parent - + Diff to current working folder - + Update to this revision - + Merge from here to current - + Add tag... @@ -71,7 +71,8 @@ - You have made no changes. + You have no uncommitted changes. + You have made no changes. @@ -101,41 +102,51 @@ + In Conflict: + + + + Untracked: - + You have not changed these files. - + You have changed these files since you last committed them. - + These files will be added to version control next time you commit. - + These files will be removed from version control next time you commit.<br>They will not be deleted from the local folder. - + These files are recorded in the version control, but absent from your working folder.<br>If you intended to delete them, select them and use Remove to tell the version control system about it.<br>If you deleted them by accident, select them and use Revert to restore their previous contents. - + + These files are unresolved following an incomplete merge.<br>Select a file and use Merge to try to resolve the merge again. + + + + These files are in your working folder but are not under version control.<br>Select a file and use Add to place it under version control or Ignore to remove it from this list. - + Files highlighted <font color=#d40000>in red</font> have appeared since your most recent commit or update. @@ -143,37 +154,37 @@ HgRunner - + User name: - + User name for "%1": - + Enter user name - + Password: - + Password for "%1" at "%2": - + Password for user "%1": - + Enter password @@ -215,69 +226,61 @@ MainWindow - - + + EasyMercurial - + About EasyMercurial - + <qt><h2>About EasyMercurial</h2><p>EasyMercurial is a simple user interface for the Mercurial version control system.</p><p>EasyMercurial is based on hgExplorer by Jari Korhonen, with thanks.<br>EasyMercurial development carried out by Chris Cannam for soundsoftware.ac.uk at the Centre for Digital Music, Queen Mary, University of London.<ul><li>Copyright &copy; 2010 Jari Korhonen</li><li>Copyright &copy; 2010 Chris Cannam</li><li>Copyright &copy; 2010 Queen Mary, University of London</li></ul><p> 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. - + Commit files - + Tag - + Enter tag: - + Revert files - - - + + + <h3>%1</h3><p>%2 - + You are about to commit the following files: - - - You are about to commit %n file(s): - - You are about to commit %n file: - You are about to commit %n files: - - - + You are about to <b>revert</b> the following files to their previous committed state.<br><br>This will <b>throw away any changes</b> that you have made to these files but have not committed: - + You are about to <b>revert</b> %n file(s).<br><br>This will <b>throw away any changes</b> that you have made to these files but have not committed. You are about to <b>revert</b> %n files.<br><br>This will <b>throw away any changes</b> that you have made to these files but have not committed. @@ -286,185 +289,200 @@ - + + Merge from the default branch + + + + + Merge from branch "%1" + + + + + Merge from %1 + + + + Confirm pull - + Confirm pull from remote repository - + You are about to pull from the following remote repository: - + Confirm push - + Confirm push to remote repository - + You are about to push to the following remote repository: - + Open Repository - + <qt><big>What would you like to open?</big></qt> - + <qt><center><img src=":images/browser-64.png"><br>Remote repository</center></qt> - + Open a remote Mercurial repository, by cloning from its URL into a local folder. - + <qt><center><img src=":images/hglogo-64.png"><br>Local repository</center></qt> - + Open an existing local Mercurial repository. - + <qt><center><img src=":images/hdd_unmount-64.png"><br>File folder</center></qt> - + Open a local folder, by creating a Mercurial repository in it. - + File chosen - + <qt><b>Folder required</b><br><br>You asked to open "%1".<br>This is a file; to open a repository, you need to choose a folder.</qt> - - + + Folder does not exist - + <qt><b>Folder does not exist</b><br><br>You asked to open "%1".<br>This folder does not exist, and it cannot be created because its parent does not exist either.</qt> - - + + Path is in existing repository - + <qt><b>Path is in an existing repository</b><br><br>You asked to initialise a repository at "%1".<br>This path is already inside an existing repository.</qt> - - + + Path is a file - + <qt><b>Path is a file</b><br><br>You asked to initialise a repository at "%1".<br>This is an existing file; it is only possible to initialise in folders.</qt> - + <qt><b>Local path is in an existing repository</b><br><br>You asked to open a remote repository by cloning it to the local path "%1".<br>This path is already inside an existing repository.<br>Please provide a new folder name for the local repository.</qt> - + <qt><b>Local path is a file</b><br><br>You asked to open a remote repository by cloning it to the local path "%1".<br>This path is an existing file.<br>Please provide a new folder name for the local repository.</qt> - + Folder exists - + <qt><b>Local folder already exists</b><br><br>You asked to open a remote repository by cloning it to the local path "%1".<br>This is the path of an existing folder.<br>Please provide a new folder name for the local repository.</qt> - + Path is inside a repository - + <qt><b>Open the repository that contains this path?</b><br><br>You asked to open "%1".<br>This is not the root folder of a repository.<br>But it is inside a repository, whose root is at "%2". <br><br>Would you like to open that repository instead?</qt> - + Folder has no repository - + <qt><b>Initialise a repository here?</b><br><br>You asked to open "%1".<br>This folder does not contain a Mercurial repository.<br><br>Would you like to initialise a repository here?</qt> - + <qt><b>Initialise a new repository?</b><br><br>You asked to open "%1".<br>This folder does not yet exist.<br><br>Would you like to create the folder and initialise a new empty repository in it?</qt> - + Repository exists - + <qt><b>Open existing repository?</b><br><br>You asked to initialise a new repository at "%1".<br>This folder already contains a repository. Would you like to open it?</qt> - + Ok - + Mercurial command did not return any output. - + Pushed %n changeset(s) Pushed %n changeset @@ -472,22 +490,22 @@ - + No changes to push - + Push complete - + The push command output was: - + Pulled %n changeset(s) Pulled %n changeset @@ -495,361 +513,383 @@ - + No changes to pull - + Pull complete - + The pull command output was: - + <qt><h3>Command failed</h3><p>The following command failed:</p><code>%1</code>%2</qt> - + <p>Its output said:</p><code>%1</code> - + Command failed - - + + Change summary + + + + + Summary of uncommitted changes + + + + + + Update - - + + + Merge - - Merge retry - - - - - Merge retry successful. - - - - + the default branch - + branch "%1" - + On %1. Not at the head of the branch: consider updating - + <b>Awaiting merge</b> on %1 + + + You are about to commit %n file(s). + + You are about to commit %n file. + You are about to commit %n files. + + - + + <qt><h3>Update successful</h3><p>%1</p> + + + + + <qt><h3>Merge successful</h3><p>%1</p> + + + + + Resolved + + + + + <qt><h3>Merge resolved</h3><p>Merge resolved successfully.</p> + + + + + Nothing committed to this repository yet + + + + + Have unresolved files following merge on %1 + + + + + Have merged but not yet committed on %1 + + + + + On %1. Not at the head of the branch + + + + + At one of %n heads of %1 + + + + + + + At the head of %1 - + Init local repository - + Create an empty local repository in selected folder - + Clone from remote - + Clone from remote repository into local repository in selected folder - + Open... - + Open repository - + Settings... - + View and change application settings - + Exit - + Exit application - + Refresh - + Refresh (info of) status of workfolder files - + Preview - + View info of changesets incoming to us from remote repository (on pull operation) - + Pull - + Pull changesets from remote repository to local repository - + Push - + Push local changesets to remote repository - - + Diff - - Filediff: View differences between selected working folder file and local repository file - - - - + Folderdiff: View all differences between working folder files and local repository files - + View changesetdiff - + Change set diff: View differences between all files of 2 repository changesets - + Revert - + Undo selected working folder file changes (return to local repository version) - + Add - + Add working folder file(s) (selected or all yet untracked) to local repository (on next commit) - + Remove - + Remove selected working folder file from local repository (on next commit) - + Update working folder from local repository - + Commit - + Save selected file(s) or all changed files in working folder (and all subfolders) to local repository - + Merge two local repository changesets to working folder - + Annotate - + Show line-by-line version information for selected file - - Resolve (list) - - - - - Resolve (list): Show list of files needing merge - - - - - Resolve (mark) - - - - - Resolve (mark): Mark selected file status as resolved - - - - - Retry merge - - - - - Retry merge after failed merge attempt. - - - - + Tag revision - + Give decsriptive name (tag) to current workfolder parent revision. - + Edit .hgignore - + Edit .hgignore file (file contains names of files that should be ignored by mercurial) - + Serve (via http) - + Serve local repository via http for workgroup access - + About - + Show the application's About box - + About Qt - + Show the Qt library's About box - + Clear selections - - + + File - + Advanced - + Help - + Ready @@ -892,7 +932,7 @@ QApplication - + EasyMercurial @@ -901,32 +941,38 @@ QObject - Identifier + Identifier: + Identifier - Author + Author: + Author - Date + Date: + Date - Branch + Branch: + Branch - Tag + Tag: + Tag - Comment + Comment: + Comment @@ -969,37 +1015,42 @@ UncommittedItem - - <qt>&nbsp;<b>Uncommitted changes</b></qt> + + <qt><b>&nbsp;Uncommitted changes</b></qt> - + Diff - + + Show summary + + + + Commit... - + Revert... - + Uncommitted changes - + Uncommitted - + changes diff -r 94be1e218655 -r 4bad3c5c053a grapher.cpp --- a/grapher.cpp Wed Dec 08 16:57:18 2010 +0000 +++ b/grapher.cpp Tue Dec 14 17:20:10 2010 +0000 @@ -546,7 +546,7 @@ item->setRows(changeRow, n); item->setEven(even); item->setZValue(-1); - m_scene->addItem(item); + m_scene->addDateItem(item); even = !even; } prevDate = date; @@ -562,7 +562,7 @@ item->setRows(changeRow, n+1); item->setEven(even); item->setZValue(-1); - m_scene->addItem(item); + m_scene->addDateItem(item); even = !even; } } diff -r 94be1e218655 -r 4bad3c5c053a hgaction.h --- a/hgaction.h Wed Dec 08 16:57:18 2010 +0000 +++ b/hgaction.h Tue Dec 14 17:20:10 2010 +0000 @@ -41,6 +41,7 @@ ACT_INIT, ACT_COMMIT, ACT_ANNOTATE, + ACT_DIFF_SUMMARY, ACT_FOLDERDIFF, ACT_CHGSETDIFF, ACT_UPDATE, diff -r 94be1e218655 -r 4bad3c5c053a hgtabwidget.cpp --- a/hgtabwidget.cpp Wed Dec 08 16:57:18 2010 +0000 +++ b/hgtabwidget.cpp Tue Dec 14 17:20:10 2010 +0000 @@ -49,6 +49,9 @@ connect(m_historyWidget, SIGNAL(revert()), this, SIGNAL(revert())); + connect(m_historyWidget, SIGNAL(showSummary()), + this, SIGNAL(showSummary())); + connect(m_historyWidget, SIGNAL(diffWorkingFolder()), this, SIGNAL(diffWorkingFolder())); diff -r 94be1e218655 -r 4bad3c5c053a hgtabwidget.h --- a/hgtabwidget.h Wed Dec 08 16:57:18 2010 +0000 +++ b/hgtabwidget.h Tue Dec 14 17:20:10 2010 +0000 @@ -84,6 +84,7 @@ void commit(); void revert(); void diffWorkingFolder(); + void showSummary(); void updateTo(QString id); void diffToParent(QString id, QString parent); diff -r 94be1e218655 -r 4bad3c5c053a historywidget.cpp --- a/historywidget.cpp Wed Dec 08 16:57:18 2010 +0000 +++ b/historywidget.cpp Tue Dec 14 17:20:10 2010 +0000 @@ -35,6 +35,8 @@ m_panned = new Panned; m_panner = new Panner; + m_panned->setDragMode(QGraphicsView::ScrollHandDrag); + QGridLayout *layout = new QGridLayout; layout->addWidget(m_panned, 0, 0); layout->addWidget(m_panner, 0, 1); @@ -259,6 +261,9 @@ connect(scene, SIGNAL(diffWorkingFolder()), this, SIGNAL(diffWorkingFolder())); + connect(scene, SIGNAL(showSummary()), + this, SIGNAL(showSummary())); + connect(scene, SIGNAL(showWork()), this, SIGNAL(showWork())); diff -r 94be1e218655 -r 4bad3c5c053a historywidget.h --- a/historywidget.h Wed Dec 08 16:57:18 2010 +0000 +++ b/historywidget.h Tue Dec 14 17:20:10 2010 +0000 @@ -49,6 +49,7 @@ void commit(); void revert(); void diffWorkingFolder(); + void showSummary(); void showWork(); void updateTo(QString id); diff -r 94be1e218655 -r 4bad3c5c053a mainwindow.cpp --- a/mainwindow.cpp Wed Dec 08 16:57:18 2010 +0000 +++ b/mainwindow.cpp Tue Dec 14 17:20:10 2010 +0000 @@ -305,7 +305,7 @@ tr("

%1

%2").arg(cf) .arg(tr("You are about to commit the following files:")), tr("

%1

%2").arg(cf) - .arg(tr("You are about to commit %n file(s):", "", reportFiles.size())), + .arg(tr("You are about to commit %n file(s).", "", reportFiles.size())), reportFiles, comment)) { @@ -438,6 +438,15 @@ mergeBinaryName = merge; } +void MainWindow::hgShowSummary() +{ + QStringList params; + + params << "diff" << "--stat"; + + runner->requestAction(HgAction(ACT_DIFF_SUMMARY, workFolderPath, params)); +} + void MainWindow::hgFolderDiff() { if (diffBinaryName == "") return; @@ -1166,15 +1175,16 @@ QString MainWindow::format3(QString head, QString intro, QString code) { + code = xmlEncode(code).replace("\n", "
").replace(" ", " "); if (intro == "") { - return QString("

%1

%2") - .arg(head).arg(xmlEncode(code).replace("\n", "
")); + return QString("

%1

%2

") + .arg(head).arg(code); } else if (code == "") { return QString("

%1

%2

") .arg(head).arg(intro); } else { - return QString("

%1

%2

%3") - .arg(head).arg(intro).arg(xmlEncode(code).replace("\n", "
")); + return QString("

%1

%2

%3

") + .arg(head).arg(intro).arg(code); } } @@ -1431,6 +1441,13 @@ shouldHgStat = true; break; + case ACT_DIFF_SUMMARY: + QMessageBox::information(this, tr("Change summary"), + format3(tr("Summary of uncommitted changes"), + "", + output)); + break; + case ACT_FOLDERDIFF: case ACT_CHGSETDIFF: case ACT_SERVE: @@ -1576,6 +1593,9 @@ connect(hgTabs, SIGNAL(diffWorkingFolder()), this, SLOT(hgFolderDiff())); + + connect(hgTabs, SIGNAL(showSummary()), + this, SLOT(hgShowSummary())); connect(hgTabs, SIGNAL(updateTo(QString)), this, SLOT(hgUpdateToRev(QString))); diff -r 94be1e218655 -r 4bad3c5c053a mainwindow.h --- a/mainwindow.h Wed Dec 08 16:57:18 2010 +0000 +++ b/mainwindow.h Tue Dec 14 17:20:10 2010 +0000 @@ -74,6 +74,7 @@ void hgRemove(); void hgAdd(); void hgCommit(); + void hgShowSummary(); void hgFolderDiff(); void hgDiffToCurrent(QString); void hgDiffToParent(QString, QString); diff -r 94be1e218655 -r 4bad3c5c053a panned.cpp --- a/panned.cpp Wed Dec 08 16:57:18 2010 +0000 +++ b/panned.cpp Tue Dec 14 17:20:10 2010 +0000 @@ -20,11 +20,18 @@ #include #include +#include + +#include #include -Panned::Panned() +Panned::Panned() : + m_dragging(false) { + m_dragTimer = new QTimer(this); + m_dragTimerMs = 50; + connect(m_dragTimer, SIGNAL(timeout()), this, SLOT(dragTimerTimeout())); setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing); } @@ -149,6 +156,93 @@ } void +Panned::mousePressEvent(QMouseEvent *ev) +{ + if (dragMode() != QGraphicsView::ScrollHandDrag || + ev->button() != Qt::LeftButton) { + QGraphicsView::mousePressEvent(ev); + return; + } + + DEBUG << "Panned::mousePressEvent: have left button in drag mode" << endl; + + setDragMode(QGraphicsView::NoDrag); + QGraphicsView::mousePressEvent(ev); + setDragMode(QGraphicsView::ScrollHandDrag); + + if (!ev->isAccepted()) { + ev->accept(); + m_dragging = true; + m_lastDragPos = ev->pos(); + m_lastOrigin = QPoint(horizontalScrollBar()->value(), + verticalScrollBar()->value()); + m_velocity = QPointF(0, 0); + m_dragTimer->start(m_dragTimerMs); + } + +} + +void +Panned::mouseMoveEvent(QMouseEvent *ev) +{ + if (!m_dragging) { + QGraphicsView::mouseMoveEvent(ev); + return; + } + DEBUG << "Panned::mouseMoveEvent: dragging" << endl; + ev->accept(); + QScrollBar *hBar = horizontalScrollBar(); + QScrollBar *vBar = verticalScrollBar(); + QPoint delta = ev->pos() - m_lastDragPos; + hBar->setValue(hBar->value() + (isRightToLeft() ? delta.x() : -delta.x())); + vBar->setValue(vBar->value() - delta.y()); + m_lastDragPos = ev->pos(); +} + +void +Panned::mouseReleaseEvent(QMouseEvent *ev) +{ + if (!m_dragging) { + QGraphicsView::mouseReleaseEvent(ev); + return; + } + DEBUG << "Panned::mouseReleaseEvent: dragging" << endl; + ev->accept(); + m_dragging = false; +} + +void +Panned::dragTimerTimeout() +{ + QPoint origin = QPoint(horizontalScrollBar()->value(), + verticalScrollBar()->value()); + if (m_dragging) { + m_velocity = QPointF + (float(origin.x() - m_lastOrigin.x()) / m_dragTimerMs, + float(origin.y() - m_lastOrigin.y()) / m_dragTimerMs); + m_lastOrigin = origin; + DEBUG << "Panned::dragTimerTimeout: velocity = " << m_velocity << endl; + } else { + if (origin == m_lastOrigin) { + m_dragTimer->stop(); + } + float x = m_velocity.x(), y = m_velocity.y(); + if (fabsf(x) > 1.0/m_dragTimerMs) x = x * 0.9f; + else x = 0.f; + if (fabsf(y) > 1.0/m_dragTimerMs) y = y * 0.9f; + else y = 0.f; + m_velocity = QPointF(x, y); + DEBUG << "Panned::dragTimerTimeout: velocity adjusted to " << m_velocity << endl; + m_lastOrigin = origin; + //!!! need to store origin in floats + horizontalScrollBar()->setValue(m_lastOrigin.x() + + m_velocity.x() * m_dragTimerMs); + verticalScrollBar()->setValue(m_lastOrigin.y() + + m_velocity.y() * m_dragTimerMs); + } +} + +void Panned::leaveEvent(QEvent *) { emit mouseLeaves(); diff -r 94be1e218655 -r 4bad3c5c053a panned.h --- a/panned.h Wed Dec 08 16:57:18 2010 +0000 +++ b/panned.h Tue Dec 14 17:20:10 2010 +0000 @@ -22,6 +22,7 @@ class QWheelEvent; class QEvent; +class QTimer; class Panned : public QGraphicsView { @@ -46,9 +47,23 @@ void zoomIn(); void zoomOut(); +private slots: + void dragTimerTimeout(); + protected: QRectF m_pannedRect; + QPoint m_lastDragPos; + QPoint m_lastOrigin; + QPointF m_velocity; + bool m_dragging; + int m_dragTimerMs; + QTimer *m_dragTimer; + + virtual void mousePressEvent(QMouseEvent *); + virtual void mouseMoveEvent(QMouseEvent *); + virtual void mouseReleaseEvent(QMouseEvent *); + virtual void paintEvent(QPaintEvent *); virtual void resizeEvent(QResizeEvent *); virtual void drawForeground(QPainter *, const QRectF &); diff -r 94be1e218655 -r 4bad3c5c053a uncommitteditem.cpp --- a/uncommitteditem.cpp Wed Dec 08 16:57:18 2010 +0000 +++ b/uncommitteditem.cpp Tue Dec 14 17:20:10 2010 +0000 @@ -35,6 +35,7 @@ m_font.setPixelSize(11); m_font.setBold(false); m_font.setItalic(false); + setCursor(Qt::ArrowCursor); } QRectF @@ -76,6 +77,8 @@ QAction *dif = menu->addAction(tr("Diff")); connect(dif, SIGNAL(triggered()), this, SIGNAL(diff())); + QAction *stat = menu->addAction(tr("Show summary")); + connect(stat, SIGNAL(triggered()), this, SIGNAL(showSummary())); menu->addSeparator(); diff -r 94be1e218655 -r 4bad3c5c053a uncommitteditem.h --- a/uncommitteditem.h Wed Dec 08 16:57:18 2010 +0000 +++ b/uncommitteditem.h Tue Dec 14 17:20:10 2010 +0000 @@ -18,13 +18,12 @@ #ifndef UNCOMMITTEDITEM_H #define UNCOMMITTEDITEM_H -#include +#include #include -class UncommittedItem : public QObject, public QGraphicsItem +class UncommittedItem : public QGraphicsObject { Q_OBJECT - Q_INTERFACES(QGraphicsItem) public: UncommittedItem(); @@ -50,6 +49,7 @@ void commit(); void revert(); void diff(); + void showSummary(); void showWork(); protected: