summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp46
-rw-r--r--core/pim/datebook/datebook.h2
-rw-r--r--core/pim/datebook/datebooksettings.cpp5
-rw-r--r--core/pim/datebook/datebooksettings.h1
-rw-r--r--core/pim/datebook/datebooksettingsbase.ui165
5 files changed, 199 insertions, 20 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index 6dd8918..cf1eeca 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -149,337 +149,355 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f )
a->setToggleAction( TRUE );
weekLstAction = a;
a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) );
a->addTo( sub_bar );
a->addTo( view );
a->setToggleAction( TRUE );
monthAction = a;
a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, g, 0 );
connect( a, SIGNAL(activated()), this, SLOT(slotFind()) );
a->addTo( sub_bar );
a = new QAction( tr( "Edit..." ), QString::null, 0, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
a->addTo( settings );
if(defaultView==DAY) viewDay();
if(defaultView==WEEK) needEvilHack=true; // viewWeek();
if(defaultView==WEEKLST) viewWeekLst();
if(defaultView==MONTH) viewMonth();
connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) );
connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) );
#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), this, SLOT(appMessage(const QCString&, const QByteArray&)) );
#endif
// listen on QPE/System
#if defined(Q_WS_QWS)
#if !defined(QT_NO_COP)
QCopChannel *channel = new QCopChannel( "QPE/System", this );
connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) );
channel = new QCopChannel( "QPE/Datebook", this );
connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) );
qDebug("olle\n");
#endif
#endif
qDebug("done t=%d", t.elapsed() );
/*
* Here is a problem description:
* When Weekview is the default view
* a DateBookWeekView get's created
* redraw() get's called. So what?
* Remember that we're still in the c'tor
* and no final layout has happened? Ok
* now all Events get arranged. Their x
* position get's determined by a QHeader
* position. But the QHeader isn't layouted or
* at the right position. redraw() is a slot
* so we'll call it then via a singleShot
* from view()
*/
if( needEvilHack ){
QTimer::singleShot( 500, this, SLOT(viewWeek()) );
}
}
void DateBook::receive( const QCString &msg, const QByteArray &data )
{
QDataStream stream( data, IO_ReadOnly );
if ( msg == "timeChange(QString)" ) {
// update active view!
if ( dayAction->isOn() )
viewDay();
else if ( weekAction->isOn() )
viewWeek();
else if ( monthAction->isOn() )
viewMonth();
}
else if (msg == "editEvent(int)") {
int uid;
stream >> uid;
Event e=db->eventByUID(uid);
editEvent(e);
}
}
DateBook::~DateBook()
{
}
void DateBook::slotSettings()
{
DateBookSettings frmSettings( ampm, this );
frmSettings.setStartTime( startTime );
frmSettings.setAlarmPreset( aPreset, presetTime );
frmSettings.setJumpToCurTime( bJumpToCurTime );
frmSettings.setRowStyle( rowStyle );
frmSettings.comboDefaultView->setCurrentItem(defaultView-1);
frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig);
+ bool found=false;
+ for (int i=0; i<(frmSettings.comboLocation->count()); i++) {
+ if ( frmSettings.comboLocation->text(i) == defaultLocation ) {
+ frmSettings.comboLocation->setCurrentItem(i);
+ found=true;
+ break;
+ }
+ }
+ if(!found) {
+ frmSettings.comboLocation->insertItem(defaultLocation);
+ frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1);
+ }
+ frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar"));
+
#if defined (Q_WS_QWS) || defined(_WS_QWS_)
frmSettings.showMaximized();
#endif
if ( frmSettings.exec() ) {
aPreset = frmSettings.alarmPreset();
presetTime = frmSettings.presetTime();
startTime = frmSettings.startTime();
bJumpToCurTime = frmSettings.jumpToCurTime();
rowStyle = frmSettings.rowStyle();
defaultView=frmSettings.comboDefaultView->currentItem()+1;
weeklistviewconfig=frmSettings.comboWeekListView->currentItem();
+ defaultLocation=frmSettings.comboLocation->currentText();
+ defaultCategories=frmSettings.comboCategory->currentCategories();
if ( dayView ) {
dayView->setStartViewTime( startTime );
dayView->setJumpToCurTime( bJumpToCurTime );
dayView->setRowStyle( rowStyle );
}
if ( weekView ) {
weekView->setStartViewTime( startTime );
}
saveSettings();
// make the change obvious
if ( views->visibleWidget() ) {
if ( views->visibleWidget() == dayView )
dayView->redraw();
else if ( views->visibleWidget() == weekView )
weekView->redraw();
else if ( views->visibleWidget() == weekLstView )
weekLstView->redraw();
}
}
}
void DateBook::fileNew()
{
slotNewEventFromKey("");
}
QString DateBook::checkEvent(const Event &e)
{
/* check if overlaps with itself */
bool checkFailed = FALSE;
/* check the next 12 repeats. should catch most problems */
QDate current_date = e.start().date();
Event previous = e;
for(int i = 0; i < 12; i++)
{
QDateTime next;
if (!nextOccurance(previous, current_date.addDays(1), next)) {
break; // no more repeats
}
if(next < previous.end()) {
checkFailed = TRUE;
break;
}
current_date = next.date();
}
if(checkFailed)
return tr("Event duration is potentially longer\n"
"than interval between repeats.");
return QString::null;
}
QDate DateBook::currentDate()
{
QDate d = QDate::currentDate();
if ( dayView && views->visibleWidget() == dayView ) {
d = dayView->date();
} else if ( weekView && views->visibleWidget() == weekView ) {
d = weekView->date();
} else if ( weekLstView && views->visibleWidget() == weekLstView ) {
d = weekLstView->date();
} else if ( monthView && views->visibleWidget() == monthView ) {
d = monthView->selectedDate();
}
return d;
}
void DateBook::view(int v, const QDate &d) {
if (v==DAY) {
initDay();
dayAction->setOn( TRUE );
dayView->setDate( d );
views->raiseWidget( dayView );
dayView->redraw();
} else if (v==WEEK) {
initWeek();
weekAction->setOn( TRUE );
weekView->setDate( d );
views->raiseWidget( weekView );
weekView->redraw();
} else if (v==WEEKLST) {
initWeekLst();
weekLstAction->setOn( TRUE );
weekLstView->setDate(d);
views->raiseWidget( weekLstView );
weekLstView->redraw();
} else if (v==MONTH) {
initMonth();
monthAction->setOn( TRUE );
monthView->setDate( d.year(), d.month(), d.day() );
views->raiseWidget( monthView );
monthView->redraw();
}
}
void DateBook::viewDefault(const QDate &d) {
/*
Config config("DateBook");
config.setGroup("Main");
int current=config.readNumEntry("defaultview", DAY);
view(current,d);
*/
view(defaultView,d);
}
void DateBook::viewDay() {
view(DAY,currentDate());
}
void DateBook::viewWeek() {
view(WEEK,currentDate());
}
void DateBook::viewWeekLst() {
view(WEEKLST,currentDate());
}
void DateBook::viewMonth() {
view(MONTH,currentDate());
}
void DateBook::insertEvent( const Event &e )
{
- qWarning("Adding Event!");
- db->addEvent(e);
+ Event dupEvent=e;
+ dupEvent.setLocation(defaultLocation);
+ dupEvent.setCategories(defaultCategories);
+ db->addEvent(dupEvent);
emit newEvent();
}
void DateBook::duplicateEvent( const Event &e )
{
qWarning("Hmmm...");
// Alot of code duplication, as this is almost like editEvent();
if (syncing) {
QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
return;
}
Event dupevent(e); // Make a duplicate.
// workaround added for text input.
QDialog editDlg( this, 0, TRUE );
DateEntry *entry;
editDlg.setCaption( tr("Duplicate Event") );
QVBoxLayout *vb = new QVBoxLayout( &editDlg );
QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
sv->setResizePolicy( QScrollView::AutoOneFit );
// KLUDGE!!!
sv->setHScrollBarMode( QScrollView::AlwaysOff );
vb->addWidget( sv );
entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" );
entry->timezone->setEnabled( FALSE );
sv->addChild( entry );
#if defined(Q_WS_QWS) || defined(_WS_QWS_)
editDlg.showMaximized();
#endif
while (editDlg.exec() ) {
Event newEv = entry->event();
QString error = checkEvent(newEv);
if (!error.isNull()) {
if (QMessageBox::warning(this, "error box", error, "Fix it", "Continue", 0, 0, 1) == 0)
continue;
}
db->addEvent(newEv);
emit newEvent();
break;
}
}
void DateBook::editEvent( const Event &e )
{
if (syncing) {
QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
return;
}
// workaround added for text input.
QDialog editDlg( this, 0, TRUE );
DateEntry *entry;
editDlg.setCaption( tr("Edit Event") );
QVBoxLayout *vb = new QVBoxLayout( &editDlg );
QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
sv->setResizePolicy( QScrollView::AutoOneFit );
// KLUDGE!!!
sv->setHScrollBarMode( QScrollView::AlwaysOff );
vb->addWidget( sv );
entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" );
entry->timezone->setEnabled( FALSE );
sv->addChild( entry );
#if defined(Q_WS_QWS) || defined(_WS_QWS_)
editDlg.showMaximized();
#endif
while (editDlg.exec() ) {
Event newEv = entry->event();
if(newEv.description().isEmpty() && newEv.notes().isEmpty() )
break;
newEv.setUid(e.uid()); // FIXME: Hack not to clear uid
QString error = checkEvent(newEv);
if (!error.isNull()) {
if (QMessageBox::warning(this, "error box", error, "Fix it", "Continue", 0, 0, 1) == 0) continue;
}
db->editEvent(e, newEv);
emit newEvent();
break;
}
}
void DateBook::removeEvent( const Event &e )
{
if (syncing) {
QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
return;
}
QString strName = e.description();
if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) )
return;
db->removeEvent( e );
@@ -513,206 +531,222 @@ void DateBook::initDay()
connect( dayView, SIGNAL( newEvent() ),
this, SLOT( fileNew() ) );
connect( dayView, SIGNAL( removeEvent( const Event & ) ),
this, SLOT( removeEvent( const Event & ) ) );
connect( dayView, SIGNAL( editEvent( const Event & ) ),
this, SLOT( editEvent( const Event & ) ) );
connect( dayView, SIGNAL( duplicateEvent( const Event & ) ),
this, SLOT( duplicateEvent( const Event & ) ) );
connect( dayView, SIGNAL( beamEvent( const Event & ) ),
this, SLOT( beamEvent( const Event & ) ) );
connect( dayView, SIGNAL(sigNewEvent(const QString &)),
this, SLOT(slotNewEventFromKey(const QString &)) );
}
}
void DateBook::initWeek()
{
if ( !weekView ) {
weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" );
weekView->setStartViewTime( startTime );
views->addWidget( weekView, WEEK );
connect( weekView, SIGNAL( showDate( int, int, int ) ),
this, SLOT( showDay( int, int, int ) ) );
connect( this, SIGNAL( newEvent() ),
weekView, SLOT( redraw() ) );
}
//But also get it right: the year that we display can be different
//from the year of the current date. So, first find the year
//number of the current week.
int yearNumber, totWeeks;
calcWeek( currentDate(), totWeeks, yearNumber, onMonday );
QDate d = QDate( yearNumber, 12, 31 );
calcWeek( d, totWeeks, yearNumber, onMonday );
while ( totWeeks == 1 ) {
d = d.addDays( -1 );
calcWeek( d, totWeeks, yearNumber, onMonday );
}
if ( totWeeks != weekView->totalWeeks() )
weekView->setTotalWeeks( totWeeks );
}
void DateBook::initWeekLst() {
if ( !weekLstView ) {
weekLstView = new DateBookWeekLst( ampm, onMonday, db,
views, "weeklst view" );
views->addWidget( weekLstView, WEEKLST );
//weekLstView->setStartViewTime( startTime );
connect( weekLstView, SIGNAL( showDate( int, int, int ) ),
this, SLOT( showDay( int, int, int ) ) );
connect( weekLstView, SIGNAL( addEvent( const QDateTime &,
const QDateTime &,
const QString & , const QString &) ),
this, SLOT( slotNewEntry( const QDateTime &,
const QDateTime &,
const QString & , const QString &) ) );
connect( this, SIGNAL( newEvent() ),
weekLstView, SLOT( redraw() ) );
connect( weekLstView, SIGNAL( editEvent( const Event & ) ),
this, SLOT( editEvent( const Event & ) ) );
}
}
void DateBook::initMonth()
{
if ( !monthView ) {
monthView = new DateBookMonth( views, "month view", FALSE, db );
views->addWidget( monthView, MONTH );
connect( monthView, SIGNAL( dateClicked( int, int, int ) ),
this, SLOT( showDay( int, int, int ) ) );
connect( this, SIGNAL( newEvent() ),
monthView, SLOT( redraw() ) );
qApp->processEvents();
}
}
void DateBook::loadSettings()
{
Config qpeconfig( "qpe" );
qpeconfig.setGroup("Time");
ampm = qpeconfig.readBoolEntry( "AMPM", TRUE );
onMonday = qpeconfig.readBoolEntry( "MONDAY" );
Config config("DateBook");
config.setGroup("Main");
startTime = config.readNumEntry("startviewtime", 8);
aPreset = config.readBoolEntry("alarmpreset");
presetTime = config.readNumEntry("presettime");
bJumpToCurTime = config.readBoolEntry("jumptocurtime");
rowStyle = config.readNumEntry("rowstyle");
defaultView = config.readNumEntry("defaultview",DAY);
weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL);
+
+ defaultLocation=config.readEntry("defaultLocation");
+ QString tmpString=config.readEntry("defaultCategories");
+ QStringList tmpStringList=QStringList::split(",",tmpString);
+ defaultCategories.truncate(0);
+ for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) {
+ defaultCategories.resize(defaultCategories.count()+1);
+ defaultCategories[defaultCategories.count()-1]=(*i).toInt();
+ }
}
void DateBook::saveSettings()
{
Config config( "qpe" );
Config configDB( "DateBook" );
configDB.setGroup( "Main" );
configDB.writeEntry("startviewtime",startTime);
configDB.writeEntry("alarmpreset",aPreset);
configDB.writeEntry("presettime",presetTime);
configDB.writeEntry("jumptocurtime", bJumpToCurTime);
configDB.writeEntry("rowstyle", rowStyle);
configDB.writeEntry("defaultview",defaultView);
configDB.writeEntry("weeklistviewconfig",weeklistviewconfig);
+
+ configDB.writeEntry("defaultLocation",defaultLocation);
+ QStringList tmpStringList;
+ for( uint i=0; i<defaultCategories.count(); i++) {
+ tmpStringList << QString::number(defaultCategories[i]);
+ }
+ configDB.writeEntry("defaultCategories",tmpStringList.join(","));
}
void DateBook::appMessage(const QCString& msg, const QByteArray& data)
{
bool needShow = FALSE;
if ( msg == "alarm(QDateTime,int)" ) {
QDataStream ds(data,IO_ReadOnly);
QDateTime when; int warn;
ds >> when >> warn;
// check to make it's okay to continue,
// this is the case that the time was set ahead, and
// we are forced given a stale alarm...
QDateTime current = QDateTime::currentDateTime();
if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() )
return;
QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60));
if ( list.count() > 0 ) {
QString msg;
bool bSound = FALSE;
int stopTimer = 0;
bool found = FALSE;
for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) {
if ( (*it).event().hasAlarm() ) {
found = TRUE;
msg += "<CENTER><B>" + (*it).description() + "</B>"
+ "<BR>" + (*it).location() + "<BR>"
+ TimeString::dateString((*it).event().start(),ampm)
+ (warn
? tr(" (in " + QString::number(warn)
+ tr(" minutes)"))
: QString(""))
+ "<BR>"
+ (*it).notes() + "</CENTER>";
if ( (*it).event().alarmSound() != Event::Silent ) {
bSound = TRUE;
}
}
}
if ( found ) {
if ( bSound ) {
Sound::soundAlarm();
alarmCounter = 0;
stopTimer = startTimer( 5000 );
}
QDialog dlg( this, 0, TRUE );
QVBoxLayout *vb = new QVBoxLayout( &dlg );
QScrollView *view = new QScrollView( &dlg, "scrollView");
view->setResizePolicy( QScrollView::AutoOneFit );
vb->addWidget( view );
QLabel *lblMsg = new QLabel( msg, &dlg );
view->addChild( lblMsg );
QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg );
connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) );
vb->addWidget( cmdOk );
#if defined(Q_WS_QWS) || defined(_WS_QWS_)
dlg.showMaximized();
#endif
needShow = dlg.exec();
if ( bSound )
killTimer( stopTimer );
}
}
} else if ( msg == "nextView()" ) {
if ( !qApp-> activeWindow ( )) {
needShow = TRUE;
} else {
QWidget* cur = views->visibleWidget();
if ( cur ) {
if ( cur == dayView )
viewWeek();
else if ( cur == weekView )
viewWeekLst();
else if ( cur == weekLstView )
viewMonth();
else if ( cur == monthView )
viewDay();
needShow = TRUE;
}
}
}
if ( needShow ) {
#if defined(Q_WS_QWS) || defined(_WS_QWS_)
showMaximized();
#else
show();
#endif
raise();
QPEApplication::setKeepRunning();
setActiveWindow();
}
}
@@ -748,212 +782,216 @@ void DateBook::changeClock( bool newClock )
if (dayView) dayView->redraw();
if (weekView) weekView->redraw();
if (weekLstView) weekLstView->redraw();
}
void DateBook::changeWeek( bool m )
{
/* no need to redraw, each widget catches. Do need to
store though for widgets we haven't made yet */
onMonday = m;
}
void DateBook::slotToday()
{
// we need to view today using default view
view(defaultView,QDate::currentDate());
}
void DateBook::closeEvent( QCloseEvent *e )
{
if(syncing) {
/* no need to save, did that at flush */
e->accept();
return;
}
// save settings will generate it's own error messages, no
// need to do checking ourselves.
saveSettings();
if ( db->save() ) {
e->accept();
} else {
if ( QMessageBox::critical( this, tr( "Out of space" ),
tr("Calendar was unable to save\n"
"your changes.\n"
"Free up some space and try again.\n"
"\nQuit anyway?"),
QMessageBox::Yes|QMessageBox::Escape,
QMessageBox::No|QMessageBox::Default )
!= QMessageBox::No )
e->accept();
else
e->ignore();
}
}
// Entering directly from the "keyboard"
void DateBook::slotNewEventFromKey( const QString &str )
{
if (syncing) {
QMessageBox::warning( this, tr("Calendar"),
tr( "Can not edit data, currently syncing") );
return;
}
// We get to here from a key pressed in the Day View
// So we can assume some things. We want the string
// passed in to be part of the description.
QDateTime start, end;
if ( views->visibleWidget() == dayView ) {
dayView->selectedDates( start, end );
} else if ( views->visibleWidget() == monthView ) {
QDate d = monthView->selectedDate();
start = end = d;
start.setTime( QTime( 10, 0 ) );
end.setTime( QTime( 12, 0 ) );
} else if ( views->visibleWidget() == weekView ) {
QDate d = weekView->date();
start = end = d;
start.setTime( QTime( 10, 0 ) );
end.setTime( QTime( 12, 0 ) );
} else if ( views->visibleWidget() == weekLstView ) {
QDate d = weekLstView->date();
start = end = d;
start.setTime( QTime( 10, 0 ) );
end.setTime( QTime( 12, 0 ) );
}
slotNewEntry(start, end, str);
}
void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) {
// argh! This really needs to be encapsulated in a class
// or function.
QDialog newDlg( this, 0, TRUE );
newDlg.setCaption( DateEntryBase::tr("New Event") );
DateEntry *e;
QVBoxLayout *vb = new QVBoxLayout( &newDlg );
QScrollView *sv = new QScrollView( &newDlg );
sv->setResizePolicy( QScrollView::AutoOneFit );
sv->setFrameStyle( QFrame::NoFrame );
sv->setHScrollBarMode( QScrollView::AlwaysOff );
vb->addWidget( sv );
Event ev;
ev.setDescription( str );
// When the new gui comes in, change this...
if(location==0) {
+ if(defaultLocation.isEmpty()) {
ev.setLocation( tr("(Unknown)") );
} else {
+ ev.setLocation( defaultLocation );
+ }
+ } else {
ev.setLocation(location);
}
+ ev.setCategories(defaultCategories);
ev.setStart( start );
ev.setEnd( end );
e = new DateEntry( onMonday, ev, ampm, &newDlg );
e->setAlarmEnabled( aPreset, presetTime, Event::Loud );
sv->addChild( e );
#if defined(Q_WS_QWS) || defined(_WS_QWS_)
newDlg.showMaximized();
#endif
while (newDlg.exec()) {
ev = e->event();
ev.assignUid();
QString error = checkEvent( ev );
if ( !error.isNull() ) {
- if ( QMessageBox::warning( this, tr("Error!"),
- error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 )
+ if ( QMessageBox::warning( this, tr("Error!"), error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 )
continue;
}
db->addEvent( ev );
emit newEvent();
break;
}
}
void DateBook::setDocument( const QString &filename )
{
if ( filename.find(".vcs") != int(filename.length()) - 4 ) return;
QValueList<Event> tl = Event::readVCalendar( filename );
for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) {
db->addEvent( *it );
}
}
static const char * beamfile = "/tmp/obex/event.vcs";
void DateBook::beamEvent( const Event &e )
{
qDebug("trying to beamn");
unlink( beamfile ); // delete if exists
mkdir("/tmp/obex/", 0755);
Event::writeVCalendar( beamfile, e );
Ir *ir = new Ir( this );
connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
QString description = e.description();
ir->send( beamfile, description, "text/x-vCalendar" );
}
void DateBook::beamDone( Ir *ir )
{
delete ir;
unlink( beamfile );
}
void DateBook::slotFind()
{
// move it to the day view...
viewDay();
FindDialog frmFind( "Calendar", this );
frmFind.setUseDate( true );
frmFind.setDate( currentDate() );
QObject::connect( &frmFind,
SIGNAL(signalFindClicked(const QString&, const QDate&,
bool, bool, int)),
this,
SLOT(slotDoFind(const QString&, const QDate&,
bool, bool, int)) );
QObject::connect( this,
SIGNAL(signalNotFound()),
&frmFind,
SLOT(slotNotFound()) );
QObject::connect( this,
SIGNAL(signalWrapAround()),
&frmFind,
SLOT(slotWrapAround()) );
frmFind.move(0,0);
frmFind.exec();
inSearch = false;
}
bool catComp( QArray<int> cats, int category )
{
bool returnMe;
int i,
count;
count = int(cats.count());
returnMe = false;
if ( (category == -1 && count == 0) || category == -2 )
returnMe = true;
else {
for ( i = 0; i < count; i++ ) {
if ( category == cats[i] ) {
returnMe = true;
break;
}
}
}
return returnMe;
}
void DateBook::slotDoFind( const QString& txt, const QDate &dt,
bool caseSensitive, bool /*backwards*/,
int category )
{
QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ),
next;
QRegExp r( txt );
r.setCaseSensitive( caseSensitive );
diff --git a/core/pim/datebook/datebook.h b/core/pim/datebook/datebook.h
index 3f57d4a..eeb8666 100644
--- a/core/pim/datebook/datebook.h
+++ b/core/pim/datebook/datebook.h
@@ -28,109 +28,111 @@ enum { DAY=1,WEEK,WEEKLST,MONTH }; // defaultView values
enum { NONE=0,NORMAL,EXTENDED }; // WeekLstView's modes.
class QAction;
class QWidgetStack;
class DateBookDay;
class DateBookWeek;
class DateBookWeekLst;
class DateBookMonth;
class Event;
class QDate;
class Ir;
class DateBookDBHack : public DateBookDB {
public:
Event eventByUID(int id);
};
class DateBook : public QMainWindow
{
Q_OBJECT
public:
DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
~DateBook();
signals:
void newEvent();
void signalNotFound();
void signalWrapAround();
protected:
QDate currentDate();
void timerEvent( QTimerEvent *e );
void closeEvent( QCloseEvent *e );
void view(int v, const QDate &d);
public slots:
void flush();
void reload();
private slots:
void fileNew();
void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location=0);
void slotSettings();
void slotToday(); // view today
void changeClock( bool newClock );
void changeWeek( bool newDay );
void appMessage(const QCString& msg, const QByteArray& data);
// handle key events in the day view...
void slotNewEventFromKey( const QString &str );
void slotFind();
void slotDoFind( const QString &, const QDate &, bool, bool, int );
void viewDefault(const QDate &d);
void viewDay();
void viewWeek();
void viewWeekLst();
void viewMonth();
void showDay( int y, int m, int d );
void insertEvent( const Event &e );
void editEvent( const Event &e );
void duplicateEvent( const Event &e );
void removeEvent( const Event &e );
void receive( const QCString &msg, const QByteArray &data );
void setDocument( const QString & );
void beamEvent( const Event &e );
void beamDone( Ir *ir );
private:
void addEvent( const Event &e );
void initDay();
void initWeek();
void initWeekLst();
void initMonth();
void loadSettings();
void saveSettings();
private:
DateBookDBHack *db;
QWidgetStack *views;
DateBookDay *dayView;
DateBookWeek *weekView;
DateBookMonth *monthView;
DateBookWeekLst *weekLstView;
QAction *dayAction, *weekAction, *weekLstAction, *monthAction;
int weeklistviewconfig;
bool aPreset; // have everything set to alarm?
int presetTime; // the standard time for the alarm
int startTime;
int rowStyle;
int defaultView;
+ QArray<int> defaultCategories;
+ QString defaultLocation;
bool bJumpToCurTime; //should jump to current time in dayview?
bool ampm;
bool onMonday;
bool syncing;
bool inSearch;
int alarmCounter;
QString checkEvent(const Event &);
};
#endif
diff --git a/core/pim/datebook/datebooksettings.cpp b/core/pim/datebook/datebooksettings.cpp
index 49fcd17..675b17f 100644
--- a/core/pim/datebook/datebooksettings.cpp
+++ b/core/pim/datebook/datebooksettings.cpp
@@ -1,132 +1,133 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "datebooksettings.h"
#include <qpe/qpeapplication.h>
#include <qspinbox.h>
#include <qcheckbox.h>
#include <qcombobox.h>
DateBookSettings::DateBookSettings( bool whichClock, QWidget *parent,
const char *name, bool modal, WFlags fl )
: DateBookSettingsBase( parent, name, modal, fl ),
ampm( whichClock )
{
init();
- QObject::connect( qApp, SIGNAL( clockChanged( bool ) ),
- this, SLOT( slotChangeClock( bool ) ) );
+ QObject::connect( qApp, SIGNAL( clockChanged( bool ) ), this, SLOT( slotChangeClock( bool ) ) );
+ QArray<int> categories;
+ comboCategory->setCategories( categories, "Calendar", tr("Calendar") );
}
DateBookSettings::~DateBookSettings()
{
}
void DateBookSettings::setStartTime( int newStartViewTime )
{
if ( ampm ) {
if ( newStartViewTime >= 12 ) {
newStartViewTime %= 12;
if ( newStartViewTime == 0 )
newStartViewTime = 12;
spinStart->setSuffix( tr(":00 PM") );
}
else if ( newStartViewTime == 0 ) {
newStartViewTime = 12;
spinStart->setSuffix( tr(":00 AM") );
}
oldtime = newStartViewTime;
}
spinStart->setValue( newStartViewTime );
}
int DateBookSettings::startTime() const
{
int returnMe = spinStart->value();
if ( ampm ) {
if ( returnMe != 12 && spinStart->suffix().contains(tr("PM"), FALSE) )
returnMe += 12;
else if (returnMe == 12 && spinStart->suffix().contains(tr("AM"), TRUE))
returnMe = 0;
}
return returnMe;
}
void DateBookSettings::setAlarmPreset( bool bAlarm, int presetTime )
{
chkAlarmPreset->setChecked( bAlarm );
if ( presetTime >=5 )
spinPreset->setValue( presetTime );
}
bool DateBookSettings::alarmPreset() const
{
return chkAlarmPreset->isChecked();
}
int DateBookSettings::presetTime() const
{
return spinPreset->value();
}
void DateBookSettings::slot12Hour( int i )
{
if ( ampm ) {
if ( spinStart->suffix().contains( tr("AM"), FALSE ) ) {
if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 )
spinStart->setSuffix( tr(":00 PM") );
} else {
if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 )
spinStart->setSuffix( tr(":00 AM") );
}
oldtime = i;
}
}
void DateBookSettings::init()
{
if ( ampm ) {
spinStart->setMinValue( 1 );
spinStart->setMaxValue( 12 );
spinStart->setValue( 12 );
spinStart->setSuffix( tr(":00 AM") );
oldtime = 12;
} else {
spinStart->setMinValue( 0 );
spinStart->setMaxValue( 23 );
spinStart->setSuffix( tr(":00") );
}
}
void DateBookSettings::slotChangeClock( bool whichClock )
{
int saveMe;
saveMe = spinStart->value();
if ( ampm && spinStart->suffix().contains( tr("AM"), FALSE ) ) {
if ( saveMe == 12 )
saveMe = 0;
} else if ( ampm && spinStart->suffix().contains( tr("PM"), FALSE ) ) {
if ( saveMe != 12 )
saveMe += 12;
}
ampm = whichClock;
diff --git a/core/pim/datebook/datebooksettings.h b/core/pim/datebook/datebooksettings.h
index 90a07f9..c3036e1 100644
--- a/core/pim/datebook/datebooksettings.h
+++ b/core/pim/datebook/datebooksettings.h
@@ -1,53 +1,54 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#ifndef DATEBOOKSETTINGS_H
#define DATEBOOKSETTINGS_H
#include "datebooksettingsbase.h"
+#include <qpe/categoryselect.h>
class DateBookSettings : public DateBookSettingsBase
{
public:
DateBookSettings( bool whichClock, QWidget *parent = 0,
const char *name = 0, bool modal = TRUE, WFlags = 0 );
~DateBookSettings();
void setStartTime( int newStartViewTime );
int startTime() const;
void setAlarmPreset( bool bAlarm, int presetTime );
bool alarmPreset() const;
int presetTime() const;
void setAlarmType( int alarmType );
int alarmType() const;
void setJumpToCurTime( bool bJump );
bool jumpToCurTime() const;
void setRowStyle( int style );
int rowStyle() const;
private slots:
void slot12Hour( int );
void slotChangeClock( bool );
private:
void init();
bool ampm;
int oldtime;
};
#endif
diff --git a/core/pim/datebook/datebooksettingsbase.ui b/core/pim/datebook/datebooksettingsbase.ui
index 3836330..e613db1 100644
--- a/core/pim/datebook/datebooksettingsbase.ui
+++ b/core/pim/datebook/datebooksettingsbase.ui
@@ -1,132 +1,132 @@
<!DOCTYPE UI><UI>
<class>DateBookSettingsBase</class>
<comment>**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
** $Id$
**
**********************************************************************</comment>
<widget>
<class>QDialog</class>
<property stdset="1">
<name>name</name>
<cstring>DateBookSettingsBase</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
<width>273</width>
- <height>303</height>
+ <height>340</height>
</rect>
</property>
<property stdset="1">
<name>caption</name>
<string>Preferences</string>
</property>
<property>
<name>layoutMargin</name>
</property>
<property>
<name>layoutSpacing</name>
</property>
<vbox>
<property stdset="1">
<name>margin</name>
<number>11</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QTabWidget</class>
<property stdset="1">
<name>name</name>
<cstring>TabWidget2</cstring>
</property>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>tab</cstring>
</property>
<attribute>
<name>title</name>
<string>Views</string>
</attribute>
<vbox>
<property stdset="1">
<name>margin</name>
<number>11</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout5</cstring>
</property>
<hbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<spacer>
<property>
<name>name</name>
<cstring>Spacer1</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Horizontal</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>Expanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
<widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabel1_2</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Default view:</string>
</property>
</widget>
<widget>
<class>QComboBox</class>
<item>
@@ -437,139 +437,276 @@
<name>enabled</name>
<bool>false</bool>
</property>
<property stdset="1">
<name>suffix</name>
<string> minutes</string>
</property>
<property stdset="1">
<name>maxValue</name>
<number>180</number>
</property>
<property stdset="1">
<name>minValue</name>
<number>0</number>
</property>
<property stdset="1">
<name>lineStep</name>
<number>5</number>
</property>
<property stdset="1">
<name>value</name>
<number>5</number>
</property>
</widget>
</hbox>
</widget>
</vbox>
</widget>
<widget>
<class>QGroupBox</class>
<property stdset="1">
<name>name</name>
<cstring>GroupBox7</cstring>
</property>
<property stdset="1">
<name>title</name>
<string>Start viewing events</string>
</property>
<vbox>
<property stdset="1">
<name>margin</name>
<number>11</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout1</cstring>
</property>
<hbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>lblStartTime</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Start Time:</string>
</property>
</widget>
<widget>
<class>QSpinBox</class>
<property stdset="1">
<name>name</name>
<cstring>spinStart</cstring>
</property>
<property stdset="1">
<name>suffix</name>
<string>:00</string>
</property>
<property stdset="1">
<name>wrapping</name>
<bool>true</bool>
</property>
<property stdset="1">
<name>maxValue</name>
<number>23</number>
</property>
</widget>
</hbox>
</widget>
</vbox>
</widget>
- <spacer>
- <property>
+ <widget>
+ <class>QGroupBox</class>
+ <property stdset="1">
<name>name</name>
- <cstring>Spacer9</cstring>
+ <cstring>GroupBox5_2_2</cstring>
</property>
<property stdset="1">
- <name>orientation</name>
- <enum>Vertical</enum>
+ <name>title</name>
+ <string>Defaults</string>
</property>
+ <vbox>
<property stdset="1">
- <name>sizeType</name>
- <enum>Expanding</enum>
+ <name>margin</name>
+ <number>11</number>
</property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget>
+ <class>QLayoutWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Layout6_2</cstring>
+ </property>
+ <hbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget>
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TextLabel2_2_3</cstring>
+ </property>
+ <property stdset="1">
+ <name>frameShape</name>
+ <enum>MShape</enum>
+ </property>
+ <property stdset="1">
+ <name>frameShadow</name>
+ <enum>MShadow</enum>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Location:</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QComboBox</class>
+ <item>
<property>
- <name>sizeHint</name>
- <size>
- <width>20</width>
- <height>20</height>
- </size>
+ <name>text</name>
+ <string></string>
</property>
- </spacer>
+ </item>
+ <item>
+ <property>
+ <name>text</name>
+ <string>Office</string>
+ </property>
+ </item>
+ <item>
+ <property>
+ <name>text</name>
+ <string>Home</string>
+ </property>
+ </item>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>comboLocation</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>editable</name>
+ <bool>true</bool>
+ </property>
+ <property stdset="1">
+ <name>currentItem</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>duplicatesEnabled</name>
+ <bool>false</bool>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget>
+ <class>QLayoutWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Layout7_2</cstring>
+ </property>
+ <hbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget>
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TextLabel2_2_2_2</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Category:</string>
+ </property>
+ </widget>
+ <widget>
+ <class>CategorySelect</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>comboCategory</cstring>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+ </widget>
</vbox>
</widget>
</widget>
</vbox>
</widget>
+<customwidgets>
+ <customwidget>
+ <class>CategorySelect</class>
+ <header location="global">qpe/categoryselect.h</header>
+ <sizehint>
+ <width>-1</width>
+ <height>-1</height>
+ </sizehint>
+ <container>0</container>
+ <sizepolicy>
+ <hordata>7</hordata>
+ <verdata>1</verdata>
+ </sizepolicy>
+ <pixmap>image0</pixmap>
+ </customwidget>
+</customwidgets>
+<images>
+ <image>
+ <name>image0</name>
+ <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data>
+ </image>
+</images>
<connections>
<connection>
<sender>chkAlarmPreset</sender>
<signal>toggled(bool)</signal>
<receiver>spinPreset</receiver>
<slot>setEnabled(bool)</slot>
</connection>
<connection>
<sender>spinStart</sender>
<signal>valueChanged(int)</signal>
<receiver>DateBookSettingsBase</receiver>
<slot>slot12Hour( int )</slot>
</connection>
<slot access="public">slotChangeClock( bool )</slot>
<slot access="public">slot12Hour( int )</slot>
</connections>
</UI>