summaryrefslogtreecommitdiffabout
path: root/kaddressbook/viewmanager.cpp
Side-by-side diff
Diffstat (limited to 'kaddressbook/viewmanager.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/viewmanager.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp
index 59bddd9..9c3a641 100644
--- a/kaddressbook/viewmanager.cpp
+++ b/kaddressbook/viewmanager.cpp
@@ -573,96 +573,105 @@ void ViewManager::doSearch( const QString& s,KABC::Field *field )
void ViewManager::setActiveFilter( int index )
{
Filter currentFilter;
if ( ( index - 1 ) < 0 )
currentFilter = Filter();
else
currentFilter = mFilterList[ index - 1 ];
// Check if we have a view. Since the filter combo is created before
// the view, this slot could be called before there is a valid view.
if ( mActiveView ) {
mActiveView->setFilter( currentFilter );
mActiveView->refresh();
emit selected( QString::null );
}
}
void ViewManager::configureFilters()
{
FilterDialog dlg( this );
dlg.setFilters( mFilterList );
if ( dlg.exec() )
mFilterList = dlg.filters();
uint pos = mActionSelectFilter->currentItem();
mActionSelectFilter->setItems( filterNames() );
mActionSelectFilter->setCurrentItem( pos );
setActiveFilter( pos );
int cw = 150;
if (QApplication::desktop()->width() == 480 )
cw = 0;
mActionSelectFilter->setComboWidth( cw );
saveSettings();
}
QStringList ViewManager::filterNames() const
{
QStringList names( i18n( "No Filter" ) );
Filter::List::ConstIterator it;
for ( it = mFilterList.begin(); it != mFilterList.end(); ++it )
names.append( (*it).name() );
return names;
}
+Filter ViewManager::getFilterByName( const QString &name ) const
+{
+ Filter::List::ConstIterator it;
+ for ( it = mFilterList.begin(); it != mFilterList.end(); ++it )
+ if ( name == (*it).name() )
+ return (*it);
+
+ return Filter();
+}
int ViewManager::filterPosition( const QString &name ) const
{
int pos = 0;
Filter::List::ConstIterator it;
for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos )
if ( name == (*it).name() )
return pos + 1;
return 0;
}
void ViewManager::initActions()
{
//US <ActionList name="view_loadedviews"/>
//US <Separator/>
#ifdef KAB_EMBEDDED
QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu();
QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu();
QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu();
#endif //KAB_EMBEDDED
mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" );
#if KDE_VERSION >= 309
mActionSelectView->setMenuAccelsEnabled( false );
#endif
connect( mActionSelectView, SIGNAL( activated( const QString& ) ),
SLOT( setActiveView( const QString& ) ) );
#ifdef KAB_EMBEDDED
mActionSelectView->plug(viewmenu);
viewmenu->insertSeparator();
#endif //KAB_EMBEDDED
KAction *action;
action = new KAction( i18n( "Modify View..." ), "configure", 0, this,
SLOT( editView() ), mCore->actionCollection(), "view_modify" );
#ifndef KAB_EMBEDDED
action->setWhatsThis( i18n( "By pressing this button a dialog opens that allows you to modify the view of the addressbook. There you can add or remove fields that you want to be shown or hidden in the addressbook like the name for example." ) );
#else //KAB_EMBEDDED
action->plug(viewmenu);
#endif //KAB_EMBEDDED
action = new KAction( i18n( "Add View..." ), "window_new", 0, this,