-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 | |||
@@ -11,159 +11,164 @@ | |||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
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 <qvbox.h> |
30 | #include <qfile.h> | 30 | #include <qfile.h> |
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 | 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 | ||
83 | 84 | ||
84 | mTitleLabel = new QLabel(i18n("Title"),vb); | 85 | mTitleLabel = new QLabel(i18n("Title"),vb); |
85 | mTitleLabel->setMargin(2); | 86 | mTitleLabel->setMargin(2); |
86 | mTitleLabel->setAlignment(AlignCenter); | 87 | mTitleLabel->setAlignment(AlignCenter); |
87 | QPushButton * loadTemplate = new QPushButton( vb ); | 88 | QPushButton * loadTemplate = new QPushButton( vb ); |
88 | QPushButton * saveTemplate = new QPushButton( vb ); | 89 | QPushButton * saveTemplate = new QPushButton( vb ); |
89 | if ( QApplication::desktop()->width() < 321 ) | 90 | if ( QApplication::desktop()->width() < 321 ) |
90 | icon = SmallIcon("fileexport16"); | 91 | icon = SmallIcon("fileexport16"); |
91 | else | 92 | else |
92 | icon = SmallIcon("fileexport"); | 93 | icon = SmallIcon("fileexport"); |
93 | saveTemplate->setIconSet (icon ) ; | 94 | saveTemplate->setIconSet (icon ) ; |
94 | //size = saveTemplate->sizeHint().height(); | 95 | //size = saveTemplate->sizeHint().height(); |
95 | saveTemplate->setFixedSize( size, size ); | 96 | saveTemplate->setFixedSize( size, size ); |
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() |
146 | { | 151 | { |
147 | QString fileName =locateLocal( "templates", "journals" ); | 152 | QString fileName =locateLocal( "templates", "journals" ); |
148 | QDir t_dir; | 153 | QDir t_dir; |
149 | if ( !t_dir.exists(fileName) ) | 154 | if ( !t_dir.exists(fileName) ) |
150 | t_dir.mkdir ( fileName ); | 155 | t_dir.mkdir ( fileName ); |
151 | fileName += "/journal"; | 156 | fileName += "/journal"; |
152 | fileName = KFileDialog::getOpenFileName( fileName , i18n("Insert Journal template"), this ); | 157 | fileName = KFileDialog::getOpenFileName( fileName , i18n("Insert Journal template"), this ); |
153 | if ( fileName.length() == 0 ) | 158 | if ( fileName.length() == 0 ) |
154 | return; | 159 | return; |
155 | QFile fileIn( fileName ); | 160 | QFile fileIn( fileName ); |
156 | if (!fileIn.open( IO_ReadOnly ) ) { | 161 | if (!fileIn.open( IO_ReadOnly ) ) { |
157 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") | 162 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") |
158 | .arg( fileName ) ); | 163 | .arg( fileName ) ); |
159 | return; | 164 | return; |
160 | } | 165 | } |
161 | QTextStream tsIn( &fileIn ); | 166 | QTextStream tsIn( &fileIn ); |
162 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | 167 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); |
163 | QString text = tsIn.read(); | 168 | QString text = tsIn.read(); |
164 | fileIn.close(); | 169 | fileIn.close(); |
165 | int line, col; | 170 | int line, col; |
166 | mEditor->getCursorPosition (& line, & col ); | 171 | mEditor->getCursorPosition (& line, & col ); |
167 | mEditor-> insertAt ( text, line, col, true ); | 172 | mEditor-> insertAt ( text, line, col, true ); |
168 | //mEditor->setIgnoreMark( true ); | 173 | //mEditor->setIgnoreMark( true ); |
169 | setDirty(); | 174 | setDirty(); |