@ -25,23 +25,23 @@
# include "evaluator.h"
# include "result.h"
# include <qapplication.h>
# include <qlabel.h>
# include <qlineedit.h>
# include <qlistbox.h>
# include <qpainter.h>
# include <qregexp.h>
# include <qstringlist.h>
# include <qstyle.h>
# include <qsyntaxhighlighter.h>
# include <qtimer.h>
# include <qtooltip.h>
# include <qmessagebox.h>
# include <qvbox.h>
# include <t qapplication.h>
# include <t qlabel.h>
# include <t qlineedit.h>
# include <t qlistbox.h>
# include <t qpainter.h>
# include <t qregexp.h>
# include <t qstringlist.h>
# include <t qstyle.h>
# include <t qsyntaxhighlighter.h>
# include <t qtimer.h>
# include <t qtooltip.h>
# include <t qmessagebox.h>
# include <t qvbox.h>
# include <netwm.h>
# include <fixx11h.h> // netwm.h includes X11 headers which conflict with qevent
# include <qevent.h>
# include <t qevent.h>
# include <kdebug.h>
@ -50,26 +50,26 @@
// XXX: QT 4: Replace this with qBinaryFind().
using std : : binary_search ;
class CalcResultLabel : public QLabel
class CalcResultLabel : public T QLabel
{
public :
CalcResultLabel ( QWidget * parent , const char * name , int WFlags ) :
QLabel ( parent , name , WFlags )
CalcResultLabel ( T QWidget * tq parent, const char * name , int WFlags ) :
T QLabel( tq parent, name , WFlags )
{
}
protected :
virtual void mousePressEvent ( QMouseEvent * )
virtual void mousePressEvent ( T QMouseEvent * )
{
hide ( ) ;
}
} ;
class EditorHighlighter : public QSyntaxHighlighter
class EditorHighlighter : public T QSyntaxHighlighter
{
public :
EditorHighlighter ( Editor * ) ;
int highlightParagraph ( const QString & text , int ) ;
int highlightParagraph ( const T QString & text , int ) ;
private :
Editor * editor ;
@ -79,50 +79,50 @@ class Editor::Private
{
public :
Evaluator * eval ;
QStringList history ;
T QStringList history ;
int index ;
bool autoCompleteEnabled ;
EditorCompletion * completion ;
QTimer * completionTimer ;
T QTimer* completionTimer ;
bool autoCalcEnabled ;
char format ;
int decimalDigits ;
QTimer * autoCalcTimer ;
QLabel * autoCalcLabel ;
T QTimer* autoCalcTimer ;
T QLabel* autoCalcLabel ;
bool syntaxHighlightEnabled ;
EditorHighlighter * highlighter ;
QMap < ColorType , QColor > highlightColors ;
QTimer * matchingTimer ;
T QMap< ColorType , T QColor> highlightColors ;
T QTimer* matchingTimer ;
} ;
class EditorCompletion : : Private
{
public :
Editor * editor ;
QVBox * completionPopup ;
QListBox * completionListBox ;
T QVBox * completionPopup ;
T QListBox * completionListBox ;
} ;
class ChoiceItem : public QListBoxText
class ChoiceItem : public T QListBoxText
{
public :
ChoiceItem ( QListBox * , const QString & ) ;
ChoiceItem ( T QListBox* , const T QString& ) ;
void setMinNameWidth ( int w ) { minNameWidth = w ; }
int nameWidth ( ) const ;
protected :
void paint ( QPainter * p ) ;
void paint ( T QPainter* p ) ;
private :
QString item ;
QString desc ;
T QString item ;
T QString desc ;
int minNameWidth ;
} ;
ChoiceItem : : ChoiceItem ( QListBox * listBox , const QString & text ) :
QListBoxText ( listBox , text ) , minNameWidth ( 0 )
ChoiceItem : : ChoiceItem ( T QListBox* listBox , const T QString& text ) :
T QListBoxText( listBox , text ) , minNameWidth ( 0 )
{
QStringList list = QStringList : : split ( ' : ' , text ) ;
T QStringList list = T QStringList: : split ( ' : ' , text ) ;
if ( list . count ( ) ) item = list [ 0 ] ;
if ( list . count ( ) > 1 ) desc = list [ 1 ] ;
}
@ -133,48 +133,48 @@ int ChoiceItem::nameWidth() const
if ( item . isEmpty ( ) )
return 0 ;
QFontMetrics fm = listBox ( ) - > fontMetrics ( ) ;
T QFontMetrics fm = listBox ( ) - > fontMetrics ( ) ;
return fm . width ( item ) ;
}
void ChoiceItem : : paint ( QPainter * painter )
void ChoiceItem : : paint ( T QPainter* painter )
{
int itemHeight = height ( listBox ( ) ) ;
QFontMetrics fm = painter - > fontMetrics ( ) ;
T QFontMetrics fm = painter - > fontMetrics ( ) ;
int yPos = ( ( itemHeight - fm . height ( ) ) / 2 ) + fm . ascent ( ) ;
painter - > drawText ( 3 , yPos , item ) ;
//int xPos = fm.width( item );
int xPos = QMAX ( fm . width ( item ) , minNameWidth ) ;
int xPos = T QMAX( fm . width ( item ) , minNameWidth ) ;
if ( ! isSelected ( ) )
painter - > setPen ( listBox ( ) - > palette ( ) . disabled ( ) . text ( ) . dark ( ) ) ;
painter - > setPen ( listBox ( ) - > tq palette( ) . disabled ( ) . text ( ) . dark ( ) ) ;
painter - > drawText ( 10 + xPos , yPos , desc ) ;
}
EditorHighlighter : : EditorHighlighter ( Editor * e ) :
QSyntaxHighlighter ( e )
T QSyntaxHighlighter( e )
{
editor = e ;
}
int EditorHighlighter : : highlightParagraph ( const QString & text , int )
int EditorHighlighter : : highlightParagraph ( const T QString & text , int )
{
if ( ! editor - > isSyntaxHighlightEnabled ( ) )
{
setFormat ( 0 , text . length ( ) , editor - > colorGroup ( ) . text ( ) ) ;
setFormat ( 0 , text . length ( ) , editor - > tq colorGroup( ) . text ( ) ) ;
return 0 ;
}
QStringList fnames = FunctionManager : : instance ( ) - > functionList ( FunctionManager : : All ) ;
T QStringList fnames = FunctionManager : : instance ( ) - > functionList ( FunctionManager : : All ) ;
fnames . sort ( ) ; // Sort list so we can bin search it.
Tokens tokens = Evaluator : : scan ( text ) ;
for ( unsigned i = 0 ; i < tokens . count ( ) ; i + + )
{
Token & token = tokens [ i ] ;
QString text = token . text ( ) . lower ( ) ;
QFont font = editor - > font ( ) ;
QColor color = Qt : : black ;
T QString text = token . text ( ) . lower ( ) ;
T QFont font = editor - > font ( ) ;
T QColor color = T Qt: : black ;
switch ( token . type ( ) )
{
case Token : : Number :
@ -204,22 +204,22 @@ int EditorHighlighter::highlightParagraph ( const QString & text, int )
Editor : : Editor ( QWidget * parent , const char * name ) :
QTextEdit ( parent , name )
Editor : : Editor ( T QWidget* tq parent, const char * name ) :
T QTextEdit( tq parent, name )
{
d = new Private ;
d - > eval = 0 ;
d - > index = 0 ;
d - > autoCompleteEnabled = true ;
d - > completion = new EditorCompletion ( this ) ;
d - > completionTimer = new QTimer ( this ) ;
d - > completionTimer = new T QTimer( this ) ;
d - > autoCalcEnabled = true ;
d - > syntaxHighlightEnabled = true ;
d - > highlighter = new EditorHighlighter ( this ) ;
d - > autoCalcTimer = new QTimer ( this ) ;
d - > matchingTimer = new QTimer ( this ) ;
d - > autoCalcTimer = new T QTimer( this ) ;
d - > matchingTimer = new T QTimer( this ) ;
setSizePolicy ( QSizePolicy : : Expanding , QSizePolicy : : Fixed ) ;
tq setSizePolicy( T QSizePolicy: : Expanding , T QSizePolicy: : Fixed ) ;
setWordWrap ( NoWrap ) ;
setHScrollBarMode ( AlwaysOff ) ;
setVScrollBarMode ( AlwaysOff ) ;
@ -228,26 +228,26 @@ Editor::Editor( QWidget* parent, const char* name ):
setTabChangesFocus ( true ) ;
setLinkUnderline ( false ) ;
connect ( d - > completion , SIGNAL ( selectedCompletion ( const QString & ) ) ,
SLOT ( autoComplete ( const QString & ) ) ) ;
connect ( this , SIGNAL ( textChanged ( ) ) , SLOT ( checkAutoComplete ( ) ) ) ;
connect ( d - > completionTimer , SIGNAL ( timeout ( ) ) , SLOT ( triggerAutoComplete ( ) ) ) ;
connect ( d - > completion , TQT_ SIGNAL( selectedCompletion ( const T QString& ) ) ,
TQT_ SLOT( autoComplete ( const T QString& ) ) ) ;
connect ( this , TQT_ SIGNAL( textChanged ( ) ) , TQT_ SLOT( checkAutoComplete ( ) ) ) ;
connect ( d - > completionTimer , TQT_ SIGNAL( timeout ( ) ) , TQT_ SLOT( triggerAutoComplete ( ) ) ) ;
connect ( this , SIGNAL ( textChanged ( ) ) , SLOT ( checkMatching ( ) ) ) ;
connect ( d - > matchingTimer , SIGNAL ( timeout ( ) ) , SLOT ( doMatchingLeft ( ) ) ) ;
connect ( d - > matchingTimer , SIGNAL ( timeout ( ) ) , SLOT ( doMatchingRight ( ) ) ) ;
connect ( this , SIGNAL ( textChanged ( ) ) , SLOT ( checkAutoCalc ( ) ) ) ;
connect ( d - > autoCalcTimer , SIGNAL ( timeout ( ) ) , SLOT ( autoCalc ( ) ) ) ;
connect ( this , TQT_ SIGNAL( textChanged ( ) ) , TQT_ SLOT( checkMatching ( ) ) ) ;
connect ( d - > matchingTimer , TQT_ SIGNAL( timeout ( ) ) , TQT_ SLOT( doMatchingLeft ( ) ) ) ;
connect ( d - > matchingTimer , TQT_ SIGNAL( timeout ( ) ) , TQT_ SLOT( doMatchingRight ( ) ) ) ;
connect ( this , TQT_ SIGNAL( textChanged ( ) ) , TQT_ SLOT( checkAutoCalc ( ) ) ) ;
connect ( d - > autoCalcTimer , TQT_ SIGNAL( timeout ( ) ) , TQT_ SLOT( autoCalc ( ) ) ) ;
d - > autoCalcLabel = new CalcResultLabel ( 0 , " autocalc " , WStyle_StaysOnTop |
WStyle_Customize | WStyle_NoBorder | WStyle_Tool | WX11BypassWM ) ;
d - > autoCalcLabel - > setFrameStyle ( QFrame : : Plain | QFrame : : Box ) ;
d - > autoCalcLabel - > setPalette ( QToolTip : : palette ( ) ) ;
d - > autoCalcLabel - > setFrameStyle ( T QFrame: : Plain | T QFrame: : Box ) ;
d - > autoCalcLabel - > setPalette ( T QToolTip: : palette ( ) ) ;
d - > autoCalcLabel - > hide ( ) ;
setHighlightColor ( Number , QColor ( 0 , 0 , 127 ) ) ;
setHighlightColor ( FunctionName , QColor ( 85 , 0 , 0 ) ) ;
setHighlightColor ( Variable , QColor ( 0 , 85 , 0 ) ) ;
setHighlightColor ( MatchedPar , QColor ( 255 , 255 , 183 ) ) ;
setHighlightColor ( Number , T QColor( 0 , 0 , 127 ) ) ;
setHighlightColor ( FunctionName , T QColor( 85 , 0 , 0 ) ) ;
setHighlightColor ( Variable , T QColor( 0 , 85 , 0 ) ) ;
setHighlightColor ( MatchedPar , T QColor( 255 , 255 , 183 ) ) ;
}
Editor : : ~ Editor ( )
@ -256,24 +256,24 @@ Editor::~Editor()
delete d ;
}
QSize Editor : : sizeHint ( ) const
T QSize Editor : : tq sizeHint( ) const
{
constPolish ( ) ;
QFontMetrics fm = fontMetrics ( ) ;
int h = QMAX ( fm . lineSpacing ( ) , 14 ) ;
T QFontMetrics fm = fontMetrics ( ) ;
int h = T QMAX( fm . lineSpacing ( ) , 14 ) ;
int w = fm . width ( ' x ' ) * 20 ;
int m = frameWidth ( ) * 2 ;
return ( style ( ) . sizeFromContents ( QStyle : : CT_LineEdit , this ,
QSize ( w + m , h + m + 4 ) .
expandedTo ( QApplication : : globalStrut ( ) ) ) ) ;
return ( tq style( ) . tq sizeFromContents( T QStyle: : CT_LineEdit , this ,
T QSize( w + m , h + m + 4 ) .
expandedTo ( T QApplication: : globalStrut ( ) ) ) ) ;
}
QStringList Editor : : history ( ) const
T QStringList Editor : : history ( ) const
{
return d - > history ;
}
void Editor : : setHistory ( const QStringList & h )
void Editor : : setHistory ( const T QStringList& h )
{
d - > history = h ;
d - > index = d - > history . count ( ) ;
@ -309,11 +309,11 @@ void Editor::setDecimalDigits( int digits )
d - > decimalDigits = digits ;
}
void Editor : : appendHistory ( const QString & text )
void Editor : : appendHistory ( const T QString& text )
{
if ( text . isEmpty ( ) ) return ;
QString lastText ;
T QString lastText ;
if ( d - > history . count ( ) )
lastText = d - > history [ d - > history . count ( ) - 1 ] ;
if ( text = = lastText ) return ;
@ -333,9 +333,9 @@ void Editor::squelchNextAutoCalc()
d - > autoCalcTimer - > stop ( ) ;
}
void Editor : : setText ( const QString & txt )
void Editor : : setText ( const T QString & txt )
{
QTextEdit : : setText ( txt ) ;
T QTextEdit: : setText ( txt ) ;
squelchNextAutoCalc ( ) ;
}
@ -374,7 +374,7 @@ void Editor::doMatchingLeft()
getCursorPosition ( & para , & curPos ) ;
// check for right par
QString subtext = text ( ) . left ( curPos ) ;
T QString subtext = text ( ) . left ( curPos ) ;
Tokens tokens = Evaluator : : scan ( subtext ) ;
if ( ! tokens . valid ( ) ) return ;
if ( tokens . count ( ) < 1 ) return ;
@ -423,7 +423,7 @@ void Editor::doMatchingRight()
getCursorPosition ( & para , & curPos ) ;
// check for left par
QString subtext = text ( ) . right ( text ( ) . length ( ) - curPos ) ;
T QString subtext = text ( ) . right ( text ( ) . length ( ) - curPos ) ;
Tokens tokens = Evaluator : : scan ( subtext ) ;
if ( ! tokens . valid ( ) ) return ;
if ( tokens . count ( ) < 1 ) return ;
@ -472,7 +472,7 @@ void Editor::triggerAutoComplete()
// faster now that it uses flex. ;)
int para = 0 , curPos = 0 ;
getCursorPosition ( & para , & curPos ) ;
QString subtext = text ( ) . left ( curPos ) ;
T QString subtext = text ( ) . left ( curPos ) ;
Tokens tokens = Evaluator : : scan ( subtext ) ;
if ( ! tokens . valid ( ) )
{
@ -489,18 +489,18 @@ void Editor::triggerAutoComplete()
if ( ! lastToken . isIdentifier ( ) )
return ;
QString id = lastToken . text ( ) ;
T QString id = lastToken . text ( ) ;
if ( id . isEmpty ( ) )
return ;
// find matches in function names
QStringList fnames = FunctionManager : : instance ( ) - > functionList ( FunctionManager : : All ) ;
QStringList choices ;
T QStringList fnames = FunctionManager : : instance ( ) - > functionList ( FunctionManager : : All ) ;
T QStringList choices ;
for ( unsigned i = 0 ; i < fnames . count ( ) ; i + + )
if ( fnames [ i ] . startsWith ( id , false ) )
if ( fnames [ i ] . tq startsWith( id , false ) )
{
QString str = fnames [ i ] ;
T QString str = fnames [ i ] ;
: : Function * f = FunctionManager : : instance ( ) - > function ( str ) ;
if ( f & & ! f - > description . isEmpty ( ) )
@ -512,17 +512,17 @@ void Editor::triggerAutoComplete()
choices . sort ( ) ;
// find matches in variables names
QStringList vchoices ;
QStringList values = ValueManager : : instance ( ) - > valueNames ( ) ;
T QStringList vchoices ;
T QStringList values = ValueManager : : instance ( ) - > valueNames ( ) ;
for ( QStringList : : ConstIterator it = values . begin ( ) ; it ! = values . end ( ) ; + + it )
if ( ( * it ) . startsWith ( id , false ) )
for ( T QStringList: : ConstIterator it = values . begin ( ) ; it ! = values . end ( ) ; + + it )
if ( ( * it ) . tq startsWith( id , false ) )
{
QString choice = ValueManager : : description ( * it ) ;
T QString choice = ValueManager : : description ( * it ) ;
if ( choice . isEmpty ( ) )
choice = ValueManager : : instance ( ) - > value ( * it ) . toString ( ) ;
vchoices . append ( QString ( " %1:%2 " ) . arg ( * it , choice ) ) ;
vchoices . append ( T QString( " %1:%2 " ) . tq arg( * it , choice ) ) ;
}
vchoices . sort ( ) ;
@ -534,7 +534,7 @@ void Editor::triggerAutoComplete()
// one match, complete it for the user
if ( choices . count ( ) = = 1 )
{
QString str = QStringList : : split ( ' : ' , choices [ 0 ] ) [ 0 ] ;
T QString str = T QStringList: : split ( ' : ' , choices [ 0 ] ) [ 0 ] ;
// single perfect match, no need to give choices.
if ( str = = id . lower ( ) )
@ -554,7 +554,7 @@ void Editor::triggerAutoComplete()
d - > completion - > showCompletion ( choices ) ;
}
void Editor : : autoComplete ( const QString & item )
void Editor : : autoComplete ( const T QString& item )
{
if ( ! d - > autoCompleteEnabled | | item . isEmpty ( ) )
return ;
@ -562,7 +562,7 @@ void Editor::autoComplete( const QString& item )
int para = 0 , curPos = 0 ;
getCursorPosition ( & para , & curPos ) ;
QString subtext = text ( ) . left ( curPos ) ;
T QString subtext = text ( ) . left ( curPos ) ;
Tokens tokens = Evaluator : : scan ( subtext ) ;
if ( ! tokens . valid ( ) | | tokens . count ( ) < 1 )
@ -572,7 +572,7 @@ void Editor::autoComplete( const QString& item )
if ( ! lastToken . isIdentifier ( ) )
return ;
QStringList str = QStringList : : split ( ' : ' , item ) ;
T QStringList str = T QStringList: : split ( ' : ' , item ) ;
blockSignals ( true ) ;
setSelection ( 0 , lastToken . pos ( ) , 0 , lastToken . pos ( ) + lastToken . text ( ) . length ( ) ) ;
@ -585,7 +585,7 @@ void Editor::autoCalc()
if ( ! d - > autoCalcEnabled )
return ;
QString str = Evaluator : : autoFix ( text ( ) ) ;
T QString str = Evaluator : : autoFix ( text ( ) ) ;
if ( str . isEmpty ( ) )
return ;
@ -595,8 +595,8 @@ void Editor::autoCalc()
return ;
// If we're using set for a function don't try.
QRegExp setFn ( " \\ s*set.* \\ (.*= " ) ;
if ( str . find ( setFn ) ! = - 1 )
T QRegExp setFn ( " \\ s*set.* \\ (.*= " ) ;
if ( str . tq find( setFn ) ! = - 1 )
return ;
// strip off assignment operator, e.g. "x=1+2" becomes "1+2" only
@ -622,19 +622,19 @@ void Editor::autoCalc()
Abakus : : number_t result = parseString ( str . latin1 ( ) ) ;
if ( Result : : lastResult ( ) - > type ( ) = = Result : : Value )
{
QString ss = QString ( " Result: <b>%2</b> " ) . arg ( result . toString ( ) ) ;
T QString ss = T QString( " Result: <b>%2</b> " ) . tq arg( result . toString ( ) ) ;
d - > autoCalcLabel - > setText ( ss ) ;
d - > autoCalcLabel - > adjustSize ( ) ;
// reposition nicely
QPoint pos = mapToGlobal ( QPoint ( 0 , 0 ) ) ;
T QPoint pos = mapToGlobal ( T QPoint( 0 , 0 ) ) ;
pos . setY ( pos . y ( ) - d - > autoCalcLabel - > height ( ) - 1 ) ;
d - > autoCalcLabel - > move ( pos ) ;
d - > autoCalcLabel - > show ( ) ;
d - > autoCalcLabel - > raise ( ) ;
// do not show it forever
QTimer : : singleShot ( 5000 , d - > autoCalcLabel , SLOT ( hide ( ) ) ) ;
T QTimer: : singleShot ( 5000 , d - > autoCalcLabel , TQT_ SLOT( hide ( ) ) ) ;
}
else
{
@ -643,7 +643,7 @@ void Editor::autoCalc()
}
}
QString Editor : : formatNumber ( const Abakus : : number_t & value ) const
T QString Editor : : formatNumber ( const Abakus : : number_t & value ) const
{
return value . toString ( ) ;
}
@ -678,7 +678,7 @@ void Editor::historyForward()
ensureCursorVisible ( ) ;
}
void Editor : : keyPressEvent ( QKeyEvent * e )
void Editor : : keyPressEvent ( T QKeyEvent* e )
{
if ( e - > key ( ) = = Key_Up )
{
@ -708,10 +708,10 @@ void Editor::keyPressEvent( QKeyEvent* e )
checkMatching ( ) ;
}
QTextEdit : : keyPressEvent ( e ) ;
T QTextEdit: : keyPressEvent ( e ) ;
}
void Editor : : wheelEvent ( QWheelEvent * e )
void Editor : : wheelEvent ( T QWheelEvent * e )
{
if ( e - > delta ( ) > 0 )
historyBack ( ) ;
@ -732,7 +732,7 @@ bool Editor::isSyntaxHighlightEnabled() const
return d - > syntaxHighlightEnabled ;
}
void Editor : : setHighlightColor ( ColorType type , QColor color )
void Editor : : setHighlightColor ( ColorType type , T QColor color )
{
d - > highlightColors [ type ] = color ;
@ -742,26 +742,26 @@ void Editor::setHighlightColor( ColorType type, QColor color )
d - > highlighter - > rehighlight ( ) ;
}
QColor Editor : : highlightColor ( ColorType type )
T QColor Editor : : highlightColor ( ColorType type )
{
return d - > highlightColors [ type ] ;
}
EditorCompletion : : EditorCompletion ( Editor * editor ) : QObject ( editor )
EditorCompletion : : EditorCompletion ( Editor * editor ) : T QObject( editor )
{
d = new Private ;
d - > editor = editor ;
d - > completionPopup = new QVBox ( editor - > topLevelWidget ( ) , 0 , WType_Popup ) ;
d - > completionPopup - > setFrameStyle ( QFrame : : Box | QFrame : : Plain ) ;
d - > completionPopup = new T QVBox( editor - > tq topLevelWidget( ) , 0 , WType_Popup ) ;
d - > completionPopup - > setFrameStyle ( T QFrame: : Box | T QFrame: : Plain ) ;
d - > completionPopup - > setLineWidth ( 1 ) ;
d - > completionPopup - > installEventFilter ( this ) ;
d - > completionPopup - > setSizePolicy ( QSizePolicy : : Expanding , QSizePolicy : : Minimum ) ;
d - > completionPopup - > tq setSizePolicy( T QSizePolicy: : Expanding , T QSizePolicy: : Minimum ) ;
d - > completionListBox = new QListBox ( d - > completionPopup ) ;
d - > completionListBox = new T QListBox( d - > completionPopup ) ;
d - > completionPopup - > setFocusProxy ( d - > completionListBox ) ;
d - > completionListBox - > setFrameStyle ( QFrame : : NoFrame ) ;
d - > completionListBox - > setFrameStyle ( T QFrame: : NoFrame ) ;
d - > completionListBox - > setVariableWidth ( true ) ;
d - > completionListBox - > installEventFilter ( this ) ;
}
@ -771,14 +771,14 @@ EditorCompletion::~EditorCompletion()
delete d ;
}
bool EditorCompletion : : eventFilter ( QObject * obj , QEvent * ev )
bool EditorCompletion : : eventFilter ( T QObject * obj , T QEvent * ev )
{
if ( obj = = d - > completionPopup | | obj = = d - > completionListBox )
if ( TQT_BASE_OBJECT ( obj ) = = TQT_BASE_OBJECT ( d - > completionPopup ) | | TQT_BASE_OBJECT ( obj ) = = TQT_BASE_OBJECT ( d - > completionListBox ) )
{
if ( ev - > type ( ) = = QEvent : : KeyPress )
if ( ev - > type ( ) = = T QEvent: : KeyPress )
{
QKeyEvent * ke = ( QKeyEvent * ) ev ;
T QKeyEvent * ke = ( T QKeyEvent* ) ev ;
if ( ke - > key ( ) = = Key_Enter | | ke - > key ( ) = = Key_Return )
{
doneCompletion ( ) ;
@ -792,11 +792,11 @@ bool EditorCompletion::eventFilter( QObject *obj, QEvent *ev )
d - > completionPopup - > close ( ) ;
d - > editor - > setFocus ( ) ;
QApplication : : sendEvent ( d - > editor , ev ) ;
T QApplication: : sendEvent ( d - > editor , ev ) ;
return true ;
}
if ( ev - > type ( ) = = QEvent : : MouseButtonDblClick )
if ( ev - > type ( ) = = T QEvent: : MouseButtonDblClick )
{
doneCompletion ( ) ;
return true ;
@ -814,7 +814,7 @@ void EditorCompletion::doneCompletion()
emit selectedCompletion ( d - > completionListBox - > currentText ( ) ) ;
}
void EditorCompletion : : showCompletion ( const QStringList & choices )
void EditorCompletion : : showCompletion ( const T QStringList & choices )
{
static bool shown = false ;
if ( ! choices . count ( ) ) return ;
@ -838,14 +838,14 @@ void EditorCompletion::showCompletion( const QStringList &choices )
// size of the pop-up
d - > completionPopup - > setMaximumHeight ( 120 ) ;
d - > completionPopup - > resize ( d - > completionListBox - > sizeHint ( ) +
QSize ( d - > completionListBox - > verticalScrollBar ( ) - > width ( ) + 4 ,
d - > completionPopup - > resize ( d - > completionListBox - > tq sizeHint( ) +
T QSize( d - > completionListBox - > verticalScrollBar ( ) - > width ( ) + 4 ,
d - > completionListBox - > horizontalScrollBar ( ) - > height ( ) + 4 ) ) ;
if ( ! shown )
{
d - > completionPopup - > show ( ) ;
QTimer : : singleShot ( 0 , this , SLOT ( moveCompletionPopup ( ) ) ) ;
T QTimer: : singleShot ( 0 , this , TQT_ SLOT( moveCompletionPopup ( ) ) ) ;
}
else
{
@ -860,14 +860,14 @@ void EditorCompletion::moveCompletionPopup()
int w = d - > completionListBox - > width ( ) ;
// position, reference is editor's cursor position in global coord
QFontMetrics fm ( d - > editor - > font ( ) ) ;
T QFontMetrics fm ( d - > editor - > font ( ) ) ;
int para = 0 , curPos = 0 ;
d - > editor - > getCursorPosition ( & para , & curPos ) ;
int pixelsOffset = fm . width ( d - > editor - > text ( ) , curPos ) ;
pixelsOffset - = d - > editor - > contentsX ( ) ;
QPoint pos = d - > editor - > mapToGlobal ( QPoint ( pixelsOffset , d - > editor - > height ( ) ) ) ;
T QPoint pos = d - > editor - > mapToGlobal ( T QPoint( pixelsOffset , d - > editor - > height ( ) ) ) ;
// if popup is partially invisible, move to other position
NETRootInfo info ( d - > completionPopup - > x11Display ( ) ,
@ -876,7 +876,7 @@ void EditorCompletion::moveCompletionPopup()
info . activate ( ) ; // wtf is this needed for?
NETRect NETarea = info . workArea ( info . currentDesktop ( ) ) ;
QRect area ( NETarea . pos . x , NETarea . pos . y , NETarea . size . width , NETarea . size . height ) ;
T QRect area ( NETarea . pos . x , NETarea . pos . y , NETarea . size . width , NETarea . size . height ) ;
if ( pos . y ( ) + h > area . y ( ) + area . height ( ) )
pos . setY ( pos . y ( ) - h - d - > editor - > height ( ) ) ;