summaryrefslogtreecommitdiffabout
path: root/korganizer/journalentry.cpp
authorzautrix <zautrix>2005-06-30 05:32:10 (UTC)
committer zautrix <zautrix>2005-06-30 05:32:10 (UTC)
commitda264cf19c0183d6ea4e8dab6eabd40994e351c8 (patch) (unidiff)
tree061026fe6869c365641853b1ebba542b852046bc /korganizer/journalentry.cpp
parent4e850fa7aa99f92676e49466cfccaa5d5e0ec24c (diff)
downloadkdepimpi-da264cf19c0183d6ea4e8dab6eabd40994e351c8.zip
kdepimpi-da264cf19c0183d6ea4e8dab6eabd40994e351c8.tar.gz
kdepimpi-da264cf19c0183d6ea4e8dab6eabd40994e351c8.tar.bz2
fixxx
Diffstat (limited to 'korganizer/journalentry.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/journalentry.cpp39
1 files changed, 11 insertions, 28 deletions
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp
index 58863fe..add874f 100644
--- a/korganizer/journalentry.cpp
+++ b/korganizer/journalentry.cpp
@@ -52,65 +52,62 @@
52#include "journalentry.h" 52#include "journalentry.h"
53//#include "journalentry.moc" 53//#include "journalentry.moc"
54#ifndef DESKTOP_VERSION 54#ifndef DESKTOP_VERSION
55#include <qpe/qpeapplication.h> 55#include <qpe/qpeapplication.h>
56#endif 56#endif
57JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : 57JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) :
58 QFrame(parent) 58 QFrame(parent)
59{ 59{
60 heiHint = QApplication::desktop()->height() / 5 ; 60 heiHint = QApplication::desktop()->height() / 5 ;
61 showOnlyMode = false; 61 showOnlyMode = false;
62 mCalendar = calendar; 62 mCalendar = calendar;
63 mJournal = 0; 63 mJournal = 0;
64 mDirty = false;
65 64
66 QHBox * vb = new QHBox ( this ); 65 QHBox * vb = new QHBox ( this );
67 QIconSet icon; 66 QPixmap iconp;
68 67
69 QPushButton * toggleJournal = new QPushButton( vb ); 68 QPushButton * toggleJournal = new QPushButton( vb );
70 icon = SmallIcon("1updownarrow"); 69 iconp = SmallIcon("1updownarrow");
71 toggleJournal->setIconSet (icon ) ; 70 toggleJournal->setPixmap (iconp ) ;
72 new QLabel(i18n(" Title: "),vb); 71 new QLabel(i18n(" Title: "),vb);
73 mTitle = new KLineEdit ( vb ); 72 mTitle = new KLineEdit ( vb );
74 mTitleLabel = new QLabel(i18n("Title"),vb); 73 mTitleLabel = new QLabel(i18n("Title"),vb);
75 mTitleLabel->setMargin(0); 74 mTitleLabel->setMargin(0);
76 mTitleLabel->setAlignment(AlignCenter); 75 mTitleLabel->setAlignment(AlignCenter);
77 QPushButton * loadTemplate = new QPushButton( vb ); 76 QPushButton * loadTemplate = new QPushButton( vb );
78 QPushButton * saveTemplate = new QPushButton( vb ); 77 QPushButton * saveTemplate = new QPushButton( vb );
79 if ( QApplication::desktop()->width() < 321 ) 78 if ( QApplication::desktop()->width() < 321 )
80 icon = SmallIcon("fileexport16"); 79 iconp = SmallIcon("fileexport16");
81 else 80 else
82 icon = SmallIcon("fileexport"); 81 iconp = SmallIcon("fileexport");
83 saveTemplate->setIconSet (icon ) ; 82 saveTemplate->setPixmap (iconp ) ;
84 int size = saveTemplate->sizeHint().height(); 83 int size = saveTemplate->sizeHint().height();
85 if ( QApplication::desktop()->width() < 321 ) 84 if ( QApplication::desktop()->width() < 321 )
86 icon = SmallIcon("fileimport16"); 85 iconp = SmallIcon("fileimport16");
87 else 86 else
88 icon = SmallIcon("fileimport"); 87 iconp = SmallIcon("fileimport");
89 loadTemplate->setIconSet (icon ) ; 88 loadTemplate->setPixmap (iconp ) ;
90 loadTemplate->setFixedSize( size, size ); 89 loadTemplate->setFixedSize( size, size );
91 saveTemplate->setFixedSize( size, size ); 90 saveTemplate->setFixedSize( size, size );
92 toggleJournal->setFixedSize( size , size ); 91 toggleJournal->setFixedSize( size , size );
93 mEditor = new KTextEdit(this); 92 mEditor = new KTextEdit(this);
94 connect(mEditor,SIGNAL(textChanged()),SLOT(setDirty()));
95#ifndef DESKTOP_VERSION 93#ifndef DESKTOP_VERSION
96 QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold ); 94 QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold );
97#endif 95#endif
98 mEditor->setWordWrap( KTextEdit::WidgetWidth ); 96 mEditor->setWordWrap( KTextEdit::WidgetWidth );
99 QBoxLayout *topLayout = new QVBoxLayout(this); 97 QBoxLayout *topLayout = new QVBoxLayout(this);
100 topLayout->addWidget(vb); 98 topLayout->addWidget(vb);
101 topLayout->addWidget(mEditor); 99 topLayout->addWidget(mEditor);
102 mEditor->installEventFilter(this); 100 mEditor->installEventFilter(this);
103 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); 101 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) );
104 connect( mTitle, SIGNAL( textChanged ( const QString & ) ), this , SLOT( setDirty() ) );
105 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); 102 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) );
106 connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) ); 103 connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) );
107} 104}
108 105
109JournalEntry::~JournalEntry() 106JournalEntry::~JournalEntry()
110{ 107{
111 //qDebug("JournalEntry::~JournalEntry() "); 108 //qDebug("JournalEntry::~JournalEntry() ");
112} 109}
113QSize JournalEntry::sizeHint() const 110QSize JournalEntry::sizeHint() const
114{ 111{
115 return QSize ( 240, heiHint ); 112 return QSize ( 240, heiHint );
116} 113}
@@ -152,25 +149,24 @@ void JournalEntry::slotLoadTemplate()
152 KMessageBox::error( this, i18n("Error loading template file\n '%1'.") 149 KMessageBox::error( this, i18n("Error loading template file\n '%1'.")
153 .arg( fileName ) ); 150 .arg( fileName ) );
154 return; 151 return;
155 } 152 }
156 QTextStream tsIn( &fileIn ); 153 QTextStream tsIn( &fileIn );
157 tsIn.setCodec( QTextCodec::codecForName("utf8") ); 154 tsIn.setCodec( QTextCodec::codecForName("utf8") );
158 QString text = tsIn.read(); 155 QString text = tsIn.read();
159 fileIn.close(); 156 fileIn.close();
160 int line, col; 157 int line, col;
161 mEditor->getCursorPosition (& line, & col ); 158 mEditor->getCursorPosition (& line, & col );
162 mEditor-> insertAt ( text, line, col, true ); 159 mEditor-> insertAt ( text, line, col, true );
163 //mEditor->setIgnoreMark( true ); 160 //mEditor->setIgnoreMark( true );
164 setDirty();
165} 161}
166void JournalEntry::setDate(const QDate &date) 162void JournalEntry::setDate(const QDate &date)
167{ 163{
168 showOnlyMode = false; 164 showOnlyMode = false;
169 mDate = date; 165 mDate = date;
170 writeJournal(); 166 writeJournal();
171 int id = mCalendar->defaultCalendar(); 167 int id = mCalendar->defaultCalendar();
172 QString calname = KOPrefs::instance()->getCalendar( id )->mName; 168 QString calname = KOPrefs::instance()->getCalendar( id )->mName;
173 mTitleLabel->setText( " (" + calname +")"); 169 mTitleLabel->setText( " (" + calname +")");
174} 170}
175 171
176void JournalEntry::toggleShowJournal() 172void JournalEntry::toggleShowJournal()
@@ -194,38 +190,31 @@ void JournalEntry::setJournal(Journal *journal)
194 if ( journal->isReadOnly() ) 190 if ( journal->isReadOnly() )
195 mTitle->setText(mJournal->summary()+" ("+i18n("readonly")+")"); 191 mTitle->setText(mJournal->summary()+" ("+i18n("readonly")+")");
196 else 192 else
197 mTitle->setText(mJournal->summary()); 193 mTitle->setText(mJournal->summary());
198 mEditor->setText(mJournal->description()); 194 mEditor->setText(mJournal->description());
199 mTitle->setReadOnly (journal->isReadOnly() ); 195 mTitle->setReadOnly (journal->isReadOnly() );
200 mEditor->setReadOnly ( journal->isReadOnly() ); 196 mEditor->setReadOnly ( journal->isReadOnly() );
201 int id = mJournal->calID(); 197 int id = mJournal->calID();
202 198
203 QString calname = KOPrefs::instance()->getCalendar( id )->mName; 199 QString calname = KOPrefs::instance()->getCalendar( id )->mName;
204 mTitleLabel->setText( " (" + calname +")"); 200 mTitleLabel->setText( " (" + calname +")");
205 201
206 mDirty = false;
207} 202}
208 203
209Journal *JournalEntry::journal() const 204Journal *JournalEntry::journal() const
210{ 205{
211 return mJournal; 206 return mJournal;
212} 207}
213 208
214void JournalEntry::setDirty()
215{
216 mDirty = true;
217
218// kdDebug() << "JournalEntry::setDirty()" << endl;
219}
220 209
221void JournalEntry::clear() 210void JournalEntry::clear()
222{ 211{
223 mJournal = 0; 212 mJournal = 0;
224 mEditor->setText(""); 213 mEditor->setText("");
225} 214}
226 215
227bool JournalEntry::eventFilter( QObject *o, QEvent *e ) 216bool JournalEntry::eventFilter( QObject *o, QEvent *e )
228{ 217{
229// kdDebug() << "JournalEntry::event received " << e->type() << endl; 218// kdDebug() << "JournalEntry::event received " << e->type() << endl;
230 219
231 if ( e->type() == QEvent::FocusOut ) { 220 if ( e->type() == QEvent::FocusOut ) {
@@ -235,51 +224,45 @@ bool JournalEntry::eventFilter( QObject *o, QEvent *e )
235 QKeyEvent * k = (QKeyEvent *) e; 224 QKeyEvent * k = (QKeyEvent *) e;
236 if ( k->state() == Qt::ControlButton ) { 225 if ( k->state() == Qt::ControlButton ) {
237 k->ignore(); 226 k->ignore();
238 //return true; 227 //return true;
239 } 228 }
240 } 229 }
241 230
242 return QFrame::eventFilter( o, e ); // standard event processing 231 return QFrame::eventFilter( o, e ); // standard event processing
243} 232}
244 233
245void JournalEntry::writeJournal() 234void JournalEntry::writeJournal()
246{ 235{
247// kdDebug() << "JournalEntry::writeJournal()" << endl;
248 if (!mDirty) return;
249 236
250 if (mEditor->text().isEmpty()) { 237 if (mEditor->text().isEmpty() && mTitle->text().isEmpty()) {
251 if ( mJournal ) { 238 if ( mJournal ) {
252 mDirty = false;
253 bool conf = KOPrefs::instance()->mConfirm; 239 bool conf = KOPrefs::instance()->mConfirm;
254 KOPrefs::instance()->mConfirm = false; 240 KOPrefs::instance()->mConfirm = false;
255 emit deleteJournal(mJournal); 241 emit deleteJournal(mJournal);
256 KOPrefs::instance()->mConfirm = conf; 242 KOPrefs::instance()->mConfirm = conf;
257 mJournal = 0; 243 mJournal = 0;
258 } 244 }
259 return; 245 return;
260 } 246 }
261 247
262// kdDebug() << "JournalEntry::writeJournal()..." << endl; 248// kdDebug() << "JournalEntry::writeJournal()..." << endl;
263 249
264 if (!mJournal) { 250 if (!mJournal) {
265 mJournal = new Journal; 251 mJournal = new Journal;
266 mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); 252 mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0)));
267 mCalendar->addJournal(mJournal); 253 mCalendar->addJournal(mJournal);
268 } 254 }
269 255
270 mJournal->setDescription(mEditor->text()); 256 mJournal->setDescription(mEditor->text());
271 mJournal->setSummary(mTitle->text()); 257 mJournal->setSummary(mTitle->text());
272 mDirty = false;
273} 258}
274 259
275void JournalEntry::flushEntry() 260void JournalEntry::flushEntry()
276{ 261{
277 if (!mDirty) return; 262 writeJournal();
278
279 writeJournal();
280} 263}
281void JournalEntry::keyPressEvent ( QKeyEvent * e ) 264void JournalEntry::keyPressEvent ( QKeyEvent * e )
282{ 265{
283 e->ignore(); 266 e->ignore();
284 267
285} 268}