summaryrefslogtreecommitdiffabout
path: root/korganizer/journalentry.cpp
authorMichael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
committer Michael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
commita08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff)
tree8ee90d686081c52e7c69b5ce946e9b1a7d690001 /korganizer/journalentry.cpp
parent11edc920afe4f274c0964436633aa632c8288a40 (diff)
downloadkdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2
initial public commit of qt4 portp1
Diffstat (limited to 'korganizer/journalentry.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/journalentry.cpp39
1 files changed, 23 insertions, 16 deletions
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp
index 5269af7..2814c61 100644
--- a/korganizer/journalentry.cpp
+++ b/korganizer/journalentry.cpp
@@ -23,20 +23,27 @@
23 23
24// 24//
25// Journal Entry 25// Journal Entry
26 26
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qvbox.h> 29#include <q3vbox.h>
30#include <qfile.h> 30#include <qfile.h>
31#include <qdir.h> 31#include <qdir.h>
32#include <qtextstream.h> 32#include <q3textstream.h>
33#include <qtextcodec.h> 33#include <qtextcodec.h>
34#include <qpixmap.h> 34#include <qpixmap.h>
35#include <qpushbutton.h> 35#include <qpushbutton.h>
36#include <qapplication.h> 36#include <qapplication.h>
37#include <QDesktopWidget>
38//Added by qt3to4:
39#include <QResizeEvent>
40#include <Q3Frame>
41#include <QKeyEvent>
42#include <QEvent>
43#include <Q3VBoxLayout>
37 44
38#include <kdebug.h> 45#include <kdebug.h>
39#include <kglobal.h> 46#include <kglobal.h>
40#include <klocale.h> 47#include <klocale.h>
41#include <ktextedit.h> 48#include <ktextedit.h>
42#include <kfiledialog.h> 49#include <kfiledialog.h>
@@ -54,26 +61,26 @@
54#include "journalentry.h" 61#include "journalentry.h"
55//#include "journalentry.moc" 62//#include "journalentry.moc"
56#ifndef DESKTOP_VERSION 63#ifndef DESKTOP_VERSION
57#include <qpe/qpeapplication.h> 64#include <qpe/qpeapplication.h>
58#endif 65#endif
59JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : 66JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) :
60 QFrame(parent) 67 Q3Frame(parent)
61{ 68{
62 69
63 int fac = 5; 70 int fac = 5;
64 heiHint = QApplication::desktop()->height(); 71 heiHint = QApplication::desktop()->height();
65 if ( heiHint > 800 ) 72 if ( heiHint > 800 )
66 fac += 2; 73 fac += 2;
67 heiHint = heiHint / fac; 74 heiHint = heiHint / fac;
68 75
69 showOnlyMode = false; 76 showOnlyMode = false;
70 mCalendar = calendar; 77 mCalendar = calendar;
71 mJournal = 0; 78 mJournal = 0;
72 visibleMode = true; 79 visibleMode = true;
73 QHBox * vb = new QHBox ( this ); 80 Q3HBox * vb = new Q3HBox ( this );
74 QPixmap iconp; 81 QPixmap iconp;
75 vb->setMargin ( KDialog::marginHint()-1 ); 82 vb->setMargin ( KDialog::marginHint()-1 );
76 QPushButton * toggleJournal = new QPushButton( vb ); 83 QPushButton * toggleJournal = new QPushButton( vb );
77 iconp = SmallIcon("1updownarrow"); 84 iconp = SmallIcon("1updownarrow");
78 toggleJournal->setPixmap (iconp ) ; 85 toggleJournal->setPixmap (iconp ) ;
79 QLabel* textLabel = new QLabel(" "+i18n("Title: "),vb); 86 QLabel* textLabel = new QLabel(" "+i18n("Title: "),vb);
@@ -126,19 +133,19 @@ JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) :
126 } else { 133 } else {
127 mTitle->setMaximumWidth( (maxwid/4)*3); 134 mTitle->setMaximumWidth( (maxwid/4)*3);
128 mCalendarBox->setMaximumWidth( maxwid/2 ); 135 mCalendarBox->setMaximumWidth( maxwid/2 );
129 } 136 }
130 //mCalendarBox->setMaximumWidth( maxwid/2 -20 ); 137 //mCalendarBox->setMaximumWidth( maxwid/2 -20 );
131 mEditor->setWordWrap( KTextEdit::WidgetWidth ); 138 mEditor->setWordWrap( KTextEdit::WidgetWidth );
132 QBoxLayout *topLayout = new QVBoxLayout(this); 139 Q3BoxLayout *topLayout = new Q3VBoxLayout(this);
133 topLayout->addWidget(vb); 140 topLayout->addWidget(vb);
134 topLayout->addWidget(mEditor); 141 topLayout->addWidget(mEditor);
135 mEditor->installEventFilter(this); 142 mEditor->installEventFilter(this);
136 installEventFilter(this); 143 installEventFilter(this);
137 mTitle->installEventFilter(this); 144 mTitle->installEventFilter(this);
138 setFocusPolicy (QWidget::NoFocus); 145 setFocusPolicy (Qt::NoFocus);
139 146
140 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); 147 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) );
141 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); 148 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) );
142 connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) ); 149 connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) );
143 mTitle->load( KOLocationBox::SUMMARYJOURNAL ); 150 mTitle->load( KOLocationBox::SUMMARYJOURNAL );
144 mTitle->lineEdit ()->setText(""); 151 mTitle->lineEdit ()->setText("");
@@ -165,13 +172,13 @@ void JournalEntry::resizeEvent(QResizeEvent* e )
165 } 172 }
166 //mCalendarBox->setMaximumWidth( maxwid/2 -20 ); 173 //mCalendarBox->setMaximumWidth( maxwid/2 -20 );
167 } 174 }
168 //setMaximumWidth( QApplication::desktop()->width() ); 175 //setMaximumWidth( QApplication::desktop()->width() );
169 //qDebug("MAXXX %d ", QApplication::desktop()->width()); 176 //qDebug("MAXXX %d ", QApplication::desktop()->width());
170#endif 177#endif
171 QFrame::resizeEvent( e ); 178 Q3Frame::resizeEvent( e );
172} 179}
173QSize JournalEntry::sizeHint() const 180QSize JournalEntry::sizeHint() const
174{ 181{
175 return QSize ( 240, heiHint ); 182 return QSize ( 240, heiHint );
176} 183}
177void JournalEntry::slotSaveTemplate() 184void JournalEntry::slotSaveTemplate()
@@ -183,19 +190,19 @@ void JournalEntry::slotSaveTemplate()
183 fileName += "/journal"; 190 fileName += "/journal";
184 fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Journal template"), this ); 191 fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Journal template"), this );
185 if ( fileName.length() == 0 ) 192 if ( fileName.length() == 0 )
186 return; 193 return;
187 194
188 QFile fileIn( fileName ); 195 QFile fileIn( fileName );
189 if (!fileIn.open( IO_WriteOnly ) ) { 196 if (!fileIn.open( QIODevice::WriteOnly ) ) {
190 KMessageBox::error( this, i18n("Error saving template file\n '%1'.") 197 KMessageBox::error( this, i18n("Error saving template file\n '%1'.")
191 .arg( fileName ) ); 198 .arg( fileName ) );
192 return; 199 return;
193 } 200 }
194 // QString text; 201 // QString text;
195 QTextStream tsIn( &fileIn ); 202 Q3TextStream tsIn( &fileIn );
196 tsIn.setCodec( QTextCodec::codecForName("utf8") ); 203 tsIn.setCodec( QTextCodec::codecForName("utf8") );
197 tsIn << mEditor->text(); 204 tsIn << mEditor->text();
198 fileIn.close(); 205 fileIn.close();
199} 206}
200void JournalEntry::slotLoadTemplate() 207void JournalEntry::slotLoadTemplate()
201{ 208{
@@ -205,18 +212,18 @@ void JournalEntry::slotLoadTemplate()
205 t_dir.mkdir ( fileName ); 212 t_dir.mkdir ( fileName );
206 fileName += "/journal"; 213 fileName += "/journal";
207 fileName = KFileDialog::getOpenFileName( fileName , i18n("Insert Journal template"), this ); 214 fileName = KFileDialog::getOpenFileName( fileName , i18n("Insert Journal template"), this );
208 if ( fileName.length() == 0 ) 215 if ( fileName.length() == 0 )
209 return; 216 return;
210 QFile fileIn( fileName ); 217 QFile fileIn( fileName );
211 if (!fileIn.open( IO_ReadOnly ) ) { 218 if (!fileIn.open( QIODevice::ReadOnly ) ) {
212 KMessageBox::error( this, i18n("Error loading template file\n '%1'.") 219 KMessageBox::error( this, i18n("Error loading template file\n '%1'.")
213 .arg( fileName ) ); 220 .arg( fileName ) );
214 return; 221 return;
215 } 222 }
216 QTextStream tsIn( &fileIn ); 223 Q3TextStream tsIn( &fileIn );
217 tsIn.setCodec( QTextCodec::codecForName("utf8") ); 224 tsIn.setCodec( QTextCodec::codecForName("utf8") );
218 QString text = tsIn.read(); 225 QString text = tsIn.read();
219 fileIn.close(); 226 fileIn.close();
220 int line, col; 227 int line, col;
221 mEditor->getCursorPosition (& line, & col ); 228 mEditor->getCursorPosition (& line, & col );
222 mEditor-> insertAt ( text, line, col, true ); 229 mEditor-> insertAt ( text, line, col, true );
@@ -313,17 +320,17 @@ void JournalEntry::clear()
313} 320}
314 321
315bool JournalEntry::eventFilter( QObject *o, QEvent *e ) 322bool JournalEntry::eventFilter( QObject *o, QEvent *e )
316{ 323{
317// kdDebug() << "JournalEntry::event received " << e->type() << endl; 324// kdDebug() << "JournalEntry::event received " << e->type() << endl;
318 if ( isVisible() ) { 325 if ( isVisible() ) {
319 mEditor->setFocusPolicy (QWidget::StrongFocus); 326 mEditor->setFocusPolicy (Qt::StrongFocus);
320 mTitle->setFocusPolicy (QWidget::StrongFocus); 327 mTitle->setFocusPolicy (Qt::StrongFocus);
321 } else { 328 } else {
322 mEditor->setFocusPolicy (QWidget::NoFocus); 329 mEditor->setFocusPolicy (Qt::NoFocus);
323 mTitle->setFocusPolicy (QWidget::NoFocus); 330 mTitle->setFocusPolicy (Qt::NoFocus);
324 } 331 }
325 if ( e->type() == QEvent::FocusOut ) { 332 if ( e->type() == QEvent::FocusOut ) {
326 writeJournal(); 333 writeJournal();
327 } 334 }
328 if ( e->type() == QEvent::KeyPress ) { 335 if ( e->type() == QEvent::KeyPress ) {
329 QKeyEvent * k = (QKeyEvent *) e; 336 QKeyEvent * k = (QKeyEvent *) e;
@@ -332,13 +339,13 @@ bool JournalEntry::eventFilter( QObject *o, QEvent *e )
332 if ( k->state() == Qt::ControlButton ) { 339 if ( k->state() == Qt::ControlButton ) {
333 k->ignore(); 340 k->ignore();
334 //return true; 341 //return true;
335 } 342 }
336 } 343 }
337 344
338 return QFrame::eventFilter( o, e ); // standard event processing 345 return Q3Frame::eventFilter( o, e ); // standard event processing
339} 346}
340 347
341void JournalEntry::writeJournal() 348void JournalEntry::writeJournal()
342{ 349{
343 if ( !visibleMode ) return; 350 if ( !visibleMode ) return;
344 if ( !mTitle->isEnabled() ) return; 351 if ( !mTitle->isEnabled() ) return;