summaryrefslogtreecommitdiff
authoreilers <eilers>2002-10-16 10:55:17 (UTC)
committer eilers <eilers>2002-10-16 10:55:17 (UTC)
commit2bfae6336f88a460311abaf727256c3413b27f67 (patch) (side-by-side diff)
treef554fcecb260ef506a839f4d7994f427ad184555
parentf9756ca203a06fa60413ef1a96416d87b9dc1a6b (diff)
downloadopie-2bfae6336f88a460311abaf727256c3413b27f67.zip
opie-2bfae6336f88a460311abaf727256c3413b27f67.tar.gz
opie-2bfae6336f88a460311abaf727256c3413b27f67.tar.bz2
Fixed reload after sync- bug
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/pim/addressbook/TODO6
-rw-r--r--core/pim/addressbook/abtable.cpp17
-rw-r--r--core/pim/addressbook/abtable.h5
-rw-r--r--core/pim/addressbook/addressbook.cpp54
4 files changed, 21 insertions, 61 deletions
diff --git a/core/pim/addressbook/TODO b/core/pim/addressbook/TODO
index 32d2838..7bc906d 100644
--- a/core/pim/addressbook/TODO
+++ b/core/pim/addressbook/TODO
@@ -1,26 +1,28 @@
Stuff todo:
Urgent:
-- Syncing: abtable not reloaded after sync.
+
+- Font menu is invisible using german translation
Important:
- Finishing of new View functions (List, Phonebook...)
- Reload if contacts were changed externally
- "What's this" should be added
- The names of the countries are sorted by there english names, only..
Even if they are translated.. :S
- Store last settings of combo-boxes
Less important:
- Find widget should be replaced by something like
qpdf has.
- The picker (alphabetical sort widget) should be
placed verticaly or horizontally (configurable)
-Should be Fixed:
+Should be Fixed (not absolute sure, need validation):
- "Nonenglish" translation bug has to be fixed.
Fixed: \ No newline at end of file
+- Syncing: abtable not reloaded after sync.
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp
index 70c070f..91a7171 100644
--- a/core/pim/addressbook/abtable.cpp
+++ b/core/pim/addressbook/abtable.cpp
@@ -449,81 +449,84 @@ void AbTable::addEntry( const OContact &newCnt )
int row = numRows();
setNumRows( row + 1 );
insertIntoTable( newCnt, row );
qWarning("abtable:AddContact");
m_contactdb.add ( newCnt );
setCurrentCell( row, 0 );
// updateVisible();
}
void AbTable::resizeRows() {
/*
if (numRows()) {
for (int i = 0; i < numRows(); i++) {
setRowHeight( i, size );
}
}
updateVisible();
*/
}
-bool AbTable::save( const QString& /* fn */ )
+bool AbTable::save()
{
// QTime t;
// t.start();
qWarning("abtable:Save data");
- m_contactdb.save();
- return true;
+ return m_contactdb.save();
}
-void AbTable::load( const QString& /* fn */ )
+void AbTable::load()
{
setSorting( false );
setUpdatesEnabled( FALSE );
qWarning("abtable:Load data");
OContactAccess::List list = m_contactdb.allRecords();
OContactAccess::List::Iterator it;
setNumRows( list.count() );
int row = 0;
for ( it = list.begin(); it != list.end(); ++it )
insertIntoTable( *it, row++ );
- resort();
-
setUpdatesEnabled( TRUE );
setSorting( true );
- //resort();
+ resort();
}
+void AbTable::reload()
+{
+ m_contactdb.reload();
+ load();
+}
+
void AbTable::realignTable( int row )
{
QTableItem *ti1,
*ti2;
int totalRows = numRows();
for ( int curr = row; curr < totalRows - 1; curr++ ) {
// the same info from the todo list still applies, but I
// don't think it is _too_ bad.
ti1 = item( curr + 1, 0 );
ti2 = item( curr + 1, 1 );
takeItem( ti1 );
takeItem( ti2 );
setItem( curr, 0, ti1 );
setItem( curr, 1, ti2 );
}
setNumRows( totalRows - 1 );
resort();
}
// Add contact into table.
void AbTable::insertIntoTable( const OContact &cnt, int row )
{
QString strName,
strContact;
diff --git a/core/pim/addressbook/abtable.h b/core/pim/addressbook/abtable.h
index 84aef1e..80c3ca0 100644
--- a/core/pim/addressbook/abtable.h
+++ b/core/pim/addressbook/abtable.h
@@ -56,50 +56,51 @@ public:
private:
QGuardedPtr<QComboBox> cb;
};
class AbTable : public QTable
{
Q_OBJECT
public:
AbTable( const QValueList<int> *ordered, QWidget *parent, const char *name=0 );
~AbTable();
// NEW
void addEntry( const OContact &newContact );
OContact currentEntry();
void replaceCurrentEntry( const OContact &newContact );
void init();
void deleteCurrentEntry();
void clear();
void clearFindRow() { currFindRow = -2; }
void loadFields();
void refresh();
- bool save( const QString &fn );
- void load( const QString &fn );
+ bool save();
+ void load();
+ void reload();
// addresspicker mode
void setChoiceNames( const QStringList& list);
QStringList choiceNames() const;
void setChoiceSelection(int index, const QStringList& list);
QStringList choiceSelection(int index) const;
void setShowCategory( const QString &b, const QString &c );
void setShowByLetter( char c );
QString showCategory() const;
QStringList categories();
void resizeRows();
void show();
void setPaintingEnabled( bool e );
QString showBook() const;
public slots:
void slotDoFind( const QString &str, bool caseSensitive, bool backwards,
int category );
signals:
void empty( bool );
void details();
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index 2eb9ddf..93581e8 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -46,60 +46,48 @@
#include <qaction.h>
#include <qdialog.h>
#include <qdir.h>
#include <qfile.h>
#include <qimage.h>
#include <qlayout.h>
#include <qpe/qpemenubar.h>
#include <qmessagebox.h>
#include <qpixmap.h>
#include <qpopupmenu.h>
#include <qpe/qpetoolbar.h>
#include <qstringlist.h>
#include <qtoolbutton.h>
#include <qwhatsthis.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <qdatetime.h>
#include "picker.h"
-static QString addressbookOldXMLFilename()
-{
- QString filename = QPEApplication::documentDir() + "addressbook.xml";
- return filename;
-}
-
-static QString addressbookXMLFilename()
-{
- QString filename = Global::applicationFileName("addressbook",
- "addressbook.xml");
- return filename;
-}
static QString addressbookPersonalVCardName()
{
QString filename = Global::applicationFileName("addressbook",
"businesscard.vcf");
return filename;
}
AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
WFlags f )
: QMainWindow( parent, name, f ),
abEditor(0),
bAbEditFirstTime(TRUE),
syncing(FALSE)
{
isLoading = true;
initFields();
setCaption( tr("Contacts") );
setIcon( Resource::loadPixmap( "AddressBook" ) );
setToolBarsMovable( FALSE );
@@ -181,81 +169,62 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
a->addTo( edit );
a->addTo( listTools );
}
edit->insertSeparator();
a = new QAction( tr("Import vCard"), QString::null, 0, 0, 0, TRUE );
actionPersonal = a;
connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) );
a->addTo( edit );
edit->insertSeparator();
a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE );
actionPersonal = a;
connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) );
a->addTo( edit );
a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
a->addTo( edit );
// Create Views
-
- // This is safe to call without checking to see if it exists...
- // not to mention it also does the necessary stuff for the
- // journaling...
- QString str = addressbookXMLFilename();
- if ( str.isNull() ) {
- QMessageBox::warning(
- this,
- tr("Out of Space"),
- tr("There is not enough space to create\n"
- "neccessary startup files.\n"
- "\nFree up some space before\nentering data!")
- );
- }
-
listContainer = new QWidget( this );
QVBoxLayout *vb = new QVBoxLayout( listContainer );
abList = new AbTable( &orderedFields, listContainer, "table" );
vb->addWidget(abList);
// abList->setHScrollBarMode( QScrollView::AlwaysOff );
connect( abList, SIGNAL( empty( bool ) ), this, SLOT( listIsEmpty( bool ) ) );
connect( abList, SIGNAL( details() ), this, SLOT( slotListView() ) );
connect( abList, SIGNAL(currentChanged(int,int)), this, SLOT(slotUpdateToolbar()) );
mView = 0;
- abList->load( addressbookXMLFilename() );
- if ( QFile::exists(addressbookOldXMLFilename()) ) {
- abList->load( addressbookOldXMLFilename() );
- QFile::remove(addressbookOldXMLFilename());
- }
+ abList->load();
pLabel = new LetterPicker( listContainer );
connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char)));
vb->addWidget(pLabel);
catMenu = new QPopupMenu( this );
catMenu->setCheckable( TRUE );
connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) );
populateCategories();
mbList->insertItem( tr("View"), catMenu );
// setCentralWidget( listContainer );
fontMenu = new QPopupMenu(this);
fontMenu->setCheckable( true );
connect( fontMenu, SIGNAL(activated(int)), this, SLOT(slotSetFont(int)));
fontMenu->insertItem(tr( "Small" ), 0);
fontMenu->insertItem(tr( "Normal" ), 1);
fontMenu->insertItem(tr( "Large" ), 2);
defaultFont = new QFont( abList->font() );
slotSetFont(startFontSize);
@@ -688,121 +657,106 @@ void AddressbookWindow::editEntry( EntryMode entryMode )
insertEntry.assignUid();
abList->addEntry( insertEntry );
} else {
OContact replaceEntry = abEditor->entry();
if ( !replaceEntry.isValidUid() )
replaceEntry.assignUid();
abList->replaceCurrentEntry( replaceEntry );
}
}
populateCategories();
showList();
}
void AddressbookWindow::listIsEmpty( bool empty )
{
if ( !empty ) {
deleteButton->setEnabled( TRUE );
}
}
void AddressbookWindow::reload()
{
syncing = FALSE;
abList->clear();
- abList->load( addressbookXMLFilename() );
+ abList->reload();
}
void AddressbookWindow::flush()
{
syncing = TRUE;
- abList->save( addressbookXMLFilename() );
+ abList->save();
}
void AddressbookWindow::closeEvent( QCloseEvent *e )
{
if ( centralWidget() == mView ) {
if (actionPersonal->isOn()) {
// pretend we clicked it off
actionPersonal->setOn(FALSE);
slotPersonalView();
} else {
showList();
}
e->ignore();
return;
}
if(syncing) {
/* shouldn't we save, I hear you say? well its already been set
so that an edit can not occur during a sync, and we flushed
at the start of the sync, so there is no need to save
Saving however itself would cause problems. */
e->accept();
return;
}
//################## shouldn't always save
// True, but the database handles this automatically ! (se)
if ( save() )
e->accept();
else
e->ignore();
}
/*
Returns TRUE if it is OK to exit
*/
bool AddressbookWindow::save()
{
- QString str = addressbookXMLFilename();
- if ( str.isNull() ) {
+ if ( !abList->save() ) {
if ( QMessageBox::critical( 0, tr("Out of space"),
tr("Unable to save information.\n"
"Free up some space\n"
"and try again.\n"
"\nQuit anyway?"),
QMessageBox::Yes|QMessageBox::Escape,
QMessageBox::No|QMessageBox::Default )
!= QMessageBox::No )
return TRUE;
else
return FALSE;
- } else {
- if ( !abList->save( str ) ) {
- if ( QMessageBox::critical( 0, tr( "Out of space" ),
- tr("Unable to save information.\n"
- "Free up some space\n"
- "and try again.\n"
- "\nQuit anyway?"),
- QMessageBox::Yes|QMessageBox::Escape,
- QMessageBox::No|QMessageBox::Default )
- != QMessageBox::No )
- return TRUE;
- else
- return FALSE;
- }
}
return TRUE;
}
void AddressbookWindow::slotSettings()
{
AddressSettings frmSettings( this );
#if defined(Q_WS_QWS) || defined(_WS_QWS_)
frmSettings.showMaximized();
#endif
if ( frmSettings.exec() ) {
allFields.clear();
orderedFields.clear();
slOrderedFields.clear();
initFields();
if ( abEditor )
abEditor->loadFields();
abList->refresh();
}
}
void AddressbookWindow::initFields()