2010-07-23 09:23 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com)

* contrib/hbqt/doc/en/class_hbqplaintextedit.txt
  * contrib/hbqt/hbqt_hbqplaintextedit.cpp
  * contrib/hbqt/hbqt_hbqplaintextedit.h
  * contrib/hbqt/qtgui/HBQPlainTextEdit.cpp
  * contrib/hbqt/qtgui/THBQPlainTextEdit.prg
  * contrib/hbqt/qth/HBQPlainTextEdit.qth
    + Prepared: to handle another field completion protocol - 
                a work-in-progress.

  * contrib/hbxbp/xbpbrowse.prg
    ! Minor.

  * contrib/hbide/idebrowse.prg
  * contrib/hbide/ideedit.prg
  * contrib/hbide/ideeditor.prg
    + Prepared: to handle field completion engine.
This commit is contained in:
Pritpal Bedi
2010-07-23 16:28:53 +00:00
parent 3b6e247f8f
commit 4974542ee9
11 changed files with 217 additions and 50 deletions

View File

@@ -16,6 +16,24 @@
The license applies to all entries newer than 2009-04-28.
*/
2010-07-23 09:23 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com)
* contrib/hbqt/doc/en/class_hbqplaintextedit.txt
* contrib/hbqt/hbqt_hbqplaintextedit.cpp
* contrib/hbqt/hbqt_hbqplaintextedit.h
* contrib/hbqt/qtgui/HBQPlainTextEdit.cpp
* contrib/hbqt/qtgui/THBQPlainTextEdit.prg
* contrib/hbqt/qth/HBQPlainTextEdit.qth
+ Prepared: to handle another field completion protocol -
a work-in-progress.
* contrib/hbxbp/xbpbrowse.prg
! Minor.
* contrib/hbide/idebrowse.prg
* contrib/hbide/ideedit.prg
* contrib/hbide/ideeditor.prg
+ Prepared: to handle field completion engine.
2010-07-23 17:34 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* harbour-win-spec
* harbour-wce-spec

View File

@@ -177,6 +177,7 @@ CLASS IdeBrowseManager INHERIT IdeObject
METHOD buildLeftToolbar()
METHOD buildTablesButton()
METHOD showTablesTree()
METHOD fetchFldsList( cAlias )
ENDCLASS
@@ -344,6 +345,15 @@ METHOD IdeBrowseManager:create( oIde )
/*----------------------------------------------------------------------*/
METHOD IdeBrowseManager:fetchFldsList( cAlias )
LOCAL aFlds := { "System","Latin" }
HB_SYMBOL_UNUSED( cAlias )
RETURN aFlds
/*------------------------------------------------------------------------*/
METHOD IdeBrowseManager:dispStatusInfo()
::aStatusPnls[ PNL_PANELS ]:setText( "Panels: " + hb_ntos( len( ::aPanels ) ) + ":" + ::oCurPanel:cPanel )

View File

