Tag: cws_dev300_dba31c
User: fs      
Date: 2008-09-03 12:01:12+0000
Modified:
   dba/dbaccess/source/ui/control/dbtreelistbox.cxx

Log:
 #i93424# reworked the handling/notification of selection/changes

File Changes:

Directory: /dba/dbaccess/source/ui/control/
===========================================

File [changed]: dbtreelistbox.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/control/dbtreelistbox.cxx?r1=1.20.40.1&r2=1.20.40.2
Delta lines:  +42 -70
---------------------
--- dbtreelistbox.cxx   2008-09-03 11:56:15+0000        1.20.40.1
+++ dbtreelistbox.cxx   2008-09-03 12:01:10+0000        1.20.40.2
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: dbtreelistbox.cxx,v $
- * $Revision: 1.20.40.1 $
+ * $Revision: 1.20.40.2 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -104,11 +104,9 @@
 //------------------------------------------------------------------------
 DBTreeListBox::DBTreeListBox( Window* pParent, const Reference< 
XMultiServiceFactory >& _rxORB, WinBits nWinStyle ,sal_Bool _bHandleEnterKey)
        :SvTreeListBox(pParent,nWinStyle)
-       ,m_pSelectedEntry(NULL)
        ,m_pDragedEntry(NULL)
        ,m_pActionListener(NULL)
        ,m_pContextMenuProvider( NULL )
