Eneboo - Documentación para desarrolladores
src/qt/tools/linguist/linguist/msgedit.h
Ir a la documentación de este archivo.
00001 /**********************************************************************
00002 ** Copyright (C) 2000-2005 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of Qt Linguist.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
00012 ** licenses may use this file in accordance with the Qt Commercial License
00013 ** Agreement provided with the Software.
00014 **
00015 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00016 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00017 **
00018 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00019 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00020 **   information about Qt Commercial License Agreements.
00021 **
00022 ** Contact info@trolltech.com if any conditions of this licensing are
00023 ** not clear to you.
00024 **
00025 **********************************************************************/
00026 
00027 #ifndef MSGEDIT_H
00028 #define MSGEDIT_H
00029 
00030 #include "trwindow.h"
00031 #include "phrase.h"
00032 
00033 #include <metatranslator.h>
00034 
00035 #include <qsplitter.h>
00036 #include <qstring.h>
00037 #include <qstringlist.h>
00038 #include <qvaluelist.h>
00039 #include <qscrollview.h>
00040 #include <qpixmap.h>
00041 #include <qbitmap.h>
00042 #include <qtooltip.h>
00043 
00044 class QAccel;
00045 class QDockArea;
00046 class QDockWindow;
00047 class QLabel;
00048 class QListView;
00049 class QListViewItem;
00050 class QTextView;
00051 class QVBoxLayout;
00052 
00053 class EditorPage;
00054 class MED;
00055 class PhraseLV;
00056 
00057 class PageCurl : public QWidget
00058 {
00059     Q_OBJECT
00060 public:
00061     PageCurl( QWidget * parent = 0, const char * name = 0,
00062               WFlags f = 0 )
00063         : QWidget( parent, name, f )
00064     {
00065         QPixmap px = TrWindow::pageCurl();
00066         if ( px.mask() ) {
00067             setMask( *px.mask() );
00068         }
00069         setBackgroundPixmap( px );
00070         setFixedSize( px.size() );
00071         
00072         QRect r( 34, 0, width()-34, 19 );
00073         QToolTip::add( this, r, tr("Next unfinished phrase") );
00074         r.setSize( QSize(width()-34, height()-20) );
00075         r.setX( 0 );
00076         r.setY( 20 );
00077         QToolTip::add( this, r, tr("Previous unfinished phrase") );
00078     }
00079     
00080 protected:
00081     void mouseReleaseEvent( QMouseEvent * e )
00082     {
00083         int x = e->pos().x() - 14;
00084         int y = e->pos().y() - 8;
00085                 
00086         if ( y <= x )
00087             emit nextPage();
00088         else
00089             emit prevPage();
00090     }
00091     
00092 signals:
00093     void prevPage();
00094     void nextPage();
00095 };
00096 
00097 class ShadowWidget : public QWidget
00098 {    
00099 public:
00100     ShadowWidget( QWidget * parent = 0, const char * name = 0 );
00101     ShadowWidget( QWidget * child, QWidget * parent = 0, const char * name = 0 );
00102     
00103     void setShadowWidth( int width ) { sWidth = width; }
00104     int  shadowWidth() const { return sWidth; }
00105     void setMargin( int margin ){ wMargin = margin; }
00106     int  margin() const { return wMargin; }
00107     void setWidget( QWidget * child);
00108     
00109 protected:
00110     void resizeEvent( QResizeEvent * e );
00111     void paintEvent( QPaintEvent * e );
00112     
00113 private:
00114     int sWidth;
00115     int wMargin;
00116     QWidget * childWgt;
00117 };
00118 
00119 class EditorPage : public QFrame
00120 {
00121     Q_OBJECT
00122 public:
00123     EditorPage( QWidget * parent = 0, const char * name = 0 );
00124     
00125 protected:
00126     void resizeEvent( QResizeEvent * );
00127     void layoutWidgets();
00128     void updateCommentField();
00129     void calculateFieldHeight( QTextView * field );
00130     void fontChange( const QFont & );
00131     
00132 private:
00133     PageCurl * pageCurl;
00134     QLabel * srcTextLbl;
00135     QLabel * transLbl;
00136     QTextView * srcText;
00137     QTextView * cmtText;
00138     MED   * translationMed;
00139 
00140     friend class MessageEditor;
00141     
00142 private slots:
00143     void handleTranslationChanges();
00144     void handleSourceChanges();
00145     void handleCommentChanges();
00146     
00147 signals:
00148     void pageHeightUpdated( int height );
00149 };
00150 
00151 class MessageEditor : public QWidget
00152 {
00153     Q_OBJECT
00154 public:
00155     MessageEditor( MetaTranslator * t, QWidget * parent = 0,
00156                    const char * name = 0 );
00157     QListView * sourceTextList() const;
00158     QListView * phraseList() const;
00159     
00160     void showNothing();
00161     void showContext( const QString& context, bool finished );
00162     void showMessage( const QString& text, const QString& comment,
00163                       const QString& fullContext, const QString& translation,
00164                       MetaTranslatorMessage::Type type,
00165                       const QValueList<Phrase>& phrases );
00166     void setFinished( bool finished );
00167     bool eventFilter( QObject *, QEvent * );
00168 
00169 signals:
00170     void translationChanged( const QString& translation );
00171     void finished( bool finished );
00172     void prevUnfinished();
00173     void nextUnfinished();
00174     void updateActions( bool enable );
00175     
00176     void undoAvailable( bool avail );
00177     void redoAvailable( bool avail );
00178     void cutAvailable( bool avail );
00179     void copyAvailable( bool avail );
00180     void pasteAvailable( bool avail );
00181 
00182     void focusSourceList();
00183     void focusPhraseList();
00184     
00185 public slots:
00186     void undo();
00187     void redo();
00188     void cut();
00189     void copy();
00190     void paste();
00191     void del();
00192     void selectAll();
00193     void beginFromSource();
00194     void toggleGuessing();
00195     void finishAndNext();
00196 
00197 private slots:
00198     void emitTranslationChanged();
00199     void guessActivated( int accelKey );
00200     void insertPhraseInTranslation( QListViewItem *item );
00201     void insertPhraseInTranslationAndLeave( QListViewItem *item );
00202     void updateButtons();
00203     void updateCanPaste();
00204     void toggleFinished();
00205 
00206     void updatePageHeight( int height );
00207     
00208 protected:
00209     void resizeEvent( QResizeEvent * );
00210     
00211 private:
00212     void setTranslation( const QString& translation, bool emitt );
00213     void setEditionEnabled( bool enabled );
00214 
00215     QListView * srcTextList;
00216     QDockArea * topDock, * bottomDock;
00217     QDockWindow * topDockWnd, *bottomDockWnd;
00218     EditorPage * editorPage;
00219     QVBoxLayout * v;
00220 
00221     QLabel * phraseLbl;
00222     PhraseLV * phraseLv;
00223     QAccel * accel;
00224     bool itemFinished;
00225     
00226     ShadowWidget * sw;
00227     QScrollView * sv;
00228     
00229     MetaTranslator *tor;
00230     QString sourceText;
00231     QStringList guesses;
00232     bool mayOverwriteTranslation;
00233     bool canPaste;
00234     bool doGuesses;
00235 };
00236 
00237 #endif
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'