~l3on/ubuntu/precise/rkward/rebuild1

« back to all changes in this revision

Viewing changes to rkward/windows/rkcommandlog.h

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Friedrichsmeier
  • Date: 2008-04-20 21:30:00 UTC
  • mfrom: (1.2.2 upstream) (3.1.9 hardy)
  • Revision ID: james.westby@ubuntu.com-20080420213000-fs4i8efmfc793bnn
new upstream release
closes: #475175
closes: #463348
closes: #475982

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
                          rkcommandlog  -  description
 
3
                             -------------------
 
4
    begin                : Sun Nov 3 2002
 
5
    copyright            : (C) 2002, 2004, 2005, 2006, 2007 by Thomas Friedrichsmeier
 
6
    email                : tfry@users.sourceforge.net
 
7
 ***************************************************************************/
 
8
 
 
9
/***************************************************************************
 
10
 *                                                                         *
 
11
 *   This program is free software; you can redistribute it and/or modify  *
 
12
 *   it under the terms of the GNU General Public License as published by  *
 
13
 *   the Free Software Foundation; either version 2 of the License, or     *
 
14
 *   (at your option) any later version.                                   *
 
15
 *                                                                         *
 
16
 ***************************************************************************/
 
17
 
 
18
#ifndef RKCOMMANDLOG_H
 
19
#define RKCOMMANDLOG_H
 
20
 
 
21
#include <qstring.h>
 
22
#include <qtextedit.h>
 
23
#include <kmdichildview.h>
 
24
 
 
25
#include "rkmdiwindow.h"
 
26
#include "../rbackend/rcommandreceiver.h"
 
27
 
 
28
class RCommand;
 
29
class ROutput;
 
30
class QPushButton;
 
31
class QTextEdit;
 
32
class RKCommandEditor;
 
33
class QBoxLayout;
 
34
class RKCommandLogView;
 
35
class RKCommandLogPart;
 
36
 
 
37
/**
 
38
        \brief This widget shows all executed commands and their result
 
39
@author Thomas Friedrichsmeier
 
40
*/
 
41
 
 
42
class RKCommandLog : public RKMDIWindow, public RCommandReceiver {
 
43
        Q_OBJECT
 
44
public: 
 
45
/** Adds input to the log_view-window (i.e. commands issued) */
 
46
        void addInput (RCommand *command);
 
47
/** Adds output to the log_view-window (i.e. replies received) */
 
48
        void newOutput (RCommand *command, ROutput *output_fragment);
 
49
 
 
50
        static RKCommandLog *getLog () { return rkcommand_log; };
 
51
 
 
52
        RKCommandLogView *getView () { return log_view; };
 
53
protected:
 
54
/** Command has finished. If the command has failed, it may be necessary to print some more information */
 
55
        void rCommandDone (RCommand *command);
 
56
        RKCommandLog (QWidget *parent, bool tool_window, const char *name=0);
 
57
        ~RKCommandLog ();
 
58
public slots:
 
59
/** configures the log_view-window */
 
60
        void configureLog ();
 
61
/** clears the log_view-window */
 
62
        void clearLog ();
 
63
        void runSelection ();
 
64
private:
 
65
        void addInputNoCheck (RCommand *command);
 
66
        void addOutputNoCheck (RCommand *command, ROutput *output);
 
67
        void checkRaiseWindow (RCommand *command);
 
68
/** internal helper function, called whenever a line/lines have been added. Check whether log is longer than maximum setting. Scroll to the bottom */
 
69
        void linesAdded ();
 
70
/** Id of last command the input (i.e. the command itself) was shown for. Used to keep track of whether a command's input should be shown or not */
 
71
        int command_input_shown;
 
72
/** On a given command, the log_view should not be raised more than once */
 
73
        int last_raised_command;
 
74
 
 
75
        RKCommandLogView *log_view;
 
76
friend class RKWardMainWindow;
 
77
        static RKCommandLog *rkcommand_log;
 
78
};
 
79
 
 
80
/** Simply subclass of QTextEdit to override context menu handling */
 
81
class RKCommandLogView : public QTextEdit {
 
82
        Q_OBJECT
 
83
public:
 
84
        RKCommandLogView (RKCommandLog *parent);
 
85
        ~RKCommandLogView ();
 
86
public slots:
 
87
        void selectAll ();
 
88
signals:
 
89
        void popupMenuRequest (const QPoint &pos);
 
90
protected:
 
91
        bool eventFilter (QObject *o, QEvent *e);
 
92
};
 
93
 
 
94
#include <kparts/part.h>
 
95
 
 
96
class KAction;
 
97
 
 
98
/** Provides a part interface for the RKCommandLog */
 
99
class RKCommandLogPart : public KParts::Part {
 
100
        Q_OBJECT
 
101
public:
 
102
        explicit RKCommandLogPart (RKCommandLog *for_log);
 
103
        ~RKCommandLogPart ();
 
104
public slots:
 
105
        void doPopupMenu (const QPoint &pos);
 
106
private:
 
107
        RKCommandLog *log;
 
108
 
 
109
        KAction *run_selection;
 
110
        KAction *copy;
 
111
};
 
112
 
 
113
#endif