summaryrefslogtreecommitdiffabout
path: root/korganizer/koeditorgeneral.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/koeditorgeneral.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koeditorgeneral.cpp51
1 files changed, 45 insertions, 6 deletions
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp
index 915c7ec..50a04ea 100644
--- a/korganizer/koeditorgeneral.cpp
+++ b/korganizer/koeditorgeneral.cpp
@@ -97,107 +97,146 @@ void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout)
headerLayout->addWidget(locationLabel,1,2);
else
headerLayout->addWidget(locationLabel,2,0);
mLocationEdit = new KOLocationBox(TRUE,parent,10);
mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->height() > 240 )
mLocationEdit->setMaximumHeight( hei + 6);
// mLocationEdit = new QLineEdit(parent);
connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) );
if ( QApplication::desktop()->height() < 320 ) {
headerLayout->addWidget(mLocationEdit,1,3);
headerLayout->setColStretch( 1, 10);
headerLayout->setColStretch( 3, 10);
}
else {
headerLayout->addWidget(mLocationEdit,2,1);
headerLayout->setColStretch( 1, 10);
}
}
void KOEditorGeneral::setFocusOn( int i )
{
mNextFocus = i;
QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() ));
}
void KOEditorGeneral::slotSetFocusOn()
{
mNextFocus;
if ( mNextFocus == 1 ) {
mDescriptionEdit->setFocus();
mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333);
}
if ( mNextFocus == 2 ) {
mSummaryEdit->setFocus();
}
}
void KOEditorGeneral::editCategories()
{
// qDebug("KOEditorGeneral::editCategories() ");
KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &)));
//KOGlobals::fitDialogToScreen( csd );
csd->setColorEnabled();
csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) );
csd->exec();
delete csd;
}
+
+void KOEditorGeneral::showCatPopup()
+{
+ mCatPopup->clear();
+ QStringList checkedCategories = QStringList::split (",", mCategoriesLabel->text());
+ int index = 0;
+ for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
+ it != KOPrefs::instance()->mCustomCategories.end ();
+ ++it) {
+ mCatPopup->insertItem (*it, index );
+ //mCategory[index] = *it;
+ if (checkedCategories.find (*it) != checkedCategories.end ()) mCatPopup->setItemChecked (index, true);
+ ++index;
+ }
+}
+void KOEditorGeneral::selectedCatPopup( int index )
+{
+ qDebug("i %d c %d ", index, KOPrefs::instance()->mCustomCategories.count());
+ QStringList categories = QStringList::split (",", mCategoriesLabel->text());
+ QString colcat = categories.first();
+ if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ())
+ categories.remove (KOPrefs::instance()->mCustomCategories[index]);
+ else
+ categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]);
+ categories.sort ();
+ if ( !colcat.isEmpty() ) {
+ if ( categories.find ( colcat ) != categories.end () ) {
+ categories.remove( colcat );
+ categories.prepend( colcat );
+ }
+ }
+ mCategoriesLabel->setText( categories.join(",") );
+}
+
void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout)
{
QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout );
-
+ mCatPopup = new QPopupMenu ( parent );
+ mCatPopup->setCheckable (true);
+ connect(mCatPopup,SIGNAL(aboutToShow () ), this ,SLOT(showCatPopup()));
+ connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT(selectedCatPopup( int )));
mCategoriesButton = new QPushButton(parent);
- mCategoriesButton->setText(i18n("Categories..."));
- connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() ));
+ mCategoriesButton->setText(i18n("Categories"));
+ //connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() ));
categoriesLayout->addWidget(mCategoriesButton);
-
- mCategoriesLabel = new QLabel(parent);
- mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken);
+ mCategoriesButton->setPopup( mCatPopup );
+ mCategoriesLabel = new QPushButton(parent);//new QLabel(parent);
+ mCategoriesLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
+ connect(mCategoriesLabel,SIGNAL(clicked()),this, SLOT(editCategories() ));
+ //mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken);
categoriesLayout->addWidget(mCategoriesLabel,1);
}
void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout)
{
QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout );
QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent);
mCancelBox = new QCheckBox ( i18n("Cancelled"), parent);
secrecyLayout->addWidget(mCancelBox);
secrecyLayout->addWidget(secrecyLabel);
mSecrecyCombo = new QComboBox(parent);
mSecrecyCombo->insertStringList(Incidence::secrecyList());
secrecyLayout->addWidget(mSecrecyCombo);
}
void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout)
{
mDescriptionEdit = new KTextEdit(parent);
mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont );
mDescriptionEdit->append("");
mDescriptionEdit->setReadOnly(false);
mDescriptionEdit->setOverwriteMode(false);
mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth );
topLayout->addWidget(mDescriptionEdit);
#ifndef DESKTOP_VERSION
QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold );
#endif
}
void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout)
{
QBoxLayout *alarmLayout = new QHBoxLayout(topLayout);
//mAlarmBell = new QLabel(parent);
//mAlarmBell->setPixmap(SmallIcon("bell"));
//alarmLayout->addWidget(mAlarmBell);
if ( QApplication::desktop()->width() < 320 )
mAlarmButton = new QCheckBox(i18n("Rem."),parent);
else
mAlarmButton = new QCheckBox(i18n("Reminder:"),parent);
connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool)));
alarmLayout->addWidget(mAlarmButton);
mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ;