diff options
author | Szymon Kłos <eszkadev@gmail.com> | 2015-06-05 17:40:40 +0200 |
---|---|---|
committer | Szymon Kłos <eszkadev@gmail.com> | 2015-07-16 09:52:47 +0200 |
commit | 9464775a9f4a9368069d928a915bb91c2c447413 (patch) | |
tree | 5f19fb97120eb92da6aa5b58d743d4d55446fe3a | |
parent | e881504669930cdce875b33b80ecff0e17061827 (diff) |
filter select handler
Change-Id: Iec362f7cf6540a5f312a9fdb4898c94433f68a9d
-rw-r--r-- | include/svtools/RemoteFilesDialog.hxx | 7 | ||||
-rw-r--r-- | sfx2/source/appl/appopen.cxx | 6 | ||||
-rw-r--r-- | svtools/source/dialogs/RemoteFilesDialog.cxx | 44 |
3 files changed, 52 insertions, 5 deletions
diff --git a/include/svtools/RemoteFilesDialog.hxx b/include/svtools/RemoteFilesDialog.hxx index aac99ba5bbae..e831a3294045 100644 --- a/include/svtools/RemoteFilesDialog.hxx +++ b/include/svtools/RemoteFilesDialog.hxx @@ -32,6 +32,8 @@ #define WB_MULTISELECTION 0x20000000L +#define FILTER_ALL "*.*" + enum SvtRemoteDlgMode { REMOTEDLG_MODE_OPEN = 0, @@ -58,6 +60,8 @@ public: virtual void dispose() SAL_OVERRIDE; virtual void Resize() SAL_OVERRIDE; + void AddFilter( OUString sName, OUString sType ); + private: ::com::sun::star::uno::Reference < com::sun::star::uno::XComponentContext > m_context; @@ -80,6 +84,7 @@ private: VclPtr<Edit> m_pName_ed; std::vector<ServicePtr> m_aServices; + std::vector<OUString> m_aFilters; void FillServicesListbox(); @@ -98,6 +103,8 @@ private: DECL_LINK( SelectHdl, void * ); DECL_LINK( SplitHdl, void * ); + + DECL_LINK( SelectFilterHdl, void * ); }; #endif // INCLUDED_SVTOOLS_REMOTEFILESDIALOG_HXX diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx index a641ebb51ed6..001ed1b176d3 100644 --- a/sfx2/source/appl/appopen.cxx +++ b/sfx2/source/appl/appopen.cxx @@ -1128,6 +1128,12 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq ) void SfxApplication::OpenRemoteExec_Impl( SfxRequest& ) { ScopedVclPtrInstance< RemoteFilesDialog > aDlg((vcl::Window*)NULL, WB_OPEN); + + // Filters for test purposes + aDlg->AddFilter("All files", FILTER_ALL); + aDlg->AddFilter("ODT files", "*.odt"); + aDlg->AddFilter("ODS files", "*.ods"); + aDlg->Execute(); } diff --git a/svtools/source/dialogs/RemoteFilesDialog.cxx b/svtools/source/dialogs/RemoteFilesDialog.cxx index 5976ea61cbe8..1c32612cad81 100644 --- a/svtools/source/dialogs/RemoteFilesDialog.cxx +++ b/svtools/source/dialogs/RemoteFilesDialog.cxx @@ -11,8 +11,6 @@ using namespace ::com::sun::star::uno; -#define FILTER_ALL "*.*" - class FileViewContainer : public vcl::Window { private: @@ -99,6 +97,11 @@ RemoteFilesDialog::RemoteFilesDialog(vcl::Window* pParent, WinBits nBits) m_bMultiselection = (nBits & WB_MULTISELECTION) ? true : false; m_bIsUpdated = false; + m_pOpen_btn->Enable( false ); + m_pSave_btn->Enable( false ); + m_pFilter_lb->Enable( false ); + m_pName_ed->Enable( false ); + if(m_eMode == REMOTEDLG_MODE_OPEN) { m_pSave_btn->Hide(); @@ -143,6 +146,7 @@ RemoteFilesDialog::RemoteFilesDialog(vcl::Window* pParent, WinBits nBits) m_pContainer->init(m_pFileView, m_pSplitter, m_pTreeView); m_pContainer->Show(); + m_pContainer->Enable( false ); m_pAddService_btn->SetMenuMode(MENUBUTTON_MENUMODE_TIMED); m_pAddService_btn->SetClickHdl( LINK( this, RemoteFilesDialog, AddServiceHdl ) ); @@ -152,8 +156,7 @@ RemoteFilesDialog::RemoteFilesDialog(vcl::Window* pParent, WinBits nBits) m_pServices_lb->SetSelectHdl( LINK( this, RemoteFilesDialog, SelectServiceHdl ) ); - m_pFilter_lb->InsertEntry(FILTER_ALL); - m_pFilter_lb->SelectEntryPos(0); + m_pFilter_lb->SetSelectHdl( LINK( this, RemoteFilesDialog, SelectFilterHdl ) ); } RemoteFilesDialog::~RemoteFilesDialog() @@ -261,11 +264,25 @@ int RemoteFilesDialog::GetSelectedServicePos() return nPos; } +void RemoteFilesDialog::AddFilter( OUString sName, OUString sType ) +{ + m_aFilters.push_back( sType ); + m_pFilter_lb->InsertEntry( sName ); + + if(m_pFilter_lb->GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND) + m_pFilter_lb->SelectEntryPos( 0 ); +} + OUString RemoteFilesDialog::getCurrentFilter() { OUString sFilter; - sFilter = m_pFilter_lb->GetSelectEntry(); + int nPos = m_pFilter_lb->GetSelectEntryPos(); + + if(nPos != LISTBOX_ENTRY_NOTFOUND) + sFilter = m_aFilters[nPos]; + else + sFilter = FILTER_ALL; return sFilter; } @@ -281,6 +298,13 @@ void RemoteFilesDialog::OpenURL( OUString sURL ) m_pFileView->EndInplaceEditing( false ); m_pPath_ed->SetText( sURL ); eResult = m_pFileView->Initialize( sURL, sFilter, NULL, BlackList ); + + if( eResult == eSuccess ) + { + m_pFilter_lb->Enable( true ); + m_pName_ed->Enable( true ); + m_pContainer->Enable( true ); + } } } @@ -430,4 +454,14 @@ IMPL_LINK_NOARG ( RemoteFilesDialog, SplitHdl ) return 1; } +IMPL_LINK_NOARG ( RemoteFilesDialog, SelectFilterHdl ) +{ + OUString sCurrentURL = m_pFileView->GetViewURL(); + + if( !sCurrentURL.isEmpty() ) + OpenURL( sCurrentURL ); + + return 1; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |