-rw-r--r-- | korganizer/journalentry.cpp | 2 | ||||
-rw-r--r-- | korganizer/koagenda.cpp | 6 | ||||
-rw-r--r-- | korganizer/koagenda.h | 2 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 4 |
4 files changed, 10 insertions, 4 deletions
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp index 5fc3f2f..7f6f221 100644 --- a/korganizer/journalentry.cpp +++ b/korganizer/journalentry.cpp @@ -190,128 +190,130 @@ void JournalEntry::slotSaveTemplate() // QString text; QTextStream tsIn( &fileIn ); tsIn.setCodec( QTextCodec::codecForName("utf8") ); tsIn << mEditor->text(); fileIn.close(); } void JournalEntry::slotLoadTemplate() { QString fileName =locateLocal( "templates", "journals" ); QDir t_dir; if ( !t_dir.exists(fileName) ) t_dir.mkdir ( fileName ); fileName += "/journal"; fileName = KFileDialog::getOpenFileName( fileName , i18n("Insert Journal template"), this ); if ( fileName.length() == 0 ) return; QFile fileIn( fileName ); if (!fileIn.open( IO_ReadOnly ) ) { KMessageBox::error( this, i18n("Error loading template file\n '%1'.") .arg( fileName ) ); return; } QTextStream tsIn( &fileIn ); tsIn.setCodec( QTextCodec::codecForName("utf8") ); QString text = tsIn.read(); fileIn.close(); int line, col; mEditor->getCursorPosition (& line, & col ); mEditor-> insertAt ( text, line, col, true ); //mEditor->setIgnoreMark( true ); } void JournalEntry::setDate(const QDate &date) { showOnlyMode = false; writeJournal(); mDate = date; fillCalendar( mCalendar->defaultCalendar() ); } void JournalEntry::fillCalendar( int setToID ) { mCalendarBox->clear(); KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); int std = 0; int count = 0; while ( kkf ) { if ( (!kkf->mErrorOnLoad &&! kkf->isReadOnly) || setToID == kkf->mCalNumber ) { if ( setToID ) { if ( kkf->mCalNumber == setToID ) std = count; } else { if ( kkf->isStandard ) { std = count; } } ++count; mCalendarBox->insertItem( kkf->mName ); } kkf = KOPrefs::instance()->mCalendars.next(); } mCalendarBox->setCurrentItem( std ); } void JournalEntry::toggleShowJournal() { + if ( mEditor->text().isEmpty() && mTitle->currentText ().isEmpty() ) + return; if (!mEditor->text().isEmpty() || !mTitle->currentText ().isEmpty()) flushEntry(); if ( showOnlyMode ) emit showJournalOnly( 0 ); else { // we have to protect mJournal from deleting if mJournal has empty text visibleMode = false; // set to true via :setShowOnly() emit showJournalOnly( mJournal ); //QTimer::singleShot( 0, this, SLOT( setVisibleOn() ) ); } } void JournalEntry::setVisibleOn() { visibleMode = true; } void JournalEntry::setShowOnly() { showOnlyMode = true; if ( mTitle->currentText().isEmpty() ) mTitle->setFocus(); else mEditor->setFocus(); } void JournalEntry::setJournal(Journal *journal, bool saveJournal ) { if ( saveJournal ) writeJournal(); mTitle->load( KOLocationBox::SUMMARYJOURNAL ); mJournal = journal; if ( journal->isReadOnly() ) mTitle->lineEdit ()->setText(mJournal->summary()+" ("+i18n("readonly")+")"); else mTitle->lineEdit ()->setText(mJournal->summary()); mEditor->setText(mJournal->description()); mTitle->setEnabled (!journal->isReadOnly() ); mEditor->setReadOnly ( journal->isReadOnly() ); mCalendarBox->setEnabled (!journal->isReadOnly() ); fillCalendar( mJournal->calID() ); } Journal *JournalEntry::journal() const { return mJournal; } void JournalEntry::clear() { mJournal = 0; mEditor->setText(""); mTitle->load( KOLocationBox::SUMMARYJOURNAL ); mTitle->lineEdit ()->setText(""); } bool JournalEntry::eventFilter( QObject *o, QEvent *e ) { // kdDebug() << "JournalEntry::event received " << e->type() << endl; if ( e->type() == QEvent::FocusOut ) { writeJournal(); } if ( e->type() == QEvent::KeyPress ) { QKeyEvent * k = (QKeyEvent *) e; diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index c738f7e..7e9fa71 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp @@ -26,129 +26,132 @@ #ifndef _WIN32_ #define protected public #include <qwidget.h> #undef protected #endif #include <qintdict.h> #include <qdatetime.h> #include <qapplication.h> #include <qpopupmenu.h> #include <qcursor.h> #include <qpainter.h> #include <kdebug.h> #include <klocale.h> #include <kiconloader.h> #include <kglobal.h> #include "koagendaitem.h" #include "koprefs.h" #include "koglobals.h" #include "koagenda.h" #include <libkcal/event.h> #include <libkcal/todo.h> #ifndef DESKTOP_VERSION #include <qpe/qpeapplication.h> #endif //extern bool globalFlagBlockPainting; extern int globalFlagBlockAgenda; extern int globalFlagBlockAgendaItemPaint; extern int globalFlagBlockAgendaItemUpdate; extern int globalFlagBlockStartup; //////////////////////////////////////////////////////////////////////////// MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) : QFrame(_agenda->viewport(),name), agenda(_agenda) { setLineWidth(0); setMargin(0); setBackgroundColor(Qt::red); minutes = new QTimer(this); connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); minutes->start(0, true); mTimeBox = new QLabel(this); mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); QPalette pal = mTimeBox->palette(); pal.setColor(QColorGroup::Foreground, Qt::red); mTimeBox->setPalette(pal); //mTimeBox->setAutoMask(true); agenda->addChild(mTimeBox); oldToday = -1; } MarcusBains::~MarcusBains() { //delete minutes; } - +void MarcusBains::hideMe() +{ + hide(); mTimeBox->hide(); +} int MarcusBains::todayColumn() { QDate currentDate = QDate::currentDate(); DateList dateList = agenda->dateList(); DateList::ConstIterator it; int col = 0; for(it = dateList.begin(); it != dateList.end(); ++it) { if((*it) == currentDate) return KOGlobals::self()->reverseLayout() ? agenda->columns() - 1 - col : col; ++col; } return -1; } void MarcusBains::updateLoc() { updateLocation(); } void MarcusBains::updateLocation(bool recalculate) { QTime tim = QTime::currentTime(); //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); if((tim.hour() == 0) && (oldTime.hour()==23)) recalculate = true; int mins = tim.hour()*60 + tim.minute(); int minutesPerCell = 24 * 60 / agenda->rows(); int y = mins*agenda->gridSpacingY()/minutesPerCell; int today = recalculate ? todayColumn() : oldToday; int x = agenda->gridSpacingX()*today; bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); oldTime = tim; oldToday = today; if(disabled || (today<0)) { hide(); mTimeBox->hide(); return; } else { show(); mTimeBox->show(); } if(recalculate) setFixedSize(agenda->gridSpacingX(),1); agenda->moveChild(this, x, y); raise(); if(recalculate) //mTimeBox->setFont(QFont("helvetica",10)); mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); mTimeBox->adjustSize(); // the -2 below is there because there is a bug in this program // somewhere, where the last column of this widget is a few pixels // narrower than the other columns. int offs = (today==agenda->columns()-1) ? -4 : 0; agenda->moveChild(mTimeBox, x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, y-mTimeBox->height()); mTimeBox->raise(); @@ -311,128 +314,129 @@ void KOAgenda::init() SLOT(checkScrollBoundaries(int))); // Create the Marcus Bains line. if(mAllDayMode) mMarcusBains = 0; else { mMarcusBains = new MarcusBains(this); addChild(mMarcusBains); } mPopupKind = 0; mPopupItem = 0; mInvalidPixmap = false; } void KOAgenda::shrinkPixmap() { mPaintPixmap.resize( 20,20); mInvalidPixmap = true; } void KOAgenda::slotContentMove(int,int) { emit sendPing(); if ( mActionType == NOP ) slotClearSelection(); if ( mSelectedItem && !mActionItem ) { deselectItem(); emit incidenceSelected( 0 ); } } void KOAgenda::clear() { KOAgendaItem *item; for ( item=mItems.first(); item != 0; item=mItems.next() ) { mUnusedItems.append( item ); //item->hide(); } mItems.clear(); mSelectedItem = 0; clearSelection(); } void KOAgenda::clearSelection() { mSelectionCellX = 0; mSelectionYTop = 0; mSelectionHeight = 0; } void KOAgenda::marcus_bains() { if(mMarcusBains) mMarcusBains->updateLocation(true); } void KOAgenda::changeColumns(int columns) { if (columns == 0) { qDebug("KOAgenda::changeColumns() called with argument 0 "); return; } clear(); mColumns = columns; computeSizes(); + if(mMarcusBains) mMarcusBains->hideMe(); } /* This is the eventFilter function, which gets all events from the KOAgendaItems contained in the agenda. It has to handle moving and resizing for all items. */ bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) { // kdDebug() << "KOAgenda::eventFilter" << endl; switch(event->type()) { case QEvent::MouseButtonPress: case QEvent::MouseButtonDblClick: case QEvent::MouseButtonRelease: case QEvent::MouseMove: return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); case (QEvent::Leave): if (!mActionItem) setCursor(arrowCursor); return true; default: return QScrollView::eventFilter(object,event); } } void KOAgenda::popupMenu() { mPopupTimer->stop(); if ( mPopupKind == 1 || mPopupKind == 3 ) { if (mActionItem ) { endItemAction(); } mLeftMouseDown = false; // no more leftMouse computation if (mPopupItem) { //mClickedItem = mPopupItem; selectItem(mPopupItem); if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) mAllAgendaPopup->installEventFilter( this ); emit showIncidencePopupSignal(mPopupItem->incidence()); } } else if ( mPopupKind == 2 || mPopupKind == 4 ) { if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action endSelectAction( false ); // do not emit new event signal mLeftMouseDown = false; // no more leftMouse computation } if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) mNewItemPopup->installEventFilter( this ); mNewItemPopup->popup( mPopupPos); } mLeftMouseDown = false; mPopupItem = 0; mPopupKind = 0; } void KOAgenda::categoryChanged(Incidence * inc) { KOAgendaItem *item; for ( item=mItems.first(); item != 0; item=mItems.next() ) { if ( item->incidence() == inc ) { item->initColor (); item->updateItem(); } } diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h index 86cf2f4..59e7472 100644 --- a/korganizer/koagenda.h +++ b/korganizer/koagenda.h @@ -1,115 +1,115 @@ /* 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. */ #ifndef KOAGENDA_H #define KOAGENDA_H #include <qscrollview.h> #include <qtimer.h> #include <qmemarray.h> #include <qpainter.h> #include <qpixmap.h> #include <qguardedptr.h> #include "koagendaitem.h" #include "koeventview.h" class QPopupMenu; class QTime; class KConfig; class QFrame; class KOAgenda; class KCal::Event; class KCal::Todo; using namespace KCal; class MarcusBains : public QFrame { Q_OBJECT public: MarcusBains(KOAgenda *agenda=0,const char *name=0); virtual ~MarcusBains(); - + void hideMe(); public slots: void updateLocation(bool recalculate=false); void updateLoc(); private: int todayColumn(); QTimer *minutes; QLabel *mTimeBox; KOAgenda *agenda; QTime oldTime; int oldToday; }; class KOAgenda : public QScrollView { Q_OBJECT public: enum MouseActionType { NOP, MOVE, SELECT, RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT }; KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0, const char * name=0, WFlags f=0 ); KOAgenda ( int columns, QWidget * parent=0, const char * name=0, WFlags f=0 ); virtual ~KOAgenda(); bool mInvalidPixmap; Incidence *selectedIncidence() const; QDate selectedIncidenceDate() const; virtual bool eventFilter ( QObject *, QEvent * ); void contentsToGrid (int x, int y, int& gx, int& gy); void gridToContents (int gx, int gy, int& x, int& y); int timeToY (const QTime &time); QTime gyToTime (int y); void setStartHour(int startHour); KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom); KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd); void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, int YTop,int YBottom); void changeColumns(int columns); int columns() { return mColumns; } int rows() { return mRows; } int gridSpacingX() const { return mGridSpacingX; } int gridSpacingY() const { return mGridSpacingY; } // virtual QSizePolicy sizePolicy() const; void clear(); void clearSelection(); void hideUnused(); /** Calculates the minimum width */ virtual int minimumWidth() const; /** Update configuration from preference settings */ diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index f46a103..82c0f4c 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp @@ -1296,146 +1296,146 @@ void KOTodoView::changedCategories(int index) 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() ); int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); //qDebug("ROW %d ", row); if (!item) { newTodo(); return; } else { if ( row == 1 ) { mActiveItem = (KOTodoViewItem *) item; newSubTodo(); return; } if ( row == 5 || row == 6 || row == 2) { mActiveItem = (KOTodoViewItem *) item; Todo * t = mActiveItem->todo(); if ( t->isRunning() ) { if ( t->runTime() < 15) { t->stopRunning(); mActiveItem->construct(); topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!")); return; } else toggleRunningItem(); return; } else { t->setRunning( true ); mActiveItem->construct(); topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!")); return; } } } if ( KOPrefs::instance()->mEditOnDoubleClick ) editItem( item ); else showItem( item , QPoint(), 0 ); } void KOTodoView::toggleRunningItem() { // qDebug("KOTodoView::toggleRunning() "); if ( ! mActiveItem ) return; Todo * t = mActiveItem->todo(); if ( t->isRunning() ) { KOStopTodoPrefs tp ( t, this ); if (QApplication::desktop()->width() <= 800 ){ int wid = tp.width(); int hei = tp.height(); int xx = (QApplication::desktop()->width()-wid)/2; int yy = (QApplication::desktop()->height()-hei)/2; tp.setGeometry( xx,yy,wid,hei ); } tp.exec(); - mActiveItem->construct(); + updateTodo ( t, 0 ); } else { KOStartTodoPrefs tp ( t->summary(), this ); if (QApplication::desktop()->width() <= 800 ){ int wid = tp.width(); int hei = tp.height(); int xx = (QApplication::desktop()->width()-wid)/2; int yy = (QApplication::desktop()->height()-hei)/2; tp.setGeometry( xx,yy,wid,hei ); } if ( !tp.exec() ) return; if ( tp.stopAll() ) { mCalendar->stopAllTodos(); t->setRunning( true ); updateView(); } else { t->setRunning( true ); - mActiveItem->construct(); + updateTodo ( t, 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 ) { topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); pendingSubtodo = 0; } else { Todo* newParent = todoItem->todo(); Todo* newSub = pendingSubtodo->todo(); pendingSubtodo = 0; emit reparentTodoSignal( newParent,newSub ); return; } } } void KOTodoView::setDocumentId( const QString &id ) { mDocPrefs->setDoc( id ); } void KOTodoView::itemStateChanged( QListViewItem *item ) { if (!item) return; KOTodoViewItem *todoItem = (KOTodoViewItem *)item; // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); } void KOTodoView::saveLayout(KConfig *config, const QString &group) const { mTodoListView->saveLayout(config,group); } void KOTodoView::restoreLayout(KConfig *config, const QString &group) { mTodoListView->restoreLayout(config,group); |