-rw-r--r-- | korganizer/calendarview.cpp | 20 | ||||
-rw-r--r-- | korganizer/koeditordetails.cpp | 2 | ||||
-rw-r--r-- | korganizer/koeditorgeneral.cpp | 9 | ||||
-rw-r--r-- | korganizer/koeditorgeneralevent.cpp | 5 | ||||
-rw-r--r-- | korganizer/koeditorgeneraltodo.cpp | 2 | ||||
-rw-r--r-- | korganizer/koeventeditor.cpp | 6 | ||||
-rw-r--r-- | korganizer/koincidenceeditor.cpp | 2 | ||||
-rw-r--r-- | korganizer/kotodoeditor.cpp | 4 |
8 files changed, 40 insertions, 10 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index c0f3be7..fd026fa 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -591,192 +591,206 @@ void CalendarView::init() connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); connect(QApplication::clipboard(),SIGNAL(dataChanged()), SLOT(checkClipboard())); connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), SLOT( processTodoListSelection( Incidence * ) ) ); connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); // kdDebug() << "CalendarView::CalendarView() done" << endl; mDateFrame = new QVBox(0,0,WType_Popup); //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); mDateFrame->setLineWidth(3); mDateFrame->hide(); mDateFrame->setCaption( i18n( "Pick a date to display")); mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); mEventEditor = mDialogManager->getEventEditor(); mTodoEditor = mDialogManager->getTodoEditor(); mFlagEditDescription = false; mSuspendTimer = new QTimer( this ); mAlarmTimer = new QTimer( this ); mRecheckAlarmTimer = new QTimer( this ); connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); mAlarmDialog = new AlarmDialog( this ); connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); mAlarmDialog->setServerNotification( false ); mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); #ifndef DESKTOP_VERSION //US listen for arriving address resultsets connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); #endif mDateNavigator->setCalendar( mCalendar ); } CalendarView::~CalendarView() { // kdDebug() << "~CalendarView()" << endl; //qDebug("CalendarView::~CalendarView() "); delete mDialogManager; delete mViewManager; delete mStorage; delete mDateFrame ; delete mEventViewerDialog; //kdDebug() << "~CalendarView() done" << endl; } void CalendarView::setScrollBarStep(int val ) { #ifdef DESKTOP_VERSION mDateScrollBar->setLineStep ( val ); #endif } void CalendarView::scrollBarValue(int val ) { #ifdef DESKTOP_VERSION if ( QApplication::desktop()->width() < 800 ) return; static bool block = false; if ( block ) return; block = true; val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); //qDebug("VAL %d ",val ); int count = mNavigator->selectedDates().count(); int year = mNavigator->selectedDates().first().year(); int day = mNavigator->selectedDates().first().dayOfYear(); if ( val == day -1 ) { block = false; return; } QDate d ( year,1,1 ); mNavigator->selectDates( d.addDays( val ), count ); block = false; #endif } void CalendarView::checkAlarms() { + + QString message; + QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; + KopiCalendarFile * cal = calendars.first(); + while ( cal ) { + if ( cal->mErrorOnLoad ) { + message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; + } + cal = calendars.next(); + } + if ( !message.isEmpty() ) { + message = KGlobal::formatMessage( i18n("The loading of one or more calendar failed:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); + KMessageBox::error(this,message); + } KConfig *config = KOGlobals::config(); config->setGroup( "AppRun" ); QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); int daysto = dt.daysTo( QDate::currentDate() ); int days = config->readNumEntry( "LatestProgramStopDays" , daysto); dt = dt.addDays( days ); int secto = dt.secsTo( QDateTime::currentDateTime() ); int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; //qDebug("KO: Reading program stop %d ", secs); //secs -= ( 3600 * 24*3 ); // debug only QDateTime latest = dt.addSecs ( secs ); qDebug("KO: Last termination on %s ", latest.toString().latin1()); //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); QPtrList<Incidence> el = mCalendar->rawIncidences(); QPtrList<Incidence> al; Incidence* inL = el.first(); QDateTime cur = QDateTime::currentDateTime().addSecs(-59); qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); while ( inL ) { bool ok = false; int offset = 0; QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; if ( ok ) { //qDebug("OK %s",next.toString().latin1()); if ( next < cur ) { al.append( inL ); //qDebug("found missed alarm: %s ", inL->summary().latin1() ); } } inL = el.next(); } if ( al.count() ) { QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); dia->setCaption( i18n("KO/Pi: Missing alarms!") ); QVBoxLayout* lay = new QVBoxLayout( dia ); lay->setSpacing( 0 ); lay->setMargin( 0 ); MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); lay->addWidget( matb ); if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { int wid = 210; int x = QApplication::desktop()->width() - wid - 7; int y = QApplication::desktop()->height() - wid - 70; dia->setGeometry ( x,y,wid,wid); } else { int si = 220; if ( QApplication::desktop()->width() > 470 ) si = 400; dia->resize(si,si/2); } dia->setBackgroundColor( QColor( 255, 255, 255 ) ); dia->show(); } } void CalendarView::showDay( QDate d ) { dateNavigator()->blockSignals( true ); dateNavigator()->selectDate( d ); dateNavigator()->blockSignals( false ); mViewManager->showDayView(); //dateNavigator()->selectDate( d ); } void CalendarView::timerAlarm() { //qDebug("CalendarView::timerAlarm() "); computeAlarm(mAlarmNotification ); } void CalendarView::suspendAlarm() { //qDebug(" CalendarView::suspendAlarm() "); computeAlarm(mSuspendAlarmNotification ); } void CalendarView::startAlarm( QString mess , QString filename) { topLevelWidget()->showNormal(); topLevelWidget()->setActiveWindow(); topLevelWidget()->raise(); mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); } void CalendarView::checkNextTimerAlarm() { mCalendar->checkAlarmForIncidence( 0, true ); } void CalendarView::computeAlarm( QString msg ) { @@ -1830,203 +1844,203 @@ bool CalendarView::importQtopia( const QString &categories, QtopiaFormat qtopiaFormat; qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); updateView(); return true; #if 0 mGlobalSyncMode = SYNC_MODE_QTOPIA; mCurrentSyncDevice = "qtopia-XML"; if ( mSyncManager->mAskForPreferences ) edit_sync_options(); qApp->processEvents(); CalendarLocal* calendar = new CalendarLocal(); calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); bool syncOK = false; QtopiaFormat qtopiaFormat; qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); bool loadOk = true; if ( !categories.isEmpty() ) loadOk = qtopiaFormat.load( calendar, categories ); if ( loadOk && !datebook.isEmpty() ) loadOk = qtopiaFormat.load( calendar, datebook ); if ( loadOk && !todolist.isEmpty() ) loadOk = qtopiaFormat.load( calendar, todolist ); if ( loadOk ) { getEventViewerDialog()->setSyncMode( true ); syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); getEventViewerDialog()->setSyncMode( false ); qApp->processEvents(); if ( syncOK ) { if ( mSyncManager->mWriteBackFile ) { // write back XML file } setModified( true ); } } else { QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), question, i18n("Ok")) ; } delete calendar; updateView(); return syncOK; #endif } void CalendarView::setSyncEventsReadOnly() { mCalendar->setSyncEventsReadOnly(); } bool CalendarView::loadCalendars() { QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; KopiCalendarFile * cal = calendars.first(); mCalendar->setDefaultCalendar( 1 ); openCalendar( MainWindow::defaultFileName(), false ); cal = calendars.next(); while ( cal ) { addCalendar( cal ); cal = calendars.next(); } restoreCalendarSettings(); return true; } bool CalendarView::restoreCalendarSettings() { QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; KopiCalendarFile * cal = calendars.first(); while ( cal ) { mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); if ( cal->isStandard ) mCalendar->setDefaultCalendar( cal->mCalNumber ); cal = calendars.next(); } setSyncEventsReadOnly(); mCalendar->reInitAlarmSettings(); updateUnmanagedViews(); updateView(); return true; } void CalendarView::addCalendarId( int id ) { KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); - addCalendar( cal ); + if ( cal ) + addCalendar( cal ); } bool CalendarView::addCalendar( KopiCalendarFile * cal ) { cal->mErrorOnLoad = false; if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { cal->mLoadDt = QDateTime::currentDateTime(); return true; } - qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() ); - KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName)); + qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); cal->mErrorOnLoad = true; return false; } bool CalendarView::openCalendar(QString filename, bool merge) { if (filename.isEmpty()) { return false; } if (!QFile::exists(filename)) { KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); return false; } globalFlagBlockAgenda = 1; clearAllViews(); if (!merge) { mViewManager->setDocumentId( filename ); mCalendar->close(); } mStorage->setFileName( filename ); if ( mStorage->load() ) { if ( merge ) ;//setModified( true ); else { //setModified( true ); mViewManager->setDocumentId( filename ); mDialogManager->setDocumentId( filename ); mTodoList->setDocumentId( filename ); } globalFlagBlockAgenda = 2; // if ( getLastSyncEvent() ) // getLastSyncEvent()->setReadOnly( true ); mCalendar->reInitAlarmSettings(); setSyncEventsReadOnly(); updateUnmanagedViews(); updateView(); if ( filename != MainWindow::defaultFileName() ) { saveCalendar( MainWindow::defaultFileName() ); } else { QFileInfo finf ( MainWindow::defaultFileName()); if ( finf.exists() ) { setLoadedFileVersion( finf.lastModified () ); } } return true; } else { // while failing to load, the calendar object could // have become partially populated. Clear it out. if ( !merge ) { mCalendar->close(); mViewManager->setDocumentId( filename ); mDialogManager->setDocumentId( filename ); mTodoList->setDocumentId( filename ); } //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); globalFlagBlockAgenda = 2; mCalendar->reInitAlarmSettings(); setSyncEventsReadOnly(); updateUnmanagedViews(); updateView(); } return false; } void CalendarView::showOpenError() { KMessageBox::error(this,i18n("Couldn't load calendar\n.")); } void CalendarView::setLoadedFileVersion(QDateTime dt) { loadedFileVersion = dt; } bool CalendarView::checkFileChanged(QString fn) { QFileInfo finf ( fn ); if ( !finf.exists() ) return true; QDateTime dt = finf.lastModified (); if ( dt <= loadedFileVersion ) return false; return true; } void CalendarView::watchSavedFile() { QFileInfo finf ( MainWindow::defaultFileName()); if ( !finf.exists() ) return; QDateTime dt = finf.lastModified (); if ( dt < loadedFileVersion ) { //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); diff --git a/korganizer/koeditordetails.cpp b/korganizer/koeditordetails.cpp index 7354940..479bd8b 100644 --- a/korganizer/koeditordetails.cpp +++ b/korganizer/koeditordetails.cpp @@ -1,179 +1,181 @@ /* This file is part of KOrganizer. Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in thse hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #include <qtooltip.h> #include <qfiledialog.h> #include <qlayout.h> #include <qvbox.h> #include <qbuttongroup.h> #include <qvgroupbox.h> #include <qwidgetstack.h> #include <qdatetime.h> #include <qapp.h> #include <klocale.h> #include <kglobal.h> +#include <kdialog.h> #include <kiconloader.h> #include <kstandarddirs.h> #include <kmessagebox.h> #ifndef KORG_NOKABC #ifdef DESKTOP_VERSION #include <kabc/addresseedialog.h> #else //DESKTOP_VERSION #include <externalapphandler.h> #endif //DESKTOP_VERSION #endif #include <libkcal/incidence.h> #include "koprefs.h" #include "koeditordetails.h" template <> CustomListViewItem<class Attendee *>::~CustomListViewItem() { delete mData; } template <> void CustomListViewItem<class Attendee *>::updateItem() { setText(0,mData->name()); setText(1,mData->email()); setText(2,mData->roleStr()); setText(3,mData->statusStr()); if (mData->RSVP() && !mData->email().isEmpty()) { setPixmap(4,SmallIcon("mailappt")); setSortKey(4,"j"); } else { setPixmap(4,SmallIcon("nomailappt")); setSortKey(4,"n"); } } KOEditorDetails::KOEditorDetails (int spacing,QWidget* parent,const char* name) : QWidget( parent, name), mDisableItemUpdate( false ) { QGridLayout *topLayout = new QGridLayout(this); topLayout->setSpacing(spacing); + topLayout->setMargin(KDialog::marginHint()-2); QString organizer = KOPrefs::instance()->email(); mOrganizerLabel = new QLabel(i18n("Organizer: %1").arg(organizer),this); mListView = new KListView(this,"mListView"); mListView->addColumn(i18n("Name"),180); mListView->addColumn(i18n("Email"),180); mListView->addColumn(i18n("Role"),60); mListView->addColumn(i18n("Status"),100); mListView->addColumn(i18n("RSVP"),35); if ( QApplication::desktop()->width() <= 320 || QApplication::desktop()->height() <= 240) { int hei = 80; if ( QApplication::desktop()->height() <= 240 ) hei = 60; mListView->setFixedHeight(hei); } mListView->setAllColumnsShowFocus (true ); //mListView->setSingleClick( true ); connect(mListView,SIGNAL(selectionChanged(QListViewItem *)), SLOT(updateAttendeeInput())); connect(mListView,SIGNAL(executed(QListViewItem * ,const QPoint&, int )), SLOT(itemClicked(QListViewItem * ,const QPoint& , int ))); mRsvpButton = new QCheckBox(this); mRsvpButton->setText(i18n("Request response")); mAddressBookButton = new QPushButton(i18n("Address &Book..."),this); QLabel *attendeeLabel = new QLabel(this); attendeeLabel->setText(i18n("Name:")); attendeeLabel->setFixedSize( attendeeLabel->sizeHint() ); mNameEdit = new QLineEdit(this); connect(mNameEdit,SIGNAL(textChanged(const QString &)), SLOT(updateAttendeeItem())); mUidEdit = new QLineEdit(0); mUidEdit->setText(""); QLabel *emailLabel = new QLabel(this); emailLabel->setText(i18n("Email:")); mEmailEdit = new QLineEdit(this); connect(mEmailEdit,SIGNAL(textChanged(const QString &)), SLOT(updateAttendeeItem())); QLabel *attendeeRoleLabel = new QLabel(this); attendeeRoleLabel->setText(i18n("Role:")); mRoleCombo = new QComboBox(false,this); mRoleCombo->insertStringList(Attendee::roleList()); connect(mRoleCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem())); QLabel *statusLabel = new QLabel(this); statusLabel->setText( i18n("Status:") ); mStatusCombo = new QComboBox(false,this); mStatusCombo->insertStringList(Attendee::statusList()); connect(mStatusCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem())); connect(mRsvpButton,SIGNAL(clicked()),SLOT(updateAttendeeItem())); QWidget *buttonBox = new QWidget(this); QVBoxLayout *buttonLayout = new QVBoxLayout(buttonBox); QPushButton *newButton = new QPushButton(i18n("&New"),buttonBox); buttonLayout->addWidget(newButton); connect(newButton,SIGNAL(clicked()),SLOT(addNewAttendee())); mRemoveButton = new QPushButton(i18n("&Remove"),buttonBox); buttonLayout->addWidget(mRemoveButton); connect(mRemoveButton, SIGNAL(clicked()),SLOT(removeAttendee())); // buttonLayout->addWidget(mAddressBookButton); connect(mAddressBookButton,SIGNAL(clicked()),SLOT(openAddressBook())); //mRoleCombo->setFixedSize( mRoleCombo->sizeHint () ); if ( QApplication::desktop()->height() <= 240 ) { mRoleCombo->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Minimum ,FALSE) ); mStatusCombo->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Minimum ,FALSE) ); topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,5); topLayout->addMultiCellWidget(mListView,1,1,0,5); topLayout->addWidget(attendeeLabel,3,0); topLayout->addMultiCellWidget(mNameEdit,3,3,1,4); topLayout->addWidget(emailLabel,4,0); topLayout->addMultiCellWidget(mEmailEdit,4,4,1,4); topLayout->addWidget(attendeeRoleLabel,5,0); topLayout->addMultiCellWidget(mRoleCombo,5,5,1,2); topLayout->addWidget(statusLabel,5,3); topLayout->addMultiCellWidget(mStatusCombo,5,5,4,5); topLayout->addMultiCellWidget(mAddressBookButton,2,2,2,5); topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1); topLayout->addMultiCellWidget(buttonBox,3,4,5,5); topLayout->setRowStretch(1,5); topLayout->setColStretch(0,0); } else { if (qApp->desktop()->width() < 640 ) { if ( qApp->desktop()->width() < 300 ) topLayout->setSpacing(1); ;//mListView->setFixedHeight(80); topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,3); diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp index e07bc53..29e68b3 100644 --- a/korganizer/koeditorgeneral.cpp +++ b/korganizer/koeditorgeneral.cpp @@ -1,288 +1,291 @@ /* This file is part of KOrganizer. Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #include <qwidget.h> #include <qtooltip.h> #include <qlayout.h> #include <qvbox.h> #include <qbuttongroup.h> #include <qvgroupbox.h> #include <qwidgetstack.h> #include <qdatetime.h> #include <qtimer.h> #include <qfile.h> #include <qregexp.h> #include <kglobal.h> +#include <kdialog.h> #include <kdebug.h> #include <klocale.h> #include <kiconloader.h> #include <kmessagebox.h> #include <kfiledialog.h> #include <kstandarddirs.h> #include <libkcal/todo.h> #include <libkcal/event.h> #include <libkdepim/categoryselectdialog.h> #include <libkdepim/kdateedit.h> #include "koprefs.h" #include "koglobals.h" #include "koeditorgeneral.h" #include "kolocationbox.h" #ifndef DESKTOP_VERSION #include <qpe/qpeapplication.h> #else #include <qapplication.h> #endif KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) : QObject( parent, name) { mNextFocus = 0; } KOEditorGeneral::~KOEditorGeneral() { } void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout) { QGridLayout *headerLayout = new QGridLayout(topLayout); #if 0 mOwnerLabel = new QLabel(i18n("Owner:"),parent); headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1); #endif - + // 1 on pda + // 11 on desktop + headerLayout->setSpacing( (KDialog::spacingHint()-3)*2+1 ); QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent); headerLayout->addWidget(summaryLabel,1,0); mSummaryEdit = new KOLocationBox(TRUE,parent, 10); mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) ); //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() ); int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2; if ( QApplication::desktop()->width() > 320 ) mSummaryEdit->setMaximumHeight( hei +6 ); //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding ); // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink } // mSummaryEdit = new QLineEdit(parent); headerLayout->addWidget(mSummaryEdit,1,1); connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); QLabel *locationLabel = new QLabel(i18n("Location:"),parent); if ( QApplication::desktop()->height() < 320 ) headerLayout->addWidget(locationLabel,1,2); else headerLayout->addWidget(locationLabel,2,0); mLocationEdit = new KOLocationBox(TRUE,parent,10); - mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); + mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->height() > 240 ) mLocationEdit->setMaximumHeight( hei + 6); // mLocationEdit = new QLineEdit(parent); connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); if ( QApplication::desktop()->height() < 320 ) { headerLayout->addWidget(mLocationEdit,1,3); headerLayout->setColStretch( 1, 10); headerLayout->setColStretch( 3, 10); } else { headerLayout->addWidget(mLocationEdit,2,1); headerLayout->setColStretch( 1, 10); } } void KOEditorGeneral::setFocusOn( int i ) { mNextFocus = i; QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() )); } void KOEditorGeneral::slotSetFocusOn() { mNextFocus; if ( mNextFocus == 1 ) { mDescriptionEdit->setFocus(); mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); } if ( mNextFocus == 2 ) { mSummaryEdit->setFocus(); } } void KOEditorGeneral::editCategories() { // qDebug("KOEditorGeneral::editCategories() "); KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); //KOGlobals::fitDialogToScreen( csd ); csd->setColorEnabled(); csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); csd->exec(); delete csd; } void KOEditorGeneral::showCatPopup() { mCatPopup->clear(); QStringList checkedCategories = QStringList::split (",", mCategoriesLabel->text()); int index = 0; for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); it != KOPrefs::instance()->mCustomCategories.end (); ++it) { mCatPopup->insertItem (*it, index ); //mCategory[index] = *it; if (checkedCategories.find (*it) != checkedCategories.end ()) mCatPopup->setItemChecked (index, true); ++index; } } void KOEditorGeneral::selectedCatPopup( int index ) { QStringList categories = QStringList::split (",", mCategoriesLabel->text()); QString colcat = categories.first(); if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ()) categories.remove (KOPrefs::instance()->mCustomCategories[index]); else categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]); categories.sort (); if ( !colcat.isEmpty() ) { if ( categories.find ( colcat ) != categories.end () ) { categories.remove( colcat ); categories.prepend( colcat ); } } setCategories( categories.join(",") ); } void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) { QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); mCatPopup = new QPopupMenu ( parent ); mCatPopup->setCheckable (true); connect(mCatPopup,SIGNAL(aboutToShow () ), this ,SLOT(showCatPopup())); connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT(selectedCatPopup( int ))); mCategoriesButton = new QPushButton(parent); mCategoriesButton->setText(i18n("Categories...")); connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); //connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); categoriesLayout->addWidget(mCategoriesButton); mCategoriesLabel = new QPushButton(parent);//new QLabel(parent); - mCategoriesLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); + mCategoriesLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Fixed ,FALSE) ); mCategoriesLabel->setPopup( mCatPopup ); //mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); categoriesLayout->addWidget(mCategoriesLabel,1); } void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) { QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); secrecyLayout->addWidget(mCancelBox); secrecyLayout->addWidget(secrecyLabel); mSecrecyCombo = new QComboBox(parent); mSecrecyCombo->insertStringList(Incidence::secrecyList()); secrecyLayout->addWidget(mSecrecyCombo); } void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout) { mDescriptionEdit = new KTextEdit(parent); mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont ); mDescriptionEdit->append(""); mDescriptionEdit->setReadOnly(false); mDescriptionEdit->setOverwriteMode(false); mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); topLayout->addWidget(mDescriptionEdit); #ifndef DESKTOP_VERSION QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold ); #endif } void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) { QBoxLayout *alarmLayout = new QHBoxLayout(topLayout); //mAlarmBell = new QLabel(parent); //mAlarmBell->setPixmap(SmallIcon("bell")); //alarmLayout->addWidget(mAlarmBell); if ( QApplication::desktop()->width() < 320 ) mAlarmButton = new QCheckBox(i18n("Rem."),parent); else mAlarmButton = new QCheckBox(i18n("Reminder:"),parent); connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool))); alarmLayout->addWidget(mAlarmButton); mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus ); alarmLayout->addWidget(mAlarmTimeEdit); mAlarmIncrCombo = new QComboBox(false, parent); if ( QApplication::desktop()->width() < 320 ) { mAlarmIncrCombo->insertItem(i18n("min")); mAlarmIncrCombo->insertItem(i18n("hou")); mAlarmIncrCombo->insertItem(i18n("day")); mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() ); mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() ); } else { mAlarmIncrCombo->insertItem(i18n("minute(s)")); mAlarmIncrCombo->insertItem(i18n("hour(s)")); mAlarmIncrCombo->insertItem(i18n("day(s)")); } // mAlarmIncrCombo->setMinimumHeight(20); alarmLayout->addWidget(mAlarmIncrCombo); mAlarmSoundButton = new QPushButton(parent); mAlarmSoundButton->setPixmap(SmallIcon("playsound")); mAlarmSoundButton->setToggleButton(true); QToolTip::add(mAlarmSoundButton, i18n("No sound set")); connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); alarmLayout->addWidget(mAlarmSoundButton); mAlarmProgramButton = new QPushButton(parent); mAlarmProgramButton->setPixmap(SmallIcon("run")); mAlarmProgramButton->setToggleButton(true); QToolTip::add(mAlarmProgramButton, i18n("No program set")); connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); alarmLayout->addWidget(mAlarmProgramButton); mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); // if ( KOPrefs::instance()->mCompactDialogs ) { // mAlarmSoundButton->hide(); // mAlarmProgramButton->hide(); // } } void KOEditorGeneral::pickAlarmSound() { //qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() ); bool oldState = mAlarmSoundButton->isOn(); QString fileName(KFileDialog::getOpenFileName(mAlarmSound, diff --git a/korganizer/koeditorgeneralevent.cpp b/korganizer/koeditorgeneralevent.cpp index 3dd7f5c..2c6ed9f 100644 --- a/korganizer/koeditorgeneralevent.cpp +++ b/korganizer/koeditorgeneralevent.cpp @@ -1,191 +1,192 @@ /* This file is part of KOrganizer. Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #include <qtooltip.h> #include <qlayout.h> #include <qvbox.h> #include <qbuttongroup.h> #include <qvgroupbox.h> #include <qwidgetstack.h> #include <qdatetime.h> #include <kdebug.h> #include <kglobal.h> +#include <kdialog.h> #include <klocale.h> #include <kiconloader.h> #include <kmessagebox.h> #include <kfiledialog.h> #include <kstandarddirs.h> #include <libkcal/event.h> #include <libkdepim/kdateedit.h> #include "koprefs.h" #include "koeditorgeneralevent.h" #include "kolocationbox.h" KOEditorGeneralEvent::KOEditorGeneralEvent(QObject* parent, const char* name) : KOEditorGeneral( parent, name) { mTemplate = false; connect(this,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), SLOT(setDuration())); connect(this,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), SLOT(emitDateTimeStr())); } KOEditorGeneralEvent::~KOEditorGeneralEvent() { } void KOEditorGeneralEvent::finishSetup() { //disabled // QWidget::setTabOrder( mSummaryEdit, mLocationEdit ); // QWidget::setTabOrder( mLocationEdit, mStartDateEdit ); // QWidget::setTabOrder( mStartDateEdit, mStartTimeEdit ); // QWidget::setTabOrder( mStartTimeEdit, mEndDateEdit ); // QWidget::setTabOrder( mEndDateEdit, mEndTimeEdit ); // QWidget::setTabOrder( mEndTimeEdit, mNoTimeButton ); // QWidget::setTabOrder( mNoTimeButton, mAlarmButton ); // QWidget::setTabOrder( mAlarmButton, mAlarmTimeEdit ); // QWidget::setTabOrder( mFreeTimeCombo, mCategoriesButton ); // QWidget::setTabOrder( mCategoriesButton, mSecrecyCombo ); // QWidget::setTabOrder( mSecrecyCombo, mDescriptionEdit ); mSummaryEdit->load(KOLocationBox::SUMMARYEVENT); mSummaryEdit->setFocus(); } void KOEditorGeneralEvent::initTime(QWidget *parent,QBoxLayout *topLayout) { QBoxLayout *timeLayout = new QVBoxLayout(topLayout); QGroupBox *timeGroupBox = new QGroupBox(1,QGroupBox::Horizontal, i18n("Date && Time"),parent); timeLayout->addWidget(timeGroupBox); - timeGroupBox->layout()->setSpacing( 0 ); - timeGroupBox->layout()->setMargin( 5 ); + timeGroupBox->layout()->setSpacing( KDialog::spacingHintSmall() ); + timeGroupBox->layout()->setMargin( KDialog::marginHint() ); QFrame *timeBoxFrame = new QFrame(timeGroupBox); QGridLayout *layoutTimeBox = new QGridLayout(timeBoxFrame,2,3); layoutTimeBox->setSpacing(topLayout->spacing()); mStartDateLabel = new QLabel(i18n("Start:"),timeBoxFrame); layoutTimeBox->addWidget(mStartDateLabel,0,0); mStartDateEdit = new KDateEdit(timeBoxFrame); layoutTimeBox->addWidget(mStartDateEdit,0,1); mStartTimeEdit = new KOTimeEdit(timeBoxFrame); layoutTimeBox->addWidget(mStartTimeEdit,0,2); mEndDateLabel = new QLabel(i18n("End:"),timeBoxFrame); layoutTimeBox->addWidget(mEndDateLabel,1,0); mEndDateEdit = new KDateEdit(timeBoxFrame); layoutTimeBox->addWidget(mEndDateEdit,1,1); mEndTimeEdit = new KOTimeEdit(timeBoxFrame); layoutTimeBox->addWidget(mEndTimeEdit,1,2); QWidget* duration = new QWidget( timeBoxFrame ); QHBoxLayout *flagsBox = new QHBoxLayout( duration ); mNoTimeButton = new QCheckBox(i18n("All day event"),duration); flagsBox->addWidget(mNoTimeButton); connect(mNoTimeButton, SIGNAL(toggled(bool)),SLOT(dontAssociateTime(bool))); mDurationLabel = new QLabel( duration ); // if ( KOPrefs::instance()->mCompactDialogs ) { //layoutTimeBox->addMultiCellWidget( mDurationLabel, 3, 3, 0, 3 ); //} else { flagsBox->addWidget( mDurationLabel ); //} flagsBox->setStretchFactor(mDurationLabel, 10 ); mDurationLabel->setAlignment( AlignRight | AlignVCenter); layoutTimeBox->addMultiCellWidget( duration, 2, 2, 0, 3 ); // time widgets are checked if they contain a valid time connect(mStartTimeEdit, SIGNAL(timeChanged(QTime)), this, SLOT(startTimeChanged(QTime))); connect(mEndTimeEdit, SIGNAL(timeChanged(QTime)), this, SLOT(endTimeChanged(QTime))); // date widgets are checked if they contain a valid date connect(mStartDateEdit, SIGNAL(dateChanged(QDate)), this, SLOT(startDateChanged(QDate))); connect(mEndDateEdit, SIGNAL(dateChanged(QDate)), this, SLOT(endDateChanged(QDate))); connect(mStartDateEdit,SIGNAL(setTimeTo(QTime)),this,SLOT(sTimeChanged(QTime))); connect(mEndDateEdit,SIGNAL(setTimeTo(QTime)),this,SLOT(eTimeChanged(QTime))); } void KOEditorGeneralEvent::initClass(QWidget *parent,QBoxLayout *topLayout) { QBoxLayout *classLayout = new QHBoxLayout(topLayout); QLabel *freeTimeLabel = new QLabel(i18n("Show time as:"),parent); classLayout->addWidget(freeTimeLabel); mFreeTimeCombo = new QComboBox(false, parent); mFreeTimeCombo->insertItem(i18n("Busy")); mFreeTimeCombo->insertItem(i18n("Free")); classLayout->addWidget(mFreeTimeCombo); } void KOEditorGeneralEvent::timeStuffDisable(bool disable) { mStartTimeEdit->setEnabled( !disable ); mEndTimeEdit->setEnabled( !disable ); setDuration(); emitDateTimeStr(); } void KOEditorGeneralEvent::dontAssociateTime(bool noTime) { timeStuffDisable(noTime); //if(alarmButton->isChecked()) alarmStuffDisable(noTime); allDayChanged(noTime); } void KOEditorGeneralEvent::setDateTimes(QDateTime start, QDateTime end) { // kdDebug() << "KOEditorGeneralEvent::setDateTimes(): Start DateTime: " << start.toString() << endl; if ( !mTemplate ) mStartDateEdit->setDate(start.date()); // KTimeEdit seems to emit some signals when setTime() is called. mStartTimeEdit->blockSignals( true ); mStartTimeEdit->setTime(start.time()); mStartTimeEdit->blockSignals( false ); if ( !mTemplate ) mEndDateEdit->setDate(end.date()); mEndTimeEdit->setTime(end.time()); mCurrStartDateTime = start; diff --git a/korganizer/koeditorgeneraltodo.cpp b/korganizer/koeditorgeneraltodo.cpp index 0a734ee..965cf47 100644 --- a/korganizer/koeditorgeneraltodo.cpp +++ b/korganizer/koeditorgeneraltodo.cpp @@ -1,188 +1,188 @@ /* This file is part of KOrganizer. Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #include <qtooltip.h> #include <qfiledialog.h> #include <qlayout.h> #include <qvbox.h> #include <qbuttongroup.h> #include <qvgroupbox.h> #include <qwidgetstack.h> #include <qdatetime.h> #include <qapplication.h> #include <kglobal.h> #include <klocale.h> #include <kiconloader.h> #include <kmessagebox.h> #include <kdebug.h> #include <krestrictedline.h> #include <kstandarddirs.h> #include <kfiledialog.h> #include <kdialog.h> #include <libkcal/todo.h> #include <libkdepim/kdateedit.h> #include "koprefs.h" #include "ktimeedit.h" #include "koeditorgeneraltodo.h" #include "kolocationbox.h" KOEditorGeneralTodo::KOEditorGeneralTodo(QObject* parent, const char* name) : KOEditorGeneral( parent, name) { } KOEditorGeneralTodo::~KOEditorGeneralTodo() { } void KOEditorGeneralTodo::finishSetup() { // QWidget::setTabOrder(mSummaryEdit, mLocationEdit); // QWidget::setTabOrder(mLocationEdit, mDueCheck); // QWidget::setTabOrder(mDueCheck, mDueDateEdit); // QWidget::setTabOrder(mDueDateEdit, mDueTimeEdit); // QWidget::setTabOrder(mDueTimeEdit, mStartCheck); // QWidget::setTabOrder(mStartCheck, mStartDateEdit); // QWidget::setTabOrder(mStartDateEdit, mStartTimeEdit); // QWidget::setTabOrder(mStartTimeEdit, mTimeButton); // QWidget::setTabOrder(mTimeButton, mCompletedCombo); // QWidget::setTabOrder(mCompletedCombo, mPriorityCombo); // QWidget::setTabOrder(mPriorityCombo, mAlarmButton); // QWidget::setTabOrder(mAlarmButton, mCategoriesButton); // QWidget::setTabOrder(mCategoriesButton, mSecrecyCombo); // QWidget::setTabOrder(mSecrecyCombo, mDescriptionEdit); mSummaryEdit->load(KOLocationBox::SUMMARYTODO); mSummaryEdit->setFocus(); } void KOEditorGeneralTodo::initTime(QWidget *parent,QBoxLayout *topLayout) { QBoxLayout *timeLayout = new QVBoxLayout(topLayout); QGroupBox *timeGroupBox = new QGroupBox(1,QGroupBox::Horizontal, i18n("Date && Time"),parent); timeLayout->addWidget(timeGroupBox); - timeGroupBox->layout()->setSpacing( KDialog::spacingHintSmall() ); + timeGroupBox->layout()->setSpacing( KDialog::spacingHint()-2 ); timeGroupBox->layout()->setMargin( KDialog::marginHint() ); QFrame *timeBoxFrame = new QFrame(timeGroupBox); QGridLayout *layoutTimeBox = new QGridLayout(timeBoxFrame,3,3); layoutTimeBox->setSpacing(KDialog::spacingHintSmall()); layoutTimeBox->setColStretch( 1, 1 ); mDueCheck = new QCheckBox(i18n("Due:"),timeBoxFrame); layoutTimeBox->addWidget(mDueCheck,1,0); connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(enableDueEdit(bool))); connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(showAlarm())); mDueDateEdit = new KDateEdit(timeBoxFrame); layoutTimeBox->addWidget(mDueDateEdit,1,1); mDueTimeEdit = new KOTimeEdit(timeBoxFrame); layoutTimeBox->addWidget(mDueTimeEdit,1,2); mStartCheck = new QCheckBox(i18n("Start:"),timeBoxFrame); layoutTimeBox->addWidget(mStartCheck,0,0); connect(mStartCheck,SIGNAL(toggled(bool)),SLOT(enableStartEdit(bool))); mStartDateEdit = new KDateEdit(timeBoxFrame); layoutTimeBox->addWidget(mStartDateEdit,0,1); mStartTimeEdit = new KOTimeEdit(timeBoxFrame); layoutTimeBox->addWidget(mStartTimeEdit,0,2); mTimeButton = new QCheckBox(i18n("Time associated"),timeBoxFrame); layoutTimeBox->addMultiCellWidget(mTimeButton,2,2,0,1); connect(mTimeButton,SIGNAL(toggled(bool)),SLOT(enableTimeEdits(bool))); connect(mDueDateEdit,SIGNAL(setTimeTo(QTime)),mDueTimeEdit,SLOT(setTime(QTime))); connect(mStartDateEdit,SIGNAL(setTimeTo(QTime)),mStartTimeEdit,SLOT(setTime(QTime))); connect(mStartDateEdit, SIGNAL(dateChanged(QDate)), this, SLOT(startDateChanged(QDate))); // some more layouting //layoutTimeBox->setColStretch(3,1); } void KOEditorGeneralTodo::initCompletion(QWidget *parent, QBoxLayout *topLayout) { mCompletedCombo = new QComboBox(parent); // xgettext:no-c-format mCompletedCombo->insertItem(i18n(" 0 %")); // xgettext:no-c-format mCompletedCombo->insertItem(i18n(" 20 %")); // xgettext:no-c-format mCompletedCombo->insertItem(i18n(" 40 %")); // xgettext:no-c-format mCompletedCombo->insertItem(i18n(" 60 %")); // xgettext:no-c-format mCompletedCombo->insertItem(i18n(" 80 %")); // xgettext:no-c-format mCompletedCombo->insertItem(i18n("100 %")); connect(mCompletedCombo,SIGNAL(activated(int)),SLOT(completedChanged(int))); topLayout->addWidget(mCompletedCombo); mCompletedLabel = new QLabel(i18n("completed"),parent); topLayout->addWidget(mCompletedLabel); mCompleteDateEdit = new KDateEdit(parent); topLayout->addWidget(mCompleteDateEdit ); mCompleteTimeEdit = new KOTimeEdit(parent); topLayout->addWidget( mCompleteTimeEdit); mCompletedCombo->setSizePolicy( QSizePolicy( QSizePolicy::Preferred,QSizePolicy::Preferred) ); mCompletedLabel->setSizePolicy( QSizePolicy( QSizePolicy::Expanding,QSizePolicy::Preferred) ); connect(mCompleteDateEdit,SIGNAL(setTimeTo(QTime)),mCompleteTimeEdit,SLOT(setTime(QTime))); if ( QApplication::desktop()->width() <= 480 ) { if ( QApplication::desktop()->width() < 320 ) mCompleteDateEdit->setMaximumWidth( 85 ); else mCompleteDateEdit->setMaximumWidth( 140 ); topLayout->setSpacing( 0 ); } } void KOEditorGeneralTodo::initPriority(QWidget *parent, QBoxLayout *topLayout) { QHBox* h = new QHBox ( parent ); topLayout->addWidget( h ); QLabel *priorityLabel = new QLabel(i18n("Priority:"), h); // topLayout->addWidget(priorityLabel); mPriorityCombo = new QComboBox( h ); mPriorityCombo->insertItem(i18n("1 (high)")); mPriorityCombo->insertItem(i18n("2")); mPriorityCombo->insertItem(i18n("3")); mPriorityCombo->insertItem(i18n("4")); diff --git a/korganizer/koeventeditor.cpp b/korganizer/koeventeditor.cpp index 75dae34..9ede543 100644 --- a/korganizer/koeventeditor.cpp +++ b/korganizer/koeventeditor.cpp @@ -15,228 +15,234 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #include <qtooltip.h> #include <qframe.h> #include <qpixmap.h> #include <qhbox.h> #include <qdir.h> #include <qlayout.h> #include <qwidgetstack.h> #include <qapplication.h> #include <kiconloader.h> #include <kstandarddirs.h> #include <kdebug.h> #include <klocale.h> #include <kfiledialog.h> #include <kmessagebox.h> #include <libkcal/calendarresources.h> #include <libkcal/resourcecalendar.h> #include <kresources/resourceselectdialog.h> #include <libkdepim/categoryselectdialog.h> #include <libkcal/calendarlocal.h> #include <libkcal/icalformat.h> #include "koprefs.h" #include "koeventeditor.h" extern int globalFlagBlockAgenda; KOEventEditor::KOEventEditor( Calendar *calendar, QWidget *parent ) : KOIncidenceEditor( i18n("Edit Event"), calendar, parent ) { mEvent = 0; init(); if ( QApplication::desktop()->height() <= 240 ) hideButtons(); } KOEventEditor::~KOEventEditor() { //emit dialogClose( mEvent ); } void KOEventEditor::init() { setupGeneral(); setupAttendeesTab(); setupRecurrence(); // Propagate date time settings to recurrence tab connect(mGeneral,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), mRecurrence,SLOT(setDefaultsDates(QDateTime,QDateTime))); connect(mGeneral,SIGNAL(dateTimeStrChanged(const QString &)), mRecurrence,SLOT(setDateTimeStr(const QString &))); // Category dialog // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); //connect(mCategoryDialog,SIGNAL(categoriesSelected(const QString &)), // mGeneral,SLOT(setCategories(const QString &))); } void KOEventEditor::reload() { if ( mEvent ) readEvent( mEvent ); } void KOEventEditor::setSecrecy( int sec ) { mGeneral->setSecrecy( sec ); } void KOEventEditor::setCategories( QString s ) { mGeneral->setCategories(s); } void KOEventEditor::setupGeneral() { mGeneral = new KOEditorGeneralEvent( this, "KOEditorGeneralEvent" ); connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); if( KOPrefs::instance()->mCompactDialogs ) { QFrame *topFrame = addPage(i18n("General")); QBoxLayout *topLayout = new QVBoxLayout(topFrame); topLayout->setSpacing(spacingHint()-1); topLayout->setMargin(marginHint()-1); + topLayout->addStretch ( 1 ); mGeneral->initHeader(topFrame,topLayout); + topLayout->addStretch ( 1 ); mGeneral->initTime(topFrame,topLayout); + topLayout->addStretch ( 1 ); // QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); mGeneral->initAlarm(topFrame,topLayout); + topLayout->addStretch ( 1 ); mGeneral->enableAlarm( false ); QBoxLayout *buttonLayout; if ( QApplication::desktop()->width() < 500 && QApplication::desktop()->height() > 240 ) buttonLayout = new QVBoxLayout( topLayout ); else buttonLayout = new QHBoxLayout( topLayout ); QHBox* buttonWidget = new QHBox (topFrame); QIconSet icon; if ( QApplication::desktop()->width() < 321 ) icon = SmallIcon("fileexport16"); else icon = SmallIcon("fileexport"); QPushButton * loadTemplate = new QPushButton( buttonWidget); QPushButton * saveTemplate = new QPushButton( buttonWidget); saveTemplate->setIconSet (icon ) ; int size = saveTemplate->sizeHint().height(); saveTemplate->setFixedSize( size, size ); if ( QApplication::desktop()->width() < 321 ) icon = SmallIcon("fileimport16"); else icon = SmallIcon("fileimport"); loadTemplate->setIconSet (icon ) ; loadTemplate->setFixedSize( size, size ); buttonLayout->addWidget( buttonWidget ); mGeneral->initCategories( topFrame, buttonLayout ); topLayout->addStretch( 1 ); QFrame *topFrame2 = addPage(i18n("Details")); QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); + topLayout2->setSpacing(spacingHint()-1); + topLayout2->setMargin(marginHint()-1); topLayout2->setSpacing(spacingHint()); mGeneral->initClass(topFrame2,topLayout2); mGeneral->initSecrecy( topFrame2, topLayout2 ); mGeneral->initDescription(topFrame2,topLayout2); connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); } else { QFrame *topFrame = addPage(i18n("General")); QBoxLayout *topLayout = new QVBoxLayout(topFrame); topLayout->setSpacing(spacingHint()); mGeneral->initHeader(topFrame,topLayout); mGeneral->initTime(topFrame,topLayout); QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); mGeneral->initAlarm(topFrame,alarmLineLayout); mGeneral->initClass(topFrame,alarmLineLayout); mGeneral->initDescription(topFrame,topLayout); QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); mGeneral->initCategories( topFrame, detailsLayout ); mGeneral->initSecrecy( topFrame, detailsLayout ); } mGeneral->finishSetup(); } void KOEventEditor::setupRecurrence() { QFrame *topFrame = addPage( i18n("Recurrence") ); QBoxLayout *topLayout = new QVBoxLayout( topFrame ); mRecurrence = new KOEditorRecurrence( topFrame ); topLayout->addWidget( mRecurrence ); } void KOEventEditor::editEvent(Event *event, bool showDescription) { // init(); mEvent = event; readEvent(mEvent); if ( showDescription ) { showPage( 1 ); mGeneral->setFocusOn( 1 ); } else { showPage( 0 ); mGeneral->setFocusOn( 2 ); } } void KOEventEditor::newEvent( QDateTime from, QDateTime to, bool allDay ) { // init(); mEvent = 0; setDefaults(from,to,allDay); } void KOEventEditor::loadDefaults() { int fmt = KOPrefs::instance()->mStartTime; QDateTime from(QDate::currentDate(), QTime(fmt,0,0)); QDateTime to(QDate::currentDate(), QTime(fmt+KOPrefs::instance()->mDefaultDuration,0,0)); setDefaults(from,to,false); } bool KOEventEditor::processInput( bool emitTime ) { if (!validateInput()) return false; Event *event = 0; if (mEvent) event = mEvent; else { event = new Event; event->setOrganizer(KOPrefs::instance()->email()); } writeEvent(event); if ( emitTime ) { globalFlagBlockAgenda = 1; emit showAgendaView( false ); emit jumpToTime( event->dtStart().date() ); globalFlagBlockAgenda = 2; } if (mEvent) { event->setRevision(event->revision()+1); emit eventChanged(event); } else { diff --git a/korganizer/koincidenceeditor.cpp b/korganizer/koincidenceeditor.cpp index 9813a80..9bc0302 100644 --- a/korganizer/koincidenceeditor.cpp +++ b/korganizer/koincidenceeditor.cpp @@ -1,185 +1,185 @@ /* This file is part of KOrganizer. Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #include <qtooltip.h> #include <qframe.h> #include <qpixmap.h> #include <qlayout.h> #include <qwidgetstack.h> #include <qdatetime.h> #include <qdir.h> #include <kdebug.h> #include <klocale.h> #include <kstandarddirs.h> #include <kmessagebox.h> #include <kfiledialog.h> #include <libkdepim/categoryselectdialog.h> #include <libkdepim/kinputdialog.h> #include <libkcal/calendarlocal.h> #include <libkcal/icalformat.h> #include "koprefs.h" #include "koincidenceeditor.h" KOIncidenceEditor::KOIncidenceEditor( const QString &caption, Calendar *calendar, QWidget *parent ) : KDialogBase( Tabbed, caption, Ok | Apply | Cancel |/* Default | */User1, Ok, parent, caption, true, false ), mSaveTemplateDialog( 0 ) { mCalendar = calendar; setButtonText( Default, i18n("Template...") ); QString saveTemplateText; // if ( KOPrefs::instance()->mCompactDialogs ) { // showButton( User1, false ); // showButton( Apply, false ); // } else { showButton( Apply, false ); saveTemplateText = i18n("Ok+Agenda"); // } setButtonText( User1, saveTemplateText ); //mCategoryDialog = new KPIM::CategorySelectDialog( KOPrefs::instance(), this ); // KOGlobals::fitDialogToScreen( mCategoryDialog ); //connect(mCategoryDialog,SIGNAL(editCategories()),SIGNAL(editCategories())); //connect( this, SIGNAL( defaultClicked() ), SLOT( slotLoadTemplate() ) ); // connect( this, SIGNAL( user1Clicked() ), SLOT( slotSaveTemplate() ) ); connect( this, SIGNAL( user1Clicked() ), SLOT( slotShowIncidence() ) ); } KOIncidenceEditor::~KOIncidenceEditor() { //delete mCategoryDialog; } void KOIncidenceEditor::setupAttendeesTab() { QFrame *topFrame = addPage(i18n("Attendees")); QBoxLayout *topLayout = new QVBoxLayout(topFrame); - mDetails = new KOEditorDetails(spacingHint(),topFrame); + mDetails = new KOEditorDetails(spacingHint()-2,topFrame); topLayout->addWidget(mDetails); } void KOIncidenceEditor::slotApply() { processInput( false ); } void KOIncidenceEditor::accept() { slotOk(); } void KOIncidenceEditor::slotOk() { if ( processInput( false ) ) QDialog::accept(); } void KOIncidenceEditor::updateCategoryConfig() { qDebug("KOIncidenceEditor::updateCategoryConfig() is dead! "); //mCategoryDialog->updateCategoryConfig(); } void KOIncidenceEditor::slotCancel() { reject(); } void KOIncidenceEditor::slotLoadTemplate() { kdDebug() << "KOIncidenceEditor::loadTemplate()" << endl; } void KOIncidenceEditor::slotShowIncidence() { if ( processInput(true ) ) { accept(); } } void KOIncidenceEditor::slotSaveTemplate() { kdDebug() << "KOIncidenceEditor::saveTemplate()" << endl; } void KOIncidenceEditor::createSaveTemplateDialog( SaveTemplateDialog::IncidenceType type ) { if ( !mSaveTemplateDialog ) { mSaveTemplateDialog = new SaveTemplateDialog( type, this ); connect( mSaveTemplateDialog, SIGNAL( templateSelected( const QString & ) ), SLOT( saveTemplate( const QString & ) ) ); } mSaveTemplateDialog->show(); mSaveTemplateDialog->raise(); } void KOIncidenceEditor::saveAsTemplate( Incidence *incidence, const QString &templateName ) { CalendarLocal cal; cal.addIncidence( incidence ); ICalFormat format; format.save( &cal, templateName ); } QString KOIncidenceEditor::loadTemplate( Calendar *cal, const QString &type, const QStringList &templates ) { // bool ok = false; // QString templateName = KInputDialog::getItem( i18n("Load Template"), // i18n("Select a template to load:"), templates, 0, &ok ); // if ( !ok || templateName.isEmpty() ) return QString::null; // QString fileName = locateLocal( "data", "korganizer/templates/" + type + "/" + // templateName ); // fn =KFileDialog:: getOpenFileName( fn, "Import filename(*.ics/*.vcs)", this ); // QString fileName;// =locateLocal( "templates", incidence->type() ); // fileName=KFileDialog:: getOpenFileName( fileName, "Load "+incidence()->type(), this ); // if ( fileNamelength() == 0) // return QString::null; // if ( fileName.isEmpty() ) { // KMessageBox::error( this, i18n("Unable to find template '%1'.") // .arg( fileName ) ); // return QString::null; // } else { // ICalFormat format; // if ( !format.load( cal, fileName ) ) { // KMessageBox::error( this, i18n("Error loading template file '%1'.") // .arg( fileName ) ); // return QString::null; // } // } return ""; } diff --git a/korganizer/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp index 8b90ae5..555c1b1 100644 --- a/korganizer/kotodoeditor.cpp +++ b/korganizer/kotodoeditor.cpp @@ -27,195 +27,199 @@ #include <qpixmap.h> #include <qlayout.h> #include <qhbox.h> #include <qdir.h> #include <qdatetime.h> #include <qapplication.h> #include <qtabwidget.h> #include <kiconloader.h> #include <klocale.h> #include <kfiledialog.h> #include <kstandarddirs.h> #include <kmessagebox.h> #include <libkdepim/categoryselectdialog.h> #include <libkcal/calendarlocal.h> #include <libkcal/calendarresources.h> #include <libkcal/resourcecalendar.h> #include <libkcal/icalformat.h> #include <kresources/resourceselectdialog.h> #include <libkdepim/kdateedit.h> #include "koprefs.h" #include "kolocationbox.h" #include "kotodoeditor.h" extern int globalFlagBlockAgenda; KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) : KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent ) { mTodo = 0; mRelatedTodo = 0; findButton(User1)->hide(); init(); if ( QApplication::desktop()->height() <= 240 ) hideButtons(); } KOTodoEditor::~KOTodoEditor() { emit dialogClose( mTodo ); } void KOTodoEditor::init() { setupGeneral(); setupAttendeesTab(); setupRecurrence(); connect(mGeneral,SIGNAL(datesChecked()),this ,SLOT(checkRecurrence())); mRecurrence->setDateTimeStr( i18n("<i>The recurrence is computed from the start datetime!</i>") ); connect(mGeneral,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), mRecurrence,SLOT(setDefaultsDates(QDateTime,QDateTime))); } void KOTodoEditor::setupRecurrence() { QFrame *topFrame = addPage( i18n("Recurrence") ); QBoxLayout *topLayout = new QVBoxLayout( topFrame ); mRecurrence = new KOEditorRecurrence( topFrame ); topLayout->addWidget( mRecurrence ); } void KOTodoEditor::setCategories( QString s ) { mGeneral->setCategories(s); } void KOTodoEditor::setSecrecy( int sec ) { mGeneral->setSecrecy( sec ); } void KOTodoEditor::reload() { if ( mTodo ) readTodo( mTodo ); } void KOTodoEditor::setupGeneral() { mGeneral = new KOEditorGeneralTodo(this); connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)), // mGeneral,SLOT(setCategories(const QString &))); if (KOPrefs::instance()->mCompactDialogs) { QFrame *topFrame = addPage(i18n("General")); QBoxLayout *topLayout = new QVBoxLayout(topFrame); if ( QApplication::desktop()->width() < 480 ) { topLayout->setMargin(marginHintSmall()); topLayout->setSpacing(spacingHintSmall()); } else { topLayout->setMargin(marginHint()); topLayout->setSpacing(spacingHint()); } + topLayout->addStretch( 1 ); mGeneral->initHeader(topFrame,topLayout); + topLayout->addStretch( 1 ); mGeneral->initTime(topFrame,topLayout); + topLayout->addStretch( 1 ); mGeneral->initAlarm(topFrame,topLayout); + topLayout->addStretch( 1 ); mGeneral->enableAlarm( false ); QBoxLayout *priorityLayout; if ( QApplication::desktop()->width() < 500 ) priorityLayout = new QVBoxLayout( topLayout ); else priorityLayout = new QHBoxLayout( topLayout ); QWidget* prioWidget = new QWidget (topFrame); priorityLayout->addWidget( prioWidget ); QHBoxLayout* priorityLayout2 = new QHBoxLayout( prioWidget); QIconSet icon; if ( QApplication::desktop()->width() < 321 ) icon = SmallIcon("fileimport16"); else icon = SmallIcon("fileimport"); QPushButton * loadTemplate = new QPushButton( prioWidget); loadTemplate->setIconSet (icon ) ; int size = loadTemplate->sizeHint().height(); loadTemplate->setFixedSize( size, size ); if ( QApplication::desktop()->width() < 321 ) icon = SmallIcon("fileexport16"); else icon = SmallIcon("fileexport"); QPushButton * saveTemplate = new QPushButton( prioWidget); saveTemplate->setIconSet (icon ) ; saveTemplate->setFixedSize( size, size ); priorityLayout2->addWidget(loadTemplate); priorityLayout2->addWidget(saveTemplate); mGeneral->initPriority(prioWidget,priorityLayout2); mGeneral->initCategories( topFrame, priorityLayout ); topLayout->addStretch(1); QFrame *topFrame2 = addPage(i18n("Details")); QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); topLayout2->setMargin(marginHint()); topLayout2->setSpacing(spacingHint()); QHBoxLayout *completionLayout = new QHBoxLayout( topLayout2 ); mGeneral->initCompletion(topFrame2,completionLayout); mGeneral->initSecrecy( topFrame2, topLayout2 ); mGeneral->initDescription(topFrame2,topLayout2); // QHBox * hb = new QHBox ( topFrame2 ); // topLayout2->addWidget(hb); // hb->setSpacing( 3 ); connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); } else { QFrame *topFrame = addPage(i18n("General")); QBoxLayout *topLayout = new QVBoxLayout(topFrame); topLayout->setSpacing(spacingHint()); mGeneral->initHeader(topFrame,topLayout); mGeneral->initTime(topFrame,topLayout); mGeneral->initStatus(topFrame,topLayout); QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); mGeneral->initAlarm(topFrame,alarmLineLayout); mGeneral->initDescription(topFrame,topLayout); QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); mGeneral->initCategories( topFrame, detailsLayout ); mGeneral->initSecrecy( topFrame, detailsLayout ); } mGeneral->finishSetup(); } void KOTodoEditor::editTodo(Todo *todo, bool editDescription) { //init(); mTodo = todo; readTodo(mTodo); if ( editDescription ) { showPage( 1 ); mGeneral->setFocusOn( 1 ); } else { showPage( 0 ); mGeneral->setFocusOn( 2 ); } checkRecurrence(); } void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay) { //init(); |