1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
//
// C++ Implementation: %{MODULE}
//
// Description:
//
//
// Author: Roie Kerstein <sf_kersteinroie@bezeqint.net>, (C) 2004
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "addbookmarkspreferences.h"
#include "addbookmarksprefsui.h"
#include "addbookmarksplugin.h"
#include <kgenericfactory.h>
#include <kopetepluginmanager.h>
#include <kopetecontactlist.h>
#include <tqcheckbox.h>
#include <tqlayout.h>
#include <tqbuttongroup.h>
#include <tqlistbox.h>
#include <tqnamespace.h>
#include <tqradiobutton.h>
typedef KGenericFactory<BookmarksPreferences> BookmarksPreferencesFactory;
K_EXPORT_COMPONENT_FACTORY( kcm_kopete_addbookmarks, BookmarksPreferencesFactory("kcm_kopete_addbookmarks") )
BookmarksPreferences::BookmarksPreferences(TQWidget *parent, const char *name, const TQStringList &args)
: KCModule(BookmarksPreferencesFactory::instance(), parent, args)
{
Q_UNUSED( name );
( new TQVBoxLayout (this) )->setAutoAdd( true );
p_dialog = new BookmarksPrefsUI( this );
load();
connect( p_dialog->yesButton, TQT_SIGNAL( toggled(bool) ), this, TQT_SLOT( slotSetStatusChanged() ));
connect( p_dialog->noButton, TQT_SIGNAL( toggled(bool) ), this, TQT_SLOT( slotSetStatusChanged() ));
connect( p_dialog->onlySelectedButton, TQT_SIGNAL( toggled(bool) ), this, TQT_SLOT( slotSetStatusChanged() ));
connect( p_dialog->onlyNotSelectedButton, TQT_SIGNAL( toggled(bool) ), this, TQT_SLOT( slotSetStatusChanged() ));
connect( p_dialog->contactList, TQT_SIGNAL( selectionChanged() ), this, TQT_SLOT( slotSetStatusChanged() ));
if(Kopete::PluginManager::self()->plugin("kopete_addbookmarks") )
connect( this, TQT_SIGNAL(PreferencesChanged()), Kopete::PluginManager::self()->plugin("kopete_addbookmarks") , TQT_SLOT(slotReloadSettings()));
connect( p_dialog->m_addUntrusted, TQT_SIGNAL( toggled(bool) ), this, TQT_SLOT( slotAddUntrustedChanged() ) );
}
BookmarksPreferences::~BookmarksPreferences()
{
}
void BookmarksPreferences::save()
{
TQStringList list;
TQStringList::iterator it;
m_settings.setFolderForEachContact( (BookmarksPrefsSettings::UseSubfolders)p_dialog->buttonGroup1->selectedId() );
if ( m_settings.isFolderForEachContact() == BookmarksPrefsSettings::SelectedContacts ||
m_settings.isFolderForEachContact() == BookmarksPrefsSettings::UnselectedContacts ) {
for( uint i = 0; i < p_dialog->contactList->count() ; ++i ){
if( p_dialog->contactList->isSelected( i ) ){
list += p_dialog->contactList->text( i );
}
}
m_settings.setContactsList( list );
}
m_settings.setAddBookmarksFromUnknownContacts( p_dialog->m_addUntrusted->isChecked() );
m_settings.save();
emit PreferencesChanged();
emit KCModule::changed(false);
}
void BookmarksPreferences::slotSetStatusChanged()
{
if ( p_dialog->buttonGroup1->selectedId() == 1 || p_dialog->buttonGroup1->selectedId() == 0)
p_dialog->contactList->setEnabled(false);
else
p_dialog->contactList->setEnabled(true);
emit KCModule::changed(true);
}
void BookmarksPreferences::slotAddUntrustedChanged()
{
emit KCModule::changed(true);
}
void BookmarksPreferences::load()
{
TQStringList list;
TQStringList::iterator it;
TQListBoxItem* item;
m_settings.load();
p_dialog->buttonGroup1->setButton(m_settings.isFolderForEachContact());
p_dialog->m_addUntrusted->setChecked( m_settings.addBookmarksFromUnknownContacts() );
if( p_dialog->contactList->count() == 0 ){
TQStringList contacts = Kopete::ContactList::self()->contacts();
contacts.sort();
p_dialog->contactList->insertStringList( contacts );
}
p_dialog->contactList->clearSelection();
p_dialog->contactList->setEnabled( m_settings.isFolderForEachContact() == BookmarksPrefsSettings::SelectedContacts ||
m_settings.isFolderForEachContact() == BookmarksPrefsSettings::UnselectedContacts );
list = m_settings.getContactsList();
for( it = list.begin() ; it != list.end() ; ++it){
if ( ( item = p_dialog->contactList->findItem(*it, Qt::ExactMatch ) ) ){
p_dialog->contactList->setSelected( item, true );
}
}
emit KCModule::changed(false);
}
#include "addbookmarkspreferences.moc"
|