startcenter: Hide template toggle button if no templates

Change-Id: I9c6f2058e67990156a4be928449c6ebe6614e486
Reviewed-on: https://gerrit.libreoffice.org/5913
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Krisztian Pinter 2013-09-11 17:34:09 +02:00 committed by Caolán McNamara
parent f3123d396c
commit eacbdd0e97
3 changed files with 30 additions and 4 deletions

View File

@ -37,6 +37,8 @@ public:
// Fill view with template folders thumbnails
virtual void Populate ();
bool HasUnfilteredItems(FILTER_APPLICATION App);
virtual void reload ();
virtual void showRootRegion ();

View File

@ -59,6 +59,22 @@ TemplateLocalView::~TemplateLocalView()
delete mpDocTemplates;
}
bool TemplateLocalView::HasUnfilteredItems(FILTER_APPLICATION App)
{
ViewFilter_Application aFilter(App);
bool bFound = false;
for (size_t i = 0; !bFound && i < maRegions.size(); ++i)
{
TemplateContainerItem *pFolderItem = maRegions[i];
for (size_t j = 0; !bFound && j < pFolderItem->maTemplates.size(); ++j)
{
bFound = aFilter.isValid(pFolderItem->maTemplates[j].aPath);
}
}
return bFound;
}
void TemplateLocalView::Populate ()
{
for (size_t i = 0; i < maRegions.size(); ++i)

View File

@ -369,11 +369,19 @@ void BackingWindow::setupTemplateView( TemplateLocalView* pView, FILTER_APPLICAT
pView->showRootRegion();
pView->setOpenTemplateHdl( LINK( this, BackingWindow, OpenTemplateHdl ) );
// setup buttons
pRecentButton->SetClickHdl( LINK( this, BackingWindow, RecentTemplateToggleHdl ) );
pTemplateButton->SetClickHdl( LINK( this, BackingWindow, RecentTemplateToggleHdl ) );
if( pView->HasUnfilteredItems(eFilter) )
{
// setup buttons
pRecentButton->SetClickHdl( LINK( this, BackingWindow, RecentTemplateToggleHdl ) );
pTemplateButton->SetClickHdl( LINK( this, BackingWindow, RecentTemplateToggleHdl ) );
pRecentButton->Hide(); // hidden by default
pRecentButton->Hide(); // hidden by default
}
else // no templates, hide toggle button
{
pTemplateButton->Hide();
pRecentButton->Hide();
}
}
void BackingWindow::Paint( const Rectangle& )
{