-rw-r--r-- | korganizer/journalentry.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp index 7274849..0b923ad 100644 --- a/korganizer/journalentry.cpp +++ b/korganizer/journalentry.cpp | |||
@@ -35,48 +35,49 @@ | |||
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 | 45 | ||
46 | #include <libkcal/journal.h> | 46 | #include <libkcal/journal.h> |
47 | #include <libkcal/calendarresources.h> | 47 | #include <libkcal/calendarresources.h> |
48 | #include <libkcal/resourcecalendar.h> | 48 | #include <libkcal/resourcecalendar.h> |
49 | #include <kresources/resourceselectdialog.h> | 49 | #include <kresources/resourceselectdialog.h> |
50 | 50 | ||
51 | #include "journalentry.h" | 51 | #include "journalentry.h" |
52 | //#include "journalentry.moc" | 52 | //#include "journalentry.moc" |
53 | #ifndef DESKTOP_VERSION | 53 | #ifndef DESKTOP_VERSION |
54 | #include <qpe/qpeapplication.h> | 54 | #include <qpe/qpeapplication.h> |
55 | #endif | 55 | #endif |
56 | JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : | 56 | JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : |
57 | QFrame(parent) | 57 | QFrame(parent) |
58 | { | 58 | { |
59 | heiHint = QApplication::desktop()->height() / 5 ; | ||
59 | showOnlyMode = false; | 60 | showOnlyMode = false; |
60 | mCalendar = calendar; | 61 | mCalendar = calendar; |
61 | mJournal = 0; | 62 | mJournal = 0; |
62 | mDirty = false; | 63 | mDirty = false; |
63 | 64 | ||
64 | QHBox * vb = new QHBox ( this ); | 65 | QHBox * vb = new QHBox ( this ); |
65 | QPushButton * newJournal = new QPushButton( vb ); | 66 | QPushButton * newJournal = new QPushButton( vb ); |
66 | QIconSet icon; | 67 | QIconSet icon; |
67 | if ( QApplication::desktop()->width() < 321 ) | 68 | if ( QApplication::desktop()->width() < 321 ) |
68 | icon = SmallIcon("ko16old"); | 69 | icon = SmallIcon("ko16old"); |
69 | else | 70 | else |
70 | icon = SmallIcon("ko24old"); | 71 | icon = SmallIcon("ko24old"); |
71 | newJournal->setIconSet (icon ) ; | 72 | newJournal->setIconSet (icon ) ; |
72 | int size = newJournal->sizeHint().height(); | 73 | int size = newJournal->sizeHint().height(); |
73 | newJournal->setFixedSize( size, size ); | 74 | newJournal->setFixedSize( size, size ); |
74 | 75 | ||
75 | 76 | ||
76 | QPushButton * toggleJournal = new QPushButton( vb ); | 77 | QPushButton * toggleJournal = new QPushButton( vb ); |
77 | icon = SmallIcon("1updownarrow"); | 78 | icon = SmallIcon("1updownarrow"); |
78 | toggleJournal->setIconSet (icon ) ; | 79 | toggleJournal->setIconSet (icon ) ; |
79 | //int size = toggleJournal->sizeHint().height(); | 80 | //int size = toggleJournal->sizeHint().height(); |
80 | toggleJournal->setFixedSize( size * 2 /3 , size ); | 81 | toggleJournal->setFixedSize( size * 2 /3 , size ); |
81 | 82 | ||
82 | 83 | ||
@@ -96,50 +97,54 @@ JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : | |||
96 | if ( QApplication::desktop()->width() < 321 ) | 97 | if ( QApplication::desktop()->width() < 321 ) |
97 | icon = SmallIcon("fileimport16"); | 98 | icon = SmallIcon("fileimport16"); |
98 | else | 99 | else |
99 | icon = SmallIcon("fileimport"); | 100 | icon = SmallIcon("fileimport"); |
100 | loadTemplate->setIconSet (icon ) ; | 101 | loadTemplate->setIconSet (icon ) ; |
101 | loadTemplate->setFixedSize( size, size ); | 102 | loadTemplate->setFixedSize( size, size ); |
102 | mEditor = new KTextEdit(this); | 103 | mEditor = new KTextEdit(this); |
103 | connect(mEditor,SIGNAL(textChanged()),SLOT(setDirty())); | 104 | connect(mEditor,SIGNAL(textChanged()),SLOT(setDirty())); |
104 | #ifndef DESKTOP_VERSION | 105 | #ifndef DESKTOP_VERSION |
105 | QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold ); | 106 | QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold ); |
106 | #endif | 107 | #endif |
107 | mEditor->setWordWrap( KTextEdit::WidgetWidth ); | 108 | mEditor->setWordWrap( KTextEdit::WidgetWidth ); |
108 | QBoxLayout *topLayout = new QVBoxLayout(this); | 109 | QBoxLayout *topLayout = new QVBoxLayout(this); |
109 | topLayout->addWidget(vb); | 110 | topLayout->addWidget(vb); |
110 | topLayout->addWidget(mEditor); | 111 | topLayout->addWidget(mEditor); |
111 | mEditor->installEventFilter(this); | 112 | mEditor->installEventFilter(this); |
112 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); | 113 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); |
113 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); | 114 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); |
114 | connect( newJournal, SIGNAL( clicked() ), this , SIGNAL( newJournal() ) ); | 115 | connect( newJournal, SIGNAL( clicked() ), this , SIGNAL( newJournal() ) ); |
115 | connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) ); | 116 | connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) ); |
116 | } | 117 | } |
117 | 118 | ||
118 | JournalEntry::~JournalEntry() | 119 | JournalEntry::~JournalEntry() |
119 | { | 120 | { |
121 | qDebug("JournalEntry::~JournalEntry() "); | ||
122 | } | ||
123 | QSize JournalEntry::sizeHint() const | ||
124 | { | ||
125 | return QSize ( 240, heiHint ); | ||
120 | } | 126 | } |
121 | |||
122 | void JournalEntry::slotSaveTemplate() | 127 | void JournalEntry::slotSaveTemplate() |
123 | { | 128 | { |
124 | QString fileName =locateLocal( "templates", "journals" ); | 129 | QString fileName =locateLocal( "templates", "journals" ); |
125 | QDir t_dir; | 130 | QDir t_dir; |
126 | if ( !t_dir.exists(fileName) ) | 131 | if ( !t_dir.exists(fileName) ) |
127 | t_dir.mkdir ( fileName ); | 132 | t_dir.mkdir ( fileName ); |
128 | fileName += "/journal"; | 133 | fileName += "/journal"; |
129 | fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Journal template"), this ); | 134 | fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Journal template"), this ); |
130 | if ( fileName.length() == 0 ) | 135 | if ( fileName.length() == 0 ) |
131 | return; | 136 | return; |
132 | 137 | ||
133 | QFile fileIn( fileName ); | 138 | QFile fileIn( fileName ); |
134 | if (!fileIn.open( IO_WriteOnly ) ) { | 139 | if (!fileIn.open( IO_WriteOnly ) ) { |
135 | KMessageBox::error( this, i18n("Error saving template file\n '%1'.") | 140 | KMessageBox::error( this, i18n("Error saving template file\n '%1'.") |
136 | .arg( fileName ) ); | 141 | .arg( fileName ) ); |
137 | return; | 142 | return; |
138 | } | 143 | } |
139 | // QString text; | 144 | // QString text; |
140 | QTextStream tsIn( &fileIn ); | 145 | QTextStream tsIn( &fileIn ); |
141 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | 146 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); |
142 | tsIn << mEditor->text(); | 147 | tsIn << mEditor->text(); |
143 | fileIn.close(); | 148 | fileIn.close(); |
144 | } | 149 | } |
145 | void JournalEntry::slotLoadTemplate() | 150 | void JournalEntry::slotLoadTemplate() |