Diffstat (limited to 'kaddressbook/views/kaddressbooktableview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp index 272f2eb..7efaaa9 100644 --- a/kaddressbook/views/kaddressbooktableview.cpp +++ b/kaddressbook/views/kaddressbooktableview.cpp @@ -1,162 +1,166 @@ // $Id$ -#include <qvbox.h> -#include <qlistbox.h> +#include <q3vbox.h> +#include <q3listbox.h> #include <qwidget.h> #include <qfile.h> #include <qimage.h> #include <qcombobox.h> #include <qapplication.h> -#include <qdragobject.h> +#include <q3dragobject.h> #include <qevent.h> -#include <qurl.h> +#include <q3url.h> #include <qpixmap.h> +//Added by qt3to4: +#include <QDropEvent> +#include <QKeyEvent> +#include <Q3VBoxLayout> #include <kabc/addressbook.h> #include <kapplication.h> #include <kconfig.h> #include <kcolorbutton.h> #include <kdebug.h> #include <kglobal.h> #include <kiconloader.h> #include <klineedit.h> #include <klocale.h> #include <kmessagebox.h> #include <kurl.h> #include <kurlrequester.h> //US#include "configuretableviewdialog.h" #include "contactlistview.h" #include "kabprefs.h" #include "undocmds.h" #include "viewmanager.h" #include <qlayout.h> -#include <qheader.h> +#include <q3header.h> #include <qregexp.h> #include "kaddressbooktableview.h" KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, QWidget *parent, const char *name ) : KAddressBookView( ab, parent, name ) { - mainLayout = new QVBoxLayout( viewWidget(), 2 ); + mainLayout = new Q3VBoxLayout( viewWidget(), 2 ); // The list view will be created when the config is read. mListView = 0; } KAddressBookTableView::~KAddressBookTableView() { } void KAddressBookTableView::setFocusAV() { if ( mListView ) mListView->setFocus(); } void KAddressBookTableView::scrollUP() { QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); QApplication::postEvent( mListView, ev ); ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Up, 0,0 ); QApplication::postEvent( mListView, ev ); } void KAddressBookTableView::scrollDOWN() { QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); QApplication::postEvent( mListView, ev ); ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Down, 0,0 ); QApplication::postEvent( mListView, ev ); } void KAddressBookTableView::reconstructListView() { if (mListView) { disconnect(mListView, SIGNAL(selectionChanged()), this, SLOT(addresseeSelected())); - disconnect(mListView, SIGNAL(executed(QListViewItem*)), - this, SLOT(addresseeExecuted(QListViewItem*))); - disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), - this, SLOT(addresseeExecuted(QListViewItem*))); + disconnect(mListView, SIGNAL(executed(Q3ListViewItem*)), + this, SLOT(addresseeExecuted(Q3ListViewItem*))); + disconnect(mListView, SIGNAL(doubleClicked(Q3ListViewItem*)), + this, SLOT(addresseeExecuted(Q3ListViewItem*))); disconnect(mListView, SIGNAL(startAddresseeDrag()), this, SIGNAL(startDrag())); - disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), - this, SLOT(addresseeExecuted(QListViewItem*))); + disconnect(mListView, SIGNAL(returnPressed(Q3ListViewItem*)), + this, SLOT(addresseeExecuted(Q3ListViewItem*))); disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, SIGNAL(dropped(QDropEvent*))); delete mListView; } mListView = new ContactListView( this, addressBook(), viewWidget() ); connect(this, SIGNAL(printView()), mListView , SLOT(printMe())); //US set singleClick manually, because it is no global configparameter in embedded space mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick); // Add the columns KABC::Field::List fieldList = fields(); KABC::Field::List::ConstIterator it; int c = 0; for( it = fieldList.begin(); it != fieldList.end(); ++it ) { mListView->addColumn( (*it)->label() ); - mListView->setColumnWidthMode(c++, QListView::Manual); + mListView->setColumnWidthMode(c++, Q3ListView::Manual); //US // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); } connect(mListView, SIGNAL(selectionChanged()), this, SLOT(addresseeSelected())); connect(mListView, SIGNAL(startAddresseeDrag()), this, SIGNAL(startDrag())); connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, SIGNAL(dropped(QDropEvent*))); if (KABPrefs::instance()->mHonorSingleClick) { // qDebug("KAddressBookTableView::reconstructListView single"); - connect(mListView, SIGNAL(executed(QListViewItem*)), - this, SLOT(addresseeExecuted(QListViewItem*))); + connect(mListView, SIGNAL(executed(Q3ListViewItem*)), + this, SLOT(addresseeExecuted(Q3ListViewItem*))); } else { // qDebug("KAddressBookTableView::reconstructListView double"); - connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), - this, SLOT(addresseeExecuted(QListViewItem*))); + connect(mListView, SIGNAL(doubleClicked(Q3ListViewItem*)), + this, SLOT(addresseeExecuted(Q3ListViewItem*))); } - connect(mListView, SIGNAL(returnPressed(QListViewItem*)), - this, SLOT(addresseeExecuted(QListViewItem*))); + connect(mListView, SIGNAL(returnPressed(Q3ListViewItem*)), + this, SLOT(addresseeExecuted(Q3ListViewItem*))); connect(mListView, SIGNAL(signalDelete()), this, SLOT(addresseeDeleted())); //US performceimprovement. Refresh is done from the outside //US refresh(); mListView->setSorting( 0, true ); mainLayout->addWidget( mListView ); mainLayout->activate(); mListView->show(); } void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) { mListView->clear(); if ( s.isEmpty() || s == "*" ) { refresh(); return; } QRegExp re = getRegExp( s ); if (!re.isValid()) return; KABC::Addressee::List addresseeList = addressees(); KABC::Addressee::List::Iterator it; if ( field ) { for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) continue; #if QT_VERSION >= 0x030000 if (re.search(field->value( *it ).lower()) == 0) #else if (re.match(field->value( *it ).lower()) == 0) @@ -315,178 +319,178 @@ void KAddressBookTableView::refresh(QString uid) nextUID = nextItem->addressee().uid(); currentUID = currentItem->addressee().uid(); } mListView->clear(); currentItem = 0; KABC::Addressee::List addresseeList = addressees(); KABC::Addressee::List::Iterator it; for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) continue; ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); if ( (*it).uid() == currentUID ) currentItem = item; else if ( (*it).uid() == nextUID && !currentItem ) currentItem = item; } // Sometimes the background pixmap gets messed up when we add lots // of items. mListView->repaint(); if ( !currentItem ) currentItem = (ContactListViewItem *)mListView->firstChild(); if ( currentItem ) { mListView->setCurrentItem( currentItem ); mListView->ensureItemVisible( currentItem ); mListView->setSelected( currentItem, true ); } } else { // Only need to update on entry. Iterate through and try to find it ContactListViewItem *ceItem; - QListViewItemIterator it( mListView ); + Q3ListViewItemIterator it( mListView ); while ( it.current() ) { #ifndef KAB_EMBEDDED ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); #else //KAB_EMBEDDED ceItem = (ContactListViewItem*)( it.current() ); #endif //KAB_EMBEDDED if ( ceItem && ceItem->addressee().uid() == uid ) { ceItem->refresh(); return; } ++it; } refresh( QString::null ); } } QStringList KAddressBookTableView::selectedUids() { QStringList uidList; - QListViewItem *item; + Q3ListViewItem *item; ContactListViewItem *ceItem; for(item = mListView->firstChild(); item; item = item->itemBelow()) { if (mListView->isSelected( item )) { #ifndef KAB_EMBEDDED ceItem = dynamic_cast<ContactListViewItem*>(item); #else //KAB_EMBEDDED ceItem = (ContactListViewItem*)(item); #endif //KAB_EMBEDDED if (ceItem != 0L) uidList << ceItem->addressee().uid(); } } if ( uidList.count() == 0 ) if ( mListView->currentItem() ) { ceItem = (ContactListViewItem*)(mListView->currentItem()) ; uidList << ceItem->addressee().uid(); } return uidList; } void KAddressBookTableView::setSelected(QString uid, bool selected) { - QListViewItem *item; + Q3ListViewItem *item; ContactListViewItem *ceItem; if (uid.isNull()) { mListView->selectAll(selected); } else { for(item = mListView->firstChild(); item; item = item->itemBelow()) { #ifndef KAB_EMBEDDED ceItem = dynamic_cast<ContactListViewItem*>(item); #else //KAB_EMBEDDED ceItem = (ContactListViewItem*)(item); #endif //KAB_EMBEDDED if ((ceItem != 0L) && (ceItem->addressee().uid() == uid)) { mListView->setSelected(item, selected); if (selected) mListView->ensureItemVisible(item); } } } } void KAddressBookTableView::addresseeSelected() { // We need to try to find the first selected item. This might not be the // last selected item, but when QListView is in multiselection mode, // there is no way to figure out which one was // selected last. - QListViewItem *item; + Q3ListViewItem *item; bool found =false; for (item = mListView->firstChild(); item && !found; item = item->nextSibling()) { if (item->isSelected()) { found = true; #ifndef KAB_EMBEDDED ContactListViewItem *ceItem = dynamic_cast<ContactListViewItem*>(item); #else //KAB_EMBEDDED ContactListViewItem *ceItem = (ContactListViewItem*)(item); #endif //KAB_EMBEDDED if ( ceItem ) emit selected(ceItem->addressee().uid()); } } if (!found) emit selected(QString::null); } -void KAddressBookTableView::addresseeExecuted(QListViewItem *item) +void KAddressBookTableView::addresseeExecuted(Q3ListViewItem *item) { if (item) { #ifndef KAB_EMBEDDED ContactListViewItem *ceItem = dynamic_cast<ContactListViewItem*>(item); #else //KAB_EMBEDDED ContactListViewItem *ceItem = (ContactListViewItem*)(item); #endif //KAB_EMBEDDED if (ceItem) { emit executed(ceItem->addressee().uid()); } } else { emit executed(QString::null); } } void KAddressBookTableView::addresseeDeleted() { emit deleteRequest(); } -#ifndef KAB_EMBEDDED -#include "kaddressbooktableview.moc" +#ifndef KAB_EMBEDDED_ +#include "moc_kaddressbooktableview.cpp" #endif //KAB_EMBEDDED |