-    ,m_nSelectLock(0)
        ,m_bHandleEnterKey(_bHandleEnterKey)
        ,m_xORB(_rxORB)
 {
@@ -118,11 +116,9 @@
 // 
-----------------------------------------------------------------------------
 DBTreeListBox::DBTreeListBox( Window* pParent, const Reference< 
XMultiServiceFactory >& _rxORB, const ResId& rResId,sal_Bool _bHandleEnterKey)
        :SvTreeListBox(pParent,rResId)
-       ,m_pSelectedEntry(NULL)
        ,m_pDragedEntry(NULL)
        ,m_pActionListener(NULL)
        ,m_pContextMenuProvider( NULL )
-       ,m_nSelectLock(0)
        ,m_bHandleEnterKey(_bHandleEnterKey)
        ,m_xORB(_rxORB)
 {
@@ -149,8 +145,7 @@
 DBTreeListBox::~DBTreeListBox()
 {
        DBG_DTOR(DBTreeListBox,NULL);
-       if(m_aTimer.IsActive())
-               m_aTimer.Stop();        
+    implStopSelectionTimer();
 }
 //------------------------------------------------------------------------
 SvLBoxEntry* DBTreeListBox::GetEntryPosByName( const String& aName, 
SvLBoxEntry* pStart, const IEntryFilter* _pFilter ) const
@@ -200,20 +195,6 @@
 }
 
 // -------------------------------------------------------------------------
-void DBTreeListBox::SelectEntry(SvLBoxEntry* _pEntry)
-{
-       OSL_ENSURE(_pEntry,"Who called me with NULL!");
-       if ( _pEntry )
-       {
-               if ( GetCurEntry() )
-                       Select(GetCurEntry(), sal_False);
-               Select(_pEntry, sal_True);
-               SetCurEntry(_pEntry);
-               implSelected(_pEntry);
-       }
-}
-
-// -------------------------------------------------------------------------
 void DBTreeListBox::InitEntry( SvLBoxEntry* _pEntry, const XubString& aStr, 
const Image& _rCollEntryBmp, const Image& _rExpEntryBmp, SvLBoxButtonKind 
eButtonKind)
 {
        SvTreeListBox::InitEntry( _pEntry, aStr, _rCollEntryBmp,_rExpEntryBmp, 
eButtonKind);
@@ -223,40 +204,33 @@
 }
 
 // -------------------------------------------------------------------------
-void DBTreeListBox::implSelected(SvLBoxEntry* _pSelected)
+void DBTreeListBox::implStopSelectionTimer()
 {
-       if(!m_nSelectLock && _pSelected && m_pSelectedEntry != _pSelected)
-       {
-               // re-start the timer
-               if(m_aTimer.IsActive())
+       if ( m_aTimer.IsActive() )
                        m_aTimer.Stop();
-               m_pSelectedEntry = _pSelected;
-               m_aTimer.Start();
-       }
 }
 
 // -------------------------------------------------------------------------
-sal_Int32 DBTreeListBox::lockAutoSelect()
+void DBTreeListBox::implStartSelectionTimer()
 {
-       return ++m_nSelectLock;
+    implStopSelectionTimer();
+       m_aTimer.Start();
 }
 
-// -------------------------------------------------------------------------
-sal_Int32 DBTreeListBox::unlockAutoSelect()
-{
-       DBG_ASSERT(m_nSelectLock, "DBTreeListBox::unlockAutoSelect: not 
locked!");
-       return --m_nSelectLock;
-}
 // 
-----------------------------------------------------------------------------
 
 void DBTreeListBox::DeselectHdl()
 {
+    m_aSelectedEntries.erase( GetHdlEntry() );
        SvTreeListBox::DeselectHdl();
+       implStartSelectionTimer();
 }
 // -------------------------------------------------------------------------
 void DBTreeListBox::SelectHdl()
 {
-       implSelected(GetHdlEntry());
+    m_aSelectedEntries.insert( GetHdlEntry() );
+    SvTreeListBox::SelectHdl();
+       implStartSelectionTimer();
 }
 
 // -------------------------------------------------------------------------
@@ -281,15 +255,16 @@
 // 
-----------------------------------------------------------------------------
 void DBTreeListBox::ModelHasEntryInvalidated( SvListEntry* _pEntry )
 {
-       SvTreeListBox::ModelHasEntryInvalidated(_pEntry);
-       if ( _pEntry == m_pSelectedEntry && m_pSelectedEntry )
+       SvTreeListBox::ModelHasEntryInvalidated( _pEntry );
+
+    if ( m_aSelectedEntries.find( _pEntry ) != m_aSelectedEntries.end() )
        {
-               SvLBoxItem* pTextItem = 
m_pSelectedEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING);
-               if ( pTextItem && 
!static_cast<OBoldListboxString*>(pTextItem)->isEmphasized() )
+               SvLBoxItem* pTextItem = static_cast< SvLBoxEntry* >( _pEntry 
)->GetFirstItem( SV_ITEM_ID_BOLDLBSTRING );
+               if ( pTextItem && !static_cast< OBoldListboxString* >( 
pTextItem )->isEmphasized() )
                {
-                       if(m_aTimer.IsActive())
-                               m_aTimer.Stop();
-                       m_pSelectedEntry = NULL;
+            implStopSelectionTimer();
+            m_aSelectedEntries.erase( _pEntry );
+                // ehm - why?
                }
        }
 }
@@ -297,11 +272,10 @@
 void DBTreeListBox::ModelHasRemoved( SvListEntry* _pEntry )
 {
        SvTreeListBox::ModelHasRemoved(_pEntry);
-       if (_pEntry == m_pSelectedEntry)
+    if ( m_aSelectedEntries.find( _pEntry ) != m_aSelectedEntries.end() )
        {
-               if(m_aTimer.IsActive())
-                       m_aTimer.Stop();
-               m_pSelectedEntry = NULL;
+        implStopSelectionTimer();
+        m_aSelectedEntries.erase( _pEntry );
        }
 }
 
@@ -364,7 +338,7 @@
                if ( m_pDragedEntry && m_pActionListener->requestDrag( 
_nAction, _rPosPixel ) )
                {
                        // if the (asynchronous) drag started, stop the 
selection timer
-                       m_aTimer.Stop();
+            implStopSelectionTimer();
                        // and stop selecting entries by simply moving the mouse
                        EndSelection();
                }
@@ -414,24 +388,24 @@
                switch(eFunc)
                {
                        case KEYFUNC_CUT:
-                bHandled = (m_aCutHandler.IsSet() && m_pSelectedEntry);
+                bHandled = ( m_aCutHandler.IsSet() && 
!m_aSelectedEntries.empty() );
                                if ( bHandled )
-                                       m_aCutHandler.Call(m_pSelectedEntry);
+                                       m_aCutHandler.Call( NULL );
                                break;
                        case KEYFUNC_COPY:
-                bHandled = (m_aCopyHandler.IsSet() && m_pSelectedEntry);
+                bHandled = ( m_aCopyHandler.IsSet() && 
!m_aSelectedEntries.empty() );
                                if ( bHandled )
-                                       m_aCopyHandler.Call(m_pSelectedEntry);
+                                       m_aCopyHandler.Call( NULL );
                                break;
                        case KEYFUNC_PASTE:
-                bHandled = (m_aPasteHandler.IsSet() && m_pSelectedEntry);
+                bHandled = ( m_aPasteHandler.IsSet() && 
!m_aSelectedEntries.empty() );
                                if ( bHandled )
-                                       m_aPasteHandler.Call(m_pSelectedEntry);
+                                       m_aPasteHandler.Call( NULL );
                                break;
                        case KEYFUNC_DELETE:
-                bHandled = (m_aDeleteHandler.IsSet() && m_pSelectedEntry);
+                bHandled = ( m_aDeleteHandler.IsSet() && 
!m_aSelectedEntries.empty() );
                                if ( bHandled )
-                                       m_aDeleteHandler.Call(m_pSelectedEntry);
+                                       m_aDeleteHandler.Call( NULL );
                                break;
             default:
                 break;
@@ -480,9 +454,8 @@
        aEntry.aNewText  =rNewText;
        if(m_aEditedHandler.Call(&aEntry) != 0)
        {
-               if(m_aTimer.IsActive())
-                       m_aTimer.Stop();
-               m_pSelectedEntry = NULL; // to force that the renamed selection 
will be reselected
+        implStopSelectionTimer();
+        m_aSelectedEntries.erase( pEntry );
        }
        SetEntryText(pEntry,aEntry.aNewText);
        
@@ -730,24 +703,23 @@
 // 
-----------------------------------------------------------------------------
 void DBTreeListBox::ExcecuteContextMenuAction( USHORT _nSelectedPopupEntry )
 {
-       if ( m_pContextMenuProvider )
+       if ( m_pContextMenuProvider && _nSelectedPopupEntry )
                m_pContextMenuProvider->getCommandController().executeChecked( 
_nSelectedPopupEntry, Sequence< PropertyValue >() );
 }
 
 // 
-----------------------------------------------------------------------------
 IMPL_LINK(DBTreeListBox, OnTimeOut, void*, /*EMPTY_ARG*/)
 {
-       if(m_aTimer.IsActive())
-               m_aTimer.Stop();
-       if (m_pSelectedEntry)
-               aSelectHdl.Call( m_pSelectedEntry );    
+    implStopSelectionTimer();
+
+    m_aSelChangeHdl.Call( NULL );      
        return 0L;
 }
 // 
-----------------------------------------------------------------------------
 void DBTreeListBox::StateChanged( StateChangedType nStateChange )
 {
-    if ( nStateChange == STATE_CHANGE_VISIBLE && m_aTimer.IsActive() )
-           m_aTimer.Stop();
+    if ( nStateChange == STATE_CHANGE_VISIBLE )
+        implStopSelectionTimer();
 }
 // .........................................................................
 }      // namespace dbaui




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to