groupview.cpp
00001 /* 00002 This file is part of KitchenSync. 00003 00004 Copyright (c) 2005 Cornelius Schumacher <schumacher@kde.org> 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #include <tqlayout.h> 00022 00023 #include "aboutpage.h" 00024 #include "groupitem.h" 00025 #include "syncprocessmanager.h" 00026 00027 #include "groupview.h" 00028 00029 GroupView::GroupView( TQWidget *parent ) 00030 : TQWidget( parent ), mAboutPage( 0 ) 00031 { 00032 mLayout = new TQVBoxLayout( this ); 00033 00034 mWidgetList = new KWidgetList( this ); 00035 00036 mLayout->addWidget( mWidgetList ); 00037 } 00038 00039 SyncProcess* GroupView::selectedSyncProcess() const 00040 { 00041 GroupItem *item = static_cast<GroupItem*>( mWidgetList->selectedItem() ); 00042 if ( item ) 00043 return item->syncProcess(); 00044 else 00045 return 0; 00046 } 00047 00048 void GroupView::clear() 00049 { 00050 mWidgetList->clear(); 00051 } 00052 00053 void GroupView::updateView() 00054 { 00055 clear(); 00056 00057 if ( SyncProcessManager::self()->count() == 0 ) { 00058 mWidgetList->hide(); 00059 00060 if ( !mAboutPage ) { 00061 mAboutPage = new AboutPage( this ); 00062 mLayout->addWidget( mAboutPage ); 00063 00064 connect( mAboutPage, TQT_SIGNAL( addGroup() ), TQT_SIGNAL( addGroup() ) ); 00065 } 00066 00067 mAboutPage->show(); 00068 00069 } else { 00070 if ( mAboutPage ) 00071 mAboutPage->hide(); 00072 mWidgetList->show(); 00073 } 00074 00075 for ( int i = 0; i < SyncProcessManager::self()->count(); ++i ) { 00076 SyncProcess *process = SyncProcessManager::self()->at( i ); 00077 00078 GroupItem *item = new GroupItem( mWidgetList, process ); 00079 connect( item, TQT_SIGNAL( synchronizeGroup( SyncProcess* ) ), 00080 TQT_SIGNAL( synchronizeGroup( SyncProcess* ) ) ); 00081 connect( item, TQT_SIGNAL( abortSynchronizeGroup( SyncProcess* ) ), 00082 TQT_SIGNAL( abortSynchronizeGroup( SyncProcess* ) ) ); 00083 connect( item, TQT_SIGNAL( configureGroup( SyncProcess* ) ), 00084 TQT_SIGNAL( configureGroup( SyncProcess* ) ) ); 00085 00086 mWidgetList->appendItem( item ); 00087 } 00088 } 00089 00090 void GroupView::updateSyncProcess( SyncProcess *syncProcess ) 00091 { 00092 for ( int i = 0; i < (int)mWidgetList->count(); ++i ) { 00093 GroupItem *item = static_cast<GroupItem*>( mWidgetList->item( i ) ); 00094 if ( item && item->syncProcess() == syncProcess ) 00095 item->update(); 00096 } 00097 } 00098 00099 #include "groupview.moc"