summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2004-10-20 12:05:18 (UTC)
committer zautrix <zautrix>2004-10-20 12:05:18 (UTC)
commit5cf3c1bce58a6487af166e637e54571e98156fd0 (patch) (side-by-side diff)
tree2e1ba14350aa322bb21729cf462b96e658fa6929 /korganizer
parente2a0df411042d986adb31b28f9e0a2f17395358c (diff)
downloadkdepimpi-5cf3c1bce58a6487af166e637e54571e98156fd0.zip
kdepimpi-5cf3c1bce58a6487af166e637e54571e98156fd0.tar.gz
kdepimpi-5cf3c1bce58a6487af166e637e54571e98156fd0.tar.bz2
OL import fixes
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koimportoldialog.cpp3
-rw-r--r--korganizer/mainwindow.cpp8
2 files changed, 9 insertions, 2 deletions
diff --git a/korganizer/koimportoldialog.cpp b/korganizer/koimportoldialog.cpp
index 0a3c2d5..c0bde0d 100644
--- a/korganizer/koimportoldialog.cpp
+++ b/korganizer/koimportoldialog.cpp
@@ -1,445 +1,446 @@
/*
This file is part of KOrganizer.
Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#include <qtooltip.h>
#include <qframe.h>
#include <qpixmap.h>
#include <qlayout.h>
#include <qprogressbar.h>
#include <qwidgetstack.h>
#include <qdatetime.h>
#include <qdir.h>
#include <qapplication.h>
#include <qhbox.h>
+#include <qregexp.h>
#include <qheader.h>
#include <qdatetime.h>
#include <qlistview.h>
#include <kdebug.h>
#include <klocale.h>
#include <kstandarddirs.h>
#include <kmessagebox.h>
#include <kfiledialog.h>
#include <libkdepim/categoryselectdialog.h>
#include <libkdepim/kinputdialog.h>
#include <libkcal/calendarlocal.h>
#include <libkcal/icalformat.h>
#include <kabc/stdaddressbook.h>
#include "koprefs.h"
#include "koglobals.h"
#include "koimportoldialog.h"
#include "../outport/msoutl9.h"
#include <ole2.h>
#include <comutil.h>
_Application gOlApp;
QDateTime mDdate2Qdtr( DATE dt)
{
COleDateTime odt;
SYSTEMTIME st;
odt = dt;
odt.GetAsSystemTime(st);
QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) );
return qdt;
}
class OLEListViewItem : public QCheckListItem
{
public:
OLEListViewItem( QListView *parent, QString text ) :
QCheckListItem( parent, text, QCheckListItem::CheckBox ) { ; };
OLEListViewItem( QListViewItem *after, QString text ) :
QCheckListItem( after, text, QCheckListItem::CheckBox ) { ; };
~OLEListViewItem() {};
void setData( DWORD data ) {mData= data; };
DWORD data() { return mData ;};
private:
DWORD mData;
};
KOImportOLdialog::KOImportOLdialog( const QString &caption,
Calendar *calendar, QWidget *parent ) :
KDialogBase( Plain, caption, User1 | Close, Ok,
parent, caption, true, false, i18n("Import!") )
{
QHBox * mw = new QHBox( this );
setMainWidget( mw );
mListView = new QListView( mw );
mListView->addColumn(i18n("Select Folder to import"));
mListView->addColumn(i18n("Content Type"));
mCalendar = calendar;
connect( this, SIGNAL( user1Clicked() ),SLOT ( slotApply()));
setupFolderView();
resize( sizeHint().width()+50, sizeHint().height()+50 );
}
KOImportOLdialog::~KOImportOLdialog()
{
}
void KOImportOLdialog::setupFolderView()
{
SCODE sc = ::OleInitialize(NULL);
if ( FAILED ( sc ) ) {
KMessageBox::information(this,"OLE initialisation failed");
return;
}
if(!gOlApp.CreateDispatch(_T("Outlook.Application"),NULL)){
KMessageBox::information(this,"Sorry, cannot access Outlook");
return ;
}
MAPIFolder mfInbox;
MAPIFolder mfRoot;
CString szName;
_NameSpace olNS;
olNS = gOlApp.GetNamespace(_T("MAPI"));
mfInbox = olNS.GetDefaultFolder(6);
mfRoot = mfInbox.GetParent();
szName = mfRoot.GetName();
long iType = mfRoot.GetDefaultItemType();
QString mes;
mes = QString::fromUcs2( szName.GetBuffer() );
OLEListViewItem * root = new OLEListViewItem( mListView, mes );
mfRoot.m_lpDispatch->AddRef();
addFolder( root, mfRoot.m_lpDispatch );
root->setOpen( true );
mListView->setSortColumn( 0 );
mListView->sort( );
}
void KOImportOLdialog::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent)
{
MAPIFolder mfParent(dispParent), mfChild;
_Folders folders;
_variant_t fndx((long)0);
CString szName;
long iType;
OLEListViewItem* hChild;
folders = mfParent.GetFolders();
for(int i=1; i <= folders.GetCount(); ++i)
{
fndx = (long)i;
mfChild = folders.Item(fndx.Detach());
mfChild.m_lpDispatch->AddRef();
szName = mfChild.GetName();
iType = mfChild.GetDefaultItemType();
hChild = new OLEListViewItem( iParent , QString::fromUcs2( szName.GetBuffer() ) );
if ( iType != 1)
hChild->setEnabled( false );
QString ts;
switch( iType ) {
case 0:
ts = i18n("Mail");
break;
case 1:
ts = i18n("Calendar");
break;
case 2:
ts = i18n("Contacts");
break;
case 3:
ts = i18n("Todos");
break;
case 4:
ts = i18n("Journals");
break;
case 5:
ts = i18n("Notes");
break;
default:
ts = i18n("Unknown");
}
hChild->setText( 1,ts);
hChild->setData( (DWORD) mfChild.m_lpDispatch );
mfChild.m_lpDispatch->AddRef();
addFolder(hChild, mfChild.m_lpDispatch);
}
}
void KOImportOLdialog::slotApply()
{
importedItems = 0;
OLEListViewItem* child = (OLEListViewItem*) mListView->firstChild();
while ( child ) {
if ( child->isOn() )
readCalendarData( child->data() );
child = (OLEListViewItem*) child->itemBelow();
}
QString mes = i18n("Importing complete.\n\n%1 items imported.").arg( importedItems);
KMessageBox::information(this,mes);
}
void KOImportOLdialog::readCalendarData( DWORD folder )
{
LPDISPATCH dispItem = (LPDISPATCH)folder;
dispItem->AddRef();
MAPIFolder mf(dispItem);
mf.m_lpDispatch->AddRef();
_Items folderItems;
_variant_t indx((long)0);
LPDISPATCH itm;
int i;
folderItems = mf.GetItems();
QProgressBar bar( folderItems.GetCount(),0 );
bar.setCaption (i18n("Importing - close to abort!") );
int h = bar.sizeHint().height() ;
int w = 300;
int dw = QApplication::desktop()->width();
int dh = QApplication::desktop()->height();
bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
bar.show();
for(i=1; i <= folderItems.GetCount(); ++i)
{
qApp->processEvents();
if ( ! bar.isVisible() )
return ;
bar.setProgress( i );
indx = (long)i;
itm = folderItems.Item(indx.Detach());
_AppointmentItem * pItem = (_AppointmentItem *)&itm;
ol2kopiCalendar( pItem );
itm->Release();
}
}
void KOImportOLdialog::slotOk()
{
QDialog::accept();
}
void KOImportOLdialog::ol2kopiCalendar( _AppointmentItem * aItem, bool computeRecurrence )
{
KCal::Event* event = new KCal::Event();
if ( aItem->GetAllDayEvent() ){
event->setDtStart( QDateTime( mDdate2Qdtr( aItem->GetStart()).date(),QTime(0,0,0 ) ));
event->setDtEnd( QDateTime( mDdate2Qdtr( aItem->GetEnd()) .date(),QTime(0,0,0 )).addDays(-1));
event->setFloats( true );
} else {
event->setDtStart( mDdate2Qdtr( aItem->GetStart()) );
event->setDtEnd( mDdate2Qdtr( aItem->GetEnd()) );
event->setFloats( false );
}
event->setSummary( QString::fromUcs2( aItem->GetSubject().GetBuffer()) );
event->setLocation( QString::fromUcs2( aItem->GetLocation().GetBuffer()) );
- event->setDescription( QString::fromUcs2( aItem->GetBody().GetBuffer()) );
+ event->setDescription( QString::fromUcs2( aItem->GetBody().GetBuffer()).replace( QRegExp("\\r"), "") );
QString cat = QString::fromUcs2( aItem->GetCategories().GetBuffer());
event->setCategories( QStringList::split( ";", cat ));
if ( aItem->GetReminderSet() ) {
event->clearAlarms();
Alarm* alarm = event->newAlarm();
alarm->setStartOffset( -aItem->GetReminderMinutesBeforeStart()*60 );
alarm->setEnabled( true );
if ( aItem->GetReminderPlaySound() ) {
alarm->setType( Alarm::Audio );
alarm->setAudioFile( QString::fromUcs2( aItem->GetReminderSoundFile().GetBuffer()));
}
else
alarm->setType( Alarm::Display );
alarm->setRepeatCount( aItem->GetReplyTime() );
}
// OL :pub 0 - pers 1 - priv 2 - conf 3
// KO : pub 0 - priv 1 - conf 2
int sec = aItem->GetSensitivity() ;
if ( sec > 1 )// mapping pers -> private
--sec;
event->setSecrecy( sec );
if ( aItem->GetBusyStatus() == 0 )
event->setTransparency( Event::Transparent);// OL free
else
event->setTransparency( Event::Opaque);//OL all other
if ( aItem->GetIsRecurring() && computeRecurrence ) { //recur
RecurrencePattern recpat = aItem->GetRecurrencePattern();
QDate startDate = mDdate2Qdtr(recpat.GetPatternStartDate()).date();
int freq = recpat.GetInterval();
bool hasEndDate = !recpat.GetNoEndDate();
QDate endDate = mDdate2Qdtr(recpat.GetPatternEndDate()).date();
QBitArray weekDays( 7 );
weekDays.fill(false );
uint weekDaysNum = recpat.GetDayOfWeekMask();
int i;
int bb = 2;
for( i = 1; i <= 6; ++i ) {
weekDays.setBit( i - 1, ( bb & weekDaysNum ));
bb = 4 << (i-1);
//qDebug(" %d bit %d ",i-1,weekDays.at(i-1) );
}
if ( 1 & weekDaysNum)
weekDays.setBit( 6 );
// int pos = 1;// pending
Recurrence *r = event->recurrence();
int rtype = recpat.GetRecurrenceType();
//recurrence types are:
/*
olRecursDaily(0)
olRecursWeekly(1)
olRecursMonthly(2)
olRecursMonthNth(3)
olRecursYearly(5)
olRecursYearNth(6)
*/
int duration = recpat.GetOccurrences();
if ( !hasEndDate )
duration = -1;
//LPDISPATCH RecurrencePattern::GetExceptions()
//long RecurrencePattern::GetMonthOfYear()
if ( rtype == 0 ) {
if ( hasEndDate ) r->setDaily( freq, endDate );
else r->setDaily( freq, duration );
} else if ( rtype == 1 ) {
if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate );
else r->setWeekly( freq, weekDays, duration );
} else if ( rtype == 2 ) {
if ( hasEndDate )
r->setMonthly( Recurrence::rMonthlyDay, freq, endDate );
else
r->setMonthly( Recurrence::rMonthlyDay, freq, duration );
//r->addMonthlyDay( startDate.day() );
r->addMonthlyDay( recpat.GetDayOfMonth() );
} else if ( rtype == 3 ) {
if ( hasEndDate )
r->setMonthly( Recurrence::rMonthlyPos, freq, endDate );
else
r->setMonthly( Recurrence::rMonthlyPos, freq, duration );
QBitArray days( 7 );
days.fill( false );
days.setBit( startDate.dayOfWeek() - 1 );
int pos = (startDate.day()/7)+1;
r->addMonthlyPos( pos, days );
//QString mes = i18n("Importing monthlypos.\n\npos: %1 , day: %2").arg( pos).arg( startDate.dayOfWeek() - 1);
//KMessageBox::information(this,mes);
} else if ( rtype == 5 ) {
freq = 1;
if ( hasEndDate )
r->setYearly( Recurrence::rYearlyMonth, freq, endDate );
else
r->setYearly( Recurrence::rYearlyMonth, freq, duration );
r->addYearlyNum( startDate.month() );
} else if ( true /*rtype == 6*/ ) {
// KOganizer cannot handle this in the GUI
// we are mapping this to monthly - every 12. month
freq = 12;
if ( hasEndDate )
r->setMonthly( Recurrence::rMonthlyPos, freq, endDate );
else
r->setMonthly( Recurrence::rMonthlyPos, freq, duration );
QBitArray days( 7 );
days.fill( false );
days.setBit( startDate.dayOfWeek() - 1 );
int pos = (startDate.day()/7)+1;
r->addMonthlyPos( pos, days );
}
// recurrence exceptions
LPDISPATCH dispItem = recpat.GetExceptions();
dispItem->AddRef();
Exceptions ex(dispItem);
_variant_t indx((long)0);
LPDISPATCH itm;
for(i=1; i <= ex.GetCount(); ++i) {
indx = (long)i;
itm = ex.Item( indx.Detach() );
::Exception * pItem = (::Exception *)&itm;
event->addExDate( QDateTime( mDdate2Qdtr( pItem->GetOriginalDate())).date() );
if ( !pItem->GetDeleted() ) {
LPDISPATCH appIt = pItem->GetAppointmentItem();
_AppointmentItem * paItem = (_AppointmentItem *)&appIt;
ol2kopiCalendar( paItem, false );
}
itm->Release();
}
}
// recurrence ENTE
event->setOrganizer( QString::fromUcs2( aItem->GetOrganizer().GetBuffer()));
//GetOptionalAttendees()
//GetRequiredAttendees()
LPDISPATCH dispItem = aItem->GetRecipients();
dispItem->AddRef();
_Folders mf(dispItem);
mf.m_lpDispatch->AddRef();
_variant_t indx((long)0);
LPDISPATCH itm;
int i;
QString optAtt = QString::fromUcs2( aItem->GetOptionalAttendees().GetBuffer());
QString reqAtt = QString::fromUcs2( aItem->GetRequiredAttendees().GetBuffer());
//GetRequiredAttendees()
for(i=1; i <= mf.GetCount(); ++i) {
indx = (long)i;
itm = mf.Item( indx.Detach() );
Recipient * pItem = (Recipient *)&itm;
//a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
QString name = QString::fromUcs2( pItem->GetName().GetBuffer());
KCal::Attendee::PartStat stat;
bool rsvp = false;
switch ( pItem->GetMeetingResponseStatus() ) {
case 0: //not answered
rsvp = true;
case 5: //not answered
stat = Attendee::NeedsAction;
break;
case 1: //organizer
stat = Attendee::Delegated ;
break;
case 2: //tentative
stat = Attendee::Tentative ;
break;
case 3: //accepted
stat = Attendee::Accepted;
break;
case 4: //declined
stat =Attendee::Declined ;
break;
default:
stat = Attendee::NeedsAction ;
}
KCal::Attendee::Role role;
if ( event->organizer() == name )
role = KCal::Attendee::Chair;
else if ( reqAtt.find( name ) >= 0 )
role = KCal::Attendee::ReqParticipant;
else if ( optAtt.find( name ) >= 0 )
role = KCal::Attendee::OptParticipant;
else
role = KCal::Attendee::NonParticipant;
QString mail = QString::fromUcs2(pItem->GetAddress().GetBuffer());
if( mail.isEmpty() && name.find("@") > 0 ) {
int kl = name.find("<");
int gr = name.find(">");
if ( kl >= 0 && gr >= 0) {
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 9e215b9..63484d6 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -99,403 +99,409 @@ class KOex2phonePrefs : public QDialog
mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
mWriteBackFuture->setChecked( true );
lay->addWidget( mWriteBackFuture );
temphb = new QHBox( this );
new QLabel( i18n("Max. weeks in future: ") , temphb );
mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
mWriteBackFutureWeeks->setValue( 8 );
lay->addWidget( temphb );
lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
lab->setAlignment (AlignHCenter );
QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
lay->addWidget( ok );
QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
lay->addWidget( cancel );
connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
resize( 220, 240 );
}
public:
QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
QCheckBox* mWriteBackFuture;
QSpinBox* mWriteBackFutureWeeks;
};
int globalFlagBlockStartup;
MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
QMainWindow( parent, name )
{
#ifdef DESKTOP_VERSION
setFont( QFont("Arial"), 14 );
#endif
mClosed = false;
//QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
QString confFile = locateLocal("config","korganizerrc");
QFileInfo finf ( confFile );
bool showWarning = !finf.exists();
setIcon(SmallIcon( "ko24" ) );
mBlockAtStartup = true;
mFlagKeyPressed = false;
setCaption("KOrganizer/Pi");
KOPrefs *p = KOPrefs::instance();
KPimGlobalPrefs::instance()->setGlobalConfig();
if ( p->mHourSize > 18 )
p->mHourSize = 18;
QMainWindow::ToolBarDock tbd;
if ( p->mToolBarHor ) {
if ( p->mToolBarUp )
tbd = Bottom;
else
tbd = Top;
}
else {
if ( p->mToolBarUp )
tbd = Right;
else
tbd = Left;
}
if ( KOPrefs::instance()->mUseAppColors )
QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
globalFlagBlockStartup = 1;
iconToolBar = new QPEToolBar( this );
addToolBar (iconToolBar , tbd );
mCalendarModifiedFlag = false;
QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
splash->setAlignment ( AlignCenter );
setCentralWidget( splash );
#ifndef DESKTOP_VERSION
showMaximized();
#endif
//qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
setDefaultPreferences();
mCalendar = new CalendarLocal();
mView = new CalendarView( mCalendar, this,"mCalendar " );
mView->hide();
//mView->resize(splash->size() );
initActions();
mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
mSyncManager->setBlockSave(false);
mView->setSyncManager(mSyncManager);
#ifndef DESKTOP_VERSION
iconToolBar->show();
qApp->processEvents();
#endif
//qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
int vh = height() ;
int vw = width();
//qDebug("Toolbar hei %d ",iconToolBar->height() );
if ( iconToolBar->orientation () == Qt:: Horizontal ) {
vh -= iconToolBar->height();
} else {
vw -= iconToolBar->height();
}
//mView->setMaximumSize( splash->size() );
//mView->resize( splash->size() );
//qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
mView->readSettings();
bool newFile = false;
if( !QFile::exists( defaultFileName() ) ) {
QFileInfo finfo ( defaultFileName() );
QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
qDebug("oldfile %s ", oldFile.latin1());
QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
finfo.setFile( oldFile );
if (finfo.exists() ) {
KMessageBox::information( this, message);
mView->openCalendar( oldFile );
qApp->processEvents();
} else {
oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
finfo.setFile( oldFile );
if (finfo.exists() ) {
KMessageBox::information( this, message);
mView->openCalendar( oldFile );
qApp->processEvents();
}
}
mView->saveCalendar( defaultFileName() );
newFile = true;
}
QTime neededSaveTime = QDateTime::currentDateTime().time();
mView->openCalendar( defaultFileName() );
int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
qDebug("KO: Calendar loading time: %d ms",msNeeded );
if ( KOPrefs::instance()->mLanguageChanged ) {
KOPrefs::instance()->setCategoryDefaults();
int count = mView->addCategories();
KOPrefs::instance()->mLanguageChanged = false;
}
processIncidenceSelection( 0 );
connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
SLOT( processIncidenceSelection( Incidence * ) ) );
connect( mView, SIGNAL( modifiedChanged( bool ) ),
SLOT( slotModifiedChanged( bool ) ) );
connect( mView, SIGNAL( tempDisableBR(bool) ),
SLOT( disableBR(bool) ) );
connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
mView->setModified( false );
mBlockAtStartup = false;
mView->setModified( false );
setCentralWidget( mView );
globalFlagBlockStartup = 0;
mView->show();
delete splash;
if ( newFile )
mView->updateConfig();
// qApp->processEvents();
//qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
//fillSyncMenu();
connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
mSyncManager->setDefaultFileName( defaultFileName());
connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
mSyncManager->fillSyncMenu();
mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
if ( showWarning ) {
KMessageBox::information( this,
"You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
qApp->processEvents();
mView->dialogManager()->showSyncOptions();
}
//US listen for result adressed from Ka/Pi
#ifndef DESKTOP_VERSION
connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
#endif
#ifndef DESKTOP_VERSION
infrared = 0;
#endif
mBRdisabled = false;
toggleBeamReceive();
}
MainWindow::~MainWindow()
{
//qDebug("MainWindow::~MainWindow() ");
//save toolbar location
delete mCalendar;
delete mSyncManager;
+#ifndef DESKTOP_VERSION
if ( infrared )
delete infrared;
+#endif
}
void MainWindow::disableBR(bool b)
{
+#ifndef DESKTOP_VERSION
if ( b ) {
if ( infrared ) {
toggleBeamReceive();
mBRdisabled = true;
}
+ mBRdisabled = true;
} else {
if ( mBRdisabled ) {
mBRdisabled = false;
- toggleBeamReceive();
+ //makes no sense,because other cal ap is probably running
+ // toggleBeamReceive();
}
}
+#endif
}
bool MainWindow::beamReceiveEnabled()
{
#ifndef DESKTOP_VERSION
return ( infrared != 0 );
#endif
return false;
}
void MainWindow::toggleBeamReceive()
{
if ( mBRdisabled )
return;
#ifndef DESKTOP_VERSION
if ( infrared ) {
qDebug("disable BeamReceive ");
delete infrared;
infrared = 0;
brAction->setOn(false);
return;
}
qDebug("enable BeamReceive ");
brAction->setOn(true);
infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ;
QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& )));
#endif
}
void MainWindow::showMaximized ()
{
#ifndef DESKTOP_VERSION
if ( ! globalFlagBlockStartup )
if ( mClosed )
mView->goToday();
#endif
QWidget::showMaximized () ;
mClosed = false;
}
void MainWindow::closeEvent( QCloseEvent* ce )
{
if ( ! KOPrefs::instance()->mAskForQuit ) {
saveOnClose();
mClosed = true;
ce->accept();
return;
}
switch( QMessageBox::information( this, "KO/Pi",
i18n("Do you really want\nto close KO/Pi?"),
i18n("Close"), i18n("No"),
0, 0 ) ) {
case 0:
saveOnClose();
mClosed = true;
ce->accept();
break;
case 1:
ce->ignore();
break;
case 2:
default:
break;
}
}
void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
{
QDataStream stream( data, IO_ReadOnly );
// QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
//QString datamess;
//qDebug("message ");
qDebug("KO: QCOP message received: %s ", cmsg.data() );
if ( cmsg == "setDocument(QString)" ) {
QDataStream stream( data, IO_ReadOnly );
QString fileName;
stream >> fileName;
//qDebug("filename %s ", fileName.latin1());
showMaximized();
raise();
KOPrefs::instance()->mLastSyncedLocalFile = fileName ;
mSyncManager->slotSyncMenu( 1002 );
return;
}
if ( cmsg == "-writeFile" ) {
// I made from the "-writeFile" an "-writeAlarm"
mView->viewManager()->showWhatsNextView();
mCalendar->checkAlarmForIncidence( 0, true);
showMaximized();
raise();
return;
}
if ( cmsg == "-writeFileSilent" ) {
// I made from the "-writeFile" an "-writeAlarm"
// mView->viewManager()->showWhatsNextView();
mCalendar->checkAlarmForIncidence( 0, true);
//showMaximized();
//raise();
hide();
return;
}
if ( cmsg == "-newCountdown" ) {
qDebug("newCountdown ");
}
QString msg ;
QString allmsg = cmsg;
while ( allmsg.length() > 0 ) {
int nextC = allmsg.find( "-", 1 );
if ( nextC == -1 ) {
msg = allmsg;
allmsg = "";
} else{
msg = allmsg.left( nextC );
allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
}
//qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
if ( msg == "-newEvent" ) {
mView->newEvent();
}
if ( msg == "-newTodo" ) {
mView->newTodo();
}
if ( msg == "-showWN" ) {
mView->viewManager()->showWhatsNextView();
}
if ( msg == "-showTodo" ) {
mView->viewManager()->showTodoView();
}
if ( msg == "-showList" ) {
mView->viewManager()->showListView();
}
else if ( msg == "-showDay" ) {
mView->viewManager()->showDayView();
}
else if ( msg == "-showWWeek" ) {
mView->viewManager()->showWorkWeekView();
}
else if ( msg == "-ringSync" ) {
mSyncManager->multiSync( false );
}
else if ( msg == "-showWeek" ) {
mView->viewManager()->showWeekView();
}
else if ( msg == "-showTodo" ) {
mView->viewManager()->showTodoView();
}
else if ( msg == "-showJournal" ) {
mView->dateNavigator()->selectDates( 1 );
mView->dateNavigator()->selectToday();
mView->viewManager()->showJournalView();
}
else if ( msg == "-showKO" ) {
mView->viewManager()->showNextXView();
}
else if ( msg == "-showWNext" || msg == "nextView()" ) {
mView->viewManager()->showWhatsNextView();
}
else if ( msg == "-showNextXView" ) {
mView->viewManager()->showNextXView();
}
}
showMaximized();
raise();
}
QPixmap MainWindow::loadPixmap( QString name )
{
return SmallIcon( name );
}
void MainWindow::initActions()
{
//KOPrefs::instance()->mShowFullMenu
iconToolBar->clear();
KOPrefs *p = KOPrefs::instance();
//QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
QPopupMenu *viewMenu = new QPopupMenu( this );