Diffstat (limited to 'korganizer/koeditorgeneral.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | korganizer/koeditorgeneral.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp index 407a5d5..fd50b05 100644 --- a/korganizer/koeditorgeneral.cpp +++ b/korganizer/koeditorgeneral.cpp | |||
@@ -1,204 +1,204 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
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 | #include <qwidget.h> | 24 | #include <qwidget.h> |
25 | #include <qtooltip.h> | 25 | #include <qtooltip.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qvbox.h> | 27 | #include <qvbox.h> |
28 | #include <qbuttongroup.h> | 28 | #include <qbuttongroup.h> |
29 | #include <qvgroupbox.h> | 29 | #include <qvgroupbox.h> |
30 | #include <qwidgetstack.h> | 30 | #include <qwidgetstack.h> |
31 | #include <qdatetime.h> | 31 | #include <qdatetime.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | #include <qfile.h> | 33 | #include <qfile.h> |
34 | #include <qregexp.h> | 34 | #include <qregexp.h> |
35 | 35 | ||
36 | 36 | ||
37 | #include <kglobal.h> | 37 | #include <kglobal.h> |
38 | #include <kdialog.h> | 38 | #include <kdialog.h> |
39 | #include <kdebug.h> | 39 | #include <kdebug.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kiconloader.h> | 41 | #include <kiconloader.h> |
42 | #include <kmessagebox.h> | 42 | #include <kmessagebox.h> |
43 | #include <kfiledialog.h> | 43 | #include <kfiledialog.h> |
44 | #include <kstandarddirs.h> | 44 | #include <kstandarddirs.h> |
45 | 45 | ||
46 | #include <libkcal/todo.h> | 46 | #include <libkcal/todo.h> |
47 | #include <libkcal/event.h> | 47 | #include <libkcal/event.h> |
48 | #include <libkdepim/categoryselectdialog.h> | 48 | #include <libkdepim/categoryselectdialog.h> |
49 | #include <libkdepim/kdateedit.h> | 49 | #include <libkdepim/kdateedit.h> |
50 | 50 | ||
51 | #include "koprefs.h" | 51 | #include "koprefs.h" |
52 | #include "koglobals.h" | 52 | #include "koglobals.h" |
53 | 53 | ||
54 | #include "koeditorgeneral.h" | 54 | #include "koeditorgeneral.h" |
55 | #include "kolocationbox.h" | 55 | #include "kolocationbox.h" |
56 | #ifndef DESKTOP_VERSION | 56 | #ifndef DESKTOP_VERSION |
57 | #include <qpe/qpeapplication.h> | 57 | #include <qpe/qpeapplication.h> |
58 | #else | 58 | #else |
59 | #include <qapplication.h> | 59 | #include <qapplication.h> |
60 | #endif | 60 | #endif |
61 | 61 | ||
62 | KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) : | 62 | KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) : |
63 | QObject( parent, name) | 63 | QObject( parent, name) |
64 | { | 64 | { |
65 | mNextFocus = 0; | 65 | mNextFocus = 0; |
66 | } | 66 | } |
67 | 67 | ||
68 | KOEditorGeneral::~KOEditorGeneral() | 68 | KOEditorGeneral::~KOEditorGeneral() |
69 | { | 69 | { |
70 | } | 70 | } |
71 | 71 | ||
72 | void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout) | 72 | void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout) |
73 | { | 73 | { |
74 | QGridLayout *headerLayout = new QGridLayout(topLayout); | 74 | QGridLayout *headerLayout = new QGridLayout(topLayout); |
75 | 75 | ||
76 | #if 0 | 76 | #if 0 |
77 | mOwnerLabel = new QLabel(i18n("Owner:"),parent); | 77 | mOwnerLabel = new QLabel(i18n("Owner:"),parent); |
78 | headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1); | 78 | headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1); |
79 | #endif | 79 | #endif |
80 | // 1 on pda | 80 | // 1 on pda |
81 | // 11 on desktop | 81 | // 11 on desktop |
82 | headerLayout->setSpacing( (KDialog::spacingHint()-3)*2+1 ); | 82 | headerLayout->setSpacing( (KDialog::spacingHint()-3)*2+1 ); |
83 | QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent); | 83 | QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent); |
84 | headerLayout->addWidget(summaryLabel,0,0); | 84 | headerLayout->addWidget(summaryLabel,0,0); |
85 | 85 | ||
86 | mSummaryEdit = new KOLocationBox(TRUE,parent, 10); | 86 | mSummaryEdit = new KOLocationBox(TRUE,parent, 50); |
87 | mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); | 87 | mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); |
88 | //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) ); | 88 | //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) ); |
89 | //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() ); | 89 | //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() ); |
90 | int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2; | 90 | int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2; |
91 | if ( QApplication::desktop()->width() > 320 ) | 91 | if ( QApplication::desktop()->width() > 320 ) |
92 | mSummaryEdit->setMaximumHeight( hei +6 ); | 92 | mSummaryEdit->setMaximumHeight( hei +6 ); |
93 | //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding ); | 93 | //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding ); |
94 | // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink } | 94 | // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink } |
95 | // mSummaryEdit = new QLineEdit(parent); | 95 | // mSummaryEdit = new QLineEdit(parent); |
96 | if ( QApplication::desktop()->height() < 320 ) | 96 | if ( QApplication::desktop()->height() < 320 ) |
97 | headerLayout->addWidget(mSummaryEdit,0,1); | 97 | headerLayout->addWidget(mSummaryEdit,0,1); |
98 | else | 98 | else |
99 | headerLayout->addMultiCellWidget(mSummaryEdit,0,0,1,2); | 99 | headerLayout->addMultiCellWidget(mSummaryEdit,0,0,1,2); |
100 | connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); | 100 | connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); |
101 | 101 | ||
102 | QLabel *locationLabel = new QLabel(i18n("Location:"),parent); | 102 | QLabel *locationLabel = new QLabel(i18n("Location:"),parent); |
103 | if ( QApplication::desktop()->height() < 320 ) | 103 | if ( QApplication::desktop()->height() < 320 ) |
104 | headerLayout->addWidget(locationLabel,0,2); | 104 | headerLayout->addWidget(locationLabel,0,2); |
105 | else | 105 | else |
106 | headerLayout->addWidget(locationLabel,1,0); | 106 | headerLayout->addWidget(locationLabel,1,0); |
107 | 107 | ||
108 | mLocationEdit = new KOLocationBox(TRUE,parent,10); | 108 | mLocationEdit = new KOLocationBox(TRUE,parent,30); |
109 | mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); | 109 | mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); |
110 | if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->height() > 240 ) | 110 | if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->height() > 240 ) |
111 | mLocationEdit->setMaximumHeight( hei + 6); | 111 | mLocationEdit->setMaximumHeight( hei + 6); |
112 | 112 | ||
113 | // mLocationEdit = new QLineEdit(parent); | 113 | // mLocationEdit = new QLineEdit(parent); |
114 | connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); | 114 | connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); |
115 | 115 | ||
116 | mCalendarBox = new QComboBox ( parent ); | 116 | mCalendarBox = new QComboBox ( parent ); |
117 | mCalendarBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); | 117 | mCalendarBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); |
118 | if ( QApplication::desktop()->height() < 320 ) { | 118 | if ( QApplication::desktop()->height() < 320 ) { |
119 | headerLayout->addWidget(mLocationEdit,0,3); | 119 | headerLayout->addWidget(mLocationEdit,0,3); |
120 | headerLayout->addWidget(mCalendarBox,0,4); | 120 | headerLayout->addWidget(mCalendarBox,0,4); |
121 | headerLayout->setColStretch( 1, 10); | 121 | headerLayout->setColStretch( 1, 10); |
122 | headerLayout->setColStretch( 3, 10); | 122 | headerLayout->setColStretch( 3, 10); |
123 | mCalendarBox->setMaximumWidth( 64 ); | 123 | mCalendarBox->setMaximumWidth( 64 ); |
124 | } | 124 | } |
125 | else { | 125 | else { |
126 | headerLayout->addWidget(mLocationEdit,1,1); | 126 | headerLayout->addWidget(mLocationEdit,1,1); |
127 | headerLayout->addWidget(mCalendarBox,1,2); | 127 | headerLayout->addWidget(mCalendarBox,1,2); |
128 | headerLayout->setColStretch( 1, 3); | 128 | headerLayout->setColStretch( 1, 3); |
129 | headerLayout->setColStretch( 2, 1); | 129 | headerLayout->setColStretch( 2, 1); |
130 | } | 130 | } |
131 | 131 | ||
132 | } | 132 | } |
133 | void KOEditorGeneral::setFocusOn( int i ) | 133 | void KOEditorGeneral::setFocusOn( int i ) |
134 | { | 134 | { |
135 | mNextFocus = i; | 135 | mNextFocus = i; |
136 | QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() )); | 136 | QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() )); |
137 | } | 137 | } |
138 | void KOEditorGeneral::slotSetFocusOn() | 138 | void KOEditorGeneral::slotSetFocusOn() |
139 | { | 139 | { |
140 | mNextFocus; | 140 | mNextFocus; |
141 | if ( mNextFocus == 1 ) { | 141 | if ( mNextFocus == 1 ) { |
142 | mDescriptionEdit->setFocus(); | 142 | mDescriptionEdit->setFocus(); |
143 | mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); | 143 | mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); |
144 | } | 144 | } |
145 | if ( mNextFocus == 2 ) { | 145 | if ( mNextFocus == 2 ) { |
146 | mSummaryEdit->setFocus(); | 146 | mSummaryEdit->setFocus(); |
147 | } | 147 | } |
148 | } | 148 | } |
149 | void KOEditorGeneral::editCategories() | 149 | void KOEditorGeneral::editCategories() |
150 | { | 150 | { |
151 | // qDebug("KOEditorGeneral::editCategories() "); | 151 | // qDebug("KOEditorGeneral::editCategories() "); |
152 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); | 152 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); |
153 | connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); | 153 | connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); |
154 | //KOGlobals::fitDialogToScreen( csd ); | 154 | //KOGlobals::fitDialogToScreen( csd ); |
155 | csd->setColorEnabled(); | 155 | csd->setColorEnabled(); |
156 | csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); | 156 | csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); |
157 | csd->exec(); | 157 | csd->exec(); |
158 | delete csd; | 158 | delete csd; |
159 | } | 159 | } |
160 | 160 | ||
161 | void KOEditorGeneral::showCatPopup() | 161 | void KOEditorGeneral::showCatPopup() |
162 | { | 162 | { |
163 | mCatPopup->clear(); | 163 | mCatPopup->clear(); |
164 | QStringList checkedCategories = QStringList::split (",", mCategoriesLabel->text()); | 164 | QStringList checkedCategories = QStringList::split (",", mCategoriesLabel->text()); |
165 | int index = 0; | 165 | int index = 0; |
166 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); | 166 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); |
167 | it != KOPrefs::instance()->mCustomCategories.end (); | 167 | it != KOPrefs::instance()->mCustomCategories.end (); |
168 | ++it) { | 168 | ++it) { |
169 | mCatPopup->insertItem (*it, index ); | 169 | mCatPopup->insertItem (*it, index ); |
170 | //mCategory[index] = *it; | 170 | //mCategory[index] = *it; |
171 | if (checkedCategories.find (*it) != checkedCategories.end ()) mCatPopup->setItemChecked (index, true); | 171 | if (checkedCategories.find (*it) != checkedCategories.end ()) mCatPopup->setItemChecked (index, true); |
172 | ++index; | 172 | ++index; |
173 | } | 173 | } |
174 | } | 174 | } |
175 | void KOEditorGeneral::selectedCatPopup( int index ) | 175 | void KOEditorGeneral::selectedCatPopup( int index ) |
176 | { | 176 | { |
177 | QStringList categories = QStringList::split (",", mCategoriesLabel->text()); | 177 | QStringList categories = QStringList::split (",", mCategoriesLabel->text()); |
178 | QString colcat = categories.first(); | 178 | QString colcat = categories.first(); |
179 | if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ()) | 179 | if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ()) |
180 | categories.remove (KOPrefs::instance()->mCustomCategories[index]); | 180 | categories.remove (KOPrefs::instance()->mCustomCategories[index]); |
181 | else | 181 | else |
182 | categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]); | 182 | categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]); |
183 | categories.sort (); | 183 | categories.sort (); |
184 | if ( !colcat.isEmpty() ) { | 184 | if ( !colcat.isEmpty() ) { |
185 | if ( categories.find ( colcat ) != categories.end () ) { | 185 | if ( categories.find ( colcat ) != categories.end () ) { |
186 | categories.remove( colcat ); | 186 | categories.remove( colcat ); |
187 | categories.prepend( colcat ); | 187 | categories.prepend( colcat ); |
188 | } | 188 | } |
189 | } | 189 | } |
190 | setCategories( categories.join(",") ); | 190 | setCategories( categories.join(",") ); |
191 | } | 191 | } |
192 | 192 | ||
193 | void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) | 193 | void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) |
194 | { | 194 | { |
195 | QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); | 195 | QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); |
196 | mCatPopup = new QPopupMenu ( parent ); | 196 | mCatPopup = new QPopupMenu ( parent ); |
197 | mCatPopup->setCheckable (true); | 197 | mCatPopup->setCheckable (true); |
198 | connect(mCatPopup,SIGNAL(aboutToShow () ), this ,SLOT(showCatPopup())); | 198 | connect(mCatPopup,SIGNAL(aboutToShow () ), this ,SLOT(showCatPopup())); |
199 | connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT(selectedCatPopup( int ))); | 199 | connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT(selectedCatPopup( int ))); |
200 | mCategoriesButton = new QPushButton(parent); | 200 | mCategoriesButton = new QPushButton(parent); |
201 | mCategoriesButton->setText(i18n("Categories...")); | 201 | mCategoriesButton->setText(i18n("Categories...")); |
202 | connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); | 202 | connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); |
203 | //connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); | 203 | //connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); |
204 | categoriesLayout->addWidget(mCategoriesButton); | 204 | categoriesLayout->addWidget(mCategoriesButton); |