-rw-r--r-- | korganizer/calendarview.cpp | 4 | ||||
-rw-r--r-- | korganizer/koagenda.cpp | 1 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 3 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 8 | ||||
-rw-r--r-- | microkde/ofileselector_p.cpp | 4 |
5 files changed, 12 insertions, 8 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 7566c6f..4b3f806 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -3808,390 +3808,388 @@ void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) return; } if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { KMessageBox::sorry(this,i18n("The event has no attendees.")); return; } Event *ev = 0; if (event) ev = new Event(*event); Todo *to = 0; if (todo) to = new Todo(*todo); if (method == Scheduler::Reply || method == Scheduler::Refresh) { Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); if (!me) { KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); return; } if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { StatusDialog *statdlg = new StatusDialog(this); if (!statdlg->exec()==QDialog::Accepted) return; me->setStatus( statdlg->status() ); delete(statdlg); } Attendee *menew = new Attendee(*me); if (ev) { ev->clearAttendees(); ev->addAttendee(menew,false); } else { if (to) { todo->clearAttendees(); todo->addAttendee(menew,false); } } } OutgoingDialog *dlg = mDialogManager->outgoingDialog(); if (ev) { if ( !dlg->addMessage(ev,method) ) delete(ev); } else { if (to) { if ( !dlg->addMessage(to,method) ) delete(to); } } } void CalendarView::openAddressbook() { KRun::runCommand("kaddressbook"); } void CalendarView::setModified(bool modified) { if ( modified ) emit signalmodified(); if (mModified != modified) { mModified = modified; emit modifiedChanged(mModified); } } bool CalendarView::isReadOnly() { return mReadOnly; } void CalendarView::setReadOnly(bool readOnly) { if (mReadOnly != readOnly) { mReadOnly = readOnly; emit readOnlyChanged(mReadOnly); } } bool CalendarView::isModified() { return mModified; } void CalendarView::slotprintSelInc() { if ( currentSelection() == 0 ) { KMessageBox::sorry(this,i18n("There is nothing selected!")); return; } showIncidence(); getEventViewerDialog()->print(); } void CalendarView::printSetup() { #ifndef KORG_NOPRINTER createPrinter(); mCalPrinter->setupPrinter(); #endif } void CalendarView::print() { #ifndef KORG_NOPRINTER createPrinter(); DateList tmpDateList = mNavigator->selectedDates(); mCalPrinter->print(CalPrinter::Month, tmpDateList.first(), tmpDateList.last()); #endif } void CalendarView::printPreview() { #ifndef KORG_NOPRINTER kdDebug() << "CalendarView::printPreview()" << endl; createPrinter(); DateList tmpDateList = mNavigator->selectedDates(); mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), tmpDateList.last()); #endif } void CalendarView::exportICalendar() { QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); // Force correct extension if (filename.right(4) != ".ics") filename += ".ics"; FileStorage storage( mCalendar, filename, new ICalFormat() ); storage.save(); } bool CalendarView::exportVCalendar( QString filename ) { if (mCalendar->journals().count() > 0) { int result = KMessageBox::warningContinueCancel(this, i18n("The journal entries can not be\nexported to a vCalendar file."), i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), true); if (result != KMessageBox::Continue) return false; } //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); // Force correct extension if (filename.right(4) != ".vcs") filename += ".vcs"; FileStorage storage( mCalendar, filename, new VCalFormat ); return storage.save(); } void CalendarView::eventUpdated(Incidence *) { setModified(); // Don't call updateView here. The code, which has caused the update of the // event is responsible for updating the view. // updateView(); } void CalendarView::adaptNavigationUnits() { if (mViewManager->currentView()->isEventView()) { int days = mViewManager->currentView()->currentDateCount(); if (days == 1) { emit changeNavStringPrev(i18n("&Previous Day")); emit changeNavStringNext(i18n("&Next Day")); } else { emit changeNavStringPrev(i18n("&Previous Week")); emit changeNavStringNext(i18n("&Next Week")); } } } void CalendarView::processMainViewSelection( Incidence *incidence ) { if ( incidence ) mTodoList->clearSelection(); processIncidenceSelection( incidence ); } void CalendarView::processTodoListSelection( Incidence *incidence ) { if ( incidence && mViewManager->currentView() ) { mViewManager->currentView()->clearSelection(); } processIncidenceSelection( incidence ); } void CalendarView::processIncidenceSelection( Incidence *incidence ) { + emit incidenceSelected( incidence ); if ( incidence == mSelectedIncidence ) return; - mSelectedIncidence = incidence; - emit incidenceSelected( mSelectedIncidence ); - if ( incidence && incidence->typeID() == eventID ) { Event *event = static_cast<Event *>( incidence ); if ( event->organizer() == KOPrefs::instance()->email() ) { emit organizerEventsSelected( true ); } else { emit organizerEventsSelected(false); } if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, KOPrefs::instance()->email() ) ) { emit groupEventsSelected( true ); } else { emit groupEventsSelected(false); } return; } else { if ( incidence && incidence->typeID() == todoID ) { emit todoSelected( true ); Todo *event = static_cast<Todo *>( incidence ); if ( event->organizer() == KOPrefs::instance()->email() ) { emit organizerEventsSelected( true ); } else { emit organizerEventsSelected(false); } if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, KOPrefs::instance()->email() ) ) { emit groupEventsSelected( true ); } else { emit groupEventsSelected(false); } return; } else { emit todoSelected( false ); emit organizerEventsSelected(false); emit groupEventsSelected(false); } return; } /* if ( incidence && incidence->typeID() == todoID ) { emit todoSelected( true ); } else { emit todoSelected( false ); }*/ } void CalendarView::checkClipboard() { #ifndef KORG_NODND if (ICalDrag::canDecode(QApplication::clipboard()->data())) { emit pasteEnabled(true); } else { emit pasteEnabled(false); } #endif } void CalendarView::showDates(const DateList &selectedDates) { // kdDebug() << "CalendarView::selectDates()" << endl; if ( !mBlockShowDates ) { if ( mViewManager->currentView() ) { updateView( selectedDates.first(), selectedDates.last() ); } else { mViewManager->showAgendaView(); } } QDate date = selectedDates.first(); if ( ! date.isValid() ) { topLevelWidget()->setCaption(""); return; } QString selDates; selDates = KGlobal::locale()->formatDate( date, true); if (selectedDates.first() < selectedDates.last() ) selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); else { QString addString; if ( date == QDateTime::currentDateTime().date() ) addString = i18n("Today"); else if ( date == QDateTime::currentDateTime().date().addDays(1) ) addString = i18n("Tomorrow"); else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) addString = i18n("Yesterday"); else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) addString = i18n("Day before yesterday"); else if ( date == QDateTime::currentDateTime().date().addDays(2) ) addString = i18n("Day after tomorrow"); if ( !addString.isEmpty() ) { topLevelWidget()->setCaption( addString+", " + selDates ); return; } } topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); } QPtrList<CalFilter> CalendarView::filters() { return mFilters; } void CalendarView::editFilters() { // kdDebug() << "CalendarView::editFilters()" << endl; CalFilter *filter = mFilters.first(); while(filter) { filter = mFilters.next(); } mDialogManager->showFilterEditDialog(&mFilters); updateFilter(); } void CalendarView::toggleFilter() { if ( mLeftFrame->isHidden() ) { toggleExpand(); showFilter( true ); } else showFilter(! mCalEditView->isVisible()); } KOFilterView *CalendarView::filterView() { return mFilterView; } void CalendarView::selectFilter( int fil ) { mFilterView->setSelectedFilter( fil ); updateUnmanagedViews(); } void CalendarView::showFilter(bool visible) { #if 1 if (visible) { mCalEditView->readConfig(); mCalEditView->show(); QValueList<int> sizes; sizes = mLeftFrame->sizes(); if ( sizes.count() == 4 && sizes[3] < 20 ) { sizes.clear(); sizes << 100; sizes << 0; sizes << 0; sizes << 100; mLeftFrame->setSizes(sizes); } #if 0 sizes = mLeftFrame->sizes(); int ccc = 0; while ( ccc < sizes.count()) { qDebug("size %d %d ", ccc, sizes[ccc]); ++ccc; } #endif } else { mCalEditView->hide(); } #else if (visible) mFilterView->show(); else mFilterView->hide(); #endif } void CalendarView::toggleFilerEnabled( ) { mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); if ( !mFilterView->filtersEnabled() ) topLevelWidget()->setCaption( i18n("Filter disabled ") ); updateUnmanagedViews(); } void CalendarView::updateFilter() { CalFilter *filter = mFilterView->selectedFilter(); if (filter) { QString mess; if (mFilterView->filtersEnabled()) { mess = i18n("Filter selected: ")+filter->name(); filter->setEnabled(true); } else filter->setEnabled(false); mCalendar->setFilter(filter); updateView(); if ( !mess.isEmpty() ) topLevelWidget()->setCaption( mess ); diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 92c1cd6..acdf5a0 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp @@ -1,349 +1,348 @@ /* This file is part of KOrganizer. Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> Marcus Bains line. Copyright (c) 2001 Ali Rahimi 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 _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; } 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(); //mTimeBox->setAutoMask(true); int secs = QTime::currentTime().second(); - qDebug("second %d ", secs ); minutes->start( (60 - secs +1)*1000 ,true); } //////////////////////////////////////////////////////////////////////////// /* Create an agenda widget with rows rows and columns columns. */ KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, const char *name,WFlags f) : QScrollView(parent,name,f) { mAllAgendaPopup = 0; mColumns = columns; mRows = rows; mGridSpacingY = rowSize; mAllDayMode = false; #ifndef DESKTOP_VERSION //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); #endif mHolidayMask = 0; init(); connect ( this, SIGNAL (contentsMoving ( int , int ) ), this, SLOT ( slotContentMove(int,int)) ); } /* Create an agenda widget with columns columns and one row. This is used for all-day events. */ KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : QScrollView(parent,name,f) { mAllAgendaPopup = 0; blockResize = false; mColumns = columns; mRows = 1; //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); mGridSpacingY = KOPrefs::instance()->mAllDaySize; mAllDayMode = true; #ifndef DESKTOP_VERSION //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); #endif mHolidayMask = 0; init(); } KOAgenda::~KOAgenda() { if(mMarcusBains) delete mMarcusBains; } Incidence *KOAgenda::selectedIncidence() const { return (mSelectedItem ? mSelectedItem->incidence() : 0); } QDate KOAgenda::selectedIncidenceDate() const { return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); } void KOAgenda::init() { mPopupTimer = new QTimer(this); connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); mNewItemPopup = new QPopupMenu( this ); connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); QString pathString = ""; if ( !KOPrefs::instance()->mToolBarMiniIcons ) { if ( QApplication::desktop()->width() < 480 ) pathString += "icons16/"; } else pathString += "iconsmini/"; mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); mNewItemPopup->insertSeparator ( ); mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); #ifndef _WIN32_ int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase viewport()->setWFlags ( wflags); #endif mGridSpacingX = 80; mResizeBorderWidth = 8; mScrollBorderWidth = 8; mScrollDelay = 30; mScrollOffset = 10; mPaintPixmap.resize( 20,20); //enableClipper(true); // Grab key strokes for keyboard navigation of agenda. Seems to have no // effect. Has to be fixed. setFocusPolicy(WheelFocus); connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); mStartCellX = 0; mStartCellY = 0; mCurrentCellX = 0; mCurrentCellY = 0; mSelectionCellX = 0; mSelectionYTop = 0; mSelectionHeight = 0; mOldLowerScrollValue = -1; mOldUpperScrollValue = -1; mClickedItem = 0; mActionItem = 0; mActionType = NOP; mItemMoved = false; mSelectedItem = 0; // mItems.setAutoDelete(true); resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); viewport()->update(); setMinimumSize(30, 1); // setMaximumHeight(mGridSpacingY * mRows + 5); // Disable horizontal scrollbar. This is a hack. The geometry should be // controlled in a way that the contents horizontally always fits. Then it is // not necessary to turn off the scrollbar. setHScrollBarMode(AlwaysOff); if ( ! mAllDayMode ) setVScrollBarMode(AlwaysOn); else setVScrollBarMode(AlwaysOff); setStartHour(KOPrefs::instance()->mDayBegins); calculateWorkingHours(); connect(verticalScrollBar(),SIGNAL(valueChanged(int)), 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(); diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 86e1bd9..a87e6fc 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp @@ -965,408 +965,411 @@ KOTodoView::insertTodoItem(Todo *todo) // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; // TODO: Check, if dynmaic cast is necessary pendingSubtodo = 0; Incidence *incidence = todo->relatedTo(); while ( incidence && !incidence->calEnabled() ) incidence = incidence->relatedTo(); if (incidence && incidence->typeID() == todoID ) { Todo *relatedTodo = static_cast<Todo *>(incidence); // kdDebug() << " has Related" << endl; QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; itemIterator = mTodoMap.find(relatedTodo); if (itemIterator == mTodoMap.end()) { // kdDebug() << " related not yet in list" << endl; itemIterator = insertTodoItem (relatedTodo); } // isn't this pretty stupid? We give one Todo to the KOTodoViewItem // and one into the map. Sure finding is more easy but why? -zecke KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); return mTodoMap.insert(todo,todoItem); } else { // kdDebug() << " no Related" << endl; // see above -zecke KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); return mTodoMap.insert(todo,todoItem); } } void KOTodoView::updateConfig() { updateView(); mTodoListView->repaintContents(); } QPtrList<Incidence> KOTodoView::selectedIncidences() { QPtrList<Incidence> selected; KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); // if (!item) item = mActiveItem; if (item) selected.append(item->todo()); return selected; } QPtrList<Todo> KOTodoView::selectedTodos() { QPtrList<Todo> selected; KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); // if (!item) item = mActiveItem; if (item) selected.append(item->todo()); return selected; } void KOTodoView::changeEventDisplay(Event *, int) { updateView(); } void KOTodoView::showDates(const QDate &, const QDate &) { } void KOTodoView::showEvents(QPtrList<Event>) { kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; } void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td) { #ifndef KORG_NOPRINTER calPrinter->preview(CalPrinter::Todolist, fd, td); #endif } void KOTodoView::editItem(QListViewItem *item ) { emit editTodoSignal(((KOTodoViewItem *)item)->todo()); } void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) { emit showTodoSignal(((KOTodoViewItem *)item)->todo()); } void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) { pendingSubtodo = 0; mActiveItem = (KOTodoViewItem *)item; if (item) { switch (column){ case 1: mPriorityPopupMenu->popup(QCursor::pos ()); break; case 2: mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; case 3: moveTodo(); break; case 8: mCategoryPopupMenu->popup(QCursor::pos ()); break; case 9: mCalPopupMenu->popup(QCursor::pos ()); break; default: mItemPopupMenu->popup(QCursor::pos()); } } else mPopupMenu->popup(QCursor::pos()); } void KOTodoView::newTodo() { emit newTodoSignal(); } void KOTodoView::newSubTodo() { if (mActiveItem) { emit newSubTodoSignal(mActiveItem->todo()); } } void KOTodoView::unparentTodo() { if (mActiveItem) { emit unparentTodoSignal(mActiveItem->todo()); } } void KOTodoView::reparentTodo() { if (mActiveItem) { topLevelWidget()->setCaption(i18n("Click on new parent item")); pendingSubtodo = mActiveItem; } } void KOTodoView::editTodo() { if (mActiveItem) { emit editTodoSignal(mActiveItem->todo()); } } void KOTodoView::cloneTodo() { if (mActiveItem) { emit cloneTodoSignal((Incidence*)mActiveItem->todo()); } } void KOTodoView::cancelTodo() { if (mActiveItem) { emit cancelTodoSignal((Incidence*)mActiveItem->todo()); } } void KOTodoView::moveTodo() { if (mActiveItem) { emit moveTodoSignal((Incidence*)mActiveItem->todo()); } } void KOTodoView::beamTodo() { if (mActiveItem) { emit beamTodoSignal((Incidence*)mActiveItem->todo()); } } void KOTodoView::showTodo() { if (mActiveItem) { emit showTodoSignal(mActiveItem->todo()); } } void KOTodoView::deleteTodo() { if (mActiveItem) { emit deleteTodoSignal(mActiveItem->todo()); } } void KOTodoView::setNewPriority(int index) { if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { mActiveItem->todo()->setPriority(mPriority[index]); mActiveItem->construct(); todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); } + processSelectionChange(); } void KOTodoView::setNewPercentage(int index) { if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { mActiveItem->setOn( true ); + processSelectionChange(); return; } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); if ( par && par->isOn() ) par->setOn( false ); } if (mPercentage[index] == 100) { mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); } else { mActiveItem->todo()->setCompleted(false); } mActiveItem->todo()->setPercentComplete(mPercentage[index]); mActiveItem->construct(); todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); } + processSelectionChange(); } void KOTodoView::fillCategories () { mCategoryPopupMenu->clear(); if ( ! mActiveItem ) return; QStringList checkedCategories = mActiveItem->todo()->categories (); for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); it != KOPrefs::instance()->mCustomCategories.end (); ++it) { int index = mCategoryPopupMenu->insertItem (*it); mCategory[index] = *it; if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true); } } void KOTodoView::fillCal () { mCalPopupMenu->clear(); if (!mActiveItem) return; bool readO = mActiveItem->todo()->isReadOnly(); KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); while ( kkf ) { int index = mCalPopupMenu->insertItem( kkf->mName, kkf->mCalNumber); if ( kkf->mErrorOnLoad || kkf->isReadOnly || readO ) mCalPopupMenu->setItemEnabled( index, false ); mCalPopupMenu->setItemChecked (index, kkf->mCalNumber == mActiveItem->todo()->calID()); kkf = KOPrefs::instance()->mCalendars.next(); } } void KOTodoView::changedCal (int index ) { if (!mActiveItem) return; mActiveItem->todo()->setCalID( index ); mActiveItem->construct(); } 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() ); 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(); } 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(); } } } 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 diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 88dbd4f..cbf6096 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -1493,386 +1493,390 @@ void MainWindow::timetrackinghowto() } void MainWindow::kdesynchowto() { KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); } void MainWindow::multisynchowto() { KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); } void MainWindow::synchowto() { KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); } void MainWindow::faq() { KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); } void MainWindow::whatsNew() { KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); } void MainWindow::licence() { KApplication::showLicence(); } void MainWindow::about() { QString version; #include <../version> QMessageBox::about( this, i18n("About KOrganizer/Pi"), i18n("KOrganizer/Platform-independent\n") + "(KO/Pi) " + version + " - " + #ifdef DESKTOP_VERSION i18n("Desktop Edition\n") + #else i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + #endif i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") ); } void MainWindow::keyBindings() { QString cap = i18n("KO/Pi Keys + Colors"); QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") + i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") + i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ i18n("<p><b>R</b>: Toggle Resource View |<b>F</b>: Edit filter </p>\n")+ i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+ i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+ i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ i18n("<p><h3>In agenda view:</h3></p>\n") + i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ i18n("<p><h3>In todo view:</h3></p>\n") + i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ i18n("<p><h3>In list view:</h3></p>\n") + i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ i18n("<p><b>return</b>: Select item+one step down</p>\n")+ i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ i18n("<p><h3>In event/todo viewer:</h3></p>\n") + i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ i18n("<p><b>A</b>: Show agenda view.</p>\n")+ i18n("<p><b>E</b>: Edit item</p>\n") + i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + i18n("<p><b>White</b>: Item readonly</p>\n"); displayText( text, cap); } void MainWindow::aboutAutoSaving() { QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"); KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); } void MainWindow::aboutKnownBugs() { QMessageBox* msg; msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + i18n("\nor report them in the bugtracker on\n") + i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), QMessageBox::NoIcon, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton); msg->exec(); delete msg; } QString MainWindow::defaultFileName() { return locateLocal( "data", "korganizer/mycalendar.ics" ); } QString MainWindow::syncFileName() { #ifdef DESKTOP_VERSION return locateLocal( "tmp", "synccalendar.ics" ); #else return QString( "/tmp/synccalendar.ics" ); #endif } #include "koglobals.h" #include <kcalendarsystem.h> void MainWindow::updateWeek(QDate seda) { int weekNum = KGlobal::locale()->weekNum ( seda ); mWeekPixmap.fill( mWeekBgColor ); QPainter p ( &mWeekPixmap ); p.setFont( mWeekFont ); p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); p.end(); QIconSet icon3 ( mWeekPixmap ); mWeekAction->setIconSet ( icon3 ); } void MainWindow::updateWeekNum(const DateList &selectedDates) { updateWeek( selectedDates.first() ); } void MainWindow::processIncidenceSelection( Incidence *incidence ) { if ( !incidence ) { mShowAction->setMenuText( i18n("Show") ); enableIncidenceActions( false ); mNewSubTodoAction->setEnabled( false ); setCaptionToDates(); return; } QString startString = ""; if ( incidence->typeID() != todoID ) { if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { if ( incidence->doesFloat() ) { startString += ": "+incidence->dtStartDateStr( true ); startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); } else { startString = ": "+incidence->dtStartStr(true); startString += " --- "+((Event*)incidence)->dtEndStr(true); } } else { if ( incidence->dtStart().time() != incidence->dtEnd().time() ) startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); if ( incidence->isBirthday() || incidence->isAnniversary() ) { bool ok; QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); if ( ok ) { int years = noc.date().year() - incidence->dtStart().date().year(); startString += i18n(" (%1 y.)"). arg( years ); } } else startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); } } - else - startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); + else { + if ( (( KCal::Todo*)incidence)->percentComplete() == 100 ) + startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+i18n("completed on %1").arg( (( KCal::Todo*)incidence)->completedStr(true) ); + else + startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); + } if ( !incidence->location().isEmpty() ) startString += " (" +incidence->location()+")"; setCaption( incidence->summary()+startString); enableIncidenceActions( true ); if ( incidence->typeID() == eventID ) { mShowAction->setMenuText( i18n("Show Event") ); mNewSubTodoAction->setEnabled( false ); } else if ( incidence->typeID() == todoID ) { mShowAction->setMenuText( i18n("Show Todo") ); mNewSubTodoAction->setEnabled( true ); } else { mShowAction->setMenuText( i18n("Show") ); mNewSubTodoAction->setEnabled( false ); } } void MainWindow::enableIncidenceActions( bool enabled ) { mShowAction->setEnabled( enabled ); mEditAction->setEnabled( enabled ); mDeleteAction->setEnabled( enabled ); mCloneAction->setEnabled( enabled ); mMoveAction->setEnabled( enabled ); #ifndef DESKTOP_VERSION mBeamAction->setEnabled( enabled ); #endif mCancelAction->setEnabled( enabled ); } void MainWindow::importOL() { #ifdef _OL_IMPORT_ mView->clearAllViews(); KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); id->exec(); delete id; mView->calendar()->checkAlarmForIncidence( 0, true ); mView->updateView(); #endif } void MainWindow::importBday() { int result = QMessageBox::warning( this, i18n("KO/Pi import information!"), i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), i18n("Import!"), i18n("Cancel"), 0, 0, 1 ); if ( result == 0 ) { mView->importBday(); } } void MainWindow::importQtopia() { //#ifndef DESKTOP_VERSION QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"); #ifdef DESKTOP_VERSION mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml"); #endif int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, i18n("Import!"), i18n("Cancel"), 0, 0, 1 ); if ( result == 0 ) { #ifndef DESKTOP_VERSION QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; #else QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; #endif mView->importQtopia( categories, datebook, todolist ); } mView->calendar()->reInitAlarmSettings(); #if 0 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), i18n("Not supported \non desktop!\n"), i18n("Ok"), i18n("Cancel"), 0, 0, 1 ); #endif } void MainWindow::saveOnClose() { KOPrefs *p = KOPrefs::instance(); p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); if ( filterToolBar ) { p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); } #ifdef DESKTOP_VERSION QPoint myP; myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); if ( p->mToolBarHor ) p->mToolBarUp = myP.y() > height()/2; else p->mToolBarUp = myP.x() > width()/2; myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); if ( p->mToolBarHorV ) p->mToolBarUpV = myP.y() > height()/2; else p->mToolBarUpV = myP.x() > width()/2 ; myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); if ( p->mToolBarHorN ) p->mToolBarUpN = myP.y() > height()/2; else p->mToolBarUpN = myP.x() > width()/2 ; if ( filterToolBar ) { myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); if ( p->mToolBarHorF ) p->mToolBarUpF = myP.y() > height()/2; else p->mToolBarUpF = myP.x() > width()/2 ; } #else if ( p->mToolBarHor ) p->mToolBarUp = iconToolBar->y() > height()/2; else p->mToolBarUp = iconToolBar->x() > width()/2; if ( p->mToolBarHorV ) p->mToolBarUpV = viewToolBar->y() > height()/2; else p->mToolBarUpV = viewToolBar->x() > width()/2 ; if ( p->mToolBarHorN ) p->mToolBarUpN = navigatorToolBar->y() > height()/2; else p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; if ( filterToolBar ) { if ( p->mToolBarHorF ) p->mToolBarUpF = filterToolBar->y() > height()/2; else p->mToolBarUpF = filterToolBar->x() > width()/2 ; } #endif save(); mView->writeSettings(); mView->checkSuspendAlarm(); } void MainWindow::slotModifiedChanged( bool ) { if ( mBlockAtStartup ) return; int msec; // we store the changes after 1 minute, // and for safety reasons after 10 minutes again if ( !mSyncManager->blockSave() ) msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; else msec = 1000 * 600; mSaveTimer.start( msec, true ); // 1 minute qDebug("KO: Saving File in %d secs!", msec/1000); mCalendarModifiedFlag = true; } void MainWindow::saveStopTimer() { mSaveTimer.stop(); } void MainWindow::backupAllFiles() { QDate reference ( 2000,1,1); int daysTo = reference.daysTo ( QDate::currentDate() ); setCaption(i18n("Creating backup ... please wait ..." )); qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); // we need the file path, the backup dir and the number of bups as param QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) bupDir = KGlobalSettings::backupDataDir(); int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); if ( retval == 0 ) { setCaption(i18n("Backup cancelled" )); qDebug("KO: Backup cancelled. Will try again tomorrow "); // retval == 0 : backup skipped for today, try again tomorrow KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; } else if ( retval == 1 ){ qDebug("KO: Backup created."); // backup ok QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; KopiCalendarFile * cal = calendars.first(); cal = calendars.next(); while ( cal ) { if ( !cal->mErrorOnLoad ) { KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); } cal = calendars.next(); diff --git a/microkde/ofileselector_p.cpp b/microkde/ofileselector_p.cpp index 488dee2..f4f112e 100644 --- a/microkde/ofileselector_p.cpp +++ b/microkde/ofileselector_p.cpp @@ -175,389 +175,389 @@ OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap, setText(3, date ); setText(4, kind ); m_isDir = isDir; m_dir = dir; m_locked = isLocked; } OFileSelectorItem::~OFileSelectorItem() { } bool OFileSelectorItem::isLocked()const { return m_locked; } QString OFileSelectorItem::directory()const { return m_dir; } bool OFileSelectorItem::isDir()const { return m_isDir; } QString OFileSelectorItem::path()const { return text( 1 ); } QString OFileSelectorItem::key( int id, bool )const { QString ke; if( id == 0 || id == 1 ){ // name if( m_isDir ){ ke.append("0" ); ke.append( text(1) ); }else{ ke.append("1" ); ke.append( text(1) ); } return ke; } else if ( id == 2 ) { QString sort = "00000000"; sort = sort.left( 9-text( 2 ).length()) + text( 2 ); return sort; } else return text( id ); } OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, OFileSelector* sel) : QWidget( parent ), m_sel( sel ) { m_all = false; QVBoxLayout* lay = new QVBoxLayout( this ); m_currentDir = startDir; /* * now we add a special bar * One Button For Up * Home * Doc * And a dropdown menu with FileSystems * FUTURE: one to change dir with lineedit * Bookmarks * Create Dir */ QHBox* box = new QHBox(this ); box->setBackgroundMode( PaletteButton ); box->setSpacing( 0 ); QToolButton *btn = new QToolButton( box ); btn->setIconSet( Resource::loadPixmap("up") ); connect(btn, SIGNAL(clicked() ), this, SLOT( cdUP() ) ); btn = new QToolButton( box ); btn->setIconSet( Resource::loadPixmap("home") ); connect(btn, SIGNAL(clicked() ), this, SLOT( cdHome() ) ); btn = new QToolButton( box ); btn->setIconSet( Resource::loadPixmap("DocsIcon") ); connect(btn, SIGNAL(clicked() ), this, SLOT(cdDoc() ) ); m_btnNew = new QToolButton( box ); m_btnNew->setIconSet( Resource::loadPixmap("new") ); connect(m_btnNew, SIGNAL(clicked() ), this, SLOT(slotNew() ) ); m_btnClose = new QToolButton( box ); m_btnClose->setIconSet( Resource::loadPixmap("close") ); connect(m_btnClose, SIGNAL(clicked() ), selector(), SIGNAL(closeMe() ) ); btn = new QToolButton( box ); btn->setIconSet( Resource::loadPixmap("cardmon/pcmcia") ); /* let's fill device parts */ QPopupMenu* pop = new QPopupMenu(this); connect(pop, SIGNAL( activated(int) ), this, SLOT(slotFSActivated(int) ) ); StorageInfo storage; const QList<FileSystem> &fs = storage.fileSystems(); QListIterator<FileSystem> it(fs); for ( ; it.current(); ++it ) { const QString disk = (*it)->name(); const QString path = (*it)->path(); m_dev.insert( disk, path ); pop->insertItem( disk ); } m_fsPop = pop; btn->setPopup( pop ); btn->setPopupDelay ( 0 ); lay->addWidget( box ); m_view = new QListView( this ); m_view->installEventFilter(this); QPEApplication::setStylusOperation( m_view->viewport(), QPEApplication::RightOnHold); m_view->addColumn(" " ); m_view->addColumn(i18n("Name"), 150 ); m_view->addColumn(i18n("Size"), -1 ); m_view->addColumn(i18n("Date"), -1 ); m_view->addColumn(i18n("Mime Type"), -1 ); m_view->setSorting( 1 ); m_view->setAllColumnsShowFocus( TRUE ); lay->addWidget( m_view, 1000 ); connectSlots(); } OFileViewFileListView::~OFileViewFileListView() { } void OFileViewFileListView::slotNew() { DocLnk lnk; emit selector()->newSelected( lnk ); } OFileSelectorItem* OFileViewFileListView::currentItem()const{ QListViewItem* item = m_view->currentItem(); if (!item ) return 0l; return static_cast<OFileSelectorItem*>(item); } void OFileViewFileListView::reread( bool all ) { m_view->clear(); if (selector()->showClose() ) m_btnClose->show(); else m_btnClose->hide(); if (selector()->showNew() ) m_btnNew->show(); else m_btnNew->hide(); m_mimes = selector()->currentMimeType(); m_all = all; QDir dir( m_currentDir ); if (!dir.exists() ) return; topLevelWidget()->setCaption( dir.path() ); dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); int filter; if (m_all ) filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; else filter = QDir::Files | QDir::Dirs | QDir::All; dir.setFilter( filter ); // now go through all files const QFileInfoList *list = dir.entryInfoList(); if (!list) { cdUP(); return; } QFileInfoListIterator it( *list ); QFileInfo *fi; while( (fi=it.current() ) ){ if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){ ++it; continue; } /* * It is a symlink we try to resolve it now but don't let us attack by DOS * */ if( fi->isSymLink() ){ - qDebug("SYMLINK "); + //qDebug("SYMLINK "); QString file = fi->readLink(); for( int i = 0; i<=5; i++) { // 5 tries to prevent dos QFileInfo info( file ); - qDebug("FILE %s ", file.latin1()); + //qDebug("FILE %s ", file.latin1()); if( !info.exists() ){ addSymlink( fi, TRUE ); break; }else if( info.isDir() ){ addDir( fi, TRUE ); break; }else if( info.isFile() ){ addFile( fi, TRUE ); break; }else if( info.isSymLink() ){ file = info.readLink() ; break; }else if( i == 4){ // couldn't resolve symlink add it as symlink addSymlink( fi ); } } // off for loop for symlink resolving }else if( fi->isDir() ) addDir( fi ); else if( fi->isFile() ) addFile( fi ); ++it; } // of while loop m_view->sort(); } int OFileViewFileListView::fileCount()const{ return m_view->childCount(); } QString OFileViewFileListView::currentDir()const{ return m_currentDir; } OFileSelector* OFileViewFileListView::selector() { return m_sel; } bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e) { #if 0 if ( e->type() == QEvent::KeyPress ) { QKeyEvent *k = (QKeyEvent *)e; if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) { slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); return true; } } #endif return false; } void OFileViewFileListView::connectSlots() { connect(m_view, SIGNAL(clicked(QListViewItem*) ), this, SLOT(slotCurrentChanged(QListViewItem*) ) ); connect(m_view, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint&, int ) ), this, SLOT(slotClicked(int, QListViewItem*, const QPoint&, int ) ) ); connect(m_view, SIGNAL(doubleClicked( QListViewItem* )), this, SLOT(slotDoubleClicked(QListViewItem* ) ) ); connect(m_view, SIGNAL(returnPressed( QListViewItem* )), this, SLOT(slotDoubleClicked(QListViewItem* ) ) ); } void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) { if (!item) return; #if 0 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); if (!sel->isDir() ) { selector()->m_lneEdit->setText( sel->text(1) ); // if in fileselector mode we will emit selected if ( selector()->mode() == OFileSelector::FileSelector ) { qWarning("slot Current Changed"); QStringList str = QStringList::split("->", sel->text(1) ); QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); emit selector()->fileSelected( path ); DocLnk lnk( path ); emit selector()->fileSelected( lnk ); } } #endif } void OFileViewFileListView::slotDoubleClicked(QListViewItem* item ) { if (!item ) return; OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); if (!sel->isLocked() ) { QStringList str = QStringList::split("->", sel->text(1) ); if (sel->isDir() ) { m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); emit selector()->dirSelected( m_currentDir ); reread( m_all ); }else { // file //qWarning("slot Clicked"); selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); emit selector()->fileSelected( path ); DocLnk lnk( path ); emit selector()->fileSelected( lnk ); emit selector()->ok(); } } // not locked } void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) { if (!item || ( button != Qt::LeftButton) ) return; OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); if (!sel->isLocked() ) { QStringList str = QStringList::split("->", sel->text(1) ); if (sel->isDir() ) { m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); emit selector()->dirSelected( m_currentDir ); reread( m_all ); }else { // file //qWarning("slot Clicked"); selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); emit selector()->fileSelected( path ); DocLnk lnk( path ); emit selector()->fileSelected( lnk ); } } // not locked } void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) { MimeType type( info->absFilePath() ); if (!compliesMime( type.id() ) ) return; QPixmap pix = type.pixmap(); QString dir, name; bool locked; if ( pix.isNull() ) { QWMatrix matrix; QPixmap pixer(Resource::loadPixmap("UnknownDocument") ); matrix.scale( .4, .4 ); pix = pixer.xForm( matrix ); } dir = info->dirPath( true ); locked = false; if ( symlink ) name = info->fileName() + " -> " + info->readLink(); else{ name = info->fileName(); if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) { locked = true; pix = Resource::loadPixmap("locked"); } } (void)new OFileSelectorItem( m_view, pix, name, KGlobal::locale()->formatDateTime(info->lastModified(),true, true, KLocale::ISODate), QString::number( info->size() ), dir, locked ); } void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) { bool locked = false; QString name; QPixmap pix; if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) { locked = true; if ( symlink ) pix = Resource::loadPixmap( "symlink" ); else pix = Resource::loadPixmap( "lockedfolder" ); }else pix = symlink ? Resource::loadPixmap( "symlink") : Resource::loadPixmap("folder"); name = symlink ? info->fileName() + " -> " + info->readLink() : info->fileName(); (void)new OFileSelectorItem( m_view, pix, name, KGlobal::locale()->formatDateTime(info->lastModified(),true, true, KLocale::ISODate), QString::number( info->size() ), info->dirPath( true ), locked, true ); } void OFileViewFileListView::addSymlink( QFileInfo* , bool ) { } void OFileViewFileListView::cdUP() { QDir dir( m_currentDir ); dir.cdUp(); if (!dir.exists() ) m_currentDir = "/"; else m_currentDir = dir.absPath(); emit selector()->dirSelected( m_currentDir ); reread( m_all ); } void OFileViewFileListView::cdHome() { m_currentDir = QDir::homeDirPath(); emit selector()->dirSelected( m_currentDir ); |