-rw-r--r-- | korganizer/journalentry.cpp | 22 |
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 | |||
@@ -55,100 +55,120 @@ | |||
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 |
59 | JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : | 59 | JournalEntry::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 | ||
127 | JournalEntry::~JournalEntry() | 133 | JournalEntry::~JournalEntry() |
128 | { | 134 | { |
129 | //qDebug("JournalEntry::~JournalEntry() "); | 135 | //qDebug("JournalEntry::~JournalEntry() "); |
130 | } | 136 | } |
137 | void 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 | } | ||
131 | QSize JournalEntry::sizeHint() const | 151 | QSize JournalEntry::sizeHint() const |
132 | { | 152 | { |
133 | return QSize ( 240, heiHint ); | 153 | return QSize ( 240, heiHint ); |
134 | } | 154 | } |
135 | void JournalEntry::slotSaveTemplate() | 155 | void 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") ); |