-rw-r--r-- | korganizer/journalentry.cpp | 14 | ||||
-rw-r--r-- | korganizer/kolistview.cpp | 1 |
2 files changed, 14 insertions, 1 deletions
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp index 7f6f221..5269af7 100644 --- a/korganizer/journalentry.cpp +++ b/korganizer/journalentry.cpp @@ -88,96 +88,100 @@ JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : vb->setStretchFactor ( mTitle, 8 ); int limit = 3; if ( QApplication::desktop()->width() < 640 ) limit = 6; vb->setStretchFactor ( mCalendarBox, limit ); //mTitleLabel->setMargin(0); //mTitleLabel->setAlignment(AlignCenter); QPushButton * loadTemplate = new QPushButton( vb ); QPushButton * saveTemplate = new QPushButton( vb ); if ( QApplication::desktop()->width() < 321 ) iconp = SmallIcon("fileexport16"); else iconp = SmallIcon("fileexport"); saveTemplate->setPixmap (iconp ) ; int size = saveTemplate->sizeHint().height(); if ( QApplication::desktop()->width() < 321 ) iconp = SmallIcon("fileimport16"); else iconp = SmallIcon("fileimport"); loadTemplate->setPixmap (iconp ) ; loadTemplate->setFixedSize( size, size ); saveTemplate->setFixedSize( size, size ); int widwid = size; if ( QApplication::desktop()->width() < 320 ) widwid = size/2+1; toggleJournal->setFixedSize( widwid , size ); mTitle->setFixedHeight( size+4); mCalendarBox->setFixedHeight( size+4); mEditor = new KTextEdit(this); #ifndef DESKTOP_VERSION QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold ); #endif mMaxWidDiff = 3*size - 2*frameWidth() - textLabel->sizeHint().width(); mDeskWid = QApplication::desktop()->width(); int maxwid = mDeskWid - mMaxWidDiff; if ( QApplication::desktop()->width() < 640 ) { mTitle->setMaximumWidth( maxwid/2 +20 ); mCalendarBox->setMaximumWidth( maxwid/2 -20); } else { mTitle->setMaximumWidth( (maxwid/4)*3); mCalendarBox->setMaximumWidth( maxwid/2 ); } //mCalendarBox->setMaximumWidth( maxwid/2 -20 ); mEditor->setWordWrap( KTextEdit::WidgetWidth ); QBoxLayout *topLayout = new QVBoxLayout(this); topLayout->addWidget(vb); topLayout->addWidget(mEditor); mEditor->installEventFilter(this); + installEventFilter(this); + mTitle->installEventFilter(this); + setFocusPolicy (QWidget::NoFocus); + connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) ); mTitle->load( KOLocationBox::SUMMARYJOURNAL ); mTitle->lineEdit ()->setText(""); } JournalEntry::~JournalEntry() { //qDebug("JournalEntry::~JournalEntry() "); } void JournalEntry::resizeEvent(QResizeEvent* e ) { #ifndef DESKTOP_VERSION if ( mDeskWid != QApplication::desktop()->width() ) { mDeskWid == QApplication::desktop()->width(); int maxwid = mDeskWid - mMaxWidDiff; if ( QApplication::desktop()->width() < 640 ) { mTitle->setMaximumWidth( maxwid/2 +20 ); mCalendarBox->setMaximumWidth( maxwid/2 -20); } else { mTitle->setMaximumWidth( (maxwid/4)*3); mCalendarBox->setMaximumWidth( maxwid/2 ); } //mCalendarBox->setMaximumWidth( maxwid/2 -20 ); } //setMaximumWidth( QApplication::desktop()->width() ); //qDebug("MAXXX %d ", QApplication::desktop()->width()); #endif QFrame::resizeEvent( e ); } QSize JournalEntry::sizeHint() const { return QSize ( 240, heiHint ); } void JournalEntry::slotSaveTemplate() { QString fileName =locateLocal( "templates", "journals" ); QDir t_dir; if ( !t_dir.exists(fileName) ) t_dir.mkdir ( fileName ); fileName += "/journal"; fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Journal template"), this ); if ( fileName.length() == 0 ) return; @@ -266,102 +270,110 @@ void JournalEntry::toggleShowJournal() } 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 ( isVisible() ) { + mEditor->setFocusPolicy (QWidget::StrongFocus); + mTitle->setFocusPolicy (QWidget::StrongFocus); + } else { + mEditor->setFocusPolicy (QWidget::NoFocus); + mTitle->setFocusPolicy (QWidget::NoFocus); + } if ( e->type() == QEvent::FocusOut ) { writeJournal(); } if ( e->type() == QEvent::KeyPress ) { QKeyEvent * k = (QKeyEvent *) e; + if ( !isVisible() ) + return true; if ( k->state() == Qt::ControlButton ) { k->ignore(); //return true; } } return QFrame::eventFilter( o, e ); // standard event processing } void JournalEntry::writeJournal() { if ( !visibleMode ) return; if ( !mTitle->isEnabled() ) return; if (mEditor->text().isEmpty() && mTitle->currentText().isEmpty()) { if ( mJournal ) { Journal* j = mJournal; mJournal = 0; bool conf = KOPrefs::instance()->mConfirm; KOPrefs::instance()->mConfirm = false; emit deleteJournal(j); KOPrefs::instance()->mConfirm = conf; } return; } // kdDebug() << "JournalEntry::writeJournal()..." << endl; if (!mJournal) { mJournal = new Journal; mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); mCalendar->addJournal(mJournal); } if ( mJournal->description() != mEditor->text() ) { mJournal->setDescription(mEditor->text()); } if ( mJournal->summary() != mTitle->currentText() ) { mJournal->setSummary(mTitle->currentText()); mTitle->save(KOLocationBox::SUMMARYJOURNAL); } int id = KOPrefs::instance()->getCalendarID( mCalendarBox->currentText() ); if ( mJournal->calID() != id ) { mJournal->setCalID( id ); } } void JournalEntry::flushEntry() { writeJournal(); diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index 4fc1194..b378330 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp @@ -1249,96 +1249,97 @@ void KOListViewListView::keyPressEvent ( QKeyEvent *e) cn = currentItem(); if ( cn ) { KOListViewItem* ci = (KOListViewItem*)( cn ); if ( ci ){ //emit showIncidence( ci->data()); cn = cn->nextSibling(); if ( cn ) { setCurrentItem ( cn ); ensureItemVisible ( cn ); } emit showIncidence( ci->data()); } } e->accept(); } break; case Qt::Key_Return: case Qt::Key_Enter: { QListViewItem* cn; cn = currentItem(); if ( cn ) { KOListViewItem* ci = (KOListViewItem*)( cn ); if ( ci ){ if ( e->state() == ShiftButton ) ci->setSelected( false ); else ci->setSelected( true ); cn = cn->nextSibling(); if ( cn ) { setCurrentItem ( cn ); ensureItemVisible ( cn ); } else { emit currentChanged( ci ); } } } e->accept(); } break; default: e->ignore(); } } KOListViewListView::KOListViewListView(KOListView * lv ) : KListView( lv, "kolistlistview", false ) { mYMousePos = 0; + setAllColumnsShowFocus( true ); mPopupTimer = new QTimer(this); connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); #ifndef DESKTOP_VERSION //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); #endif setSelectionMode( QListView::Multi ); setMultiSelection( true); } bool KOListViewListView::hasMultiSelection(QListViewItem* item) { QListViewItem *qitem = firstChild (); while ( qitem ) { if ( qitem->isSelected() && item != qitem ) return true; qitem = qitem->nextSibling(); } return false; } void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) { if (!e) return; QPoint vp = contentsToViewport(e->pos()); QListViewItem *item = itemAt(vp); if (!item) { emit newEvent(); return; } KListView::contentsMouseDoubleClickEvent(e); } #if 0 void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) { //qDebug("contentsMousePressEvent++++ "); KListView::contentsMousePressEvent( e ); if ( e->button() == RightButton ) { QListViewItem* ci = currentItem(); clearSelection () ; if ( ci ) ci->setSelected( true ); } } void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) { KListView::contentsMouseReleaseEvent(e); } void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) { KListView::contentsMouseMoveEvent(e); |