summaryrefslogtreecommitdiffabout
path: root/korganizer/journalentry.cpp
authorzautrix <zautrix>2005-07-09 08:48:32 (UTC)
committer zautrix <zautrix>2005-07-09 08:48:32 (UTC)
commitf731dd9fc5b3f14c44d4de26eb5370a79c63887c (patch) (unidiff)
treee3d7b3929cc8819a5451bd04c9698bc0767e49b1 /korganizer/journalentry.cpp
parente27ad31c6016152449bbdaf4f9f387fa61183c37 (diff)
downloadkdepimpi-f731dd9fc5b3f14c44d4de26eb5370a79c63887c.zip
kdepimpi-f731dd9fc5b3f14c44d4de26eb5370a79c63887c.tar.gz
kdepimpi-f731dd9fc5b3f14c44d4de26eb5370a79c63887c.tar.bz2
fixi
Diffstat (limited to 'korganizer/journalentry.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/journalentry.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp
index b8a4cf2..f0e0f86 100644
--- a/korganizer/journalentry.cpp
+++ b/korganizer/journalentry.cpp
@@ -31,148 +31,168 @@
31#include <qdir.h> 31#include <qdir.h>
32#include <qtextstream.h> 32#include <qtextstream.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 37
38#include <kdebug.h> 38#include <kdebug.h>
39#include <kglobal.h> 39#include <kglobal.h>
40#include <klocale.h> 40#include <klocale.h>
41#include <ktextedit.h> 41#include <ktextedit.h>
42#include <kfiledialog.h> 42#include <kfiledialog.h>
43#include <kmessagebox.h> 43#include <kmessagebox.h>
44#include "koprefs.h" 44#include "koprefs.h"
45#include <klineedit.h> 45#include <klineedit.h>
46#include <kdialog.h> 46#include <kdialog.h>
47#include "kolocationbox.h" 47#include "kolocationbox.h"
48 48
49#include <libkcal/journal.h> 49#include <libkcal/journal.h>
50#include <libkcal/calendarresources.h> 50#include <libkcal/calendarresources.h>
51#include <libkcal/resourcecalendar.h> 51#include <libkcal/resourcecalendar.h>
52#include <kresources/resourceselectdialog.h> 52#include <kresources/resourceselectdialog.h>
53 53
54#include "journalentry.h" 54#include "journalentry.h"
55//#include "journalentry.moc" 55//#include "journalentry.moc"
56#ifndef DESKTOP_VERSION 56#ifndef DESKTOP_VERSION
57#include <qpe/qpeapplication.h> 57#include <qpe/qpeapplication.h>
58#endif 58#endif
59JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : 59JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) :
60 QFrame(parent) 60 QFrame(parent)
61{ 61{
62 62
63 int fac = 5; 63 int fac = 5;
64 heiHint = QApplication::desktop()->height(); 64 heiHint = QApplication::desktop()->height();
65 if ( heiHint > 800 ) 65 if ( heiHint > 800 )
66 fac += 2; 66 fac += 2;
67 heiHint = heiHint / fac; 67 heiHint = heiHint / fac;
68 68
69 showOnlyMode = false; 69 showOnlyMode = false;
70 mCalendar = calendar; 70 mCalendar = calendar;
71 mJournal = 0; 71 mJournal = 0;
72 visibleMode = true; 72 visibleMode = true;
73 QHBox * vb = new QHBox ( this ); 73 QHBox * vb = new QHBox ( this );
74 QPixmap iconp; 74 QPixmap iconp;
75 vb->setMargin ( KDialog::marginHint()-1 ); 75 vb->setMargin ( KDialog::marginHint()-1 );
76 QPushButton * toggleJournal = new QPushButton( vb ); 76 QPushButton * toggleJournal = new QPushButton( vb );
77 iconp = SmallIcon("1updownarrow"); 77 iconp = SmallIcon("1updownarrow");
78 toggleJournal->setPixmap (iconp ) ; 78 toggleJournal->setPixmap (iconp ) ;
79 vb->setStretchFactor (new QLabel(" "+i18n("Title: "),vb),1); 79 QLabel* textLabel = new QLabel(" "+i18n("Title: "),vb);
80 vb->setStretchFactor (textLabel,1);
80 vb->setStretchFactor( toggleJournal, 1 ); 81 vb->setStretchFactor( toggleJournal, 1 );
81 mTitle = new KOLocationBox(TRUE, vb, 30); 82 mTitle = new KOLocationBox(TRUE, vb, 30);
82 mTitle->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding ,QSizePolicy::Fixed ,FALSE) ); 83 mTitle->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding ,QSizePolicy::Fixed ,FALSE) );
83 mCalendarBox = new QComboBox(vb); 84 mCalendarBox = new QComboBox(vb);
84 mCalendarBox->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding ,QSizePolicy::Fixed ,FALSE) ); 85 mCalendarBox->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding ,QSizePolicy::Fixed ,FALSE) );
85#ifndef DESKTOP_VERSION 86#ifndef DESKTOP_VERSION
86 mTitle->setSizeLimit( 8 ); 87 mTitle->setSizeLimit( 8 );
87 mCalendarBox->setSizeLimit( 8 ); 88 mCalendarBox->setSizeLimit( 8 );
88#endif 89#endif
89 vb->setStretchFactor ( mTitle, 8 ); 90 vb->setStretchFactor ( mTitle, 8 );
90 vb->setStretchFactor ( mCalendarBox, 3 ); 91 vb->setStretchFactor ( mCalendarBox, 3 );
91 //mTitleLabel->setMargin(0); 92 //mTitleLabel->setMargin(0);
92 //mTitleLabel->setAlignment(AlignCenter); 93 //mTitleLabel->setAlignment(AlignCenter);
93 QPushButton * loadTemplate = new QPushButton( vb ); 94 QPushButton * loadTemplate = new QPushButton( vb );
94 QPushButton * saveTemplate = new QPushButton( vb ); 95 QPushButton * saveTemplate = new QPushButton( vb );
95 if ( QApplication::desktop()->width() < 321 ) 96 if ( QApplication::desktop()->width() < 321 )
96 iconp = SmallIcon("fileexport16"); 97 iconp = SmallIcon("fileexport16");
97 else 98 else
98 iconp = SmallIcon("fileexport"); 99 iconp = SmallIcon("fileexport");
99 saveTemplate->setPixmap (iconp ) ; 100 saveTemplate->setPixmap (iconp ) ;
100 int size = saveTemplate->sizeHint().height(); 101 int size = saveTemplate->sizeHint().height();
101 if ( QApplication::desktop()->width() < 321 ) 102 if ( QApplication::desktop()->width() < 321 )
102 iconp = SmallIcon("fileimport16"); 103 iconp = SmallIcon("fileimport16");
103 else 104 else
104 iconp = SmallIcon("fileimport"); 105 iconp = SmallIcon("fileimport");
105 loadTemplate->setPixmap (iconp ) ; 106 loadTemplate->setPixmap (iconp ) ;
106 loadTemplate->setFixedSize( size, size ); 107 loadTemplate->setFixedSize( size, size );
107 saveTemplate->setFixedSize( size, size ); 108 saveTemplate->setFixedSize( size, size );
108 toggleJournal->setFixedSize( size , size ); 109 toggleJournal->setFixedSize( size , size );
109 mTitle->setFixedHeight( size+4); 110 mTitle->setFixedHeight( size+4);
110 mCalendarBox->setFixedHeight( size+4); 111 mCalendarBox->setFixedHeight( size+4);
111 mEditor = new KTextEdit(this); 112 mEditor = new KTextEdit(this);
112#ifndef DESKTOP_VERSION 113#ifndef DESKTOP_VERSION
113 QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold ); 114 QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold );
114#endif 115#endif
116 mMaxWidDiff = 3*size - 2*frameWidth() - textLabel->sizeHint().width();
117 mDeskWid = QApplication::desktop()->width();
118 int maxwid = mDeskWid - mMaxWidDiff;
119 mTitle->setMaximumWidth( maxwid/2 +20 );
120 mCalendarBox->setMaximumWidth( maxwid/2 -20 );
115 mEditor->setWordWrap( KTextEdit::WidgetWidth ); 121 mEditor->setWordWrap( KTextEdit::WidgetWidth );
116 QBoxLayout *topLayout = new QVBoxLayout(this); 122 QBoxLayout *topLayout = new QVBoxLayout(this);
117 topLayout->addWidget(vb); 123 topLayout->addWidget(vb);
118 topLayout->addWidget(mEditor); 124 topLayout->addWidget(mEditor);
119 mEditor->installEventFilter(this); 125 mEditor->installEventFilter(this);
120 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); 126 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) );
121 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); 127 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) );
122 connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) ); 128 connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) );
123 mTitle->load( KOLocationBox::SUMMARYJOURNAL ); 129 mTitle->load( KOLocationBox::SUMMARYJOURNAL );
124 mTitle->lineEdit ()->setText(""); 130 mTitle->lineEdit ()->setText("");
125} 131}
126 132
127JournalEntry::~JournalEntry() 133JournalEntry::~JournalEntry()
128{ 134{
129 //qDebug("JournalEntry::~JournalEntry() "); 135 //qDebug("JournalEntry::~JournalEntry() ");
130} 136}
137void JournalEntry::resizeEvent(QResizeEvent* e )
138{
139#ifndef DESKTOP_VERSION
140 if ( mDeskWid != QApplication::desktop()->width() ) {
141 mDeskWid == QApplication::desktop()->width();
142 int maxwid = mDeskWid - mMaxWidDiff;
143 mTitle->setMaximumWidth( maxwid/2 +20 );
144 mCalendarBox->setMaximumWidth( maxwid/2 -20 );
145 }
146 setMaximumWidth( QApplication::desktop()->width() );
147 qDebug("MAXXX %d ", QApplication::desktop()->width());
148#endif
149 QFrame::resizeEvent( e );
150}
131QSize JournalEntry::sizeHint() const 151QSize JournalEntry::sizeHint() const
132{ 152{
133 return QSize ( 240, heiHint ); 153 return QSize ( 240, heiHint );
134} 154}
135void JournalEntry::slotSaveTemplate() 155void JournalEntry::slotSaveTemplate()
136{ 156{
137 QString fileName =locateLocal( "templates", "journals" ); 157 QString fileName =locateLocal( "templates", "journals" );
138 QDir t_dir; 158 QDir t_dir;
139 if ( !t_dir.exists(fileName) ) 159 if ( !t_dir.exists(fileName) )
140 t_dir.mkdir ( fileName ); 160 t_dir.mkdir ( fileName );
141 fileName += "/journal"; 161 fileName += "/journal";
142 fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Journal template"), this ); 162 fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Journal template"), this );
143 if ( fileName.length() == 0 ) 163 if ( fileName.length() == 0 )
144 return; 164 return;
145 165
146 QFile fileIn( fileName ); 166 QFile fileIn( fileName );
147 if (!fileIn.open( IO_WriteOnly ) ) { 167 if (!fileIn.open( IO_WriteOnly ) ) {
148 KMessageBox::error( this, i18n("Error saving template file\n '%1'.") 168 KMessageBox::error( this, i18n("Error saving template file\n '%1'.")
149 .arg( fileName ) ); 169 .arg( fileName ) );
150 return; 170 return;
151 } 171 }
152 // QString text; 172 // QString text;
153 QTextStream tsIn( &fileIn ); 173 QTextStream tsIn( &fileIn );
154 tsIn.setCodec( QTextCodec::codecForName("utf8") ); 174 tsIn.setCodec( QTextCodec::codecForName("utf8") );
155 tsIn << mEditor->text(); 175 tsIn << mEditor->text();
156 fileIn.close(); 176 fileIn.close();
157} 177}
158void JournalEntry::slotLoadTemplate() 178void JournalEntry::slotLoadTemplate()
159{ 179{
160 QString fileName =locateLocal( "templates", "journals" ); 180 QString fileName =locateLocal( "templates", "journals" );
161 QDir t_dir; 181 QDir t_dir;
162 if ( !t_dir.exists(fileName) ) 182 if ( !t_dir.exists(fileName) )
163 t_dir.mkdir ( fileName ); 183 t_dir.mkdir ( fileName );
164 fileName += "/journal"; 184 fileName += "/journal";
165 fileName = KFileDialog::getOpenFileName( fileName , i18n("Insert Journal template"), this ); 185 fileName = KFileDialog::getOpenFileName( fileName , i18n("Insert Journal template"), this );
166 if ( fileName.length() == 0 ) 186 if ( fileName.length() == 0 )
167 return; 187 return;
168 QFile fileIn( fileName ); 188 QFile fileIn( fileName );
169 if (!fileIn.open( IO_ReadOnly ) ) { 189 if (!fileIn.open( IO_ReadOnly ) ) {
170 KMessageBox::error( this, i18n("Error loading template file\n '%1'.") 190 KMessageBox::error( this, i18n("Error loading template file\n '%1'.")
171 .arg( fileName ) ); 191 .arg( fileName ) );
172 return; 192 return;
173 } 193 }
174 QTextStream tsIn( &fileIn ); 194 QTextStream tsIn( &fileIn );
175 tsIn.setCodec( QTextCodec::codecForName("utf8") ); 195 tsIn.setCodec( QTextCodec::codecForName("utf8") );
176 QString text = tsIn.read(); 196 QString text = tsIn.read();
177 fileIn.close(); 197 fileIn.close();
178 int line, col; 198 int line, col;