summaryrefslogtreecommitdiffabout
path: root/korganizer/kofilterview.h
blob: f1bbab425e124c2e3f3183ad6f35dae797e56285 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
/*
    This file is part of KOrganizer.
    Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>

    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 <qapplication.h>
#include <QDesktopWidget>
#include <qradiobutton.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qdialog.h>
#include <q3scrollview.h>
#include <qpushbutton.h>
//Added by qt3to4:
#include <Q3GridLayout>
#include <Q3PtrList>
#include <QKeyEvent>
#include <Q3VBoxLayout>
#include <kconfig.h>
#include "kofilterview_base.h"

#include <libkcal/calfilter.h>

#include <kurlrequester.h>
#include <klineedit.h>
#include <kglobal.h>
#include <kmessagebox.h>

class Q3GridLayout;

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") );
        Q3VBoxLayout* lay = new Q3VBoxLayout( 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>iCal (*.ics) file on disk:</b><br>(will be created, if not existing)"), 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())  );
        int minwid = 440;
        if ( QApplication::desktop()->width() < 480 ) minwid = 220;
        setMinimumWidth(  minwid );
        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!") ); 
        url->setURL( nameE->text() + ".ics" );
        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(Qt::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 ); }
};
class KOCalCheckButton : public QCheckBox
{
    Q_OBJECT
  public:
    KOCalCheckButton( QWidget *parent=0, const char *name=0 ) :
      QCheckBox( parent, name) 
    {
      connect( this, SIGNAL( toggled ( bool ) ),
               SLOT( bottonClicked( bool ) )); 
      mNumber = -1;
      setFocusPolicy(Qt::NoFocus); 
      //setMaximumWidth( 10 );

    }
    void setNum ( int num ) {mNumber = num; }
    signals:
    void selectNum ( int, bool );
private: 
    int mNumber;
    void keyPressEvent ( QKeyEvent * e )
    {
        e->ignore();     
    }

private slots :
    void bottonClicked( bool b) { if ( mNumber > 0 ) emit selectNum ( mNumber , b); }
};

class KOCalRadioButton : public QRadioButton
{
    Q_OBJECT
  public:
    KOCalRadioButton( QWidget *parent=0, const char *name=0 ) :
      QRadioButton( parent, name) 
    {
      connect( this, SIGNAL( toggled ( bool ) ),
               SLOT( bottonClicked( bool ) )); 
      mNumber = -1;
      setFocusPolicy(Qt::NoFocus); 
      //setMaximumWidth( 10 );

    }
        int num() { return mNumber;}
    void setNum ( int num ) {mNumber = num; }
    signals:
    void selectNum ( int );
private: 
    int mNumber;
    void keyPressEvent ( QKeyEvent * e )
    {
        e->ignore();     
    }

private slots :
    void bottonClicked( bool b) { if ( mNumber > 0  ) emit selectNum ( mNumber); }
};



class KOFilterView : public KOFilterView_base
{
    Q_OBJECT
  public:
    KOFilterView(Q3PtrList<CalFilter> *filterList,QWidget* parent=0,const char* name=0, Qt::WFlags fl=0);
    ~KOFilterView();

    void updateFilters();

    bool filtersEnabled();
    void setFiltersEnabled(bool);
    CalFilter *selectedFilter();
    void setSelectedFilter(QString);
    void setSelectedFilter( int );

  signals:
    void filterChanged();
    void editFilters();

  private:
    Q3PtrList<CalFilter> *mFilters;
};

class KOCalEditView : public Q3ScrollView
{
    Q_OBJECT
  public:
    KOCalEditView( QWidget* parent=0,const char* name=0);
    ~KOCalEditView();
    int addCalendar( QString calName, QString fileName, bool ask = true );
    int getBirtdayID();
    public slots:
    void addCal();
    void enableAll();
    void enableAlarm();
    void disableRO();
    void deleteAll();
    void selectStdCal(int);
    void selectCal(int,bool );
    void selectCalAlarm(int,bool );
    void selectReadOnly(int,bool );
    void setColor(const QColor &,int) ;
    void deleteCal(int) ;
    void infoCal(int) ;
    void readConfig(); 
    void defaultInfo();
    void findNewStandard();
  signals:
    void alarmEnabled ( int cal, bool enable );
    void calendarEnabled ( int cal, bool enable );
    void calendarReadonly ( int cal, bool readonly );
    void setCalendarDefault ( int cal );
    void removeCalendar ( int cal );
    void calendarAdded( int );
    void needsUpdate();
    void checkCalendar();
    void requestCalendarInfo( int id );

  private:
    QWidget *mw;
    void toggleList ( Q3PtrList<KOCalCheckButton> , bool b = true );
    Q3PtrList<KOCalRadioButton> mStdandardB;
    Q3PtrList<KOCalCheckButton> mEnabledB;
    Q3PtrList<KOCalCheckButton> mAlarmB;
    Q3PtrList<KOCalCheckButton> mROB;
    Q3GridLayout* mainLayout; 
};



#endif // KOFILTERVIEW_H