summaryrefslogtreecommitdiffabout
path: root/korganizer
Side-by-side diff
Diffstat (limited to 'korganizer') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/koeditorgeneral.cpp65
-rw-r--r--korganizer/koeditorgeneral.h4
-rw-r--r--korganizer/koeventpopupmenu.cpp1
3 files changed, 62 insertions, 8 deletions
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp
index 29e68b3..753630b 100644
--- a/korganizer/koeditorgeneral.cpp
+++ b/korganizer/koeditorgeneral.cpp
@@ -52,101 +52,111 @@
#include "koglobals.h"
#include "koeditorgeneral.h"
#include "kolocationbox.h"
#ifndef DESKTOP_VERSION
#include <qpe/qpeapplication.h>
#else
#include <qapplication.h>
#endif
KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) :
QObject( parent, name)
{
mNextFocus = 0;
}
KOEditorGeneral::~KOEditorGeneral()
{
}
void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout)
{
QGridLayout *headerLayout = new QGridLayout(topLayout);
#if 0
mOwnerLabel = new QLabel(i18n("Owner:"),parent);
headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1);
#endif
// 1 on pda
// 11 on desktop
headerLayout->setSpacing( (KDialog::spacingHint()-3)*2+1 );
QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent);
- headerLayout->addWidget(summaryLabel,1,0);
+ headerLayout->addWidget(summaryLabel,0,0);
mSummaryEdit = new KOLocationBox(TRUE,parent, 10);
mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
//mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) );
//qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() );
int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2;
if ( QApplication::desktop()->width() > 320 )
mSummaryEdit->setMaximumHeight( hei +6 );
//qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding );
// SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink }
// mSummaryEdit = new QLineEdit(parent);
- headerLayout->addWidget(mSummaryEdit,1,1);
+ if ( QApplication::desktop()->height() < 320 )
+ headerLayout->addWidget(mSummaryEdit,0,1);
+ else
+ headerLayout->addMultiCellWidget(mSummaryEdit,0,0,1,2);
connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) );
QLabel *locationLabel = new QLabel(i18n("Location:"),parent);
if ( QApplication::desktop()->height() < 320 )
- headerLayout->addWidget(locationLabel,1,2);
+ headerLayout->addWidget(locationLabel,0,2);
else
- headerLayout->addWidget(locationLabel,2,0);
+ headerLayout->addWidget(locationLabel,1,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 () ) );
+
+ mCalendarBox = new QComboBox ( parent );
+ mCalendarBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
if ( QApplication::desktop()->height() < 320 ) {
- headerLayout->addWidget(mLocationEdit,1,3);
+ headerLayout->addWidget(mLocationEdit,0,3);
+ headerLayout->addWidget(mCalendarBox,0,4);
headerLayout->setColStretch( 1, 10);
headerLayout->setColStretch( 3, 10);
+ mCalendarBox->setMaximumWidth( 64 );
}
else {
- headerLayout->addWidget(mLocationEdit,2,1);
+ headerLayout->addWidget(mLocationEdit,1,1);
+ headerLayout->addWidget(mCalendarBox,1,2);
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();
@@ -407,72 +417,112 @@ void KOEditorGeneral::setCategories(const QString &str)
}
void KOEditorGeneral::setDefaults(bool allDay)
{
#if 0
mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName());
#endif
mAlarmMessage = i18n("Edit new item");
enableAlarmEdit( !allDay );
// TODO: Implement a KPrefsComboItem to solve this in a clean way.
int alarmTime;
int a[] = { 1,5,10,15,30,60,180, 1440 };
int index = KOPrefs::instance()->mAlarmTime;
if (index < 0 || index > 7) {
alarmTime = 15;
} else {
alarmTime = a[index];
}
mAlarmButton ->setChecked( false );
mAlarmTimeEdit->setValue(alarmTime);
mAlarmIncrCombo->setCurrentItem(0);
enableAlarmEdit( false );
//alarmDisable (false);
mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic);
mCancelBox->setChecked( false );
mSummaryEdit->setEditText("");
mLocationEdit->setEditText("");
mDescriptionEdit->setText("");
mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
setCategories("");
+ fillCalCombo();
}
void KOEditorGeneral::setSecrecy( int num )
{
mSecrecyCombo->setCurrentItem(num);
}
-void KOEditorGeneral::readIncidence(Incidence *event)
+void KOEditorGeneral::fillCalCombo( int setToID )
+{
+ mCalendarBox->clear();
+ KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
+ int std = 0;
+ int count = 0;
+ while ( kkf ) {
+ if ( !kkf->mErrorOnLoad &&! kkf->isReadOnly ) {
+ if ( setToID ) {
+ if ( kkf->mCalNumber == setToID )
+ std = count;
+ } else {
+ if ( kkf->isStandard ) {
+ std = count;
+ }
+ }
+ ++count;
+ mCalendarBox->insertItem( kkf->mName );
+ }
+ kkf = KOPrefs::instance()->mCalendars.next();
+ }
+ mCalendarBox->setCurrentItem( std );
+ if ( KOPrefs::instance()->mCalendars.count() == 1 )
+ mCalendarBox->hide();
+ else
+ mCalendarBox->show();
+
+}
+int KOEditorGeneral::getCalendarID()
{
+ KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
+ while ( kkf ) {
+ if ( mCalendarBox->currentText() == kkf->mName)
+ return kkf->mCalNumber;
+ kkf = KOPrefs::instance()->mCalendars.next();
+ }
+ return 1;
+}
+void KOEditorGeneral::readIncidence(Incidence *event)
+{
+ fillCalCombo( event->calID() );
mAlarmMessage = event->summary();
if ( ! event->location().isEmpty() )
mAlarmMessage += " ("+event->location()+")";
mAlarmIncrCombo->setCurrentItem(0);
mSummaryEdit->setEditText(event->summary());
mLocationEdit->setEditText(event->location());
mDescriptionEdit->setText(event->description());
#if 0
// organizer information
mOwnerLabel->setText(i18n("Owner: ") + event->organizer());
#endif
enableAlarmEdit( event->isAlarmEnabled() );
//qDebug("KOEditorGeneral::readIncidence(Incidence *event) ");
if(!event->isAlarmEnabled()) {
// TODO: Implement a KPrefsComboItem to solve this in a clean way.
int alarmTime;
int a[] = { 1,5,10,15,30,60,180, 1440 };
int index = KOPrefs::instance()->mAlarmTime;
if (index < 0 || index > 7) {
alarmTime = 15;
} else {
alarmTime = a[index];
}
mAlarmTimeEdit->setValue(alarmTime);
}
mAlarmButton->setChecked( event->isAlarmEnabled() );
mSecrecyCombo->setCurrentItem(event->secrecy());
mCancelBox->setChecked( event->cancelled() );
mAlarmProgramButton->setOn(false);
mAlarmSoundButton->setOn(false);
@@ -540,33 +590,34 @@ void KOEditorGeneral::writeIncidence(Incidence *event)
if (mAlarmButton->isChecked()) {
if (event->alarms().count() == 0)
event->newAlarm();
QPtrList<Alarm> alarms = event->alarms();
Alarm *alarm;
for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
alarm->setEnabled(true);
int j = mAlarmTimeEdit->value()* -60;
if (mAlarmIncrCombo->currentItem() == 1)
j = j * 60;
else if (mAlarmIncrCombo->currentItem() == 2)
j = j * (60 * 24);
alarm->setStartOffset( j );
if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) {
alarm->setProcedureAlarm(mAlarmProgram);
}
else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn())
alarm->setAudioAlarm(mAlarmSound);
else
alarm->setType(Alarm::Invalid);
//alarm->setAudioAlarm("default");
// TODO: Deal with multiple alarms
break; // For now, stop after the first alarm
}
} else {
Alarm* alarm = event->alarms().first();
if ( alarm ) {
alarm->setEnabled(false);
alarm->setType(Alarm::Invalid);
}
}
+ event->setCalID( getCalendarID() );
}
diff --git a/korganizer/koeditorgeneral.h b/korganizer/koeditorgeneral.h
index c463403..d8b15af 100644
--- a/korganizer/koeditorgeneral.h
+++ b/korganizer/koeditorgeneral.h
@@ -6,116 +6,120 @@
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#ifndef KOEDITORGENERAL_H
#define KOEDITORGENERAL_H
#include <qframe.h>
#include <qlabel.h>
#include <qcheckbox.h>
#include <qpushbutton.h>
#include <qpopupmenu.h>
#include <qgroupbox.h>
#include <qlineedit.h>
#include <qcombobox.h>
#include <qlistview.h>
#include <qradiobutton.h>
#include <qlayout.h>
#include <qspinbox.h>
+#include <qcombobox.h>
#include <ktextedit.h>
#include <krestrictedline.h>
#include <libkcal/incidence.h>
#include "ktimeedit.h"
class KDateEdit;
class KOLocationBox;
using namespace KCal;
class KOEditorGeneral : public QObject
{
Q_OBJECT
public:
KOEditorGeneral (QObject* parent=0,const char* name=0);
virtual ~KOEditorGeneral();
void setFocusOn( int i );
void initHeader(QWidget *,QBoxLayout *);
void initDescription(QWidget *,QBoxLayout *);
void initSecrecy(QWidget *,QBoxLayout *);
void initCategories(QWidget *,QBoxLayout *);
void initAlarm(QWidget *,QBoxLayout *);
/** Set widgets to default values */
void setDefaults(bool allDay);
/** Read event object and setup widgets accordingly */
void readIncidence(Incidence *);
/** Write event settings to event object */
void writeIncidence(Incidence *);
/** Check if the input is valid. */
bool validateInput() { return true; }
void enableAlarm( bool enable );
void setSecrecy( int num );
+ int getCalendarID();
public slots:
void setCategories(const QString &);
void editCategories();
protected slots:
void enableAlarmEdit( bool enable );
void disableAlarmEdit( bool disable );
void alarmDisable( bool disable );
void pickAlarmSound();
void pickAlarmProgram();
void slotSetFocusOn();
void showCatPopup();
void selectedCatPopup( int );
signals:
void openCategoryDialog();
void allAccepted();
void dateTimesChanged(QDateTime,QDateTime);
protected:
+ void fillCalCombo( int setToID = 0 );
int mNextFocus;
//QLineEdit *mSummaryEdit;
//QLineEdit *mLocationEdit;
KOLocationBox *mSummaryEdit;
KOLocationBox *mLocationEdit;
+ QComboBox *mCalendarBox;
QLabel *mAlarmBell;
QCheckBox *mAlarmButton;
QSpinBox *mAlarmTimeEdit;
QPushButton *mAlarmSoundButton;
QPushButton *mAlarmProgramButton;
QComboBox *mAlarmIncrCombo;
KTextEdit *mDescriptionEdit;
QLabel *mOwnerLabel;
QComboBox *mSecrecyCombo;
QCheckBox *mCancelBox;
QPushButton *mCategoriesButton;
QPushButton *mCategoriesLabel;
private:
QPopupMenu * mCatPopup;
QString getFittingPath( const QString ) ;
QString mAlarmSound;
QString mAlarmProgram;
QString mAlarmMessage;
};
#endif
diff --git a/korganizer/koeventpopupmenu.cpp b/korganizer/koeventpopupmenu.cpp
index 77322e7..fc4d9a4 100644
--- a/korganizer/koeventpopupmenu.cpp
+++ b/korganizer/koeventpopupmenu.cpp
@@ -49,65 +49,64 @@ KOEventPopupMenu::KOEventPopupMenu(): QPopupMenu()
#ifndef DESKTOP_VERSION
mEditOnlyItems.append(insertItem (i18n("&Beam..."),
this,SLOT(popupBeam())));
#endif
mEditOnlyItems.append(insertItem (i18n("&Toggle Cancel"),
this,SLOT(popupCancel())));
isDisabled = false;
mCatPopup = new QPopupMenu ( this );
mCatPopup->setCheckable (true);
connect(mCatPopup,SIGNAL( aboutToShow ()), this ,SLOT( fillCatPopup()));
connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT( computeCatPopup( int )));
mCalPopup = new QPopupMenu ( this );
mCalPopup->setCheckable (true);
connect(mCalPopup,SIGNAL( aboutToShow ()), this ,SLOT( fillCalPopup()));
connect(mCalPopup,SIGNAL( activated ( int ) ), this ,SLOT( computeCalPopup( int )));
//mEditOnlyItems.append(insertItem (i18n("Categories"),mCatPopup ));
//mEditOnlyItems.append(insertItem (i18n("Calendar"),mCalPopup ));
insertItem (i18n("Categories"),mCatPopup );
insertItem (i18n("Calendar"),mCalPopup );
QValueList<int>::Iterator it;
for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) {
mSingleOnlyItems.append(*it);
}
}
void KOEventPopupMenu::enableDefault( bool enable )
{
isDisabled = !enable;
QValueList<int>::Iterator it;
for( it = mSingleOnlyItems.begin(); it != mSingleOnlyItems.end(); ++it ) {
setItemEnabled(*it,enable);
}
-
}
void KOEventPopupMenu::fillCalPopup() // CAL
{
mCalPopup->clear();
if (!mCurrentIncidence) return;
bool readO = mCurrentIncidence->isReadOnly()|| isDisabled;
KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
while ( kkf ) {
int index = mCalPopup->insertItem( kkf->mName, kkf->mCalNumber);
if ( kkf->mErrorOnLoad || kkf->isReadOnly || readO )
mCalPopup->setItemEnabled( index, false );
mCalPopup->setItemChecked (index, kkf->mCalNumber == mCurrentIncidence->calID());
kkf = KOPrefs::instance()->mCalendars.next();
}
}
void KOEventPopupMenu::computeCalPopup( int index ) // CAL
{
if (!mCurrentIncidence) return;
mCurrentIncidence->setCalID( index );
emit categoryChanged( mCurrentIncidence );
}
void KOEventPopupMenu::fillCatPopup()
{
mCatPopup->clear();
if (!mCurrentIncidence) return;
bool readO = mCurrentIncidence->isReadOnly() || isDisabled;
QStringList checkedCategories = mCurrentIncidence->categories();
int index = 0;
for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
it != KOPrefs::instance()->mCustomCategories.end ();
++it) {