@@ -199,6 +199,8 @@ CLASS IdeEdit INHERIT IdeObject
METHOD showPrototype( cProto )
METHOD hidePrototype()
METHOD completeCode( p )
METHOD completeFieldName( p )
METHOD updateFieldsList( cAlias )
METHOD setLineNumbersBkColor( nR, nG, nB )
METHOD setCurrentLineColor( nR, nG, nB )
@@ -282,6 +284,7 @@ METHOD IdeEdit:create( oIde, oEditor, nMode )
::qEdit:hbSetSpaces( ::nTabSpaces )
::qEdit:hbSetCompleter( ::qCompleter )
::qEdit:hbSetFldsCompleter( ::oEM:qFldsCompleter )
::toggleCurrentLineHighlightMode()
::toggleLineNumbers()
@@ -663,6 +666,9 @@ METHOD IdeEdit:execKeyEvent( nMode, nEvent, p, p1 )
ELSEIF p == 21017 /* Sends Block Info { t,l,b,r,mode,state } hbGetBlockInfo() */
::aViewportInfo := p1
ELSEIF p == 21041
::updateFieldsList( p1 )
ENDIF
EXIT
@@ -2248,6 +2254,48 @@ METHOD IdeEdit:completeCode( p )
/*----------------------------------------------------------------------*/
METHOD IdeEdit:completeFieldName( p )
LOCAL qCursor := QTextCursor():from( ::qEdit:textCursor() )
qCursor:movePosition( QTextCursor_Left )
qCursor:movePosition( QTextCursor_StartOfWord )
qCursor:movePosition( QTextCursor_EndOfWord, QTextCursor_KeepAnchor )
qCursor:insertText( ::parseCodeCompletion( p ) )
qCursor:movePosition( QTextCursor_Left )
qCursor:movePosition( QTextCursor_Right )
::qEdit:setTextCursor( qCursor )
RETURN Self
/*----------------------------------------------------------------------*/
METHOD IdeEdit:updateFieldsList( cAlias )
LOCAL aFlds
HB_TRACE( HB_TR_ALWAYS, cAlias )
//::disconnect( ::qCompleter, "activated(QString)", {|p| ::execEvent( "qcompleter_activated", p ) } )
aFlds := ::oBM:fetchFldsList( cAlias )
asort( aFlds, , , {|e,f| lower( e ) < lower( f ) } )
::oEM:qFldsStrList:clear()
aeval( aFlds, {|e| ::oEM:qFldsStrList:append( e ) } )
::oEM:qFldsModel:setStringList( ::oEM:qFldsStrList )
::oEM:qFldsCompleter:setModel( ::oEM:qFldsModel )
::oEM:qFldsCompleter:setWrapAround( .t. )
::oEM:qFldsCompleter:setCaseSensitivity( Qt_CaseInsensitive )
::oEM:qFldsCompleter:setModelSorting( QCompleter_CaseInsensitivelySortedModel )
::oEM:qFldsCompleter:setCompletionMode( QCompleter_PopupCompletion )
QListView():from( ::oEM:qFldsCompleter:popup() ):setAlternatingRowColors( .t. )
//::connect( ::qCompleter, "activated(QString)", {|p| ::execEvent( "qcompleter_activated", p ) } )
RETURN Self
/*----------------------------------------------------------------------*/
FUNCTION hbide_getPreviousWord( cText, nPos )
LOCAL cWord, n

View File

@@ -84,6 +84,10 @@ CLASS IdeEditsManager INHERIT IdeObject
DATA aActions INIT {}
DATA aProtos INIT {}
DATA qFldsCompleter
DATA qFldsStrList
DATA qFldsModel
METHOD new( oIde )
METHOD create( oIde )
METHOD destroy()
@@ -230,9 +234,22 @@ METHOD IdeEditsManager:create( oIde )
::oIde:qProtoList := QStringList():new()
::oIde:qCompModel := QStringListModel():new()
::oIde:qCompleter := QCompleter():new()
//
::connect( ::qCompleter, "activated(QString)", {|p| ::execEvent( "qcompleter_activated", p ) } )
/* Define fields completer */
::qFldsStrList := QStringList():new()
::qFldsModel := QStringListModel():new()
::qFldsCompleter := QCompleter():new()
//
::qFldsCompleter:setWrapAround( .t. )
::qFldsCompleter:setCaseSensitivity( Qt_CaseInsensitive )
::qFldsCompleter:setModelSorting( QCompleter_CaseInsensitivelySortedModel )
::qFldsCompleter:setCompletionMode( QCompleter_PopupCompletion )
QListView():from( ::qFldsCompleter:popup() ):setAlternatingRowColors( .t. )
//
::connect( ::qFldsCompleter, "activated(QString)", {|p| ::execEvent( "qFldsCompleter_activated", p ) } )
RETURN Self
/*----------------------------------------------------------------------*/
@@ -382,6 +399,11 @@ METHOD IdeEditsManager:execEvent( cEvent, p )
LOCAL oEdit
DO CASE
CASE cEvent == "qFldsCompleter_activated"
IF !empty( oEdit := ::getEditObjectCurrent() )
oEdit:completeFieldName( p )
ENDIF
CASE cEvent == "qcompleter_activated"
IF !empty( oEdit := ::getEditObjectCurrent() )
oEdit:completeCode( p )

