author | eilers <eilers> | 2004-12-20 14:19:24 (UTC) |
---|---|---|
committer | eilers <eilers> | 2004-12-20 14:19:24 (UTC) |
commit | 29f05e7138a05c2c32cad8b40fd432cd383964a9 (patch) (side-by-side diff) | |
tree | 2f80ace57f99ce24ac8c1e8a556c08e07ca18019 | |
parent | 18e47153532d016d878f47e0ce11cb1a9716218e (diff) | |
download | opie-29f05e7138a05c2c32cad8b40fd432cd383964a9.zip opie-29f05e7138a05c2c32cad8b40fd432cd383964a9.tar.gz opie-29f05e7138a05c2c32cad8b40fd432cd383964a9.tar.bz2 |
Fix for Bug #1269 and use of new sorted of the pim libary
-rw-r--r-- | core/pim/addressbook/abview.cpp | 27 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 7 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.h | 2 | ||||
-rw-r--r-- | core/pim/addressbook/version.h | 2 |
4 files changed, 28 insertions, 10 deletions
diff --git a/core/pim/addressbook/abview.cpp b/core/pim/addressbook/abview.cpp index 7abb45c..6be19f8 100644 --- a/core/pim/addressbook/abview.cpp +++ b/core/pim/addressbook/abview.cpp @@ -128,73 +128,81 @@ void AbView::replaceEntry( const Opie::OPimContact &contact ) } Opie::OPimContact AbView::currentEntry() { Opie::OPimContact currentContact; switch ( (int) m_curr_View ) { case TableView: currentContact = m_abTable -> currentEntry(); break; case CardView: currentContact = m_ablabel -> currentEntry(); break; } m_curr_Contact = currentContact.uid(); return currentContact; } bool AbView::save() { // odebug << "AbView::Save data" << oendl; return m_contactdb->save(); } void AbView::load() { odebug << "AbView::Load data" << oendl; // Letter Search is stopped at this place emit signalClearLetterPicker(); - if ( m_inPersonal ) - // VCard Backend does not sort.. - m_list = m_contactdb->allRecords(); - else{ - m_list = m_contactdb->sorted( true, 0, 0, 0 ); - if ( m_curr_category != -1 ) - clearForCategory(); + if ( m_curr_category == 0 ) { + // Show unfiled + m_list = m_contactdb->sorted( true, Opie::OPimContactAccess::SortFileAsName, + Opie::OPimContactAccess::DoNotShowWithCategory, 0 ); + } else if ( m_curr_category != -1 ){ + // Just show selected category + m_list = m_contactdb->sorted( true, Opie::OPimContactAccess::SortFileAsName, + Opie::OPimBase::FilterCategory, m_curr_category ); + } else { + // Show all categories + m_list = m_contactdb->sorted( true, Opie::OPimContactAccess::SortFileAsName, + Opie::OPimBase::FilterOff, 0 ); } +// if ( m_curr_category != -1 ) +// clearForCategory(); + odebug << "Number of contacts: " << m_list.count() << oendl; updateView( true ); } void AbView::reload() { odebug << "AbView::::reload()" << oendl; m_contactdb->reload(); load(); } void AbView::clear() { // :SX } void AbView::setShowByCategory( const QString& cat ) { odebug << "AbView::setShowCategory( const QString& cat )" << oendl; int intCat = 0; // All (cat == NULL) will be stored as -1 if ( cat.isNull() ) intCat = -1; else intCat = mCat.id("Contacts", cat ); // Just do anything if we really change the category @@ -208,65 +216,68 @@ void AbView::setShowByCategory( const QString& cat ) load(); } } void AbView::setShowToView( Views view ) { odebug << "void AbView::setShowToView( View " << view << " )" << oendl; if ( m_curr_View != view ){ odebug << "Change the View (Category is: " << m_curr_category << ")" << oendl; m_prev_View = m_curr_View; m_curr_View = view; updateView(); } } void AbView::setShowByLetter( char c, AbConfig::LPSearchMode mode ) { odebug << "void AbView::setShowByLetter( " << c << ", " << mode << " )" << oendl; assert( mode < AbConfig::LASTELEMENT ); Opie::OPimContact query; if ( c == 0 ){ load(); return; }else{ // If the current Backend is unable to solve the query, we will // ignore the request .. - if ( ! m_contactdb->hasQuerySettings( Opie::OPimContactAccess::WildCards | Opie::OPimContactAccess::IgnoreCase ) ){ + if ( ! m_contactdb->hasQuerySettings( Opie::OPimContactAccess::WildCards | + Opie::OPimContactAccess::IgnoreCase ) ){ + owarn << "Tried to access queryByExample which is not supported by the current backend!!" << oendl; + owarn << "I have to ignore this access!" << oendl; return; } switch( mode ){ case AbConfig::LastName: query.setLastName( QString("%1*").arg(c) ); break; case AbConfig::FileAs: query.setFileAs( QString("%1*").arg(c) ); break; default: owarn << "Unknown Searchmode for AbView::setShowByLetter ! -> " << mode << oendl << "I will ignore it.." << oendl; return; } m_list = m_contactdb->queryByExample( query, Opie::OPimContactAccess::WildCards | Opie::OPimContactAccess::IgnoreCase ); if ( m_curr_category != -1 ) clearForCategory(); m_curr_Contact = 0; } updateView( true ); } void AbView::setListOrder( const QValueList<int>& ordered ) { m_orderedFields = ordered; if ( m_abTable ){ m_abTable->setOrderedList( ordered ); m_abTable->refresh(); } updateView(); } diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index 835038a..0654e1a 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp @@ -323,64 +323,71 @@ void AddressbookWindow::importvCard() { } } void AddressbookWindow::exportvCard() { odebug << "void AddressbookWindow::exportvCard()" << oendl; QString filename = Opie::Ui::OFileDialog::getSaveFileName( 1,"/home/"); //,"", "*", this ); if( !filename.isEmpty() && ( filename[filename.length()-1] != '/' ) ){ odebug << " Save to file " << filename << ", (" << filename.length()-1 << ")" << oendl; Opie::OPimContact curCont = m_abView->currentEntry(); if ( !curCont.isEmpty() ){ Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, filename ); Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook_exp", QString::null , vcard_backend, true ); if ( access ){ access->add( curCont ); access->save(); } delete access; }else QMessageBox::critical( 0, "Export VCard", QString( tr( "You have to select a contact !") ) ); }else QMessageBox::critical( 0, "Export VCard", QString( tr( "You have to set a filename !") ) ); } void AddressbookWindow::setDocument( const QString &filename ) { odebug << "void AddressbookWindow::setDocument( " << filename << " )" << oendl; + // Switch to default backend. This should avoid to import into + // the personal database accidently. + if ( actionPersonal->isOn() ){ + actionPersonal->setOn( false ); + slotPersonalView(); + } + if ( filename.find(".vcf") != int(filename.length()) - 4 ){ switch( QMessageBox::information( this, tr ( "Right file type ?" ), tr( "The selected file \n does not end with \".vcf\".\n Do you really want to open it?" ), tr( "&Yes" ), tr( "&No" ), QString::null, 0, // Enter == button 0 2 ) ) { // Escape == button 2 case 0: odebug << "YES clicked" << oendl; break; case 1: odebug << "NO clicked" << oendl; return; break; } } Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, filename ); Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); Opie::OPimContactAccess::List allList = access->allRecords(); odebug << "Found number of contacts in File: " << allList.count() << oendl; if ( !allList.count() ) { QMessageBox::information( this, "Import VCard", "It was impossible to import\nthe VCard.\n" "The VCard may be corrupted!" ); } bool doAsk = true; diff --git a/core/pim/addressbook/addressbook.h b/core/pim/addressbook/addressbook.h index 9217e95..7cc61bf 100644 --- a/core/pim/addressbook/addressbook.h +++ b/core/pim/addressbook/addressbook.h @@ -35,65 +35,65 @@ class ContactEditor; class AbLabel; class AbTable; class QToolBar; class QPopupMenu; class QToolButton; class QDialog; class Ir; class QAction; class LetterPicker; class AddressbookWindow: public QMainWindow { Q_OBJECT public: enum EntryMode { NewEntry=0, EditEntry }; static QString appName() { return QString::fromLatin1("addressbook"); } AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); ~AddressbookWindow(); protected: void resizeEvent( QResizeEvent * e ); void editPersonal(); void editEntry( EntryMode ); void closeEvent( QCloseEvent *e ); bool save(); public slots: void flush(); void reload(); void appMessage(const QCString &, const QByteArray &); - void setDocument( const QString & ); + void setDocument( const QString & ); // Called by obex receiver and internally! #ifdef __DEBUG_RELEASE // void slotSave(); #endif private slots: 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 slotSetLetter( char ); void slotUpdateToolbar(); void slotSetFont(int); void slotFindOpen(); void slotFindClose(); void slotFind(); void slotNotFound(); void slotWrapAround(); void slotViewSwitched( int ); void slotListView(); void slotCardView(); diff --git a/core/pim/addressbook/version.h b/core/pim/addressbook/version.h index 790aa95..7ce9752 100644 --- a/core/pim/addressbook/version.h +++ b/core/pim/addressbook/version.h @@ -1,10 +1,10 @@ #ifndef _VERSION_H_ #define _VERSION_H_ #define MAINVERSION "1" #define SUBVERSION "1" -#define PATCHVERSION "0" +#define PATCHVERSION "1" #define APPNAME "OPIE_ADDRESSBOOK" #endif |