From 2173ae9ea531cd3f37e64454ce38da5ce87705e5 Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Fri, 13 Jul 2012 06:55:51 +0000 Subject: [PATCH] 2012-07-12 23:33 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbide/idebrowse.prg * contrib/hbide/ideeditor.prg * contrib/hbide/idemain.prg * contrib/hbide/idesources.prg + Implemented: 1. IdeDBU mode where .dbf(s) can be passed on command-line, as: HbIDE.exe \harbour\tests\test.dbf myOther.dbf This mode can be combined with pure source editing mode where source(s) are passed on the command-line, like; HbIDE.exe \harbour\tests\test.dbf myOther.dbf \mysources\first.prg. This mode also hides "Main" and "Docking Widgets" toolbars, thus presents a lean look. If a .dbf is passed as above, then IdeDBU gets preference over source editor in terms of application's real-estate, which seems logical. Currently, DBFCDX driver is used to open these tables, but logic is in place to honour other drivers; the only issue is how to get this information on the command-line. 2. A "default.prg" source will welcome the user on "Main" panel ready to accept input, if HbIDE is opened without any sources made available to be opened. The actual filename will be requested at the time of saving that source; either explicitly saved, or on termination. This request will come-up only if the source has been modified. --- harbour/ChangeLog | 28 ++++++++++++++ harbour/contrib/hbide/idebrowse.prg | 25 ++++++++++++ harbour/contrib/hbide/ideeditor.prg | 2 +- harbour/contrib/hbide/idemain.prg | 12 ++++++ harbour/contrib/hbide/idesources.prg | 58 +++++++++++++++------------- 5 files changed, 98 insertions(+), 27 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 8c0ab98970..734429f254 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,34 @@ The license applies to all entries newer than 2009-04-28. */ +2012-07-12 23:33 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + * contrib/hbide/idebrowse.prg + * contrib/hbide/ideeditor.prg + * contrib/hbide/idemain.prg + * contrib/hbide/idesources.prg + + Implemented: + 1. IdeDBU mode where .dbf(s) can be passed on command-line, as: + HbIDE.exe \harbour\tests\test.dbf myOther.dbf + + This mode can be combined with pure source editing mode + where source(s) are passed on the command-line, like; + HbIDE.exe \harbour\tests\test.dbf myOther.dbf \mysources\first.prg. + + This mode also hides "Main" and "Docking Widgets" toolbars, + thus presents a lean look. If a .dbf is passed as above, + then IdeDBU gets preference over source editor in terms of + application's real-estate, which seems logical. Currently, + DBFCDX driver is used to open these tables, but logic is in + place to honour other drivers; the only issue is how to get this + information on the command-line. + + 2. A "default.prg" source will welcome the user on "Main" panel + ready to accept input, if HbIDE is opened without any sources + made available to be opened. The actual filename will be requested + at the time of saving that source; either explicitly saved, or + on termination. This request will come-up only if the source + has been modified. + 2012-07-12 09:26 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbide/ideedit.prg * contrib/hbide/ideeditor.prg diff --git a/harbour/contrib/hbide/idebrowse.prg b/harbour/contrib/hbide/idebrowse.prg index 8aed369be5..aa37a29b22 100644 --- a/harbour/contrib/hbide/idebrowse.prg +++ b/harbour/contrib/hbide/idebrowse.prg @@ -146,6 +146,7 @@ CLASS IdeBrowseManager INHERIT IdeObject METHOD new( oIde ) METHOD create( oIde ) METHOD show() + METHOD open( aDbfs ) METHOD destroy() METHOD buildToolbar() METHOD execEvent( cEvent, p, p1 ) @@ -949,6 +950,30 @@ METHOD IdeBrowseManager:buildUiStruct() /*----------------------------------------------------------------------*/ +METHOD IdeBrowseManager:open( aDbfs ) + LOCAL aInfo, cTable, oRect, oRec := ::oDlg:geometry() + LOCAL nX := 0, nY := 0 + + FOR EACH cTable IN aDbfs + nX += 20; nY += 20 + // Main,C:\harbour\tests\test.dbf,TEST,DBFCDX,0,500,2,0 0 300 504,21,1,,,, + aInfo := array( TBL_VRBLS ) + aInfo[ TBL_PANEL ] := "Main" + aInfo[ TBL_NAME ] := cTable + aInfo[ TBL_GEOMETRY ] := hb_ntos( nX ) + " " + hb_ntos( nY ) + " 500 300" + + ::oCurPanel:addBrowser( aInfo ) + NEXT + oRect := ::oQScintillaDock:oWidget:geometry() + oRect:setWidth( oRec:width() - iif( empty( ::oIde:aSrcOnCmdLine() ), 50, 300 ) ) + ::oQScintillaDock:oWidget:setMinimumWidth( oRect:width() ) + ::oQScintillaDock:oWidget:show() + ::oQScintillaDock:oWidget:setMinimumWidth( 300 ) + + RETURN Self + +/*----------------------------------------------------------------------*/ + METHOD IdeBrowseManager:loadTables() LOCAL cInfo, aInfo, oCurPanel diff --git a/harbour/contrib/hbide/ideeditor.prg b/harbour/contrib/hbide/ideeditor.prg index 8fac07bfd0..83faab9a63 100644 --- a/harbour/contrib/hbide/ideeditor.prg +++ b/harbour/contrib/hbide/ideeditor.prg @@ -1687,7 +1687,7 @@ METHOD IdeEditor:execEvent( cEvent, p, p1, p2 ) CASE "qDocContentsChange" IF p1 + p2 > 0 - ::oEdit:reformatLine( p, p1, p2 ) + ::qCoEdit:reformatLine( p, p1, p2 ) ENDIF EXIT diff --git a/harbour/contrib/hbide/idemain.prg b/harbour/contrib/hbide/idemain.prg index 4eb9b5cc66..05ddb67203 100644 --- a/harbour/contrib/hbide/idemain.prg +++ b/harbour/contrib/hbide/idemain.prg @@ -189,6 +189,7 @@ CLASS HbIde DATA aEditorPath INIT {} DATA aSrcOnCmdLine INIT {} DATA aHbpOnCmdLine INIT {} + DATA aDbfOnCmdLine INIT {} /* HBQT Objects */ DATA qLayout @@ -724,6 +725,8 @@ METHOD HbIde:create( aParams ) IF ::nRunMode == HBIDE_RUN_MODE_PRG ::oDockPT:hide() ::oDockED:hide() + ::qTBarDocks:hide() + ::oMainToolbar:hide() ::oDK:setView( "Main" ) ELSEIF ::nRunMode == HBIDE_RUN_MODE_HBP ::oDockED:hide() @@ -733,6 +736,10 @@ METHOD HbIde:create( aParams ) ::oDK:setView( cView ) ENDIF + IF ! empty( ::aDbfOnCmdLine ) /* Will take priority and allot more width to browser than editor : logical */ + ::oBM:open( ::aDbfOnCmdLine ) + ENDIF + ::qTabWidget:setCurrentIndex( -1 ) ::qTabWidget:setCurrentIndex( 0 ) ::qTabWidget:setCurrentIndex( ::qTabWidget:count() - 1 ) @@ -814,6 +821,8 @@ METHOD HbIde:parseParams() DO CASE CASE cExt == ".ini" aadd( aIni, s ) + CASE cExt == ".dbf" + aadd( ::aDbfOnCmdLine, s ) CASE cExt == ".hbp" aadd( ::aHbpOnCmdLine, s ) CASE cExt $ ".prg.cpp" @@ -833,6 +842,9 @@ METHOD HbIde:parseParams() ELSEIF !empty( ::aSrcOnCmdLine ) ::cProjIni := "" ::nRunMode := HBIDE_RUN_MODE_PRG + ELSEIF !empty( ::aDbfOnCmdLine ) + ::cProjIni := "" + ::nRunMode := HBIDE_RUN_MODE_PRG /* Because then bare-bone HbIDE will be presented like sources */ ELSE ::cProjIni := "" ::nRunMode := HBIDE_RUN_MODE_INI diff --git a/harbour/contrib/hbide/idesources.prg b/harbour/contrib/hbide/idesources.prg index 2bb26b4bc9..881a79930d 100644 --- a/harbour/contrib/hbide/idesources.prg +++ b/harbour/contrib/hbide/idesources.prg @@ -120,11 +120,13 @@ METHOD IdeSourcesManager:create( oIde ) METHOD IdeSourcesManager:loadSources() LOCAL a_ - IF !empty( ::oIni:aFiles ) + IF ! empty( ::oIni:aFiles ) FOR EACH a_ IN ::oIni:aFiles /* File nPos nVPos nHPos cTheme cView lAlert lVisible, aBookMarks */ ::editSource( a_[ 1 ], a_[ 2 ], a_[ 3 ], a_[ 4 ], a_[ 5 ], a_[ 6 ], .t., .f., a_[ 7 ] ) NEXT + ELSE + ::editSource( "default.prg" ) ENDIF RETURN Self @@ -172,23 +174,24 @@ METHOD IdeSourcesManager:editSource( cSourceFile, nPos, nHPos, nVPos, cTheme, cV hbide_SetWrkFolderLast( cSourceFile ) ENDIF - IF !Empty( cSourceFile ) - IF !( hbide_isValidText( cSourceFile ) ) - MsgBox( 'File type unknown or unsupported: ' + cSourceFile ) - RETURN .f. - ELSEIF ! lNew .AND. ! hb_FileExists( cSourceFile ) - MsgBox( 'File not found: ' + cSourceFile ) - RETURN .f. - ENDIF - IF ::oEM:isOpen( cSourceFile ) - IF lAlert - IF hbide_getYesNo( cSourceFile + " is already open.", ; - "Want to re-load it again ?", "File Open Info!" ) - ::oEM:reLoad( cSourceFile ) - ENDIF + IF ! ( cSourceFile == "default.prg" ) + IF !Empty( cSourceFile ) + IF !( hbide_isValidText( cSourceFile ) ) + MsgBox( 'File type unknown or unsupported: ' + cSourceFile ) + RETURN .f. + ELSEIF ! lNew .AND. ! hb_FileExists( cSourceFile ) + MsgBox( 'File not found: ' + cSourceFile ) + RETURN .f. + ENDIF + IF ::oEM:isOpen( cSourceFile ) + IF lAlert + IF hbide_getYesNo( cSourceFile + " is already open.", "Want to re-load it again ?", "File Open Info!" ) + ::oEM:reLoad( cSourceFile ) + ENDIF + ENDIF + ::oEM:setSourceVisible( cSourceFile ) + RETURN .t. ENDIF - ::oEM:setSourceVisible( cSourceFile ) - RETURN .t. ENDIF ENDIF @@ -201,7 +204,7 @@ METHOD IdeSourcesManager:editSource( cSourceFile, nPos, nHPos, nVPos, cTheme, cV ::oEM:setSourceVisible( cSourceFile ) ENDIF - IF !Empty( cSourceFile ) .AND. !hbide_isSourcePPO( cSourceFile ) + IF ! Empty( cSourceFile ) .AND. ! ( cSourceFile == "default.prg" ) .AND. ! hbide_isSourcePPO( cSourceFile ) hbide_mnuAddFileToMRU( Self, cSourceFile, "recent_files" ) ENDIF @@ -220,19 +223,22 @@ METHOD IdeSourcesManager:saveSource( nTab, lCancel, lAs ) lCancel := .F. - IF !empty( oEdit := ::oEM:getEditorByTabPosition( nTab ) ) + IF ! Empty( oEdit := ::oEM:getEditorByTabPosition( nTab ) ) nIndex := ::qTabWidget:indexOf( oEdit:oTab:oWidget ) cSource := oEdit:sourceFile - // IF !Empty( oEdit:sourceFile ) .AND. oEdit:lLoaded .AND. oEdit:qDocument:isModified() - IF lAs .OR. empty( oEdit:sourceFile ) .OR. ( oEdit:lLoaded .AND. oEdit:qDocument:isModified() ) + IF cSource == "default.prg" .or. ! hb_fileExists( oEdit:sourceFile ) + lAs := .t. + ENDIF + + IF lAs .OR. Empty( cSource ) .OR. ( oEdit:lLoaded .AND. oEdit:qDocument:isModified() ) lNew := Empty( cSource ) .OR. lAs IF lNew cNewFile := ::selectSource( 'save', ; - iif( !Empty( cSource ), cSource, hb_dirBase() + "projects" + hb_ps() ),; + iif( ! Empty( cSource ), cSource, hb_dirBase() + "projects" + hb_ps() ),; "Save " + oEdit:oTab:caption + " as..." ) - IF empty( cNewFile ) + IF Empty( cNewFile ) // will check later what decision to take RETURN .f. ENDIF @@ -312,7 +318,7 @@ METHOD IdeSourcesManager:closeSource( nTab, lCanCancel, lCanceled, lAsk ) lSave := .F. ELSEIF lCanCancel - n := hbide_getYesNoCancel( oEditor:oTab:Caption, "has been modified, save this source?", 'Save?' ) + n := hbide_getYesNoCancel( oEditor:oTab:caption, "has been modified, save this source?", 'Save?' ) IF ( lCanceled := ( n == QMessageBox_Cancel ) ) RETURN .F. ENDIF @@ -320,13 +326,13 @@ METHOD IdeSourcesManager:closeSource( nTab, lCanCancel, lCanceled, lAsk ) ELSE IF lAsk - lSave := hbide_getYesNo( oEditor:oTab:Caption, "has been modified, save this source?", 'Save?' ) + lSave := hbide_getYesNo( oEditor:oTab:caption, "has been modified, save this source?", 'Save?' ) ELSE lSave := .t. ENDIF ENDIF - IF lSave .AND. !( ::saveSource( nTab, @lCanceled ) ) + IF lSave .AND. ! ::saveSource( nTab, @lCanceled ) IF lCanCancel RETURN .F. ENDIF