View File

@@ -62,6 +62,7 @@
:hbTextUnderCursor( lBCodeComplete ) -> cQString
:hbShowPrototype( cTip, nRows, nCols ) -> NIL
:hbSetCompleter( pCompleter ) -> NIL
:hbSetFldsCompleter( pCompleter ) -> NIL
:hbSetCurrentLineColor( pColor ) -> NIL
:hbSetLineAreaBkColor( pColor ) -> NIL
:hbRefresh() -> NIL

View File

@@ -1363,59 +1363,83 @@ void HBQPlainTextEdit::keyPressEvent( QKeyEvent * event )
}
}
if( hbKeyPressSelection( event ) )
{
if( hbKeyPressSelection( event ) ) {
return;
}
QPlainTextEdit::keyPressEvent( event );
if( ! c )
return;
if( isTipActive )
#if 0
QString alias = hbTextAlias();
if( ! alias.isEmpty() )
{
c->popup()->hide();
return;
}
if( block ){
PHB_ITEM p1 = hb_itemPutNI( NULL, 21041 );
PHB_ITEM p2 = hb_itemPutCPtr( NULL, alias.toLatin1().data() );
hb_vmEvalBlockV( block, 2, p1, p2 );
hb_itemRelease( p1 );
hb_itemRelease( p2 );
}
cFlds->setCompletionPrefix( ( QString ) 'L' );
cFlds->popup()->setCurrentIndex( cFlds->completionModel()->index( 0, 0 ) );
if( ( event->modifiers() & ( Qt::ControlModifier | Qt::AltModifier ) ) )
QRect cr = cursorRect();
cFlds->popup()->setMaximumWidth( viewport()->width() );
cr.setWidth( cFlds->popup()->sizeHintForColumn( 0 ) + cFlds->popup()->verticalScrollBar()->sizeHint().width() );
cr.setTop( cr.top() + horzRulerHeight + 5 );
cr.setBottom( cr.bottom() + horzRulerHeight + 5 );
HB_TRACE( HB_TR_ALWAYS, ( "1004" ) );
cFlds->complete( cr ); // popup it up!
HB_TRACE( HB_TR_ALWAYS, ( "1005" ) );
}
else
#endif
{
c->popup()->hide();
return;
if( ! c ) {
return;
}
if( isTipActive ) {
c->popup()->hide();
return;
}
if( ( event->modifiers() & ( Qt::ControlModifier | Qt::AltModifier ) ) ) {
c->popup()->hide();
return;
}
const bool ctrlOrShift = event->modifiers() & ( Qt::ControlModifier | Qt::ShiftModifier );
if( ( ctrlOrShift && event->text().isEmpty() ) ) {
return;
}
static QString eow( " ~!@#$%^&*()+{}|:\"<>?,./;'[]\\-=" ); /* end of word */
bool hasModifier = ( event->modifiers() != Qt::NoModifier ) && !ctrlOrShift;
QString completionPrefix = hbTextUnderCursor( true );
if( ( hasModifier ||
event->text().isEmpty() ||
completionPrefix.length() < 1 ||
eow.contains( event->text().right( 1 ) ) ) )
{
c->popup()->hide();
return;
}
if( completionPrefix != c->completionPrefix() ) {
c->setCompletionPrefix( completionPrefix );
c->popup()->setCurrentIndex( c->completionModel()->index( 0, 0 ) );
}
QRect cr = cursorRect();
c->popup()->setMaximumWidth( viewport()->width() );
cr.setWidth( c->popup()->sizeHintForColumn( 0 ) + c->popup()->verticalScrollBar()->sizeHint().width() );
cr.setTop( cr.top() + horzRulerHeight + 5 );
cr.setBottom( cr.bottom() + horzRulerHeight + 5 );
c->complete( cr ); // popup it up!
}
const bool ctrlOrShift = event->modifiers() & ( Qt::ControlModifier | Qt::ShiftModifier );
if( ( ctrlOrShift && event->text().isEmpty() ) )
return;
//static QString eow( " ~!@#$%^&*()+{}|:\"<>?,./;'[]\\-=" ); /* end of word */
static QString eow( "~!@#$%^&*()+{}|:\"<>?,./;'[]\\-=" ); /* end of word */
bool hasModifier = ( event->modifiers() != Qt::NoModifier ) && !ctrlOrShift;
QString completionPrefix = hbTextUnderCursor( true );
if( ( hasModifier ||
event->text().isEmpty() ||
completionPrefix.length() < 1 ||
eow.contains( event->text().right( 1 ) ) ) )
{
c->popup()->hide();
return;
}
if( completionPrefix != c->completionPrefix() )
{
c->setCompletionPrefix( completionPrefix );
c->popup()->setCurrentIndex( c->completionModel()->index( 0, 0 ) );
}
QRect cr = cursorRect();
c->popup()->setMaximumWidth( viewport()->width() );
cr.setWidth( c->popup()->sizeHintForColumn( 0 ) + c->popup()->verticalScrollBar()->sizeHint().width() );
cr.setTop( cr.top() + horzRulerHeight + 5 );
cr.setBottom( cr.bottom() + horzRulerHeight + 5 );
c->complete( cr ); // popup it up!
}
/*----------------------------------------------------------------------*/
@@ -1450,6 +1474,25 @@ QString HBQPlainTextEdit::hbTextUnderCursor( bool bCodeComplete )
/*----------------------------------------------------------------------*/
QString HBQPlainTextEdit::hbTextAlias()
{
QTextCursor tc( textCursor() );
tc.movePosition( QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor, 2 );
QString txt = tc.selectedText();
tc.clearSelection();
if( txt == ( QString ) "->" )
{
tc.movePosition( QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor, 1 );
tc.select( QTextCursor::WordUnderCursor );
txt = tc.selectedText();
return txt;
}
return "";
}
/*----------------------------------------------------------------------*/
void HBQPlainTextEdit::resizeEvent( QResizeEvent *e )
{
setContentsMargins( 0,0,0,0 );

View File

@@ -149,6 +149,7 @@ private:
bool isColumnSelectionON;
bool isTipActive;
QCompleter * c;
QCompleter * cFlds;
QBrush brushForBookmark( int index );
bool isCursorInSelection();
QTimer * timer;
@@ -172,6 +173,7 @@ protected:
void keyReleaseEvent( QKeyEvent * event );
public slots:
QString hbTextAlias();
void hbUpdateLineNumberAreaWidth( int newBlockCount );
void hbCaseUpper();
void hbCaseLower();
@@ -195,6 +197,7 @@ public slots:
bool hbNumberBlockVisible();
void hbShowPrototype( const QString & tip, int rows, int cols );
void hbSetCompleter( QCompleter * completer ) { c = completer; };
void hbSetFldsCompleter( QCompleter * completer ) { cFlds = completer; };
void hbSetCurrentLineColor( const QColor & color ) { m_currentLineColor = color; };
void hbSetLineAreaBkColor( const QColor & color ) { m_lineAreaBkColor = color; };
void hbRefresh();

View File

@@ -638,6 +638,20 @@ HB_FUNC( QT_HBQPLAINTEXTEDIT_HBSETCOMPLETER )
}
}
/*
* void hbSetFldsCompleter( QCompleter * completer )
*/
HB_FUNC( QT_HBQPLAINTEXTEDIT_HBSETFLDSCOMPLETER )
{
HBQPlainTextEdit * p = hbqt_par_HBQPlainTextEdit( 1 );
if( p )
( p )->hbSetFldsCompleter( hbqt_par_QCompleter( 2 ) );
else
{
HB_TRACE( HB_TR_DEBUG, ( "............................... F=QT_HBQPLAINTEXTEDIT_HBSETFLDSCOMPLETER FP=( p )->hbSetFldsCompleter( hbqt_par_QCompleter( 2 ) ); p is NULL" ) );
}
}
/*
* void hbSetCurrentLineColor( const QColor & color )
*/

