-rw-r--r-- | korganizer/calendarview.cpp | 19 | ||||
-rw-r--r-- | korganizer/koagendaview.cpp | 4 | ||||
-rw-r--r-- | korganizer/koeditorgeneral.cpp | 35 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 11 | ||||
-rw-r--r-- | korganizer/kotodoview.h | 1 |
5 files changed, 45 insertions, 25 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index beb19d9..76cce26 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -501,64 +501,69 @@ CalendarView::~CalendarView() delete mDialogManager; delete mViewManager; delete mStorage; delete mDateFrame ; delete beamDialog; delete mEventViewerDialog; //kdDebug() << "~CalendarView() done" << endl; } 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 ) { QString mess = msg; QString mAlarmMessage = mess.mid( 9 ); QString filename = MainWindow::resourcePath(); filename += "koalarm.wav"; QString tempfilename; if ( mess.left( 13 ) == "suspend_alarm") { bool error = false; int len = mess.mid( 13 ).find("+++"); if ( len < 2 ) error = true; else { tempfilename = mess.mid( 13, len ); if ( !QFile::exists( tempfilename ) ) error = true; } if ( ! error ) { filename = tempfilename; } mAlarmMessage = mess.mid( 13+len+3 ); @@ -4065,53 +4070,63 @@ void CalendarView::resetFocus() if ( mDialogManager->getSearchDialog()->isVisible() ){ mDialogManager->getSearchDialog()->raise(); mDialogManager->getSearchDialog()->setActiveWindow(); mDialogManager->getSearchDialog()->listview()->resetFocus(); } else mViewerCallerIsSearchDialog = false; } if ( !mViewerCallerIsSearchDialog ) { //mViewManager->currentView()->setFocus(); //qDebug("sssssssssssssssset focus "); topLevelWidget()->raise(); setActiveWindow(); //setFocus(); } mViewerCallerIsSearchDialog = false; } void CalendarView::showNextAlarms() { QString message; QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { QString sum = mCalendar->nextSummary(); QDateTime nextA = mNextAlarmDateTime; QDateTime cur = QDateTime::currentDateTime(); int secs = cur.secsTo( nextA ); int min = secs /60; int hours = min /60; min = min % 60; int days = hours /24; hours = hours % 24; - message = i18n("The next alarm is in:\n"); + //message = i18n("The next alarm is in:\n"); if ( days > 1 ) message += i18n("%1 days\n").arg( days ); else if ( days == 1 ) message += i18n("1 day\n"); if ( hours > 1 ) message += i18n("%1 hours\n").arg( hours ); else if ( hours == 1 ) message += i18n("1 hour\n"); if ( min > 1 ) message += i18n("%1 minutes\n").arg( min ); else if ( min == 1 ) message += i18n("1 minute\n"); - + if ( message.isEmpty() ) + message = i18n("The next alarm is in\nless than one minute!"); + else + message = i18n("The next alarm is in:\n") + message; message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; } else { message = i18n("There is no next alarm."); } +#ifdef DESKTOP_VERSION + if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { + message += i18n("\nThe internal alarm notification is disabled!\n"); + message += i18n("Enable it in the settings menu, TAB alarm."); + } + +#endif KMessageBox::information( this, message); } diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index d450a97..6d1e6d5 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp @@ -124,127 +124,127 @@ void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) p->setFont( font()); if (!KGlobal::locale()->use12Clock()) { suffix = "00"; } else if (cell > 11) suffix = "pm"; if ( timeHeight > mCellHeight ) { timeHeight = mCellHeight-1; int pointS = nFont.pointSize(); while ( pointS > 4 ) { nFont.setPointSize( pointS ); fm = QFontMetrics( nFont ); if ( fm.ascent() < mCellHeight ) break; -- pointS; } fm = QFontMetrics( nFont ); timeHeight = fm.ascent(); } //timeHeight -= (timeHeight/4-2); QFont sFont = nFont; sFont.setPointSize( sFont.pointSize()/2 ); QFontMetrics fmS( sFont ); int sHei = fmS.ascent() ; //sHei -= (sHei/4-2); int startW = mMiniWidth - frameWidth()-2 ; int tw2 = fmS.width(suffix); timeHeight = (timeHeight-1) /2 -1; //testline //p->drawLine(0,0,0,contentsHeight()); while (y < cy + ch+mCellHeight) { - p->drawLine(startW-tw2 ,y,cw+2,y); + p->drawLine(startW-tw2+1 ,y,cw+2,y); hour.setNum(cell); // handle 24h and am/pm time formats if (KGlobal::locale()->use12Clock()) { if (cell == 12) suffix = "pm"; if (cell == 0) hour.setNum(12); if (cell > 12) hour.setNum(cell - 12); } // center and draw the time label int timeWidth = fm.width(hour); int offset = startW - timeWidth - tw2 -1 ; p->setFont( nFont ); p->drawText( offset, y+ timeHeight, hour); p->setFont( sFont ); offset = startW - tw2; p->drawText( offset, y -1, suffix); // increment indices y += mCellHeight; cell++; } } /** Calculates the minimum width. */ int TimeLabels::minimumWidth() const { return mMiniWidth; } /** updates widget's internal state */ void TimeLabels::updateConfig() { mRedrawNeeded = true; // set the font // config->setGroup("Fonts"); // QFont font = config->readFontEntry("TimeBar Font"); setFont(KOPrefs::instance()->mTimeBarFont); QString test = "20"; if (KGlobal::locale()->use12Clock()) test = "12"; mMiniWidth = fontMetrics().width(test); if (KGlobal::locale()->use12Clock()) test = "pm"; else { test = "00"; } QFont sFont = font(); sFont.setPointSize( sFont.pointSize()/2 ); QFontMetrics fmS( sFont ); mMiniWidth += fmS.width( test ) + frameWidth()*2+4 ; // update geometry restrictions based on new settings setFixedWidth( mMiniWidth ); // update HourSize mCellHeight = KOPrefs::instance()->mHourSize*4; - resizeContents(50,mRows * mCellHeight); + resizeContents(mMiniWidth,mRows * mCellHeight+1); } /** update time label positions */ void TimeLabels::positionChanged() { int adjustment = mAgenda->contentsY(); setContentsPos(0, adjustment); } /** */ void TimeLabels::setAgenda(KOAgenda* agenda) { mAgenda = agenda; } void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) { mMouseDownY = e->pos().y(); mOrgCap = topLevelWidget()->caption(); } void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) { int diff = mMouseDownY - e->pos().y(); if ( diff < 10 && diff > -10 ) return; int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; if ( tSize < 4 ) tSize = 4; if ( tSize > 22 ) tSize = 22; tSize = (tSize-2)/2; diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp index b14ca43..abc80d4 100644 --- a/korganizer/koeditorgeneral.cpp +++ b/korganizer/koeditorgeneral.cpp @@ -198,117 +198,114 @@ void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) 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() ); - //QString prefix = mAlarmSound; - if (!mAlarmSoundButton->isOn()) { - mAlarmSoundButton->setOn(true); - ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); - } else { + + bool oldState = mAlarmSoundButton->isOn(); + QString fileName(KFileDialog::getOpenFileName(mAlarmSound, i18n("*.wav|Wav Files"), 0)); if (!fileName.isEmpty()) { mAlarmSound = fileName; QToolTip::remove(mAlarmSoundButton); QString dispStr = i18n("Playing '%1'").arg(fileName); QToolTip::add(mAlarmSoundButton, dispStr); mAlarmProgramButton->setOn(false); mAlarmSoundButton->setOn(true); + QToolTip::add(mAlarmProgramButton, i18n("No program set")); } else { - mAlarmProgramButton->setOn(true); - mAlarmSoundButton->setOn(false); + mAlarmProgramButton->setOn(oldState); + mAlarmSoundButton->setOn(!oldState); + } - } -#if 0 + if (mAlarmProgramButton->isOn()) ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); if ( mAlarmSoundButton->isOn()) ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); -#endif + } void KOEditorGeneral::pickAlarmProgram() { - if (!mAlarmProgramButton->isOn()) { - mAlarmProgramButton->setOn(true); - ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); - } else { + bool oldState = mAlarmProgramButton->isOn(); + QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0)); if (!fileName.isEmpty()) { mAlarmProgram = fileName; QToolTip::remove(mAlarmProgramButton); QString dispStr = i18n("Running '%1'").arg(fileName); QToolTip::add(mAlarmProgramButton, dispStr); mAlarmSoundButton->setOn(false); mAlarmProgramButton->setOn(true); + QToolTip::add(mAlarmSoundButton, i18n("No sound set")); } else { - mAlarmProgramButton->setOn(false); - mAlarmSoundButton->setOn(true); - } + mAlarmProgramButton->setOn(!oldState); + mAlarmSoundButton->setOn(oldState); } -#if 0 + if (mAlarmProgramButton->isOn()) ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); if ( mAlarmSoundButton->isOn()) ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); -#endif + } QString KOEditorGeneral::getFittingPath( const QString s ) { int maxlen = 50; if ( QApplication::desktop()->width() < 640 ) { if ( QApplication::desktop()->width() < 320 ) maxlen = 22; else maxlen = 35; } if ( s.length() > maxlen ) { return "..."+s.right(maxlen -3); } return s; } void KOEditorGeneral::enableAlarmEdit(bool enable) { if ( enable ) { if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { mAlarmSoundButton->setOn( true ); if ( mAlarmSound.isEmpty() ) mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; else { if ( ! QFile::exists( mAlarmSound ) ) mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; } } } ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage); diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 01cf0ff..395325c 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp @@ -175,90 +175,96 @@ void KOTodoListView::contentsDropEvent(QDropEvent *e) unparentTodoSignal(existingTodo); delete todo; } else { mCalendar->addTodo(todo); emit todoDropped(todo, KOGlobals::EVENTADDED); if ( destinationEvent ) reparentTodoSignal( destinationEvent, todo ); } } else { QString text; if (QTextDrag::decode(e,text)) { //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); qDebug("Dropped : " + text); QStringList emails = QStringList::split(",",text); for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { int pos = (*it).find("<"); QString name = (*it).left(pos); QString email = (*it).mid(pos); if (!email.isEmpty() && todoi) { todoi->todo()->addAttendee(new Attendee(name,email)); } } } else { qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); e->ignore(); } } #endif } +void KOTodoListView::wheelEvent (QWheelEvent *e) +{ + QListView::wheelEvent (e); +} void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) { QPoint p(contentsToViewport(e->pos())); QListViewItem *i = itemAt(p); bool rootClicked = true; if (i) { // if the user clicked into the root decoration of the item, don't // try to start a drag! int X = p.x(); //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); if (X > header()->sectionPos(0) + treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + itemMargin() +i->height()|| X < header()->sectionPos(0)) { rootClicked = false; } } else { rootClicked = false; } #ifndef KORG_NODND mMousePressed = false; - if (! rootClicked ) { + if (! rootClicked && !( e->button() == RightButton) ) { mPressPos = e->pos(); mMousePressed = true; + } else { + mMousePressed = false; } #endif //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); #ifndef DESKTOP_VERSION if (!( e->button() == RightButton && rootClicked) ) QListView::contentsMousePressEvent(e); #else QListView::contentsMousePressEvent(e); #endif } void KOTodoListView::paintEvent(QPaintEvent* e) { emit paintNeeded(); QListView::paintEvent( e); } void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) { #ifndef KORG_NODND //QListView::contentsMouseMoveEvent(e); if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > QApplication::startDragDistance()*3) { mMousePressed = false; QListViewItem *item = itemAt(contentsToViewport(mPressPos)); if (item) { DndFactory factory( mCalendar ); ICalDrag *vd = factory.createDrag( ((KOTodoViewItem *)item)->todo(),viewport()); internalDrop = false; // we cannot do any senseful here, because the DnD is still broken in Qt if (vd->drag()) { if ( !internalDrop ) { @@ -1053,65 +1059,65 @@ void KOTodoView::changedCategories(int index) if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { QStringList categories = mActiveItem->todo()->categories (); QString colcat = categories.first(); if (categories.find (mCategory[index]) != categories.end ()) categories.remove (mCategory[index]); else categories.insert (categories.end(), mCategory[index]); categories.sort (); if ( !colcat.isEmpty() ) { if ( categories.find ( colcat ) != categories.end () ) { categories.remove( colcat ); categories.prepend( colcat ); } } mActiveItem->todo()->setCategories (categories); mActiveItem->construct(); mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); } } void KOTodoView::itemDoubleClicked(QListViewItem *item) { if ( pendingSubtodo != 0 ) { topLevelWidget()->setCaption(i18n("Reparenting aborted!")); } pendingSubtodo = 0; int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); //qDebug("ROW %d ", row); if (!item) { newTodo(); return; } else { - if ( row == 1 ) { + if ( row == 1 || row == 2 ) { mActiveItem = (KOTodoViewItem *) item; newSubTodo(); return; } } if ( KOPrefs::instance()->mEditOnDoubleClick ) editItem( item ); else showItem( item , QPoint(), 0 ); } void KOTodoView::itemClicked(QListViewItem *item) { //qDebug("KOTodoView::itemClicked %d", item); if (!item) { if ( pendingSubtodo != 0 ) { topLevelWidget()->setCaption(i18n("Reparenting aborted!")); } pendingSubtodo = 0; return; } KOTodoViewItem *todoItem = (KOTodoViewItem *)item; if ( pendingSubtodo != 0 ) { bool allowReparent = true; QListViewItem *par = item; while ( par ) { if ( par == pendingSubtodo ) { allowReparent = false; break; } par = par->parent(); } if ( !allowReparent ) { @@ -1242,64 +1248,65 @@ void KOTodoView::displayAllFlat() return; } mPopupMenu->setItemChecked( 8,true ); isFlatDisplay = true; QPtrList<Todo> todoList = calendar()->todos(); mTodoMap.clear(); mTodoListView->clear(); Todo *todo; for(todo = todoList.first(); todo; todo = todoList.next()) { KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); mTodoMap.insert(todo,todoItem); } mTodoListView->setFocus(); processSelectionChange(); } void KOTodoView::setAllFlat() { if ( isFlatDisplay ) { isFlatDisplay = false; mPopupMenu->setItemChecked( 8,false ); updateView(); return; } storeCurrentItem(); displayAllFlat(); resetCurrentItem(); } void KOTodoView::purgeCompleted() { emit purgeCompletedSignal(); + } void KOTodoView::toggleQuickTodo() { if ( mQuickAdd->isVisible() ) { mQuickAdd->hide(); KOPrefs::instance()->mEnableQuickTodo = false; } else { mQuickAdd->show(); KOPrefs::instance()->mEnableQuickTodo = true; } mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); } void KOTodoView::toggleRunning() { KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); updateView(); } void KOTodoView::toggleCompleted() { KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); updateView(); } void KOTodoView::addQuickTodo() diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h index e553d0e..39976cf 100644 --- a/korganizer/kotodoview.h +++ b/korganizer/kotodoview.h @@ -39,64 +39,65 @@ #include <libkcal/todo.h> #include <korganizer/baseview.h> #include "kotodoviewitem.h" #include "koprefs.h" #include "koglobals.h" #include "datenavigator.h" class QDragEnterEvent; class QDragMoveEvent; class QDragLeaveEvent; class QDropEvent; class KOTodoViewWhatsThis; class DocPrefs; class KOTodoListView : public KListView { Q_OBJECT public: KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0); virtual ~KOTodoListView() {} signals: void paintNeeded(); void todoDropped(Todo *, int); void double_Clicked(QListViewItem *item); void reparentTodoSignal( Todo *,Todo * ); void unparentTodoSignal(Todo *); void deleteTodo( Todo * ); protected: + void wheelEvent (QWheelEvent *e); void contentsDragEnterEvent(QDragEnterEvent *); void contentsDragMoveEvent(QDragMoveEvent *); void contentsDragLeaveEvent(QDragLeaveEvent *); void contentsDropEvent(QDropEvent *); void contentsMousePressEvent(QMouseEvent *); void contentsMouseMoveEvent(QMouseEvent *); void contentsMouseReleaseEvent(QMouseEvent *); void contentsMouseDoubleClickEvent(QMouseEvent *); private: void paintEvent(QPaintEvent * pevent); bool internalDrop; QString mName; Calendar *mCalendar; QPoint mPressPos; bool mMousePressed; QListViewItem *mOldCurrent; bool mFlagKeyPressed; void keyPressEvent ( QKeyEvent * ) ; void keyReleaseEvent ( QKeyEvent * ) ; }; /** This is the line-edit on top of the todoview for fast addition of new todos */ class KOQuickTodo : public QLineEdit { public: KOQuickTodo(QWidget *parent=0); protected: |