libyui-qt
YQLogView.h
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: YQLogView.h
20 
21  Author: Stefan Hundhammer <shundhammer@suse.de>
22 
23 /-*/
24 
25 
26 #ifndef YQLogView_h
27 #define YQLogView_h
28 
29 #include <QFrame>
30 #include <QTextEdit>
31 
32 #include <yui/YLogView.h>
33 
34 class YQWidgetCaption;
35 class MyTextEdit;
36 
37 
38 
39 class YQLogView : public QFrame, public YLogView
40 {
41  Q_OBJECT
42 
43 public:
44 
48  YQLogView( YWidget * parent,
49  const std::string & label,
50  int visibleLines,
51  int maxLines );
52 
56  virtual ~YQLogView();
57 
58 protected:
67  virtual void displayLogText( const std::string & text );
68 
69 public:
70 
76  virtual void setLabel( const std::string & label );
77 
83  virtual void setEnabled( bool enabled );
84 
90  virtual int preferredWidth();
91 
97  virtual int preferredHeight();
98 
104  virtual void setSize( int newWidth, int newHeight );
105 
109  virtual bool setKeyboardFocus();
110 
111 
112 protected:
113 
114  YQWidgetCaption * _caption;
115  MyTextEdit * _qt_text;
116  QString _lastText;
117 
118 private slots:
119  void slotResize();
120 
121 };
122 
123 
124 // We need a resize event in order to set the cursor to the last line
125 // for the auto-scroll feature
126 class MyTextEdit : public QTextEdit
127 {
128  Q_OBJECT
129 public:
130  MyTextEdit( QWidget* parent ) : QTextEdit (parent) {}
131 
132 protected:
133 
134  void resizeEvent ( QResizeEvent * event )
135  {
136  emit resized();
137  QTextEdit::resizeEvent(event);
138  }
139 
140 signals:
141  void resized();
142 
143 };
144 
145 
146 #endif // YQLogView_h
Definition: YQLogView.h:39
virtual void displayLogText(const std::string &text)
Definition: YQLogView.cc:82
YQLogView(YWidget *parent, const std::string &label, int visibleLines, int maxLines)
Definition: YQLogView.cc:42
virtual int preferredWidth()
Definition: YQLogView.cc:137
virtual bool setKeyboardFocus()
Definition: YQLogView.cc:181
virtual void setLabel(const std::string &label)
Definition: YQLogView.cc:120
virtual void setEnabled(bool enabled)
Definition: YQLogView.cc:128
virtual int preferredHeight()
Definition: YQLogView.cc:144
virtual ~YQLogView()
Definition: YQLogView.cc:75
Definition: YQLogView.h:126
virtual void setSize(int newWidth, int newHeight)
Definition: YQLogView.cc:174
Definition: YQWidgetCaption.h:38