View File

@@ -101,6 +101,7 @@ CREATE CLASS HBQPlainTextEdit INHERIT HbQtObjectHandler, QPlainTextEdit
METHOD hbTextUnderCursor( lBCodeComplete )
METHOD hbShowPrototype( cTip, nRows, nCols )
METHOD hbSetCompleter( pCompleter )
METHOD hbSetFldsCompleter( pCompleter )
METHOD hbSetCurrentLineColor( pColor )
METHOD hbSetLineAreaBkColor( pColor )
METHOD hbRefresh()
@@ -268,6 +269,10 @@ METHOD HBQPlainTextEdit:hbSetCompleter( pCompleter )
RETURN Qt_HBQPlainTextEdit_hbSetCompleter( ::pPtr, hbqt_ptr( pCompleter ) )
METHOD HBQPlainTextEdit:hbSetFldsCompleter( pCompleter )
RETURN Qt_HBQPlainTextEdit_hbSetFldsCompleter( ::pPtr, hbqt_ptr( pCompleter ) )
METHOD HBQPlainTextEdit:hbSetCurrentLineColor( pColor )
RETURN Qt_HBQPlainTextEdit_hbSetCurrentLineColor( ::pPtr, hbqt_ptr( pColor ) )

View File

@@ -132,6 +132,7 @@ HB_FUNC( QT_HBQPLAINTEXTEDIT )
QString hbTextUnderCursor( bool bCodeComplete )
void hbShowPrototype( const QString & tip, int rows, int cols )
void hbSetCompleter( QCompleter * completer )
void hbSetFldsCompleter( QCompleter * completer )
void hbSetCurrentLineColor( const QColor & color )
void hbSetLineAreaBkColor( const QColor & color )
void hbRefresh()

