summaryrefslogtreecommitdiffabout
path: root/kaddressbook/views
Unidiff
Diffstat (limited to 'kaddressbook/views') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/views/kaddressbooktableview.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp
index e40eb9e..6f20e05 100644
--- a/kaddressbook/views/kaddressbooktableview.cpp
+++ b/kaddressbook/views/kaddressbooktableview.cpp
@@ -43,122 +43,128 @@ KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab,
43 : KAddressBookView( ab, parent, name ) 43 : KAddressBookView( ab, parent, name )
44{ 44{
45 mainLayout = new QVBoxLayout( viewWidget(), 2 ); 45 mainLayout = new QVBoxLayout( viewWidget(), 2 );
46 46
47 // The list view will be created when the config is read. 47 // The list view will be created when the config is read.
48 mListView = 0; 48 mListView = 0;
49} 49}
50 50
51KAddressBookTableView::~KAddressBookTableView() 51KAddressBookTableView::~KAddressBookTableView()
52{ 52{
53} 53}
54void KAddressBookTableView::setFocusAV() 54void KAddressBookTableView::setFocusAV()
55{ 55{
56 if ( mListView ) 56 if ( mListView )
57 mListView->setFocus(); 57 mListView->setFocus();
58 58
59} 59}
60void KAddressBookTableView::scrollUP() 60void KAddressBookTableView::scrollUP()
61{ 61{
62 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); 62 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 );
63 QApplication::postEvent( mListView, ev ); 63 QApplication::postEvent( mListView, ev );
64} 64}
65void KAddressBookTableView::scrollDOWN() 65void KAddressBookTableView::scrollDOWN()
66{ 66{
67 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); 67 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 );
68 QApplication::postEvent( mListView, ev ); 68 QApplication::postEvent( mListView, ev );
69} 69}
70void KAddressBookTableView::reconstructListView() 70void KAddressBookTableView::reconstructListView()
71{ 71{
72 if (mListView) 72 if (mListView)
73 { 73 {
74 disconnect(mListView, SIGNAL(selectionChanged()), 74 disconnect(mListView, SIGNAL(selectionChanged()),
75 this, SLOT(addresseeSelected())); 75 this, SLOT(addresseeSelected()));
76 disconnect(mListView, SIGNAL(executed(QListViewItem*)), 76 disconnect(mListView, SIGNAL(executed(QListViewItem*)),
77 this, SLOT(addresseeExecuted(QListViewItem*))); 77 this, SLOT(addresseeExecuted(QListViewItem*)));
78 disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), 78 disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)),
79 this, SLOT(addresseeExecuted(QListViewItem*))); 79 this, SLOT(addresseeExecuted(QListViewItem*)));
80 disconnect(mListView, SIGNAL(startAddresseeDrag()), this, 80 disconnect(mListView, SIGNAL(startAddresseeDrag()), this,
81 SIGNAL(startDrag())); 81 SIGNAL(startDrag()));
82 disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), 82 disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)),
83 this, SLOT(addresseeExecuted(QListViewItem*))); 83 this, SLOT(addresseeExecuted(QListViewItem*)));
84 84
85 disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, 85 disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
86 SIGNAL(dropped(QDropEvent*))); 86 SIGNAL(dropped(QDropEvent*)));
87 delete mListView; 87 delete mListView;
88 } 88 }
89 89
90 mListView = new ContactListView( this, addressBook(), viewWidget() ); 90 mListView = new ContactListView( this, addressBook(), viewWidget() );
91
92 //US set singleClick manually, because it is no global configparameter in embedded space
93 mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick);
91 94
92 // Add the columns 95 // Add the columns
93 KABC::Field::List fieldList = fields(); 96 KABC::Field::List fieldList = fields();
94 KABC::Field::List::ConstIterator it; 97 KABC::Field::List::ConstIterator it;
95 98
96 int c = 0; 99 int c = 0;
97 for( it = fieldList.begin(); it != fieldList.end(); ++it ) { 100 for( it = fieldList.begin(); it != fieldList.end(); ++it ) {
98 mListView->addColumn( (*it)->label() ); 101 mListView->addColumn( (*it)->label() );
99 mListView->setColumnWidthMode(c++, QListView::Manual); 102 mListView->setColumnWidthMode(c++, QListView::Manual);
100//US 103//US
101 // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); 104 // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1());
102 } 105 }
103 106
104 connect(mListView, SIGNAL(selectionChanged()), 107 connect(mListView, SIGNAL(selectionChanged()),
105 this, SLOT(addresseeSelected())); 108 this, SLOT(addresseeSelected()));
106 connect(mListView, SIGNAL(startAddresseeDrag()), this, 109 connect(mListView, SIGNAL(startAddresseeDrag()), this,
107 SIGNAL(startDrag())); 110 SIGNAL(startDrag()));
108 connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, 111 connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
109 SIGNAL(dropped(QDropEvent*))); 112 SIGNAL(dropped(QDropEvent*)));
110 113
111 if (KABPrefs::instance()->mHonorSingleClick) 114 if (KABPrefs::instance()->mHonorSingleClick) {
115 // qDebug("KAddressBookTableView::reconstructListView single");
112 connect(mListView, SIGNAL(executed(QListViewItem*)), 116 connect(mListView, SIGNAL(executed(QListViewItem*)),
113 this, SLOT(addresseeExecuted(QListViewItem*))); 117 this, SLOT(addresseeExecuted(QListViewItem*)));
114 else 118 } else {
119 // qDebug("KAddressBookTableView::reconstructListView double");
115 connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), 120 connect(mListView, SIGNAL(doubleClicked(QListViewItem*)),
116 this, SLOT(addresseeExecuted(QListViewItem*))); 121 this, SLOT(addresseeExecuted(QListViewItem*)));
122 }
117 connect(mListView, SIGNAL(returnPressed(QListViewItem*)), 123 connect(mListView, SIGNAL(returnPressed(QListViewItem*)),
118 this, SLOT(addresseeExecuted(QListViewItem*))); 124 this, SLOT(addresseeExecuted(QListViewItem*)));
119 connect(mListView, SIGNAL(signalDelete()), 125 connect(mListView, SIGNAL(signalDelete()),
120 this, SLOT(addresseeDeleted())); 126 this, SLOT(addresseeDeleted()));
121 127
122//US performceimprovement. Refresh is done from the outside 128//US performceimprovement. Refresh is done from the outside
123//US refresh(); 129//US refresh();
124 130
125 mListView->setSorting( 0, true ); 131 mListView->setSorting( 0, true );
126 mainLayout->addWidget( mListView ); 132 mainLayout->addWidget( mListView );
127 mainLayout->activate(); 133 mainLayout->activate();
128 mListView->show(); 134 mListView->show();
129} 135}
130 136
131void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) 137void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field )
132{ 138{
133 mListView->clear(); 139 mListView->clear();
134 if ( s.isEmpty() || s == "*" ) { 140 if ( s.isEmpty() || s == "*" ) {
135 refresh(); 141 refresh();
136 return; 142 return;
137 } 143 }
138 QString pattern = s.lower()+"*"; 144 QString pattern = s.lower()+"*";
139 QRegExp re; 145 QRegExp re;
140 re.setWildcard(true); // most people understand these better. 146 re.setWildcard(true); // most people understand these better.
141 re.setCaseSensitive(false); 147 re.setCaseSensitive(false);
142 re.setPattern( pattern ); 148 re.setPattern( pattern );
143 if (!re.isValid()) 149 if (!re.isValid())
144 return; 150 return;
145 KABC::Addressee::List addresseeList = addressees(); 151 KABC::Addressee::List addresseeList = addressees();
146 KABC::Addressee::List::Iterator it; 152 KABC::Addressee::List::Iterator it;
147 if ( field ) { 153 if ( field ) {
148 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 154 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
149#if QT_VERSION >= 300 155#if QT_VERSION >= 300
150 if (re.search(field->value( *it ).lower()) != -1) 156 if (re.search(field->value( *it ).lower()) != -1)
151#else 157#else
152 if (re.match(field->value( *it ).lower()) != -1) 158 if (re.match(field->value( *it ).lower()) != -1)
153#endif 159#endif
154 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 160 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
155 161
156 } 162 }
157 } else { 163 } else {
158 KABC::Field::List fieldList = fields(); 164 KABC::Field::List fieldList = fields();
159 KABC::Field::List::ConstIterator fieldIt; 165 KABC::Field::List::ConstIterator fieldIt;
160 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 166 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
161 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 167 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
162#if QT_VERSION >= 300 168#if QT_VERSION >= 300
163 if (re.search((*fieldIt)->value( *it ).lower()) != -1) 169 if (re.search((*fieldIt)->value( *it ).lower()) != -1)
164#else 170#else