summaryrefslogtreecommitdiffabout
path: root/korganizer/kofilterview.cpp
authorzautrix <zautrix>2005-06-12 22:36:41 (UTC)
committer zautrix <zautrix>2005-06-12 22:36:41 (UTC)
commit5e4f16e92a96bdf89f82be3b231d18ae9e257486 (patch) (side-by-side diff)
tree6bf55a0ae92e95dc598a813ed7b7eef5c00dfb4f /korganizer/kofilterview.cpp
parent8cfca2b9b7ece646229a72843cf8d6d63e7b8af9 (diff)
downloadkdepimpi-5e4f16e92a96bdf89f82be3b231d18ae9e257486.zip
kdepimpi-5e4f16e92a96bdf89f82be3b231d18ae9e257486.tar.gz
kdepimpi-5e4f16e92a96bdf89f82be3b231d18ae9e257486.tar.bz2
fixxxx
Diffstat (limited to 'korganizer/kofilterview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kofilterview.cpp255
1 files changed, 231 insertions, 24 deletions
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp
index dc6237b..d79b28e 100644
--- a/korganizer/kofilterview.cpp
+++ b/korganizer/kofilterview.cpp
@@ -26,13 +26,56 @@
#include <qpushbutton.h>
#include <qlayout.h>
#include <qlabel.h>
+#include <qdialog.h>
#include <libkcal/calfilter.h>
#include "kofilterview.h"
+#include "koprefs.h"
#include <kiconloader.h>
#include <kglobal.h>
+#include <kcolorbutton.h>
+#include <kmessagebox.h>
+
+
+#include <kurlrequester.h>
+#include <klineedit.h>
+
+class KONewCalPrefs : public QDialog
+{
+ public:
+ KONewCalPrefs( QWidget *parent=0, const char *name=0 ) :
+ QDialog( parent, name, true )
+ {
+ setCaption( i18n("Add new Calendar") );
+ QVBoxLayout* lay = new QVBoxLayout( this );
+ lay->setSpacing( 3 );
+ lay->setMargin( 3 );
+ QLabel * lab = new QLabel( i18n("<b>Name of new calendar:</b>"), this );
+ lay->addWidget( lab );
+ nameE = new KLineEdit( this );
+ lay->addWidget( nameE );
+ lab = new QLabel( i18n("Local ical (*.ics) file:"), this );
+ lay->addWidget( lab );
+ url = new KURLRequester ( this );
+ lay->addWidget( url );
+ QPushButton * ok = new QPushButton( i18n("OK"), this );
+ lay->addWidget( ok );
+ QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
+ lay->addWidget( cancel );
+ connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
+ connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
+ resize( 200, 200 );
+ }
+
+ QString calName() { return nameE->text(); }
+ QString calFileName() { return url->url(); }
+private:
+ KLineEdit* nameE;
+ KURLRequester *url;
+};
+
KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent,
const char* name,WFlags fl )
@@ -103,72 +146,236 @@ KOCalEditView::KOCalEditView(QWidget* parent,
const char* name )
: QWidget(parent,name)
{
- /*
- connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged()));
- connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged()));
- connect(mEditButton,SIGNAL(clicked()),SIGNAL(editCalEdits()));
- */
- QGridLayout* mainLayout = new QGridLayout ( this , 2, 6 );
- QPushButton * addBut = new QPushButton ( this );
+ mw = 0;
+ ml = new QVBoxLayout ( this );
+}
+
+KOCalEditView::~KOCalEditView()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+void KOCalEditView::selectCal(int id ,bool b)
+{
+ KOPrefs::instance()->getCalendar( id )->isEnabled = b;
+ emit calendarEnabled ( id, b );
+
+}
+void KOCalEditView::selectStdCal( int id, bool b )
+{
+
+ if ( !b ) {
+ KOCalCheckButton* it = (KOCalCheckButton*) sender();
+ if ( it ) {
+ it->blockSignals( true );
+ it->setChecked( true );
+ it->blockSignals( false );
+ return;
+ }
+ return;
+ }
+ KOCalCheckButton* sen = (KOCalCheckButton*) sender();
+ KOCalCheckButton* it = mStdandardB.first();
+ while ( it ) {
+ if ( it->isChecked() ) {
+ if ( it != sen ) {
+ it->blockSignals( true );
+ it->setChecked( false );
+ it->blockSignals( false );
+ break;
+ }
+ }
+ it = mStdandardB.next();
+ }
+ KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
+ while ( kkf ) {
+ kkf->isStandard = false;
+ kkf = KOPrefs::instance()->mCalendars.next();
+ }
+ KOPrefs::instance()->getCalendar( id )->isStandard = true;
+ emit setCalendarDefault ( id );
+}
+
+void KOCalEditView::selectCalAlarm(int id ,bool b )
+{
+ KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b;
+ emit alarmEnabled ( id , b );
+}
+void KOCalEditView::selectReadOnly(int id ,bool b )
+{
+ KOPrefs::instance()->getCalendar( id )->isReadOnly = b;
+ emit calendarReadonly ( id , b );
+
+}
+void KOCalEditView::setColor( const QColor& c, int id )
+{
+ KOPrefs::instance()->getCalendar( id )->mDefaultColor = c;
+}
+void KOCalEditView::deleteCal( int id )
+{
+ KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id );
+ QString name = kkf->mName;
+ QString file = kkf->mFileName;
+ if ( KMessageBox::warningContinueCancel( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b><tr> Do you want to remove this calendar from KO/Pi? (The file is not removed, of course!)").arg(name).arg(file) ) != KMessageBox::Continue ) return;
+ emit removeCalendar ( id );
+ KOPrefs::instance()->mCalendars.remove ( kkf );
+ readConfig();
+}
+void KOCalEditView::infoCal( int id )
+{
+ QString name = KOPrefs::instance()->getCalendar( id )->mName;
+ QString file = KOPrefs::instance()->getCalendar( id )->mFileName;
+ KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) );
+}
+void KOCalEditView::readConfig()
+{
+
+ mStdandardB.clear();
+ mEnabledB.clear();
+ mAlarmB.clear();
+ mROB.clear();
+
+ if ( mw ) delete mw;
+ mw = new QWidget ( this );
+ ml->addWidget ( mw );
+
+ mainLayout = new QGridLayout ( mw , 2, 8 );
+ mainLayout->setSpacing( 3 );
+ QPushButton * addBut = new QPushButton ( mw );
mainLayout->addWidget( addBut,0,0 );
addBut->setPixmap ( SmallIcon("plus"));
connect(addBut,SIGNAL(clicked()),SLOT(addCal()));
addBut->setMaximumWidth( addBut->sizeHint().height() );
- addBut = new QPushButton ( this );
+ addBut = new QPushButton ( mw );
mainLayout->addWidget( addBut,0,1 );
addBut->setPixmap ( SmallIcon("eye"));
connect(addBut,SIGNAL(clicked()),SLOT(enableAll()));
addBut->setMaximumWidth( addBut->sizeHint().height() );
- QLabel* lab = new QLabel ( " "+i18n("Calendar")+" ", this );
+ QLabel* lab = new QLabel ( " "+i18n("Calendar")+" ", mw );
mainLayout->addWidget( lab,0,2 );
- addBut = new QPushButton ( this );
+ addBut = new QPushButton ( mw );
mainLayout->addWidget( addBut,0,3 );
addBut->setPixmap ( SmallIcon("bell"));
connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm()));
addBut->setMaximumWidth( addBut->sizeHint().height() );
- addBut = new QPushButton ( this );
+ addBut = new QPushButton ( mw );
mainLayout->addWidget( addBut,0,4 );
addBut->setPixmap ( SmallIcon("pencil"));
connect(addBut,SIGNAL(clicked()),SLOT(disableRO()));
addBut->setMaximumWidth( addBut->sizeHint().height() );
- addBut = new QPushButton ( this );
- mainLayout->addWidget( addBut,0,5 );
+ lab = new QLabel ( i18n(" Color "), mw );
+ mainLayout->addWidget( lab,0,5 );
+#if 0
+ addBut = new QPushButton ( mw );
+ mainLayout->addWidget( addBut,0,6 );
addBut->setPixmap ( SmallIcon("minus"));
connect(addBut,SIGNAL(clicked()),SLOT(deleteAll()));
addBut->setMaximumWidth( addBut->sizeHint().height() );
+#endif
+ KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
+ int row = 1;
+ while ( kkf ) {
-}
-
-KOCalEditView::~KOCalEditView()
-{
- // no need to delete child widgets, Qt does it all for us
-}
-void KOCalEditView::readConfig( KConfig *)
-{
+ KOCalCheckButton* cb = new KOCalCheckButton( mw );
+ mainLayout->addWidget( cb,row,0 );mStdandardB.append( cb );
+ cb->setChecked( kkf->isStandard );
+ cb->setNum( kkf->mCalNumber );
+ connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectStdCal(int,bool) ) );
+ cb = new KOCalCheckButton( mw );
+ mainLayout->addWidget( cb,row,1 );mEnabledB.append( cb );
+ cb->setChecked( kkf->isEnabled );
+ cb->setNum( kkf->mCalNumber );
+ connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) );
+ KOCalButton* name = new KOCalButton( mw );
+ name->setNum( kkf->mCalNumber );
+ name->setText( kkf->mName );
+ mainLayout->addWidget( name,row,2 );
+ connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) );
+ cb = new KOCalCheckButton( mw );
+ mainLayout->addWidget( cb,row,3 );mAlarmB.append( cb );
+ cb->setChecked( kkf->isAlarmEnabled );
+ cb->setNum( kkf->mCalNumber );
+ connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) );
+ cb = new KOCalCheckButton( mw );
+ mainLayout->addWidget( cb,row,4 );mROB.append( cb );
+ cb->setChecked( kkf->isReadOnly );
+ cb->setNum( kkf->mCalNumber );
+ connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) );
+ KColorButton *colb = new KColorButton( mw );
+ mainLayout->addWidget( colb,row,5 );
+ colb->setID( kkf->mCalNumber );
+ colb->setColor( kkf->mDefaultColor );
+ connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) );
+ if ( row > 1) {
+ KOCalButton* calb = new KOCalButton( mw );
+ mainLayout->addWidget( calb,row,6 );
+ calb->setNum( kkf->mCalNumber );
+ calb->setPixmap ( SmallIcon("minus"));
+ connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) );
+ int hei = calb->sizeHint().height();
+ calb->setMaximumSize( hei*9/10, hei*9/10 );
+ }
+ ++row;
+ kkf = KOPrefs::instance()->mCalendars.next();
+ }
+ lab = new QLabel ( "", mw );
+ mainLayout->addWidget( lab,row,0 );
+ mw->show();
}
void KOCalEditView::addCal()
{
qDebug("addcal ");
+ KONewCalPrefs prefs ( this );
+ if ( ! prefs.exec() )
+ return;
+ QString name = prefs.calName();
+ QString file = prefs.calFileName();
+ QFileInfo fi ( file );
+ if (!fi.exists() ) {
+ KMessageBox::information( this, i18n("File does not exist!\nNo calendar added!"));
+ return;
+ }
+ KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar();
+ kkf->mName = name;
+ kkf->mFileName = file;
+ emit calendarAdded( kkf->mCalNumber );
+ readConfig();
}
void KOCalEditView::enableAll()
{
- qDebug("enableAll");
+ toggleList( mEnabledB );
}
void KOCalEditView::enableAlarm()
{
- qDebug("enableAlarm");
+ toggleList( mAlarmB );
}
void KOCalEditView::disableRO()
{
- qDebug("OCalEditView::disableRO() ");
+ toggleList( mROB );
+}
+void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list )
+{
+ bool dis = false;
+ KOCalCheckButton* it = list.first();
+ while ( it ) {
+ if ( !it->isChecked() ) {
+ dis = true;
+ break;
+ }
+ it = list.next();
+ }
+ it = list.first();
+ while ( it ) {
+ it->setChecked(dis);
+ it = list.next();
+ }
}
void KOCalEditView::deleteAll()
{