You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
174 lines
5.9 KiB
174 lines
5.9 KiB
15 years ago
|
/*
|
||
|
This file is part of libkcal.
|
||
|
|
||
|
Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org>
|
||
|
Copyright (c) 2004 Till Adam <adam@kde.org>
|
||
|
Copyright (c) 2005 Reinhold Kainhofer <reinhold@kainhofer.com>
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License as published by the Free Software Foundation; either
|
||
|
version 2 of the License, or (at your option) any later version.
|
||
|
|
||
|
This library is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
|
#include "folderconfig.h"
|
||
|
|
||
|
#include "folderlister.h"
|
||
|
#include "groupwaredataadaptor.h"
|
||
|
#include "folderlistview.h"
|
||
|
|
||
|
#include <klistview.h>
|
||
|
#include <klocale.h>
|
||
|
#include <kdebug.h>
|
||
|
#include <kdialog.h>
|
||
|
|
||
13 years ago
|
#include <tqlayout.h>
|
||
15 years ago
|
#include <tqgroupbox.h>
|
||
|
#include <tqpushbutton.h>
|
||
|
#include <tqcombobox.h>
|
||
|
#include <tqhbox.h>
|
||
|
#include <tqlabel.h>
|
||
15 years ago
|
|
||
|
using namespace KPIM;
|
||
|
|
||
13 years ago
|
FolderConfig::FolderConfig( TQWidget *parent )
|
||
|
: TQWidget( parent ), mFolderLister( 0 )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQBoxLayout *topLayout = new TQVBoxLayout( this );
|
||
15 years ago
|
topLayout->addSpacing( KDialog::spacingHint() );
|
||
|
|
||
14 years ago
|
TQGroupBox *topBox = new TQGroupBox( 1, Qt::Horizontal, i18n("Folder Selection"),
|
||
15 years ago
|
this );
|
||
|
topLayout->addWidget( topBox );
|
||
|
|
||
15 years ago
|
TQPushButton *button = new TQPushButton( i18n("Update Folder List"), topBox );
|
||
|
connect( button, TQT_SIGNAL( clicked() ), TQT_SIGNAL( updateFoldersClicked() ) );
|
||
15 years ago
|
|
||
|
mFolderList = new FolderListView( topBox );
|
||
|
|
||
15 years ago
|
/* TQHBox *writeBox = new TQHBox( topBox );
|
||
15 years ago
|
|
||
15 years ago
|
new TQLabel( i18n("Write to:"), writeBox );
|
||
15 years ago
|
|
||
15 years ago
|
mWriteCombo = new TQComboBox( writeBox );*/
|
||
15 years ago
|
}
|
||
|
|
||
|
FolderConfig::~FolderConfig()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
void FolderConfig::setFolderLister( FolderLister *f )
|
||
|
{
|
||
|
mFolderLister = f;
|
||
|
|
||
15 years ago
|
TQValueList<FolderListView::Property> types;
|
||
|
TQValueList<FolderLister::ContentType> suptypes( mFolderLister->supportedTypes() );
|
||
13 years ago
|
if ( suptypes.contains( FolderLister::Event ) ) types << FolderListView::Event;
|
||
|
if ( suptypes.contains( FolderLister::Todo ) ) types << FolderListView::Todo;
|
||
|
if ( suptypes.contains( FolderLister::Journal ) ) types << FolderListView::Journal;
|
||
|
if ( suptypes.contains( FolderLister::Contact ) ) types << FolderListView::Contact;
|
||
|
if ( suptypes.contains( FolderLister::All ) ) types << FolderListView::All;
|
||
|
if ( suptypes.contains( FolderLister::Unknown ) ) types << FolderListView::Unknown;
|
||
15 years ago
|
|
||
|
mFolderList->setEnabledTypes( types );
|
||
15 years ago
|
connect( mFolderLister, TQT_SIGNAL( foldersRead() ), TQT_SLOT( updateFolderList() ) );
|
||
15 years ago
|
}
|
||
|
|
||
|
void FolderConfig::retrieveFolderList( const KURL &url )
|
||
|
{
|
||
|
kdDebug(7000) << "FolderConfig::retrieveFolderList()" << endl;
|
||
|
if ( !mOldFolderListerURL.isEmpty() ) return;
|
||
|
|
||
|
if ( mFolderLister->adaptor() ) {
|
||
|
mOldFolderListerURL = mFolderLister->adaptor()->baseURL();
|
||
|
mFolderLister->adaptor()->setBaseURL( url );
|
||
|
}
|
||
|
mFolderLister->retrieveFolders( url );
|
||
|
}
|
||
|
|
||
|
void FolderConfig::updateFolderList()
|
||
|
{
|
||
|
mFolderList->clear();
|
||
|
|
||
15 years ago
|
TQStringList write;
|
||
15 years ago
|
|
||
|
if ( !mOldFolderListerURL.isEmpty() && mFolderLister->adaptor() ) {
|
||
|
mFolderLister->adaptor()->setBaseURL( mOldFolderListerURL );
|
||
|
mOldFolderListerURL = KURL();
|
||
|
}
|
||
|
|
||
|
FolderLister::Entry::List folders = mFolderLister->folders();
|
||
|
FolderLister::Entry::List::ConstIterator it;
|
||
|
for( it = folders.begin(); it != folders.end(); ++it ) {
|
||
|
FolderListItem *item = new FolderListItem( mFolderList, (*it) );
|
||
|
if ( mFolderLister->writeDestinationId( FolderLister::Event ) == (*it).id ) {
|
||
|
item->setDefault( FolderListView::Event );
|
||
|
}
|
||
|
if ( mFolderLister->writeDestinationId( FolderLister::Todo ) == (*it).id ) {
|
||
|
item->setDefault( FolderListView::Todo );
|
||
|
}
|
||
|
if ( mFolderLister->writeDestinationId( FolderLister::Journal ) == (*it).id ) {
|
||
|
item->setDefault( FolderListView::Journal );
|
||
|
}
|
||
|
if ( mFolderLister->writeDestinationId( FolderLister::Contact ) == (*it).id ) {
|
||
|
item->setDefault( FolderListView::Contact );
|
||
|
}
|
||
|
if ( mFolderLister->writeDestinationId( FolderLister::All ) == (*it).id ) {
|
||
|
item->setDefault( FolderListView::All );
|
||
|
}
|
||
|
if ( mFolderLister->writeDestinationId( FolderLister::Unknown ) == (*it).id ) {
|
||
|
item->setDefault( FolderListView::Unknown );
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void FolderConfig::saveSettings()
|
||
|
{
|
||
15 years ago
|
TQPtrList<TQListViewItem> lst;
|
||
15 years ago
|
|
||
|
FolderLister::Entry::List folders;
|
||
|
|
||
15 years ago
|
TQListViewItemIterator it( mFolderList );
|
||
15 years ago
|
while ( it.current() ) {
|
||
|
FolderListItem *item = dynamic_cast<FolderListItem *>( it.current() );
|
||
|
if ( item ) {
|
||
|
FolderLister::Entry folder = item->folder();
|
||
|
folder.active = item->isOn();
|
||
|
folders.append( folder );
|
||
|
if ( item->isDefault( FolderListView::Event ) ) {
|
||
|
mFolderLister->setWriteDestinationId( FolderLister::Event, folder.id );
|
||
|
}
|
||
|
if ( item->isDefault( FolderListView::Todo ) ) {
|
||
|
mFolderLister->setWriteDestinationId( FolderLister::Todo, folder.id );
|
||
|
}
|
||
|
if ( item->isDefault( FolderListView::Journal ) ) {
|
||
|
mFolderLister->setWriteDestinationId( FolderLister::Journal, folder.id );
|
||
|
}
|
||
|
if ( item->isDefault( FolderListView::Contact ) ) {
|
||
|
mFolderLister->setWriteDestinationId( FolderLister::Contact, folder.id );
|
||
|
}
|
||
|
if ( item->isDefault( FolderListView::All ) ) {
|
||
|
mFolderLister->setWriteDestinationId( FolderLister::All, folder.id );
|
||
|
}
|
||
|
if ( item->isDefault( FolderListView::Unknown ) ) {
|
||
|
mFolderLister->setWriteDestinationId( FolderLister::Unknown, folder.id );
|
||
|
}
|
||
|
}
|
||
|
++it;
|
||
|
}
|
||
|
|
||
|
mFolderLister->setFolders( folders );
|
||
|
}
|
||
|
|
||
|
#include "folderconfig.moc"
|