From 9b085ea6750c1c858ef44102437dda7454fa12a0 Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Thu, 26 Nov 2009 10:29:57 +0000 Subject: [PATCH] 2009-11-26 02:27 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * contrib/hbqt/hbqt_slots.cpp * contrib/hbqt/hbqt_slots.h * contrib/hbqt/qtgui/QLabel.cpp * contrib/hbqt/qth/QLabel.qth + contrib/hbide/resources/tabcmodified.png + contrib/hbide/resources/tabmodified.PNG + contrib/hbide/resources/tabreadonly.png + contrib/hbide/resources/tabunmodified.png * contrib/hbide/hbide.prg * contrib/hbide/ideactions.prg + Implemented "Find" functionality. CTRL_F or icon can be clicked. Input some string in "Find what" field and keep on pressing . + Implemented "Print with Preview" of current source code. ! Document Tab Image is toggled for "Modified and UnModified" states. ! Fixed some more artifacts. --- harbour/ChangeLog | 20 ++++ harbour/contrib/hbide/hbide.prg | 102 ++++++++++++++---- harbour/contrib/hbide/ideactions.prg | 3 +- .../contrib/hbide/resources/tabcmodified.png | Bin 0 -> 135 bytes .../contrib/hbide/resources/tabmodified.PNG | Bin 0 -> 121 bytes .../contrib/hbide/resources/tabreadonly.png | Bin 0 -> 127 bytes .../contrib/hbide/resources/tabunmodified.png | Bin 0 -> 165 bytes harbour/contrib/hbqt/hbqt_slots.cpp | 14 ++- harbour/contrib/hbqt/hbqt_slots.h | 1 + harbour/contrib/hbqt/qtgui/QLabel.cpp | 30 +++--- harbour/contrib/hbqt/qth/QLabel.qth | 17 ++- 11 files changed, 149 insertions(+), 38 deletions(-) create mode 100644 harbour/contrib/hbide/resources/tabcmodified.png create mode 100644 harbour/contrib/hbide/resources/tabmodified.PNG create mode 100644 harbour/contrib/hbide/resources/tabreadonly.png create mode 100644 harbour/contrib/hbide/resources/tabunmodified.png diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 215e324a95..8ef8c5d4ff 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,26 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-11-26 02:27 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * contrib/hbqt/hbqt_slots.cpp + * contrib/hbqt/hbqt_slots.h + + * contrib/hbqt/qtgui/QLabel.cpp + * contrib/hbqt/qth/QLabel.qth + + + contrib/hbide/resources/tabcmodified.png + + contrib/hbide/resources/tabmodified.PNG + + contrib/hbide/resources/tabreadonly.png + + contrib/hbide/resources/tabunmodified.png + + * contrib/hbide/hbide.prg + * contrib/hbide/ideactions.prg + + Implemented "Find" functionality. CTRL_F or icon can be clicked. + Input some string in "Find what" field and keep on pressing . + + Implemented "Print with Preview" of current source code. + ! Document Tab Image is toggled for "Modified and UnModified" states. + ! Fixed some more artifacts. + 2009-11-26 08:31 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbqt/hbqt.hbc * contrib/hbqt/hbqts.hbc diff --git a/harbour/contrib/hbide/hbide.prg b/harbour/contrib/hbide/hbide.prg index f234b5d00e..374509f3da 100644 --- a/harbour/contrib/hbide/hbide.prg +++ b/harbour/contrib/hbide/hbide.prg @@ -122,6 +122,7 @@ CLASS HbIde DATA qSplitterR DATA qTabWidget DATA qFindDlg + ACCESS qCurEdit INLINE iif( ::getCurrentTab() > 0, ::aTabs[ ::getCurrentTab(), 2 ], NIL ) /* XBP Objects */ @@ -142,6 +143,7 @@ CLASS HbIde DATA oLinkResult DATA oNewDlg DATA oTabWidget + DATA oPBFind, oPBRepl, oPBClose, oFind, oRepl DATA oCurProjItem @@ -196,9 +198,12 @@ CLASS HbIde DATA aComments INIT {} METHOD createTags() - METHOD loadUI() + METHOD findReplace() METHOD manageFocusInEditor() METHOD convertSelection() + METHOD printPreview() + METHOD paintRequested() + METHOD setTabImage() ENDCLASS @@ -332,9 +337,12 @@ METHOD HbIde:create( cProjectOrSource ) ::lDockRVisible := .f. ENDIF + CASE ::mp1 == xbeK_CTRL_S + ::saveSource( ::getCurrentTab(), .f. ) + CASE ::mp1 == xbeK_CTRL_F IF !empty( ::qCurEdit ) - ::loadUI( "finddialog" ) + ::findReplace( "finddialog" ) ENDIF ENDCASE @@ -370,6 +378,10 @@ METHOD HbIde:executeAction( cKey ) ::saveSource( ::getCurrentTab(), .f. ) CASE cKey == "Close" ::closeSource() + CASE cKey == "Print" + IF !empty( ::qCurEdit ) + ::printPreview() + ENDIF CASE cKey == "Undo" IF !empty( ::qCurEdit ) ::qCurEdit:undo() @@ -396,7 +408,7 @@ METHOD HbIde:executeAction( cKey ) ENDIF CASE cKey == "Find" IF !empty( ::qCurEdit ) - ::loadUI( "finddialog" ) + ::findReplace( "finddialog" ) ENDIF CASE cKey == "ToUpper" ::convertSelection( cKey ) @@ -433,6 +445,7 @@ METHOD HbIde:executeAction( cKey ) ::lDockRVisible := !( ::lDockRVisible ) CASE cKey == "Compile" + CASE cKey == "CompilePPO" ENDCASE @@ -500,11 +513,26 @@ METHOD HbIde:updateFuncList() /*----------------------------------------------------------------------*/ +METHOD HbIde:setTabImage( cState, oTab ) + LOCAL nIndex := ::qTabWidget:indexOf( QT_PTROFXBP( oTab ) ) + + DO CASE + CASE cState == "modified" + ::qTabWidget:setTabIcon( nIndex, s_resPath + "tabmodified.png" ) + + CASE cState == "unmodified" + ::qTabWidget:setTabIcon( nIndex, s_resPath + "tabunmodified.png" ) + + ENDCASE + + RETURN Self + +/*----------------------------------------------------------------------*/ + METHOD HbIde:buildTabPage( oWnd, cSource ) - LOCAL oTab, cPath, cFile, cExt + LOCAL oTab, cPath, cFile, cExt, nIndex LOCAL aPos := { 5,5 } LOCAL aSize := { 890, 420 } - LOCAL nIndex := len( ::aTabs ) DEFAULT cSource TO "Untitled" @@ -516,10 +544,11 @@ METHOD HbIde:buildTabPage( oWnd, cSource ) oTab:create() + nIndex := ::qTabWidget:currentIndex() IF lower( cExt ) $ ".c;.cpp" - ::qTabWidget:setTabIcon( nIndex, s_resPath + "filec.png" ) + ::setTabImage( "unmodified", oTab ) ELSE - ::qTabWidget:setTabIcon( nIndex, s_resPath + "fileprg.png" ) + ::setTabImage( "unmodified", oTab ) ENDIF ::qTabWidget:setTabTooltip( nIndex, cSource ) @@ -531,7 +560,7 @@ METHOD HbIde:buildTabPage( oWnd, cSource ) /*----------------------------------------------------------------------*/ METHOD HbIde:editSource( cSourceFile ) - LOCAL oTab, qEdit, qHiliter, qLayout + LOCAL oTab, qEdit, qHiliter, qLayout, qDocument DEFAULT cSourceFile TO ::cProjFile @@ -565,6 +594,11 @@ METHOD HbIde:editSource( cSourceFile ) ::updateFuncList() ::manageFocusInEditor() + qDocument := QTextDocument():configure( qEdit:document() ) + qDocument:setModified( .f. ) + + Qt_Connect_Signal( QT_PTROF( qEdit ), "textChanged()", {|| ::setTabImage( "modified", oTab ) } ) + RETURN Self /*----------------------------------------------------------------------*/ @@ -676,6 +710,8 @@ METHOD HbIde:saveSource( nTab, lConfirm ) ELSE ENDIF ENDIF + + ::setTabImage( "unmodified", ::aTabs[ nTab, 1 ] ) ENDIF RETURN Self @@ -1016,6 +1052,30 @@ METHOD HbIde:CreateTags() //----------------------------------------------------------------------// +METHOD HbIde:printPreview() + LOCAL qDlg + + qDlg := QPrintPreviewDialog():new( QT_PTROFXBP( ::oDlg ) ) + qDlg:setWindowTitle( "Harbour-QT Preview Dialog" ) + Qt_Connect_Signal( qDlg:pPtr, "paintRequested(QPrinter)", {|o,p| ::paintRequested( p,o ) } ) + qDlg:exec() + Qt_DisConnect_Signal( qDlg:pPtr, "paintRequested(QPrinter)" ) + + RETURN self + +/*----------------------------------------------------------------------*/ + +METHOD HbIde:paintRequested( pPrinter ) + LOCAL qPrinter + + qPrinter := QPrinter():configure( pPrinter ) + + ::qCurEdit:print( QT_PTROF( qPrinter ) ) + + RETURN Self + +/*----------------------------------------------------------------------*/ + METHOD HbIde:fetchProjectProperties( lNewProject ) LOCAL nRet LOCAL qLayout, qHBLayout @@ -1105,38 +1165,36 @@ METHOD HbIde:fetchProjectProperties( lNewProject ) /*----------------------------------------------------------------------*/ -METHOD HbIde:loadUI( cUi ) +METHOD HbIde:findReplace( cUi ) LOCAL qUiLoader, qFile, cUiFull - STATIC oPBFind, oPBRepl, oPBClose, qFind, qRepl - IF ::qFindDlg == NIL cUiFull := s_resPath + cUi + ".ui" qFile := QFile():new( cUiFull ) IF qFile:open( 1 ) qUiLoader := QUiLoader():new() ::qFindDlg := QDialog():configure( qUiLoader:load( QT_PTROF( qFile ), QT_PTROFXBP( ::oDlg ) ) ) - qFile:close() ::qFindDlg:setWindowFlags( Qt_Sheet ) + qFile:close() // - oPBFind := XbpPushButton():new():createFromQtPtr( , , , , , , Qt_findChild( QT_PTROF( ::qFindDlg ), "buttonFind" ) ) - oPBFind:activate := {|| ::qCurEdit:find( "Harbour" ) } + ::oFind := XbpComboBox():new():createFromQtPtr( , , , , , , Qt_findChild( QT_PTROF( ::qFindDlg ), "comboFindWhat" ) ) + ::oRepl := XbpComboBox():new():createFromQtPtr( , , , , , , Qt_findChild( QT_PTROF( ::qFindDlg ), "comboReplaceWith" ) ) - oPBRepl := XbpPushButton():new():createFromQtPtr( , , , , , , Qt_findChild( QT_PTROF( ::qFindDlg ), "buttonReplace" ) ) - oPBRepl:activate := {|| ::qCurEdit:find( "something" ) } + ::oPBFind := XbpPushButton():new():createFromQtPtr( , , , , , , Qt_findChild( QT_PTROF( ::qFindDlg ), "buttonFind" ) ) + ::oPBFind:activate := {|| ::qCurEdit:find( QLineEdit():configure( ::oFind:oWidget:lineEdit() ):text() ) } - oPBClose := XbpPushButton():new():createFromQtPtr( , , , , , , Qt_findChild( QT_PTROF( ::qFindDlg ), "buttonClose" ) ) - oPBClose:activate := {|| ::qFindDlg:hide() /*done( 1 )*/ } + ::oPBRepl := XbpPushButton():new():createFromQtPtr( , , , , , , Qt_findChild( QT_PTROF( ::qFindDlg ), "buttonReplace" ) ) + ::oPBRepl:activate := {|t| t := QLineEdit():configure( ::oRepl:oWidget:lineEdit() ):text() } - qFind := XbpComboBox():new():createFromQtPtr( , , , , , , Qt_findChild( QT_PTROF( ::qFindDlg ), "comboFindWhat" ) ) - qRepl := XbpComboBox():new():createFromQtPtr( , , , , , , Qt_findChild( QT_PTROF( ::qFindDlg ), "comboReplaceWith" ) ) - - JustACall( qFind, qRepl ) + ::oPBClose := XbpPushButton():new():createFromQtPtr( , , , , , , Qt_findChild( QT_PTROF( ::qFindDlg ), "buttonClose" ) ) + ::oPBClose:activate := {|| ::qFindDlg:hide() } ENDIF ENDIF + ::oFind:setFocus() ::qFindDlg:show() RETURN Self /*----------------------------------------------------------------------*/ + diff --git a/harbour/contrib/hbide/ideactions.prg b/harbour/contrib/hbide/ideactions.prg index 27e6bb7b22..1c29993cc3 100644 --- a/harbour/contrib/hbide/ideactions.prg +++ b/harbour/contrib/hbide/ideactions.prg @@ -87,9 +87,10 @@ FUNCTION buildToolBar( oWnd, oIde ) oTBar:addItem( "Open" , cResPath + "open.png" , , , , , "Open" ) oTBar:addItem( "Save" , cResPath + "save.png" , , , , , "Save" ) oTBar:addItem( "Close" , cResPath + "close.png" , , , , , "Close" ) + oTBar:addItem( "Print" , cResPath + "print.png" , , , , , "Print" ) oTBar:addItem( , , , , , XBPTOOLBAR_BUTTON_SEPARATOR ) oTBar:addItem( "Compile" , cResPath + "compile.png" , , , , , "Compile" ) - oTBar:addItem( "Compile to PPO" , cResPath + "ppo.png" , , , , , "6" ) + oTBar:addItem( "Compile to PPO" , cResPath + "ppo.png" , , , , , "CompilePPO" ) oTBar:addItem( "Build Project" , cResPath + "build.png" , , , , , "7" ) oTBar:addItem( "Build and Launch Project" , cResPath + "buildlaunch.png" , , , , , "8" ) oTBar:addItem( "Rebuild Project" , cResPath + "rebuild.png" , , , , , "9" ) diff --git a/harbour/contrib/hbide/resources/tabcmodified.png b/harbour/contrib/hbide/resources/tabcmodified.png new file mode 100644 index 0000000000000000000000000000000000000000..3a16317eaee552b62c66c37587d2ce190a6dad73 GIT binary patch literal 135 zcmeAS@N?(olHy`uVBq!ia0vp^96-#)!2~4PmUdhRQY`6?zK#qG8~eHcB(ehecAhSd zArj%qDG5K$H*g+E`hSrjLeqmSmg$7Mhr<&^Hzkz`u7N5KvK~Hj>TR;-TEw(lR$#h7 hk?5I+0<8fo43kUCyVktfBM&r*!PC{xWt~$(69D!YC@25` literal 0 HcmV?d00001 diff --git a/harbour/contrib/hbide/resources/tabmodified.PNG b/harbour/contrib/hbide/resources/tabmodified.PNG new file mode 100644 index 0000000000000000000000000000000000000000..d38d7bb9c990acbce7425e9585894505d17adf92 GIT binary patch literal 121 zcmeAS@N?(olHy`uVBq!ia0vp^96-#)!2~4PmUdhRQY`6?zK#qG8~eHcB(ehe2A(dC zArj%qDG5K$H*g+E`hSrjLeqmyh3`6ZV9SI9%Q!>XkFd;oaUjp~%tHa|g&Yh{ylvI` SQI2Uqy$qhNelF{r5}E+kNFn3^ literal 0 HcmV?d00001 diff --git a/harbour/contrib/hbide/resources/tabreadonly.png b/harbour/contrib/hbide/resources/tabreadonly.png new file mode 100644 index 0000000000000000000000000000000000000000..78ceedb4d558f3408b4ea4a781e2bbaa22533e89 GIT binary patch literal 127 zcmeAS@N?(olHy`uVBq!ia0vp^96-#)!2~4PmUdhRQY`6?zK#qG8~eHcB(eheW}YsN zArj%qDL?+tXS8PUN^lhjT%c#sw8~ky)uZ|8ge!|)F?%L6Oi-&4y5YmT`uGHfYQFYj ZM$N;eJ)LGuGl3>Bc)I$ztaD0e0sxsZBq0C* literal 0 HcmV?d00001 diff --git a/harbour/contrib/hbide/resources/tabunmodified.png b/harbour/contrib/hbide/resources/tabunmodified.png new file mode 100644 index 0000000000000000000000000000000000000000..89af0dc67a52788897e484a5c85b3482303aab00 GIT binary patch literal 165 zcmeAS@N?(olHy`uVBq!ia0vp^96-#)!2~4PmUdhRQjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`6_P!Id>I(3)EF2VS{N990fib~Fff!FFfhDIU|_JC!N4G1FlSew4NyYa z)5S4FB0M=I;m7#~&I3vRFET`Eda%VZoshpGWYF#$!|BS9bbEP}l&+X4P&tFAtDnm{ Hr-UW|+wdv0 literal 0 HcmV?d00001 diff --git a/harbour/contrib/hbqt/hbqt_slots.cpp b/harbour/contrib/hbqt/hbqt_slots.cpp index 674c4811b7..9c69868007 100644 --- a/harbour/contrib/hbqt/hbqt_slots.cpp +++ b/harbour/contrib/hbqt/hbqt_slots.cpp @@ -1110,8 +1110,13 @@ void Slots::tabCloseRequested( int index ) QObject *object = qobject_cast( sender() ); SlotsExecInt( object, ( char* ) "tabCloseRequested(int)", index ); } +void Slots::paintRequested( QPrinter * printer ) +{ + QObject *object = qobject_cast( sender() ); + SlotsExecPointer( object, ( char* ) "paintRequested(QPrinter)", printer ); +} - +/*----------------------------------------------------------------------*/ /* * harbour function to connect signals with slots */ @@ -1701,6 +1706,11 @@ HB_FUNC( QT_CONNECT_SIGNAL ) ret = object->connect( object, SIGNAL( tabCloseRequested( int ) ), s_s, SLOT( tabCloseRequested( int ) ), Qt::AutoConnection ); } + if( signal == ( QString ) "paintRequested(QPrinter)" ) + { + ret = object->connect( object, SIGNAL( paintRequested( QPrinter * ) ), + s_s, SLOT( paintRequested( QPrinter * ) ), Qt::AutoConnection ); + } hb_retl( ret ); @@ -1950,6 +1960,8 @@ bool disconnect_signal( QObject * object, const char * signal ) ret = object->disconnect( SIGNAL( currentCellChanged( int, int, int, int ) ) ); if( signal == ( QString ) "tabCloseRequested(int)" ) ret = object->disconnect( SIGNAL( tabCloseRequested( int ) ) ); + if( signal == ( QString ) "paintRequested(QPrinter)" ) + ret = object->disconnect( SIGNAL( paintRequested( QPrinter * ) ) ); return ret; } diff --git a/harbour/contrib/hbqt/hbqt_slots.h b/harbour/contrib/hbqt/hbqt_slots.h index a2d72eab3b..894ddf871b 100644 --- a/harbour/contrib/hbqt/hbqt_slots.h +++ b/harbour/contrib/hbqt/hbqt_slots.h @@ -324,6 +324,7 @@ public slots: void cellPressed( int row, int column ); void currentCellChanged( int currentRow, int currentColumn, int previousRow, int previousColumn ); void tabCloseRequested( int index ); + void paintRequested( QPrinter * printer ); }; class Events: public QObject diff --git a/harbour/contrib/hbqt/qtgui/QLabel.cpp b/harbour/contrib/hbqt/qtgui/QLabel.cpp index 126ef077f8..1b427f941f 100644 --- a/harbour/contrib/hbqt/qtgui/QLabel.cpp +++ b/harbour/contrib/hbqt/qtgui/QLabel.cpp @@ -96,18 +96,7 @@ QT_G_FUNC( release_QLabel ) const QMetaObject * m = ( ( QObject * ) p->ph )->metaObject(); if( ( QString ) m->className() != ( QString ) "QObject" ) { - switch( hbqt_get_object_release_method() ) - { - case HBQT_RELEASE_WITH_DELETE: - delete ( ( QLabel * ) p->ph ); - break; - case HBQT_RELEASE_WITH_DESTRUTOR: - ( ( QLabel * ) p->ph )->~QLabel(); - break; - case HBQT_RELEASE_WITH_DELETE_LATER: - ( ( QLabel * ) p->ph )->deleteLater(); - break; - } + ( ( QLabel * ) p->ph )->~QLabel(); p->ph = NULL; HB_TRACE( HB_TR_DEBUG, ( "release_QLabel Object deleted!" ) ); #if defined( __HB_DEBUG__ ) @@ -148,7 +137,22 @@ HB_FUNC( QT_QLABEL ) { void * pObj = NULL; - pObj = ( QLabel* ) new QLabel( hbqt_par_QWidget( 1 ) ) ; + if( hb_pcount() == 1 && HB_ISCHAR( 1 ) ) + { + pObj = ( QLabel* ) new QLabel( hbqt_par_QString( 1 ), 0, 0 ) ; + } + else if( hb_pcount() == 1 && HB_ISPOINTER( 1 ) ) + { + pObj = ( QLabel* ) new QLabel( hbqt_par_QWidget( 1 ) ) ; + } + if( hb_pcount() == 2 && HB_ISCHAR( 1 ) && HB_ISPOINTER( 2 ) ) + { + pObj = ( QLabel* ) new QLabel( hbqt_par_QString( 1 ), hbqt_par_QWidget( 2 ) ) ; + } + else + { + pObj = ( QLabel* ) new QLabel() ; + } hb_retptrGC( gcAllocate_QLabel( pObj ) ); } diff --git a/harbour/contrib/hbqt/qth/QLabel.qth b/harbour/contrib/hbqt/qth/QLabel.qth index d1c177df71..488d38d38b 100644 --- a/harbour/contrib/hbqt/qth/QLabel.qth +++ b/harbour/contrib/hbqt/qth/QLabel.qth @@ -70,7 +70,22 @@ New = pParent, nFlags */ HB_FUNC( QT_QLABEL ) { - hb_retptr( ( QLabel* ) new QLabel( hbqt_par_QWidget( 1 ) ) ); + if( hb_pcount() == 1 && HB_ISCHAR( 1 ) ) + { + hb_retptr( ( QLabel* ) new QLabel( hbqt_par_QString( 1 ) ) ); + } + else if( hb_pcount() == 1 && HB_ISPOINTER( 1 ) ) + { + hb_retptr( ( QLabel* ) new QLabel( hbqt_par_QWidget( 1 ) ) ); + } + if( hb_pcount() == 2 && HB_ISCHAR( 1 ) && HB_ISPOINTER( 2 ) ) + { + hb_retptr( ( QLabel* ) new QLabel( hbqt_par_QString( 1 ), hbqt_par_QWidget( 2 ) ) ); + } + else + { + hb_retptr( ( QLabel* ) new QLabel() ); + } }