File indexing completed on 2024-05-12 05:44:26

0001 /***************************************************************************
0002  *   Copyright (C) 2006-2009 by Rajko Albrecht                             *
0003  *   ral@alwins-world.de                                                   *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  *                                                                         *
0010  *   This program is distributed in the hope that it will be useful,       *
0011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0013  *   GNU General Public License for more details.                          *
0014  *                                                                         *
0015  *   You should have received a copy of the GNU General Public License     *
0016  *   along with this program; if not, write to the                         *
0017  *   Free Software Foundation, Inc.,                                       *
0018  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
0019  ***************************************************************************/
0020 #ifndef REVGRAPHVIEW_H
0021 #define REVGRAPHVIEW_H
0022 
0023 #include <svnqt/client.h>
0024 #include <svnqt/revision.h>
0025 
0026 #include <QContextMenuEvent>
0027 #include <QGraphicsView>
0028 #include <QMouseEvent>
0029 #include <QProcess>
0030 #include <QResizeEvent>
0031 
0032 namespace svn
0033 {
0034 class LogEntry;
0035 }
0036 
0037 class QTemporaryFile;
0038 class KProcess;
0039 class RevisionTree;
0040 class GraphTreeLabel;
0041 class GraphMark;
0042 class PannerView;
0043 class QGraphicsScene;
0044 class GraphTreeLabel;
0045 
0046 /**
0047     @author Rajko Albrecht <ral@alwins-world.de>
0048 */
0049 class RevGraphView : public QGraphicsView
0050 {
0051     Q_OBJECT
0052 public:
0053     enum ZoomPosition { TopLeft, TopRight, BottomLeft, BottomRight, Auto };
0054     /* avoid large copy operations */
0055     friend class RevisionTree;
0056 
0057     RevGraphView(const svn::ClientP &_client, QWidget *parent = nullptr);
0058     ~RevGraphView() override;
0059 
0060     void showText(const QString &s);
0061     void clear();
0062 
0063     void beginInsert();
0064     void endInsert();
0065 
0066     struct targetData {
0067         char Action;
0068         QString key;
0069         targetData(const QString &n, char _a)
0070             : Action(_a)
0071             , key(n)
0072         {
0073         }
0074     };
0075     typedef QList<targetData> tlist;
0076 
0077     struct keyData {
0078         QString name, Author, Date, Message;
0079         long rev;
0080         char Action;
0081         tlist targets;
0082     };
0083 
0084     typedef QMap<QString, keyData> trevTree;
0085 
0086     QString toolTip(const QString &nodename, bool full = false) const;
0087 
0088     void setBasePath(const QString &);
0089     void dumpRevtree();
0090 
0091 signals:
0092     void dispDetails(const QString &);
0093     void makeCat(const svn::Revision &, const QString &, const QString &, const svn::Revision &, QWidget *);
0094     void makeNorecDiff(const QString &, const svn::Revision &, const QString &, const svn::Revision &, QWidget *);
0095     void makeRecDiff(const QString &, const svn::Revision &, const QString &, const svn::Revision &, QWidget *);
0096 
0097 public slots:
0098     virtual void zoomRectMoved(qreal, qreal);
0099     virtual void zoomRectMoveFinished();
0100     virtual void slotClientException(const QString &what);
0101 
0102 protected slots:
0103     virtual void readDotOutput();
0104     virtual void dotExit(int, QProcess::ExitStatus);
0105 
0106 protected:
0107     QGraphicsScene *m_Scene;
0108     GraphMark *m_Marker;
0109     svn::ClientP m_Client;
0110     GraphTreeLabel *m_Selected;
0111     QTemporaryFile *m_dotTmpFile;
0112     QString m_dotOutput;
0113     KProcess *m_renderProcess;
0114     trevTree m_Tree;
0115     QColor getBgColor(const QString &nodeName) const;
0116     bool isStart(const QString &nodeName) const;
0117     char getAction(const QString &) const;
0118     QString getLabelstring(const QString &nodeName);
0119 
0120     QMap<QString, GraphTreeLabel *> m_NodeList;
0121     QMap<QString, QString> m_LabelMap;
0122 
0123     int m_xMargin, m_yMargin;
0124     PannerView *m_CompleteView;
0125     double m_cvZoom;
0126     ZoomPosition m_LastAutoPosition;
0127 
0128     void resizeEvent(QResizeEvent *) override;
0129     void mousePressEvent(QMouseEvent *e) override;
0130     void mouseReleaseEvent(QMouseEvent *e) override;
0131     void mouseMoveEvent(QMouseEvent *e) override;
0132     void contextMenuEvent(QContextMenuEvent *e) override;
0133     void mouseDoubleClickEvent(QMouseEvent *e) override;
0134     void scrollContentsBy(int dx, int dy) override;
0135 
0136     GraphTreeLabel *firstLabelAt(const QPoint &pos) const;
0137 
0138     bool m_isMoving;
0139     QPoint m_lastPos;
0140 
0141     bool m_noUpdateZoomerPos;
0142 
0143     QString m_basePath;
0144 
0145 private:
0146     void updateSizes(QSize s = QSize(0, 0));
0147     void updateZoomerPos();
0148     void setNewDirection(int dir);
0149     void makeDiffPrev(GraphTreeLabel *);
0150     void makeDiff(const QString &, const QString &);
0151     void makeSelected(GraphTreeLabel *);
0152     void makeCat(GraphTreeLabel *_l);
0153 };
0154 
0155 #endif