author | waspe <waspe> | 2003-11-03 18:28:50 (UTC) |
---|---|---|
committer | waspe <waspe> | 2003-11-03 18:28:50 (UTC) |
commit | 87a9d6badcf518ffd14559ef886ff7729b63b73b (patch) (side-by-side diff) | |
tree | 05af57bcebb8a124c2561336e4ff3dfdd52aeccb /core | |
parent | 9ce566fd5b280622670cf7b0e158f9d9c54e6e9a (diff) | |
download | opie-87a9d6badcf518ffd14559ef886ff7729b63b73b.zip opie-87a9d6badcf518ffd14559ef886ff7729b63b73b.tar.gz opie-87a9d6badcf518ffd14559ef886ff7729b63b73b.tar.bz2 |
resolved merge conflict
-rw-r--r-- | core/pim/datebook/datebook.cpp | 24 | ||||
-rw-r--r-- | core/pim/datebook/datebookweekheaderimpl.cpp | 11 | ||||
-rw-r--r-- | core/pim/datebook/datebookweeklst.cpp | 43 | ||||
-rw-r--r-- | core/pim/datebook/datebookweeklst.h | 1 | ||||
-rw-r--r-- | core/pim/osearch/datebooksearch.cpp | 2 | ||||
-rw-r--r-- | core/pim/osearch/mainwindow.cpp | 10 | ||||
-rw-r--r-- | core/pim/osearch/mainwindow.h | 14 | ||||
-rw-r--r-- | core/pim/today/plugins/addressbook/addresspluginconfig.cpp | 10 | ||||
-rw-r--r-- | core/pim/today/plugins/addressbook/addresspluginwidget.cpp | 12 | ||||
-rw-r--r-- | core/pim/today/plugins/datebook/datebookpluginconfig.h | 12 | ||||
-rw-r--r-- | core/pim/today/plugins/todolist/todopluginconfig.h | 9 | ||||
-rw-r--r-- | core/settings/security/security.cpp | 27 |
12 files changed, 107 insertions, 68 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index 10a9b59..07d7164 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp @@ -67,516 +67,522 @@ #include <sys/types.h> #include <fcntl.h> #include <unistd.h> #include <stdlib.h> DateBook::DateBook( QWidget *parent, const char *, WFlags f ) : QMainWindow( parent, "datebook", f ), aPreset( FALSE ), presetTime( -1 ), startTime( 8 ), // an acceptable default rowStyle( 0 ), bJumpToCurTime(FALSE), syncing(FALSE), inSearch(FALSE), alarmCounter(0) { bool needEvilHack= false; // if we need an Evil Hack QTime t; t.start(); db = new DateBookDBHack; qDebug("loading db t=%d", t.elapsed() ); loadSettings(); setCaption( tr("Calendar") ); setIcon( Resource::loadPixmap( "datebook_icon" ) ); setToolBarsMovable( FALSE ); views = new QWidgetStack( this ); setCentralWidget( views ); dayView = 0; weekView = 0; weekLstView = 0; monthView = 0; // QPEToolBar *bar = new QPEToolBar( this ); // bar->setHorizontalStretchable( TRUE ); // QPEMenuBar *mb = new QPEMenuBar( bar ); // mb->setMargin( 0 ); // QPopupMenu *view = new QPopupMenu( this ); // mb->insertItem( tr( "View" ), view ); QPEToolBar *sub_bar = new QPEToolBar(this); sub_bar->setHorizontalStretchable(TRUE); QActionGroup *g = new QActionGroup( this ); g->setExclusive( TRUE ); QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); a->addTo( sub_bar ); sub_bar->addSeparator(); a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); a->addTo( sub_bar ); // a->addTo( view ); sub_bar->addSeparator(); a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); a->addTo( sub_bar ); // a->addTo( view ); a->setToggleAction( TRUE ); a->setOn( TRUE ); dayAction = a; a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); a->addTo( sub_bar ); // a->addTo( view ); a->setToggleAction( TRUE ); weekAction = a; a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); a->addTo( sub_bar ); // a->addTo( view ); 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; sub_bar->addSeparator(); a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); a->addTo( sub_bar ); a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); a->addTo( sub_bar ); 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() ); + connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); + connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) ); /* * 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); }else if (msg == "viewDefault(QDate)"){ QDate day; stream >> day; viewDefault(day); } } 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) { 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 ) { Event dupEvent=e; + if(!dupEvent.isValidUid() ) // tkcRom seems to be different + dupEvent.assignUid(); 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, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) continue; } - /* - * The problem: - * DateBookDB does remove repeating events not by uid but by the time - * the recurrence was created - * so we need to update that time as well - */ - Event::RepeatPattern rp = newEv.repeatPattern(); - rp.createTime = ::time( NULL ); - newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern... + /* + * The problem: + * DateBookDB does remove repeating events not by uid but by the time + * the recurrence was created + * so we need to update that time as well + */ + Event::RepeatPattern rp = newEv.repeatPattern(); + rp.createTime = ::time( NULL ); + newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern... + if( newEv.uid() == e.uid() || !newEv.isValidUid() ) + newEv.assignUid(); 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, tr("error box"), error, tr("Fix it"), tr("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 ); if ( views->visibleWidget() == dayView && dayView ) dayView->redraw(); } void DateBook::addEvent( const Event &e ) { QDate d = e.start().date(); initDay(); dayView->setDate( d ); } void DateBook::showDay( int year, int month, int day ) { QDate d(year, month, day); view(DAY,d); } void DateBook::initDay() { if ( !dayView ) { dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); views->addWidget( dayView, DAY ); dayView->setJumpToCurTime( bJumpToCurTime ); dayView->setStartViewTime( startTime ); dayView->setRowStyle( rowStyle ); connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) ); 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 ); } } 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 &) ) ); diff --git a/core/pim/datebook/datebookweekheaderimpl.cpp b/core/pim/datebook/datebookweekheaderimpl.cpp index 770410e..84b4f1b 100644 --- a/core/pim/datebook/datebookweekheaderimpl.cpp +++ b/core/pim/datebook/datebookweekheaderimpl.cpp @@ -1,123 +1,124 @@ /********************************************************************** ** 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 "datebookweekheaderimpl.h" #include "datebookweekheader.h" #include "datebookweek.h" #include <qlabel.h> #include <qspinbox.h> #include <qdatetime.h> #include <qpe/resource.h> #include <qpe/datebookmonth.h> #include <qtoolbutton.h> /* * Constructs a DateBookWeekHeader which is a child of 'parent', with the * name 'name' and widget flags set to 'f' */ DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent, const char* name, WFlags fl ) : DateBookWeekHeaderBase( parent, name, fl ), bStartOnMonday( startOnMonday ) { setBackgroundMode( PaletteButton ); labelDate->setBackgroundMode( PaletteButton ); backmonth->setPixmap( Resource::loadPixmap("fastback") ); backweek->setPixmap( Resource::loadPixmap("back") ); forwardweek->setPixmap( Resource::loadPixmap("forward") ); forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); } /* * Destroys the object and frees any allocated resources */ DateBookWeekHeader::~DateBookWeekHeader() { // no need to delete child widgets, Qt does it all for us } void DateBookWeekHeader::pickDate() { static QPopupMenu *m1 = 0; static DateBookMonth *picker = 0; if ( !m1 ) { m1 = new QPopupMenu( this ); picker = new DateBookMonth( m1, 0, TRUE ); m1->insertItem( picker ); connect( picker, SIGNAL( dateClicked( int, int, int ) ), this, SLOT( setDate( int, int, int ) ) ); // connect( m1, SIGNAL( aboutToHide() ), this, SLOT( gotHide() ) ); } picker->setDate( date.year(), date.month(), date.day() ); m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); picker->setFocus(); } void DateBookWeekHeader::nextMonth() { qWarning("nextMonth() " ); setDate(date.addDays(28)); } void DateBookWeekHeader::prevMonth() { qWarning("prevMonth() " ); setDate(date.addDays(-28)); } void DateBookWeekHeader::nextWeek() { qWarning("nextWeek() " ); setDate(date.addDays(7)); } void DateBookWeekHeader::prevWeek() { qWarning("prevWeek() "); setDate(date.addDays(-7)); } void DateBookWeekHeader::setDate( int y, int m, int d ) { setDate(QDate(y,m,d)); } void DateBookWeekHeader::setDate(const QDate &d) { int year,week,dayofweek; date=d; dayofweek=d.dayOfWeek(); - if(bStartOnMonday) + if(bStartOnMonday) dayofweek--; else if( dayofweek == 7 ) - /* we already have the right day -7 would lead to the current week..*/ + // we already have the right day -7 would lead to the current week.. dayofweek = 0; - + date=date.addDays(-dayofweek); calcWeek(date,week,year,bStartOnMonday); QDate start=date; QDate stop=start.addDays(6); labelDate->setText( QString::number(start.day()) + "." + - start.monthName(start.month()) + "-" + + Calendar::nameOfMonth( start.month()) + "-" + QString::number(stop.day()) + "." + - start.monthName(stop.month()) +" ("+ + Calendar::nameOfMonth( stop.month()) +" ("+ tr("w")+":"+QString::number( week ) +")"); + date = d; // bugfix: 0001126 - date has to be the selected date, not monday! emit dateChanged(date); } void DateBookWeekHeader::setStartOfWeek( bool onMonday ) { bStartOnMonday = onMonday; setDate( date ); } diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp index aad1f3a..24fb0ba 100644 --- a/core/pim/datebook/datebookweeklst.cpp +++ b/core/pim/datebook/datebookweeklst.cpp @@ -1,392 +1,395 @@ #include "datebookweeklst.h" -#include "datebookweekheaderimpl.h" #include "datebook.h" -#include <qpe/calendar.h> -#include <qpe/datebookdb.h> -#include <qpe/event.h> -#include <qpe/qpeapplication.h> -#include <qpe/timestring.h> #include <qpe/datebookmonth.h> #include <qpe/config.h> #include <qpe/resource.h> +#include <qpe/calendar.h> -#include <qdatetime.h> -#include <qheader.h> -#include <qlabel.h> #include <qlayout.h> -#include <qpainter.h> -#include <qpopupmenu.h> -#include <qtimer.h> -#include <qstyle.h> #include <qtoolbutton.h> -#include <qvbox.h> -#include <qsizepolicy.h> -#include <qabstractlayout.h> #include <qtl.h> bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false); DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl) : DateBookWeekLstHeaderBase(parent, name, fl) { setBackgroundMode( PaletteButton ); labelDate->setBackgroundMode( PaletteButton ); forwardweek->setBackgroundMode( PaletteButton ); forwardweek->setPixmap( Resource::loadPixmap("forward") ); forwardmonth->setBackgroundMode( PaletteButton ); forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); backweek->setBackgroundMode( PaletteButton ); backweek->setPixmap( Resource::loadPixmap("back") ); backmonth->setBackgroundMode( PaletteButton ); backmonth->setPixmap( Resource::loadPixmap("fastback") ); DateBookWeekLstHeaderBaseLayout->setSpacing(0); DateBookWeekLstHeaderBaseLayout->setMargin(0); //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth())); connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek())); connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek())); connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth())); connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate())); connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); bStartOnMonday=onM; } DateBookWeekLstHeader::~DateBookWeekLstHeader(){} void DateBookWeekLstHeader::setDate(const QDate &d) { int year,week,dayofweek; date=d; dayofweek=d.dayOfWeek(); if(bStartOnMonday) dayofweek--; else if( dayofweek == 7 ) /* we already have the right day -7 would lead to the same week */ dayofweek = 0; date=date.addDays(-dayofweek); calcWeek(date,week,year,bStartOnMonday); QDate start=date; QDate stop=start.addDays(6); labelDate->setText( QString::number(start.day()) + "." + - start.monthName(start.month()) + "-" + + Calendar::nameOfMonth( start.month() ) + "-" + QString::number(stop.day()) + "." + - start.monthName(stop.month()) +" ("+ + Calendar::nameOfMonth( stop.month()) +" ("+ tr("w")+":"+QString::number( week ) +")"); + date = d; // bugfix: 0001126 - date has to be the selected date, not monday! emit dateChanged(date); } void DateBookWeekLstHeader::pickDate() { static QPopupMenu *m1 = 0; static DateBookMonth *picker = 0; if ( !m1 ) { m1 = new QPopupMenu( this ); picker = new DateBookMonth( m1, 0, TRUE ); m1->insertItem( picker ); connect( picker, SIGNAL( dateClicked( int, int, int ) ),this, SLOT( setDate( int, int, int ) ) ); //connect( m1, SIGNAL( aboutToHide() ), //this, SLOT( gotHide() ) ); } picker->setDate( date.year(), date.month(), date.day() ); m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); picker->setFocus(); } void DateBookWeekLstHeader::setDate(int y, int m, int d) { setDate(QDate(y,m,d)); } void DateBookWeekLstHeader::nextWeek() { setDate(date.addDays(7)); } void DateBookWeekLstHeader::prevWeek() { setDate(date.addDays(-7)); } void DateBookWeekLstHeader::nextMonth() { setDate(date.addDays(28)); } void DateBookWeekLstHeader::prevMonth() { setDate(date.addDays(-28)); } DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */, QWidget* parent, const char* name, WFlags fl ) : DateBookWeekLstDayHdrBase(parent, name, fl) { date=d; static const QString wdays=tr("MTWTFSSM", "Week days"); char day=wdays[d.dayOfWeek()-1]; + //dont use dayOfWeek() to save space ! label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) ); - add->setText("+"); + + add->setText("+"); if (d == QDate::currentDate()) { QPalette pal=label->palette(); pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); label->setPalette(pal); /* QFont f=label->font(); f.setItalic(true); label->setFont(f); label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor())); */ } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday QPalette pal=label->palette(); pal.setColor(QColorGroup::Foreground, QColor(255,0,0)); label->setPalette(pal); } connect (label, SIGNAL(clicked()), this, SLOT(showDay())); connect (add, SIGNAL(clicked()), this, SLOT(newEvent())); } void DateBookWeekLstDayHdr::showDay() { emit showDate(date.year(), date.month(), date.day()); } void DateBookWeekLstDayHdr::newEvent() { QDateTime start, stop; start=stop=date; start.setTime(QTime(10,0)); stop.setTime(QTime(12,0)); emit addEvent(start,stop,"",0); } DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, int weeklistviewconfig, QWidget* parent, const char* name, WFlags fl ) : OClickableLabel(parent,name,fl), event(ev) { // old values... lastday = "__|__", middle=" |---", Firstday="00:00", QString s,start,middle,end,day; qDebug("weeklistviewconfig=%d",weeklistviewconfig); if(weeklistviewconfig==NONE) { // No times displayed. // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); // middle.sprintf("<--->"); // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); // day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); } else if(weeklistviewconfig==NORMAL) { // "Normal", only display start time. start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); middle.sprintf(" |---"); end.sprintf("__|__"); day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times. start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); middle.sprintf("<--->"); end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); } if(ev.event().type() == Event::Normal) { if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) { // day event. s=day; } else if(ev.startDate()==ev.date()) { // start event. s=start; } else if(ev.endDate()==ev.date()) { // end event. s=end; } else { // middle day. s=middle; } } else { s=""; } setText(QString(s) + " " + ev.description()); connect(this, SIGNAL(clicked()), this, SLOT(editMe())); setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); } void DateBookWeekLstEvent::editMe() { emit editEvent(event.event()); } DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM, QWidget* parent, const char* name, WFlags fl) : QWidget( parent, name, fl ) { Config config("DateBook"); config.setGroup("Main"); int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); qDebug("Read weeklistviewconfig: %d",weeklistviewconfig); bStartOnMonday=onM; setPalette(white); setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); QVBoxLayout *layout = new QVBoxLayout( this ); qBubbleSort(ev); QValueListIterator<EffectiveEvent> it; it=ev.begin(); int dayOrder[7]; if (bStartOnMonday) { for (int d=0; d<7; d++) dayOrder[d]=d+1; } else { for (int d=0; d<7; d++) dayOrder[d]=d; dayOrder[0]=7; } // Calculate offset to first day of week. int dayoffset=d.dayOfWeek(); if(bStartOnMonday) dayoffset--; else if( dayoffset == 7 ) dayoffset = 0; for (int i=0; i<7; i++) { // Header DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this); connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); connect(hdr, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); layout->addWidget(hdr); // Events while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) { // Skip events ending at 00:00 starting at another day. DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); layout->addWidget(l); connect (l, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); } it++; } layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); } } DateBookWeekLstView::~DateBookWeekLstView(){} void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, QValueList<EffectiveEvent> &ev2, QDate &d, bool onM, QWidget* parent, const char* name, WFlags fl) : QWidget( parent, name, fl ) { QHBoxLayout *layout = new QHBoxLayout( this ); DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); layout->addWidget(w); connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &,const QString &)), this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); layout->addWidget(w); connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); } DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, QWidget *parent, const char *name ) : QWidget( parent, name ), db( newDB ), startTime( 0 ), ampm( ap ), bStartOnMonday(onM) { setFocusPolicy(StrongFocus); layout = new QVBoxLayout( this ); layout->setMargin(0); header=new DateBookWeekLstHeader(onM, this); layout->addWidget( header ); connect(header, SIGNAL(dateChanged(QDate &)), this, SLOT(dateChanged(QDate &))); connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); scroll=new QScrollView(this); scroll->setResizePolicy(QScrollView::AutoOneFit); layout->addWidget(scroll); view=NULL; Config config("DateBook"); config.setGroup("Main"); dbl=config.readBoolEntry("weeklst_dbl", false); header->dbl->setOn(dbl); } DateBookWeekLst::~DateBookWeekLst(){ Config config("DateBook"); config.setGroup("Main"); config.writeEntry("weeklst_dbl", dbl); } void DateBookWeekLst::setDate(const QDate &d) { bdate=d; header->setDate(d); } void DateBookWeekLst::setDbl(bool on) { dbl=on; redraw(); } void DateBookWeekLst::redraw() {getEvents();} QDate DateBookWeekLst::date() { return bdate; } +// return the date at the beginning of the week... +// copied from DateBookWeek +QDate DateBookWeekLst::weekDate() const +{ + QDate d=bdate; + + // Calculate offset to first day of week. + int dayoffset=d.dayOfWeek(); + if(bStartOnMonday) dayoffset--; + else if( dayoffset == 7 ) + dayoffset = 0; + + return d.addDays(-dayoffset); +} + void DateBookWeekLst::getEvents() { - QDate start = date(); + QDate start = weekDate(); //date(); QDate stop = start.addDays(6); QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); if (view) delete view; if (dbl) { QDate start2=start.addDays(7); stop=start2.addDays(6); QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); } else { view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll); } connect (view, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); scroll->addChild(view); view->show(); scroll->updateScrollBars(); } void DateBookWeekLst::dateChanged(QDate &newdate) { bdate=newdate; getEvents(); } void DateBookWeekLst::keyPressEvent(QKeyEvent *e) { switch(e->key()) { case Key_Up: scroll->scrollBy(0, -20); break; case Key_Down: scroll->scrollBy(0, 20); break; case Key_Left: header->prevWeek(); break; case Key_Right: header->nextWeek(); break; default: e->ignore(); } } diff --git a/core/pim/datebook/datebookweeklst.h b/core/pim/datebook/datebookweeklst.h index 0bfbcda..f683ce7 100644 --- a/core/pim/datebook/datebookweeklst.h +++ b/core/pim/datebook/datebookweeklst.h @@ -1,155 +1,156 @@ #ifndef DATEBOOKWEEKLST #define DATEBOOKWEEKLST #include <qwidget.h> #include <qdatetime.h> #include <qpe/event.h> #include <qlabel.h> #include <qscrollview.h> #include "datebookweeklstheader.h" #include "datebookweeklstdayhdr.h" #include <opie/oclickablelabel.h> class QDateTime; class DateBookDB; class DateBookWeekLstHeader: public DateBookWeekLstHeaderBase { Q_OBJECT public: DateBookWeekLstHeader(bool onM, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~DateBookWeekLstHeader(); void setDate(const QDate &d); public slots: void nextWeek(); void prevWeek(); void nextMonth(); void prevMonth(); void pickDate(); void setDate(int y, int m, int d); signals: void dateChanged(QDate &newdate); void setDbl(bool on); private: QDate date; // bool onMonday; bool bStartOnMonday; }; class DateBookWeekLstDayHdr: public DateBookWeekLstDayHdrBase { Q_OBJECT public: DateBookWeekLstDayHdr(const QDate &d, bool onM, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); public slots: void showDay(); void newEvent(); signals: void showDate(int y, int m, int d); void addEvent(const QDateTime &start, const QDateTime &stop, const QString &str, const QString &location); private: QDate date; }; class DateBookWeekLstEvent: public OClickableLabel { Q_OBJECT public: DateBookWeekLstEvent(const EffectiveEvent &ev, int weeklistviewconfig =1, QWidget* parent = 0, const char* name = 0, WFlags fl = 0); signals: void editEvent(const Event &e); private slots: void editMe(); private: const EffectiveEvent event; }; class DateBookWeekLstView: public QWidget { Q_OBJECT public: DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~DateBookWeekLstView(); signals: void editEvent(const Event &e); void showDate(int y, int m, int d); void addEvent(const QDateTime &start, const QDateTime &stop, const QString &str, const QString &location); private: bool bStartOnMonday; protected slots: void keyPressEvent(QKeyEvent *); }; class DateBookWeekLstDblView: public QWidget { Q_OBJECT public: DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, QValueList<EffectiveEvent> &ev2, QDate &d, bool onM, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); signals: void editEvent(const Event &e); void showDate(int y, int m, int d); void addEvent(const QDateTime &start, const QDateTime &stop, const QString &str, const QString &location); }; class DateBookWeekLst : public QWidget { Q_OBJECT public: DateBookWeekLst( bool ampm, bool onM, DateBookDB *newDB, QWidget *parent = 0, const char *name = 0 ); ~DateBookWeekLst(); void setDate( int y, int w ); void setDate(const QDate &d ); int week() const { return _week; }; QDate date(); + QDate weekDate() const; public slots: void redraw(); void dateChanged(QDate &date); protected slots: void keyPressEvent(QKeyEvent *); void setDbl(bool on); signals: void showDate(int y, int m, int d); void addEvent(const QDateTime &start, const QDateTime &stop, const QString &str, const QString &location); void editEvent(const Event &e); private: DateBookDB *db; int startTime; bool ampm; bool bStartOnMonday; bool dbl; QDate bdate; int year, _week,dow; DateBookWeekLstHeader *header; QWidget *view; QVBoxLayout *layout; QScrollView *scroll; void getEvents(); }; #endif diff --git a/core/pim/osearch/datebooksearch.cpp b/core/pim/osearch/datebooksearch.cpp index be2bf25..5da7ae9 100644 --- a/core/pim/osearch/datebooksearch.cpp +++ b/core/pim/osearch/datebooksearch.cpp @@ -1,92 +1,92 @@ // // // C++ Implementation: $MODULE$ // // Description: // // // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 // // Copyright: See COPYING file that comes with this distribution // // #include "datebooksearch.h" #include "eventitem.h" #include <qpe/resource.h> #include <qpe/config.h> #include <opie/oevent.h> #include <opie/orecur.h> #include <opie/odatebookaccess.h> #include <qiconset.h> #include <qaction.h> #include <qdatetime.h> #include <qpopupmenu.h> DatebookSearch::DatebookSearch(QListView* parent, QString name) : SearchGroup(parent, name), _dates(0), _popupMenu(0) { QIconSet is = Resource::loadIconSet( "datebook/DateBook" ); setPixmap( 0, is.pixmap( QIconSet::Small, true ) ); actionShowPastEvents = new QAction( QObject::tr("show past events"),QString::null, 0, 0, 0, true ); actionSearchInDates = new QAction( QObject::tr("search in dates"),QString::null, 0, 0, 0, true ); Config cfg( "osearch", Config::User ); cfg.setGroup( "datebook_settings" ); actionShowPastEvents->setOn( cfg.readBoolEntry( "show_past_events", false ) ); actionSearchInDates->setOn( cfg.readBoolEntry( "search_in_dates", true ) ); } DatebookSearch::~DatebookSearch() { qDebug("SAVE DATEBOOK SEARCH CONFIG"); Config cfg( "osearch", Config::User ); cfg.setGroup( "datebook_settings" ); cfg.writeEntry( "show_past_events", actionShowPastEvents->isOn() ); cfg.writeEntry( "search_in_dates", actionSearchInDates->isOn() ); delete _dates; delete _popupMenu; delete actionShowPastEvents; delete actionSearchInDates; } void DatebookSearch::load() { _dates = new ODateBookAccess(); _dates->load(); } int DatebookSearch::search() { ORecordList<OEvent> results = _dates->matchRegexp(_search); for (uint i = 0; i < results.count(); i++) insertItem( new OEvent( results[i] ) ); return _resultCount; } void DatebookSearch::insertItem( void *rec ) { OEvent *ev = (OEvent*)rec; if ( !actionShowPastEvents->isOn() && ev->endDateTime() < QDateTime::currentDateTime() && !ev->recurrence().doesRecur() ) return; if ( !actionSearchInDates->isOn() && ( ev->lastHitField() == Qtopia::StartDateTime || ev->lastHitField() == Qtopia::EndDateTime ) ) return; - (void)new EventItem( this, ev ); + new EventItem( this, ev ); _resultCount++; } QPopupMenu* DatebookSearch::popupMenu() { if (!_popupMenu){ _popupMenu = new QPopupMenu( 0 ); actionShowPastEvents->addTo( _popupMenu ); actionSearchInDates->addTo( _popupMenu ); } return _popupMenu; } diff --git a/core/pim/osearch/mainwindow.cpp b/core/pim/osearch/mainwindow.cpp index aa52061..f768d81 100644 --- a/core/pim/osearch/mainwindow.cpp +++ b/core/pim/osearch/mainwindow.cpp @@ -1,217 +1,217 @@ /*************************************************************************** * * * 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. * * * ***************************************************************************/ // (c) 2002 Patrick S. Vogt <tille@handhelds.org> #include <qaction.h> #include <qmessagebox.h> #include <qpopupmenu.h> #include <qtoolbutton.h> #include <qstring.h> #include <qlabel.h> #include <qfile.h> #include <qhbuttongroup.h> #include <qhbox.h> #include <qpushbutton.h> #include <qintdict.h> #include <qlayout.h> #include <qlineedit.h> #include <qsignalmapper.h> #include <qtextbrowser.h> #include <qregexp.h> #include <qwhatsthis.h> #include <qpe/qpemenubar.h> #include <qpe/qpemessagebox.h> #include <qpe/resource.h> #include <qpe/config.h> #include <qpe/qpetoolbar.h> #include <qpe/qpeapplication.h> #include <qpe/config.h> #include <qpe/global.h> #include <opie/owait.h> #include "olistview.h" #include "olistviewitem.h" #include "resultitem.h" #include "adresssearch.h" #include "todosearch.h" #include "datebooksearch.h" #include "applnksearch.h" #include "doclnksearch.h" #include "mainwindow.h" MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : QMainWindow( parent, name, f ), _currentItem(0) { setCaption( tr("OSearch") ); setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); QFrame *mainFrame = new QFrame( this, "mainFrame" ); mainFrame->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); mainLayout = new QVBoxLayout( mainFrame ); mainLayout->setSpacing( 0 ); mainLayout->setMargin( 0 ); resultsList = new OListView( mainFrame ); resultsList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); mainLayout->addWidget( resultsList ); detailsFrame = new QFrame( mainFrame, "detailsFrame" ); QVBoxLayout *detailsLayout = new QVBoxLayout( detailsFrame ); richEdit = new QTextView( detailsFrame ); QWhatsThis::add( richEdit, tr("The details of the current result") ); richEdit->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); detailsLayout->addWidget( richEdit ); buttonBox = new QHBox( mainFrame, "Button Box" ); _buttonCount = 0; mainLayout->addWidget( detailsFrame ); mainLayout->addWidget( buttonBox ); detailsFrame->hide(); buttonBox->hide(); - searches.append( new AppLnkSearch( resultsList, tr("applications") ) ); - searches.append( new DocLnkSearch( resultsList, tr("documents") ) ); - searches.append( new TodoSearch( resultsList, tr("todo") ) ); - searches.append( new DatebookSearch( resultsList, tr("datebook") ) ); - searches.append( new AdressSearch( resultsList, tr("adressbook") ) ); + searches.append( new AppLnkSearch( resultsList, tr("Applications") ) ); + searches.append( new DocLnkSearch( resultsList, tr("Documents") ) ); + searches.append( new TodoSearch( resultsList, tr("Todo List") ) ); + searches.append( new DatebookSearch( resultsList, tr("Calendar") ) ); + searches.append( new AdressSearch( resultsList, tr("Contacts") ) ); setCentralWidget( mainFrame ); popupTimer = new QTimer(); searchTimer = new QTimer(); connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup())); connect(searchTimer, SIGNAL(timeout()), SLOT(searchStringChanged())); connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*))); connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*))); signalMapper = new QSignalMapper( this ); connect(signalMapper, SIGNAL(mapped(int)), SLOT( slotAction(int) ) ); makeMenu(); Config cfg( "osearch", Config::User ); cfg.setGroup( "search_settings" ); actionCaseSensitiv->setOn( cfg.readBoolEntry( "caseSensitiv", false ) ); actionWildcards->setOn( cfg.readBoolEntry( "wildcards", false ) ); // actionWholeWordsOnly->setOn( cfg.readBoolEntry( "whole_words_only", false ) ); } void MainWindow::makeMenu() { QPEToolBar *toolBar = new QPEToolBar( this ); QPEToolBar *searchBar = new QPEToolBar(this); QPEMenuBar *menuBar = new QPEMenuBar( toolBar ); QPopupMenu *searchMenu = new QPopupMenu( menuBar ); // QPopupMenu *viewMenu = new QPopupMenu( menuBar ); QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); QPopupMenu *searchOptions = new QPopupMenu( cfgMenu ); setToolBarsMovable( false ); toolBar->setHorizontalStretchable( true ); menuBar->insertItem( tr( "Search" ), searchMenu ); menuBar->insertItem( tr( "Settings" ), cfgMenu ); //SETTINGS MENU cfgMenu->insertItem( tr( "Search" ), searchOptions ); QPopupMenu *pop; for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){ pop = s->popupMenu(); if (pop){ cfgMenu->insertItem( s->text(0), pop ); } } //SEARCH SearchAllAction = new QAction( tr("Search all"),QString::null, 0, this, 0 ); SearchAllAction->setIconSet( Resource::loadIconSet( "find" ) ); // QWhatsThis::add( SearchAllAction, tr("Search everything...") ); connect( SearchAllAction, SIGNAL(activated()), this, SLOT(searchAll()) ); SearchAllAction->addTo( searchMenu ); searchMenu->insertItem( tr( "Options" ), searchOptions ); //SEARCH OPTIONS //actionWholeWordsOnly = new QAction( tr("Whole words only"),QString::null, 0, this, 0, true ); //actionWholeWordsOnly->addTo( searchOptions ); actionCaseSensitiv = new QAction( tr("Case sensitiv"),QString::null, 0, this, 0, true ); actionCaseSensitiv->addTo( searchOptions ); actionWildcards = new QAction( tr("Use wildcards"),QString::null, 0, this, 0, true ); actionWildcards->addTo( searchOptions ); //SEARCH BAR addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); QLineEdit *searchEdit = new QLineEdit( searchBar, "seachEdit" ); QWhatsThis::add( searchEdit, tr("Enter your search terms here") ); searchEdit->setFocus(); searchBar->setHorizontalStretchable( TRUE ); searchBar->setStretchableWidget( searchEdit ); SearchAllAction->addTo( searchBar ); connect( searchEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( setSearch( const QString & ) ) ); } MainWindow::~MainWindow() { Config cfg( "osearch", Config::User ); cfg.setGroup( "search_settings" ); cfg.writeEntry( "caseSensitiv", actionCaseSensitiv->isOn() ); cfg.writeEntry( "wildcards", actionWildcards->isOn() ); //cfg.writeEntry( "whole_words_only", actionWholeWordsOnly->isOn() ); } void MainWindow::setCurrent(QListViewItem *item) { if (!item) return; _currentItem = (OListViewItem*)item; // _currentItem = dynamic_cast<OListViewItem*>(item); if (_currentItem->rtti() == OListViewItem::Result){ ResultItem *res = (ResultItem*)item; // ResultItem *res = dynamic_cast<ResultItem*>(item); richEdit->setText( res->toRichText() ); QIntDict<QString> acts = res->actions(); QButton *button; for (uint i = 0; i < acts.count(); i++){ button = buttonMap[i]; if (!button) { qWarning(" no button for %s", (*acts[i]).latin1() ); button = new QPushButton( buttonBox ); buttonMap.insert( i, button ); signalMapper->setMapping(button, i ); connect(button, SIGNAL(clicked() ), signalMapper, SLOT(map() ) ); } button->setText( *acts[i] ); button->show(); } for (uint i = acts.count(); i < _buttonCount; i++){ button = buttonMap[i]; if (button) button->hide(); } _buttonCount = acts.count(); detailsFrame->show(); buttonBox->show(); }else { detailsFrame->hide(); buttonBox->hide(); } popupTimer->start( 300, true ); } void MainWindow::stopTimer(QListViewItem*) { diff --git a/core/pim/osearch/mainwindow.h b/core/pim/osearch/mainwindow.h index 1f5c4bb..75054f0 100644 --- a/core/pim/osearch/mainwindow.h +++ b/core/pim/osearch/mainwindow.h @@ -1,78 +1,86 @@ /*************************************************************************** * * * 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. * * * ***************************************************************************/ -// (c) 2002 Patrick S. Vogt <tille@handhelds.org> +// (c) 2002-2003 Patrick S. Vogt <tille@handhelds.org> #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <qmainwindow.h> +#include <qdialog.h> +#include <qaction.h> #include <qlist.h> + #include <qmap.h> +#include <qtimer.h> +#include <qpopupmenu.h> class QAction; class QPEToolBar; class QHBox; class QVBoxLayout; class QTextView; class QFrame; class OListView; class OListViewItem; class QListViewItem; class QPopupMenu; -class QSignalMapper; class QTimer; + +class QSignalMapper; +class QButton; + class SearchGroup; class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); ~MainWindow(); - + static QString appName() { return QString::fromLatin1("osearch"); } public slots: void setCurrent(QListViewItem*); void setSearch( const QString& ); void searchAll(); protected slots: void slotAction(int); void showPopup(); void stopTimer( QListViewItem* ); void searchStringChanged(); void optionChanged(int); private: QHBox *buttonBox; QMap<int, QButton*> buttonMap; QSignalMapper* signalMapper; OListView *resultsList; QTextView *richEdit; OListViewItem *_currentItem; QVBoxLayout *mainLayout; QFrame *detailsFrame; QTimer *popupTimer; QTimer *searchTimer; QString _searchString; QList<SearchGroup> searches; QAction *SearchAllAction; QAction *actionCaseSensitiv; QAction *actionWildcards; //QAction *actionWholeWordsOnly; uint _buttonCount; void makeMenu(); }; #endif diff --git a/core/pim/today/plugins/addressbook/addresspluginconfig.cpp b/core/pim/today/plugins/addressbook/addresspluginconfig.cpp index b79c679..8863192 100644 --- a/core/pim/today/plugins/addressbook/addresspluginconfig.cpp +++ b/core/pim/today/plugins/addressbook/addresspluginconfig.cpp @@ -1,173 +1,179 @@ /* * addresspluginconfig.cpp * * copyright : (c) 2003 by Stefan Eilers * email : eilers.stefan@epost.de * * This implementation was derived from the todolist plugin implementation * */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #include "addresspluginconfig.h" #include <qpe/config.h> #include <qlayout.h> #include <qhbox.h> #include <qtoolbutton.h> #include <qlabel.h> #include <qwhatsthis.h> #include <qvgroupbox.h> AddressBookPluginConfig::AddressBookPluginConfig( QWidget *parent, const char* name) : TodayConfigWidget(parent, name ) { QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 20 ); #if 0 // Informational stuff QHBox *box4 = new QHBox( this ); QLabel* colorLabel = new QLabel( box4, "" ); colorLabel->setText( tr( "To activate settings: Restart application !" ) ); #endif // Buttongroup to enable/disable shown stuff QVGroupBox* b_group = new QVGroupBox( this, "name" ); b_group -> setTitle( tr("Enable/Disable Views") ); m_showBirthdayButton = new QRadioButton( b_group ); m_showBirthdayButton -> setText( tr( "Show &Birthdays" ) ); m_showAnniversaryButton = new QRadioButton( b_group ); m_showAnniversaryButton -> setText( tr( "Show &Anniveraries" ) ); QWhatsThis::add( m_showBirthdayButton , tr( "The next birthdays will just be shown, if enabled!" ) ); QWhatsThis::add( m_showAnniversaryButton , tr( "The next anniversaries will just be shown, if enabled !" ) ); // Max lines settings QHBox *box1 = new QHBox( this ); QLabel* TextLabel6 = new QLabel( box1, "TextLabel6" ); TextLabel6->setText( tr( "Max Lines: " ) ); SpinBox2 = new QSpinBox( box1, "SpinBox2" ); SpinBox2->setMaxValue( 40 ); QWhatsThis::add( SpinBox2 , tr( "Set the maximum number of lines that should be shown for each anniversaries/birthdays" ) ); #if 0 // Clip settings (currently not used) QHBox *box2 = new QHBox( this ); QLabel* clipLabel = new QLabel( box2, "" ); clipLabel->setText( tr( "Clip line after X chars: " ) ); SpinBoxClip = new QSpinBox( box2, "SpinClip" ); SpinBoxClip->setMaxValue( 200 ); QWhatsThis::add( SpinBoxClip , tr( "After how many chars should be the info about the task be cut off" ) ); #endif // Look ahead settings QHBox *box3 = new QHBox( this ); QLabel* daysLabel = new QLabel( box3, "" ); daysLabel->setText( tr( "Days look ahead: " ) ); SpinDaysClip = new QSpinBox( box3, "SpinDays" ); SpinDaysClip->setMaxValue( 200 ); QWhatsThis::add( SpinDaysClip , tr( "How many days we should search forward" ) ); +// QHBox *box4 = new QHBox( this ); + +// QLabel* colorLabel = new QLabel( box4, "" ); +// colorLabel->setText( tr( "To activate settings: Restart application !" ) ); + + QHBox *box5 = new QHBox( this ); QLabel* colorLabel2 = new QLabel( box5, "" ); colorLabel2->setText( tr( "Set Headline Color: " ) ); headlineColor = new OColorButton( box5, black , "headlineColor" ); QWhatsThis::add( headlineColor , tr( "Colors for the headlines !" ) ); QHBox *box6 = new QHBox( this ); // Entry color settings QLabel* colorLabel3= new QLabel( box6, "" ); colorLabel3->setText( tr( "Set Entry Color: " ) ); entryColor = new OColorButton( box6, black , "entryColor" ); QWhatsThis::add( entryColor , tr( "This color will be used for shown birthdays/anniversaries !" ) ); // Urgent color settings QHBox *box7 = new QHBox( this ); QLabel* colorLabel5 = new QLabel( box7, "" ); colorLabel5->setText( tr( "Set Urgent\nColor if below " ) ); SpinUrgentClip = new QSpinBox( box7, "SpinDays" ); SpinUrgentClip->setMaxValue( 200 ); QLabel* colorLabel6 = new QLabel( box7, "" ); colorLabel6->setText( tr( " days: " ) ); urgentColor = new OColorButton( box7, red , "urgentColor" ); QWhatsThis::add( urgentColor , tr( "This urgent color will be used if we are close to the event !" ) ); QWhatsThis::add( SpinUrgentClip , tr( "The urgent color will be used if the birthday/anniversary is closer than given days !" ) ); - layout->addWidget( b_group ); + //layout->addWidget( box4 ); layout->addWidget( box1 ); - // layout->addWidget( box2 ); + //layout->addWidget( box2 ); layout->addWidget( box3 ); layout->addWidget( box5 ); layout->addWidget( box6 ); layout->addWidget( box7 ); readConfig(); } void AddressBookPluginConfig::readConfig() { Config cfg( "todayaddressplugin" ); cfg.setGroup( "config" ); m_max_lines_task = cfg.readNumEntry( "maxlinestask", 5 ); SpinBox2->setValue( m_max_lines_task ); // m_maxCharClip = cfg.readNumEntry( "maxcharclip", 38 ); // SpinBoxClip->setValue( m_maxCharClip ); m_daysLookAhead = cfg.readNumEntry( "dayslookahead", 14 ); SpinDaysClip->setValue( m_daysLookAhead ); m_urgentDays = cfg.readNumEntry( "urgentdays", 7 ); SpinUrgentClip->setValue( m_urgentDays ); m_entryColor = cfg.readEntry( "entrycolor", Qt::black.name() ); entryColor->setColor( QColor( m_entryColor ) ); m_headlineColor = cfg.readEntry( "headlinecolor", Qt::black.name() ); headlineColor->setColor( QColor( m_headlineColor ) ); m_urgentColor = cfg.readEntry( "urgentcolor", Qt::red.name() ); urgentColor->setColor( QColor( m_urgentColor ) ); m_showBirthdayButton->setChecked( cfg.readBoolEntry( "showBirthdays", true ) ); m_showAnniversaryButton->setChecked( cfg.readBoolEntry( "showAnniversaries", true ) ); } void AddressBookPluginConfig::writeConfig() { Config cfg( "todayaddressplugin" ); cfg.setGroup( "config" ); m_max_lines_task = SpinBox2->value(); cfg.writeEntry( "maxlinestask", m_max_lines_task ); // m_maxCharClip = SpinBoxClip->value(); // cfg.writeEntry( "maxcharclip", m_maxCharClip ); m_daysLookAhead = SpinDaysClip->value(); cfg.writeEntry( "dayslookahead", m_daysLookAhead ); m_urgentDays = SpinUrgentClip->value(); if ( m_urgentDays > m_daysLookAhead ) m_urgentDays = m_daysLookAhead; cfg.writeEntry( "urgentdays", m_urgentDays ); m_entryColor = entryColor->color().name(); cfg.writeEntry( "entrycolor", m_entryColor ); m_headlineColor = headlineColor->color().name(); cfg.writeEntry( "headlinecolor", m_headlineColor ); m_urgentColor = urgentColor->color().name(); cfg.writeEntry( "urgentcolor", m_urgentColor ); cfg.writeEntry( "showBirthdays", m_showBirthdayButton->isChecked() ); cfg.writeEntry( "showAnniversaries", m_showAnniversaryButton->isChecked() ); cfg.write(); } AddressBookPluginConfig::~AddressBookPluginConfig() { } diff --git a/core/pim/today/plugins/addressbook/addresspluginwidget.cpp b/core/pim/today/plugins/addressbook/addresspluginwidget.cpp index dad09db..d47bc0b 100644 --- a/core/pim/today/plugins/addressbook/addresspluginwidget.cpp +++ b/core/pim/today/plugins/addressbook/addresspluginwidget.cpp @@ -1,225 +1,229 @@ /* * addresspluginwidget.cpp * * copyright : (c) 2003 by Stefan Eilers * email : eilers.stefan@epost.de * * This implementation was derived from the todolist plugin implementation * */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #include "addresspluginwidget.h" #include <qvaluelist.h> #include <qtl.h> #include <qstring.h> #include <qscrollview.h> #include <qobject.h> #include <qdatetime.h> #include <qpe/config.h> #include <qpe/timestring.h> #include <qpe/qcopenvelope_qws.h> #include <opie/ocontact.h> AddressBookPluginWidget::AddressBookPluginWidget( QWidget *parent, const char* name ) : QWidget( parent, name ) { addressLabel = 0l; m_contactdb = 0l; layoutTodo = 0l; // Hä ? Nonsense ! (se) if ( m_contactdb ) { delete m_contactdb; } m_contactdb = new OContactAccess("addressplugin"); connect( m_contactdb, SIGNAL( signalChanged( const OContactAccess * ) ), this, SLOT( refresh( const OContactAccess * ) ) ); readConfig(); getAddress(); } AddressBookPluginWidget::~AddressBookPluginWidget() { delete m_contactdb; } void AddressBookPluginWidget::refresh( const OContactAccess* ) { qWarning(" AddressBookPluginWidget::Database was changed externally ! "); m_contactdb->reload(); getAddress(); } void AddressBookPluginWidget::reinitialize() { readConfig(); getAddress(); } void AddressBookPluginWidget::readConfig() { Config cfg( "todayaddressplugin" ); cfg.setGroup( "config" ); m_maxLinesTask = cfg.readNumEntry( "maxlinestask", 5 ); m_maxCharClip = cfg.readNumEntry( "maxcharclip", 38 ); m_daysLookAhead = cfg.readNumEntry( "dayslookahead", 14 ); m_urgentDays = cfg.readNumEntry( "urgentdays", 7 ); m_entryColor = cfg.readEntry("entrycolor", Qt::black.name() ); m_headlineColor = cfg.readEntry( "headlinecolor", Qt::black.name() ); m_urgentColor = cfg.readEntry( "urgentcolor", Qt::red.name() ); m_showBirthdays = cfg.readBoolEntry( "showBirthdays", true ); m_showAnniversaries = cfg.readBoolEntry( "showAnniversaries", true ); } /** * Get the addresss */ void AddressBookPluginWidget::getAddress() { if ( ! layoutTodo ){ layoutTodo = new QVBoxLayout( this ); } if ( ! addressLabel ) { addressLabel = new OClickableLabel( this ); connect( addressLabel, SIGNAL( clicked() ), this, SLOT( startAddressBook() ) ); layoutTodo->addWidget( addressLabel ); } QString output; // Check whether the database provide the search option.. - if ( !m_contactdb->hasQuerySettings( OContactAccess::DateDiff ) ){ + if ( !m_contactdb->hasQuerySettings( OContactAccess::DateDiff ) ){ // Libopie seems to be old.. output = QObject::tr( "Database does not provide this search query ! Please upgrade libOpie !<br>" ); addressLabel->setText( output ); return; } - + // Define the query for birthdays and start search.. QDate lookAheadDate = QDate::currentDate().addDays( m_daysLookAhead ); int ammount = 0; if ( m_showBirthdays ){ - qWarning("Searching from now (%s) until %s ! ", - QDate::currentDate().toString().latin1(), + qWarning("Searching from now (%s) until %s ! ", + QDate::currentDate().toString().latin1(), lookAheadDate.toString().latin1() ); + } + + if ( m_contactdb->hasQuerySettings( OContactAccess::DateDiff ) ){ + OContact querybirthdays; querybirthdays.setBirthday( lookAheadDate ); m_list = m_contactdb->queryByExample( querybirthdays, OContactAccess::DateDiff ); if ( m_list.count() > 0 ){ output = "<font color=" + m_headlineColor + ">" + QObject::tr( "Next birthdays in <b> %1 </b> days:" ) .arg( m_daysLookAhead ) + "</font> <br>"; for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) { if ( ammount++ < m_maxLinesTask ){ // Now we want to calculate how many days //until birthday. We have to set // the correct year to calculate the day diff... QDate destdate = (*m_it).birthday(); destdate.setYMD( QDate::currentDate().year(), destdate.month(), destdate.day() ); if ( QDate::currentDate().daysTo(destdate) < 0 ) destdate.setYMD( QDate::currentDate().year()+1, destdate.month(), destdate.day() ); if ( QDate::currentDate().daysTo(destdate) < m_urgentDays ) output += "<font color=" + m_urgentColor + "><b>-" + (*m_it).fullName() + " (" + QString::number(QDate::currentDate() .daysTo(destdate)) + " Days) </b></font><br>"; else output += "<font color=" + m_entryColor + "><b>-" + (*m_it).fullName() + " (" + QString::number(QDate::currentDate() .daysTo(destdate)) + " Days) </b></font><br>"; } } } else { output = "<font color=" + m_headlineColor + ">" + QObject::tr( "No birthdays in <b> %1 </b> days!" ) .arg( m_daysLookAhead ) + "</font> <br>"; } } if ( m_showAnniversaries ){ // Define the query for anniversaries and start search.. OContact queryanniversaries; queryanniversaries.setAnniversary( lookAheadDate ); m_list = m_contactdb->queryByExample( queryanniversaries, OContactAccess::DateDiff ); ammount = 0; if ( m_list.count() > 0 ){ output += "<font color=" + m_headlineColor + ">" + QObject::tr( "Next anniversaries in <b> %1 </b> days:" ) .arg( m_daysLookAhead ) + "</font> <br>"; for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) { if ( ammount++ < m_maxLinesTask ){ // Now we want to calculate how many days until anniversary. // We have to set the correct year to calculate the day diff... QDate destdate = (*m_it).anniversary(); destdate.setYMD( QDate::currentDate().year(), destdate.month(), destdate.day() ); if ( QDate::currentDate().daysTo(destdate) < 0 ) destdate.setYMD( QDate::currentDate().year()+1, destdate.month(), destdate.day() ); if ( QDate::currentDate().daysTo(destdate) < m_urgentDays ) output += "<font color=" + m_urgentColor + "><b>-" + (*m_it).fullName() + " (" + QString::number(QDate::currentDate() .daysTo( destdate ) ) + " Days) </b></font><br>"; else output += "<font color=" + m_entryColor + "><b>-" + (*m_it).fullName() + " (" + QString::number(QDate::currentDate() .daysTo( destdate ) ) + " Days) </b></font><br>"; } } } else { output += "<font color=" + m_headlineColor + ">" + QObject::tr( "No anniversaries in <b> %1 </b> days!" ) .arg( m_daysLookAhead ) + "</font> <br>"; } } addressLabel->setText( output ); } /** * start the todolist */ void AddressBookPluginWidget::startAddressBook() { QCopEnvelope e( "QPE/System", "execute(QString)" ); e << QString( "addressbook" ); } diff --git a/core/pim/today/plugins/datebook/datebookpluginconfig.h b/core/pim/today/plugins/datebook/datebookpluginconfig.h index bc412dd..2d303fc 100644 --- a/core/pim/today/plugins/datebook/datebookpluginconfig.h +++ b/core/pim/today/plugins/datebook/datebookpluginconfig.h @@ -1,62 +1,60 @@ /* * datebookpluginconfig.h * * copyright : (c) 2002,2003 by Maximilian Reiß * email : harlekin@handhelds.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. * * * ***************************************************************************/ #ifndef DATEBOOK_PLUGIN_CONFIG_H #define DATEBOOK_PLUGIN_CONFIG_H #include <qcheckbox.h> #include <qspinbox.h> #include <opie/todayconfigwidget.h> -class DatebookPluginConfig : public TodayConfigWidget { +#include "datebookpluginconfigbase.h" + +class DatebookPluginConfig : public TodayConfigWidget { Q_OBJECT + public: DatebookPluginConfig( QWidget *parent, const char *name ); ~DatebookPluginConfig(); void writeConfig(); private: /** * if changed then save */ bool changed(); void readConfig(); - QCheckBox* CheckBox2; - QCheckBox* CheckBox1; - QCheckBox* CheckBox3; - QSpinBox* SpinBox1; - QSpinBox* SpinBox2; - + DatebookPluginConfigBase *m_gui; // how many lines should be showed in the datebook section int m_max_lines_meet; // If location is to be showed too, 1 to activate it. int m_show_location; // if notes should be shown int m_show_notes; // should only later appointments be shown or all for the current day. int m_only_later; int m_more_days; }; #endif diff --git a/core/pim/today/plugins/todolist/todopluginconfig.h b/core/pim/today/plugins/todolist/todopluginconfig.h index e09251c..54d35cf 100644 --- a/core/pim/today/plugins/todolist/todopluginconfig.h +++ b/core/pim/today/plugins/todolist/todopluginconfig.h @@ -1,58 +1,59 @@ /* * todopluginconfig.h * * copyright : (c) 2002, 2003 by Maximilian Reiß * email : harlekin@handhelds.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. * * * ***************************************************************************/ #ifndef TODOLIST_PLUGIN_CONFIG_H #define TODOLIST_PLUGIN_CONFIG_H -//#include <qwidget.h> #include <qspinbox.h> #include <opie/todayconfigwidget.h> +#include "todopluginconfigbase.h" + class TodolistPluginConfig : public TodayConfigWidget { -Q_OBJECT + Q_OBJECT public: TodolistPluginConfig( QWidget *parent, const char *name ); ~TodolistPluginConfig(); private: /** * if changed then save */ bool changed(); void readConfig(); void writeConfig(); + + TodoPluginConfigBase *m_gui; - QSpinBox* SpinBox2; - QSpinBox* SpinBoxClip; // how many lines should be showed in the todolist section int m_max_lines_task; // clip the lines after X chars int m_maxCharClip; }; #endif diff --git a/core/settings/security/security.cpp b/core/settings/security/security.cpp index c4726b3..00ea105 100644 --- a/core/settings/security/security.cpp +++ b/core/settings/security/security.cpp @@ -1,314 +1,325 @@ /********************************************************************** ** 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 "security.h" #include <qpe/qpeapplication.h> #include <qpe/config.h> #include <qpe/password.h> #include <qpe/qpedialog.h> #include <qpe/qcopenvelope_qws.h> #include <qcheckbox.h> #include <qpushbutton.h> #include <qcombobox.h> #include <qmessagebox.h> #include <qfile.h> #include <qlistview.h> #include <qtextstream.h> Security::Security( QWidget* parent, const char* name, WFlags fl ) : SecurityBase( parent, name, TRUE, fl ) { valid=FALSE; Config cfg("Security"); cfg.setGroup("Passcode"); passcode = cfg.readEntry("passcode"); passcode_poweron->setChecked(cfg.readBoolEntry("passcode_poweron",FALSE)); cfg.setGroup("Sync"); int auth_peer = cfg.readNumEntry("auth_peer",0xc0a88100);//new default 192.168.129.0/24 int auth_peer_bits = cfg.readNumEntry("auth_peer_bits",24); selectNet(auth_peer,auth_peer_bits); connect(syncnet, SIGNAL(textChanged(const QString&)), this, SLOT(setSyncNet(const QString&))); /* cfg.setGroup("Remote"); if ( telnetAvailable() ) telnet->setChecked(cfg.readEntry("allow_telnet")); else telnet->hide(); if ( sshAvailable() ) ssh->setChecked(cfg.readEntry("allow_ssh")); else ssh->hide(); */ QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; Config loginCfg(configFile,Config::File); loginCfg.setGroup("General"); autoLoginName=loginCfg.readEntry("AutoLogin",""); if (autoLoginName.stripWhiteSpace().isEmpty()) { autoLogin=false; } else { autoLogin=true; } cfg.setGroup("SyncMode"); int mode = cfg.readNumEntry("Mode",2); // Default to Sharp syncModeCombo->setCurrentItem( mode - 1 ); connect(autologinToggle, SIGNAL(toggled(bool)), this, SLOT(toggleAutoLogin(bool))); connect(userlist, SIGNAL(activated(int)), this, SLOT(changeLoginName(int))); connect(changepasscode,SIGNAL(clicked()), this, SLOT(changePassCode())); connect(clearpasscode,SIGNAL(clicked()), this, SLOT(clearPassCode())); loadUsers(); updateGUI(); dl = new QPEDialogListener(this); showMaximized(); } Security::~Security() { } void Security::updateGUI() { bool empty = passcode.isEmpty(); changepasscode->setText( empty ? tr("Set passcode" ) : tr("Change passcode" ) ); passcode_poweron->setEnabled( !empty ); clearpasscode->setEnabled( !empty ); autologinToggle->setChecked(autoLogin); userlist->setEnabled(autoLogin); } void Security::show() { - valid=FALSE; + //valid=FALSE; setEnabled(FALSE); SecurityBase::show(); if ( passcode.isEmpty() ) { // could insist... //changePassCode(); //if ( passcode.isEmpty() ) //reject(); } else { - QString pc = enterPassCode(tr("Enter passcode")); - if ( pc != passcode ) { - QMessageBox::critical(this, tr("Passcode incorrect"), - tr("The passcode entered is incorrect.\nAccess denied")); - reject(); - return; - } + + if (!valid) // security passcode was not asked yet, so ask now + { + QString pc = enterPassCode(tr("Enter passcode")); + if ( pc != passcode ) { + QMessageBox::critical(this, tr("Passcode incorrect"), + tr("The passcode entered is incorrect.\nAccess denied")); + reject(); + return; + } + } } setEnabled(TRUE); valid=TRUE; } void Security::accept() { applySecurity(); QDialog::accept(); QCopEnvelope env("QPE/System", "securityChanged()" ); } void Security::done(int r) { QDialog::done(r); close(); } void Security::selectNet(int auth_peer,int auth_peer_bits) { QString sn; if ( auth_peer_bits == 0 && auth_peer == 0 ) { sn = tr("Any"); } else if ( auth_peer_bits == 32 && auth_peer == 0 ) { sn = tr("None"); } else { sn = QString::number((auth_peer>>24)&0xff) + "." + QString::number((auth_peer>>16)&0xff) + "." + QString::number((auth_peer>>8)&0xff) + "." + QString::number((auth_peer>>0)&0xff) + "/" + QString::number(auth_peer_bits); } for (int i=0; i<syncnet->count(); i++) { if ( syncnet->text(i).left(sn.length()) == sn ) { syncnet->setCurrentItem(i); return; } } qDebug("No match for \"%s\"",sn.latin1()); } void Security::parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits) { auth_peer=0; if ( sn == tr("Any") ) { auth_peer = 0; auth_peer_bits = 0; } else if ( sn == tr("None") ) { auth_peer = 0; auth_peer_bits = 32; } else { int x=0; for (int i=0; i<4; i++) { int nx = sn.find(QChar(i==3 ? '/' : '.'),x); auth_peer = (auth_peer<<8)|sn.mid(x,nx-x).toInt(); x = nx+1; } uint n = (uint)sn.find(' ',x)-x; auth_peer_bits = sn.mid(x,n).toInt(); } } void Security::loadUsers ( void ) { QFile passwd("/etc/passwd"); if ( passwd.open(IO_ReadOnly) ) { QTextStream t( &passwd ); QString s; QStringList account; while ( !t.eof() ) { account = QStringList::split(':',t.readLine()); // Hide disabled accounts if (*account.at(1)!="*") { userlist->insertItem(*account.at(0)); // Highlight this item if it is set to autologinToggle if ( *account.at(0) == autoLoginName) userlist->setCurrentItem(userlist->count()-1); } } passwd.close(); } } + void Security::toggleAutoLogin(bool val) { autoLogin=val; userlist->setEnabled(val); if (!autoLogin) autoLoginName=userlist->currentText(); } + + + + void Security::setSyncNet(const QString& sn) { int auth_peer,auth_peer_bits; parseNet(sn,auth_peer,auth_peer_bits); selectNet(auth_peer,auth_peer_bits); } void Security::applySecurity() { if ( valid ) { +<<<<<<< security.cpp Config cfg("Security"); cfg.setGroup("Passcode"); cfg.writeEntry("passcode",passcode); cfg.writeEntry("passcode_poweron",passcode_poweron->isChecked()); cfg.setGroup("Sync"); int auth_peer=0; int auth_peer_bits; QString sn = syncnet->currentText(); parseNet(sn,auth_peer,auth_peer_bits); cfg.writeEntry("auth_peer",auth_peer); cfg.writeEntry("auth_peer_bits",auth_peer_bits); /* cfg.setGroup("Remote"); if ( telnetAvailable() ) cfg.writeEntry("allow_telnet",telnet->isChecked()); if ( sshAvailable() ) cfg.writeEntry("allow_ssh",ssh->isChecked()); // ### write ssh/telnet sys config files */ QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; Config loginCfg(configFile,Config::File); loginCfg.setGroup("General"); if (autoLogin) { loginCfg.writeEntry("AutoLogin",autoLoginName); } else { loginCfg.removeEntry("AutoLogin"); } cfg.setGroup("SyncMode"); cfg.writeEntry("Mode", syncModeCombo->currentItem()+1 ); + } } void Security::changeLoginName( int idx ) { autoLoginName = userlist->text(idx);; updateGUI(); } void Security::changePassCode() { QString new1; QString new2; do { new1 = enterPassCode(tr("Enter new passcode")); if ( new1.isNull() ) return; new2 = enterPassCode(tr("Re-enter new passcode")); if ( new2.isNull() ) return; } while (new1 != new2); passcode = new1; updateGUI(); } void Security::clearPassCode() { passcode = QString::null; updateGUI(); } QString Security::enterPassCode(const QString& prompt) { return Password::getPassword(prompt); } bool Security::telnetAvailable() const { // ### not implemented return FALSE; } bool Security::sshAvailable() const { // ### not implemented return FALSE; } |