summaryrefslogtreecommitdiff
path: root/core
authoreilers <eilers>2003-05-09 08:40:42 (UTC)
committer eilers <eilers>2003-05-09 08:40:42 (UTC)
commitfd1f8bdfc8bad5a0344468118c66c6afe3044fde (patch) (side-by-side diff)
tree58f18282117f9b524c13221f6a54c7bbc94a5827 /core
parenta82928a004882e9aba652061fc6ecffb85d403cf (diff)
downloadopie-fd1f8bdfc8bad5a0344468118c66c6afe3044fde.zip
opie-fd1f8bdfc8bad5a0344468118c66c6afe3044fde.tar.gz
opie-fd1f8bdfc8bad5a0344468118c66c6afe3044fde.tar.bz2
Added two QCop functions for OSearch:
editUid(int), showUid(int)..
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/abview.cpp7
-rw-r--r--core/pim/addressbook/abview.h1
-rw-r--r--core/pim/addressbook/addressbook.cpp52
3 files changed, 35 insertions, 25 deletions
diff --git a/core/pim/addressbook/abview.cpp b/core/pim/addressbook/abview.cpp
index b89b794..d3ca783 100644
--- a/core/pim/addressbook/abview.cpp
+++ b/core/pim/addressbook/abview.cpp
@@ -251,96 +251,103 @@ void AbView::setListOrder( const QValueList<int>& ordered )
}
QString AbView::showCategory() const
{
return mCat.label( "Contacts", m_curr_category );
}
void AbView::showPersonal( bool personal )
{
// qWarning ("void AbView::showPersonal( %d )", personal);
if ( personal ){
if ( m_inPersonal )
return;
// Now switch to vCard Backend and load data.
// The current default backend will be stored
// to avoid unneeded load/stores.
m_storedDB = m_contactdb;
OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
addressbookPersonalVCardName() );
m_contactdb = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
m_inPersonal = true;
m_curr_View = CardView;
}else{
if ( !m_inPersonal )
return;
// Remove vCard Backend and restore default
m_contactdb->save();
delete m_contactdb;
m_contactdb = m_storedDB;
m_storedDB = 0l;
m_curr_View = TableView;
m_inPersonal = false;
}
load();
}
+void AbView::setCurrentUid( int uid ){
+
+ m_curr_Contact = uid;
+ updateView( true ); //true: Don't modificate the UID !
+}
+
+
QStringList AbView::categories()
{
mCat.load( categoryFileName() );
QStringList categoryList = mCat.labels( "Contacts" );
return categoryList;
}
// BEGIN: Slots
void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp,
bool , QString cat )
{
// qWarning( "void AbView::slotDoFind" );
// We reloading the data: Deselect Letterpicker
emit signalClearLetterPicker();
// Use the current Category if nothing else selected
int category = 0;
if ( cat.isEmpty() )
category = m_curr_category;
else{
category = mCat.id("Contacts", cat );
}
// qWarning ("Find in Category %d", category);
QRegExp r( str );
r.setCaseSensitive( caseSensitive );
r.setWildcard( !useRegExp );
// Get all matching entries out of the database
m_list = m_contactdb->matchRegexp( r );
// qWarning( "found: %d", m_list.count() );
if ( m_list.count() == 0 ){
emit signalNotFound();
return;
}
// Now remove all contacts with wrong category (if any selected)
// This algorithm is a litte bit ineffective, but
// we will not have a lot of matching entries..
clearForCategory();
// Now show all found entries
updateView( true );
}
diff --git a/core/pim/addressbook/abview.h b/core/pim/addressbook/abview.h
index 8570fe7..55c63cc 100644
--- a/core/pim/addressbook/abview.h
+++ b/core/pim/addressbook/abview.h
@@ -1,79 +1,80 @@
#ifndef _ABVIEW_H_
#define _ABVIEW_H_
#include <qwidget.h>
#include <qwidgetstack.h>
#include <qpe/categories.h>
#include <opie/ocontact.h>
#include <opie/ocontactaccess.h>
#include "contacteditor.h"
#include "abtable.h"
#include "ablabel.h"
class AbView: public QWidget
{
Q_OBJECT
public:
enum Views{ TableView=0, CardView, PersonalView };
AbView( QWidget* parent, const QValueList<int>& ordered );
~AbView();
bool save();
void load();
void reload();
void clear();
void setView( Views view );
void showPersonal( bool personal );
+ void setCurrentUid( int uid );
void setShowByCategory( const QString& cat );
void setShowToView( Views view );
void setShowByLetter( char c );
void setListOrder( const QValueList<int>& ordered );
// Add Entry and put to current
void addEntry( const OContact &newContact );
void removeEntry( const int UID );
void replaceEntry( const OContact &contact );
OContact currentEntry();
void inSearch() { m_inSearch = true; }
void offSearch();
QString showCategory() const;
QStringList categories();
signals:
void signalNotFound();
void signalClearLetterPicker();
void signalViewSwitched ( int );
public slots:
void slotDoFind( const QString &str, bool caseSensitive, bool useRegExp,
bool backwards, QString category = QString::null );
void slotSwitch();
private:
void updateListinViews();
void updateView( bool newdata = false );
void clearForCategory();
bool contactCompare( const OContact &cnt, int category );
void parseName( const QString& name, QString *first, QString *middle,
QString * last );
Categories mCat;
bool m_inSearch;
bool m_inPersonal;
int m_curr_category;
Views m_curr_View;
Views m_prev_View;
int m_curr_Contact;
OContactAccess* m_contactdb;
OContactAccess* m_storedDB;
OContactAccess::List m_list;
QWidgetStack* m_viewStack;
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index 89a3312..e053e94 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -641,126 +641,128 @@ static void parseName( const QString& name, QString *first, QString *middle,
}
int space = rest.find( ' ' );
if ( space <= 0 ) {
*first = rest;
} else {
*first = rest.left( space );
*middle = rest.mid( space+1 );
}
}
void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data)
{
if (msg == "editPersonal()") {
editPersonal();
} else if (msg == "editPersonalAndClose()") {
editPersonal();
close();
} else if ( msg == "addContact(QString,QString)" ) {
QDataStream stream(data,IO_ReadOnly);
QString name, email;
stream >> name >> email;
OContact cnt;
QString fn, mn, ln;
parseName( name, &fn, &mn, &ln );
// qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() );
cnt.setFirstName( fn );
cnt.setMiddleName( mn );
cnt.setLastName( ln );
cnt.insertEmails( email );
cnt.setDefaultEmail( email );
cnt.setFileAs();
m_abView -> addEntry( cnt );
// :SXm_abView()->init( cnt );
editEntry( EditEntry );
} else if ( msg == "beamBusinessCard()" ) {
QString beamFilename = addressbookPersonalVCardName();
if ( !QFile::exists( beamFilename ) )
return; // can't beam a non-existent file
Ir *ir = new Ir( this );
connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
QString description = "mycard.vcf";
ir->send( beamFilename, description, "text/x-vCard" );
- }
-#if 0
- else if (msg == "pickAddresses(QCString,QCString,QStringList,...)" ) {
+ } else if ( msg == "showUid(int)" ) {
QDataStream stream(data,IO_ReadOnly);
- QCString ch,m;
- QStringList types;
- stream >> ch >> m >> types;
- AddressPicker picker(abList,this,0,TRUE);
- picker.showMaximized();
- picker.setChoiceNames(types);
- int i=0;
- for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) {
- QStringList sel;
- stream >> sel;
- picker.setSelection(i++,sel);
+ int uid;
+ stream >> uid;
+
+ // Deactivate Personal View..
+ if ( actionPersonal->isOn() ){
+ actionPersonal->setOn( false );
+ slotPersonalView();
}
- picker.showMaximized();
- picker.exec();
- // ###### note: contacts may have been added - save here!
+ // Reset category and show as card..
+ m_abView -> setShowByCategory( QString::null );
+ m_abView -> setCurrentUid( uid );
+ slotViewSwitched ( AbView::CardView );
+
+ } else if ( msg == "editUid(int)" ) {
+ QDataStream stream(data,IO_ReadOnly);
+ int uid;
+ stream >> uid;
- setCentralWidget(abList);
- QCopEnvelope e(ch,m);
- i=0;
- for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) {
- QStringList sel = picker.selection(i++);
- e << sel;
+ // Deactivate Personal View..
+ if ( actionPersonal->isOn() ){
+ actionPersonal->setOn( false );
+ slotPersonalView();
}
- }
-#endif
+
+ // Reset category and edit..
+ m_abView -> setShowByCategory( QString::null );
+ m_abView -> setCurrentUid( uid );
+ slotViewEdit();
+ }
}
void AddressbookWindow::editEntry( EntryMode entryMode )
{
OContact entry;
if ( !abEditor ) {
abEditor = new ContactEditor( entry, this, "editor" );
}
if ( entryMode == EditEntry )
abEditor->setEntry( m_abView -> currentEntry() );
else if ( entryMode == NewEntry )
abEditor->setEntry( entry );
// other things may change the caption.
abEditor->setCaption( tr("Edit Address") );
#if defined(Q_WS_QWS) || defined(_WS_QWS_)
abEditor->showMaximized();
#endif
// fix the foxus...
abEditor->setNameFocus();
if ( abEditor->exec() ) {
setFocus();
if ( entryMode == NewEntry ) {
OContact insertEntry = abEditor->entry();
insertEntry.assignUid();
m_abView -> addEntry( insertEntry );
} else {
OContact replEntry = abEditor->entry();
if ( !replEntry.isValidUid() )
replEntry.assignUid();
m_abView -> replaceEntry( replEntry );
}
}
// populateCategories();
}
void AddressbookWindow::editPersonal()
{
OContact entry;
// Switch to personal view if not selected
// but take care of the menu, too
if ( ! actionPersonal->isOn() ){
qWarning("*** ++++");