author | drw <drw> | 2005-02-06 23:12:25 (UTC) |
---|---|---|
committer | drw <drw> | 2005-02-06 23:12:25 (UTC) |
commit | 5652634e4ff03370564925ce0856b260c001dc0f (patch) (side-by-side diff) | |
tree | 614cbdec8ff9f4f674a9cb4e5caf44cce1def4f8 /core/pim | |
parent | 266d71ee80151b3c97671acc95275aa65b682388 (diff) | |
download | opie-5652634e4ff03370564925ce0856b260c001dc0f.zip opie-5652634e4ff03370564925ce0856b260c001dc0f.tar.gz opie-5652634e4ff03370564925ce0856b260c001dc0f.tar.bz2 |
Convert to OPimMainWindow and UI tweaks. There is still a couple items yet to do...
-rw-r--r-- | core/pim/addressbook/abconfig.cpp | 22 | ||||
-rw-r--r-- | core/pim/addressbook/abconfig.h | 13 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 654 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.h | 52 | ||||
-rw-r--r-- | core/pim/addressbook/contacteditor.cpp | 62 | ||||
-rw-r--r-- | core/pim/addressbook/contacteditor.h | 6 |
6 files changed, 310 insertions, 499 deletions
diff --git a/core/pim/addressbook/abconfig.cpp b/core/pim/addressbook/abconfig.cpp index a3fd222..2583327 100644 --- a/core/pim/addressbook/abconfig.cpp +++ b/core/pim/addressbook/abconfig.cpp @@ -21,3 +21,3 @@ AbConfig::~AbConfig() { -} +} @@ -68,2 +68,7 @@ AbConfig::LPSearchMode AbConfig::letterPickerSearch() const +const QString &AbConfig::category() const +{ + return m_category; +} + void AbConfig::setUseRegExp( bool v ) @@ -123,2 +128,7 @@ void AbConfig::setLetterPickerSearch( const AbConfig::LPSearchMode mode ) +void AbConfig::setCategory( const QString &cat ) +{ + m_category = cat; +} + void AbConfig::load() @@ -128,2 +138,5 @@ void AbConfig::load() + cfg.setGroup( "View" ); + m_category = cfg.readEntry( "Category", "All" ); + cfg.setGroup("Font"); @@ -168,2 +181,5 @@ void AbConfig::save() Config cfg("AddressBook"); + cfg.setGroup( "View" ); + cfg.writeEntry( "Category", m_category ); + cfg.setGroup("Font"); @@ -195,5 +211,5 @@ void AbConfig::save() cfg.writeEntry( "PatchVersion", PATCHVERSION ); - + } - + } diff --git a/core/pim/addressbook/abconfig.h b/core/pim/addressbook/abconfig.h index c312179..68d087c 100644 --- a/core/pim/addressbook/abconfig.h +++ b/core/pim/addressbook/abconfig.h @@ -3,3 +3,3 @@ -#include <qstringlist.h> +#include <qstringlist.h> #include <qmainwindow.h> @@ -19,3 +19,3 @@ public: ~AbConfig(); - + // Search Settings @@ -31,6 +31,7 @@ public: LPSearchMode letterPickerSearch() const; - + const QString &category() const; + void setUseRegExp( bool v ); void setUseWildCards( bool v ); - void setBeCaseSensitive( bool v ); + void setBeCaseSensitive( bool v ); void setUseQtMail( bool v ); @@ -42,2 +43,3 @@ public: void setLetterPickerSearch( const LPSearchMode mode ); + void setCategory( const QString &cat ); @@ -57,3 +59,3 @@ protected: bool m_useRegExp; - bool m_beCaseSensitive; + bool m_beCaseSensitive; int m_fontSize; @@ -63,2 +65,3 @@ protected: int m_lpSearchMode; + QString m_category; diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index 3f0ac74..a4c2c6e 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp @@ -56,10 +56,10 @@ extern QString addressbookPersonalVCardName(); AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, - WFlags f ) - : QMainWindow( parent, name, f ), - catMenu (0l), + WFlags /*f*/ ) + : Opie::OPimMainWindow( "Addressbook", "Contacts", tr( "Contact" ), "AddressBook", + parent, name, WType_TopLevel | WStyle_ContextHelp ), abEditor(0l), - syncing(FALSE), - m_tableViewButton(0l), - m_cardViewButton(0l) + syncing(false) { + setCaption( tr( "Contacts" ) ); + isLoading = true; @@ -68,179 +68,61 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, - setCaption( tr("Contacts") ); - setIcon( Resource::loadPixmap( "addressbook/AddressBook" ) ); - - // Settings for Main Menu - // setToolBarsMovable( false ); - setToolBarsMovable( !m_config.fixedBars() ); - setRightJustification( true ); - - QToolBar *bar = new QToolBar( this ); - bar->setHorizontalStretchable( TRUE ); - - QMenuBar *mbList = new QMenuBar( bar ); - mbList->setMargin( 0 ); - - QPopupMenu *edit = new QPopupMenu( mbList ); - mbList->insertItem( tr( "Contact" ), edit ); - - // Category Menu - catMenu = new QPopupMenu( this ); - catMenu->setCheckable( TRUE ); - connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); - mbList->insertItem( tr("View"), catMenu ); - - // Create Toolbar - listTools = new QToolBar( this, "list operations" ); - listTools->setHorizontalStretchable( true ); - addToolBar( listTools ); - moveToolBar( listTools, m_config.getToolBarPos() ); - - // View Icons - m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "addressbook/listview" ), - QString::null, 0, this, 0 ); - connect( m_tableViewButton, SIGNAL( activated() ), this, SLOT( slotListView() ) ); - m_tableViewButton->setToggleAction( true ); - m_tableViewButton->addTo( listTools ); - m_cardViewButton = new QAction( tr( "Card" ), Resource::loadPixmap( "addressbook/cardview" ), QString::null, 0, this, 0 ); - connect( m_cardViewButton, SIGNAL( activated() ), this, SLOT( slotCardView() ) ); - m_cardViewButton->setToggleAction( true ); - m_cardViewButton->addTo( listTools ); - - listTools->addSeparator(); - - // Other Buttons - QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, - 0, this, 0 ); - actionNew = a; - connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); - a->addTo( edit ); - a->addTo( listTools ); - - a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, - 0, this, 0 ); - actionEdit = a; - connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); - a->addTo( edit ); - a->addTo( listTools ); - - a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, - 0, this, 0 ); - actionTrash = a; - connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); - a->addTo( edit ); - a->addTo( listTools ); - - - // make it possible to go directly to businesscard via qcop call - //#if defined(Q_WS_QWS) // Why this ? (se) -#if !defined(QT_NO_COP) - QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this ); - connect (addressChannel, SIGNAL( received(const QCString&,const QByteArray&)), - this, SLOT ( appMessage(const QCString&,const QByteArray&) ) ); -#endif - // #endif - a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), - QString::null, 0, this, 0 ); - actionFind = a; - connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) ); - a->addTo( edit ); - a->addTo( listTools ); - - // Much better search widget, taken from QTReader.. (se) - searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE ); - searchBar->setHorizontalStretchable( TRUE ); - searchBar->hide(); - searchEdit = new QLineEdit( searchBar, "searchEdit" ); - -// QFont f("unifont", 16 /*, QFont::Bold*/); -// searchEdit->setFont( f ); - - searchBar->setStretchableWidget( searchEdit ); - connect( searchEdit, SIGNAL( returnPressed() ), - this, SLOT( slotFind() ) ); - - a = new QAction( tr( "Start Search" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); - connect( a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); - a->addTo( searchBar ); - - a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); - connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) ); - a->addTo( searchBar ); - - a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "addressbook/sendmail" ), - QString::null, 0, this, 0 ); - //a->setEnabled( FALSE ); we got support for it now :) zecke - actionMail = a; - connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); - a->addTo( edit ); - a->addTo( listTools ); - - if ( Ir::supported() ) { - a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, - 0, this, 0 ); - actionBeam = a; - connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); - a->addTo( edit ); - a->addTo( listTools ); - } + // Create Views + m_listContainer = new QWidget( this ); + QVBoxLayout *vb = new QVBoxLayout( m_listContainer ); - edit->insertSeparator(); + m_abView = new AbView( m_listContainer, m_config.orderList() ); + vb->addWidget( m_abView ); + connect( m_abView, SIGNAL(signalViewSwitched(int)), + this, SLOT(slotViewSwitched(int)) ); - a = new QAction( tr("Import vCard"), Resource::loadPixmap( "addressbook/fileimport"), QString::null, - 0, this, 0); - actionPersonal = a; - connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); - a->addTo( edit ); + QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); - a = new QAction( tr("Export vCard"), Resource::loadPixmap( "addressbook/fileexport"), QString::null, - 0, this, 0); - actionPersonal = a; - connect( a, SIGNAL( activated() ), this, SLOT( exportvCard() ) ); - a->addTo( edit ); + // Letter Picker + pLabel = new LetterPicker( m_listContainer ); + connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); + connect(m_abView, SIGNAL(signalClearLetterPicker()), pLabel, SLOT(clear()) ); - edit->insertSeparator(); + vb->addWidget( pLabel ); - a = new QAction( tr("My Personal Details"), Resource::loadPixmap( "addressbook/identity" ), - QString::null, 0, this, 0 , TRUE ); - actionPersonal = a; - connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); - a->addTo( edit ); + // Quick search bar + m_searchBar = new OFloatBar( "Search", this, QMainWindow::Top, true ); + m_searchBar->setHorizontalStretchable( true ); + m_searchBar->hide(); + m_searchEdit = new QLineEdit( m_searchBar, "m_searchEdit" ); + m_searchBar->setStretchableWidget( m_searchEdit ); + connect( m_searchEdit, SIGNAL(returnPressed()), this, SLOT(slotFind()) ); -#ifdef __DEBUG_RELEASE - // Remove this function for public Release ! This is only - // for debug purposes .. - a = new QAction( tr( "Save all Data"), QString::null, 0, 0 ); - connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) ); - a->addTo( edit ); -#endif - a = new QAction( tr( "Config" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, - 0, this, 0 ); - connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) ); - a->addTo( edit ); + QAction *a = new QAction( tr( "Start Search" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); + connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); + a->addTo( m_searchBar ); - // Create Views - listContainer = new QWidget( this ); - QVBoxLayout *vb = new QVBoxLayout( listContainer ); + // Insert Contact menu items + QActionGroup *items = new QActionGroup( this, QString::null, false ); - m_abView = new AbView( listContainer, m_config.orderList() ); - vb->addWidget( m_abView ); - // abList->setHScrollBarMode( QScrollView::AlwaysOff ); - connect( m_abView, SIGNAL( signalViewSwitched(int) ), - this, SLOT( slotViewSwitched(int) ) ); + m_actionMail = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "addressbook/sendmail" ), + QString::null, 0, items, 0 ); + connect( m_actionMail, SIGNAL(activated()), this, SLOT(writeMail()) ); + a = new QAction( tr("Import vCard"), Resource::loadPixmap( "addressbook/fileimport"), + QString::null, 0, items, 0 ); + connect( a, SIGNAL(activated()), this, SLOT(importvCard()) ); - QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); + a = new QAction( tr("Export vCard"), Resource::loadPixmap( "addressbook/fileexport"), + QString::null, 0, items, 0 ); + connect( a, SIGNAL(activated()), this, SLOT(exportvCard()) ); - // m_abView->load(); // Already done by c'tor . + m_actionPersonal = new QAction( tr("My Personal Details"), Resource::loadPixmap( "addressbook/identity" ), + QString::null, 0, items, 0 , true ); + connect( m_actionPersonal, SIGNAL(activated()), this, SLOT(slotPersonalView()) ); - // Letter Picker - pLabel = new LetterPicker( listContainer ); - connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); - connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) ); + insertItemMenuItems( items ); - vb->addWidget( pLabel ); + // Insert View menu items + items = new QActionGroup( this, QString::null, false ); + + a = new QAction( tr("Show quick search bar"),QString::null, 0, items, 0, true ); + connect( a, SIGNAL(toggled(bool)), this, SLOT(slotShowFind(bool)) ); - // All Categories into view-menu.. - populateCategories(); + insertViewMenuItems( items ); @@ -251,34 +133,19 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, - setCentralWidget(listContainer); + setCentralWidget(m_listContainer); // odebug << "adressbook contrsuction: t=" << t.elapsed() << oendl; - connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); - connect( qApp, SIGNAL( reload() ), this, SLOT( reload() ) ); - connect( qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ), - this, SLOT( appMessage(const QCString&,const QByteArray&) ) ); - + connect( qApp, SIGNAL(flush()), this, SLOT(flush()) ); + connect( qApp, SIGNAL(reload()), this, SLOT(reload()) ); + connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), + this, SLOT(appMessage(const QCString&,const QByteArray&)) ); isLoading = false; -} - -void AddressbookWindow::slotConfig() -{ - ConfigDlg* dlg = new ConfigDlg( this, "Config" ); - dlg -> setConfig( m_config ); - if ( QPEApplication::execDialog( dlg ) ) { - odebug << "Config Dialog accepted!" << oendl; - m_config = dlg -> getConfig(); - if ( m_curFontSize != m_config.fontSize() ){ - odebug << "Font was changed!" << oendl; - m_curFontSize = m_config.fontSize(); - emit slotSetFont( m_curFontSize ); - } - m_abView -> setListOrder( m_config.orderList() ); - } - - delete dlg; + // Handle category selection + setViewCategory( m_config.category() ); + m_abView->setShowByCategory( m_config.category() ); + connect( this, SIGNAL(categorySelected(const QString&)), + this, SLOT(slotSetCategory(const QString&)) ); } - void AddressbookWindow::slotSetFont( int size ) @@ -356,4 +223,4 @@ void AddressbookWindow::setDocument( const QString &filename ) // the personal database accidently. - if ( actionPersonal->isOn() ){ - actionPersonal->setOn( false ); + if ( m_actionPersonal->isOn() ){ + m_actionPersonal->setOn( false ); slotPersonalView(); @@ -440,9 +307,29 @@ AddressbookWindow::~AddressbookWindow() -void AddressbookWindow::slotUpdateToolbar() +int AddressbookWindow::create() +{ + return 0; +} + +bool AddressbookWindow::remove( int /*uid*/ ) +{ + return false; +} + +void AddressbookWindow::beam( int /*uid*/ ) +{ +} + +void AddressbookWindow::show( int /*uid*/ ) +{ +} + +void AddressbookWindow::edit( int /*uid*/ ) { - Opie::OPimContact ce = m_abView->currentEntry(); - actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); } -void AddressbookWindow::slotListNew() +void AddressbookWindow::add( const Opie::OPimRecord& ) +{ +} + +void AddressbookWindow::slotItemNew() { @@ -457,10 +344,21 @@ void AddressbookWindow::slotListNew() -// void AddressbookWindow::slotListView() -// { -// m_abView -> init( abList->currentEntry() ); -// // :SX mView->sync(); -// //:SX showView(); -// } +void AddressbookWindow::slotItemEdit() +{ + if(!syncing) { + if (m_actionPersonal->isOn()) { + editPersonal(); + } else { + editEntry( EditEntry ); + } + } else { + QMessageBox::warning( this, tr("Contacts"), + tr("Can not edit data, currently syncing") ); + } +} + +void AddressbookWindow::slotItemDuplicate() +{ +} -void AddressbookWindow::slotListDelete() +void AddressbookWindow::slotItemDelete() { @@ -488,15 +386,80 @@ void AddressbookWindow::slotListDelete() -void AddressbookWindow::slotFindOpen() +static const char * beamfile = "/tmp/obex/contact.vcf"; + +void AddressbookWindow::slotItemBeam() { - searchBar->show(); - m_abView -> inSearch(); - searchEdit->setFocus(); + QString beamFilename; + Opie::OPimContact c; + if ( m_actionPersonal->isOn() ) { + beamFilename = addressbookPersonalVCardName(); + if ( !QFile::exists( beamFilename ) ) + return; // can't beam a non-existent file + Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, + beamFilename ); + Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); + Opie::OPimContactAccess::List allList = access->allRecords(); + Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first + c = *it; + + delete access; + } else { + unlink( beamfile ); // delete if exists + mkdir("/tmp/obex/", 0755); + c = m_abView -> currentEntry(); + Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, + beamfile ); + Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); + access->add( c ); + access->save(); + delete access; + + beamFilename = beamfile; + } + + odebug << "Beaming: " << beamFilename << oendl; + + Ir *ir = new Ir( this ); + connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); + QString description = c.fullName(); + ir->send( beamFilename, description, "text/x-vCard" ); } -void AddressbookWindow::slotFindClose() + +void AddressbookWindow::slotItemFind() { - searchBar->hide(); - m_abView -> offSearch(); - // m_abView->setFocus(); } +void AddressbookWindow::slotConfigure() +{ + ConfigDlg* dlg = new ConfigDlg( this, "Config" ); + dlg -> setConfig( m_config ); + if ( QPEApplication::execDialog( dlg ) ) { + odebug << "Config Dialog accepted!" << oendl; + m_config = dlg -> getConfig(); + if ( m_curFontSize != m_config.fontSize() ){ + odebug << "Font was changed!" << oendl; + m_curFontSize = m_config.fontSize(); + emit slotSetFont( m_curFontSize ); + } + m_abView -> setListOrder( m_config.orderList() ); + } + + delete dlg; +} + +void AddressbookWindow::slotShowFind( bool show ) +{ + if ( show ) + { + // Display search bar + m_searchBar->show(); + m_abView -> inSearch(); + m_searchEdit->setFocus(); + } + else + { + // Hide search bar + m_searchBar->hide(); + m_abView -> offSearch(); + } +} @@ -504,5 +467,5 @@ void AddressbookWindow::slotFind() { - m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false); + m_abView->slotDoFind( m_searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false); - searchEdit->clearFocus(); + m_searchEdit->clearFocus(); // m_abView->setFocus(); @@ -516,18 +479,2 @@ void AddressbookWindow::slotViewBack() -void AddressbookWindow::slotViewEdit() -{ - if(!syncing) { - if (actionPersonal->isOn()) { - editPersonal(); - } else { - editEntry( EditEntry ); - } - } else { - QMessageBox::warning( this, tr("Contacts"), - tr("Can not edit data, currently syncing") ); - } -} - - - void AddressbookWindow::writeMail() @@ -569,42 +516,2 @@ void AddressbookWindow::writeMail() -static const char * beamfile = "/tmp/obex/contact.vcf"; - -void AddressbookWindow::slotBeam() -{ - QString beamFilename; - Opie::OPimContact c; - if ( actionPersonal->isOn() ) { - beamFilename = addressbookPersonalVCardName(); - if ( !QFile::exists( beamFilename ) ) - return; // can't beam a non-existent file - Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, - beamFilename ); - Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); - Opie::OPimContactAccess::List allList = access->allRecords(); - Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first - c = *it; - - delete access; - } else { - unlink( beamfile ); // delete if exists - mkdir("/tmp/obex/", 0755); - c = m_abView -> currentEntry(); - Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, - beamfile ); - Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); - access->add( c ); - access->save(); - delete access; - - beamFilename = beamfile; - } - - odebug << "Beaming: " << beamFilename << oendl; - - Ir *ir = new Ir( this ); - connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); - QString description = c.fullName(); - ir->send( beamFilename, description, "text/x-vCard" ); -} - void AddressbookWindow::beamDone( Ir *ir ) @@ -647,3 +554,3 @@ void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) { - bool needShow = FALSE; + bool needShow = false; odebug << "Receiving QCop-Call with message " << msg << oendl; @@ -653,2 +560,5 @@ void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) editPersonal(); + + // Categories might have changed, so reload + reloadCategories(); } else if (msg == "editPersonalAndClose()") { @@ -676,2 +586,5 @@ void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) editEntry( EditEntry ); + + // Categories might have changed, so reload + reloadCategories(); } else if ( msg == "beamBusinessCard()" ) { @@ -694,4 +607,4 @@ void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) // Deactivate Personal View.. - if ( actionPersonal->isOn() ){ - actionPersonal->setOn( false ); + if ( m_actionPersonal->isOn() ){ + m_actionPersonal->setOn( false ); slotPersonalView(); @@ -713,4 +626,4 @@ void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) // Deactivate Personal View.. - if ( actionPersonal->isOn() ){ - actionPersonal->setOn( false ); + if ( m_actionPersonal->isOn() ){ + m_actionPersonal->setOn( false ); slotPersonalView(); @@ -721,4 +634,7 @@ void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) m_abView -> setCurrentUid( uid ); - slotViewEdit(); - } + slotItemEdit(); + + // Categories might have changed, so reload + reloadCategories(); + } @@ -726,3 +642,2 @@ void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) QPEApplication::setKeepRunning(); - } @@ -742,5 +657,5 @@ void AddressbookWindow::editEntry( EntryMode entryMode ) - // fix the foxus... + // fix the focus... abEditor->setNameFocus(); - if ( QPEApplication::execDialog( abEditor ) ) { + if ( QPEApplication::execDialog( abEditor ) == QDialog::Accepted ) { setFocus(); @@ -759,5 +674,6 @@ void AddressbookWindow::editEntry( EntryMode entryMode ) } - } - // populateCategories(); + // Categories might have changed, so reload + reloadCategories(); + } } @@ -770,5 +686,5 @@ void AddressbookWindow::editPersonal() // but take care of the menu, too - if ( ! actionPersonal->isOn() ){ + if ( ! m_actionPersonal->isOn() ){ odebug << "*** ++++" << oendl; - actionPersonal->setOn( true ); + m_actionPersonal->setOn( true ); slotPersonalView(); @@ -790,37 +706,18 @@ void AddressbookWindow::slotPersonalView() { - odebug << "slotPersonalView()" << oendl; - if (!actionPersonal->isOn()) { - // we just turned it off - odebug << "slotPersonalView()-> OFF" << oendl; - setCaption( tr("Contacts") ); - actionNew->setEnabled(TRUE); - actionTrash->setEnabled(TRUE); - actionFind->setEnabled(TRUE); - actionMail->setEnabled(TRUE); - // slotUpdateToolbar(); - - m_abView->showPersonal( false ); + odebug << "slotPersonalView()" << oendl; - return; - } - - odebug << "slotPersonalView()-> ON" << oendl; - // XXX need to disable some QActions. - actionNew->setEnabled(FALSE); - actionTrash->setEnabled(FALSE); - actionFind->setEnabled(FALSE); - actionMail->setEnabled(FALSE); + bool personal = m_actionPersonal->isOn(); - setCaption( tr("Contacts - My Personal Details") ); + // Disable certain menu items when showing personal details + setItemNewEnabled( !personal ); + setItemDuplicateEnabled( !personal ); + setItemDeleteEnabled( !personal ); + m_actionMail->setEnabled( !personal ); - m_abView->showPersonal( true ); + // Display appropriate view + m_abView->showPersonal( personal ); -} - - -void AddressbookWindow::listIsEmpty( bool empty ) -{ - if ( !empty ) { - deleteButton->setEnabled( TRUE ); - } + // Set application caption + personal ? setCaption( tr( "Contacts - My Personal Details") ) + : setCaption( tr( "Contacts") ); } @@ -829,3 +726,3 @@ void AddressbookWindow::reload() { - syncing = FALSE; + syncing = false; m_abView->clear(); @@ -836,3 +733,3 @@ void AddressbookWindow::flush() { - syncing = TRUE; + syncing = true; m_abView->save(); @@ -865,3 +762,3 @@ void AddressbookWindow::closeEvent( QCloseEvent *e ) /* - Returns TRUE if it is OK to exit + Returns true if it is OK to exit */ @@ -879,7 +776,7 @@ bool AddressbookWindow::save() != QMessageBox::No ) - return TRUE; + return true; else - return FALSE; + return false; } - return TRUE; + return true; } @@ -911,59 +808,9 @@ void AddressbookWindow::slotWrapAround() -void AddressbookWindow::slotSetCategory( int c ) +void AddressbookWindow::slotSetCategory( const QString &category ) { - odebug << "void AddressbookWindow::slotSetCategory( " << c << " ) from " - << catMenu->count() << oendl; - - QString cat, book; - AbView::Views view = AbView::TableView; - - if ( c <= 0 ) - return; - - // Switch view - if ( c < 3 ) - for ( unsigned int i = 1; i < 3; i++ ){ - if ( catMenu ) - catMenu->setItemChecked( i, c == (int)i ); - } - else - // Checkmark Category Menu Item Selected - for ( unsigned int i = 3; i < catMenu->count(); i++ ) - catMenu->setItemChecked( i, c == (int)i ); - - // Now switch to the selected category - for ( unsigned int i = 1; i < catMenu->count(); i++ ) { - if (catMenu->isItemChecked( i )) { - if ( i == 1 ){ // default List view - book = QString::null; - view = AbView::TableView; - }else if ( i == 2 ){ - book = tr( "Cards" ); - view = AbView::CardView; -// }else if ( i == 3 ){ -// book = tr( "Personal" ); -// view = AbView:: PersonalView; - }else if ( i == 3 ){ // default All Categories - cat = QString::null; - }else if ( i == (unsigned int)catMenu->count() - 1 ){ // last menu option (seperator is counted, too) will be Unfiled - cat = "Unfiled"; - odebug << "Unfiled selected!" << oendl; - }else{ - cat = m_abView->categories()[i - 4]; - } - } - } - - // Switch to the selected View - slotViewSwitched( view ); + odebug << "void AddressbookWindow::slotSetCategory( " << category << " )" << oendl; // Tell the view about the selected category - m_abView -> setShowByCategory( cat ); - - if ( book.isEmpty() ) - book = "List"; - if ( cat.isEmpty() ) - cat = "All"; - - setCaption( tr( "Contacts" ) + " - " + book + " - " + tr( cat ) ); + m_config.setCategory( category ); + m_abView -> setShowByCategory( category ); } @@ -973,21 +820,2 @@ void AddressbookWindow::slotViewSwitched( int view ) odebug << "void AddressbookWindow::slotViewSwitched( " << view << " )" << oendl; - int menu = 0; - - // Switch to selected view - switch ( view ){ - case AbView::TableView: - menu = 1; - m_tableViewButton->setOn(true); - m_cardViewButton->setOn(false); - break; - case AbView::CardView: - menu = 2; - m_tableViewButton->setOn(false); - m_cardViewButton->setOn(true); - break; - } - for ( unsigned int i = 1; i < 3; i++ ){ - if ( catMenu ) - catMenu->setItemChecked( i, menu == (int)i ); - } @@ -1015,35 +843 @@ void AddressbookWindow::slotSetLetter( char c ) { - -void AddressbookWindow::populateCategories() -{ - catMenu->clear(); - - int id, rememberId; - id = 1; - rememberId = 0; - - catMenu->insertItem( Resource::loadPixmap( "addressbook/listview" ), tr( "List" ), id++ ); - catMenu->insertItem( Resource::loadPixmap( "addressbook/cardview" ), tr( "Cards" ), id++ ); -// catMenu->insertItem( tr( "Personal" ), id++ ); - catMenu->insertSeparator(); - - catMenu->insertItem( tr( "All" ), id++ ); - QStringList categories = m_abView->categories(); - categories.append( tr( "Unfiled" ) ); - for ( QStringList::Iterator it = categories.begin(); - it != categories.end(); ++it ) { - catMenu->insertItem( *it, id ); - if ( *it == m_abView -> showCategory() ) - rememberId = id; - ++id; - } - - - if ( m_abView -> showCategory().isEmpty() ) { - slotSetCategory( 3 ); - } - else { - slotSetCategory( rememberId ); - } -} - diff --git a/core/pim/addressbook/addressbook.h b/core/pim/addressbook/addressbook.h index 7cc61bf..b04e2cc 100644 --- a/core/pim/addressbook/addressbook.h +++ b/core/pim/addressbook/addressbook.h @@ -25,3 +25,4 @@ -#include <qmainwindow.h> +#include <opie2/opimmainwindow.h> + #include <qvaluelist.h> @@ -43,4 +44,5 @@ class QAction; class LetterPicker; +class Opie::OPimRecord; -class AddressbookWindow: public QMainWindow +class AddressbookWindow: public Opie::OPimMainWindow { @@ -71,23 +73,30 @@ public slots: +protected slots: + int create(); + bool remove( int uid ); + void beam( int uid ); + void show( int uid ); + void edit( int uid ); + void add( const Opie::OPimRecord& ); + private slots: + void slotItemNew(); + void slotItemEdit(); + void slotItemDuplicate(); + void slotItemDelete(); + void slotItemBeam(); + void slotItemFind(); + void slotConfigure(); + void importvCard(); void exportvCard(); - void slotListNew(); -/* void slotListView(); */ - void slotListDelete(); void slotViewBack(); - void slotViewEdit(); void slotPersonalView(); - void listIsEmpty( bool ); -/* void slotSettings(); */ void writeMail(); - void slotBeam(); void beamDone( Ir * ); - void slotSetCategory( int ); + void slotSetCategory( const QString &category ); void slotSetLetter( char ); - void slotUpdateToolbar(); void slotSetFont(int); - void slotFindOpen(); - void slotFindClose(); + void slotShowFind( bool show ); void slotFind(); @@ -100,10 +109,4 @@ private slots: - void slotConfig(); - private: - void populateCategories(); - - QPopupMenu *catMenu; QToolBar *listTools; - QToolButton *deleteButton; enum Panes { paneList=0, paneView, paneEdit }; @@ -112,9 +115,9 @@ private: AbView* m_abView; - QWidget *listContainer; + QWidget *m_listContainer; // Searching stuff - OFloatBar* searchBar; - QLineEdit* searchEdit; + OFloatBar* m_searchBar; + QLineEdit* m_searchEdit; - QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, *actionPersonal, *actionMail; + QAction *m_actionPersonal, *m_actionMail; @@ -130,5 +133,2 @@ private: - QAction* m_tableViewButton; - QAction* m_cardViewButton; - int active_view; diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp index b078968..dec4c7c 100644 --- a/core/pim/addressbook/contacteditor.cpp +++ b/core/pim/addressbook/contacteditor.cpp @@ -33,3 +33,2 @@ #include <qlabel.h> -#include <qtabwidget.h> #include <qlayout.h> @@ -60,3 +59,3 @@ ContactEditor::ContactEditor( const Opie::OPimContact &entry, WFlags ) - : QDialog( parent, name, TRUE, WStyle_ContextHelp ), + : QDialog( parent, name, true, WStyle_ContextHelp ), defaultEmailChooserPosition( -1 ), @@ -121,10 +120,10 @@ void ContactEditor::init() { - tabMain = new QTabWidget( this ); + tabMain = new Opie::Ui::OTabWidget( this ); vb->addWidget( tabMain ); - QWidget *tabViewport = new QWidget ( tabMain ); + m_generalWidget = new QWidget ( tabMain ); - vb = new QVBoxLayout( tabViewport ); + vb = new QVBoxLayout( m_generalWidget ); - svGeneral = new QScrollView( tabViewport ); + svGeneral = new QScrollView( m_generalWidget ); vb->addWidget( svGeneral, 0, 0 ); @@ -138,4 +137,3 @@ void ContactEditor::init() { - QGridLayout *gl = new QGridLayout( container, 1, 1, 2, 4 ); - gl->setResizeMode( QLayout::FreeResize ); + QGridLayout *gl = new QGridLayout( container, 10, 2, 2, 4 ); @@ -170,3 +168,3 @@ void ContactEditor::init() { // Chooser 1 - cmbChooserField1 = new QComboBox( FALSE, container ); + cmbChooserField1 = new QComboBox( false, container ); QWhatsThis::add( cmbChooserField1, tr( "Press to select attribute to change" ) ); @@ -183,3 +181,3 @@ void ContactEditor::init() { // Chooser 2 - cmbChooserField2 = new QComboBox( FALSE, container ); + cmbChooserField2 = new QComboBox( false, container ); QWhatsThis::add( cmbChooserField2, tr( "Press to select attribute to change" ) ); @@ -196,3 +194,3 @@ void ContactEditor::init() { // Chooser 3 - cmbChooserField3 = new QComboBox( FALSE, container ); + cmbChooserField3 = new QComboBox( false, container ); QWhatsThis::add( cmbChooserField3, tr( "Press to select attribute to change" ) ); @@ -211,3 +209,3 @@ void ContactEditor::init() { gl->addWidget( l, 7, 0 ); - cmbFileAs = new QComboBox( TRUE, container ); + cmbFileAs = new QComboBox( true, container ); gl->addWidget( cmbFileAs, 7, 1 ); @@ -221,8 +219,8 @@ void ContactEditor::init() { - btnNote = new QPushButton( tr( "Notes..." ), container ); + btnNote = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Notes..." ), container ); gl->addWidget( btnNote, 9, 1 ); - tabMain->insertTab( tabViewport, tr( "General" ) ); + tabMain->addTab( m_generalWidget, "addressbook/AddressBookSmall", tr( "General" ) ); - tabViewport = new QWidget ( tabMain ); + QWidget *tabViewport = new QWidget ( tabMain ); @@ -240,3 +238,3 @@ void ContactEditor::init() { - cmbAddress = new QComboBox( FALSE, container ); + cmbAddress = new QComboBox( false, container ); cmbAddress->insertItem( tr( "Business" ) ); @@ -267,3 +265,3 @@ void ContactEditor::init() { gl->addWidget( l, 5, 0 ); - cmbCountry = new QComboBox( TRUE, container ); + cmbCountry = new QComboBox( true, container ); cmbCountry->insertItem( "" ); @@ -487,3 +485,3 @@ void ContactEditor::init() { // Chooser 4 - cmbChooserField4 = new QComboBox( FALSE, container ); + cmbChooserField4 = new QComboBox( false, container ); cmbChooserField4->setMaximumWidth( 90 ); @@ -503,3 +501,3 @@ void ContactEditor::init() { - tabMain->insertTab( tabViewport, tr( "Address" ) ); + tabMain->addTab( tabViewport, "home", tr( "Address" ) ); @@ -527,3 +525,3 @@ void ContactEditor::init() { QPopupMenu* m1 = new QPopupMenu( container ); - birthdayPicker = new DateBookMonth( m1, 0, TRUE ); + birthdayPicker = new DateBookMonth( m1, 0, true ); m1->insertItem( birthdayPicker ); @@ -552,3 +550,3 @@ void ContactEditor::init() { m1 = new QPopupMenu( container ); - anniversaryPicker = new DateBookMonth( m1, 0, TRUE ); + anniversaryPicker = new DateBookMonth( m1, 0, true ); m1->insertItem( anniversaryPicker ); @@ -601,5 +599,5 @@ void ContactEditor::init() { - tabMain->insertTab( tabViewport, tr( "Details" ) ); + tabMain->addTab( tabViewport, "UtilsIcon", tr( "Details" ) ); - dlgNote = new QDialog( this, "Note Dialog", TRUE ); + dlgNote = new QDialog( this, "Note Dialog", true ); dlgNote->setCaption( tr("Enter Note") ); @@ -610,3 +608,3 @@ void ContactEditor::init() { - dlgName = new QDialog( this, "Name Dialog", TRUE ); + dlgName = new QDialog( this, "Name Dialog", true ); dlgName->setCaption( tr("Edit Name") ); @@ -1095,3 +1093,3 @@ void ContactEditor::slotName() { if ( QPEApplication::execDialog( dlgName ) ) { - if ( txtLastName->text().contains( ' ', TRUE ) ) + if ( txtLastName->text().contains( ' ', true ) ) tmpName = txtLastName->text() + ", " + txtFirstName->text() + " " + txtMiddleName->text(); @@ -1140,3 +1138,3 @@ QString ContactEditor::parseName( const QString fullName, int type ) { - commapos = simplifiedName.find( ',', 0, TRUE); + commapos = simplifiedName.find( ',', 0, true); if ( commapos >= 0 ) { @@ -1264,3 +1262,3 @@ void ContactEditor::setEntry( const Opie::OPimContact &entry ) { cleanupFields(); - tabMain->setCurrentPage( 0 ); + tabMain->setCurrentTab( m_generalWidget ); @@ -1285,3 +1283,3 @@ void ContactEditor::setEntry( const Opie::OPimContact &entry ) { // Lastnames with multiple words need to be protected by a comma ! - if ( ent.lastName().contains( ' ', TRUE ) ) + if ( ent.lastName().contains( ' ', true ) ) txtFullName->setText( ent.lastName() + ", " + ent.firstName() + " " + ent.middleName() ); @@ -1689,4 +1687,4 @@ static inline bool containsAlphaNum( const QString &str ) if ( !str[i].isSpace() ) - return TRUE; - return FALSE; + return true; + return false; } @@ -1699,4 +1697,4 @@ static inline bool constainsWhiteSpace( const QString &str ) if ( str[i].isSpace() ) - return TRUE; - return FALSE; + return true; + return false; } diff --git a/core/pim/addressbook/contacteditor.h b/core/pim/addressbook/contacteditor.h index 1b86e6f..f3cbbd4 100644 --- a/core/pim/addressbook/contacteditor.h +++ b/core/pim/addressbook/contacteditor.h @@ -25,2 +25,3 @@ #include <opie2/opimcontactfields.h> +#include <opie2/otabwidget.h> @@ -44,5 +45,3 @@ const int NAME_S = 7; - class QScrollView; -class QTabWidget; class QMultiLineEdit; @@ -146,3 +145,4 @@ class ContactEditor : public QDialog { - QTabWidget *tabMain; + Opie::Ui::OTabWidget *tabMain; + QWidget *m_generalWidget; QScrollView *svGeneral; |