View File

@@ -138,6 +138,8 @@
#define __ev_footersec_resized__ 122 /* Footer Section Resized */
#define __ev_frame_resized__ 2001
#define __ev_contextMenuRequested__ 2002
#define __editor_closeEditor__ 1400
#define __editor_commitData__ 1401
/*----------------------------------------------------------------------*/
@@ -780,8 +782,8 @@ METHOD XbpBrowse:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
::qDelegate := QItemDelegate():new()
::oTableView:setItemDelegate( ::qDelegate )
::connect( ::qDelegate, "closeEditor(QWidget,int)", {|p,p1| ::execSlot( 1400 /*"editor_closeEditor"*/, p, p1 ) } )
::connect( ::qDelegate, "commitData(QWidget)" , {|p | ::execSlot( 1401 /*"editor_commitData"*/ , p ) } )
::connect( ::qDelegate, "closeEditor(QWidget,int)", {|p,p1| ::execSlot( __editor_closeEditor__, p, p1 ) } )
::connect( ::qDelegate, "commitData(QWidget)" , {|p | ::execSlot( __editor_commitData__ , p ) } )
//::oTableView:setEditTriggers( QAbstractItemView_AllEditTriggers )
//::oTableView:setEditTriggers( QAbstractItemView_DoubleClicked )
@@ -803,7 +805,7 @@ METHOD XbpBrowse:execSlot( nEvent, p1, p2, p3 )
oPoint := QPoint():from( ::oTableView:mapToGlobal( p1 ) )
::hbContextMenu( { oPoint:x(), oPoint:y() } )
CASE nEvent == 1401 // "editor_commitData"
CASE nEvent == __editor_commitData__
qWidget := QLineEdit():from( p1 )
cTxt := qWidget:text()