From 1a264692f1d16e41db132cdc154c36d07dfe45be Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Mon, 17 May 2010 04:33:03 +0000 Subject: [PATCH] 2010-15-16 21:05 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * contrib/hbide/resources/tabreadonly.png ! Changed: to reflect clearly visible readonly status. * contrib/hbide/ideedit.prg * contrib/hbide/ideeditor.prg + Implemented: plus file's "readonly" attribute obtained by hb_fGetAttr() == 33 ( please correct me if it is not OK on all systems ). "Switch ReadOnly Mode" toggles the readonly status of the current source in focus only if on disk attribute is normal. ReadOnly status is permanent if disk attribute equals 33 and cannot be toggled. While in readonly mode, cut/paste/alter operation are suspened, only copy operation is supported. Copy can be performed with mouse and keyboard both and all three modes are available. --- harbour/ChangeLog | 19 +++++ harbour/contrib/hbide/ideedit.prg | 65 +++++++++++++++--- harbour/contrib/hbide/ideeditor.prg | 29 +++++--- .../contrib/hbide/resources/tabreadonly.png | Bin 2940 -> 118 bytes 4 files changed, 93 insertions(+), 20 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index f8dbc2620d..cfa39fec0a 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,25 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-15-16 21:05 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * contrib/hbide/resources/tabreadonly.png + ! Changed: to reflect clearly visible readonly status. + + * contrib/hbide/ideedit.prg + * contrib/hbide/ideeditor.prg + + Implemented: plus + file's "readonly" attribute obtained by hb_fGetAttr() == 33 + ( please correct me if it is not OK on all systems ). + + "Switch ReadOnly Mode" toggles the readonly status of the + current source in focus only if on disk attribute is normal. + ReadOnly status is permanent if disk attribute equals 33 and + cannot be toggled. + + While in readonly mode, cut/paste/alter operation are suspened, + only copy operation is supported. Copy can be performed with + mouse and keyboard both and all three modes are available. + 2010-05-17 00:59 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * contrib/sddfb/sddfb.hbi ! Sync with recent fix in contrib/hbfbird/hbfbird.hbi. diff --git a/harbour/contrib/hbide/ideedit.prg b/harbour/contrib/hbide/ideedit.prg index 33eb9f11ef..ca60286a9c 100644 --- a/harbour/contrib/hbide/ideedit.prg +++ b/harbour/contrib/hbide/ideedit.prg @@ -110,26 +110,27 @@ CLASS IdeEdit INHERIT IdeObject DATA aBookMarks INIT {} DATA lModified INIT .F. - DATA lIndentIt INIT .f. - DATA lUpdatePrevWord INIT .f. - DATA lCopyWhenDblClicked INIT .f. + DATA lIndentIt INIT .F. + DATA lUpdatePrevWord INIT .F. + DATA lCopyWhenDblClicked INIT .F. DATA cCurLineText INIT "" DATA cProto INIT "" DATA qTimer DATA nProtoLine INIT -1 DATA nProtoCol INIT -1 - DATA isSuspended INIT .f. + DATA isSuspended INIT .F. DATA fontFamily INIT "Courier New" DATA pointSize INIT 10 DATA currentPointSize INIT 10 DATA qFont DATA aBlockCopyContents INIT {} - DATA isLineSelectionON INIT .f. - DATA aSelectionInfo INIT { -1,-1,-1,-1,0,0 } + DATA isLineSelectionON INIT .F. + DATA aSelectionInfo INIT { -1,-1,-1,-1,1,0 } - DATA isColumnSelectionON INIT .f. + DATA isColumnSelectionON INIT .F. + DATA lReadOnly INIT .F. METHOD new( oEditor, nMode ) METHOD create( oEditor, nMode ) @@ -147,7 +148,7 @@ CLASS IdeEdit INHERIT IdeObject METHOD selectAll() METHOD toggleSelectionMode() - METHOD setReadOnly() + METHOD setReadOnly( lReadOnly ) METHOD setNewMark() METHOD gotoMark( nIndex ) METHOD duplicateLine() @@ -809,6 +810,10 @@ METHOD IdeEdit:copyBlockContents( aCord ) METHOD IdeEdit:pasteBlockContents( nMode ) LOCAL i, nCol, qCursor, nMaxCol, aCopy, a_, nPasteMode + IF ::lReadOnly + RETURN Self + ENDIF + aCopy := hbide_memoToArray( QClipboard():new():text() ) IF empty( aCopy ) RETURN Self @@ -874,6 +879,10 @@ METHOD IdeEdit:pasteBlockContents( nMode ) METHOD IdeEdit:insertBlockContents( aCord ) LOCAL nT, nL, nB, nR, nW, i, cLine, cKey, qCursor + IF ::lReadOnly + RETURN Self + ENDIF + hbide_normalizeRect( aCord, @nT, @nL, @nB, @nR ) nW := nR - nL @@ -913,6 +922,10 @@ METHOD IdeEdit:insertBlockContents( aCord ) METHOD IdeEdit:deleteBlockContents( aCord ) LOCAL nT, nL, nB, nR, nW, i, cLine, qCursor, k, nSelMode + IF ::lReadOnly + RETURN Self + ENDIF + hbide_normalizeRect( aCord, @nT, @nL, @nB, @nR ) k := aCord[ 7 ] k := iif( empty( k ), Qt_Key_X, k ) @@ -921,7 +934,7 @@ METHOD IdeEdit:deleteBlockContents( aCord ) ENDIF nSelMode := aCord[ 5 ] -//HB_TRACE( HB_TR_ALWAYS, nT, nL, nB, nR, nSelMode ) + qCursor := QTextCursor():from( ::qEdit:textCursor() ) qCursor:beginEditBlock() @@ -976,6 +989,10 @@ METHOD IdeEdit:blockComment() LOCAL cComment := "// " LOCAL nLen := len( cComment ) + IF ::lReadOnly + RETURN Self + ENDIF + ::qEdit:hbGetSelectionInfo(); aCord := ::aSelectionInfo hbide_normalizeRect( aCord, @nT, @nL, @nB, @nR ) nW := nR - nL @@ -1017,6 +1034,10 @@ METHOD IdeEdit:blockComment() METHOD IdeEdit:streamComment() LOCAL nT, nL, nB, nR, nW, i, cLine, qCursor, aCord, nMode, q_ + IF ::lReadOnly + RETURN Self + ENDIF + ::qEdit:hbGetSelectionInfo(); aCord := ::aSelectionInfo hbide_normalizeRect( aCord, @nT, @nL, @nB, @nR ) @@ -1059,6 +1080,10 @@ METHOD IdeEdit:streamComment() METHOD IdeEdit:blockIndent( nDirctn ) LOCAL nT, nL, nB, nR, nW, i, cLine, qCursor, aCord, q_, nMode, cLineSel + IF ::lReadOnly + RETURN Self + ENDIF + ::qEdit:hbGetSelectionInfo(); aCord := ::aSelectionInfo hbide_normalizeRect( aCord, @nT, @nL, @nB, @nR ) nW := nR - nL @@ -1106,6 +1131,10 @@ METHOD IdeEdit:blockIndent( nDirctn ) METHOD IdeEdit:blockConvert( cMode ) LOCAL nT, nL, nB, nR, nW, i, cLine, qCursor, aCord, q_, nMode + IF ::lReadOnly + RETURN Self + ENDIF + ::qEdit:hbGetSelectionInfo(); aCord := ::aSelectionInfo hbide_normalizeRect( aCord, @nT, @nL, @nB, @nR ) nW := nR - nL @@ -1276,6 +1305,9 @@ METHOD IdeEdit:undo() /*----------------------------------------------------------------------*/ METHOD IdeEdit:cut() + IF ::lReadOnly + RETURN Self + ENDIF ::qEdit:hbCut( Qt_Key_X ) RETURN Self @@ -1288,6 +1320,9 @@ METHOD IdeEdit:copy() /*----------------------------------------------------------------------*/ METHOD IdeEdit:paste() + IF ::lReadOnly + RETURN Self + ENDIF ::qEdit:hbPaste() RETURN Self @@ -1299,8 +1334,16 @@ METHOD IdeEdit:selectAll() /*----------------------------------------------------------------------*/ -METHOD IdeEdit:setReadOnly() - ::qEdit:setReadOnly( .t. ) // ! ::qEdit:isReadOnly() ) +METHOD IdeEdit:setReadOnly( lReadOnly ) + IF ::oEditor:lReadOnly + lReadOnly := .t. + ELSE + IF ! hb_isLogical( lReadOnly ) + lReadOnly := ! ::qEdit:isReadOnly() + ENDIF + ENDIF + ::lReadOnly := lReadOnly + ::qEdit:setReadOnly( lReadOnly ) ::oEditor:setTabImage() RETURN Self diff --git a/harbour/contrib/hbide/ideeditor.prg b/harbour/contrib/hbide/ideeditor.prg index 803c13259f..7c3f353aa1 100644 --- a/harbour/contrib/hbide/ideeditor.prg +++ b/harbour/contrib/hbide/ideeditor.prg @@ -1021,6 +1021,7 @@ CLASS IdeEditor INHERIT IdeObject DATA nnRow INIT -99 DATA qEvents + DATA lReadOnly INIT .F. METHOD new( oIde, cSourceFile, nPos, nHPos, nVPos, cTheme, cView ) METHOD create( oIde, cSourceFile, nPos, nHPos, nVPos, cTheme, cView, aBookMarks ) @@ -1064,7 +1065,7 @@ METHOD IdeEditor:new( oIde, cSourceFile, nPos, nHPos, nVPos, cTheme, cView ) /*----------------------------------------------------------------------*/ METHOD IdeEditor:create( oIde, cSourceFile, nPos, nHPos, nVPos, cTheme, cView, aBookMarks ) - LOCAL cFileTemp + LOCAL cFileTemp, nAttr DEFAULT oIde TO ::oIde DEFAULT cSourceFile TO ::sourceFile @@ -1098,6 +1099,9 @@ METHOD IdeEditor:create( oIde, cSourceFile, nPos, nHPos, nVPos, cTheme, cView, a ferase( cFileTemp ) ENDIF ENDIF + IF hb_fGetAttr( cSourceFile, @nAttr ) + ::lReadOnly := ( nAttr == 33 ) + ENDIF ::cType := upper( strtran( ::cExt, ".", "" ) ) ::cType := iif( ::cType $ "PRG,C,CPP,H,CH,PPO", ::cType, "U" ) @@ -1136,6 +1140,10 @@ METHOD IdeEditor:create( oIde, cSourceFile, nPos, nHPos, nVPos, cTheme, cView, a ::oEM:addSourceInTree( ::sourceFile, ::cView ) ::qTabWidget:setStyleSheet( GetStyleSheet( "QTabWidget", ::nAnimantionMode ) ) + IF ::lReadOnly + ::oEdit:setReadOnly( .t. ) + ::qEdit:setTextInteractionFlags( Qt_TextSelectableByMouse + Qt_TextSelectableByKeyboard ) + ENDIF ::setTabImage() RETURN Self @@ -1214,7 +1222,8 @@ METHOD IdeEditor:setDocumentProperties() QTextDocument():configure( ::qEdit:document() ):setModified( .f. ) - ::qTabWidget:setTabIcon( ::qTabWidget:indexOf( ::oTab:oWidget ), ::resPath + "tabunmodified.png" ) + ::qTabWidget:setTabIcon( ::qTabWidget:indexOf( ::oTab:oWidget ), ; + hbide_image( iif( ::lReadOnly, "tabreadonly", "tabunmodified" ) ) ) ::lLoaded := .T. IF ::cType $ "PRG,C,CPP,H,CH" @@ -1387,17 +1396,19 @@ METHOD IdeEditor:setTabImage( qEdit ) nIndex := ::qTabWidget:indexOf( ::oTab:oWidget ) lModified := ::qDocument:isModified() - lReadOnly := qEdit:isReadOnly() + lReadOnly := iif( ::lReadOnly, ::lReadOnly, qEdit:isReadOnly() ) - IF lModified - cIcon := "tabmodified.png" - ELSEIF lReadOnly - cIcon := "tabreadonly.png" + IF lReadOnly + cIcon := "tabreadonly" ELSE - cIcon := "tabunmodified.png" + IF lModified + cIcon := "tabmodified" + ELSE + cIcon := "tabunmodified" + ENDIF ENDIF - ::qTabWidget:setTabIcon( nIndex, ::resPath + cIcon ) + ::qTabWidget:setTabIcon( nIndex, hbide_image( cIcon ) ) ::oDK:setStatusText( SB_PNL_MODIFIED, iif( lModified, "Modified", iif( lReadOnly, "ReadOnly", " " ) ) ) RETURN Self diff --git a/harbour/contrib/hbide/resources/tabreadonly.png b/harbour/contrib/hbide/resources/tabreadonly.png index 1d215a8abfec38ceaf949837b46989badd6bd73c..2fa075bf3e6ee6a2545355c15d9b43b1dcdc3f6d 100644 GIT binary patch literal 118 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`ww^AIAr-fhQx*sq^hq_`Zupc(WTQ2UV9u06&@M2EXhz|<=Ml?(6vQG(5%Oy Q1!xe1r>mdKI;Vst0N1=Fx&QzG literal 2940 zcmV-?3xo8DP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^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