From 40894a194c8dd5cb1c18ef33c40f920ac42fe9ad Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Sat, 6 Feb 2010 21:51:16 +0000 Subject: [PATCH] 2010-02-06 13:44 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * contrib/hbide/resources/findinfiles.ui * contrib/hbide/resources/findinfiles.uic * contrib/hbqt/qtgui/QSizePolicy.cpp * contrib/hbqt/qth/QSizePolicy.qth * contrib/hbqt/THbQtUI.prg * contrib/hbide/hbide.prg * contrib/hbide/idedocks.prg * contrib/hbide/ideeditor.prg * contrib/hbide/idefindreplace.prg * contrib/hbide/ideobject.prg + Added more info in "Results". ! Core normalization. + Implemented RegEx search. I am not good at this engine, please test. % Changed TODO => DONE in one entry in ChangeLog. --- harbour/ChangeLog | 25 +- harbour/contrib/hbide/hbide.prg | 3 + harbour/contrib/hbide/idedocks.prg | 42 ++- harbour/contrib/hbide/ideeditor.prg | 4 +- harbour/contrib/hbide/idefindreplace.prg | 331 ++++++++++++------ harbour/contrib/hbide/ideobject.prg | 3 + .../contrib/hbide/resources/findinfiles.ui | 4 +- .../contrib/hbide/resources/findinfiles.uic | 6 +- harbour/contrib/hbqt/THbQtUI.prg | 96 ++--- harbour/contrib/hbqt/qtgui/QSizePolicy.cpp | 5 +- harbour/contrib/hbqt/qth/QSizePolicy.qth | 4 + 11 files changed, 351 insertions(+), 172 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 9d6ac86b3c..1896ba0e06 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,27 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-02-06 13:44 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * contrib/hbide/resources/findinfiles.ui + * contrib/hbide/resources/findinfiles.uic + + * contrib/hbqt/qtgui/QSizePolicy.cpp + * contrib/hbqt/qth/QSizePolicy.qth + + * contrib/hbqt/THbQtUI.prg + + * contrib/hbide/hbide.prg + * contrib/hbide/idedocks.prg + * contrib/hbide/ideeditor.prg + * contrib/hbide/idefindreplace.prg + * contrib/hbide/ideobject.prg + + + Added more info in "Results". + ! Core normalization. + + Implemented RegEx search. + I am not good at this engine, please test. + % Changed TODO => DONE in one entry in ChangeLog. + 2010-02-06 19:51 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * src/vm/runner.c * BYTE -> char @@ -157,8 +178,8 @@ Please forward any suggessions you think will make it more useful. - ; TODO: Regex implementation. - Regex for multiple lines. + ; DONE: Regex implementation. + TODO: Regex for multiple lines. Including sub-folders. Including sub-projects. "Replace" implementation ( I am exploring how it can be safest ) diff --git a/harbour/contrib/hbide/hbide.prg b/harbour/contrib/hbide/hbide.prg index 94a05c594e..0aaa0e8e79 100644 --- a/harbour/contrib/hbide/hbide.prg +++ b/harbour/contrib/hbide/hbide.prg @@ -119,6 +119,8 @@ CLASS HbIde DATA oFR /* Find Replace Manager */ DATA oEV /* Available Environments */ DATA oThemes + DATA oFindInFiles + DATA oDockFind DATA oUI @@ -575,6 +577,7 @@ METHOD HbIde:execEditorAction( cKey ) EXIT CASE "MatchPairs" // + ::oDockFind:show() EXIT CASE "InsertSeparator" ::oEM:insertSeparator() diff --git a/harbour/contrib/hbide/idedocks.prg b/harbour/contrib/hbide/idedocks.prg index b6705d5df8..73ddad6b7f 100644 --- a/harbour/contrib/hbide/idedocks.prg +++ b/harbour/contrib/hbide/idedocks.prg @@ -87,6 +87,7 @@ CLASS IdeDocks INHERIT IdeObject METHOD buildCompileResults() METHOD buildLinkResults() METHOD buildOutputResults() + METHOD buildFindInFiles() METHOD outputDoubleClicked( lSelected ) METHOD buildStatusBar() METHOD toggleLeftDocks() @@ -168,6 +169,7 @@ METHOD IdeDocks:buildDockWidgets() ::buildCompileResults() ::buildLinkResults() ::buildOutputResults() + //::buildFindInFiles() ::oDlg:oWidget:tabifyDockWidget( ::oDockB:oWidget , ::oDockB1:oWidget ) ::oDlg:oWidget:tabifyDockWidget( ::oDockB1:oWidget, ::oDockB2:oWidget ) @@ -359,8 +361,8 @@ METHOD IdeDocks:buildOutputResults() ::oDockB2:oWidget:setWindowTitle( "Output Console" ) ::oDockB2:oWidget:setFocusPolicy( Qt_NoFocus ) - ::oIde:oOutputResult := XbpRtf():new( ::oDockB2 ):create( , , { 0,0 }, { 100, 400 }, , .t. ) - ::oOutputResult:oWidget:setAcceptRichText( .t. ) + ::oIde:oOutputResult := XbpRtf():new( ::oDockB2 ):create( , , { 0,0 }, { 100, 400 }, , .T. ) + ::oOutputResult:oWidget:setAcceptRichText( .T. ) ::oOutputResult:oWidget:setReadOnly( .T. ) ::oDockB2:oWidget:setWidget( ::oOutputResult:oWidget ) @@ -534,3 +536,39 @@ METHOD IdeDocks:setStatusText( nPart, xValue ) RETURN Self /*----------------------------------------------------------------------*/ + +METHOD IdeDocks:buildFindInFiles() + LOCAL oXbp + + ::oIde:oDockFind := XbpWindow():new( ::oDa ) + ::oDockFind:oWidget := QDockWidget():new( ::oDlg:oWidget ) + ::oDockFind:oWidget:setObjectName( "dockFindInFiles" ) + ::oDlg:addChild( ::oDockFind ) + ::oDockFind:oWidget:setFeatures( QDockWidget_DockWidgetClosable ) + ::oDockFind:oWidget:setAllowedAreas( Qt_RightDockWidgetArea ) + ::oDockFind:oWidget:setWindowTitle( "Find in Files" ) + ::oDockFind:oWidget:setFocusPolicy( Qt_NoFocus ) + + ::oIde:oFindInFiles := IdeFindInFiles():new( ::oIde, .t. ) + ::oIde:oFindInFiles:lInDockWindow := .t. + ::oIde:oFindInFiles:create() + + oXbp := XbpWindow():new( ::oDockFind ) + oXbp:qtObject := IdeFindInFiles():new( ::oIde, .t. ):create() //::oIde:oFindInFiles + oXbp:oWidget := oXbp:qtObject:oUI + //::oIde:oFindInFiles := XbpWindow():new( ::oDockFind ) + //::oDockFind:qtObject := ::oIde:oFindInFiles:oUI + //::oDockFind:qtObject := HbQtUI():new( ::resPath + "findform.uic", ::oDockFind:oWidget ):build() + //::oIde:oFindInFiles:oWidget := ::oDockFind:qtObject + + //::oDockFind:oWidget:setWidget( ::oFindInFiles:oWidget ) + //::oDockFind:oWidget:setWidget( ::oIde:oFindInFiles:oUI ) + ::oDockFind:oWidget:setWidget( oXbp:oWidget ) + + ::oDlg:oWidget:addDockWidget_1( Qt_RightDockWidgetArea, ::oDockFind:oWidget, Qt_Horizontal ) + ::oDockFind:hide() + + RETURN Self + +/*----------------------------------------------------------------------*/ + diff --git a/harbour/contrib/hbide/ideeditor.prg b/harbour/contrib/hbide/ideeditor.prg index 2d46ef9c8c..f9c25a5a84 100644 --- a/harbour/contrib/hbide/ideeditor.prg +++ b/harbour/contrib/hbide/ideeditor.prg @@ -994,8 +994,8 @@ METHOD IdeEditor:create( oIde, cSourceFile, nPos, nHPos, nVPos, cTheme ) ::qDocument := QTextDocument():configure( ::qEdit:document() ) #if 1 - ::connect( ::qDocument, "blockCountChanged(int)" , {|p | ::exeEvent( 21, p ) } ) - ::connect( ::qDocument, "contentsChange(int,int,int)", {|p,p1,p2| ::exeEvent( 22, p, p1, p2 ) } ) + ::connect( ::qDocument, "blockCountChanged(int)" , {|p | ::exeEvent( blockCountChanged, p ) } ) + ::connect( ::qDocument, "contentsChange(int,int,int)", {|p,p1,p2| ::exeEvent( contentsChange, p, p1, p2 ) } ) #else hbide_dbg( 2001, ::qSlots:hbConnect( ::qDocument, "blockCountChanged(int)" , {|o,p | ::exeEvent( 21, o, p ) } ) ) ::qSlots:hbConnect( ::qDocument, "contentsChange(int,int,int)", {|o,p,p1,p2| ::exeEvent( 22, o, p, p1, p2 ) } ) diff --git a/harbour/contrib/hbide/idefindreplace.prg b/harbour/contrib/hbide/idefindreplace.prg index fc214baadc..22607832f6 100644 --- a/harbour/contrib/hbide/idefindreplace.prg +++ b/harbour/contrib/hbide/idefindreplace.prg @@ -323,9 +323,11 @@ METHOD IdeFindReplace:updateFindReplaceData( cMode ) #define F_BLUE '' #define F_YELLOW '' -#define F_SECTION '' -#define F_FOLDER '' +#define F_SECTION '' +#define F_SECTION_ITEM '' +#define F_INFO '' #define F_FILE '' +#define F_SEARCH '' #define F_END '' @@ -335,9 +337,9 @@ METHOD IdeFindReplace:updateFindReplaceData( cMode ) #define LOG_FLAGS 4 #define LOG_TERMINATED 5 #define LOG_SECTION 6 -#define LOG_FOLDER 7 -#define LOG_PROJECT 8 -#define LOG_EMPTY 9 +#define LOG_SECTION_ITEM 7 +#define LOG_EMPTY 8 +#define LOG_INFO 9 /*----------------------------------------------------------------------*/ @@ -352,21 +354,24 @@ CLASS IdeFindInFiles INHERIT IdeObject DATA nMisses INIT 0 DATA cOrigExpr - DATA cRegExp + DATA compRegEx DATA cReplWith DATA lRegEx INIT .F. DATA lListOnly INIT .T. DATA lMatchCase INIT .F. DATA lNotDblClick INIT .F. + DATA lShowOnCreate INIT .T. + DATA lInDockWindow INIT .F. - METHOD new( oIde ) - METHOD create( oIde ) + METHOD new( oIde, lShowOnCreate ) + METHOD create( oIde, lShowOnCreate ) + METHOD show() METHOD destroy() METHOD print() METHOD paintRequested( pPrinter ) METHOD find() METHOD findInABunch( aFiles ) - METHOD showLog( nType, cMsg, p, p1, p2 ) + METHOD showLog( nType, cMsg, aLines ) METHOD execEvent( cEvent, p ) METHOD execContextMenu( p ) @@ -375,20 +380,23 @@ CLASS IdeFindInFiles INHERIT IdeObject /*----------------------------------------------------------------------*/ -METHOD IdeFindInFiles:new( oIde ) +METHOD IdeFindInFiles:new( oIde, lShowOnCreate ) - ::oIde := oIde + ::oIde := oIde + ::lShowOnCreate := lShowOnCreate RETURN Self /*----------------------------------------------------------------------*/ -METHOD IdeFindInFiles:create( oIde ) +METHOD IdeFindInFiles:create( oIde, lShowOnCreate ) LOCAL cText, qLineEdit, aProjList, cProj, qItem - DEFAULT oIde TO ::oIde + DEFAULT oIde TO ::oIde + DEFAULT lShowOnCreate TO ::lShowOnCreate - ::oIde := oIde + ::oIde := oIde + ::lShowOnCreate := lShowOnCreate #ifdef HBIDE_USE_UIC ::oUI := HbQtUI():new( ::oIde:resPath + "findinfiles.uic", ::oIde:oDlg:oWidget ):build() @@ -415,27 +423,32 @@ METHOD IdeFindInFiles:create( oIde ) ::oIde:setPosAndSizeByIni( ::oUI:oWidget, FindInFilesDialogGeometry ) qLineEdit := QLineEdit():configure( ::oUI:q_comboExpr:lineEdit() ) - IF !empty( cText := ::oEM:getSelectedText() ) - qLineEdit:setText( cText ) + IF !empty( ::oEM ) + IF !empty( cText := ::oEM:getSelectedText() ) + qLineEdit:setText( cText ) + ENDIF ENDIF qLineEdit:selectAll() /* Populate Projects Name */ - aProjList := ::oPM:getProjectsTitleList() - FOR EACH cProj IN aProjList - IF !empty( cProj ) - qItem := QListWidgetItem():new() - qItem:setFlags( Qt_ItemIsUserCheckable + Qt_ItemIsEnabled + Qt_ItemIsSelectable ) - qItem:setText( cProj ) - qItem:setCheckState( 0 ) - ::oUI:q_listProjects:addItem_1( qItem ) - aadd( ::aItems, qItem ) - ENDIF - NEXT + IF !empty( ::oPM ) + aProjList := ::oPM:getProjectsTitleList() + FOR EACH cProj IN aProjList + IF !empty( cProj ) + qItem := QListWidgetItem():new() + qItem:setFlags( Qt_ItemIsUserCheckable + Qt_ItemIsEnabled + Qt_ItemIsSelectable ) + qItem:setText( cProj ) + qItem:setCheckState( 0 ) + ::oUI:q_listProjects:addItem_1( qItem ) + aadd( ::aItems, qItem ) + ENDIF + NEXT + ENDIF ::oUI:q_editResults:setReadOnly( .t. ) - ::oUI:q_editResults:setFontFamily( "Courier New" ) - ::oUI:q_editResults:setFontPointSize( 10 ) + //::oUI:q_editResults:setFontFamily( "Courier New" ) + //::oUI:q_editResults:setFontPointSize( 10 ) + ::oUI:q_editResults:setFont( ::oFont:oWidget ) ::oUI:q_editResults:setContextMenuPolicy( Qt_CustomContextMenu ) ::oUI:q_labelStatus:setText( "Ready" ) @@ -456,6 +469,20 @@ METHOD IdeFindInFiles:create( oIde ) ::oUI:signal( "editResults" , "customContextMenuRequested(QPoint)", {|p| ::execEvent( "editResults-contextMenu", p ) } ) ::oUI:show() + #if 0 + IF ::lShowOnCreate + ::show() + ENDIF + #endif + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD IdeFindInFiles:show() + + IF ! ::lInDockWindow + ::oUI:show() + ENDIF RETURN Self @@ -466,6 +493,15 @@ METHOD IdeFindInFiles:execEvent( cEvent, p ) SWITCH cEvent + CASE "buttonClose" + IF ::lInDockWindow + ::oDockFind:hide() + ELSE + ::oIde:aIni[ INI_HBIDE, FindInFilesDialogGeometry ] := hbide_posAndSize( ::oUI:oWidget ) + ::destroy() + ENDIF + EXIT + CASE "comboFind" ::oIde:oSBar:getItem( SB_PNL_SEARCH ):caption := "FIND: " + p EXIT @@ -482,11 +518,6 @@ METHOD IdeFindInFiles:execEvent( cEvent, p ) CASE "buttonRepl" EXIT - CASE "buttonClose" - ::oIde:aIni[ INI_HBIDE, FindInFilesDialogGeometry ] := hbide_posAndSize( ::oUI:oWidget ) - ::destroy() - EXIT - CASE "buttonStop" ::lStop := .t. EXIT @@ -653,9 +684,12 @@ METHOD IdeFindInFiles:find() ENDIF ::lRegEx := ::oUI:q_checkRegEx:isChecked() - IF ::lRegEx .AND. ! hb_isRegEx( ::lRegEx ) - MsgBox( "Error in Regular Expression" ) - RETURN Self + IF ::lRegEx + ::compRegEx := hb_regExComp( ::cOrigExpr ) + IF ! hb_isRegEx( ::compRegEx ) + MsgBox( "Error in Regular Expression" ) + RETURN Self + ENDIF ENDIF ::lListOnly := ::oUI:q_checkListOnly:isChecked() ::lMatchCase := ::oUI:q_checkMatchCase:isChecked() @@ -735,33 +769,49 @@ METHOD IdeFindInFiles:find() /* Fun Begins */ ::showLog( LOG_SEPARATOR ) - ::showLog( LOG_FLAGS, "[ Begins: " + dtoc( date() ) + " " + time() + " ] [ " + "Find Expression: " + ::cOrigExpr + " ]" ) + ::showLog( LOG_FLAGS, "[Begins: " + dtoc( date() ) + "-" + time() + "][" + "Find Expression: " + ::cOrigExpr + "]" ) ::showLog( LOG_FLAGS, hbide_getFlags( lPrg, lC, lCpp, lH, lCh, lRc, lTabs, lSubF, lSubP, ::lRegEx, ::lListOnly, ::lMatchCase ) ) ::showLog( LOG_EMPTY ) nStart := seconds() - IF !empty( aOpenSrc ) - ::showLog( LOG_SECTION, "Open Tabs" ) - ::findInABunch( aOpenSrc ) + IF lTabs + ::showLog( LOG_SECTION, "OpenTabs" ) + IF !empty( aOpenSrc ) + ::findInABunch( aOpenSrc ) + ELSE + ::showLog( LOG_INFO, "No matching files found" ) + ENDIF ENDIF - IF !empty( aFolderSrc ) - ::showLog( LOG_SECTION, "Folder: " + cFolder ) - ::findInABunch( aFolderSrc ) + + IF !empty( cFolder ) + ::showLog( LOG_SECTION, "Folders" ) + IF !empty( aFolderSrc ) + ::showLog( LOG_SECTION_ITEM, "Folder: " + cFolder ) + ::findInABunch( aFolderSrc ) + ELSE + ::showLog( LOG_INFO, "No matching files found" ) + ENDIF ENDIF - IF !empty( aProjSrc ) - FOR EACH a_ IN aProjSrc - ::showLog( LOG_SECTION, "Project: " + a_[ 1 ] ) - ::findInABunch( a_[ 2 ] ) - NEXT + + IF !empty( aProjs ) + ::showLog( LOG_SECTION, "Projects" ) + IF !empty( aProjSrc ) + FOR EACH a_ IN aProjSrc + ::showLog( LOG_SECTION_ITEM, "Project: " + a_[ 1 ] ) + ::findInABunch( a_[ 2 ] ) + NEXT + ELSE + ::showLog( LOG_INFO, "No matching files found" ) + ENDIF ENDIF nEnd := seconds() ::showLog( LOG_EMPTY ) - ::showLog( LOG_FLAGS, "[ Ends:" + dtoc( date() ) + " " + time() + " ] [ Time Taken: " + hb_ntos( nEnd - nStart ) + " ] " + ; - "[ Searched: " + hb_ntos( ::nSearched ) + " ] [ Finds: " + hb_ntos( ::nFounds ) + " ] " + ; - "[ Not on disk: " + hb_ntos( ::nMisses ) + " ]" ) + ::showLog( LOG_FLAGS, "[Ends:" + dtoc( date() ) + "-" + time() + "-" + hb_ntos( nEnd - nStart ) + " Secs]" + ; + "[Searched: " + hb_ntos( ::nSearched ) + "][Finds: " + hb_ntos( ::nFounds ) + "]" + ; + "[Files not found: " + hb_ntos( ::nMisses ) + "]" ) ::showLog( LOG_SEPARATOR ) ::showLog( LOG_EMPTY ) @@ -777,8 +827,9 @@ METHOD IdeFindInFiles:find() /*----------------------------------------------------------------------*/ METHOD IdeFindInFiles:findInABunch( aFiles ) - LOCAL s, cExpr, nLine, aLines, aBuffer, cLine + LOCAL s, cExpr, nLine, aLines, aBuffer, cLine, nNoMatch, aMatch, regEx + nNoMatch := 0 FOR EACH s IN aFiles IF ::lStop /* Stop button is pressed */ ::showLog( LOG_EMPTY ) @@ -791,40 +842,60 @@ METHOD IdeFindInFiles:findInABunch( aFiles ) ::nSearched++ aBuffer := hb_ATokens( StrTran( hb_MemoRead( s ), Chr( 13 ) ), Chr( 10 ) ) nLine := 0 - IF ::lMatchCase - cExpr := ::cOrigExpr + + IF ::lRegEx + regEx := ::compRegEx FOR EACH cLine IN aBuffer nLine++ - IF cExpr $ cLine - aadd( aLines, { nLine, cLine } ) + // exp, string, lMatchCase, lNewLine, nMaxMatch, nMatchWhich, lMatchOnly + IF !empty( aMatch := hb_regExAll( regEx, cLine, ::lMatchCase, .F., 0, 1, .F. ) ) + aadd( aLines, { nLine, cLine, aMatch } ) ENDIF NEXT ELSE - cExpr := lower( ::cOrigExpr ) - FOR EACH cLine IN aBuffer - nLine++ - IF cExpr $ lower( cLine ) - aadd( aLines, { nLine, cLine } ) - ENDIF - NEXT + IF ::lMatchCase + cExpr := ::cOrigExpr + FOR EACH cLine IN aBuffer + nLine++ + IF cExpr $ cLine + aadd( aLines, { nLine, cLine, NIL } ) + ENDIF + NEXT + ELSE + cExpr := lower( ::cOrigExpr ) + FOR EACH cLine IN aBuffer + nLine++ + IF cExpr $ lower( cLine ) + aadd( aLines, { nLine, cLine, NIL } ) + ENDIF + NEXT + ENDIF ENDIF + IF len( aLines ) > 0 - ::showLog( LOG_FINDS, s, aLines, ::cOrigExpr, ::lMatchCase ) + ::showLog( LOG_FINDS, s, aLines ) ::nFounds++ + ELSE + nNoMatch++ ENDIF ELSE ::showLog( LOG_MISSING, s ) ::nMisses++ ENDIF NEXT + IF nNoMatch == len( aFiles ) + ::showLog( LOG_INFO, "Searched (" + hb_ntos( len( aFiles ) ) + ") files, no matches found" ) + ENDIF RETURN Self /*----------------------------------------------------------------------*/ -METHOD IdeFindInFiles:showLog( nType, cMsg, p, p1, p2 ) - LOCAL a_, n, cPre, cPost, cTkn, nWidth, cText - LOCAL qCursor +METHOD IdeFindInFiles:showLog( nType, cMsg, aLines ) + LOCAL a_, n, cPre, cPost, nWidth, cText, nB, cL, nL, cT, cExp, aM + LOCAL qCursor, qResult + + qResult := ::oUI:q_editResults DEFAULT cMsg TO "" @@ -833,71 +904,85 @@ METHOD IdeFindInFiles:showLog( nType, cMsg, p, p1, p2 ) SWITCH nType CASE LOG_SEPARATOR - ::oUI:q_editResults:append( F_BLACK + hbide_outputLine( "=", 70 ) + F_END ) + qResult:append( F_BLACK + hbide_outputLine( "=", 68 ) + F_END ) aadd( ::aInfo, { 0, NIL, NIL } ) EXIT - CASE LOG_TERMINATED - ::oUI:q_editResults:append( F_RED + "---------------- Terminated ---------------" + F_END ) + CASE LOG_FLAGS + qResult:append( F_BLACK + cMsg + F_END ) aadd( ::aInfo, { 0, NIL, NIL } ) EXIT - CASE LOG_MISSING - ::oUI:q_editResults:append( F_RED + cMsg + F_END ) + CASE LOG_INFO + qResult:append( F_INFO + "" + cMsg + "" + F_END ) + aadd( ::aInfo, { 0, NIL, NIL } ) + EXIT + + CASE LOG_SECTION + qResult:append( F_SECTION + "" + cMsg + "" + F_END ) + aadd( ::aInfo, { 0, NIL, NIL } ) + EXIT + + CASE LOG_SECTION_ITEM + qResult:append( F_SECTION_ITEM + cMsg + F_END ) aadd( ::aInfo, { 0, NIL, NIL } ) EXIT CASE LOG_FINDS - cText := F_FILE + "" + cMsg + " ( "+ hb_ntos( len( p ) ) + " )" + "" + F_END + cText := F_FILE + "" + cMsg + " ( "+ hb_ntos( len( aLines ) ) + " )" + "" + F_END ::oUI:q_editResults:append( cText ) ::oUI:q_labelStatus:setText( cText ) aadd( ::aInfo, { -1, cMsg, NIL } ) n := 0 - aeval( p, {|a_| n := max( n, a_[ 1 ] ) } ) + aeval( aLines, {|a_| n := max( n, a_[ 1 ] ) } ) nWidth := iif( n < 10, 1, iif( n < 100, 2, iif( n < 1000, 3, iif( n < 10000, 4, iif( n < 100000, 5, 7 ) ) ) ) ) - FOR EACH a_ IN p - IF p2 - n := at( p1, a_[ 2 ] ) - ELSE - n := at( lower( p1 ), lower( a_[ 2 ] ) ) - ENDIF - cPre := substr( a_[ 2 ], 1, n - 1 ) - cPost := substr( a_[ 2 ], n + len( p1 ) ) - cTkn := substr( a_[ 2 ], n, len( p1 ) ) - ::oUI:q_editResults:append( F_BLACK + "   (" + strzero( a_[ 1 ], nWidth ) + ")  " + ; - cPre + "" + cTkn + "" + cPost + ; - F_END ) - // mode, source, line#, pos, slctn - aadd( ::aInfo, { -2, cMsg, a_[ 1 ], n, cTkn } ) + IF ::lRegEx + FOR EACH a_ IN aLines + nL := a_[ 1 ] + aM := a_[ 3 ] + nB := aM[ 1, 2 ] + cL := hbide_buildResultLine( a_[ 2 ], aM ) + cT := aM[ 1, 1 ] - qCursor:movePosition( QTextCursor_Down ) - NEXT + qResult:append( F_BLACK + "   (" + strzero( nL, nWidth ) + ")  " + cL + F_END ) + + aadd( ::aInfo, { -2, cMsg, nL, nB, cT } ) + qCursor:movePosition( QTextCursor_Down ) + NEXT + ELSE + cExp := iif( ::lMatchCase, ::cOrigExpr, lower( ::cOrigExpr ) ) + FOR EACH a_ IN aLines + nL := a_[ 1 ] + cL := a_[ 2 ] + nB := at( cExp, cL ) + cPre := substr( cL, 1, nB - 1 ) + cPost := substr( cL, nB + len( cExp ) ) + cT := substr( cL, nB, len( cExp ) ) + cL := cPre + F_SEARCH + "" + cT + "" + F_END + cPost + + qResult:append( F_BLACK + "   (" + strzero( nL, nWidth ) + ")  " + cL + F_END ) + + // mode, source, line#, pos, slctn + aadd( ::aInfo, { -2, cMsg, nL, nB, cT } ) + qCursor:movePosition( QTextCursor_Down ) + NEXT + ENDIF EXIT - CASE LOG_FLAGS - ::oUI:q_editResults:append( F_BLACK + cMsg + F_END ) + CASE LOG_TERMINATED + qResult:append( F_RED + "---------------- Terminated ---------------" + F_END ) aadd( ::aInfo, { 0, NIL, NIL } ) EXIT - CASE LOG_SECTION - ::oUI:q_editResults:append( F_SECTION + "" + cMsg + "" + F_END ) - aadd( ::aInfo, { 0, NIL, NIL } ) - EXIT - - CASE LOG_FOLDER - ::oUI:q_editResults:append( F_FOLDER + "      " + "" + cMsg + "" + F_END ) - aadd( ::aInfo, { 0, NIL, NIL } ) - EXIT - - CASE LOG_PROJECT - ::oUI:q_editResults:append( F_FOLDER + "      " + "" + cMsg + "" + F_END ) + CASE LOG_MISSING + qResult:append( F_RED + cMsg + F_END ) aadd( ::aInfo, { 0, NIL, NIL } ) EXIT CASE LOG_EMPTY - ::oUI:q_editResults:append( F_BLACK + " " + F_END ) + qResult:append( F_BLACK + " " + F_END ) aadd( ::aInfo, { 0, NIL, NIL } ) EXIT @@ -911,6 +996,24 @@ METHOD IdeFindInFiles:showLog( nType, cMsg, p, p1, p2 ) /*----------------------------------------------------------------------*/ +STATIC FUNCTION hbide_buildResultLine( cLine, aM ) + LOCAL cT, cR, i + + FOR i := 1 TO len( aM ) + cR := aM[ i, 1 ] + cT := replicate( chr( 255 ), len( aM[ i, 1 ] ) ) + cLine := strtran( cLine, cR, cT, 1, 1 ) + NEXT + FOR i := 1 TO len( aM ) + cR := replicate( chr( 255 ), len( aM[ i, 1 ] ) ) + cT := F_SEARCH + "" + aM[ i, 1 ] + "" + F_END + cLine := strtran( cLine, cR, cT, 1, 1 ) + NEXT + + RETURN cLine + +/*----------------------------------------------------------------------*/ + METHOD IdeFindInFiles:print() LOCAL qDlg @@ -969,14 +1072,14 @@ STATIC FUNCTION hbide_getFlags( lPrg, lC, lCpp, lH, lCh, lRc, lTabs, lSubF, lSub HB_SYMBOL_UNUSED( lSubP ) HB_SYMBOL_UNUSED( lListOnly ) - s += "[.prg=" + L2S( lPrg ) + "] " - s += "[.c=" + L2S( lC ) + "] " - s += "[.cpp=" + L2S( lCpp ) + "] " - s += "[.h=" + L2S( lH ) + "] " - s += "[.ch=" + L2S( lCh ) + "] " - s += "[.rc=" + L2S( lRc ) + "] " - s += "[RegEx=" + L2S( lRegEx ) + "] " - s += "[Case=" + L2S( lMatchCase ) + "] " + s += "[.prg=" + L2S( lPrg ) + "]" + s += "[.c=" + L2S( lC ) + "]" + s += "[.cpp=" + L2S( lCpp ) + "]" + s += "[.h=" + L2S( lH ) + "]" + s += "[.ch=" + L2S( lCh ) + "]" + s += "[.rc=" + L2S( lRc ) + "]" + s += "[RegEx=" + L2S( lRegEx ) + "]" + s += "[Case=" + L2S( lMatchCase ) + "]" RETURN s diff --git a/harbour/contrib/hbide/ideobject.prg b/harbour/contrib/hbide/ideobject.prg index 1afdc8a1fe..101c87bcaa 100644 --- a/harbour/contrib/hbide/ideobject.prg +++ b/harbour/contrib/hbide/ideobject.prg @@ -91,6 +91,9 @@ CLASS IdeObject ACCESS oSM INLINE ::oIde:oSM ACCESS oEV INLINE ::oIde:oEV + ACCESS oDockFind INLINE ::oIde:oDockFind + ACCESS oFindInFiles INLINE ::oIde:oFindInFiles + ACCESS aMeta INLINE ::oIde:aMeta ACCESS oFont INLINE ::oIde:oFont diff --git a/harbour/contrib/hbide/resources/findinfiles.ui b/harbour/contrib/hbide/resources/findinfiles.ui index 2bec44b474..2be1bf921c 100644 --- a/harbour/contrib/hbide/resources/findinfiles.ui +++ b/harbour/contrib/hbide/resources/findinfiles.ui @@ -47,13 +47,13 @@ 0 - 100 + 60 16777215 - 100 + 60 diff --git a/harbour/contrib/hbide/resources/findinfiles.uic b/harbour/contrib/hbide/resources/findinfiles.uic index 6da7de9b4a..bfb680c999 100644 --- a/harbour/contrib/hbide/resources/findinfiles.uic +++ b/harbour/contrib/hbide/resources/findinfiles.uic @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading ui file 'findinfiles.ui' ** -** Created: Thu Feb 4 18:06:12 2010 +** Created: Sat Feb 6 02:13:07 2010 ** by: Qt User Interface Compiler version 4.5.0 ** ** WARNING! All changes made in this file will be lost when recompiling ui file! @@ -91,8 +91,8 @@ public: listProjects = new QListWidget(FindReplInFiles); listProjects->setObjectName(QString::fromUtf8("listProjects")); - listProjects->setMinimumSize(QSize(0, 100)); - listProjects->setMaximumSize(QSize(16777215, 100)); + listProjects->setMinimumSize(QSize(0, 60)); + listProjects->setMaximumSize(QSize(16777215, 60)); listProjects->setEditTriggers(QAbstractItemView::NoEditTriggers); listProjects->setSelectionMode(QAbstractItemView::MultiSelection); listProjects->setSortingEnabled(false); diff --git a/harbour/contrib/hbqt/THbQtUI.prg b/harbour/contrib/hbqt/THbQtUI.prg index bca0dccfab..eeeed20883 100644 --- a/harbour/contrib/hbqt/THbQtUI.prg +++ b/harbour/contrib/hbqt/THbQtUI.prg @@ -97,6 +97,7 @@ CLASS HbQtUI METHOD loadContents( cUiFull ) METHOD loadUI( cUiFull, qParent ) METHOD build( cFileOrBuffer, qParent ) + METHOD formatCommand( cCmd, lText ) ERROR HANDLER OnError( ... ) @@ -388,7 +389,7 @@ METHOD HbQtUI:build( cFileOrBuffer, qParent ) ELSEIF !empty( cText := hbq_pullSetToolTip( ::org, s:__enumIndex() ) ) n := at( "->", cText ) cNam := alltrim( substr( cText, 1, n - 1 ) ) - cCmd := hbq_cmdFormat( substr( cText, n + 2 ), .t. ) + cCmd := ::formatCommand( substr( cText, n + 2 ), .t. ) aadd( aCommands, { cNam, cCmd } ) // hbq_dbg( "Command ", pad( cNam, 20 ), cCmd ) @@ -396,7 +397,7 @@ METHOD HbQtUI:build( cFileOrBuffer, qParent ) ELSEIF !empty( cText := hbq_pullText( ::org, s:__enumIndex() ) ) n := at( "->", cText ) cNam := alltrim( substr( cText, 1, n - 1 ) ) - cCmd := hbq_cmdFormat( substr( cText, n + 2 ), .t. ) + cCmd := ::formatCommand( substr( cText, n + 2 ), .t. ) aadd( aCommands, { cNam, cCmd } ) // hbq_dbg( "Command ", pad( cNam, 20 ), cCmd ) @@ -404,7 +405,7 @@ METHOD HbQtUI:build( cFileOrBuffer, qParent ) ELSEIF hbq_isValidCmdLine( s ) .AND. !( "->" $ s ) .AND. ( ( n := at( ".", s ) ) > 0 ) /* Assignment to objects on stack */ cNam := substr( s, 1, n - 1 ) cCmd := substr( s, n + 1 ) - cCmd := hbq_cmdFormat( cCmd, .f. ) + cCmd := ::formatCommand( cCmd, .f. ) cCmd := hbq_setObjects( cCmd, ::widgets ) cCmd := hbq_setObjects( cCmd, ::widgets ) aadd( aCommands, { cNam, cCmd } ) @@ -416,7 +417,7 @@ METHOD HbQtUI:build( cFileOrBuffer, qParent ) ( at( "->", s ) > n ) cNam := substr( s, 1, n - 1 ) cCmd := substr( s, n + 1 ) - cCmd := hbq_cmdFormat( cCmd, .f. ) + cCmd := ::formatCommand( cCmd, .f. ) cCmd := hbq_setObjects( cCmd, ::widgets ) cCmd := hbq_setObjects( cCmd, ::widgets ) aadd( aCommands, { cNam, cCmd } ) @@ -425,7 +426,7 @@ METHOD HbQtUI:build( cFileOrBuffer, qParent ) ELSEIF ( n := at( "->", s ) ) > 0 /* Assignments or calls to objects on heap */ cNam := substr( s, 1, n - 1 ) - cCmd := hbq_cmdFormat( substr( s, n + 2 ), .f. ) + cCmd := ::formatCommand( substr( s, n + 2 ), .f. ) cCmd := hbq_setObjects( cCmd, ::widgets ) aadd( aCommands, { cNam, cCmd } ) // @@ -469,11 +470,11 @@ hbq_dbg( "------------------------------------------------------------" ) IF a_:__enumIndex() > 1 IF type( a_[ 3 ] ) == "UI" cBlock := "{|o| " + a_[ 4 ] + "}" +hbq_dbg( "Constr ", pad( a_[ 2 ], 20 ), cBlock ) bBlock := &( cBlock ) x := eval( bBlock, ::qObj ) IF hb_isObject( x ) -hbq_dbg( "Constr ", pad( a_[ 2 ], 20 ), x:pPtr, cBlock ) ::qObj[ a_[ 2 ] ] := x ENDIF ELSE @@ -535,6 +536,49 @@ hbq_dbg( pad( a_[ 1 ], 20 ), cBlock ) /*----------------------------------------------------------------------*/ +METHOD HbQtUI:formatCommand( cCmd, lText ) + LOCAL regDefine, aDefine, n, n1, cNam, cCmd1 + + STATIC nn := 100 + + DEFAULT lText TO .t. + + cCmd := strtran( cCmd, "QApplication::translate" , "q__tr" ) + cCmd := strtran( cCmd, "QApplication::UnicodeUTF8", '"UTF8"' ) + cCmd := strtran( cCmd, "QString()" , '""' ) + cCmd := strtran( cCmd, "QSize(" , "QSize():new(" ) + cCmd := strtran( cCmd, "QRect(" , "QRect():new(" ) + + IF ( "::" $ cCmd ) + regDefine := hb_RegexComp( "\b[A-Za-z_]+\:\:[A-Za-z_]+\b" ) + aDefine := hb_RegEx( regDefine, cCmd ) + IF !empty( aDefine ) + cCmd := strtran( cCmd, "::", "_" ) /* Qt Defines - how to handle */ + ENDIF + ENDIF + + IF ! lText .AND. ( at( ".", cCmd ) ) > 0 + // sizePolicy setHeightForWidth(ProjectProperties->sizePolicy().hasHeightForWidth()); + // + IF ( at( "setHeightForWidth(", cCmd ) ) > 0 + cNam := "__qsizePolicy" + hb_ntos( ++nn ) + n := at( "(", cCmd ) + n1 := at( ".", cCmd ) + cCmd1 := hbq_setObjects( substr( cCmd, n + 1, n1 - n - 1 ), ::widgets ) + cCmd1 := strtran( cCmd1, "->", ":" ) + aadd( ::widgets, { "QSizePolicy", cNam, "QSizePolicy()", "QSizePolicy():configure(" + cCmd1 + ")" } ) + cCmd := 'setHeightForWidth(o[ "' + cNam + '" ]:' + substr( cCmd, n1 + 1 ) + + ELSE + cCmd := "pPtr" + + ENDIF + ENDIF + + RETURN cCmd + +/*----------------------------------------------------------------------*/ + STATIC FUNCTION hbq_isObjectNameSet( s ) RETURN ( "objectName" $ s .OR. "ObjectName" $ s ) @@ -628,46 +672,6 @@ STATIC FUNCTION hbq_replaceConstants( s, hConst ) /*----------------------------------------------------------------------*/ -STATIC FUNCTION hbq_cmdFormat( cCmd, lTip ) - LOCAL regDefine, aDefine, n, n1 - - cCmd := strtran( cCmd, "QApplication::translate" , "q__tr" ) - cCmd := strtran( cCmd, "QApplication::UnicodeUTF8", '"UTF8"' ) - cCmd := strtran( cCmd, "QString()" , '""' ) - cCmd := strtran( cCmd, "QSize(" , "QSize():new(" ) - cCmd := strtran( cCmd, "QRect(" , "QRect():new(" ) - - IF ( "::" $ cCmd ) - regDefine := hb_RegexComp( "\b[A-Za-z_]+\:\:[A-Za-z_]+\b" ) - aDefine := hb_RegEx( regDefine, cCmd ) - IF !empty( aDefine ) - cCmd := strtran( cCmd, "::", "_" ) /* Qt Defines - how to handle */ - ENDIF - ENDIF - - IF !( lTip ) -// cCmd := strtran( cCmd, "|" , "+" ) /* C OR */ - - IF ( at( ".", cCmd ) ) > 0 - /* TODO: call object's contructor in :configure */ - // - // sizePolicy setHeightForWidth(ProjectProperties->sizePolicy().hasHeightForWidth()); - // - IF ( at( "setHeightForWidth(", cCmd ) ) > 0 - n := at( "(", cCmd ) - n1 := at( ".", cCmd ) - cCmd := "setHeightForWidth(QSizePolicy():configure(" + ; - substr( cCmd, n + 1, n1 - n - 1 ) + ")" + ':' + substr( cCmd, n1 + 1 ) - ELSE - cCmd := "pPtr" - ENDIF - ENDIF - ENDIF - - RETURN cCmd - -/*----------------------------------------------------------------------*/ - STATIC FUNCTION hbq_setObjects( cCmd, aObj_ ) LOCAL n, cObj IF ( n := ascan( aObj_, {|e_| ( e_[ 2 ] + "," ) $ cCmd } ) ) > 0 diff --git a/harbour/contrib/hbqt/qtgui/QSizePolicy.cpp b/harbour/contrib/hbqt/qtgui/QSizePolicy.cpp index d9a61324f8..b257b356ad 100644 --- a/harbour/contrib/hbqt/qtgui/QSizePolicy.cpp +++ b/harbour/contrib/hbqt/qtgui/QSizePolicy.cpp @@ -137,9 +137,12 @@ HB_FUNC( QT_QSIZEPOLICY ) if( hb_pcount() >= 2 && HB_ISNUM( 1 ) && HB_ISNUM( 2 ) ) { -HB_TRACE( HB_TR_ALWAYS, ( "================ %i %i", hb_parni( 1 ), hb_parni( 2 ) ) ); pObj = new QSizePolicy( ( QSizePolicy::Policy ) hb_parni( 1 ), ( QSizePolicy::Policy ) hb_parni( 2 ) ) ; } + else if( hb_pcount() == 1 && HB_ISPOINTER( 1 ) ) + { + pObj = new QSizePolicy( *hbqt_par_QSizePolicy( 1 ) ) ; + } else { pObj = new QSizePolicy() ; diff --git a/harbour/contrib/hbqt/qth/QSizePolicy.qth b/harbour/contrib/hbqt/qth/QSizePolicy.qth index 93ca55a09b..4c5532a197 100644 --- a/harbour/contrib/hbqt/qth/QSizePolicy.qth +++ b/harbour/contrib/hbqt/qth/QSizePolicy.qth @@ -76,6 +76,10 @@ HB_FUNC( QT_QSIZEPOLICY ) { hb_retptr( new QSizePolicy( ( QSizePolicy::Policy ) hb_parni( 1 ), ( QSizePolicy::Policy ) hb_parni( 2 ) ) ); } + else if( hb_pcount() == 1 && HB_ISPOINTER( 1 ) ) + { + hb_retptr( new QSizePolicy( *hbqt_par_QSizePolicy( 1 ) ) ); + } else { hb_retptr( new QSizePolicy() );