summaryrefslogtreecommitdiffstats
path: root/vcs/cvsservice/annotatepage.h
blob: 2a06280495583ae07af4bcf6c20b22416ad6bae2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/***************************************************************************
 *   Copyright (C) 2005 by Robert Gruber                                   *
 *   rgruber@users.sourceforge.net                                         *
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef ANNOTATEPAGE_H
#define ANNOTATEPAGE_H

#include "cvsservicedcopIface.h"
#include <qwidget.h>
#include <qmap.h>
#include <qlistview.h>

class CvsJob_stub;
class CvsService_stub;
class QTextBrowser;
class AnnotateView;
class QStringList;
class KLineEdit;
class KPushButton;

/**
 * Implementation for the page displaying 'cvs annotate' output.
 * To the top of the page the user can enter a revision and request
 * a annotate run for it.
 * The main widget of a page is the AnnotateView. It holds the output
 * of the cvs annotate job. See there for further detail.
 *
 * @author Robert Gruber <rgruber@users.sourceforge.net>
 */
class AnnotatePage : public QWidget, virtual public CVSServiceDCOPIface
{
    Q_OBJECT

    friend class AnnotateDialog;
    friend class AnnotateView;

public:
    AnnotatePage( CvsService_stub *cvsService, QWidget *parent=0, const char *name=0, int flags=0 );
    virtual ~AnnotatePage();

    /**
     * Call cvs annotate for the given file and revistion.
     * @param pathName The filename to annotate
     * @param revision The CVS revision number
     */
    void startAnnotate( const QString pathName, const QString revision="" );

    /**
     * Cancels the current operation if any
     */
    void cancel();

signals:
    /**
     * This signal is ment to be emitted by the nested AnnotateView.
     * The dialog that holds this page catches it in order to create
     * a new page with the annotate output for the given revision.
     * @param rev The revision for which a new annotate run is requested
     */
    void requestAnnotate(const QString rev);

private slots:
    // DCOP Iface
    virtual void slotJobExited( bool normalExit, int exitStatus );
    virtual void slotReceivedOutput( QString someOutput );
    virtual void slotReceivedErrors( QString someErrors );

    /**
     * This slot is connected to the button next to m_leRevision.
     * It clears the AnnotateView and reruns cvs annotate with the
     * revision the user entered into m_leRevision
     */
    void slotNewAnnotate();

private:
    /**
     * This method is executed after the cvs annotate job finished.
     * It parses the output and passes it to the AnnotateView
     */
    void parseAnnotateOutput(QStringList& lines);


    /**
     * This is the output buffer for the cvs annotate job.
     * Everytime slotReceivedOutput() is called by dcop
     * we append the gained data to this buffer.
     */
    QString m_output;
    /**
     * This is the AnnotateView. It gets nested into this page.
     */
    AnnotateView *m_annotateView;
    /**
     * The file for which this page holds the annotate output.
     */
    QString m_pathName;
    /**
     * Maps the checkin comments to revision numbers
     */
    QMap<QString, QString>  m_comments;

    /**
     * With this KLineEdit and the KPushButton next to it
     * the user can rerun cvs annotate for any revision he
     * enters into this KLineEdit.
     */
    KLineEdit *m_leRevision;
    /**
     * With this KPushButton the user can rerun cvs annotate
     * for the revision he entered into m_leRevision
     */
    KPushButton *m_btnAnnotate;

    CvsService_stub *m_cvsService;
    CvsJob_stub *m_cvsAnnotateJob;
};

#endif