libyui-qt  2.43.5
/usr/src/RPM/BUILD/libyui-qt-2.43.5/src/YQLogView.h
00001 /*
00002   Copyright (C) 2000-2012 Novell, Inc
00003   This library is free software; you can redistribute it and/or modify
00004   it under the terms of the GNU Lesser General Public License as
00005   published by the Free Software Foundation; either version 2.1 of the
00006   License, or (at your option) version 3.0 of the License. This library
00007   is distributed in the hope that it will be useful, but WITHOUT ANY
00008   WARRANTY; without even the implied warranty of MERCHANTABILITY or
00009   FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
00010   License for more details. You should have received a copy of the GNU
00011   Lesser General Public License along with this library; if not, write
00012   to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
00013   Floor, Boston, MA 02110-1301 USA
00014 */
00015 
00016 
00017 /*-/
00018 
00019   File:       YQLogView.h
00020 
00021   Author:     Stefan Hundhammer <sh@suse.de>
00022 
00023 /-*/
00024 
00025 
00026 #ifndef YQLogView_h
00027 #define YQLogView_h
00028 
00029 #include <QFrame>
00030 #include <QTextEdit>
00031 
00032 #include <yui/YLogView.h>
00033 
00034 class YQWidgetCaption;
00035 class MyTextEdit;
00036 
00037 
00038 
00039 class YQLogView : public QFrame, public YLogView
00040 {
00041     Q_OBJECT
00042 
00043 public:
00044 
00045     /**
00046      * Constructor
00047      **/
00048     YQLogView( YWidget *        parent,
00049                const std::string &      label,
00050                int              visibleLines,
00051                int              maxLines );
00052 
00053     /**
00054      * Destructor.
00055      **/
00056     virtual ~YQLogView();
00057 
00058 protected:
00059     /**
00060      * Display the part of the log text that should be displayed.
00061      * 'text' contains the last 'visibleLines()' lines.
00062      * This is called whenever the log text changes. Note that the text might
00063      * also be empty, in which case the displayed log text should be cleared.
00064      *
00065      * Implemented from YLogView.
00066      **/
00067     virtual void displayLogText( const std::string & text );
00068 
00069 public:
00070 
00071     /**
00072      * Set the label (the caption above the log text).
00073      *
00074      * Reimplemented from YLogView.
00075      **/
00076     virtual void setLabel( const std::string & label );
00077 
00078     /**
00079      * Set enabled/disabled state.
00080      *
00081      * Reimplemented from YWidget.
00082      **/
00083     virtual void setEnabled( bool enabled );
00084 
00085     /**
00086      * Preferred width of the widget.
00087      *
00088      * Reimplemented from YWidget.
00089      **/
00090     virtual int preferredWidth();
00091 
00092     /**
00093      * Preferred height of the widget.
00094      *
00095      * Reimplemented from YWidget.
00096      **/
00097     virtual int preferredHeight();
00098 
00099     /**
00100      * Set the new size of the widget.
00101      *
00102      * Reimplemented from YWidget.
00103      **/
00104     virtual void setSize( int newWidth, int newHeight );
00105 
00106     /**
00107      * Accept the keyboard focus.
00108      **/
00109     virtual bool setKeyboardFocus();
00110 
00111 
00112 protected:
00113 
00114     YQWidgetCaption *   _caption;
00115     MyTextEdit *        _qt_text;
00116     QString _lastText;
00117 
00118 private slots:
00119     void slotResize();
00120 
00121 };
00122 
00123 
00124 // We need a resize event in order to set the cursor to the last line
00125 // for the auto-scroll feature
00126 class MyTextEdit : public QTextEdit
00127 {
00128   Q_OBJECT
00129   public:
00130     MyTextEdit( QWidget* parent ) : QTextEdit (parent) {}
00131 
00132   protected:
00133     void resizeEvent ( QResizeEvent * event )
00134     { emit resized();
00135       QTextEdit::resizeEvent(event);
00136     }
00137 
00138   signals:
00139     void resized();
00140 
00141 };
00142 
00143 
00144 #endif // YQLogView_h
 All Classes Functions Variables