-rw-r--r-- | kabc/addresseedialog.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/kabc/addresseedialog.cpp b/kabc/addresseedialog.cpp index b3429e3..648e780 100644 --- a/kabc/addresseedialog.cpp +++ b/kabc/addresseedialog.cpp | |||
@@ -35,64 +35,65 @@ | |||
35 | #include "addresseedialog.h" | 35 | #include "addresseedialog.h" |
36 | #include "KDGanttMinimizeSplitter.h" | 36 | #include "KDGanttMinimizeSplitter.h" |
37 | //#include "addresseedialog.moc" | 37 | //#include "addresseedialog.moc" |
38 | 38 | ||
39 | using namespace KABC; | 39 | using namespace KABC; |
40 | 40 | ||
41 | AddresseeItem::AddresseeItem( QListView *parent, const Addressee &addressee ) : | 41 | AddresseeItem::AddresseeItem( QListView *parent, const Addressee &addressee ) : |
42 | QListViewItem( parent ), | 42 | QListViewItem( parent ), |
43 | mAddressee( addressee ) | 43 | mAddressee( addressee ) |
44 | { | 44 | { |
45 | QString name = addressee.familyName()+", "+ addressee.givenName(); | 45 | QString name = addressee.familyName()+", "+ addressee.givenName(); |
46 | if ( name.length() == 2 ) | 46 | if ( name.length() == 2 ) |
47 | name = addressee.organization(); | 47 | name = addressee.organization(); |
48 | setText( Name,name); | 48 | setText( Name,name); |
49 | setText( Email, addressee.preferredEmail() ); | 49 | setText( Email, addressee.preferredEmail() ); |
50 | } | 50 | } |
51 | 51 | ||
52 | QString AddresseeItem::key( int column, bool ) const | 52 | QString AddresseeItem::key( int column, bool ) const |
53 | { | 53 | { |
54 | 54 | ||
55 | if (column == Email) { | 55 | if (column == Email) { |
56 | QString value = text(Email); | 56 | QString value = text(Email); |
57 | int val = value.findRev("@"); | 57 | int val = value.findRev("@"); |
58 | return value.mid( val) + value.left( val ); | 58 | return value.mid( val) + value.left( val ); |
59 | } | 59 | } |
60 | return text(column).lower(); | 60 | return text(column).lower(); |
61 | } | 61 | } |
62 | 62 | ||
63 | AddresseeDialog::AddresseeDialog( QWidget *parent, bool multiple ) : | 63 | AddresseeDialog::AddresseeDialog( QWidget *parent, bool multiple ) : |
64 | KDialogBase( KDialogBase::Plain, i18n("Select Addressee"), | 64 | KDialogBase( KDialogBase::Plain, i18n("Select Addressee"), |
65 | Ok|Cancel, No, parent ), mMultiple( multiple ) | 65 | Ok|Cancel, No, parent ), mMultiple( multiple ) |
66 | { | 66 | { |
67 | qDebug("NEW AddresseeDialog "); | ||
67 | QWidget *topWidget = plainPage(); | 68 | QWidget *topWidget = plainPage(); |
68 | 69 | ||
69 | QBoxLayout *topLayout = new QHBoxLayout( topWidget ); | 70 | QBoxLayout *topLayout = new QHBoxLayout( topWidget ); |
70 | 71 | ||
71 | 72 | ||
72 | KDGanttMinimizeSplitter* mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, topWidget); | 73 | KDGanttMinimizeSplitter* mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, topWidget); |
73 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 74 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
74 | 75 | ||
75 | topLayout->addWidget(mMiniSplitter ); | 76 | topLayout->addWidget(mMiniSplitter ); |
76 | 77 | ||
77 | QWidget *listWidget = new QWidget( mMiniSplitter ); | 78 | QWidget *listWidget = new QWidget( mMiniSplitter ); |
78 | 79 | ||
79 | QBoxLayout *listLayout = new QVBoxLayout (listWidget) ; | 80 | QBoxLayout *listLayout = new QVBoxLayout (listWidget) ; |
80 | //topLayout->addLayout( listLayout ); | 81 | //topLayout->addLayout( listLayout ); |
81 | 82 | ||
82 | mAddresseeList = new KListView( listWidget ); | 83 | mAddresseeList = new KListView( listWidget ); |
83 | mAddresseeList->addColumn( i18n("Name") ); | 84 | mAddresseeList->addColumn( i18n("Name") ); |
84 | mAddresseeList->addColumn( i18n("Email") ); | 85 | mAddresseeList->addColumn( i18n("Email") ); |
85 | mAddresseeList->setAllColumnsShowFocus( true ); | 86 | mAddresseeList->setAllColumnsShowFocus( true ); |
86 | mAddresseeList->setFullWidth( true ); | 87 | mAddresseeList->setFullWidth( true ); |
87 | listLayout->addWidget( mAddresseeList ); | 88 | listLayout->addWidget( mAddresseeList ); |
88 | connect( mAddresseeList, SIGNAL( doubleClicked( QListViewItem * ) ), | 89 | connect( mAddresseeList, SIGNAL( doubleClicked( QListViewItem * ) ), |
89 | SLOT( slotOk() ) ); | 90 | SLOT( slotOk() ) ); |
90 | 91 | ||
91 | mAddresseeEdit = new QLineEdit( listWidget ); | 92 | mAddresseeEdit = new QLineEdit( listWidget ); |
92 | connect( mAddresseeEdit, SIGNAL( returnPressed() ), | 93 | connect( mAddresseeEdit, SIGNAL( returnPressed() ), |
93 | SLOT( loadAddressBook() ) ); | 94 | SLOT( loadAddressBook() ) ); |
94 | mAddresseeEdit->setFocus(); | 95 | mAddresseeEdit->setFocus(); |
95 | 96 | ||
96 | listLayout->addWidget( mAddresseeEdit ); | 97 | listLayout->addWidget( mAddresseeEdit ); |
97 | 98 | ||
98 | if ( mMultiple ) { | 99 | if ( mMultiple ) { |
@@ -108,64 +109,65 @@ AddresseeDialog::AddresseeDialog( QWidget *parent, bool multiple ) : | |||
108 | mSelectedList->addColumn( i18n("Name") ); | 109 | mSelectedList->addColumn( i18n("Name") ); |
109 | mSelectedList->addColumn( i18n("Email") ); | 110 | mSelectedList->addColumn( i18n("Email") ); |
110 | mSelectedList->setAllColumnsShowFocus( true ); | 111 | mSelectedList->setAllColumnsShowFocus( true ); |
111 | mSelectedList->setFullWidth( true ); | 112 | mSelectedList->setFullWidth( true ); |
112 | connect( mSelectedList, SIGNAL( doubleClicked( QListViewItem * ) ), | 113 | connect( mSelectedList, SIGNAL( doubleClicked( QListViewItem * ) ), |
113 | SLOT( removeSelected() ) ); | 114 | SLOT( removeSelected() ) ); |
114 | 115 | ||
115 | QPushButton *unselectButton = new QPushButton( i18n("Unselect"), selectedGroup ); | 116 | QPushButton *unselectButton = new QPushButton( i18n("Unselect"), selectedGroup ); |
116 | connect ( unselectButton, SIGNAL( clicked() ), SLOT( removeSelected() ) ); | 117 | connect ( unselectButton, SIGNAL( clicked() ), SLOT( removeSelected() ) ); |
117 | 118 | ||
118 | connect( mAddresseeList, SIGNAL( clicked( QListViewItem * ) ), | 119 | connect( mAddresseeList, SIGNAL( clicked( QListViewItem * ) ), |
119 | SLOT( addSelected( QListViewItem * ) ) ); | 120 | SLOT( addSelected( QListViewItem * ) ) ); |
120 | connect( mAddresseeList, SIGNAL( returnPressed( QListViewItem * ) ), | 121 | connect( mAddresseeList, SIGNAL( returnPressed( QListViewItem * ) ), |
121 | SLOT( selectNextItem( QListViewItem * ) ) ); | 122 | SLOT( selectNextItem( QListViewItem * ) ) ); |
122 | 123 | ||
123 | } | 124 | } |
124 | 125 | ||
125 | mAddressBook = StdAddressBook::self( true ); | 126 | mAddressBook = StdAddressBook::self( true ); |
126 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook* ) ), | 127 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook* ) ), |
127 | SLOT( addressBookChanged() ) ); | 128 | SLOT( addressBookChanged() ) ); |
128 | connect( mAddressBook, SIGNAL( loadingFinished( Resource* ) ), | 129 | connect( mAddressBook, SIGNAL( loadingFinished( Resource* ) ), |
129 | SLOT( addressBookChanged() ) ); | 130 | SLOT( addressBookChanged() ) ); |
130 | 131 | ||
131 | loadAddressBook(); | 132 | loadAddressBook(); |
132 | QValueList<int> splitterSize; | 133 | QValueList<int> splitterSize; |
133 | splitterSize.append( ( width() / 5 ) * 3 ); | 134 | splitterSize.append( ( width() / 5 ) * 3 ); |
134 | splitterSize.append( ( width() / 5 ) *2 ); | 135 | splitterSize.append( ( width() / 5 ) *2 ); |
135 | mMiniSplitter->setSizes( splitterSize ); | 136 | mMiniSplitter->setSizes( splitterSize ); |
136 | } | 137 | } |
137 | 138 | ||
138 | AddresseeDialog::~AddresseeDialog() | 139 | AddresseeDialog::~AddresseeDialog() |
139 | { | 140 | { |
141 | qDebug("DELETE AddresseeDialog "); | ||
140 | } | 142 | } |
141 | 143 | ||
142 | void AddresseeDialog::loadAddressBook() | 144 | void AddresseeDialog::loadAddressBook() |
143 | { | 145 | { |
144 | mAddresseeList->clear(); | 146 | mAddresseeList->clear(); |
145 | mItemDict.clear(); | 147 | mItemDict.clear(); |
146 | if ( mAddresseeEdit->text().isEmpty() ) { | 148 | if ( mAddresseeEdit->text().isEmpty() ) { |
147 | AddressBook::Iterator it; | 149 | AddressBook::Iterator it; |
148 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 150 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
149 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | 151 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) |
150 | continue; | 152 | continue; |
151 | new AddresseeItem( mAddresseeList, (*it) ); | 153 | new AddresseeItem( mAddresseeList, (*it) ); |
152 | } | 154 | } |
153 | return; | 155 | return; |
154 | } | 156 | } |
155 | //mAddresseeEdit->completionObject()->clear(); | 157 | //mAddresseeEdit->completionObject()->clear(); |
156 | QRegExp re; | 158 | QRegExp re; |
157 | re.setWildcard(true); // most people understand these better. | 159 | re.setWildcard(true); // most people understand these better. |
158 | re.setCaseSensitive(false); | 160 | re.setCaseSensitive(false); |
159 | re.setPattern( "*"+ mAddresseeEdit->text() + "*"); | 161 | re.setPattern( "*"+ mAddresseeEdit->text() + "*"); |
160 | 162 | ||
161 | AddressBook::Iterator it; | 163 | AddressBook::Iterator it; |
162 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 164 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
163 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | 165 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) |
164 | continue; | 166 | continue; |
165 | QString name = (*it).familyName()+", "+ (*it).givenName(); | 167 | QString name = (*it).familyName()+", "+ (*it).givenName(); |
166 | if ( name.length() == 2 ) | 168 | if ( name.length() == 2 ) |
167 | name = (*it).realName(); | 169 | name = (*it).realName(); |
168 | name += (*it).preferredEmail(); | 170 | name += (*it).preferredEmail(); |
169 | #if QT_VERSION >= 0x030000 | 171 | #if QT_VERSION >= 0x030000 |
170 | if (re.search(name) != -1) | 172 | if (re.search(name) != -1) |
171 | #else | 173 | #else |