author | zautrix <zautrix> | 2005-06-30 05:32:10 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-30 05:32:10 (UTC) |
commit | da264cf19c0183d6ea4e8dab6eabd40994e351c8 (patch) (side-by-side diff) | |
tree | 061026fe6869c365641853b1ebba542b852046bc | |
parent | 4e850fa7aa99f92676e49466cfccaa5d5e0ec24c (diff) | |
download | kdepimpi-da264cf19c0183d6ea4e8dab6eabd40994e351c8.zip kdepimpi-da264cf19c0183d6ea4e8dab6eabd40994e351c8.tar.gz kdepimpi-da264cf19c0183d6ea4e8dab6eabd40994e351c8.tar.bz2 |
fixxx
-rw-r--r-- | korganizer/journalentry.cpp | 39 | ||||
-rw-r--r-- | korganizer/journalentry.h | 3 | ||||
-rw-r--r-- | korganizer/kojournalview.cpp | 6 |
3 files changed, 15 insertions, 33 deletions
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp index 58863fe..add874f 100644 --- a/korganizer/journalentry.cpp +++ b/korganizer/journalentry.cpp @@ -40,89 +40,86 @@ #include <klocale.h> #include <ktextedit.h> #include <kfiledialog.h> #include <kmessagebox.h> #include "koprefs.h" #include <klineedit.h> #include <libkcal/journal.h> #include <libkcal/calendarresources.h> #include <libkcal/resourcecalendar.h> #include <kresources/resourceselectdialog.h> #include "journalentry.h" //#include "journalentry.moc" #ifndef DESKTOP_VERSION #include <qpe/qpeapplication.h> #endif JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : QFrame(parent) { heiHint = QApplication::desktop()->height() / 5 ; showOnlyMode = false; mCalendar = calendar; mJournal = 0; - mDirty = false; QHBox * vb = new QHBox ( this ); - QIconSet icon; + QPixmap iconp; QPushButton * toggleJournal = new QPushButton( vb ); - icon = SmallIcon("1updownarrow"); - toggleJournal->setIconSet (icon ) ; + iconp = SmallIcon("1updownarrow"); + toggleJournal->setPixmap (iconp ) ; new QLabel(i18n(" Title: "),vb); mTitle = new KLineEdit ( vb ); mTitleLabel = new QLabel(i18n("Title"),vb); mTitleLabel->setMargin(0); mTitleLabel->setAlignment(AlignCenter); QPushButton * loadTemplate = new QPushButton( vb ); QPushButton * saveTemplate = new QPushButton( vb ); if ( QApplication::desktop()->width() < 321 ) - icon = SmallIcon("fileexport16"); + iconp = SmallIcon("fileexport16"); else - icon = SmallIcon("fileexport"); - saveTemplate->setIconSet (icon ) ; + iconp = SmallIcon("fileexport"); + saveTemplate->setPixmap (iconp ) ; int size = saveTemplate->sizeHint().height(); if ( QApplication::desktop()->width() < 321 ) - icon = SmallIcon("fileimport16"); + iconp = SmallIcon("fileimport16"); else - icon = SmallIcon("fileimport"); - loadTemplate->setIconSet (icon ) ; + iconp = SmallIcon("fileimport"); + loadTemplate->setPixmap (iconp ) ; loadTemplate->setFixedSize( size, size ); saveTemplate->setFixedSize( size, size ); toggleJournal->setFixedSize( size , size ); mEditor = new KTextEdit(this); - connect(mEditor,SIGNAL(textChanged()),SLOT(setDirty())); #ifndef DESKTOP_VERSION QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold ); #endif mEditor->setWordWrap( KTextEdit::WidgetWidth ); QBoxLayout *topLayout = new QVBoxLayout(this); topLayout->addWidget(vb); topLayout->addWidget(mEditor); mEditor->installEventFilter(this); connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); - connect( mTitle, SIGNAL( textChanged ( const QString & ) ), this , SLOT( setDirty() ) ); connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) ); } JournalEntry::~JournalEntry() { //qDebug("JournalEntry::~JournalEntry() "); } 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; QFile fileIn( fileName ); @@ -140,146 +137,132 @@ void JournalEntry::slotSaveTemplate() 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 ); - setDirty(); } void JournalEntry::setDate(const QDate &date) { showOnlyMode = false; mDate = date; writeJournal(); int id = mCalendar->defaultCalendar(); QString calname = KOPrefs::instance()->getCalendar( id )->mName; mTitleLabel->setText( " (" + calname +")"); } void JournalEntry::toggleShowJournal() { flushEntry(); if ( showOnlyMode ) emit showJournalOnly( 0 ); else emit showJournalOnly( mJournal ); } void JournalEntry::setShowOnly() { showOnlyMode = true; mEditor->setFocus(); } void JournalEntry::setJournal(Journal *journal) { writeJournal(); mJournal = journal; if ( journal->isReadOnly() ) mTitle->setText(mJournal->summary()+" ("+i18n("readonly")+")"); else mTitle->setText(mJournal->summary()); mEditor->setText(mJournal->description()); mTitle->setReadOnly (journal->isReadOnly() ); mEditor->setReadOnly ( journal->isReadOnly() ); int id = mJournal->calID(); QString calname = KOPrefs::instance()->getCalendar( id )->mName; mTitleLabel->setText( " (" + calname +")"); - mDirty = false; } Journal *JournalEntry::journal() const { return mJournal; } -void JournalEntry::setDirty() -{ - mDirty = true; - -// kdDebug() << "JournalEntry::setDirty()" << endl; -} void JournalEntry::clear() { mJournal = 0; mEditor->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; if ( k->state() == Qt::ControlButton ) { k->ignore(); //return true; } } return QFrame::eventFilter( o, e ); // standard event processing } void JournalEntry::writeJournal() { -// kdDebug() << "JournalEntry::writeJournal()" << endl; - if (!mDirty) return; - if (mEditor->text().isEmpty()) { + if (mEditor->text().isEmpty() && mTitle->text().isEmpty()) { if ( mJournal ) { - mDirty = false; bool conf = KOPrefs::instance()->mConfirm; KOPrefs::instance()->mConfirm = false; emit deleteJournal(mJournal); KOPrefs::instance()->mConfirm = conf; mJournal = 0; } return; } // kdDebug() << "JournalEntry::writeJournal()..." << endl; if (!mJournal) { mJournal = new Journal; mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); mCalendar->addJournal(mJournal); } mJournal->setDescription(mEditor->text()); mJournal->setSummary(mTitle->text()); - mDirty = false; } void JournalEntry::flushEntry() { - if (!mDirty) return; - - writeJournal(); + writeJournal(); } void JournalEntry::keyPressEvent ( QKeyEvent * e ) { e->ignore(); } diff --git a/korganizer/journalentry.h b/korganizer/journalentry.h index b37cabd..f2db785 100644 --- a/korganizer/journalentry.h +++ b/korganizer/journalentry.h @@ -34,51 +34,48 @@ class KTextEdit; class KLineEdit; using namespace KCal; class JournalEntry : public QFrame { Q_OBJECT public: JournalEntry(Calendar *,QWidget *parent); virtual ~JournalEntry(); void setJournal(Journal *); Journal *journal() const; void setDate(const QDate &); void clear(); void flushEntry(); void setShowOnly(); QSize sizeHint() const; protected slots: void slotSaveTemplate(); void slotLoadTemplate(); - void setDirty(); void toggleShowJournal(); signals: void deleteJournal(Journal *); void newJournal(); void showJournalOnly( Journal * ); protected: bool eventFilter( QObject *o, QEvent *e ); void writeJournal(); private: bool showOnlyMode; Calendar *mCalendar; Journal *mJournal; QDate mDate; void keyPressEvent ( QKeyEvent * ) ; QLabel *mTitleLabel; KLineEdit * mTitle; KTextEdit *mEditor; int heiHint; - - bool mDirty; }; #endif diff --git a/korganizer/kojournalview.cpp b/korganizer/kojournalview.cpp index ff87ef4..cb9a2c0 100644 --- a/korganizer/kojournalview.cpp +++ b/korganizer/kojournalview.cpp @@ -38,54 +38,54 @@ #include "koprefs.h" #include <kglobal.h> #include <libkcal/calendar.h> #include "journalentry.h" #include "kojournalview.h" using namespace KOrg; KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent, const char *name) : KOrg::BaseView(calendar, parent, name) { mCalendar = calendar; QScrollView * sv = new QScrollView( this ); QHBoxLayout * hbl = new QHBoxLayout( this ); hbl->addWidget( sv ); parWid = new QWidget( sv->viewport() ); sv->addChild(parWid); sv->setResizePolicy( QScrollView:: AutoOneFit ); mTopLayout = new QVBoxLayout(parWid); QHBox * vb = new QHBox ( parWid ); QPushButton * newJournal = new QPushButton( vb ); - QIconSet icon; + QPixmap icon; if ( QApplication::desktop()->width() < 321 ) icon = SmallIcon("ko16old"); else icon = SmallIcon("ko24old"); - newJournal->setIconSet (icon ) ; + newJournal->setPixmap (icon ) ; int size = newJournal->sizeHint().height(); newJournal->setFixedSize( size, size ); mDateLabel = new QLabel ( vb ); mTopLayout->addWidget( vb ); mDateLabel->setMargin(1); mDateLabel->setAlignment(AlignCenter); connect( newJournal, SIGNAL( clicked() ), this , SLOT( newJournal() ) ); getNewEntry(); } KOJournalView::~KOJournalView() { } int KOJournalView::currentDateCount() { return 0; } JournalEntry* KOJournalView::getNewEntry() { JournalEntry* Entry = new JournalEntry(mCalendar,parWid); jEntries.append( Entry ); mTopLayout->addWidget(Entry); Entry->setFont ( KOPrefs::instance()->mJornalViewFont ); @@ -117,56 +117,58 @@ void KOJournalView::updateView() mEntry = jEntries.next(); } showDates( mDate, QDate() ); } void KOJournalView::flushView() { JournalEntry* mEntry = jEntries.first(); while ( mEntry ) { mEntry->flushEntry(); mEntry = jEntries.next(); } } void KOJournalView::clearList() { JournalEntry* mEntry = jEntries.first(); while ( mEntry ) { mEntry->clear(); mEntry = jEntries.next(); } } void KOJournalView::newJournal() { + flushView(); Journal* mJournal = new Journal; mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); mCalendar->addJournal(mJournal); showDates( mDate, QDate() ); } void KOJournalView::showOnly ( Journal* j ) { + flushView(); if ( j == 0 ) { showDates( mDate, QDate() ); return; } QPtrList<Journal> jl; jl.append ( j ); showList( jl ); JournalEntry* mEntry = jEntries.first(); mEntry->setShowOnly(); } void KOJournalView::showList(QPtrList<Journal> jl) { JournalEntry* mEntry = jEntries.first(); JournalEntry* firstEntry = mEntry; int count = jl.count(); int iii = 0; while ( iii < count ) { if ( !mEntry ) { mEntry = getNewEntry(); mEntry->show(); mEntry->setDate(mDate); mEntry->setJournal(jl.at(iii)); mEntry = 0; } else { |