summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-06-15 20:45:30 (UTC)
committer zautrix <zautrix>2005-06-15 20:45:30 (UTC)
commite74483434835ad799b1a6880ae4576aacb14624a (patch) (side-by-side diff)
tree2a060544e0f6b026d773032d65ab079d75879afd
parente17a686fcfab42a71f25e9f0a4c3a395ec41a7b1 (diff)
downloadkdepimpi-e74483434835ad799b1a6880ae4576aacb14624a.zip
kdepimpi-e74483434835ad799b1a6880ae4576aacb14624a.tar.gz
kdepimpi-e74483434835ad799b1a6880ae4576aacb14624a.tar.bz2
fixes
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--korganizer/kofilterview.cpp74
-rw-r--r--korganizer/kofilterview.h59
2 files changed, 95 insertions, 38 deletions
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp
index 105028a..36ee2eb 100644
--- a/korganizer/kofilterview.cpp
+++ b/korganizer/kofilterview.cpp
@@ -6,96 +6,63 @@
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.
*/
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qdialog.h>
+#include <qtextstream.h>
+#include <qtextcodec.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 )
: KOFilterView_base(parent,name,fl)
{
mFilters = filterList;
connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged()));
connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged()));
connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters()));
}
KOFilterView::~KOFilterView()
{
// no need to delete child widgets, Qt does it all for us
}
bool KOFilterView::filtersEnabled()
{
return mEnabledCheck->isChecked();
}
void KOFilterView::setFiltersEnabled(bool set)
@@ -352,58 +319,89 @@ void KOCalEditView::readConfig()
if ( row > 1) {
KColorButton *colb = new KColorButton( mw );
mainLayout->addWidget( colb,row,++iii );
colb->setID( kkf->mCalNumber );
colb->setColor( kkf->mDefaultColor );
connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) );
KOCalButton* calb = new KOCalButton( mw );
mainLayout->addWidget( calb,row,++iii );
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()
{
+ bool tryagain = true;
+ QString name, file;
+ while ( tryagain ) {
KONewCalPrefs prefs ( this );
+ if ( !name.isEmpty() ) prefs.nameE->setText( name );
+ if ( !file.isEmpty() ) prefs.url->setURL( file );
if ( ! prefs.exec() )
return;
- QString name = prefs.calName();
- QString file = prefs.calFileName();
+ name = prefs.calName();
+ file = prefs.calFileName();
+ tryagain = false;
+ KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
+ while ( kkf ) {
+ if ( kkf->mName == name ) {
+ KMessageBox::information( this, i18n("Sorry, the calendar name already exists!\nPlease choose another name!") );
+ name = "";
+ break;
+ tryagain = true;
+ }
+ if ( kkf->mFileName == file ) {
+
+ break;
+ tryagain = true;
+ }
+ kkf = KOPrefs::instance()->mCalendars.next();
+ }
+ }
QFileInfo fi ( file );
if (!fi.exists() ) {
- KMessageBox::information( this, i18n("File does not exist!\nNo calendar added!"));
+ if ( KMessageBox::questionYesNo(this, i18n("The file does not exist!\nShall I create it for you?")) == KMessageBox::No )
+ return;
+ QFile fileIn( file );
+ if (!fileIn.open( IO_WriteOnly ) ) {
+ KMessageBox::sorry( this, i18n("Sorry, cannot create the file!\nNo calendar added!") );
return;
}
+ QTextStream tsIn( &fileIn );
+ tsIn.setCodec( QTextCodec::codecForName("utf8") );
+ tsIn << "BEGIN:VCALENDAR\nPRODID:-//KDE-Pim//Platform-independent 2.1.0\nVERSION:2.0\nEND:VCALENDAR\n";
+ fileIn.close();
+ }
KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar();
kkf->mName = name;
kkf->mFileName = file;
emit calendarAdded( kkf->mCalNumber );
emit needsUpdate();
QTimer::singleShot( 0, this, SLOT ( readConfig() ) );
}
void KOCalEditView::enableAll()
{
toggleList( mEnabledB );
}
void KOCalEditView::enableAlarm()
{
toggleList( mAlarmB );
}
void KOCalEditView::disableRO()
{
toggleList( mROB );
}
void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list )
{
bool dis = false;
KOCalCheckButton* it = list.first();
while ( it ) {
diff --git a/korganizer/kofilterview.h b/korganizer/kofilterview.h
index 3ab316f..945947a 100644
--- a/korganizer/kofilterview.h
+++ b/korganizer/kofilterview.h
@@ -4,58 +4,117 @@
This program is free software; you can redistribute it and/or modify
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 KOFILTERVIEW_H
#define KOFILTERVIEW_H
#include <qstring.h>
#include <qcheckbox.h>
+#include <qlayout.h>
+#include <qlabel.h>
#include <qscrollview.h>
#include <qpushbutton.h>
#include <kconfig.h>
#include "kofilterview_base.h"
#include <libkcal/calfilter.h>
+#include <kurlrequester.h>
+#include <klineedit.h>
+#include <kglobal.h>
+#include <kmessagebox.h>
+
class QGridLayout;
using namespace KCal;
+
+class KONewCalPrefs : public QDialog
+{
+ Q_OBJECT
+ 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("<b>Local ical (*.ics) file:</b>"), 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 ( checkValid() ) );
+ connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
+ setMinimumWidth( 220 );
+ resize(sizeHint() );
+ }
+
+ QString calName() { return nameE->text(); }
+ QString calFileName() { return url->url(); }
+
+public slots:
+void checkValid() {
+ if ( nameE->text().isEmpty() ) {
+ KMessageBox::information( this, i18n("Sorry, the calendar name is empty!") );
+ nameE->setText( "LPQJ_"+ QString::number( QTime::currentTime().msec () ));
+ return;
+ }
+ if ( url->url().isEmpty() ) {
+ KMessageBox::information( this, i18n("Sorry, the file name is empty!") );
+ return;
+ }
+ accept();
+}
+
+public:
+ KLineEdit* nameE;
+ KURLRequester *url;
+};
+
class KOCalButton : public QPushButton
{
Q_OBJECT
public:
KOCalButton( QWidget *parent=0, const char *name=0 ) :
QPushButton( parent, name)
{
connect( this, SIGNAL( clicked() ),
SLOT( bottonClicked() ));
mNumber = -1;
setFocusPolicy(NoFocus);
}
void setNum ( int num ) {mNumber = num; }
signals:
void selectNum ( int );
private:
int mNumber;
void keyPressEvent ( QKeyEvent * e )
{
e->ignore();
}
private slots :
void bottonClicked() { if ( mNumber > 0 ) emit selectNum ( mNumber ); }