summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp11
-rw-r--r--korganizer/filteredit_base.cpp73
-rw-r--r--korganizer/filteredit_base.h18
-rw-r--r--korganizer/filteredit_base.ui123
-rw-r--r--korganizer/korganizer.pro4
-rw-r--r--libkcal/calfilter.h2
-rw-r--r--libkdepim/ksyncmanager.cpp10
-rw-r--r--libkdepim/ksyncmanager.h4
8 files changed, 170 insertions, 75 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 378c7d4..8258c74 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -807,384 +807,395 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
case SYNC_PREF_REMOTE:
if ( lastSync > remoteMod )
return 1;
if ( lastSync > localMod )
return 2;
return 2;
break;
case SYNC_PREF_NEWEST:
if ( localMod > remoteMod )
return 1;
else
return 2;
break;
case SYNC_PREF_ASK:
//qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
if ( lastSync > remoteMod )
return 1;
if ( lastSync > localMod )
return 2;
//qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
localIsNew = localMod >= remoteMod;
if ( localIsNew )
getEventViewerDialog()->setColorMode( 1 );
else
getEventViewerDialog()->setColorMode( 2 );
getEventViewerDialog()->setIncidence(local);
if ( localIsNew )
getEventViewerDialog()->setColorMode( 2 );
else
getEventViewerDialog()->setColorMode( 1 );
getEventViewerDialog()->addIncidence(remote);
getEventViewerDialog()->setColorMode( 0 );
//qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
getEventViewerDialog()->showMe();
result = getEventViewerDialog()->executeS( localIsNew );
return result;
break;
case SYNC_PREF_FORCE_LOCAL:
return 1;
break;
case SYNC_PREF_FORCE_REMOTE:
return 2;
break;
default:
// SYNC_PREF_TAKE_BOTH not implemented
break;
}
return 0;
}
Event* CalendarView::getLastSyncEvent()
{
Event* lse;
//qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
if (!lse) {
lse = new Event();
lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
QString sum = "";
if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
sum = "E: ";
lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
lse->setDtStart( mLastCalendarSync );
lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
lse->setCategories( i18n("SyncEvent") );
lse->setReadOnly( true );
mCalendar->addEvent( lse );
}
return lse;
}
// we check, if the to delete event has a id for a profile
// if yes, we set this id in the profile to delete
void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
{
if ( lastSync.count() == 0 ) {
//qDebug(" lastSync.count() == 0");
return;
}
if ( toDelete->type() == "Journal" )
return;
Event* eve = lastSync.first();
while ( eve ) {
QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
if ( !id.isEmpty() ) {
QString des = eve->description();
QString pref = "e";
if ( toDelete->type() == "Todo" )
pref = "t";
des += pref+ id + ",";
eve->setReadOnly( false );
eve->setDescription( des );
//qDebug("setdes %s ", des.latin1());
eve->setReadOnly( true );
}
eve = lastSync.next();
}
}
void CalendarView::checkExternalId( Incidence * inc )
{
QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
checkExternSyncEvent( lastSync, inc );
}
bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
{
bool syncOK = true;
int addedEvent = 0;
int addedEventR = 0;
int deletedEventR = 0;
int deletedEventL = 0;
int changedLocal = 0;
int changedRemote = 0;
//QPtrList<Event> el = local->rawEvents();
Event* eventR;
QString uid;
int take;
Event* eventL;
Event* eventRSync;
Event* eventLSync;
QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
bool fullDateRange = false;
local->resetTempSyncStat();
mLastCalendarSync = QDateTime::currentDateTime();
if ( mSyncManager->syncWithDesktop() ) {
remote->resetPilotStat(1);
if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
} else {
qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
}
}
QDateTime modifiedCalendar = mLastCalendarSync;
eventLSync = getLastSyncEvent();
eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
if ( eventR ) {
eventRSync = (Event*) eventR->clone();
remote->deleteEvent(eventR );
} else {
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
eventRSync = (Event*)eventLSync->clone();
} else {
fullDateRange = true;
eventRSync = new Event();
eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
eventRSync->setDtStart( mLastCalendarSync );
eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
eventRSync->setCategories( i18n("SyncEvent") );
}
}
if ( eventLSync->dtStart() == mLastCalendarSync )
fullDateRange = true;
if ( ! fullDateRange ) {
if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
// qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
//qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
fullDateRange = true;
}
}
if ( mSyncManager->syncWithDesktop() ) {
fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
}
if ( fullDateRange )
mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
else
mLastCalendarSync = eventLSync->dtStart();
// for resyncing if own file has changed
if ( mCurrentSyncDevice == "deleteaftersync" ) {
mLastCalendarSync = loadedFileVersion;
//qDebug("setting mLastCalendarSync ");
}
//qDebug("*************************** ");
qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
QPtrList<Incidence> er = remote->rawIncidences();
Incidence* inR = er.first();
Incidence* inL;
QProgressBar bar( er.count(),0 );
bar.setCaption (i18n("Syncing - close to abort!") );
+ // ************** setting up filter *************
+ CalFilter *filterIN = 0;
+ CalFilter *filterOUT = 0;
+ CalFilter *filter = mFilters.first();
+ while(filter) {
+ if ( filter->name() == mSyncManager->mFilterInCal )
+ filterIN = filter;
+ if ( filter->name() == mSyncManager->mFilterOutCal )
+ filterOUT = filter;
+ filter = mFilters.next();
+ }
int w = 300;
if ( QApplication::desktop()->width() < 320 )
w = 220;
int h = bar.sizeHint().height() ;
int dw = QApplication::desktop()->width();
int dh = QApplication::desktop()->height();
bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
bar.show();
int modulo = (er.count()/10)+1;
int incCounter = 0;
while ( inR ) {
if ( ! bar.isVisible() )
return false;
if ( incCounter % modulo == 0 )
bar.setProgress( incCounter );
++incCounter;
uid = inR->uid();
bool skipIncidence = false;
if ( uid.left(15) == QString("last-syncEvent-") )
skipIncidence = true;
QString idS;
qApp->processEvents();
if ( !skipIncidence ) {
inL = local->incidence( uid );
if ( inL ) { // maybe conflict - same uid in both calendars
if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
//qDebug("take %d %s ", take, inL->summary().latin1());
if ( take == 3 )
return false;
if ( take == 1 ) {// take local **********************
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
else
idS = inR->IDStr();
remote->deleteIncidence( inR );
inR = inL->clone();
inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
inR->setIDStr( idS );
remote->addIncidence( inR );
if ( mSyncManager->syncWithDesktop() )
inR->setPilotId( 2 );
++changedRemote;
} else {// take remote **********************
idS = inL->IDStr();
int pid = inL->pilotId();
local->deleteIncidence( inL );
inL = inR->clone();
if ( mSyncManager->syncWithDesktop() )
inL->setPilotId( pid );
inL->setIDStr( idS );
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
}
local->addIncidence( inL );
++changedLocal;
}
}
} else { // no conflict ********** add or delete remote
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
QString des = eventLSync->description();
QString pref = "e";
if ( inR->type() == "Todo" )
pref = "t";
if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
//remote->deleteIncidence( inR );
++deletedEventR;
} else {
inR->setLastModified( modifiedCalendar );
inL = inR->clone();
inL->setIDStr( ":" );
inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
local->addIncidence( inL );
++addedEvent;
}
} else {
if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
inR->setLastModified( modifiedCalendar );
inL = inR->clone();
inL->setIDStr( ":" );
local->addIncidence( inL );
++addedEvent;
} else {
checkExternSyncEvent(eventRSyncSharp, inR);
remote->deleteIncidence( inR );
++deletedEventR;
}
}
}
}
inR = er.next();
}
QPtrList<Incidence> el = local->rawIncidences();
inL = el.first();
modulo = (el.count()/10)+1;
bar.setCaption (i18n("Add / remove events") );
bar.setTotalSteps ( el.count() ) ;
bar.show();
incCounter = 0;
while ( inL ) {
qApp->processEvents();
if ( ! bar.isVisible() )
return false;
if ( incCounter % modulo == 0 )
bar.setProgress( incCounter );
++incCounter;
uid = inL->uid();
bool skipIncidence = false;
if ( uid.left(15) == QString("last-syncEvent-") )
skipIncidence = true;
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
skipIncidence = true;
if ( !skipIncidence ) {
inR = remote->incidence( uid );
if ( ! inR ) { // no conflict ********** add or delete local
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
checkExternSyncEvent(eventLSyncSharp, inL);
local->deleteIncidence( inL );
++deletedEventL;
} else {
if ( ! mSyncManager->mWriteBackExistingOnly ) {
inL->removeID(mCurrentSyncDevice );
++addedEventR;
//qDebug("remote added Incidence %s ", inL->summary().latin1());
inL->setLastModified( modifiedCalendar );
inR = inL->clone();
inR->setIDStr( ":" );
inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
remote->addIncidence( inR );
}
}
} else {
if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
checkExternSyncEvent(eventLSyncSharp, inL);
local->deleteIncidence( inL );
++deletedEventL;
} else {
if ( ! mSyncManager->mWriteBackExistingOnly ) {
++addedEventR;
inL->setLastModified( modifiedCalendar );
inR = inL->clone();
inR->setIDStr( ":" );
remote->addIncidence( inR );
}
}
}
}
}
inL = el.next();
}
int delFut = 0;
int remRem = 0;
if ( mSyncManager->mWriteBackInFuture ) {
er = remote->rawIncidences();
remRem = er.count();
inR = er.first();
QDateTime dt;
QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
while ( inR ) {
if ( inR->type() == "Todo" ) {
Todo * t = (Todo*)inR;
if ( t->hasDueDate() )
dt = t->dtDue();
else
dt = cur.addSecs( 62 );
}
else if (inR->type() == "Event" ) {
bool ok;
dt = inR->getNextOccurence( cur, &ok );
if ( !ok )
dt = cur.addSecs( -62 );
}
else
dt = inR->dtStart();
if ( dt < cur || dt > end ) {
remote->deleteIncidence( inR );
++delFut;
}
inR = er.next();
}
}
bar.hide();
mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
eventLSync->setReadOnly( false );
eventLSync->setDtStart( mLastCalendarSync );
diff --git a/korganizer/filteredit_base.cpp b/korganizer/filteredit_base.cpp
index 21a0954..e724da4 100644
--- a/korganizer/filteredit_base.cpp
+++ b/korganizer/filteredit_base.cpp
@@ -1,128 +1,145 @@
/****************************************************************************
** Form implementation generated from reading ui file 'filteredit_base.ui'
**
-** Created: Di Mai 4 15:30:31 2004
+** Created: So Jan 16 11:23:21 2005
** by: The User Interface Compiler ($Id$)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
#include "filteredit_base.h"
#include <qvariant.h>
#include <qpushbutton.h>
#include <qframe.h>
#include <qbuttongroup.h>
#include <qradiobutton.h>
#include <qlistbox.h>
#include <qlabel.h>
#include <qcheckbox.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
+#include "filteredit_base.ui.h"
/*
* Constructs a FilterEdit_base as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*/
FilterEdit_base::FilterEdit_base( QWidget* parent, const char* name, WFlags fl )
: QWidget( parent, name, fl )
{
if ( !name )
setName( "FilterEdit_base" );
FilterEdit_baseLayout = new QVBoxLayout( this, 0, 0, "FilterEdit_baseLayout");
mCriteriaFrame = new QFrame( this, "mCriteriaFrame" );
mCriteriaFrame->setFrameShape( QFrame::StyledPanel );
mCriteriaFrame->setFrameShadow( QFrame::Raised );
- mCriteriaFrameLayout = new QGridLayout( mCriteriaFrame, 1, 1, 3, 2, "mCriteriaFrameLayout");
+ mCriteriaFrameLayout = new QVBoxLayout( mCriteriaFrame, 3, 2, "mCriteriaFrameLayout");
ButtonGroup1 = new QButtonGroup( mCriteriaFrame, "ButtonGroup1" );
ButtonGroup1->setColumnLayout(0, Qt::Vertical );
ButtonGroup1->layout()->setSpacing( 6 );
- ButtonGroup1->layout()->setMargin( 11 );
- ButtonGroup1Layout = new QVBoxLayout( ButtonGroup1->layout() );
+ ButtonGroup1->layout()->setMargin( 6 );
+ ButtonGroup1Layout = new QGridLayout( ButtonGroup1->layout() );
ButtonGroup1Layout->setAlignment( Qt::AlignTop );
+ layout4 = new QHBoxLayout( 0, 0, 6, "layout4");
+
mCatShowCheck = new QRadioButton( ButtonGroup1, "mCatShowCheck" );
- ButtonGroup1Layout->addWidget( mCatShowCheck );
+ layout4->addWidget( mCatShowCheck );
mCatHideCheck = new QRadioButton( ButtonGroup1, "mCatHideCheck" );
- ButtonGroup1Layout->addWidget( mCatHideCheck );
-
- mCatList = new QListBox( ButtonGroup1, "mCatList" );
- ButtonGroup1Layout->addWidget( mCatList );
+ layout4->addWidget( mCatHideCheck );
mCatEditButton = new QPushButton( ButtonGroup1, "mCatEditButton" );
- ButtonGroup1Layout->addWidget( mCatEditButton );
+ layout4->addWidget( mCatEditButton );
- mCriteriaFrameLayout->addWidget( ButtonGroup1, 0, 0 );
+ ButtonGroup1Layout->addLayout( layout4, 0, 0 );
- layout1 = new QHBoxLayout( 0, 0, 0, "layout1");
+ mCatList = new QListBox( ButtonGroup1, "mCatList" );
+
+ ButtonGroup1Layout->addWidget( mCatList, 1, 0 );
+ mCriteriaFrameLayout->addWidget( ButtonGroup1 );
+
+ layout7 = new QHBoxLayout( 0, 0, 6, "layout7");
textLabel1 = new QLabel( mCriteriaFrame, "textLabel1" );
- layout1->addWidget( textLabel1 );
+ layout7->addWidget( textLabel1 );
mRecurringCheck = new QCheckBox( mCriteriaFrame, "mRecurringCheck" );
- layout1->addWidget( mRecurringCheck );
+ layout7->addWidget( mRecurringCheck );
mCompletedCheck = new QCheckBox( mCriteriaFrame, "mCompletedCheck" );
- layout1->addWidget( mCompletedCheck );
+ layout7->addWidget( mCompletedCheck );
+ mCriteriaFrameLayout->addLayout( layout7 );
+
+ layout9 = new QHBoxLayout( 0, 0, 6, "layout9");
- mCriteriaFrameLayout->addLayout( layout1, 1, 0 );
+ textLabel1_2 = new QLabel( mCriteriaFrame, "textLabel1_2" );
+ layout9->addWidget( textLabel1_2 );
+
+ mEventCheck = new QCheckBox( mCriteriaFrame, "mEventCheck" );
+ layout9->addWidget( mEventCheck );
+
+ mTodoCheck = new QCheckBox( mCriteriaFrame, "mTodoCheck" );
+ layout9->addWidget( mTodoCheck );
+
+ mJournalCheck = new QCheckBox( mCriteriaFrame, "mJournalCheck" );
+ layout9->addWidget( mJournalCheck );
+ mCriteriaFrameLayout->addLayout( layout9 );
layout2 = new QHBoxLayout( 0, 0, 0, "layout2");
textLabel2 = new QLabel( mCriteriaFrame, "textLabel2" );
layout2->addWidget( textLabel2 );
mPublicCheck = new QCheckBox( mCriteriaFrame, "mPublicCheck" );
layout2->addWidget( mPublicCheck );
mPrivateCheck = new QCheckBox( mCriteriaFrame, "mPrivateCheck" );
layout2->addWidget( mPrivateCheck );
mConfidentialCheck = new QCheckBox( mCriteriaFrame, "mConfidentialCheck" );
mConfidentialCheck->setChecked( FALSE );
layout2->addWidget( mConfidentialCheck );
-
- mCriteriaFrameLayout->addLayout( layout2, 2, 0 );
+ mCriteriaFrameLayout->addLayout( layout2 );
FilterEdit_baseLayout->addWidget( mCriteriaFrame );
languageChange();
- resize( QSize(284, 241).expandedTo(minimumSizeHint()) );
+ resize( QSize(351, 275).expandedTo(minimumSizeHint()) );
clearWState( WState_Polished );
}
/*
* Destroys the object and frees any allocated resources
*/
FilterEdit_base::~FilterEdit_base()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void FilterEdit_base::languageChange()
{
setCaption( tr( "FilterEditor" ) );
ButtonGroup1->setTitle( tr( "Categories" ) );
- mCatShowCheck->setText( tr( "Show only selected" ) );
- mCatHideCheck->setText( tr( "Show all but selected" ) );
+ mCatShowCheck->setText( tr( "Include" ) );
+ mCatHideCheck->setText( tr( "Exclude" ) );
mCatEditButton->setText( tr( "Edit Selection..." ) );
- textLabel1->setText( tr( "Hide" ) );
+ textLabel1->setText( tr( "Exclude" ) );
mRecurringCheck->setText( tr( "recurring events" ) );
mCompletedCheck->setText( tr( "completed to-dos" ) );
- textLabel2->setText( tr( "Show" ) );
+ textLabel1_2->setText( tr( "Exclude" ) );
+ mEventCheck->setText( tr( "events" ) );
+ mTodoCheck->setText( tr( "todos" ) );
+ mJournalCheck->setText( tr( "journals" ) );
+ textLabel2->setText( tr( "Include" ) );
mPublicCheck->setText( tr( "public" ) );
mPrivateCheck->setText( tr( "private" ) );
mConfidentialCheck->setText( tr( "confidential" ) );
}
-void FilterEdit_base::updateFilter()
-{
- qWarning( "FilterEdit_base::updateFilter(): Not implemented yet" );
-}
-
diff --git a/korganizer/filteredit_base.h b/korganizer/filteredit_base.h
index 664598a..0c2988a 100644
--- a/korganizer/filteredit_base.h
+++ b/korganizer/filteredit_base.h
@@ -1,66 +1,72 @@
/****************************************************************************
** Form interface generated from reading ui file 'filteredit_base.ui'
**
-** Created: Di Mai 4 15:24:50 2004
+** Created: So Jan 16 11:23:21 2005
** by: The User Interface Compiler ($Id$)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
#ifndef FILTEREDIT_BASE_H
#define FILTEREDIT_BASE_H
#include <qvariant.h>
#include <qwidget.h>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QSpacerItem;
class QFrame;
class QButtonGroup;
class QRadioButton;
+class QPushButton;
class QListBox;
class QListBoxItem;
-class QPushButton;
class QLabel;
class QCheckBox;
class FilterEdit_base : public QWidget
{
Q_OBJECT
public:
FilterEdit_base( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
~FilterEdit_base();
QFrame* mCriteriaFrame;
QButtonGroup* ButtonGroup1;
QRadioButton* mCatShowCheck;
QRadioButton* mCatHideCheck;
- QListBox* mCatList;
QPushButton* mCatEditButton;
+ QListBox* mCatList;
QLabel* textLabel1;
QCheckBox* mRecurringCheck;
QCheckBox* mCompletedCheck;
+ QLabel* textLabel1_2;
+ QCheckBox* mEventCheck;
+ QCheckBox* mTodoCheck;
+ QCheckBox* mJournalCheck;
QLabel* textLabel2;
QCheckBox* mPublicCheck;
QCheckBox* mPrivateCheck;
QCheckBox* mConfidentialCheck;
public slots:
virtual void updateFilter();
protected:
QVBoxLayout* FilterEdit_baseLayout;
- QGridLayout* mCriteriaFrameLayout;
- QVBoxLayout* ButtonGroup1Layout;
- QHBoxLayout* layout1;
+ QVBoxLayout* mCriteriaFrameLayout;
+ QGridLayout* ButtonGroup1Layout;
+ QHBoxLayout* layout4;
+ QHBoxLayout* layout7;
+ QHBoxLayout* layout9;
QHBoxLayout* layout2;
protected slots:
virtual void languageChange();
};
#endif // FILTEREDIT_BASE_H
diff --git a/korganizer/filteredit_base.ui b/korganizer/filteredit_base.ui
index b7cbb59..2436f57 100644
--- a/korganizer/filteredit_base.ui
+++ b/korganizer/filteredit_base.ui
@@ -1,201 +1,250 @@
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
<class>FilterEdit_base</class>
<widget class="QWidget">
<property name="name">
<cstring>FilterEdit_base</cstring>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
- <width>284</width>
- <height>241</height>
+ <width>351</width>
+ <height>275</height>
</rect>
</property>
<property name="caption">
<string>FilterEditor</string>
</property>
<property name="layoutMargin" stdset="0">
</property>
<property name="layoutSpacing" stdset="0">
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<widget class="QFrame">
<property name="name">
<cstring>mCriteriaFrame</cstring>
</property>
<property name="frameShape">
<enum>StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>Raised</enum>
</property>
<property name="layoutMargin" stdset="0">
</property>
- <grid>
+ <vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<property name="margin">
<number>3</number>
</property>
<property name="spacing">
<number>2</number>
</property>
- <widget class="QButtonGroup" row="0" column="0">
+ <widget class="QButtonGroup">
<property name="name">
<cstring>ButtonGroup1</cstring>
</property>
<property name="title">
<string>Categories</string>
</property>
- <vbox>
+ <grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<property name="margin">
- <number>11</number>
+ <number>6</number>
</property>
<property name="spacing">
<number>6</number>
</property>
- <widget class="QRadioButton">
+ <widget class="QLayoutWidget" row="0" column="0">
<property name="name">
- <cstring>mCatShowCheck</cstring>
- </property>
- <property name="text">
- <string>Show only selected</string>
+ <cstring>layout4</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>mCatShowCheck</cstring>
+ </property>
+ <property name="text">
+ <string>Include</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>mCatHideCheck</cstring>
+ </property>
+ <property name="text">
+ <string>Exclude</string>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>mCatEditButton</cstring>
+ </property>
+ <property name="text">
+ <string>Edit Selection...</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QListBox" row="1" column="0">
+ <property name="name">
+ <cstring>mCatList</cstring>
</property>
</widget>
- <widget class="QRadioButton">
+ </grid>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout7</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
<property name="name">
- <cstring>mCatHideCheck</cstring>
+ <cstring>textLabel1</cstring>
</property>
<property name="text">
- <string>Show all but selected</string>
+ <string>Exclude</string>
</property>
</widget>
- <widget class="QListBox">
+ <widget class="QCheckBox">
<property name="name">
- <cstring>mCatList</cstring>
+ <cstring>mRecurringCheck</cstring>
+ </property>
+ <property name="text">
+ <string>recurring events</string>
</property>
</widget>
- <widget class="QPushButton">
+ <widget class="QCheckBox">
<property name="name">
- <cstring>mCatEditButton</cstring>
+ <cstring>mCompletedCheck</cstring>
</property>
<property name="text">
- <string>Edit Selection...</string>
+ <string>completed to-dos</string>
</property>
</widget>
- </vbox>
+ </hbox>
</widget>
- <widget class="QLayoutWidget" row="1" column="0">
+ <widget class="QLayoutWidget">
<property name="name">
- <cstring>layout1</cstring>
+ <cstring>layout9</cstring>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
- <property name="margin">
- <number>0</number>
- </property>
- <property name="spacing">
- <number>0</number>
- </property>
<widget class="QLabel">
<property name="name">
- <cstring>textLabel1</cstring>
+ <cstring>textLabel1_2</cstring>
</property>
<property name="text">
- <string>Hide</string>
+ <string>Exclude</string>
</property>
</widget>
<widget class="QCheckBox">
<property name="name">
- <cstring>mRecurringCheck</cstring>
+ <cstring>mEventCheck</cstring>
</property>
<property name="text">
- <string>recurring events</string>
+ <string>events</string>
</property>
</widget>
<widget class="QCheckBox">
<property name="name">
- <cstring>mCompletedCheck</cstring>
+ <cstring>mTodoCheck</cstring>
</property>
<property name="text">
- <string>completed to-dos</string>
+ <string>todos</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>mJournalCheck</cstring>
+ </property>
+ <property name="text">
+ <string>journals</string>
</property>
</widget>
</hbox>
</widget>
- <widget class="QLayoutWidget" row="2" column="0">
+ <widget class="QLayoutWidget">
<property name="name">
<cstring>layout2</cstring>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<widget class="QLabel">
<property name="name">
<cstring>textLabel2</cstring>
</property>
<property name="text">
- <string>Show</string>
+ <string>Include</string>
</property>
</widget>
<widget class="QCheckBox">
<property name="name">
<cstring>mPublicCheck</cstring>
</property>
<property name="text">
<string>public</string>
</property>
</widget>
<widget class="QCheckBox">
<property name="name">
<cstring>mPrivateCheck</cstring>
</property>
<property name="text">
<string>private</string>
</property>
</widget>
<widget class="QCheckBox">
<property name="name">
<cstring>mConfidentialCheck</cstring>
</property>
<property name="text">
<string>confidential</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</hbox>
</widget>
- </grid>
+ </vbox>
</widget>
</vbox>
</widget>
+<includes>
+ <include location="local" impldecl="in implementation">filteredit_base.ui.h</include>
+</includes>
<slots>
<slot>updateFilter()</slot>
</slots>
<layoutdefaults spacing="6" margin="11"/>
</UI>
diff --git a/korganizer/korganizer.pro b/korganizer/korganizer.pro
index 2816c6e..628d84e 100644
--- a/korganizer/korganizer.pro
+++ b/korganizer/korganizer.pro
@@ -1,193 +1,193 @@
TEMPLATE = app
CONFIG = qt warn_on
TARGET = kopi
OBJECTS_DIR = _obj/
MOC_DIR = _moc
DESTDIR= ../bin
include( ../variables.pri )
INCLUDEPATH += ../microkde ../ interfaces ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim
#../qtcompat
DEFINES += KORG_NODND KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL
DEFINES += KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER
#KORG_NOPRINTER KORG_NOKABC
DEFINES += KORG_NOLVALTERNATION
DEFINES += DESKTOP_VERSION
unix : {
LIBS += ../bin/libmicrokdepim.so
LIBS += ../bin/libmicrokcal.so
LIBS += ../bin/libmicrokde.so
LIBS += ../bin/libmicrokabc.so
#LIBS += -lbluetooth
#LIBS += -lsdp
#LIBS += -lldap
OBJECTS_DIR = obj/unix
MOC_DIR = moc/unix
}
win32: {
RC_FILE = winicons.rc
DEFINES += _WIN32_
LIBS += ../bin/microkdepim.lib
LIBS += ../bin/microkcal.lib
LIBS += ../bin/microkde.lib
LIBS += ../bin/microkabc.lib
LIBS += ../libical/lib/ical.lib
LIBS += ../libical/lib/icalss.lib
#LIBS += atls.lib
LIBS += mfc71u.lib
QMAKE_LINK += /NODEFAULTLIB:LIBC
#QMAKE_LINK += /NODEFAULTLIB:MSVCRT
#QMAKE_LINK += /NODEFAULTLIB:uafxcw.lib
OBJECTS_DIR = obj/win
MOC_DIR = moc/win
}
-INTERFACES = kofilterview_base.ui
-# filteredit_base.ui
+INTERFACES = kofilterview_base.ui
+# filteredit_base.ui
# kdateedit.h \
HEADERS = \
filteredit_base.h \
alarmclient.h \
calendarview.h \
customlistviewitem.h \
datenavigator.h \
docprefs.h \
filtereditdialog.h \
incomingdialog.h \
incomingdialog_base.h \
interfaces/korganizer/baseview.h \
interfaces/korganizer/calendarviewbase.h \
journalentry.h \
kdatenavigator.h \
koagenda.h \
koagendaitem.h \
koagendaview.h \
kocounterdialog.h \
kodaymatrix.h \
kodialogmanager.h \
koeditordetails.h \
koeditorgeneral.h \
koeditorgeneralevent.h \
koeditorgeneraltodo.h \
koeditorrecurrence.h \
koeventeditor.h \
koeventpopupmenu.h \
koeventview.h \
koeventviewer.h \
koeventviewerdialog.h \
kofilterview.h \
koglobals.h \
koincidenceeditor.h \
kojournalview.h \
kolistview.h \
kolocationbox.h \
komonthview.h \
koprefs.h \
koprefsdialog.h \
kotimespanview.h \
kotodoeditor.h \
kotodoview.h \
kotodoviewitem.h \
koviewmanager.h \
kowhatsnextview.h \
ktimeedit.h \
lineview.h \
mainwindow.h \
navigatorbar.h \
outgoingdialog.h \
outgoingdialog_base.h \
publishdialog.h \
publishdialog_base.h \
savetemplatedialog.h \
searchdialog.h \
simplealarmclient.h \
statusdialog.h \
timeline.h \
timespanview.h \
version.h \
../kalarmd/alarmdialog.h \
SOURCES = \
filteredit_base.cpp \
calendarview.cpp \
datenavigator.cpp \
docprefs.cpp \
filtereditdialog.cpp \
incomingdialog.cpp \
incomingdialog_base.cpp \
journalentry.cpp \
kdatenavigator.cpp \
koagenda.cpp \
koagendaitem.cpp \
koagendaview.cpp \
kocounterdialog.cpp \
kodaymatrix.cpp \
kodialogmanager.cpp \
koeditordetails.cpp \
koeditorgeneral.cpp \
koeditorgeneralevent.cpp \
koeditorgeneraltodo.cpp \
koeditorrecurrence.cpp \
koeventeditor.cpp \
koeventpopupmenu.cpp \
koeventview.cpp \
koeventviewer.cpp \
koeventviewerdialog.cpp \
kofilterview.cpp \
koglobals.cpp \
koincidenceeditor.cpp \
kojournalview.cpp \
kolistview.cpp \
kolocationbox.cpp \
komonthview.cpp \
koprefs.cpp \
koprefsdialog.cpp \
kotimespanview.cpp \
kotodoeditor.cpp \
kotodoview.cpp \
kotodoviewitem.cpp \
koviewmanager.cpp \
kowhatsnextview.cpp \
ktimeedit.cpp \
lineview.cpp \
main.cpp \
mainwindow.cpp \
navigatorbar.cpp \
outgoingdialog.cpp \
outgoingdialog_base.cpp \
publishdialog.cpp \
publishdialog_base.cpp \
savetemplatedialog.cpp \
searchdialog.cpp \
simplealarmclient.cpp \
statusdialog.cpp \
timeline.cpp \
timespanview.cpp \
../kalarmd/alarmdialog.cpp
HEADERS += calprintbase.h calprinter.h calprintplugins.h cellitem.h
INTERFACES += calprintdayconfig_base.ui \
calprintmonthconfig_base.ui \
calprinttodoconfig_base.ui \
calprintweekconfig_base.ui
SOURCES += calprintbase.cpp calprinter.cpp calprintplugins.cpp cellitem.cpp
win32: {
HEADERS += ../outport/msoutl9.h \
koimportoldialog.h
SOURCES += ../outport/msoutl9.cpp \
koimportoldialog.cpp
}
diff --git a/libkcal/calfilter.h b/libkcal/calfilter.h
index d6d4717..5ad0064 100644
--- a/libkcal/calfilter.h
+++ b/libkcal/calfilter.h
@@ -1,128 +1,128 @@
/*
This file is part of libkcal.
Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef _CALFILTER_H
#define _CALFILTER_H
#include <qstring.h>
#include <qptrlist.h>
#include "event.h"
#include "todo.h"
namespace KCal {
/**
Filter for calendar objects.
*/
class CalFilter {
public:
/** Construct filter. */
CalFilter();
/** Construct filter with name */
CalFilter(const QString &name);
/** Destruct filter. */
~CalFilter();
/**
Set name of filter.
*/
void setName(const QString &name) { mName = name; }
/**
Return name of filter.
*/
QString name() const { return mName; }
/**
Apply filter to eventlist, all events not matching filter criterias are
removed from the list.
*/
void apply(QPtrList<Event> *eventlist);
/**
Apply filter to todolist, all todos not matching filter criterias are
removed from the list.
*/
void apply(QPtrList<Todo> *todolist);
/**
Apply filter criteria on the specified event. Return true, if event passes
criteria, otherwise return false.
*/
bool filterEvent(Event *);
/**
Apply filter criteria on the specified todo. Return true, if event passes
criteria, otherwise return false.
*/
bool filterTodo(Todo *);
/**
Apply filter criteria on the specified incidence. Return true, if event passes
criteria, otherwise return false.
*/
bool filterIncidence(Incidence *);
/**
Enable or disable filter.
*/
void setEnabled(bool);
/**
Return wheter the filter is enabled or not.
*/
bool isEnabled();
bool showCategories();
int getSecrecy();
/**
Set list of categories, which is used for showing/hiding categories of
events.
See related functions.
*/
void setCategoryList(const QStringList &);
/**
Return category list, used for showing/hiding categories of events.
See related functions.
*/
QStringList categoryList();
- enum { HideRecurring = 1, HideCompleted = 2, ShowCategories = 4 ,ShowPublic = 8, ShowPrivate = 16, ShowConfidential = 32 };
+ enum { HideRecurring = 1, HideCompleted = 2, ShowCategories = 4 ,ShowPublic = 8, ShowPrivate = 16, ShowConfidential = 32, HideEvents = 64, HideTodos = 128, HideJournals = 256 };
/**
Set criteria, which have to be fulfilled by events passing the filter.
*/
void setCriteria(int);
/**
Get inclusive filter criteria.
*/
int criteria();
private:
QString mName;
int mCriteria;
bool mEnabled;
QStringList mCategoryList;
};
}
#endif /* _CALFILTER_H */
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 33b4a65..6c1f444 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -63,716 +63,724 @@ KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, Targ
{
mServerSocket = 0;
bar = new QProgressBar ( 1, 0 );
bar->setCaption ("");
mWriteBackInPast = 2;
int w = 300;
if ( QApplication::desktop()->width() < 320 )
w = 220;
int h = bar->sizeHint().height() ;
int dw = QApplication::desktop()->width();
int dh = QApplication::desktop()->height();
bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
if ( mPrefs->mPassiveSyncAutoStart )
enableQuick( false );
}
KSyncManager::~KSyncManager()
{
delete bar;
}
void KSyncManager::fillSyncMenu()
{
if ( mSyncMenu->count() )
mSyncMenu->clear();
mSyncMenu->insertItem( i18n("Configure..."), 0 );
mSyncMenu->insertSeparator();
QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu );
mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 );
clearMenu->insertItem( i18n("For all profiles"), 1 );
clearMenu->insertSeparator();
connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) );
mSyncMenu->insertSeparator();
if ( mServerSocket == 0 ) {
mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
} else {
mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
}
mSyncMenu->insertSeparator();
mSyncMenu->insertItem( i18n("Multiple sync"), 1 );
mSyncMenu->insertSeparator();
KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
config.setGroup("General");
QStringList prof = config.readListEntry("SyncProfileNames");
mLocalMachineName = config.readEntry("LocalMachineName","undefined");
if ( prof.count() < 2 ) {
prof.clear();
QString externalName;
#ifdef DESKTOP_VERSION
#ifdef _WIN32_
externalName = "OutLook(not_implemented)";
#else
externalName = "KDE_Desktop";
#endif
#else
externalName = "Sharp_DTM";
#endif
prof << externalName;
prof << i18n("Local_file");
prof << i18n("Last_file");
KSyncProfile* temp = new KSyncProfile ();
temp->setName( prof[0] );
temp->writeConfig(&config);
temp->setName( prof[1] );
temp->writeConfig(&config);
temp->setName( prof[2] );
temp->writeConfig(&config);
config.setGroup("General");
config.writeEntry("SyncProfileNames",prof);
config.writeEntry("ExternSyncProfiles",externalName);
config.sync();
delete temp;
}
mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
mSyncProfileNames = prof;
unsigned int i;
for ( i = 0; i < prof.count(); ++i ) {
mSyncMenu->insertItem( prof[i], 1000+i );
clearMenu->insertItem( prof[i], 1000+i );
if ( i == 2 )
mSyncMenu->insertSeparator();
}
QDir app_dir;
//US do not display SharpDTM if app is pwmpi, or no sharpfiles available
if ( mTargetApp == PWMPI) {
mSyncMenu->removeItem( 1000 );
clearMenu->removeItem( 1000 );
}
#ifndef DESKTOP_VERSION
else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
mSyncMenu->removeItem( 1000 );
clearMenu->removeItem( 1000 );
}
#endif
mSyncMenu->removeItem( 1002 );
clearMenu->removeItem( 1002 );
}
void KSyncManager::slotClearMenu( int action )
{
QString syncDevice;
if ( action > 999 ) {
syncDevice = mSyncProfileNames[action - 1000] ;
}
int result = 0;
QString sd;
if ( syncDevice.isEmpty() )
sd = i18n("Do you want to\nclear all sync info\nof all profiles?");
else
sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice );
result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0,
0, 1 );
if ( result )
return;
mImplementation->removeSyncInfo( syncDevice );
}
void KSyncManager::slotSyncMenu( int action )
{
qDebug("syncaction %d ", action);
if ( action == 5000 )
return;
mSyncWithDesktop = false;
if ( action == 0 ) {
// seems to be a Qt2 event handling bug
// syncmenu.clear causes a segfault at first time
// when we call it after the main event loop, it is ok
// same behaviour when calling OM/Pi via QCOP for the first time
QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
//confSync();
return;
}
if ( action == 1 ) {
multiSync( true );
return;
}
if ( action == 2 ) {
enableQuick();
QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
return;
}
if ( action == 3 ) {
delete mServerSocket;
mServerSocket = 0;
QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
return;
}
if (blockSave())
return;
setBlockSave(true);
bool silent = false;
if ( action == 999 ) {
//special mode for silent syncing
action = 1000;
silent = true;
}
mCurrentSyncProfile = action - 1000 ;
mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ;
mCurrentSyncName = mLocalMachineName ;
KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
KSyncProfile* temp = new KSyncProfile ();
temp->setName(mSyncProfileNames[mCurrentSyncProfile]);
temp->readConfig(&config);
if (silent) {
mAskForPreferences = false;
mShowSyncSummary = false;
mWriteBackFile = true;
mSyncAlgoPrefs = 2;// take newest
}
else {
mAskForPreferences = temp->getAskForPreferences();
mShowSyncSummary = temp->getShowSummaryAfterSync();
mWriteBackFile = temp->getWriteBackFile();
mSyncAlgoPrefs = temp->getSyncPrefs();
}
mWriteBackExistingOnly = temp->getWriteBackExisting();
mIsKapiFile = temp->getIsKapiFile();
mWriteBackInFuture = 0;
if ( temp->getWriteBackFuture() ) {
mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
mWriteBackInPast = temp->getWriteBackPastWeeks( );
}
-
+ mFilterInCal = temp->getFilterInCal();
+ mFilterOutCal = temp->getFilterOutCal();
+ mFilterInAB = temp->getFilterInAB();
+ mFilterOutAB = temp->getFilterOutAB();
+
if ( action == 1000 ) {
mIsKapiFile = false;
#ifdef DESKTOP_VERSION
syncKDE();
#else
syncSharp();
#endif
} else if ( action == 1001 ) {
syncLocalFile();
} else if ( action == 1002 ) {
mWriteBackFile = false;
mAskForPreferences = false;
mShowSyncSummary = false;
mSyncAlgoPrefs = 3;
quickSyncLocalFile();
} else if ( action >= 1003 ) {
if ( temp->getIsLocalFileSync() ) {
switch(mTargetApp)
{
case (KAPI):
if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
break;
case (KOPI):
if ( syncWithFile( temp->getRemoteFileName( ), false ) )
mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
break;
case (PWMPI):
if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
break;
default:
qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
break;
}
} else {
if ( temp->getIsPhoneSync() ) {
mPhoneDevice = temp->getPhoneDevice( ) ;
mPhoneConnection = temp->getPhoneConnection( );
mPhoneModel = temp->getPhoneModel( );
syncPhone();
} else if ( temp->getIsPiSync() ) {
if ( mTargetApp == KAPI ) {
mPassWordPiSync = temp->getRemotePwAB();
mActiveSyncPort = temp->getRemotePortAB();
mActiveSyncIP = temp->getRemoteIPAB();
} else if ( mTargetApp == KOPI ) {
mPassWordPiSync = temp->getRemotePw();
mActiveSyncPort = temp->getRemotePort();
mActiveSyncIP = temp->getRemoteIP();
} else {
mPassWordPiSync = temp->getRemotePwPWM();
mActiveSyncPort = temp->getRemotePortPWM();
mActiveSyncIP = temp->getRemoteIPPWM();
}
syncPi();
while ( !mPisyncFinished ) {
//qDebug("waiting ");
qApp->processEvents();
}
} else
syncRemote( temp );
}
}
delete temp;
setBlockSave(false);
}
void KSyncManager::enableQuick( bool ask )
{
bool autoStart;
bool changed = false;
if ( ask ) {
QDialog dia ( 0, "input-dialog", true );
QLineEdit lab ( &dia );
QVBoxLayout lay( &dia );
lab.setText( mPrefs->mPassiveSyncPort );
lay.setMargin(7);
lay.setSpacing(7);
int po = 9197+mTargetApp;
QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia );
lay.addWidget( &label);
lay.addWidget( &lab);
QLineEdit lepw ( &dia );
lepw.setText( mPrefs->mPassiveSyncPw );
QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
lay.addWidget( &label2);
lay.addWidget( &lepw);
QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia );
lay.addWidget( &autostart);
autostart.setChecked( mPrefs->mPassiveSyncAutoStart );
#ifdef DESKTOP_VERSION
#ifdef _WIN32_
QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia );
syncdesktop.hide();// not implemented!
#else
QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia );
#endif
lay.addWidget( &syncdesktop);
#else
mPrefs->mPassiveSyncWithDesktop = false;
QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia );
syncdesktop.hide();
#endif
syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop );
dia.setFixedSize( 230,120 );
dia.setCaption( i18n("Enter port for Pi-Sync") );
QPushButton pb ( "OK", &dia);
lay.addWidget( &pb );
connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
dia.show();
if ( ! dia.exec() )
return;
dia.hide();
qApp->processEvents();
if ( mPrefs->mPassiveSyncPw != lepw.text() ) {
changed = true;
mPrefs->mPassiveSyncPw = lepw.text();
}
if ( mPrefs->mPassiveSyncPort != lab.text() ) {
mPrefs->mPassiveSyncPort = lab.text();
changed = true;
}
autoStart = autostart.isChecked();
if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) {
changed = true;
mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked();
}
}
else
autoStart = mPrefs->mPassiveSyncAutoStart;
if ( autoStart != mPrefs->mPassiveSyncAutoStart )
changed = true;
bool ok;
mPrefs->mPassiveSyncAutoStart = false;
Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok);
if ( ! ok ) {
KMessageBox::information( 0, i18n("No valid port"));
return;
}
//qDebug("port %d ", port);
mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
mServerSocket->setFileName( defaultFileName() );//bbb
//qDebug("connected ");
if ( !mServerSocket->ok() ) {
KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!"));
delete mServerSocket;
mServerSocket = 0;
return;
}
mPrefs->mPassiveSyncAutoStart = autoStart;
if ( changed ) {
mPrefs->writeConfig();
}
connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
}
void KSyncManager::syncLocalFile()
{
QString fn =mPrefs->mLastSyncedLocalFile;
QString ext;
switch(mTargetApp)
{
case (KAPI):
ext = "(*.vcf)";
break;
case (KOPI):
ext = "(*.ics/*.vcs)";
break;
case (PWMPI):
ext = "(*.pwm)";
break;
default:
qDebug("KSyncManager::syncLocalFile: invalid apptype selected");
break;
}
fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
if ( fn == "" )
return;
if ( syncWithFile( fn, false ) ) {
qDebug("syncLocalFile() successful ");
}
}
bool KSyncManager::syncWithFile( QString fn , bool quick )
{
bool ret = false;
QFileInfo info;
info.setFile( fn );
QString mess;
bool loadbup = true;
if ( !info. exists() ) {
mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
int result = QMessageBox::warning( mParent, i18n("Warning!"),
mess );
return ret;
}
int result = 0;
if ( !quick ) {
mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
result = QMessageBox::warning( mParent, i18n("Warning!"),
mess,
i18n("Sync"), i18n("Cancel"), 0,
0, 1 );
if ( result )
return false;
}
if ( mAskForPreferences )
if ( !edit_sync_options()) {
mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
return false;
}
if ( result == 0 ) {
//qDebug("Now sycing ... ");
if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) )
mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") );
else
mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
if ( ! quick )
mPrefs->mLastSyncedLocalFile = fn;
}
return ret;
}
void KSyncManager::quickSyncLocalFile()
{
if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) {
qDebug("quick syncLocalFile() successful ");
}
}
void KSyncManager::multiSync( bool askforPrefs )
{
if (blockSave())
return;
setBlockSave(true);
QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"),
question,
i18n("Yes"), i18n("No"),
0, 0 ) != 0 ) {
setBlockSave(false);
mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!"));
return;
}
mCurrentSyncDevice = i18n("Multiple profiles") ;
mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs;
if ( askforPrefs ) {
if ( !edit_sync_options()) {
mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") );
return;
}
mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs;
}
mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") );
qApp->processEvents();
int num = ringSync() ;
if ( num > 1 )
ringSync();
setBlockSave(false);
if ( num )
emit save();
if ( num )
mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) );
else
mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
return;
}
int KSyncManager::ringSync()
{
int syncedProfiles = 0;
unsigned int i;
QTime timer;
KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
QStringList syncProfileNames = mSyncProfileNames;
KSyncProfile* temp = new KSyncProfile ();
mAskForPreferences = false;
for ( i = 0; i < syncProfileNames.count(); ++i ) {
mCurrentSyncProfile = i;
temp->setName(syncProfileNames[mCurrentSyncProfile]);
temp->readConfig(&config);
bool includeInRingSync;
switch(mTargetApp)
{
case (KAPI):
includeInRingSync = temp->getIncludeInRingSyncAB();
break;
case (KOPI):
includeInRingSync = temp->getIncludeInRingSync();
break;
case (PWMPI):
includeInRingSync = temp->getIncludeInRingSyncPWM();
break;
default:
qDebug("KSyncManager::ringSync: invalid apptype selected");
break;
}
if ( includeInRingSync && ( i < 1 || i > 2 )) {
mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
++syncedProfiles;
mSyncWithDesktop = false;
// mAskForPreferences = temp->getAskForPreferences();
mWriteBackFile = temp->getWriteBackFile();
mWriteBackExistingOnly = temp->getWriteBackExisting();
mIsKapiFile = temp->getIsKapiFile();
mWriteBackInFuture = 0;
if ( temp->getWriteBackFuture() ) {
mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
mWriteBackInPast = temp->getWriteBackPastWeeks( );
}
+ mFilterInCal = temp->getFilterInCal();
+ mFilterOutCal = temp->getFilterOutCal();
+ mFilterInAB = temp->getFilterInAB();
+ mFilterOutAB = temp->getFilterOutAB();
mShowSyncSummary = false;
mCurrentSyncDevice = syncProfileNames[i] ;
mCurrentSyncName = mLocalMachineName;
if ( i == 0 ) {
mIsKapiFile = false;
#ifdef DESKTOP_VERSION
syncKDE();
#else
syncSharp();
#endif
} else {
if ( temp->getIsLocalFileSync() ) {
switch(mTargetApp)
{
case (KAPI):
if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
break;
case (KOPI):
if ( syncWithFile( temp->getRemoteFileName( ), false ) )
mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
break;
case (PWMPI):
if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
break;
default:
qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
break;
}
} else {
if ( temp->getIsPhoneSync() ) {
mPhoneDevice = temp->getPhoneDevice( ) ;
mPhoneConnection = temp->getPhoneConnection( );
mPhoneModel = temp->getPhoneModel( );
syncPhone();
} else if ( temp->getIsPiSync() ) {
if ( mTargetApp == KAPI ) {
mPassWordPiSync = temp->getRemotePwAB();
mActiveSyncPort = temp->getRemotePortAB();
mActiveSyncIP = temp->getRemoteIPAB();
} else if ( mTargetApp == KOPI ) {
mPassWordPiSync = temp->getRemotePw();
mActiveSyncPort = temp->getRemotePort();
mActiveSyncIP = temp->getRemoteIP();
} else {
mPassWordPiSync = temp->getRemotePwPWM();
mActiveSyncPort = temp->getRemotePortPWM();
mActiveSyncIP = temp->getRemoteIPPWM();
}
syncPi();
while ( !mPisyncFinished ) {
//qDebug("waiting ");
qApp->processEvents();
}
timer.start();
while ( timer.elapsed () < 2000 ) {
qApp->processEvents();
}
} else
syncRemote( temp, false );
}
}
timer.start();
mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") );
while ( timer.elapsed () < 2000 ) {
qApp->processEvents();
#ifndef _WIN32_
sleep (1);
#endif
}
}
}
delete temp;
return syncedProfiles;
}
void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
{
QString question;
if ( ask ) {
question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
if ( QMessageBox::information( mParent, i18n("Sync"),
question,
i18n("Yes"), i18n("No"),
0, 0 ) != 0 )
return;
}
QString preCommand;
QString localTempFile;
QString postCommand;
switch(mTargetApp)
{
case (KAPI):
preCommand = prof->getPreSyncCommandAB();
postCommand = prof->getPostSyncCommandAB();
localTempFile = prof->getLocalTempFileAB();
break;
case (KOPI):
preCommand = prof->getPreSyncCommand();
postCommand = prof->getPostSyncCommand();
localTempFile = prof->getLocalTempFile();
break;
case (PWMPI):
preCommand = prof->getPreSyncCommandPWM();
postCommand = prof->getPostSyncCommandPWM();
localTempFile = prof->getLocalTempFilePWM();
break;
default:
qDebug("KSyncManager::syncRemote: invalid apptype selected");
break;
}
int fi;
if ( (fi = preCommand.find("$PWD$")) > 0 ) {
QString pwd = getPassword();
preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 );
}
int maxlen = 30;
if ( QApplication::desktop()->width() > 320 )
maxlen += 25;
mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) );
int fileSize = 0;
int result = system ( preCommand );
// 0 : okay
// 256: no such file or dir
//
qDebug("Sync: Remote copy result(0 = okay): %d ",result );
if ( result != 0 ) {
unsigned int len = maxlen;
while ( len < preCommand.length() ) {
preCommand.insert( len , "\n" );
len += maxlen +2;
}
question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ;
QMessageBox::information( mParent, i18n("Sync - ERROR"),
question,
i18n("Okay!")) ;
mParent->topLevelWidget()->setCaption ("KDE-Pim");
return;
}
mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) );
//qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
if ( syncWithFile( localTempFile, true ) ) {
if ( mWriteBackFile ) {
int fi;
if ( (fi = postCommand.find("$PWD$")) > 0 ) {
QString pwd = getPassword();
postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 );
}
mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) );
result = system ( postCommand );
qDebug("Sync:Writing back file result: %d ", result);
if ( result != 0 ) {
mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
return;
} else {
mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) );
}
}
}
return;
}
bool KSyncManager::edit_pisync_options()
{
QDialog dia( mParent, "dia", true );
dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice );
QVBoxLayout lay ( &dia );
lay.setSpacing( 5 );
lay.setMargin( 3 );
QLabel lab1 ( i18n("Password for remote access:"), &dia);
lay.addWidget( &lab1 );
QLineEdit le1 (&dia );
lay.addWidget( &le1 );
QLabel lab2 ( i18n("Remote IP address:"), &dia);
lay.addWidget( &lab2 );
QLineEdit le2 (&dia );
lay.addWidget( &le2 );
QLabel lab3 ( i18n("Remote port number:"), &dia);
lay.addWidget( &lab3 );
QLineEdit le3 (&dia );
lay.addWidget( &le3 );
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 2d0a4ab..6d89950 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -1,217 +1,221 @@
/*
This file is part of KDE-Pim/Pi.
Copyright (c) 2004 Ulf Schenk
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
$Id$
*/
#ifndef _KSYNCMANAGER_H
#define _KSYNCMANAGER_H
#include <qobject.h>
#include <qstring.h>
#include <qsocket.h>
#include <qdatetime.h>
#include <qserversocket.h>
#include <qtextstream.h>
#include <qregexp.h>
class QPopupMenu;
class KSyncProfile;
class KPimPrefs;
class QWidget;
class KSyncManager;
class KSyncInterface;
class QProgressBar;
class KServerSocket : public QServerSocket
{
Q_OBJECT
public:
KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 );
void newConnection ( int socket ) ;
void setFileName( QString fn ) {mFileName = fn;};
signals:
void file_received( bool );
void request_file();
void saveFile();
void endConnect();
private slots:
void discardClient();
void readClient();
void readBackFileFromSocket();
private :
bool blockRC;
void send_file();
void get_file();
void end_connect();
QDialog* mSyncActionDialog;
QSocket* mSocket;
QString mPassWord;
QString mFileName;
QTime piTime;
QString piFileString;
};
class KCommandSocket : public QObject
{
Q_OBJECT
public:
enum state { successR, errorR, successW, errorW, errorTO, quiet };
KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 );
void readFile( QString );
void writeFile( QString );
void sendStop();
signals:
void commandFinished( KCommandSocket*, int );
private slots:
void startReadFileFromSocket();
void readFileFromSocket();
void deleteSocket();
void writeFileToSocket();
private :
QSocket* mSocket;
QString mPassWord;
Q_UINT16 mPort;
QString mHost;
QString mFileName;
QTimer* mTimerSocket;
int mRetVal;
QTime mTime;
QString mFileString;
bool mFirst;
};
class KSyncManager : public QObject
{
Q_OBJECT
public:
enum TargetApp {
KOPI = 0,
KAPI = 1,
PWMPI = 2 };
KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu);
~KSyncManager() ;
void multiSync( bool askforPrefs );
bool blockSave() { return mBlockSaveFlag; }
void setBlockSave(bool sa) { mBlockSaveFlag = sa; }
void setDefaultFileName( QString s) { mDefFileName = s ;}
QString defaultFileName() { return mDefFileName ;}
QString syncFileName();
void enableQuick( bool ask = true);
bool syncWithDesktop () { return mSyncWithDesktop;}
QString getCurrentSyncDevice() { return mCurrentSyncDevice; }
QString getCurrentSyncName() { return mCurrentSyncName; }
void showProgressBar(int percentage, QString caption = QString::null, int total=100);
void hideProgressBar();
bool isProgressBarCanceled();
// sync stuff
QString mLocalMachineName;
QStringList mExternSyncProfiles;
QStringList mSyncProfileNames;
bool mAskForPreferences;
bool mShowSyncSummary;
bool mIsKapiFile;
bool mWriteBackExistingOnly;
int mSyncAlgoPrefs;
bool mWriteBackFile;
int mWriteBackInFuture;
int mWriteBackInPast;
QString mPhoneDevice;
QString mPhoneConnection;
QString mPhoneModel;
QString mPassWordPiSync;
QString mActiveSyncPort;
QString mActiveSyncIP ;
+ QString mFilterInCal;
+ QString mFilterOutCal;
+ QString mFilterInAB;
+ QString mFilterOutAB;
static QDateTime mRequestedSyncEvent;
signals:
void save();
void request_file();
void getFile( bool );
public slots:
void slotSyncMenu( int );
void slotClearMenu( int action );
void deleteCommandSocket(KCommandSocket*s, int state);
void readFileFromSocket();
void fillSyncMenu();
private:
void syncPi();
KServerSocket * mServerSocket;
KPimPrefs* mPrefs;
QString mDefFileName;
QString mCurrentSyncDevice;
QString mCurrentSyncName;
void quickSyncLocalFile();
bool syncWithFile( QString fn , bool quick );
void syncLocalFile();
void syncPhone();
void syncSharp();
void syncKDE();
bool syncExternalApplication(QString);
int mCurrentSyncProfile ;
void syncRemote( KSyncProfile* prof, bool ask = true);
bool edit_sync_options();
bool edit_pisync_options();
int ringSync();
QString getPassword( );
bool mPisyncFinished;
bool mBlockSaveFlag;
QWidget* mParent;
KSyncInterface* mImplementation;
TargetApp mTargetApp;
QPopupMenu* mSyncMenu;
QProgressBar* bar;
bool mSyncWithDesktop;
private slots:
void confSync();
};
class KSyncInterface
{
public :
virtual void removeSyncInfo( QString syncProfile) = 0;
virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0;
virtual bool syncExternal(KSyncManager* manager, QString resource)
{
// empty implementation, because some syncable applications do not
// have an external(sharpdtm) syncmode, like pwmanager.
return false;
}
};
#endif