summaryrefslogtreecommitdiffabout
path: root/kabc
Unidiff
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addresseedialog.cpp40
1 files changed, 28 insertions, 12 deletions
diff --git a/kabc/addresseedialog.cpp b/kabc/addresseedialog.cpp
index 34f4160..b3429e3 100644
--- a/kabc/addresseedialog.cpp
+++ b/kabc/addresseedialog.cpp
@@ -14,32 +14,35 @@
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <qlayout.h> 21#include <qlayout.h>
22#include <qpushbutton.h> 22#include <qpushbutton.h>
23#include <qgroupbox.h> 23#include <qgroupbox.h>
24#include <qapplication.h> 24#include <qapplication.h>
25#include <qregexp.h> 25#include <qregexp.h>
26#include <qvbox.h>
27#include <qlabel.h>
26 28
27#include <klocale.h> 29#include <klocale.h>
28#include <kdebug.h> 30#include <kdebug.h>
29#include <kglobalsettings.h> 31#include <kglobalsettings.h>
30 32
31#include "stdaddressbook.h" 33#include "stdaddressbook.h"
32 34
33#include "addresseedialog.h" 35#include "addresseedialog.h"
36#include "KDGanttMinimizeSplitter.h"
34//#include "addresseedialog.moc" 37//#include "addresseedialog.moc"
35 38
36using namespace KABC; 39using namespace KABC;
37 40
38AddresseeItem::AddresseeItem( QListView *parent, const Addressee &addressee ) : 41AddresseeItem::AddresseeItem( QListView *parent, const Addressee &addressee ) :
39 QListViewItem( parent ), 42 QListViewItem( parent ),
40 mAddressee( addressee ) 43 mAddressee( addressee )
41{ 44{
42 QString name = addressee.familyName()+", "+ addressee.givenName(); 45 QString name = addressee.familyName()+", "+ addressee.givenName();
43 if ( name.length() == 2 ) 46 if ( name.length() == 2 )
44 name = addressee.organization(); 47 name = addressee.organization();
45 setText( Name,name); 48 setText( Name,name);
@@ -50,56 +53,65 @@ QString AddresseeItem::key( int column, bool ) const
50{ 53{
51 54
52 if (column == Email) { 55 if (column == Email) {
53 QString value = text(Email); 56 QString value = text(Email);
54 int val = value.findRev("@"); 57 int val = value.findRev("@");
55 return value.mid( val) + value.left( val ); 58 return value.mid( val) + value.left( val );
56 } 59 }
57 return text(column).lower(); 60 return text(column).lower();
58} 61}
59 62
60AddresseeDialog::AddresseeDialog( QWidget *parent, bool multiple ) : 63AddresseeDialog::AddresseeDialog( QWidget *parent, bool multiple ) :
61 KDialogBase( KDialogBase::Plain, i18n("Select Addressee"), 64 KDialogBase( KDialogBase::Plain, i18n("Select Addressee"),
62 Ok|Cancel, Ok, parent ), mMultiple( multiple ) 65 Ok|Cancel, No, parent ), mMultiple( multiple )
63{ 66{
64 QWidget *topWidget = plainPage(); 67 QWidget *topWidget = plainPage();
65 68
66 QBoxLayout *topLayout = new QHBoxLayout( topWidget ); 69 QBoxLayout *topLayout = new QHBoxLayout( topWidget );
67 QBoxLayout *listLayout = new QVBoxLayout;
68 topLayout->addLayout( listLayout );
69 70
70 mAddresseeList = new KListView( topWidget ); 71
72 KDGanttMinimizeSplitter* mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, topWidget);
73 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
74
75 topLayout->addWidget(mMiniSplitter );
76
77 QWidget *listWidget = new QWidget( mMiniSplitter );
78
79 QBoxLayout *listLayout = new QVBoxLayout (listWidget) ;
80 //topLayout->addLayout( listLayout );
81
82 mAddresseeList = new KListView( listWidget );
71 mAddresseeList->addColumn( i18n("Name") ); 83 mAddresseeList->addColumn( i18n("Name") );
72 mAddresseeList->addColumn( i18n("Email") ); 84 mAddresseeList->addColumn( i18n("Email") );
73 mAddresseeList->setAllColumnsShowFocus( true ); 85 mAddresseeList->setAllColumnsShowFocus( true );
74 mAddresseeList->setFullWidth( true ); 86 mAddresseeList->setFullWidth( true );
75 listLayout->addWidget( mAddresseeList ); 87 listLayout->addWidget( mAddresseeList );
76 connect( mAddresseeList, SIGNAL( doubleClicked( QListViewItem * ) ), 88 connect( mAddresseeList, SIGNAL( doubleClicked( QListViewItem * ) ),
77 SLOT( slotOk() ) ); 89 SLOT( slotOk() ) );
78 90
79 mAddresseeEdit = new QLineEdit( topWidget ); 91 mAddresseeEdit = new QLineEdit( listWidget );
80 connect( mAddresseeEdit, SIGNAL( returnPressed() ), 92 connect( mAddresseeEdit, SIGNAL( returnPressed() ),
81 SLOT( loadAddressBook() ) ); 93 SLOT( loadAddressBook() ) );
82 mAddresseeEdit->setFocus(); 94 mAddresseeEdit->setFocus();
83 95
84 listLayout->addWidget( mAddresseeEdit ); 96 listLayout->addWidget( mAddresseeEdit );
85 97
86 if ( mMultiple ) { 98 if ( mMultiple ) {
87 QBoxLayout *selectedLayout = new QVBoxLayout; 99 //QBoxLayout *selectedLayout = new QVBoxLayout;
88 topLayout->addLayout( selectedLayout ); 100 //topLayout->addLayout( selectedLayout );
89 topLayout->setSpacing( spacingHint() ); 101 //topLayout->setSpacing( spacingHint() );
90 102
91 QGroupBox *selectedGroup = new QGroupBox( 1, Horizontal, i18n("Selected"), 103 QVBox *selectedGroup = new QVBox( mMiniSplitter );
92 topWidget ); 104 new QLabel ( i18n("Selected:"), selectedGroup );
93 selectedLayout->addWidget( selectedGroup ); 105 //selectedLayout->addWidget( selectedGroup );
94 106
95 mSelectedList = new KListView( selectedGroup ); 107 mSelectedList = new KListView( selectedGroup );
96 mSelectedList->addColumn( i18n("Name") ); 108 mSelectedList->addColumn( i18n("Name") );
97 mSelectedList->addColumn( i18n("Email") ); 109 mSelectedList->addColumn( i18n("Email") );
98 mSelectedList->setAllColumnsShowFocus( true ); 110 mSelectedList->setAllColumnsShowFocus( true );
99 mSelectedList->setFullWidth( true ); 111 mSelectedList->setFullWidth( true );
100 connect( mSelectedList, SIGNAL( doubleClicked( QListViewItem * ) ), 112 connect( mSelectedList, SIGNAL( doubleClicked( QListViewItem * ) ),
101 SLOT( removeSelected() ) ); 113 SLOT( removeSelected() ) );
102 114
103 QPushButton *unselectButton = new QPushButton( i18n("Unselect"), selectedGroup ); 115 QPushButton *unselectButton = new QPushButton( i18n("Unselect"), selectedGroup );
104 connect ( unselectButton, SIGNAL( clicked() ), SLOT( removeSelected() ) ); 116 connect ( unselectButton, SIGNAL( clicked() ), SLOT( removeSelected() ) );
105 117
@@ -107,25 +119,29 @@ AddresseeDialog::AddresseeDialog( QWidget *parent, bool multiple ) :
107 SLOT( addSelected( QListViewItem * ) ) ); 119 SLOT( addSelected( QListViewItem * ) ) );
108 connect( mAddresseeList, SIGNAL( returnPressed( QListViewItem * ) ), 120 connect( mAddresseeList, SIGNAL( returnPressed( QListViewItem * ) ),
109 SLOT( selectNextItem( QListViewItem * ) ) ); 121 SLOT( selectNextItem( QListViewItem * ) ) );
110 122
111 } 123 }
112 124
113 mAddressBook = StdAddressBook::self( true ); 125 mAddressBook = StdAddressBook::self( true );
114 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook* ) ), 126 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook* ) ),
115 SLOT( addressBookChanged() ) ); 127 SLOT( addressBookChanged() ) );
116 connect( mAddressBook, SIGNAL( loadingFinished( Resource* ) ), 128 connect( mAddressBook, SIGNAL( loadingFinished( Resource* ) ),
117 SLOT( addressBookChanged() ) ); 129 SLOT( addressBookChanged() ) );
118 130
119 loadAddressBook(); 131 loadAddressBook();
132 QValueList<int> splitterSize;
133 splitterSize.append( ( width() / 5 ) * 3 );
134 splitterSize.append( ( width() / 5 ) *2 );
135 mMiniSplitter->setSizes( splitterSize );
120} 136}
121 137
122AddresseeDialog::~AddresseeDialog() 138AddresseeDialog::~AddresseeDialog()
123{ 139{
124} 140}
125 141
126void AddresseeDialog::loadAddressBook() 142void AddresseeDialog::loadAddressBook()
127{ 143{
128 mAddresseeList->clear(); 144 mAddresseeList->clear();
129 mItemDict.clear(); 145 mItemDict.clear();
130 if ( mAddresseeEdit->text().isEmpty() ) { 146 if ( mAddresseeEdit->text().isEmpty() ) {
131 AddressBook::Iterator it; 147 AddressBook::Iterator it;