Diffstat (limited to 'noncore/apps/tinykate/libkate/microkde') (more/less context) (ignore whitespace changes)
58 files changed, 4008 insertions, 0 deletions
diff --git a/noncore/apps/tinykate/libkate/microkde/kaction.h b/noncore/apps/tinykate/libkate/microkde/kaction.h new file mode 100644 index 0000000..622330e --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kaction.h | |||
@@ -0,0 +1,8 @@ | |||
1 | #ifndef MINIKDE_KACTION_H | ||
2 | #define MINIKDE_KACTION_H | ||
3 | |||
4 | #include <qaction.h> | ||
5 | |||
6 | #define KAction QAction | ||
7 | |||
8 | #endif | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kapplication.cpp b/noncore/apps/tinykate/libkate/microkde/kapplication.cpp new file mode 100644 index 0000000..60ed579 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kapplication.cpp | |||
@@ -0,0 +1,8 @@ | |||
1 | #include <stdlib.h> | ||
2 | |||
3 | #include "kapplication.h" | ||
4 | |||
5 | int KApplication::random() | ||
6 | { | ||
7 | return rand(); | ||
8 | } | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kapplication.h b/noncore/apps/tinykate/libkate/microkde/kapplication.h new file mode 100644 index 0000000..99fb4f0 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kapplication.h | |||
@@ -0,0 +1,11 @@ | |||
1 | #ifndef MINIKDE_KAPPLICATION_H | ||
2 | #define MINIKDE_KAPPLICATION_H | ||
3 | |||
4 | class KApplication | ||
5 | { | ||
6 | public: | ||
7 | static int random(); | ||
8 | static int cursorFlashTime() { return 1000; } | ||
9 | }; | ||
10 | |||
11 | #endif | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kcolorbtn.cpp b/noncore/apps/tinykate/libkate/microkde/kcolorbtn.cpp new file mode 100644 index 0000000..5d21f15 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kcolorbtn.cpp | |||
@@ -0,0 +1,84 @@ | |||
1 | /* This file is part of the KDE libraries | ||
2 | Copyright (C) 1997 Martin Jones (mjones@kde.org) | ||
3 | Copyright (C) 1999 Cristian Tibirna (ctibirna@kde.org) | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Library General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Library General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Library General Public License | ||
16 | along with this library; see the file COPYING.LIB. If not, write to | ||
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | #include <qdialog.h> | ||
22 | #include <qpainter.h> | ||
23 | #include <qdrawutil.h> | ||
24 | #include <qapplication.h> | ||
25 | #include <kglobalsettings.h> | ||
26 | #include "kcolordialog.h" | ||
27 | #include "kcolorbtn.h" | ||
28 | |||
29 | KColorButton::KColorButton( QWidget *parent, const char *name ) | ||
30 | : QPushButton( parent, name ), dragFlag(false) | ||
31 | { | ||
32 | // 2000-10-15 (putzer): fixes broken keyboard usage | ||
33 | connect (this, SIGNAL(clicked()), this, SLOT(chooseColor())); | ||
34 | } | ||
35 | |||
36 | KColorButton::KColorButton( const QColor &c, QWidget *parent, | ||
37 | const char *name ) | ||
38 | : QPushButton( parent, name ), col(c), dragFlag(false) | ||
39 | { | ||
40 | |||
41 | // 2000-10-15 (putzer): fixes broken keyboard usage | ||
42 | connect (this, SIGNAL(clicked()), this, SLOT(chooseColor())); | ||
43 | } | ||
44 | |||
45 | void KColorButton::setColor( const QColor &c ) | ||
46 | { | ||
47 | col = c; | ||
48 | repaint( false ); | ||
49 | } | ||
50 | |||
51 | void KColorButton::drawButtonLabel( QPainter *painter ) | ||
52 | { | ||
53 | QRect r = QApplication::style().buttonRect( 0, 0, width(), height() ); | ||
54 | int l = r.x(); | ||
55 | int t = r.y(); | ||
56 | int w = r.width(); | ||
57 | int h = r.height(); | ||
58 | int b = 5; | ||
59 | |||
60 | QColor lnCol = colorGroup().text(); | ||
61 | QColor fillCol = isEnabled() ? col : backgroundColor(); | ||
62 | |||
63 | if ( isDown() ) { | ||
64 | qDrawPlainRect( painter, l+b+1, t+b+1, w-b*2, h-b*2, lnCol, 1, 0 ); | ||
65 | b++; | ||
66 | painter->fillRect( l+b+1, t+b+1, w-b*2, h-b*2, fillCol ); | ||
67 | } else { | ||
68 | qDrawPlainRect( painter, l+b, t+b, w-b*2, h-b*2, lnCol, 1, 0 ); | ||
69 | b++; | ||
70 | painter->fillRect( l+b, t+b, w-b*2, h-b*2, fillCol ); | ||
71 | } | ||
72 | } | ||
73 | |||
74 | void KColorButton::chooseColor() | ||
75 | { | ||
76 | if( KColorDialog::getColor( col) == QDialog::Rejected ) | ||
77 | { | ||
78 | return; | ||
79 | } | ||
80 | |||
81 | repaint( false ); | ||
82 | emit changed( col ); | ||
83 | } | ||
84 | |||
diff --git a/noncore/apps/tinykate/libkate/microkde/kcolorbtn.h b/noncore/apps/tinykate/libkate/microkde/kcolorbtn.h new file mode 100644 index 0000000..b79d5e8 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kcolorbtn.h | |||
@@ -0,0 +1,92 @@ | |||
1 | /* This file is part of the KDE libraries | ||
2 | Copyright (C) 1997 Martin Jones (mjones@kde.org) | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Library General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 2 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | Library General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to | ||
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
17 | Boston, MA 02111-1307, USA. | ||
18 | */ | ||
19 | |||
20 | #ifndef __COLBTN_H__ | ||
21 | #define __COLBTN_H__ | ||
22 | |||
23 | #include <qpushbutton.h> | ||
24 | |||
25 | /** | ||
26 | * This widget can be used to display or allow user selection of a colour. | ||
27 | * | ||
28 | * @see KColorDialog | ||
29 | * | ||
30 | * @short A pushbutton to display or allow user selection of a colour. | ||
31 | * @version $Id$ | ||
32 | */ | ||
33 | class KColorButton : public QPushButton | ||
34 | { | ||
35 | Q_OBJECT | ||
36 | Q_PROPERTY( QColor color READ color WRITE setColor ) | ||
37 | |||
38 | public: | ||
39 | /** | ||
40 | * Constructor. Create a KColorButton. | ||
41 | */ | ||
42 | KColorButton( QWidget *parent, const char *name = 0L ); | ||
43 | /** | ||
44 | * Constructor. Create a KColorButton. | ||
45 | * @param cThe initial colour of the button. | ||
46 | */ | ||
47 | KColorButton( const QColor &c, QWidget *parent, const char *name = 0L ); | ||
48 | /** | ||
49 | * Destructor. | ||
50 | */ | ||
51 | virtual ~KColorButton() {} | ||
52 | |||
53 | /** | ||
54 | * The current colour. | ||
55 | * @return The current colour. | ||
56 | */ | ||
57 | QColor color() const | ||
58 | {return col; } | ||
59 | /** | ||
60 | * Set the current colour. | ||
61 | * | ||
62 | * @param cThe colour to set. | ||
63 | */ | ||
64 | void setColor( const QColor &c ); | ||
65 | |||
66 | signals: | ||
67 | /** | ||
68 | * This signal will be emitted when the colour of the widget | ||
69 | * is changed, either with @ref #setColor() or via user selection. | ||
70 | */ | ||
71 | void changed( const QColor &newColor ); | ||
72 | |||
73 | protected slots: | ||
74 | void chooseColor(); | ||
75 | |||
76 | protected: | ||
77 | /** | ||
78 | * @reimplemented | ||
79 | */ | ||
80 | virtual void drawButtonLabel( QPainter *p ); | ||
81 | |||
82 | private: | ||
83 | QColor col; | ||
84 | QPoint mPos; | ||
85 | bool dragFlag; | ||
86 | |||
87 | class KColorButtonPrivate; | ||
88 | KColorButtonPrivate *d; | ||
89 | }; | ||
90 | |||
91 | #endif | ||
92 | |||
diff --git a/noncore/apps/tinykate/libkate/microkde/kcolorbutton.h b/noncore/apps/tinykate/libkate/microkde/kcolorbutton.h new file mode 100644 index 0000000..b446eca --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kcolorbutton.h | |||
@@ -0,0 +1,4 @@ | |||
1 | #ifndef K_COLOR_BUTTON_H | ||
2 | #define K_COLOR_BUTTON_H | ||
3 | #include <kcolorbtn.h> | ||
4 | #endif | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kcolordialog.cpp b/noncore/apps/tinykate/libkate/microkde/kcolordialog.cpp new file mode 100644 index 0000000..3aee42a --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kcolordialog.cpp | |||
@@ -0,0 +1,6 @@ | |||
1 | #include "kcolordialog.h" | ||
2 | |||
3 | int KColorDialog::getColor( const QColor & ) | ||
4 | { | ||
5 | return 0; | ||
6 | } | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kcolordialog.h b/noncore/apps/tinykate/libkate/microkde/kcolordialog.h new file mode 100644 index 0000000..0f831cd --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kcolordialog.h | |||
@@ -0,0 +1,14 @@ | |||
1 | #ifndef MINIKDE_KCOLORDIALOG_H | ||
2 | #define MINIKDE_KCOLORDIALOG_H | ||
3 | |||
4 | #include <qcolor.h> | ||
5 | |||
6 | class KColorDialog | ||
7 | { | ||
8 | public: | ||
9 | enum { Accepted }; | ||
10 | |||
11 | static int getColor( const QColor & ); | ||
12 | }; | ||
13 | |||
14 | #endif | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kconfig.cpp b/noncore/apps/tinykate/libkate/microkde/kconfig.cpp new file mode 100644 index 0000000..d88bda0 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kconfig.cpp | |||
@@ -0,0 +1,181 @@ | |||
1 | #include <qfile.h> | ||
2 | #include <qtextstream.h> | ||
3 | |||
4 | #include "kdebug.h" | ||
5 | |||
6 | #include "kconfig.h" | ||
7 | |||
8 | QString KConfig::mGroup = ""; | ||
9 | //QString KConfig::mGroup = "General"; | ||
10 | |||
11 | KConfig::KConfig( const QString &fileName ) | ||
12 | : mFileName( fileName ), mDirty( false ) | ||
13 | { | ||
14 | kdDebug() << "KConfig::KConfig(): '" << fileName << "'" << endl; | ||
15 | |||
16 | load(); | ||
17 | } | ||
18 | |||
19 | |||
20 | KConfig::~KConfig() | ||
21 | { | ||
22 | sync(); | ||
23 | } | ||
24 | |||
25 | void KConfig::setGroup( const QString &group ) | ||
26 | { | ||
27 | return; | ||
28 | |||
29 | // kdDebug() << "KConfig::setGroup(): '" << group << "'" << endl; | ||
30 | |||
31 | mGroup = group; | ||
32 | |||
33 | if ( mGroup.right( 1 ) != "/" ) mGroup += "/"; | ||
34 | } | ||
35 | |||
36 | |||
37 | QValueList<int> KConfig::readIntListEntry( const QString & ) | ||
38 | { | ||
39 | QValueList<int> l; | ||
40 | return l; | ||
41 | } | ||
42 | |||
43 | int KConfig::readNumEntry( const QString &, int def ) | ||
44 | { | ||
45 | return def; | ||
46 | } | ||
47 | |||
48 | QString KConfig::readEntry( const QString &key, const QString &def ) | ||
49 | { | ||
50 | QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key ); | ||
51 | |||
52 | if ( it == mStringMap.end() ) { | ||
53 | return def; | ||
54 | } | ||
55 | |||
56 | return *it; | ||
57 | } | ||
58 | |||
59 | QStringList KConfig::readListEntry( const QString & ) | ||
60 | { | ||
61 | return QStringList(); | ||
62 | } | ||
63 | |||
64 | bool KConfig::readBoolEntry( const QString &key, bool def ) | ||
65 | { | ||
66 | QMap<QString,bool>::ConstIterator it = mBoolMap.find( mGroup + key ); | ||
67 | |||
68 | if ( it == mBoolMap.end() ) { | ||
69 | return def; | ||
70 | } | ||
71 | |||
72 | return *it; | ||
73 | } | ||
74 | |||
75 | QColor KConfig::readColorEntry( const QString &, QColor *def ) | ||
76 | { | ||
77 | if ( def ) return *def; | ||
78 | return QColor(); | ||
79 | } | ||
80 | |||
81 | QFont KConfig::readFontEntry( const QString &, QFont *def ) | ||
82 | { | ||
83 | if ( def ) return *def; | ||
84 | return QFont(); | ||
85 | } | ||
86 | |||
87 | |||
88 | void KConfig::writeEntry( const QString &, QValueList<int> ) | ||
89 | { | ||
90 | } | ||
91 | |||
92 | void KConfig::writeEntry( const QString &, int ) | ||
93 | { | ||
94 | } | ||
95 | |||
96 | void KConfig::writeEntry( const QString &key, const QString &value ) | ||
97 | { | ||
98 | mStringMap.insert( mGroup + key, value ); | ||
99 | |||
100 | mDirty = true; | ||
101 | } | ||
102 | |||
103 | void KConfig::writeEntry( const QString &, const QStringList & ) | ||
104 | { | ||
105 | } | ||
106 | |||
107 | void KConfig::writeEntry( const QString &key, bool value) | ||
108 | { | ||
109 | mBoolMap.insert( mGroup + key, value ); | ||
110 | |||
111 | mDirty = true; | ||
112 | } | ||
113 | |||
114 | void KConfig::writeEntry( const QString &, const QColor & ) | ||
115 | { | ||
116 | } | ||
117 | |||
118 | void KConfig::writeEntry( const QString &, const QFont & ) | ||
119 | { | ||
120 | } | ||
121 | |||
122 | void KConfig::load() | ||
123 | { | ||
124 | mBoolMap.clear(); | ||
125 | mStringMap.clear(); | ||
126 | |||
127 | QFile f( mFileName ); | ||
128 | if ( !f.open( IO_ReadOnly ) ) { | ||
129 | kdDebug() << "KConfig::load(): Can't open file '" << mFileName << "'" | ||
130 | << endl; | ||
131 | return; | ||
132 | } | ||
133 | |||
134 | |||
135 | QTextStream t( &f ); | ||
136 | |||
137 | QString line = t.readLine(); | ||
138 | |||
139 | while ( !line.isNull() ) { | ||
140 | QStringList tokens = QStringList::split( ",", line ); | ||
141 | if ( tokens[0] == "bool" ) { | ||
142 | bool value = false; | ||
143 | if ( tokens[2] == "1" ) value = true; | ||
144 | |||
145 | mBoolMap.insert( tokens[1], value ); | ||
146 | } else if ( tokens[0] == "QString" ) { | ||
147 | QString value = tokens[2]; | ||
148 | mStringMap.insert( tokens[1], value ); | ||
149 | } | ||
150 | |||
151 | line = t.readLine(); | ||
152 | } | ||
153 | } | ||
154 | |||
155 | void KConfig::sync() | ||
156 | { | ||
157 | if ( !mDirty ) return; | ||
158 | |||
159 | QFile f( mFileName ); | ||
160 | if ( !f.open( IO_WriteOnly ) ) { | ||
161 | kdDebug() << "KConfig::sync(): Can't open file '" << mFileName << "'" | ||
162 | << endl; | ||
163 | return; | ||
164 | } | ||
165 | |||
166 | QTextStream t( &f ); | ||
167 | |||
168 | QMap<QString,bool>::ConstIterator itBool; | ||
169 | for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) { | ||
170 | t << "bool," << itBool.key() << "," << (*itBool ) << endl; | ||
171 | } | ||
172 | |||
173 | QMap<QString,QString>::ConstIterator itString; | ||
174 | for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) { | ||
175 | t << "QString," << itString.key() << "," << (*itString ) << endl; | ||
176 | } | ||
177 | |||
178 | f.close(); | ||
179 | |||
180 | mDirty = false; | ||
181 | } | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kconfig.h b/noncore/apps/tinykate/libkate/microkde/kconfig.h new file mode 100644 index 0000000..8bd768a --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kconfig.h | |||
@@ -0,0 +1,51 @@ | |||
1 | #ifndef MINIKDE_KCONFIG_H | ||
2 | #define MINIKDE_KCONFIG_H | ||
3 | |||
4 | #include <qstring.h> | ||
5 | #include <qstringlist.h> | ||
6 | #include <qvaluelist.h> | ||
7 | #include <qcolor.h> | ||
8 | #include <qfont.h> | ||
9 | #include <qmap.h> | ||
10 | |||
11 | class KConfig | ||
12 | { | ||
13 | public: | ||
14 | KConfig( const QString & ); | ||
15 | ~KConfig(); | ||
16 | |||
17 | void setGroup( const QString & ); | ||
18 | |||
19 | bool hasGroup( const QString &) {return false;} | ||
20 | |||
21 | QValueList<int> readIntListEntry( const QString & ); | ||
22 | int readNumEntry( const QString &, int def=0 ); | ||
23 | QString readEntry( const QString &, const QString &def=QString::null ); | ||
24 | QStringList readListEntry( const QString & ); | ||
25 | bool readBoolEntry( const QString &, bool def=false ); | ||
26 | QColor readColorEntry( const QString &, QColor * ); | ||
27 | QFont readFontEntry( const QString &, QFont * ); | ||
28 | |||
29 | void writeEntry( const QString &, QValueList<int> ); | ||
30 | void writeEntry( const QString &, int ); | ||
31 | void writeEntry( const QString &, const QString & ); | ||
32 | void writeEntry( const QString &, const QStringList & ); | ||
33 | void writeEntry( const QString &, bool ); | ||
34 | void writeEntry( const QString &, const QColor & ); | ||
35 | void writeEntry( const QString &, const QFont & ); | ||
36 | |||
37 | void load(); | ||
38 | void sync(); | ||
39 | |||
40 | private: | ||
41 | static QString mGroup; | ||
42 | |||
43 | QString mFileName; | ||
44 | |||
45 | QMap<QString,bool> mBoolMap; | ||
46 | QMap<QString,QString> mStringMap; | ||
47 | |||
48 | bool mDirty; | ||
49 | }; | ||
50 | |||
51 | #endif | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kdatepicker.cpp b/noncore/apps/tinykate/libkate/microkde/kdatepicker.cpp new file mode 100644 index 0000000..2cdd609 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kdatepicker.cpp | |||
@@ -0,0 +1,405 @@ | |||
1 | /* -*- C++ -*- | ||
2 | This file is part of the KDE libraries | ||
3 | Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) | ||
4 | (C) 1998-2001 Mirko Boehm (mirko@kde.org) | ||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Library General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Library General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Library General Public License | ||
16 | along with this library; see the file COPYING.LIB. If not, write to | ||
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | #include "kdatepicker.h" | ||
22 | #include <kglobal.h> | ||
23 | #include <kapplication.h> | ||
24 | #include <klocale.h> | ||
25 | #include <kiconloader.h> | ||
26 | #include <qframe.h> | ||
27 | #include <qpainter.h> | ||
28 | #include <qdialog.h> | ||
29 | #include <qtoolbutton.h> | ||
30 | #include <qfont.h> | ||
31 | #include <qlineedit.h> | ||
32 | #include <qvalidator.h> | ||
33 | #include <kdebug.h> | ||
34 | #include <knotifyclient.h> | ||
35 | #include "kdatetbl.h" | ||
36 | #include "kdatepicker.moc" | ||
37 | |||
38 | |||
39 | KDatePicker::KDatePicker(QWidget *parent, QDate dt, const char *name) | ||
40 | : QFrame(parent,name), | ||
41 | yearForward(new QToolButton(this)), | ||
42 | yearBackward(new QToolButton(this)), | ||
43 | monthForward(new QToolButton(this)), | ||
44 | monthBackward(new QToolButton(this)), | ||
45 | selectMonth(new QToolButton(this)), | ||
46 | selectYear(new QToolButton(this)), | ||
47 | line(new QLineEdit(this)), | ||
48 | val(new KDateValidator(this)), | ||
49 | table(new KDateTable(this)), | ||
50 | fontsize(10) | ||
51 | { | ||
52 | // ----- | ||
53 | setFontSize(10); | ||
54 | line->setValidator(val); | ||
55 | yearForward->setPixmap(BarIcon(QString::fromLatin1("2rightarrow"))); | ||
56 | yearBackward->setPixmap(BarIcon(QString::fromLatin1("2leftarrow"))); | ||
57 | monthForward->setPixmap(BarIcon(QString::fromLatin1("1rightarrow"))); | ||
58 | monthBackward->setPixmap(BarIcon(QString::fromLatin1("1leftarrow"))); | ||
59 | setDate(dt); // set button texts | ||
60 | connect(table, SIGNAL(dateChanged(QDate)), SLOT(dateChangedSlot(QDate))); | ||
61 | connect(table, SIGNAL(tableClicked()), SLOT(tableClickedSlot())); | ||
62 | connect(monthForward, SIGNAL(clicked()), SLOT(monthForwardClicked())); | ||
63 | connect(monthBackward, SIGNAL(clicked()), SLOT(monthBackwardClicked())); | ||
64 | connect(yearForward, SIGNAL(clicked()), SLOT(yearForwardClicked())); | ||
65 | connect(yearBackward, SIGNAL(clicked()), SLOT(yearBackwardClicked())); | ||
66 | connect(selectMonth, SIGNAL(clicked()), SLOT(selectMonthClicked())); | ||
67 | connect(selectYear, SIGNAL(clicked()), SLOT(selectYearClicked())); | ||
68 | connect(line, SIGNAL(returnPressed()), SLOT(lineEnterPressed())); | ||
69 | } | ||
70 | |||
71 | KDatePicker::~KDatePicker() | ||
72 | { | ||
73 | } | ||
74 | |||
75 | void | ||
76 | KDatePicker::resizeEvent(QResizeEvent*) | ||
77 | { | ||
78 | QWidget *buttons[] = { | ||
79 | yearBackward, | ||
80 | monthBackward, | ||
81 | selectMonth, | ||
82 | selectYear, | ||
83 | monthForward, | ||
84 | yearForward }; | ||
85 | const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]); | ||
86 | QSize sizes[NoOfButtons]; | ||
87 | int buttonHeight=0; | ||
88 | int count; | ||
89 | int w; | ||
90 | int x=0; | ||
91 | // ----- calculate button row height: | ||
92 | for(count=0; count<NoOfButtons; ++count) { | ||
93 | sizes[count]=buttons[count]->sizeHint(); | ||
94 | buttonHeight=QMAX(buttonHeight, sizes[count].height()); | ||
95 | } | ||
96 | // ----- calculate size of the month button: | ||
97 | w=0; | ||
98 | for(count=0; count<NoOfButtons; ++count) { | ||
99 | if(buttons[count]!=selectMonth) | ||
100 | { | ||
101 | w+=sizes[count].width(); | ||
102 | } else { | ||
103 | x=count; | ||
104 | } | ||
105 | } | ||
106 | sizes[x].setWidth(width()-w); // stretch the month button | ||
107 | // ----- place the buttons: | ||
108 | x=0; | ||
109 | for(count=0; count<NoOfButtons; ++count) | ||
110 | { | ||
111 | w=sizes[count].width(); | ||
112 | buttons[count]->setGeometry(x, 0, w, buttonHeight); | ||
113 | x+=w; | ||
114 | } | ||
115 | // ----- place the line edit for direct input: | ||
116 | sizes[0]=line->sizeHint(); | ||
117 | line->setGeometry(0, height()-sizes[0].height(), width(), sizes[0].height()); | ||
118 | // ----- adjust the table: | ||
119 | table->setGeometry(0, buttonHeight, width(), | ||
120 | height()-buttonHeight-sizes[0].height()); | ||
121 | } | ||
122 | |||
123 | void | ||
124 | KDatePicker::dateChangedSlot(QDate date) | ||
125 | { | ||
126 | kdDebug() << "KDatePicker::dateChangedSlot: date changed (" << date.year() << "/" << date.month() << "/" << date.day() << ")." << endl; | ||
127 | line->setText(KGlobal::locale()->formatDate(date, true)); | ||
128 | emit(dateChanged(date)); | ||
129 | } | ||
130 | |||
131 | void | ||
132 | KDatePicker::tableClickedSlot() | ||
133 | { | ||
134 | kdDebug() << "KDatePicker::tableClickedSlot: table clicked." << endl; | ||
135 | emit(dateSelected(table->getDate())); | ||
136 | emit(tableClicked()); | ||
137 | } | ||
138 | |||
139 | const QDate& | ||
140 | KDatePicker::getDate() const | ||
141 | { | ||
142 | return table->getDate(); | ||
143 | } | ||
144 | |||
145 | const QDate & | ||
146 | KDatePicker::date() const | ||
147 | { | ||
148 | return table->getDate(); | ||
149 | } | ||
150 | |||
151 | bool | ||
152 | KDatePicker::setDate(const QDate& date) | ||
153 | { | ||
154 | if(date.isValid()) { | ||
155 | QString temp; | ||
156 | // ----- | ||
157 | table->setDate(date); | ||
158 | selectMonth->setText(KGlobal::locale()->monthName(date.month(), false)); | ||
159 | temp.setNum(date.year()); | ||
160 | selectYear->setText(temp); | ||
161 | line->setText(KGlobal::locale()->formatDate(date, true)); | ||
162 | return true; | ||
163 | } else { | ||
164 | kdDebug() << "KDatePicker::setDate: refusing to set invalid date." << endl; | ||
165 | return false; | ||
166 | } | ||
167 | } | ||
168 | |||
169 | void | ||
170 | KDatePicker::monthForwardClicked() | ||
171 | { | ||
172 | QDate temp=table->getDate(); | ||
173 | int day=temp.day(); | ||
174 | // ----- | ||
175 | if(temp.month()==12) { | ||
176 | temp.setYMD(temp.year()+1, 1, 1); | ||
177 | } else { | ||
178 | temp.setYMD(temp.year(), temp.month()+1, 1); | ||
179 | } | ||
180 | if(temp.daysInMonth()<day) { | ||
181 | temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); | ||
182 | } else { | ||
183 | temp.setYMD(temp.year(), temp.month(), day); | ||
184 | } | ||
185 | // assert(temp.isValid()); | ||
186 | setDate(temp); | ||
187 | } | ||
188 | |||
189 | void | ||
190 | KDatePicker::monthBackwardClicked() | ||
191 | { | ||
192 | QDate temp=table->getDate(); | ||
193 | int day=temp.day(); | ||
194 | // ----- | ||
195 | if(temp.month()==1) | ||
196 | { | ||
197 | temp.setYMD(temp.year()-1, 12, 1); | ||
198 | } else { | ||
199 | temp.setYMD(temp.year(), temp.month()-1, 1); | ||
200 | } | ||
201 | if(temp.daysInMonth()<day) | ||
202 | { | ||
203 | temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); | ||
204 | } else { | ||
205 | temp.setYMD(temp.year(), temp.month(), day); | ||
206 | } | ||
207 | // assert(temp.isValid()); | ||
208 | setDate(temp); | ||
209 | } | ||
210 | |||
211 | void | ||
212 | KDatePicker::yearForwardClicked() | ||
213 | { | ||
214 | QDate temp=table->getDate(); | ||
215 | int day=temp.day(); | ||
216 | // ----- | ||
217 | temp.setYMD(temp.year()+1, temp.month(), 1); | ||
218 | if(temp.daysInMonth()<day) | ||
219 | { | ||
220 | temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); | ||
221 | } else { | ||
222 | temp.setYMD(temp.year(), temp.month(), day); | ||
223 | } | ||
224 | // assert(temp.isValid()); | ||
225 | setDate(temp); | ||
226 | } | ||
227 | |||
228 | void | ||
229 | KDatePicker::yearBackwardClicked() | ||
230 | { | ||
231 | QDate temp=table->getDate(); | ||
232 | int day=temp.day(); | ||
233 | // ----- | ||
234 | temp.setYMD(temp.year()-1, temp.month(), 1); | ||
235 | if(temp.daysInMonth()<day) | ||
236 | { | ||
237 | temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); | ||
238 | } else { | ||
239 | temp.setYMD(temp.year(), temp.month(), day); | ||
240 | } | ||
241 | // assert(temp.isValid()); | ||
242 | setDate(temp); | ||
243 | } | ||
244 | |||
245 | void | ||
246 | KDatePicker::selectMonthClicked() | ||
247 | { | ||
248 | int month; | ||
249 | KPopupFrame* popup = new KPopupFrame(this); | ||
250 | KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(fontsize, popup); | ||
251 | // ----- | ||
252 | picker->resize(picker->sizeHint()); | ||
253 | popup->setMainWidget(picker); | ||
254 | picker->setFocus(); | ||
255 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); | ||
256 | if(popup->exec(selectMonth->mapToGlobal(QPoint(0, selectMonth->height())))) | ||
257 | { | ||
258 | QDate date; | ||
259 | int day; | ||
260 | // ----- | ||
261 | month=picker->getResult(); | ||
262 | date=table->getDate(); | ||
263 | day=date.day(); | ||
264 | // ----- construct a valid date in this month: | ||
265 | date.setYMD(date.year(), month, 1); | ||
266 | date.setYMD(date.year(), month, QMIN(day, date.daysInMonth())); | ||
267 | // ----- set this month | ||
268 | setDate(date); | ||
269 | } else { | ||
270 | KNotifyClient::beep(); | ||
271 | } | ||
272 | delete popup; | ||
273 | } | ||
274 | |||
275 | void | ||
276 | KDatePicker::selectYearClicked() | ||
277 | { | ||
278 | int year; | ||
279 | KPopupFrame* popup = new KPopupFrame(this); | ||
280 | KDateInternalYearSelector* picker = new KDateInternalYearSelector(fontsize, popup); | ||
281 | // ----- | ||
282 | picker->resize(picker->sizeHint()); | ||
283 | popup->setMainWidget(picker); | ||
284 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); | ||
285 | picker->setFocus(); | ||
286 | if(popup->exec(selectYear->mapToGlobal(QPoint(0, selectMonth->height())))) | ||
287 | { | ||
288 | QDate date; | ||
289 | int day; | ||
290 | // ----- | ||
291 | year=picker->getYear(); | ||
292 | date=table->getDate(); | ||
293 | day=date.day(); | ||
294 | // ----- construct a valid date in this month: | ||
295 | date.setYMD(year, date.month(), 1); | ||
296 | date.setYMD(year, date.month(), QMIN(day, date.daysInMonth())); | ||
297 | // ----- set this month | ||
298 | setDate(date); | ||
299 | } else { | ||
300 | KNotifyClient::beep(); | ||
301 | } | ||
302 | delete popup; | ||
303 | } | ||
304 | |||
305 | void | ||
306 | KDatePicker::setEnabled(bool enable) | ||
307 | { | ||
308 | QWidget *widgets[]= { | ||
309 | yearForward, yearBackward, monthForward, monthBackward, | ||
310 | selectMonth, selectYear, | ||
311 | line, table }; | ||
312 | const int Size=sizeof(widgets)/sizeof(widgets[0]); | ||
313 | int count; | ||
314 | // ----- | ||
315 | for(count=0; count<Size; ++count) | ||
316 | { | ||
317 | widgets[count]->setEnabled(enable); | ||
318 | } | ||
319 | } | ||
320 | |||
321 | void | ||
322 | KDatePicker::lineEnterPressed() | ||
323 | { | ||
324 | QDate temp; | ||
325 | // ----- | ||
326 | if(val->date(line->text(), temp)==QValidator::Acceptable) | ||
327 | { | ||
328 | kdDebug() << "KDatePicker::lineEnterPressed: valid date entered." << endl; | ||
329 | emit(dateEntered(temp)); | ||
330 | setDate(temp); | ||
331 | } else { | ||
332 | KNotifyClient::beep(); | ||
333 | kdDebug() << "KDatePicker::lineEnterPressed: invalid date entered." << endl; | ||
334 | } | ||
335 | } | ||
336 | |||
337 | QSize | ||
338 | KDatePicker::sizeHint() const | ||
339 | { | ||
340 | QSize tableSize=table->sizeHint(); | ||
341 | QWidget *buttons[]={ | ||
342 | yearBackward, | ||
343 | monthBackward, | ||
344 | selectMonth, | ||
345 | selectYear, | ||
346 | monthForward, | ||
347 | yearForward }; | ||
348 | const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]); | ||
349 | QSize sizes[NoOfButtons]; | ||
350 | int cx=0, cy=0, count; | ||
351 | // ----- store the size hints: | ||
352 | for(count=0; count<NoOfButtons; ++count) | ||
353 | { | ||
354 | sizes[count]=buttons[count]->sizeHint(); | ||
355 | if(buttons[count]==selectMonth) | ||
356 | { | ||
357 | cx+=maxMonthRect.width(); | ||
358 | } else { | ||
359 | cx+=sizes[count].width(); | ||
360 | } | ||
361 | cy=QMAX(sizes[count].height(), cy); | ||
362 | } | ||
363 | // ----- calculate width hint: | ||
364 | cx=QMAX(cx, tableSize.width()); // line edit ignored | ||
365 | // ----- calculate height hint: | ||
366 | cy+=tableSize.height()+line->sizeHint().height(); | ||
367 | return QSize(cx, cy); | ||
368 | } | ||
369 | |||
370 | void | ||
371 | KDatePicker::setFontSize(int s) | ||
372 | { | ||
373 | QWidget *buttons[]= { | ||
374 | // yearBackward, | ||
375 | // monthBackward, | ||
376 | selectMonth, | ||
377 | selectYear, | ||
378 | // monthForward, | ||
379 | // yearForward | ||
380 | }; | ||
381 | const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]); | ||
382 | int count; | ||
383 | QFont font; | ||
384 | QRect r; | ||
385 | // ----- | ||
386 | fontsize=s; | ||
387 | for(count=0; count<NoOfButtons; ++count) | ||
388 | { | ||
389 | font=buttons[count]->font(); | ||
390 | font.setPointSize(s); | ||
391 | buttons[count]->setFont(font); | ||
392 | } | ||
393 | QFontMetrics metrics(selectMonth->fontMetrics()); | ||
394 | for(int i=1; i <= 12; ++i) | ||
395 | { // maxMonthRect is used by sizeHint() | ||
396 | r=metrics.boundingRect(KGlobal::locale()->monthName(i, false)); | ||
397 | maxMonthRect.setWidth(QMAX(r.width(), maxMonthRect.width())); | ||
398 | maxMonthRect.setHeight(QMAX(r.height(), maxMonthRect.height())); | ||
399 | } | ||
400 | table->setFontSize(s); | ||
401 | } | ||
402 | |||
403 | void KDatePicker::virtual_hook( int id, void* data ) | ||
404 | { /*BASE::virtual_hook( id, data );*/ } | ||
405 | |||
diff --git a/noncore/apps/tinykate/libkate/microkde/kdatepicker.h b/noncore/apps/tinykate/libkate/microkde/kdatepicker.h new file mode 100644 index 0000000..8fe8d66 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kdatepicker.h | |||
@@ -0,0 +1,177 @@ | |||
1 | /* -*- C++ -*- | ||
2 | This file is part of the KDE libraries | ||
3 | Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) | ||
4 | (C) 1998-2001 Mirko Boehm (mirko@kde.org) | ||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Library General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Library General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Library General Public License | ||
16 | along with this library; see the file COPYING.LIB. If not, write to | ||
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | #ifndef MICROKDE_KDATEPICKER_H | ||
21 | #define MICROKDE_KDATEPICKER_H | ||
22 | #include <qdatetime.h> | ||
23 | #include <qframe.h> | ||
24 | |||
25 | class QLineEdit; | ||
26 | class QToolButton; | ||
27 | class KDateValidator; | ||
28 | class KDateTable; | ||
29 | |||
30 | /** | ||
31 | * Provides a widget for calendar date input. | ||
32 | * | ||
33 | * Different from the | ||
34 | * previous versions, it now emits two types of signals, either | ||
35 | * @ref dateSelected() or @ref dateEntered() (see documentation for both | ||
36 | * signals). | ||
37 | * | ||
38 | * A line edit has been added in the newer versions to allow the user | ||
39 | * to select a date directly by entering numbers like 19990101 | ||
40 | * or 990101. | ||
41 | * | ||
42 | * @image kdatepicker.png KDatePicker | ||
43 | * | ||
44 | * @version $Id$ | ||
45 | * @author Tim Gilman, Mirko Boehm | ||
46 | * | ||
47 | * @short A date selection widget. | ||
48 | **/ | ||
49 | class KDatePicker: public QFrame | ||
50 | { | ||
51 | Q_OBJECT | ||
52 | public: | ||
53 | /** The usual constructor. The given date will be displayed | ||
54 | * initially. | ||
55 | **/ | ||
56 | KDatePicker(QWidget *parent=0, | ||
57 | QDate=QDate::currentDate(), | ||
58 | const char *name=0); | ||
59 | /** | ||
60 | * The destructor. | ||
61 | **/ | ||
62 | virtual ~KDatePicker(); | ||
63 | |||
64 | /** The size hint for date pickers. The size hint recommends the | ||
65 | * minimum size of the widget so that all elements may be placed | ||
66 | * without clipping. This sometimes looks ugly, so when using the | ||
67 | * size hint, try adding 28 to each of the reported numbers of | ||
68 | * pixels. | ||
69 | **/ | ||
70 | QSize sizeHint() const; | ||
71 | |||
72 | /** | ||
73 | * Sets the date. | ||
74 | * | ||
75 | * @returns @p false and does not change anything | ||
76 | * if the date given is invalid. | ||
77 | **/ | ||
78 | bool setDate(const QDate&); | ||
79 | |||
80 | /** | ||
81 | * Returns the selected date. | ||
82 | * @deprecated | ||
83 | **/ | ||
84 | const QDate& getDate() const; | ||
85 | |||
86 | /** | ||
87 | * @returns the selected date. | ||
88 | */ | ||
89 | const QDate &date() const; | ||
90 | |||
91 | /** | ||
92 | * Enables or disables the widget. | ||
93 | **/ | ||
94 | void setEnabled(bool); | ||
95 | |||
96 | /** | ||
97 | * Sets the font size of the widgets elements. | ||
98 | **/ | ||
99 | void setFontSize(int); | ||
100 | /** | ||
101 | * Returns the font size of the widget elements. | ||
102 | */ | ||
103 | int fontSize() const | ||
104 | { return fontsize; } | ||
105 | |||
106 | protected: | ||
107 | /// the resize event | ||
108 | void resizeEvent(QResizeEvent*); | ||
109 | /// the year forward button | ||
110 | QToolButton *yearForward; | ||
111 | /// the year backward button | ||
112 | QToolButton *yearBackward; | ||
113 | /// the month forward button | ||
114 | QToolButton *monthForward; | ||
115 | /// the month backward button | ||
116 | QToolButton *monthBackward; | ||
117 | /// the button for selecting the month directly | ||
118 | QToolButton *selectMonth; | ||
119 | /// the button for selecting the year directly | ||
120 | QToolButton *selectYear; | ||
121 | /// the line edit to enter the date directly | ||
122 | QLineEdit *line; | ||
123 | /// the validator for the line edit: | ||
124 | KDateValidator *val; | ||
125 | /// the date table | ||
126 | KDateTable *table; | ||
127 | /// the size calculated during resize events | ||
128 | // QSize sizehint; | ||
129 | /// the widest month string in pixels: | ||
130 | QSize maxMonthRect; | ||
131 | protected slots: | ||
132 | void dateChangedSlot(QDate); | ||
133 | void tableClickedSlot(); | ||
134 | void monthForwardClicked(); | ||
135 | void monthBackwardClicked(); | ||
136 | void yearForwardClicked(); | ||
137 | void yearBackwardClicked(); | ||
138 | void selectMonthClicked(); | ||
139 | void selectYearClicked(); | ||
140 | void lineEnterPressed(); | ||
141 | signals: | ||
142 | /** This signal is emitted each time the selected date is changed. | ||
143 | * Usually, this does not mean that the date has been entered, | ||
144 | * since the date also changes, for example, when another month is | ||
145 | * selected. | ||
146 | * @see dateSelected | ||
147 | */ | ||
148 | void dateChanged(QDate); | ||
149 | /** This signal is emitted each time a day has been selected by | ||
150 | * clicking on the table (hitting a day in the current month). It | ||
151 | * has the same meaning as dateSelected() in older versions of | ||
152 | * KDatePicker. | ||
153 | */ | ||
154 | void dateSelected(QDate); | ||
155 | /** This signal is emitted when enter is pressed and a VALID date | ||
156 | * has been entered before into the line edit. Connect to both | ||
157 | * dateEntered() and dateSelected() to receive all events where the | ||
158 | * user really enters a date. | ||
159 | */ | ||
160 | void dateEntered(QDate); | ||
161 | /** This signal is emitted when the day has been selected by | ||
162 | * clicking on it in the table. | ||
163 | */ | ||
164 | void tableClicked(); | ||
165 | |||
166 | private: | ||
167 | /// the font size for the widget | ||
168 | int fontsize; | ||
169 | |||
170 | protected: | ||
171 | virtual void virtual_hook( int id, void* data ); | ||
172 | private: | ||
173 | class KDatePickerPrivate; | ||
174 | KDatePickerPrivate *d; | ||
175 | }; | ||
176 | |||
177 | #endif // KDATEPICKER_H | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kdatetbl.cpp b/noncore/apps/tinykate/libkate/microkde/kdatetbl.cpp new file mode 100644 index 0000000..c56991d --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kdatetbl.cpp | |||
@@ -0,0 +1,718 @@ | |||
1 | /* -*- C++ -*- | ||
2 | This file is part of the KDE libraries | ||
3 | Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) | ||
4 | (C) 1998-2001 Mirko Boehm (mirko@kde.org) | ||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Library General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Library General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Library General Public License | ||
16 | along with this library; see the file COPYING.LIB. If not, write to | ||
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /////////////////// KDateTable widget class ////////////////////// | ||
22 | // | ||
23 | // Copyright (C) 1997 Tim D. Gilman | ||
24 | // (C) 1998-2001 Mirko Boehm | ||
25 | // Written using Qt (http://www.troll.no) for the | ||
26 | // KDE project (http://www.kde.org) | ||
27 | // | ||
28 | // This is a support class for the KDatePicker class. It just | ||
29 | // draws the calender table without titles, but could theoretically | ||
30 | // be used as a standalone. | ||
31 | // | ||
32 | // When a date is selected by the user, it emits a signal: | ||
33 | // dateSelected(QDate) | ||
34 | |||
35 | #include <kglobal.h> | ||
36 | #include <kglobalsettings.h> | ||
37 | #include <kapplication.h> | ||
38 | #include <klocale.h> | ||
39 | #include <kdebug.h> | ||
40 | #include <knotifyclient.h> | ||
41 | #include "kdatetbl.h" | ||
42 | #include <qdatetime.h> | ||
43 | #include <qstring.h> | ||
44 | #include <qpen.h> | ||
45 | #include <qpainter.h> | ||
46 | #include <qdialog.h> | ||
47 | #include <assert.h> | ||
48 | #include <qapplication.h> | ||
49 | |||
50 | KDateValidator::KDateValidator(QWidget* parent, const char* name) | ||
51 | : QValidator(parent, name) | ||
52 | { | ||
53 | } | ||
54 | |||
55 | QValidator::State | ||
56 | KDateValidator::validate(QString& text, int&) const | ||
57 | { | ||
58 | QDate temp; | ||
59 | // ----- everything is tested in date(): | ||
60 | return date(text, temp); | ||
61 | } | ||
62 | |||
63 | QValidator::State | ||
64 | KDateValidator::date(const QString& text, QDate& d) const | ||
65 | { | ||
66 | QDate tmp = KGlobal::locale()->readDate(text); | ||
67 | if (!tmp.isNull()) | ||
68 | { | ||
69 | d = tmp; | ||
70 | return Acceptable; | ||
71 | } else | ||
72 | return Valid; | ||
73 | } | ||
74 | |||
75 | void | ||
76 | KDateValidator::fixup( QString& ) const | ||
77 | { | ||
78 | |||
79 | } | ||
80 | |||
81 | KDateTable::KDateTable(QWidget *parent, QDate date_, const char* name, WFlags f) | ||
82 | : QGridView(parent, name, f) | ||
83 | { | ||
84 | setFontSize(10); | ||
85 | if(!date_.isValid()) | ||
86 | { | ||
87 | kdDebug() << "KDateTable ctor: WARNING: Given date is invalid, using current date." << endl; | ||
88 | date_=QDate::currentDate(); | ||
89 | } | ||
90 | setFocusPolicy( QWidget::StrongFocus ); | ||
91 | setNumRows(7); // 6 weeks max + headline | ||
92 | setNumCols(7); // 7 days a week | ||
93 | setHScrollBarMode(AlwaysOff); | ||
94 | setVScrollBarMode(AlwaysOff); | ||
95 | #if 0 | ||
96 | viewport()->setEraseColor(lightGray); | ||
97 | #endif | ||
98 | setDate(date_); // this initializes firstday, numdays, numDaysPrevMonth | ||
99 | } | ||
100 | |||
101 | void | ||
102 | KDateTable::paintCell(QPainter *painter, int row, int col) | ||
103 | { | ||
104 | QRect rect; | ||
105 | QString text; | ||
106 | QPen pen; | ||
107 | int w=cellWidth(); | ||
108 | int h=cellHeight(); | ||
109 | int pos; | ||
110 | QBrush brushBlue(blue); | ||
111 | QBrush brushLightblue(lightGray); | ||
112 | QFont font=KGlobalSettings::generalFont(); | ||
113 | // ----- | ||
114 | font.setPointSize(fontsize); | ||
115 | if(row==0) | ||
116 | { // we are drawing the headline | ||
117 | font.setBold(true); | ||
118 | painter->setFont(font); | ||
119 | bool normalday = true; | ||
120 | QString daystr; | ||
121 | if (KGlobal::locale()->weekStartsMonday()) | ||
122 | { | ||
123 | daystr = KGlobal::locale()->weekDayName(col+1, true); | ||
124 | if (col == 5 || col == 6) | ||
125 | normalday = false; | ||
126 | } else { | ||
127 | daystr = KGlobal::locale()->weekDayName(col==0? 7 : col, true); | ||
128 | if (col == 0 || col == 6) | ||
129 | normalday = false; | ||
130 | } | ||
131 | if (!normalday) | ||
132 | { | ||
133 | painter->setPen(lightGray); | ||
134 | painter->setBrush(brushLightblue); | ||
135 | painter->drawRect(0, 0, w, h); | ||
136 | painter->setPen(blue); | ||
137 | } else { | ||
138 | painter->setPen(blue); | ||
139 | painter->setBrush(brushBlue); | ||
140 | painter->drawRect(0, 0, w, h); | ||
141 | painter->setPen(white); | ||
142 | } | ||
143 | painter->drawText(0, 0, w, h-1, AlignCenter, | ||
144 | daystr, -1, &rect); | ||
145 | painter->setPen(black); | ||
146 | painter->moveTo(0, h-1); | ||
147 | painter->lineTo(w-1, h-1); | ||
148 | // ----- draw the weekday: | ||
149 | } else { | ||
150 | painter->setFont(font); | ||
151 | pos=7*(row-1)+col; | ||
152 | if (KGlobal::locale()->weekStartsMonday()) | ||
153 | pos++; | ||
154 | if(pos<firstday || (firstday+numdays<=pos)) | ||
155 | { // we are either | ||
156 | // ° painting a day of the previous month or | ||
157 | // ° painting a day of the following month | ||
158 | if(pos<firstday) | ||
159 | { // previous month | ||
160 | text.setNum(numDaysPrevMonth+pos-firstday+1); | ||
161 | } else { // following month | ||
162 | text.setNum(pos-firstday-numdays+1); | ||
163 | } | ||
164 | painter->setPen(gray); | ||
165 | } else { // paint a day of the current month | ||
166 | text.setNum(pos-firstday+1); | ||
167 | painter->setPen(black); | ||
168 | } | ||
169 | |||
170 | pen=painter->pen(); | ||
171 | if(firstday+date.day()-1==pos) | ||
172 | { | ||
173 | if(hasFocus()) | ||
174 | { // draw the currently selected date | ||
175 | painter->setPen(red); | ||
176 | painter->setBrush(darkRed); | ||
177 | pen=white; | ||
178 | } else { | ||
179 | painter->setPen(darkGray); | ||
180 | painter->setBrush(darkGray); | ||
181 | pen=white; | ||
182 | } | ||
183 | } else { | ||
184 | painter->setBrush(lightGray); | ||
185 | painter->setPen(lightGray); | ||
186 | } | ||
187 | painter->drawRect(0, 0, w, h); | ||
188 | painter->setPen(pen); | ||
189 | painter->drawText(0, 0, w, h, AlignCenter, text, -1, &rect); | ||
190 | } | ||
191 | if(rect.width()>maxCell.width()) maxCell.setWidth(rect.width()); | ||
192 | if(rect.height()>maxCell.height()) maxCell.setHeight(rect.height()); | ||
193 | } | ||
194 | |||
195 | void | ||
196 | KDateTable::keyPressEvent( QKeyEvent *e ) | ||
197 | { | ||
198 | if ( e->key() == Qt::Key_Prior ) { | ||
199 | if ( date.month() == 1 ) { | ||
200 | KNotifyClient::beep(); | ||
201 | return; | ||
202 | } | ||
203 | int day = date.day(); | ||
204 | if ( day > 27 ) | ||
205 | while ( !QDate::isValid( date.year(), date.month()-1, day ) ) | ||
206 | day--; | ||
207 | setDate(QDate(date.year(), date.month()-1, day)); | ||
208 | return; | ||
209 | } | ||
210 | if ( e->key() == Qt::Key_Next ) { | ||
211 | if ( date.month() == 12 ) { | ||
212 | KNotifyClient::beep(); | ||
213 | return; | ||
214 | } | ||
215 | int day = date.day(); | ||
216 | if ( day > 27 ) | ||
217 | while ( !QDate::isValid( date.year(), date.month()+1, day ) ) | ||
218 | day--; | ||
219 | setDate(QDate(date.year(), date.month()+1, day)); | ||
220 | return; | ||
221 | } | ||
222 | |||
223 | int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; | ||
224 | |||
225 | int temp=firstday+date.day()-dayoff; | ||
226 | int pos = temp; | ||
227 | |||
228 | if ( e->key() == Qt::Key_Up ) { | ||
229 | pos -= 7; | ||
230 | } | ||
231 | if ( e->key() == Qt::Key_Down ) { | ||
232 | pos += 7; | ||
233 | } | ||
234 | if ( e->key() == Qt::Key_Left ) { | ||
235 | pos--; | ||
236 | } | ||
237 | if ( e->key() == Qt::Key_Right ) { | ||
238 | pos++; | ||
239 | } | ||
240 | |||
241 | if(pos+dayoff<=firstday) | ||
242 | { // this day is in the previous month | ||
243 | KNotifyClient::beep(); | ||
244 | return; | ||
245 | } | ||
246 | if(firstday+numdays<pos+dayoff) | ||
247 | { // this date is in the next month | ||
248 | KNotifyClient::beep(i18n( "Month not long enough" )); | ||
249 | return; | ||
250 | } | ||
251 | |||
252 | if ( pos == temp ) | ||
253 | return; | ||
254 | |||
255 | setDate(QDate(date.year(), date.month(), pos-firstday+dayoff)); | ||
256 | updateCell(temp/7+1, temp%7); // Update the previously selected cell | ||
257 | updateCell(pos/7+1, pos%7); // Update the selected cell | ||
258 | assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); | ||
259 | } | ||
260 | |||
261 | void | ||
262 | KDateTable::viewportResizeEvent(QResizeEvent * e) | ||
263 | { | ||
264 | QGridView::viewportResizeEvent(e); | ||
265 | |||
266 | setCellWidth(viewport()->width()/7); | ||
267 | setCellHeight(viewport()->height()/7); | ||
268 | } | ||
269 | |||
270 | void | ||
271 | KDateTable::setFontSize(int size) | ||
272 | { | ||
273 | int count; | ||
274 | QFontMetrics metrics(fontMetrics()); | ||
275 | QRect rect; | ||
276 | // ----- store rectangles: | ||
277 | fontsize=size; | ||
278 | // ----- find largest day name: | ||
279 | maxCell.setWidth(0); | ||
280 | maxCell.setHeight(0); | ||
281 | for(count=0; count<7; ++count) | ||
282 | { | ||
283 | rect=metrics.boundingRect(KGlobal::locale()->weekDayName(count+1, true)); | ||
284 | maxCell.setWidth(QMAX(maxCell.width(), rect.width())); | ||
285 | maxCell.setHeight(QMAX(maxCell.height(), rect.height())); | ||
286 | } | ||
287 | // ----- compare with a real wide number and add some space: | ||
288 | rect=metrics.boundingRect(QString::fromLatin1("88")); | ||
289 | maxCell.setWidth(QMAX(maxCell.width()+2, rect.width())); | ||
290 | maxCell.setHeight(QMAX(maxCell.height()+4, rect.height())); | ||
291 | } | ||
292 | |||
293 | void | ||
294 | KDateTable::contentsMousePressEvent(QMouseEvent *e) | ||
295 | { | ||
296 | if(e->type()!=QEvent::MouseButtonPress) | ||
297 | { // the KDatePicker only reacts on mouse press events: | ||
298 | return; | ||
299 | } | ||
300 | if(!isEnabled()) | ||
301 | { | ||
302 | KNotifyClient::beep(); | ||
303 | return; | ||
304 | } | ||
305 | |||
306 | int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; | ||
307 | // ----- | ||
308 | int row, col, pos, temp; | ||
309 | QPoint mouseCoord; | ||
310 | // ----- | ||
311 | mouseCoord = e->pos(); | ||
312 | row=rowAt(mouseCoord.y()); | ||
313 | col=columnAt(mouseCoord.x()); | ||
314 | if(row<0 || col<0) | ||
315 | { // the user clicked on the frame of the table | ||
316 | return; | ||
317 | } | ||
318 | pos=7*(row-1)+col+1; | ||
319 | if(pos+dayoff<=firstday) | ||
320 | { // this day is in the previous month | ||
321 | KNotifyClient::beep(); | ||
322 | return; | ||
323 | } | ||
324 | if(firstday+numdays<pos+dayoff) | ||
325 | { // this date is in the next month | ||
326 | KNotifyClient::beep(); | ||
327 | return; | ||
328 | } | ||
329 | temp=firstday+date.day()-dayoff-1; | ||
330 | setDate(QDate(date.year(), date.month(), pos-firstday+dayoff)); | ||
331 | updateCell(temp/7+1, temp%7); // Update the previously selected cell | ||
332 | updateCell(row, col); // Update the selected cell | ||
333 | // assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); | ||
334 | emit(tableClicked()); | ||
335 | } | ||
336 | |||
337 | bool | ||
338 | KDateTable::setDate(const QDate& date_) | ||
339 | { | ||
340 | bool changed=false; | ||
341 | QDate temp; | ||
342 | // ----- | ||
343 | if(!date_.isValid()) | ||
344 | { | ||
345 | kdDebug() << "KDateTable::setDate: refusing to set invalid date." << endl; | ||
346 | return false; | ||
347 | } | ||
348 | if(date!=date_) | ||
349 | { | ||
350 | date=date_; | ||
351 | changed=true; | ||
352 | } | ||
353 | temp.setYMD(date.year(), date.month(), 1); | ||
354 | firstday=temp.dayOfWeek(); | ||
355 | if(firstday==1) firstday=8; | ||
356 | numdays=date.daysInMonth(); | ||
357 | if(date.month()==1) | ||
358 | { // set to december of previous year | ||
359 | temp.setYMD(date.year()-1, 12, 1); | ||
360 | } else { // set to previous month | ||
361 | temp.setYMD(date.year(), date.month()-1, 1); | ||
362 | } | ||
363 | numDaysPrevMonth=temp.daysInMonth(); | ||
364 | if(changed) | ||
365 | { | ||
366 | repaintContents(false); | ||
367 | } | ||
368 | emit(dateChanged(date)); | ||
369 | return true; | ||
370 | } | ||
371 | |||
372 | const QDate& | ||
373 | KDateTable::getDate() const | ||
374 | { | ||
375 | return date; | ||
376 | } | ||
377 | |||
378 | void KDateTable::focusInEvent( QFocusEvent *e ) | ||
379 | { | ||
380 | repaintContents(false); | ||
381 | QGridView::focusInEvent( e ); | ||
382 | } | ||
383 | |||
384 | void KDateTable::focusOutEvent( QFocusEvent *e ) | ||
385 | { | ||
386 | repaintContents(false); | ||
387 | QGridView::focusOutEvent( e ); | ||
388 | } | ||
389 | |||
390 | QSize | ||
391 | KDateTable::sizeHint() const | ||
392 | { | ||
393 | if(maxCell.height()>0 && maxCell.width()>0) | ||
394 | { | ||
395 | return QSize(maxCell.width()*numCols()+2*frameWidth(), | ||
396 | (maxCell.height()+2)*numRows()+2*frameWidth()); | ||
397 | } else { | ||
398 | kdDebug() << "KDateTable::sizeHint: obscure failure - " << endl; | ||
399 | return QSize(-1, -1); | ||
400 | } | ||
401 | } | ||
402 | |||
403 | KDateInternalMonthPicker::KDateInternalMonthPicker | ||
404 | (int fontsize, QWidget* parent, const char* name) | ||
405 | : QGridView(parent, name), | ||
406 | result(0) // invalid | ||
407 | { | ||
408 | QRect rect; | ||
409 | QFont font; | ||
410 | // ----- | ||
411 | activeCol = -1; | ||
412 | activeRow = -1; | ||
413 | font=KGlobalSettings::generalFont(); | ||
414 | font.setPointSize(fontsize); | ||
415 | setFont(font); | ||
416 | setHScrollBarMode(AlwaysOff); | ||
417 | setVScrollBarMode(AlwaysOff); | ||
418 | setFrameStyle(QFrame::NoFrame); | ||
419 | setNumRows(4); | ||
420 | setNumCols(3); | ||
421 | // enable to find drawing failures: | ||
422 | // setTableFlags(Tbl_clipCellPainting); | ||
423 | #if 0 | ||
424 | viewport()->setEraseColor(lightGray); // for consistency with the datepicker | ||
425 | #endif | ||
426 | // ----- find the preferred size | ||
427 | // (this is slow, possibly, but unfortunatly it is needed here): | ||
428 | QFontMetrics metrics(font); | ||
429 | for(int i=1; i <= 12; ++i) | ||
430 | { | ||
431 | rect=metrics.boundingRect(KGlobal::locale()->monthName(i, false)); | ||
432 | if(max.width()<rect.width()) max.setWidth(rect.width()); | ||
433 | if(max.height()<rect.height()) max.setHeight(rect.height()); | ||
434 | } | ||
435 | |||
436 | } | ||
437 | |||
438 | QSize | ||
439 | KDateInternalMonthPicker::sizeHint() const | ||
440 | { | ||
441 | return QSize((max.width()+6)*numCols()+2*frameWidth(), | ||
442 | (max.height()+6)*numRows()+2*frameWidth()); | ||
443 | } | ||
444 | |||
445 | int | ||
446 | KDateInternalMonthPicker::getResult() const | ||
447 | { | ||
448 | return result; | ||
449 | } | ||
450 | |||
451 | void | ||
452 | KDateInternalMonthPicker::setupPainter(QPainter *p) | ||
453 | { | ||
454 | p->setPen(black); | ||
455 | } | ||
456 | |||
457 | void | ||
458 | KDateInternalMonthPicker::viewportResizeEvent(QResizeEvent*) | ||
459 | { | ||
460 | setCellWidth(width()/3); | ||
461 | setCellHeight(height()/4); | ||
462 | } | ||
463 | |||
464 | void | ||
465 | KDateInternalMonthPicker::paintCell(QPainter* painter, int row, int col) | ||
466 | { | ||
467 | int index; | ||
468 | QString text; | ||
469 | // ----- find the number of the cell: | ||
470 | index=3*row+col+1; | ||
471 | text=KGlobal::locale()->monthName(index, false); | ||
472 | painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text); | ||
473 | if ( activeCol == col && activeRow == row ) | ||
474 | painter->drawRect( 0, 0, cellWidth(), cellHeight() ); | ||
475 | } | ||
476 | |||
477 | void | ||
478 | KDateInternalMonthPicker::contentsMousePressEvent(QMouseEvent *e) | ||
479 | { | ||
480 | if(!isEnabled() || e->button() != LeftButton) | ||
481 | { | ||
482 | KNotifyClient::beep(); | ||
483 | return; | ||
484 | } | ||
485 | // ----- | ||
486 | int row, col; | ||
487 | QPoint mouseCoord; | ||
488 | // ----- | ||
489 | mouseCoord = e->pos(); | ||
490 | row=rowAt(mouseCoord.y()); | ||
491 | col=columnAt(mouseCoord.x()); | ||
492 | |||
493 | if(row<0 || col<0) | ||
494 | { // the user clicked on the frame of the table | ||
495 | activeCol = -1; | ||
496 | activeRow = -1; | ||
497 | } else { | ||
498 | activeCol = col; | ||
499 | activeRow = row; | ||
500 | updateCell( row, col /*, false */ ); | ||
501 | } | ||
502 | } | ||
503 | |||
504 | void | ||
505 | KDateInternalMonthPicker::contentsMouseMoveEvent(QMouseEvent *e) | ||
506 | { | ||
507 | if (e->state() & LeftButton) | ||
508 | { | ||
509 | int row, col; | ||
510 | QPoint mouseCoord; | ||
511 | // ----- | ||
512 | mouseCoord = e->pos(); | ||
513 | row=rowAt(mouseCoord.y()); | ||
514 | col=columnAt(mouseCoord.x()); | ||
515 | int tmpRow = -1, tmpCol = -1; | ||
516 | if(row<0 || col<0) | ||
517 | { // the user clicked on the frame of the table | ||
518 | if ( activeCol > -1 ) | ||
519 | { | ||
520 | tmpRow = activeRow; | ||
521 | tmpCol = activeCol; | ||
522 | } | ||
523 | activeCol = -1; | ||
524 | activeRow = -1; | ||
525 | } else { | ||
526 | bool differentCell = (activeRow != row || activeCol != col); | ||
527 | if ( activeCol > -1 && differentCell) | ||
528 | { | ||
529 | tmpRow = activeRow; | ||
530 | tmpCol = activeCol; | ||
531 | } | ||
532 | if ( differentCell) | ||
533 | { | ||
534 | activeRow = row; | ||
535 | activeCol = col; | ||
536 | updateCell( row, col /*, false */ ); // mark the new active cell | ||
537 | } | ||
538 | } | ||
539 | if ( tmpRow > -1 ) // repaint the former active cell | ||
540 | updateCell( tmpRow, tmpCol /*, true */ ); | ||
541 | } | ||
542 | } | ||
543 | |||
544 | void | ||
545 | KDateInternalMonthPicker::contentsMouseReleaseEvent(QMouseEvent *e) | ||
546 | { | ||
547 | if(!isEnabled()) | ||
548 | { | ||
549 | return; | ||
550 | } | ||
551 | // ----- | ||
552 | int row, col, pos; | ||
553 | QPoint mouseCoord; | ||
554 | // ----- | ||
555 | mouseCoord = e->pos(); | ||
556 | row=rowAt(mouseCoord.y()); | ||
557 | col=columnAt(mouseCoord.x()); | ||
558 | if(row<0 || col<0) | ||
559 | { // the user clicked on the frame of the table | ||
560 | emit(closeMe(0)); | ||
561 | } | ||
562 | pos=3*row+col+1; | ||
563 | result=pos; | ||
564 | emit(closeMe(1)); | ||
565 | } | ||
566 | |||
567 | |||
568 | |||
569 | KDateInternalYearSelector::KDateInternalYearSelector | ||
570 | (int fontsize, QWidget* parent, const char* name) | ||
571 | : QLineEdit(parent, name), | ||
572 | val(new QIntValidator(this)), | ||
573 | result(0) | ||
574 | { | ||
575 | QFont font; | ||
576 | // ----- | ||
577 | font=KGlobalSettings::generalFont(); | ||
578 | font.setPointSize(fontsize); | ||
579 | setFont(font); | ||
580 | #if 0 | ||
581 | setFrameStyle(QFrame::NoFrame); | ||
582 | #endif | ||
583 | // we have to respect the limits of QDate here, I fear: | ||
584 | val->setRange(0, 8000); | ||
585 | setValidator(val); | ||
586 | connect(this, SIGNAL(returnPressed()), SLOT(yearEnteredSlot())); | ||
587 | } | ||
588 | |||
589 | void | ||
590 | KDateInternalYearSelector::yearEnteredSlot() | ||
591 | { | ||
592 | bool ok; | ||
593 | int year; | ||
594 | QDate date; | ||
595 | // ----- check if this is a valid year: | ||
596 | year=text().toInt(&ok); | ||
597 | if(!ok) | ||
598 | { | ||
599 | KNotifyClient::beep(); | ||
600 | return; | ||
601 | } | ||
602 | date.setYMD(year, 1, 1); | ||
603 | if(!date.isValid()) | ||
604 | { | ||
605 | KNotifyClient::beep(); | ||
606 | return; | ||
607 | } | ||
608 | result=year; | ||
609 | emit(closeMe(1)); | ||
610 | } | ||
611 | |||
612 | int | ||
613 | KDateInternalYearSelector::getYear() | ||
614 | { | ||
615 | return result; | ||
616 | } | ||
617 | |||
618 | void | ||
619 | KDateInternalYearSelector::setYear(int year) | ||
620 | { | ||
621 | QString temp; | ||
622 | // ----- | ||
623 | temp.setNum(year); | ||
624 | setText(temp); | ||
625 | } | ||
626 | |||
627 | KPopupFrame::KPopupFrame(QWidget* parent, const char* name) | ||
628 | : QFrame(parent, name, WType_Popup), | ||
629 | result(0), // rejected | ||
630 | main(0) | ||
631 | { | ||
632 | setFrameStyle(QFrame::Box|QFrame::Raised); | ||
633 | setMidLineWidth(2); | ||
634 | } | ||
635 | |||
636 | void | ||
637 | KPopupFrame::keyPressEvent(QKeyEvent* e) | ||
638 | { | ||
639 | if(e->key()==Key_Escape) | ||
640 | { | ||
641 | result=0; // rejected | ||
642 | qApp->exit_loop(); | ||
643 | } | ||
644 | } | ||
645 | |||
646 | void | ||
647 | KPopupFrame::close(int r) | ||
648 | { | ||
649 | result=r; | ||
650 | qApp->exit_loop(); | ||
651 | } | ||
652 | |||
653 | void | ||
654 | KPopupFrame::setMainWidget(QWidget* m) | ||
655 | { | ||
656 | main=m; | ||
657 | if(main!=0) | ||
658 | { | ||
659 | resize(main->width()+2*frameWidth(), main->height()+2*frameWidth()); | ||
660 | } | ||
661 | } | ||
662 | |||
663 | void | ||
664 | KPopupFrame::resizeEvent(QResizeEvent*) | ||
665 | { | ||
666 | if(main!=0) | ||
667 | { | ||
668 | main->setGeometry(frameWidth(), frameWidth(), | ||
669 | width()-2*frameWidth(), height()-2*frameWidth()); | ||
670 | } | ||
671 | } | ||
672 | |||
673 | void | ||
674 | KPopupFrame::popup(const QPoint &pos) | ||
675 | { | ||
676 | // Make sure the whole popup is visible. | ||
677 | QRect d = QApplication::desktop()->frameGeometry(); | ||
678 | int x = pos.x(); | ||
679 | int y = pos.y(); | ||
680 | int w = width(); | ||
681 | int h = height(); | ||
682 | if (x+w > d.x()+d.width()) | ||
683 | x = d.width() - w; | ||
684 | if (y+h > d.y()+d.height()) | ||
685 | y = d.height() - h; | ||
686 | if (x < d.x()) | ||
687 | x = 0; | ||
688 | if (y < d.y()) | ||
689 | y = 0; | ||
690 | |||
691 | // Pop the thingy up. | ||
692 | move(x, y); | ||
693 | show(); | ||
694 | } | ||
695 | |||
696 | int | ||
697 | KPopupFrame::exec(QPoint pos) | ||
698 | { | ||
699 | popup(pos); | ||
700 | repaint(); | ||
701 | qApp->enter_loop(); | ||
702 | hide(); | ||
703 | return result; | ||
704 | } | ||
705 | |||
706 | int | ||
707 | KPopupFrame::exec(int x, int y) | ||
708 | { | ||
709 | return exec(QPoint(x, y)); | ||
710 | } | ||
711 | |||
712 | void KPopupFrame::virtual_hook( int, void* ) | ||
713 | { /*BASE::virtual_hook( id, data );*/ } | ||
714 | |||
715 | void KDateTable::virtual_hook( int, void* ) | ||
716 | { /*BASE::virtual_hook( id, data );*/ } | ||
717 | |||
718 | #include "kdatetbl.moc" | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kdatetbl.h b/noncore/apps/tinykate/libkate/microkde/kdatetbl.h new file mode 100644 index 0000000..df7b7ef --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kdatetbl.h | |||
@@ -0,0 +1,308 @@ | |||
1 | /* -*- C++ -*- | ||
2 | This file is part of the KDE libraries | ||
3 | Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) | ||
4 | (C) 1998-2001 Mirko Boehm (mirko@kde.org) | ||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Library General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Library General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Library General Public License | ||
16 | along with this library; see the file COPYING.LIB. If not, write to | ||
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | #ifndef KDATETBL_H | ||
21 | #define KDATETBL_H | ||
22 | |||
23 | #include <qvalidator.h> | ||
24 | #include <qgridview.h> | ||
25 | #include <qlineedit.h> | ||
26 | #include <qdatetime.h> | ||
27 | |||
28 | /** | ||
29 | * A table containing month names. It is used to pick a month directly. | ||
30 | * @internal | ||
31 | * @version $Id$ | ||
32 | * @author Tim Gilman, Mirko Boehm | ||
33 | */ | ||
34 | class KDateInternalMonthPicker : public QGridView | ||
35 | { | ||
36 | Q_OBJECT | ||
37 | protected: | ||
38 | /** | ||
39 | * Store the month that has been clicked [1..12]. | ||
40 | */ | ||
41 | int result; | ||
42 | /** | ||
43 | * the cell under mouse cursor when LBM is pressed | ||
44 | */ | ||
45 | short int activeCol; | ||
46 | short int activeRow; | ||
47 | /** | ||
48 | * Contains the largest rectangle needed by the month names. | ||
49 | */ | ||
50 | QRect max; | ||
51 | signals: | ||
52 | /** | ||
53 | * This is send from the mouse click event handler. | ||
54 | */ | ||
55 | void closeMe(int); | ||
56 | public: | ||
57 | /** | ||
58 | * The constructor. | ||
59 | */ | ||
60 | KDateInternalMonthPicker(int fontsize, QWidget* parent, const char* name=0); | ||
61 | /** | ||
62 | * The size hint. | ||
63 | */ | ||
64 | QSize sizeHint() const; | ||
65 | /** | ||
66 | * Return the result. 0 means no selection (reject()), 1..12 are the | ||
67 | * months. | ||
68 | */ | ||
69 | int getResult() const; | ||
70 | protected: | ||
71 | /** | ||
72 | * Set up the painter. | ||
73 | */ | ||
74 | void setupPainter(QPainter *p); | ||
75 | /** | ||
76 | * The resize event. | ||
77 | */ | ||
78 | void viewportResizeEvent(QResizeEvent*); | ||
79 | /** | ||
80 | * Paint a cell. This simply draws the month names in it. | ||
81 | */ | ||
82 | virtual void paintCell(QPainter* painter, int row, int col); | ||
83 | /** | ||
84 | * Catch mouse click and move events to paint a rectangle around the item. | ||
85 | */ | ||
86 | void contentsMousePressEvent(QMouseEvent *e); | ||
87 | void contentsMouseMoveEvent(QMouseEvent *e); | ||
88 | /** | ||
89 | * Emit monthSelected(int) when a cell has been released. | ||
90 | */ | ||
91 | void contentsMouseReleaseEvent(QMouseEvent *e); | ||
92 | |||
93 | private: | ||
94 | class KDateInternalMonthPrivate; | ||
95 | KDateInternalMonthPrivate *d; | ||
96 | }; | ||
97 | |||
98 | /** Year selection widget. | ||
99 | * @internal | ||
100 | * @version $Id$ | ||
101 | * @author Tim Gilman, Mirko Boehm | ||
102 | */ | ||
103 | class KDateInternalYearSelector : public QLineEdit | ||
104 | { | ||
105 | Q_OBJECT | ||
106 | protected: | ||
107 | QIntValidator *val; | ||
108 | int result; | ||
109 | public slots: | ||
110 | void yearEnteredSlot(); | ||
111 | signals: | ||
112 | void closeMe(int); | ||
113 | public: | ||
114 | KDateInternalYearSelector(int fontsize, | ||
115 | QWidget* parent=0, | ||
116 | const char* name=0); | ||
117 | int getYear(); | ||
118 | void setYear(int year); | ||
119 | |||
120 | private: | ||
121 | class KDateInternalYearPrivate; | ||
122 | KDateInternalYearPrivate *d; | ||
123 | }; | ||
124 | |||
125 | /** | ||
126 | * Frame with popup menu behaviour. | ||
127 | * @author Tim Gilman, Mirko Boehm | ||
128 | * @version $Id$ | ||
129 | */ | ||
130 | class KPopupFrame : public QFrame | ||
131 | { | ||
132 | Q_OBJECT | ||
133 | protected: | ||
134 | /** | ||
135 | * The result. It is returned from exec() when the popup window closes. | ||
136 | */ | ||
137 | int result; | ||
138 | /** | ||
139 | * Catch key press events. | ||
140 | */ | ||
141 | void keyPressEvent(QKeyEvent* e); | ||
142 | /** | ||
143 | * The only subwidget that uses the whole dialog window. | ||
144 | */ | ||
145 | QWidget *main; | ||
146 | public slots: | ||
147 | /** | ||
148 | * Close the popup window. This is called from the main widget, usually. | ||
149 | * @p r is the result returned from exec(). | ||
150 | */ | ||
151 | void close(int r); | ||
152 | public: | ||
153 | /** | ||
154 | * The contructor. Creates a dialog without buttons. | ||
155 | */ | ||
156 | KPopupFrame(QWidget* parent=0, const char* name=0); | ||
157 | /** | ||
158 | * Set the main widget. You cannot set the main widget from the constructor, | ||
159 | * since it must be a child of the frame itselfes. | ||
160 | * Be careful: the size is set to the main widgets size. It is up to you to | ||
161 | * set the main widgets correct size before setting it as the main | ||
162 | * widget. | ||
163 | */ | ||
164 | void setMainWidget(QWidget* m); | ||
165 | /** | ||
166 | * The resize event. Simply resizes the main widget to the whole | ||
167 | * widgets client size. | ||
168 | */ | ||
169 | void resizeEvent(QResizeEvent*); | ||
170 | /** | ||
171 | * Open the popup window at position pos. | ||
172 | */ | ||
173 | void popup(const QPoint &pos); | ||
174 | /** | ||
175 | * Execute the popup window. | ||
176 | */ | ||
177 | int exec(QPoint p); | ||
178 | /** | ||
179 | * Dito. | ||
180 | */ | ||
181 | int exec(int x, int y); | ||
182 | |||
183 | private: | ||
184 | |||
185 | virtual bool close(bool alsoDelete) { return QFrame::close(alsoDelete); } | ||
186 | protected: | ||
187 | virtual void virtual_hook( int id, void* data ); | ||
188 | private: | ||
189 | class KPopupFramePrivate; | ||
190 | KPopupFramePrivate *d; | ||
191 | }; | ||
192 | |||
193 | /** | ||
194 | * Validates user-entered dates. | ||
195 | */ | ||
196 | class KDateValidator : public QValidator | ||
197 | { | ||
198 | public: | ||
199 | KDateValidator(QWidget* parent=0, const char* name=0); | ||
200 | virtual State validate(QString&, int&) const; | ||
201 | virtual void fixup ( QString & input ) const; | ||
202 | State date(const QString&, QDate&) const; | ||
203 | }; | ||
204 | |||
205 | /** | ||
206 | * Date selection table. | ||
207 | * This is a support class for the KDatePicker class. It just | ||
208 | * draws the calender table without titles, but could theoretically | ||
209 | * be used as a standalone. | ||
210 | * | ||
211 | * When a date is selected by the user, it emits a signal: | ||
212 | * dateSelected(QDate) | ||
213 | * | ||
214 | * @internal | ||
215 | * @version $Id$ | ||
216 | * @author Tim Gilman, Mirko Boehm | ||
217 | */ | ||
218 | class KDateTable : public QGridView | ||
219 | { | ||
220 | Q_OBJECT | ||
221 | public: | ||
222 | /** | ||
223 | * The constructor. | ||
224 | */ | ||
225 | KDateTable(QWidget *parent=0, | ||
226 | QDate date=QDate::currentDate(), | ||
227 | const char* name=0, WFlags f=0); | ||
228 | /** | ||
229 | * Returns a recommended size for the widget. | ||
230 | * To save some time, the size of the largest used cell content is | ||
231 | * calculated in each paintCell() call, since all calculations have | ||
232 | * to be done there anyway. The size is stored in maxCell. The | ||
233 | * sizeHint() simply returns a multiple of maxCell. | ||
234 | */ | ||
235 | virtual QSize sizeHint() const; | ||
236 | /** | ||
237 | * Set the font size of the date table. | ||
238 | */ | ||
239 | void setFontSize(int size); | ||
240 | /** | ||
241 | * Select and display this date. | ||
242 | */ | ||
243 | bool setDate(const QDate&); | ||
244 | const QDate& getDate() const; | ||
245 | |||
246 | |||
247 | protected: | ||
248 | /** | ||
249 | * Paint a cell. | ||
250 | */ | ||
251 | virtual void paintCell(QPainter*, int, int); | ||
252 | /** | ||
253 | * Handle the resize events. | ||
254 | */ | ||
255 | virtual void viewportResizeEvent(QResizeEvent *); | ||
256 | /** | ||
257 | * React on mouse clicks that select a date. | ||
258 | */ | ||
259 | virtual void contentsMousePressEvent(QMouseEvent *); | ||
260 | virtual void keyPressEvent( QKeyEvent *e ); | ||
261 | virtual void focusInEvent( QFocusEvent *e ); | ||
262 | virtual void focusOutEvent( QFocusEvent *e ); | ||
263 | /** | ||
264 | * The font size of the displayed text. | ||
265 | */ | ||
266 | int fontsize; | ||
267 | /** | ||
268 | * The currently selected date. | ||
269 | */ | ||
270 | QDate date; | ||
271 | /** | ||
272 | * The day of the first day in the month [1..7]. | ||
273 | */ | ||
274 | int firstday; | ||
275 | /** | ||
276 | * The number of days in the current month. | ||
277 | */ | ||
278 | int numdays; | ||
279 | /** | ||
280 | * The number of days in the previous month. | ||
281 | */ | ||
282 | int numDaysPrevMonth; | ||
283 | /** | ||
284 | * unused | ||
285 | */ | ||
286 | bool unused_hasSelection; | ||
287 | /** | ||
288 | * Save the size of the largest used cell content. | ||
289 | */ | ||
290 | QRect maxCell; | ||
291 | signals: | ||
292 | /** | ||
293 | * The selected date changed. | ||
294 | */ | ||
295 | void dateChanged(QDate); | ||
296 | /** | ||
297 | * A date has been selected by clicking on the table. | ||
298 | */ | ||
299 | void tableClicked(); | ||
300 | |||
301 | protected: | ||
302 | virtual void virtual_hook( int id, void* data ); | ||
303 | private: | ||
304 | class KDateTablePrivate; | ||
305 | KDateTablePrivate *d; | ||
306 | }; | ||
307 | |||
308 | #endif // KDATETBL_H | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kdebug.h b/noncore/apps/tinykate/libkate/microkde/kdebug.h new file mode 100644 index 0000000..9042644 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kdebug.h | |||
@@ -0,0 +1,112 @@ | |||
1 | #ifndef MINIKDE_KDEBUG_H | ||
2 | #define MINIKDE_KDEBUG_H | ||
3 | |||
4 | #include <stdio.h> | ||
5 | |||
6 | #include <qstring.h> | ||
7 | |||
8 | class kdbgstream; | ||
9 | typedef kdbgstream & (*KDBGFUNC)(kdbgstream &); // manipulator function | ||
10 | |||
11 | class kdbgstream { | ||
12 | public: | ||
13 | kdbgstream(unsigned int _area, unsigned int _level, bool _print = true) : | ||
14 | area(_area), level(_level), print(_print) { } | ||
15 | kdbgstream(const char * initialString, unsigned int _area, unsigned int _level, bool _print = true) : | ||
16 | output(QString::fromLatin1(initialString)), area(_area), level(_level), print(_print) { } | ||
17 | ~kdbgstream() | ||
18 | { | ||
19 | if (!output.isEmpty()) { | ||
20 | fprintf(stderr,"ASSERT: debug output not ended with \\n\n"); | ||
21 | *this << "\n"; | ||
22 | } | ||
23 | } | ||
24 | kdbgstream &operator<<(bool i) { | ||
25 | if (!print) return *this; | ||
26 | output += QString::fromLatin1(i ? "true" : "false"); | ||
27 | return *this; | ||
28 | } | ||
29 | kdbgstream &operator<<(short i) { | ||
30 | if (!print) return *this; | ||
31 | QString tmp; tmp.setNum(i); output += tmp; | ||
32 | return *this; | ||
33 | } | ||
34 | kdbgstream &operator<<(unsigned short i) { | ||
35 | if (!print) return *this; | ||
36 | QString tmp; tmp.setNum(i); output += tmp; | ||
37 | return *this; | ||
38 | } | ||
39 | kdbgstream &operator<<(char i) { | ||
40 | if (!print) return *this; | ||
41 | QString tmp; tmp.setNum(int(i)); output += tmp; | ||
42 | return *this; | ||
43 | } | ||
44 | kdbgstream &operator<<(unsigned char i) { | ||
45 | if (!print) return *this; | ||
46 | QString tmp; tmp.setNum(static_cast<unsigned int>(i)); output += tmp; | ||
47 | return *this; | ||
48 | } | ||
49 | |||
50 | kdbgstream &operator<<(int i) { | ||
51 | if (!print) return *this; | ||
52 | QString tmp; tmp.setNum(i); output += tmp; | ||
53 | return *this; | ||
54 | } | ||
55 | kdbgstream &operator<<(unsigned int i) { | ||
56 | if (!print) return *this; | ||
57 | QString tmp; tmp.setNum(i); output += tmp; | ||
58 | return *this; | ||
59 | } | ||
60 | kdbgstream &operator<<(long i) { | ||
61 | if (!print) return *this; | ||
62 | QString tmp; tmp.setNum(i); output += tmp; | ||
63 | return *this; | ||
64 | } | ||
65 | kdbgstream &operator<<(unsigned long i) { | ||
66 | if (!print) return *this; | ||
67 | QString tmp; tmp.setNum(i); output += tmp; | ||
68 | return *this; | ||
69 | } | ||
70 | kdbgstream &operator<<(const QString& string) { | ||
71 | if (!print) return *this; | ||
72 | output += string; | ||
73 | if (output.at(output.length() -1 ) == '\n') | ||
74 | flush(); | ||
75 | return *this; | ||
76 | } | ||
77 | kdbgstream &operator<<(const char *string) { | ||
78 | if (!print) return *this; | ||
79 | output += QString::fromUtf8(string); | ||
80 | if (output.at(output.length() - 1) == '\n') | ||
81 | flush(); | ||
82 | return *this; | ||
83 | } | ||
84 | kdbgstream &operator<<(const QCString& string) { | ||
85 | *this << string.data(); | ||
86 | return *this; | ||
87 | } | ||
88 | kdbgstream& operator<<(KDBGFUNC f) { | ||
89 | if (!print) return *this; | ||
90 | return (*f)(*this); | ||
91 | } | ||
92 | kdbgstream& operator<<(double d) { | ||
93 | QString tmp; tmp.setNum(d); output += tmp; | ||
94 | return *this; | ||
95 | } | ||
96 | void flush() { | ||
97 | if (output.isEmpty() || !print) | ||
98 | return; | ||
99 | printf("%s",output.latin1()); | ||
100 | output = QString::null; | ||
101 | } | ||
102 | private: | ||
103 | QString output; | ||
104 | unsigned int area, level; | ||
105 | bool print; | ||
106 | }; | ||
107 | |||
108 | inline kdbgstream &endl( kdbgstream &s) { s << "\n"; return s; } | ||
109 | |||
110 | inline kdbgstream kdDebug(int area = 0) { return kdbgstream(area, 0); } | ||
111 | |||
112 | #endif | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kdialog.h b/noncore/apps/tinykate/libkate/microkde/kdialog.h new file mode 100644 index 0000000..56f6bb0 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kdialog.h | |||
@@ -0,0 +1,16 @@ | |||
1 | #ifndef MINIKDE_KDIALOG_H | ||
2 | #define MINIKDE_KDIALOG_H | ||
3 | |||
4 | #include <qdialog.h> | ||
5 | |||
6 | class KDialog : public QDialog | ||
7 | { | ||
8 | public: | ||
9 | KDialog( QWidget *parent=0, const char *name=0, bool modal=true ) : | ||
10 | QDialog( parent, name, modal ) {} | ||
11 | |||
12 | static int spacingHint() { return 3; } | ||
13 | static int marginHint() { return 3; } | ||
14 | }; | ||
15 | |||
16 | #endif | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kdialogbase.cpp b/noncore/apps/tinykate/libkate/microkde/kdialogbase.cpp new file mode 100644 index 0000000..8caefe0 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kdialogbase.cpp | |||
@@ -0,0 +1,214 @@ | |||
1 | #include <qtabwidget.h> | ||
2 | #include <qpushbutton.h> | ||
3 | #include <qlayout.h> | ||
4 | #include <qframe.h> | ||
5 | |||
6 | #include "klocale.h" | ||
7 | #include "kdebug.h" | ||
8 | |||
9 | #include "kdialogbase.h" | ||
10 | |||
11 | KDialogBase::KDialogBase() | ||
12 | { | ||
13 | } | ||
14 | |||
15 | KDialogBase::KDialogBase( QWidget *parent, const char *name, bool modal, | ||
16 | const QString &caption, | ||
17 | int buttonMask, ButtonCode defaultButton, | ||
18 | bool separator, | ||
19 | const QString &user1, | ||
20 | const QString &user2, | ||
21 | const QString &user3) : | ||
22 | KDialog( parent, name, modal ) | ||
23 | { | ||
24 | init( caption, buttonMask, user1 ); | ||
25 | } | ||
26 | |||
27 | KDialogBase::KDialogBase( int dialogFace, const QString &caption, | ||
28 | int buttonMask, ButtonCode defaultButton, | ||
29 | QWidget *parent, const char *name, bool modal, | ||
30 | bool separator, | ||
31 | const QString &user1, | ||
32 | const QString &user2, | ||
33 | const QString &user3) : | ||
34 | KDialog( parent, name, modal ) | ||
35 | { | ||
36 | init( caption, buttonMask, user1 ); | ||
37 | } | ||
38 | |||
39 | KDialogBase::~KDialogBase() | ||
40 | { | ||
41 | } | ||
42 | |||
43 | void KDialogBase::init( const QString &caption, int buttonMask, | ||
44 | const QString &user1 ) | ||
45 | { | ||
46 | mMainWidget = 0; | ||
47 | mTabWidget = 0; | ||
48 | mPlainPage = 0; | ||
49 | mTopLayout = 0; | ||
50 | |||
51 | if ( !caption.isEmpty() ) { | ||
52 | setCaption( caption ); | ||
53 | } | ||
54 | |||
55 | if ( buttonMask & User1 ) { | ||
56 | mUser1Button = new QPushButton( user1, this ); | ||
57 | connect( mUser1Button, SIGNAL( clicked() ), SLOT( slotUser1() ) ); | ||
58 | } else { | ||
59 | mUser1Button = 0; | ||
60 | } | ||
61 | |||
62 | if ( buttonMask & Ok ) { | ||
63 | mOkButton = new QPushButton( i18n("Ok"), this ); | ||
64 | connect( mOkButton, SIGNAL( clicked() ), SLOT( slotOk() ) ); | ||
65 | } else { | ||
66 | mOkButton = 0; | ||
67 | } | ||
68 | |||
69 | if ( buttonMask & Apply ) { | ||
70 | mApplyButton = new QPushButton( i18n("Apply"), this ); | ||
71 | connect( mApplyButton, SIGNAL( clicked() ), SLOT( slotApply() ) ); | ||
72 | } else { | ||
73 | mApplyButton = 0; | ||
74 | } | ||
75 | |||
76 | if ( buttonMask & Cancel ) { | ||
77 | mCancelButton = new QPushButton( i18n("Cancel"), this ); | ||
78 | connect( mCancelButton, SIGNAL( clicked() ), SLOT( slotCancel() ) ); | ||
79 | } else { | ||
80 | mCancelButton = 0; | ||
81 | } | ||
82 | |||
83 | if ( buttonMask & Close ) { | ||
84 | mCloseButton = new QPushButton( i18n("Close"), this ); | ||
85 | connect( mCloseButton, SIGNAL( clicked() ), SLOT( slotClose() ) ); | ||
86 | } else { | ||
87 | mCloseButton = 0; | ||
88 | } | ||
89 | } | ||
90 | |||
91 | QTabWidget *KDialogBase::tabWidget() | ||
92 | { | ||
93 | if ( !mTabWidget ) { | ||
94 | mTabWidget = new QTabWidget( this ); | ||
95 | setMainWidget( mTabWidget ); | ||
96 | } | ||
97 | return mTabWidget; | ||
98 | } | ||
99 | |||
100 | void KDialogBase::initLayout() | ||
101 | { | ||
102 | delete mTopLayout; | ||
103 | mTopLayout = new QVBoxLayout( this ); | ||
104 | mTopLayout->setMargin( marginHint() ); | ||
105 | mTopLayout->setSpacing( spacingHint() ); | ||
106 | |||
107 | mTopLayout->addWidget( mMainWidget ); | ||
108 | |||
109 | QBoxLayout *buttonLayout = new QHBoxLayout; | ||
110 | mTopLayout->addLayout( buttonLayout ); | ||
111 | |||
112 | if ( mUser1Button ) buttonLayout->addWidget( mUser1Button ); | ||
113 | if ( mOkButton ) buttonLayout->addWidget( mOkButton ); | ||
114 | if ( mApplyButton ) buttonLayout->addWidget( mApplyButton ); | ||
115 | if ( mCancelButton ) buttonLayout->addWidget( mCancelButton ); | ||
116 | if ( mCloseButton ) buttonLayout->addWidget( mCloseButton ); | ||
117 | } | ||
118 | |||
119 | QFrame *KDialogBase::addPage( const QString &name ) | ||
120 | { | ||
121 | // kdDebug() << "KDialogBase::addPage(): " << name << endl; | ||
122 | |||
123 | QFrame *frame = new QFrame( tabWidget() ); | ||
124 | tabWidget()->addTab( frame, name ); | ||
125 | return frame; | ||
126 | } | ||
127 | |||
128 | QFrame *KDialogBase::addPage( const QString &name, int, const QPixmap & ) | ||
129 | { | ||
130 | return addPage( name ); | ||
131 | } | ||
132 | |||
133 | |||
134 | void KDialogBase::setMainWidget( QWidget *widget ) | ||
135 | { | ||
136 | kdDebug() << "KDialogBase::setMainWidget()" << endl; | ||
137 | |||
138 | mMainWidget = widget; | ||
139 | initLayout(); | ||
140 | } | ||
141 | |||
142 | |||
143 | void KDialogBase::enableButton( ButtonCode id, bool state ) | ||
144 | { | ||
145 | QPushButton *button = 0; | ||
146 | switch ( id ) { | ||
147 | case Ok: | ||
148 | button = mOkButton; | ||
149 | break; | ||
150 | case Apply: | ||
151 | button = mApplyButton; | ||
152 | break; | ||
153 | default: | ||
154 | break; | ||
155 | } | ||
156 | if ( button ) { | ||
157 | button->setEnabled( state ); | ||
158 | } | ||
159 | } | ||
160 | |||
161 | void KDialogBase::enableButtonOK( bool state ) | ||
162 | { | ||
163 | enableButton( Ok, state ); | ||
164 | } | ||
165 | |||
166 | void KDialogBase::enableButtonApply( bool state ) | ||
167 | { | ||
168 | enableButton( Apply, state ); | ||
169 | } | ||
170 | |||
171 | |||
172 | int KDialogBase::pageIndex( QWidget *widget ) const | ||
173 | { | ||
174 | return 0; | ||
175 | } | ||
176 | |||
177 | |||
178 | bool KDialogBase::showPage( int index ) | ||
179 | { | ||
180 | return false; | ||
181 | } | ||
182 | |||
183 | QFrame *KDialogBase::plainPage() | ||
184 | { | ||
185 | if ( !mPlainPage ) { | ||
186 | mPlainPage = new QFrame( this ); | ||
187 | setMainWidget( mPlainPage ); | ||
188 | } | ||
189 | return mPlainPage; | ||
190 | } | ||
191 | |||
192 | void KDialogBase::slotOk() | ||
193 | { | ||
194 | accept(); | ||
195 | } | ||
196 | |||
197 | void KDialogBase::slotApply() | ||
198 | { | ||
199 | } | ||
200 | |||
201 | void KDialogBase::slotCancel() | ||
202 | { | ||
203 | reject(); | ||
204 | } | ||
205 | |||
206 | void KDialogBase::slotClose() | ||
207 | { | ||
208 | accept(); | ||
209 | } | ||
210 | |||
211 | void KDialogBase::slotUser1() | ||
212 | { | ||
213 | emit user1Clicked(); | ||
214 | } | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kdialogbase.h b/noncore/apps/tinykate/libkate/microkde/kdialogbase.h new file mode 100644 index 0000000..dfb85d2 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kdialogbase.h | |||
@@ -0,0 +1,105 @@ | |||
1 | #ifndef MINIKDE_KDIALOGBASE_H | ||
2 | #define MINIKDE_KDIALOGBASE_H | ||
3 | |||
4 | #include <qframe.h> | ||
5 | |||
6 | #include "kdialog.h" | ||
7 | |||
8 | class QPushButton; | ||
9 | class QLayout; | ||
10 | class QTabWidget; | ||
11 | class QBoxLayout; | ||
12 | |||
13 | class KDialogBase : public KDialog | ||
14 | { | ||
15 | Q_OBJECT | ||
16 | public: | ||
17 | enum ButtonCode | ||
18 | { | ||
19 | Help = 0x00000001, | ||
20 | Default = 0x00000002, | ||
21 | Ok = 0x00000004, | ||
22 | Apply = 0x00000008, | ||
23 | Try = 0x00000010, | ||
24 | Cancel = 0x00000020, | ||
25 | Close = 0x00000040, | ||
26 | User1 = 0x00000080, | ||
27 | User2 = 0x00000100, | ||
28 | User3 = 0x00000200, | ||
29 | No = 0x00000080, | ||
30 | Yes = 0x00000100, | ||
31 | Details = 0x00000400, | ||
32 | Filler = 0x40000000, | ||
33 | Stretch = 0x80000000 | ||
34 | }; | ||
35 | |||
36 | enum DialogType | ||
37 | { | ||
38 | TreeList, | ||
39 | Tabbed, | ||
40 | Plain, | ||
41 | Swallow, | ||
42 | IconList | ||
43 | }; | ||
44 | |||
45 | KDialogBase(); | ||
46 | KDialogBase( QWidget *parent=0, const char *name=0, bool modal=true, | ||
47 | const QString &caption=QString::null, | ||
48 | int buttonMask=Ok|Apply|Cancel, ButtonCode defaultButton=Ok, | ||
49 | bool separator=false, | ||
50 | const QString &user1=QString::null, | ||
51 | const QString &user2=QString::null, | ||
52 | const QString &user3=QString::null); | ||
53 | KDialogBase( int dialogFace, const QString &caption, | ||
54 | int buttonMask, ButtonCode defaultButton, | ||
55 | QWidget *parent=0, const char *name=0, bool modal=true, | ||
56 | bool separator=false, | ||
57 | const QString &user1=QString::null, | ||
58 | const QString &user2=QString::null, | ||
59 | const QString &user3=QString::null); | ||
60 | virtual ~KDialogBase(); | ||
61 | |||
62 | QFrame *addPage( const QString & ); | ||
63 | QFrame *addPage( const QString &, int, const QPixmap & ); | ||
64 | |||
65 | void setMainWidget( QWidget *widget ); | ||
66 | |||
67 | void enableButton( ButtonCode id, bool state ); | ||
68 | void enableButtonOK( bool state ); | ||
69 | void enableButtonApply( bool state ); | ||
70 | |||
71 | int pageIndex( QWidget *widget ) const; | ||
72 | |||
73 | bool showPage( int index ); | ||
74 | |||
75 | QFrame *plainPage(); | ||
76 | |||
77 | signals: | ||
78 | void user1Clicked(); | ||
79 | |||
80 | protected slots: | ||
81 | virtual void slotOk(); | ||
82 | virtual void slotApply(); | ||
83 | virtual void slotCancel(); | ||
84 | virtual void slotClose(); | ||
85 | virtual void slotUser1(); | ||
86 | |||
87 | private: | ||
88 | QTabWidget *tabWidget(); | ||
89 | void init( const QString &caption, int buttonMask, | ||
90 | const QString &user1=QString::null ); | ||
91 | void initLayout(); | ||
92 | |||
93 | QWidget *mMainWidget; | ||
94 | QTabWidget *mTabWidget; | ||
95 | QFrame *mPlainPage; | ||
96 | QBoxLayout *mTopLayout; | ||
97 | |||
98 | QPushButton *mUser1Button; | ||
99 | QPushButton *mCloseButton; | ||
100 | QPushButton *mOkButton; | ||
101 | QPushButton *mApplyButton; | ||
102 | QPushButton *mCancelButton; | ||
103 | }; | ||
104 | |||
105 | #endif | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kemailsettings.cpp b/noncore/apps/tinykate/libkate/microkde/kemailsettings.cpp new file mode 100644 index 0000000..9a9ad84 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kemailsettings.cpp | |||
@@ -0,0 +1,6 @@ | |||
1 | #include "kemailsettings.h" | ||
2 | |||
3 | QString KEMailSettings::getSetting(KEMailSettings::Setting s) | ||
4 | { | ||
5 | return QString::null; | ||
6 | } | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kemailsettings.h b/noncore/apps/tinykate/libkate/microkde/kemailsettings.h new file mode 100644 index 0000000..cf43f17 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kemailsettings.h | |||
@@ -0,0 +1,32 @@ | |||
1 | #ifndef MINIKDE_KEMAILSETTINGS_H | ||
2 | #define MINIKDE_KEMAILSETTINGS_H | ||
3 | |||
4 | #include <qstring.h> | ||
5 | |||
6 | class KEMailSettings | ||
7 | { | ||
8 | public: | ||
9 | enum Setting { | ||
10 | ClientProgram, | ||
11 | ClientTerminal, | ||
12 | RealName, | ||
13 | EmailAddress, | ||
14 | ReplyToAddress, | ||
15 | Organization, | ||
16 | OutServer, | ||
17 | OutServerLogin, | ||
18 | OutServerPass, | ||
19 | OutServerType, | ||
20 | OutServerCommand, | ||
21 | OutServerTLS, | ||
22 | InServer, | ||
23 | InServerLogin, | ||
24 | InServerPass, | ||
25 | InServerType, | ||
26 | InServerMBXType, | ||
27 | InServerTLS | ||
28 | }; | ||
29 | QString getSetting(KEMailSettings::Setting s); | ||
30 | }; | ||
31 | |||
32 | #endif | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kfiledialog.h b/noncore/apps/tinykate/libkate/microkde/kfiledialog.h new file mode 100644 index 0000000..61781f0 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kfiledialog.h | |||
@@ -0,0 +1,21 @@ | |||
1 | #ifndef MICROKDE_KFILEDIALOG_H | ||
2 | #define MICROKDE_KFILEDIALOG_H | ||
3 | |||
4 | class KFileDialog | ||
5 | { | ||
6 | public: | ||
7 | |||
8 | static QString getSaveFileName( const QString &, | ||
9 | const QString &, QWidget * ) | ||
10 | { | ||
11 | return QString::null; | ||
12 | } | ||
13 | |||
14 | static QString getOpenFileName( const QString &, | ||
15 | const QString &, QWidget * ) | ||
16 | { | ||
17 | return QString::null; | ||
18 | } | ||
19 | }; | ||
20 | |||
21 | #endif | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kfontdialog.cpp b/noncore/apps/tinykate/libkate/microkde/kfontdialog.cpp new file mode 100644 index 0000000..d199936 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kfontdialog.cpp | |||
@@ -0,0 +1,6 @@ | |||
1 | #include "kfontdialog.h" | ||
2 | |||
3 | int KFontDialog::getFont( const QFont & ) | ||
4 | { | ||
5 | return 0; | ||
6 | } | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kfontdialog.h b/noncore/apps/tinykate/libkate/microkde/kfontdialog.h new file mode 100644 index 0000000..a4bf23d --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kfontdialog.h | |||
@@ -0,0 +1,14 @@ | |||
1 | #ifndef MINIKDE_KFONTDIALOG_H | ||
2 | #define MINIKDE_KFONTDIALOG_H | ||
3 | |||
4 | #include <qfont.h> | ||
5 | |||
6 | class KFontDialog | ||
7 | { | ||
8 | public: | ||
9 | enum { Accepted }; | ||
10 | |||
11 | static int getFont( const QFont & ); | ||
12 | }; | ||
13 | |||
14 | #endif | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kglobal.cpp b/noncore/apps/tinykate/libkate/microkde/kglobal.cpp new file mode 100644 index 0000000..572768d --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kglobal.cpp | |||
@@ -0,0 +1,49 @@ | |||
1 | #include "kglobal.h" | ||
2 | |||
3 | KLocale *KGlobal::mLocale = 0; | ||
4 | KConfig *KGlobal::mConfig = 0; | ||
5 | KIconLoader *KGlobal::mIconLoader = 0; | ||
6 | KStandardDirs *KGlobal::mDirs = 0; | ||
7 | |||
8 | QString KGlobal::mAppName = "godot"; | ||
9 | |||
10 | KLocale *KGlobal::locale() | ||
11 | { | ||
12 | if ( !mLocale ) { | ||
13 | mLocale = new KLocale(); | ||
14 | } | ||
15 | |||
16 | return mLocale; | ||
17 | } | ||
18 | |||
19 | KConfig *KGlobal::config() | ||
20 | { | ||
21 | if ( !mConfig ) { | ||
22 | mConfig = new KConfig( KStandardDirs::appDir() + mAppName + "rc" ); | ||
23 | } | ||
24 | |||
25 | return mConfig; | ||
26 | } | ||
27 | |||
28 | KIconLoader *KGlobal::iconLoader() | ||
29 | { | ||
30 | if ( !mIconLoader ) { | ||
31 | mIconLoader = new KIconLoader(); | ||
32 | } | ||
33 | |||
34 | return mIconLoader; | ||
35 | } | ||
36 | |||
37 | KStandardDirs *KGlobal::dirs() | ||
38 | { | ||
39 | if ( !mDirs ) { | ||
40 | mDirs = new KStandardDirs(); | ||
41 | } | ||
42 | |||
43 | return mDirs; | ||
44 | } | ||
45 | |||
46 | void KGlobal::setAppName( const QString &appName ) | ||
47 | { | ||
48 | mAppName = appName; | ||
49 | } | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kglobal.h b/noncore/apps/tinykate/libkate/microkde/kglobal.h new file mode 100644 index 0000000..8985bd4 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kglobal.h | |||
@@ -0,0 +1,27 @@ | |||
1 | #ifndef MINIKDE_KGLOBAL_H | ||
2 | #define MINIKDE_KGLOBAL_H | ||
3 | |||
4 | #include "klocale.h" | ||
5 | #include "kiconloader.h" | ||
6 | #include "kstandarddirs.h" | ||
7 | #include "kconfig.h" | ||
8 | |||
9 | class KGlobal { | ||
10 | public: | ||
11 | static KLocale *locale(); | ||
12 | static KConfig *config(); | ||
13 | static KIconLoader *iconLoader(); | ||
14 | static KStandardDirs *dirs(); | ||
15 | |||
16 | static void setAppName( const QString & ); | ||
17 | |||
18 | private: | ||
19 | static KLocale *mLocale; | ||
20 | static KConfig *mConfig; | ||
21 | static KIconLoader *mIconLoader; | ||
22 | static KStandardDirs *mDirs; | ||
23 | |||
24 | static QString mAppName; | ||
25 | }; | ||
26 | |||
27 | #endif | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kglobalsettings.cpp b/noncore/apps/tinykate/libkate/microkde/kglobalsettings.cpp new file mode 100644 index 0000000..cb5fe4c --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kglobalsettings.cpp | |||
@@ -0,0 +1,17 @@ | |||
1 | #include "kglobalsettings.h" | ||
2 | |||
3 | QFont KGlobalSettings::generalFont() | ||
4 | { | ||
5 | return QFont("fixed",12); | ||
6 | } | ||
7 | |||
8 | QColor KGlobalSettings::baseColor() | ||
9 | { | ||
10 | return Qt::white; | ||
11 | } | ||
12 | |||
13 | QColor KGlobalSettings::highlightColor() | ||
14 | { | ||
15 | return Qt::blue; | ||
16 | } | ||
17 | |||
diff --git a/noncore/apps/tinykate/libkate/microkde/kglobalsettings.h b/noncore/apps/tinykate/libkate/microkde/kglobalsettings.h new file mode 100644 index 0000000..34cdb49 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kglobalsettings.h | |||
@@ -0,0 +1,15 @@ | |||
1 | #ifndef MICROKDE_KGLOBALSETTINGS_H | ||
2 | #define MICROKDE_KGLOBALSETTINGS_H | ||
3 | |||
4 | #include <qfont.h> | ||
5 | #include <qcolor.h> | ||
6 | |||
7 | class KGlobalSettings | ||
8 | { | ||
9 | public: | ||
10 | static QFont generalFont(); | ||
11 | static QColor baseColor(); | ||
12 | static QColor highlightColor(); | ||
13 | }; | ||
14 | |||
15 | #endif | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kiconloader.cpp b/noncore/apps/tinykate/libkate/microkde/kiconloader.cpp new file mode 100644 index 0000000..83a2cad --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kiconloader.cpp | |||
@@ -0,0 +1,33 @@ | |||
1 | #include <qpe/resource.h> | ||
2 | |||
3 | #include "kiconloader.h" | ||
4 | |||
5 | QPixmap KIconLoader::loadIcon( const QString &name, int ) | ||
6 | { | ||
7 | return Resource::loadPixmap( "kate/" + name ); | ||
8 | } | ||
9 | |||
10 | QString KIconLoader::iconPath( const QString &, int ) | ||
11 | { | ||
12 | return QString::null; | ||
13 | } | ||
14 | |||
15 | QPixmap BarIcon( const QString &name ) | ||
16 | { | ||
17 | return Resource::loadPixmap( "kate/" + name ); | ||
18 | } | ||
19 | |||
20 | QPixmap DesktopIcon( const QString &name, int ) | ||
21 | { | ||
22 | return Resource::loadPixmap( "kate/" + name ); | ||
23 | } | ||
24 | |||
25 | QPixmap SmallIcon( const QString &name ) | ||
26 | { | ||
27 | return Resource::loadPixmap( "kate/" + name ); | ||
28 | } | ||
29 | |||
30 | QPixmap SmallIconSet( const QString &name ) | ||
31 | { | ||
32 | return Resource::loadPixmap( "kate/" + name ); | ||
33 | } | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kiconloader.h b/noncore/apps/tinykate/libkate/microkde/kiconloader.h new file mode 100644 index 0000000..c4f642e --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kiconloader.h | |||
@@ -0,0 +1,31 @@ | |||
1 | #ifndef MINIKDE_KICONLOADER_H | ||
2 | #define MINIKDE_KICONLOADER_H | ||
3 | |||
4 | #include <qpixmap.h> | ||
5 | #include <qstring.h> | ||
6 | |||
7 | class KIcon | ||
8 | { | ||
9 | public: | ||
10 | enum Group { NoGroup=-1, Desktop=0, Toolbar, MainToolbar, Small, | ||
11 | Panel, LastGroup, User }; | ||
12 | enum StdSizes { SizeSmall=16, SizeMedium=32, SizeLarge=48 }; | ||
13 | }; | ||
14 | |||
15 | class KIconLoader | ||
16 | { | ||
17 | public: | ||
18 | QPixmap loadIcon( const QString &name, int ); | ||
19 | |||
20 | QString iconPath( const QString &, int ); | ||
21 | }; | ||
22 | |||
23 | QPixmap BarIcon(const QString& name); | ||
24 | |||
25 | QPixmap DesktopIcon(const QString& name, int); | ||
26 | |||
27 | QPixmap SmallIcon(const QString& name); | ||
28 | |||
29 | QPixmap SmallIconSet( const QString &name ); | ||
30 | |||
31 | #endif | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/klineedit.h b/noncore/apps/tinykate/libkate/microkde/klineedit.h new file mode 100644 index 0000000..26956ad --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/klineedit.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef MINIKDE_KLINEEDIT_H | ||
2 | #define MINIKDE_KLINEEDIT_H | ||
3 | |||
4 | #include <qlineedit.h> | ||
5 | |||
6 | class KLineEdit : public QLineEdit | ||
7 | { | ||
8 | public: | ||
9 | KLineEdit( QWidget *parent=0, const char *name=0 ) : | ||
10 | QLineEdit( parent, name ) {} | ||
11 | }; | ||
12 | |||
13 | #endif | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/klineeditdlg.h b/noncore/apps/tinykate/libkate/microkde/klineeditdlg.h new file mode 100644 index 0000000..4136054 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/klineeditdlg.h | |||
@@ -0,0 +1,8 @@ | |||
1 | #ifndef _mykdelineeditdlg_h_ | ||
2 | #define _mykdelineeditdlg_h_ | ||
3 | |||
4 | #include <qinputdialog.h> | ||
5 | |||
6 | #define KLineEditDlg QInputDialog | ||
7 | |||
8 | #endif | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/klistview.h b/noncore/apps/tinykate/libkate/microkde/klistview.h new file mode 100644 index 0000000..008acbc --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/klistview.h | |||
@@ -0,0 +1,24 @@ | |||
1 | #ifndef MICROKDE_KLISTVIEW_H | ||
2 | #define MICROKDE_KLISTVIEW_H | ||
3 | |||
4 | #include <qlistview.h> | ||
5 | #include <qpoint.h> | ||
6 | #include <qstring.h> | ||
7 | |||
8 | class KConfig; | ||
9 | |||
10 | class KListView : public QListView | ||
11 | { | ||
12 | Q_OBJECT | ||
13 | public: | ||
14 | KListView( QWidget *parent=0, const char *name=0 ) | ||
15 | : QListView( parent, name ) {} | ||
16 | |||
17 | void saveLayout( KConfig *, const QString & ) {} | ||
18 | void restoreLayout( KConfig *, const QString & ) {} | ||
19 | |||
20 | signals: | ||
21 | void doubleClicked( QListViewItem *, QPoint, int ); | ||
22 | }; | ||
23 | |||
24 | #endif | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/klocale.cpp b/noncore/apps/tinykate/libkate/microkde/klocale.cpp new file mode 100644 index 0000000..dfdb97a --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/klocale.cpp | |||
@@ -0,0 +1,530 @@ | |||
1 | #include <qregexp.h> | ||
2 | |||
3 | #include "kdebug.h" | ||
4 | |||
5 | #include "klocale.h" | ||
6 | |||
7 | QString i18n(const char *text) | ||
8 | { | ||
9 | return QString( text ); | ||
10 | } | ||
11 | |||
12 | QString i18n(const char *,const char *text) | ||
13 | { | ||
14 | return QString( text ); | ||
15 | } | ||
16 | |||
17 | inline void put_it_in( QChar *buffer, uint& index, const QString &s ) | ||
18 | { | ||
19 | for ( uint l = 0; l < s.length(); l++ ) | ||
20 | buffer[index++] = s.at( l ); | ||
21 | } | ||
22 | |||
23 | inline void put_it_in( QChar *buffer, uint& index, int number ) | ||
24 | { | ||
25 | buffer[index++] = number / 10 + '0'; | ||
26 | buffer[index++] = number % 10 + '0'; | ||
27 | } | ||
28 | |||
29 | static int readInt(const QString &str, uint &pos) | ||
30 | { | ||
31 | if (!str.at(pos).isDigit()) return -1; | ||
32 | int result = 0; | ||
33 | for (; str.length() > pos && str.at(pos).isDigit(); pos++) | ||
34 | { | ||
35 | result *= 10; | ||
36 | result += str.at(pos).digitValue(); | ||
37 | } | ||
38 | |||
39 | return result; | ||
40 | } | ||
41 | |||
42 | QString KLocale::formatTime(const QTime &pTime, bool includeSecs) const | ||
43 | { | ||
44 | const QString rst = timeFormat(); | ||
45 | |||
46 | // only "pm/am" here can grow, the rest shrinks, but | ||
47 | // I'm rather safe than sorry | ||
48 | QChar *buffer = new QChar[rst.length() * 3 / 2 + 30]; | ||
49 | |||
50 | uint index = 0; | ||
51 | bool escape = false; | ||
52 | int number = 0; | ||
53 | |||
54 | for ( uint format_index = 0; format_index < rst.length(); format_index++ ) | ||
55 | { | ||
56 | if ( !escape ) | ||
57 | { | ||
58 | if ( rst.at( format_index ).unicode() == '%' ) | ||
59 | escape = true; | ||
60 | else | ||
61 | buffer[index++] = rst.at( format_index ); | ||
62 | } | ||
63 | else | ||
64 | { | ||
65 | switch ( rst.at( format_index ).unicode() ) | ||
66 | { | ||
67 | case '%': | ||
68 | buffer[index++] = '%'; | ||
69 | break; | ||
70 | case 'H': | ||
71 | put_it_in( buffer, index, pTime.hour() ); | ||
72 | break; | ||
73 | case 'I': | ||
74 | put_it_in( buffer, index, ( pTime.hour() + 11) % 12 + 1 ); | ||
75 | break; | ||
76 | case 'M': | ||
77 | put_it_in( buffer, index, pTime.minute() ); | ||
78 | break; | ||
79 | case 'S': | ||
80 | if (includeSecs) | ||
81 | put_it_in( buffer, index, pTime.second() ); | ||
82 | else | ||
83 | { | ||
84 | // we remove the seperator sign before the seconds and | ||
85 | // assume that works everywhere | ||
86 | --index; | ||
87 | break; | ||
88 | } | ||
89 | break; | ||
90 | case 'k': | ||
91 | number = pTime.hour(); | ||
92 | case 'l': | ||
93 | // to share the code | ||
94 | if ( rst.at( format_index ).unicode() == 'l' ) | ||
95 | number = (pTime.hour() + 11) % 12 + 1; | ||
96 | if ( number / 10 ) | ||
97 | buffer[index++] = number / 10 + '0'; | ||
98 | buffer[index++] = number % 10 + '0'; | ||
99 | break; | ||
100 | case 'p': | ||
101 | { | ||
102 | QString s; | ||
103 | if ( pTime.hour() >= 12 ) | ||
104 | put_it_in( buffer, index, i18n("pm") ); | ||
105 | else | ||
106 | put_it_in( buffer, index, i18n("am") ); | ||
107 | break; | ||
108 | } | ||
109 | default: | ||
110 | buffer[index++] = rst.at( format_index ); | ||
111 | break; | ||
112 | } | ||
113 | escape = false; | ||
114 | } | ||
115 | } | ||
116 | QString ret( buffer, index ); | ||
117 | delete [] buffer; | ||
118 | return ret; | ||
119 | } | ||
120 | |||
121 | QString KLocale::formatDate(const QDate &pDate, bool shortFormat) const | ||
122 | { | ||
123 | const QString rst = shortFormat?dateFormatShort():dateFormat(); | ||
124 | |||
125 | // I'm rather safe than sorry | ||
126 | QChar *buffer = new QChar[rst.length() * 3 / 2 + 50]; | ||
127 | |||
128 | unsigned int index = 0; | ||
129 | bool escape = false; | ||
130 | int number = 0; | ||
131 | |||
132 | for ( uint format_index = 0; format_index < rst.length(); ++format_index ) | ||
133 | { | ||
134 | if ( !escape ) | ||
135 | { | ||
136 | if ( rst.at( format_index ).unicode() == '%' ) | ||
137 | escape = true; | ||
138 | else | ||
139 | buffer[index++] = rst.at( format_index ); | ||
140 | } | ||
141 | else | ||
142 | { | ||
143 | switch ( rst.at( format_index ).unicode() ) | ||
144 | { | ||
145 | case '%': | ||
146 | buffer[index++] = '%'; | ||
147 | break; | ||
148 | case 'Y': | ||
149 | put_it_in( buffer, index, pDate.year() / 100 ); | ||
150 | case 'y': | ||
151 | put_it_in( buffer, index, pDate.year() % 100 ); | ||
152 | break; | ||
153 | case 'n': | ||
154 | number = pDate.month(); | ||
155 | case 'e': | ||
156 | // to share the code | ||
157 | if ( rst.at( format_index ).unicode() == 'e' ) | ||
158 | number = pDate.day(); | ||
159 | if ( number / 10 ) | ||
160 | buffer[index++] = number / 10 + '0'; | ||
161 | buffer[index++] = number % 10 + '0'; | ||
162 | break; | ||
163 | case 'm': | ||
164 | put_it_in( buffer, index, pDate.month() ); | ||
165 | break; | ||
166 | case 'b': | ||
167 | put_it_in( buffer, index, monthName(pDate.month(), true) ); | ||
168 | break; | ||
169 | case 'B': | ||
170 | put_it_in( buffer, index, monthName(pDate.month(), false) ); | ||
171 | break; | ||
172 | case 'd': | ||
173 | put_it_in( buffer, index, pDate.day() ); | ||
174 | break; | ||
175 | case 'a': | ||
176 | put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), true) ); | ||
177 | break; | ||
178 | case 'A': | ||
179 | put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), false) ); | ||
180 | break; | ||
181 | default: | ||
182 | buffer[index++] = rst.at( format_index ); | ||
183 | break; | ||
184 | } | ||
185 | escape = false; | ||
186 | } | ||
187 | } | ||
188 | QString ret( buffer, index ); | ||
189 | delete [] buffer; | ||
190 | return ret; | ||
191 | } | ||
192 | |||
193 | QString KLocale::formatDateTime(const QDateTime &pDateTime, | ||
194 | bool shortFormat, | ||
195 | bool includeSeconds) const | ||
196 | { | ||
197 | return i18n("concatenation of dates and time", "%1 %2") | ||
198 | .arg( formatDate( pDateTime.date(), shortFormat ) ) | ||
199 | .arg( formatTime( pDateTime.time(), includeSeconds ) ); | ||
200 | } | ||
201 | |||
202 | QString KLocale::formatDateTime(const QDateTime &pDateTime) const | ||
203 | { | ||
204 | return formatDateTime(pDateTime, true); | ||
205 | } | ||
206 | |||
207 | QDate KLocale::readDate(const QString &intstr, bool* ok) const | ||
208 | { | ||
209 | QDate date; | ||
210 | date = readDate(intstr, true, ok); | ||
211 | if (date.isValid()) return date; | ||
212 | return readDate(intstr, false, ok); | ||
213 | } | ||
214 | |||
215 | QDate KLocale::readDate(const QString &intstr, bool shortFormat, bool* ok) const | ||
216 | { | ||
217 | QString fmt = (shortFormat ? dateFormatShort() : dateFormat()).simplifyWhiteSpace(); | ||
218 | return readDate( intstr, fmt, ok ); | ||
219 | } | ||
220 | |||
221 | QDate KLocale::readDate(const QString &intstr, const QString &fmt, bool* ok) const | ||
222 | { | ||
223 | //kdDebug(173) << "KLocale::readDate intstr=" << intstr << " fmt=" << fmt << endl; | ||
224 | QString str = intstr.simplifyWhiteSpace().lower(); | ||
225 | int day = -1, month = -1; | ||
226 | // allow the year to be omitted if not in the format | ||
227 | int year = QDate::currentDate().year(); | ||
228 | uint strpos = 0; | ||
229 | uint fmtpos = 0; | ||
230 | |||
231 | while (fmt.length() > fmtpos || str.length() > strpos) | ||
232 | { | ||
233 | if ( !(fmt.length() > fmtpos && str.length() > strpos) ) | ||
234 | goto error; | ||
235 | |||
236 | QChar c = fmt.at(fmtpos++); | ||
237 | |||
238 | if (c != '%') { | ||
239 | if (c.isSpace()) | ||
240 | strpos++; | ||
241 | else if (c != str.at(strpos++)) | ||
242 | goto error; | ||
243 | continue; | ||
244 | } | ||
245 | |||
246 | // remove space at the begining | ||
247 | if (str.length() > strpos && str.at(strpos).isSpace()) | ||
248 | strpos++; | ||
249 | |||
250 | c = fmt.at(fmtpos++); | ||
251 | switch (c) | ||
252 | { | ||
253 | case 'a': | ||
254 | case 'A': | ||
255 | // this will just be ignored | ||
256 | { // Cristian Tache: porting to Win: Block added because of "j" redefinition | ||
257 | for (int j = 1; j < 8; j++) { | ||
258 | QString s = weekDayName(j, c == 'a').lower(); | ||
259 | int len = s.length(); | ||
260 | if (str.mid(strpos, len) == s) | ||
261 | strpos += len; | ||
262 | } | ||
263 | break; | ||
264 | } | ||
265 | case 'b': | ||
266 | case 'B': | ||
267 | { // Cristian Tache: porting to Win: Block added because of "j" redefinition | ||
268 | for (int j = 1; j < 13; j++) { | ||
269 | QString s = monthName(j, c == 'b').lower(); | ||
270 | int len = s.length(); | ||
271 | if (str.mid(strpos, len) == s) { | ||
272 | month = j; | ||
273 | strpos += len; | ||
274 | } | ||
275 | } | ||
276 | break; | ||
277 | } | ||
278 | case 'd': | ||
279 | case 'e': | ||
280 | day = readInt(str, strpos); | ||
281 | if (day < 1 || day > 31) | ||
282 | goto error; | ||
283 | |||
284 | break; | ||
285 | |||
286 | case 'n': | ||
287 | case 'm': | ||
288 | month = readInt(str, strpos); | ||
289 | if (month < 1 || month > 12) | ||
290 | goto error; | ||
291 | |||
292 | break; | ||
293 | |||
294 | case 'Y': | ||
295 | case 'y': | ||
296 | year = readInt(str, strpos); | ||
297 | if (year < 0) | ||
298 | goto error; | ||
299 | // Qt treats a year in the range 0-100 as 1900-1999. | ||
300 | // It is nicer for the user if we treat 0-68 as 2000-2068 | ||
301 | if (year < 69) | ||
302 | year += 2000; | ||
303 | else if (c == 'y') | ||
304 | year += 1900; | ||
305 | |||
306 | break; | ||
307 | } | ||
308 | } | ||
309 | //kdDebug(173) << "KLocale::readDate day=" << day << " month=" << month << " year=" << year << endl; | ||
310 | if ( year != -1 && month != -1 && day != -1 ) | ||
311 | { | ||
312 | if (ok) *ok = true; | ||
313 | return QDate(year, month, day); | ||
314 | } | ||
315 | error: | ||
316 | if (ok) *ok = false; | ||
317 | return QDate(); // invalid date | ||
318 | } | ||
319 | |||
320 | QTime KLocale::readTime(const QString &intstr, bool *ok) const | ||
321 | { | ||
322 | QTime _time; | ||
323 | _time = readTime(intstr, true, ok); | ||
324 | if (_time.isValid()) return _time; | ||
325 | return readTime(intstr, false, ok); | ||
326 | } | ||
327 | |||
328 | QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const | ||
329 | { | ||
330 | QString str = intstr.simplifyWhiteSpace().lower(); | ||
331 | QString Format = timeFormat().simplifyWhiteSpace(); | ||
332 | if (!seconds) | ||
333 | Format.replace(QRegExp(QString::fromLatin1(".%S")), QString::null); | ||
334 | |||
335 | int hour = -1, minute = -1, second = seconds ? -1 : 0; // don't require seconds | ||
336 | bool g_12h = false; | ||
337 | bool pm = false; | ||
338 | uint strpos = 0; | ||
339 | uint Formatpos = 0; | ||
340 | |||
341 | while (Format.length() > Formatpos || str.length() > strpos) | ||
342 | { | ||
343 | if ( !(Format.length() > Formatpos && str.length() > strpos) ) goto error; | ||
344 | |||
345 | QChar c = Format.at(Formatpos++); | ||
346 | |||
347 | if (c != '%') | ||
348 | { | ||
349 | if (c.isSpace()) | ||
350 | strpos++; | ||
351 | else if (c != str.at(strpos++)) | ||
352 | goto error; | ||
353 | continue; | ||
354 | } | ||
355 | |||
356 | // remove space at the begining | ||
357 | if (str.length() > strpos && str.at(strpos).isSpace()) | ||
358 | strpos++; | ||
359 | |||
360 | c = Format.at(Formatpos++); | ||
361 | switch (c) | ||
362 | { | ||
363 | case 'p': | ||
364 | { | ||
365 | QString s; | ||
366 | s = i18n("pm").lower(); | ||
367 | int len = s.length(); | ||
368 | if (str.mid(strpos, len) == s) | ||
369 | { | ||
370 | pm = true; | ||
371 | strpos += len; | ||
372 | } | ||
373 | else | ||
374 | { | ||
375 | s = i18n("am").lower(); | ||
376 | len = s.length(); | ||
377 | if (str.mid(strpos, len) == s) { | ||
378 | pm = false; | ||
379 | strpos += len; | ||
380 | } | ||
381 | else | ||
382 | goto error; | ||
383 | } | ||
384 | } | ||
385 | break; | ||
386 | |||
387 | case 'k': | ||
388 | case 'H': | ||
389 | g_12h = false; | ||
390 | hour = readInt(str, strpos); | ||
391 | if (hour < 0 || hour > 23) | ||
392 | goto error; | ||
393 | |||
394 | break; | ||
395 | |||
396 | case 'l': | ||
397 | case 'I': | ||
398 | g_12h = true; | ||
399 | hour = readInt(str, strpos); | ||
400 | if (hour < 1 || hour > 12) | ||
401 | goto error; | ||
402 | |||
403 | break; | ||
404 | |||
405 | case 'M': | ||
406 | minute = readInt(str, strpos); | ||
407 | if (minute < 0 || minute > 59) | ||
408 | goto error; | ||
409 | |||
410 | break; | ||
411 | |||
412 | case 'S': | ||
413 | second = readInt(str, strpos); | ||
414 | if (second < 0 || second > 59) | ||
415 | goto error; | ||
416 | |||
417 | break; | ||
418 | } | ||
419 | } | ||
420 | if (g_12h) | ||
421 | { | ||
422 | hour %= 12; | ||
423 | if (pm) hour += 12; | ||
424 | } | ||
425 | |||
426 | if (ok) *ok = true; | ||
427 | return QTime(hour, minute, second); | ||
428 | |||
429 | error: | ||
430 | if (ok) *ok = false; | ||
431 | return QTime(-1, -1, -1); // return invalid date if it didn't work | ||
432 | // This will be removed in the near future, since it gives a warning on stderr. | ||
433 | // The presence of the bool* (since KDE-3.0) removes the need for an invalid QTime. | ||
434 | } | ||
435 | |||
436 | bool KLocale::use12Clock() const | ||
437 | { | ||
438 | return false; | ||
439 | } | ||
440 | |||
441 | bool KLocale::weekStartsMonday() const | ||
442 | { | ||
443 | return true; | ||
444 | } | ||
445 | |||
446 | QString KLocale::weekDayName(int i,bool shortName) const | ||
447 | { | ||
448 | if ( shortName ) | ||
449 | switch ( i ) | ||
450 | { | ||
451 | case 1: return i18n("Monday", "Mon"); | ||
452 | case 2: return i18n("Tuesday", "Tue"); | ||
453 | case 3: return i18n("Wednesday", "Wed"); | ||
454 | case 4: return i18n("Thursday", "Thu"); | ||
455 | case 5: return i18n("Friday", "Fri"); | ||
456 | case 6: return i18n("Saturday", "Sat"); | ||
457 | case 7: return i18n("Sunday", "Sun"); | ||
458 | } | ||
459 | else | ||
460 | switch ( i ) | ||
461 | { | ||
462 | case 1: return i18n("Monday"); | ||
463 | case 2: return i18n("Tuesday"); | ||
464 | case 3: return i18n("Wednesday"); | ||
465 | case 4: return i18n("Thursday"); | ||
466 | case 5: return i18n("Friday"); | ||
467 | case 6: return i18n("Saturday"); | ||
468 | case 7: return i18n("Sunday"); | ||
469 | } | ||
470 | |||
471 | return QString::null; | ||
472 | } | ||
473 | |||
474 | QString KLocale::monthName(int i,bool shortName) const | ||
475 | { | ||
476 | if ( shortName ) | ||
477 | switch ( i ) | ||
478 | { | ||
479 | case 1: return i18n("January", "Jan"); | ||
480 | case 2: return i18n("February", "Feb"); | ||
481 | case 3: return i18n("March", "Mar"); | ||
482 | case 4: return i18n("April", "Apr"); | ||
483 | case 5: return i18n("May short", "May"); | ||
484 | case 6: return i18n("June", "Jun"); | ||
485 | case 7: return i18n("July", "Jul"); | ||
486 | case 8: return i18n("August", "Aug"); | ||
487 | case 9: return i18n("September", "Sep"); | ||
488 | case 10: return i18n("October", "Oct"); | ||
489 | case 11: return i18n("November", "Nov"); | ||
490 | case 12: return i18n("December", "Dec"); | ||
491 | } | ||
492 | else | ||
493 | switch (i) | ||
494 | { | ||
495 | case 1: return i18n("January"); | ||
496 | case 2: return i18n("February"); | ||
497 | case 3: return i18n("March"); | ||
498 | case 4: return i18n("April"); | ||
499 | case 5: return i18n("May long", "May"); | ||
500 | case 6: return i18n("June"); | ||
501 | case 7: return i18n("July"); | ||
502 | case 8: return i18n("August"); | ||
503 | case 9: return i18n("September"); | ||
504 | case 10: return i18n("October"); | ||
505 | case 11: return i18n("November"); | ||
506 | case 12: return i18n("December"); | ||
507 | } | ||
508 | |||
509 | return QString::null; | ||
510 | } | ||
511 | |||
512 | QString KLocale::country() const | ||
513 | { | ||
514 | return QString::null; | ||
515 | } | ||
516 | |||
517 | QString KLocale::dateFormat() const | ||
518 | { | ||
519 | return "%A %d %B %Y"; | ||
520 | } | ||
521 | |||
522 | QString KLocale::dateFormatShort() const | ||
523 | { | ||
524 | return "%d.%m.%Y"; | ||
525 | } | ||
526 | |||
527 | QString KLocale::timeFormat() const | ||
528 | { | ||
529 | return "%H:%M:%S"; | ||
530 | } | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/klocale.h b/noncore/apps/tinykate/libkate/microkde/klocale.h new file mode 100644 index 0000000..cff200b --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/klocale.h | |||
@@ -0,0 +1,53 @@ | |||
1 | #ifndef MINIKDE_KLOCALE_H | ||
2 | #define MINIKDE_KLOCALE_H | ||
3 | |||
4 | #include <qstring.h> | ||
5 | #include <qdatetime.h> | ||
6 | |||
7 | |||
8 | #define I18N_NOOP(x) x | ||
9 | |||
10 | |||
11 | QString i18n(const char *text); | ||
12 | QString i18n(const char *hint, const char *text); | ||
13 | |||
14 | // Qt3's uic generates i18n( "msg", "comment" ) calls which conflict | ||
15 | // with our i18n method. we use uic -tr tr2i18n to redirect | ||
16 | // to the right i18n() function | ||
17 | inline QString tr2i18n(const char* message, const char* =0) { | ||
18 | return i18n( message); | ||
19 | } | ||
20 | |||
21 | class KLocale | ||
22 | { | ||
23 | public: | ||
24 | |||
25 | QString formatDate(const QDate &pDate, bool shortFormat = false) const; | ||
26 | QString formatTime(const QTime &pTime, bool includeSecs = false) const; | ||
27 | QString formatDateTime(const QDateTime &pDateTime) const; | ||
28 | QString formatDateTime(const QDateTime &pDateTime, | ||
29 | bool shortFormat, | ||
30 | bool includeSecs = false) const; | ||
31 | |||
32 | QDate readDate(const QString &str, bool* ok = 0) const; | ||
33 | QDate readDate( const QString &intstr, const QString &fmt, bool* ok = 0) const; | ||
34 | QTime readTime(const QString &str, bool* ok = 0) const; | ||
35 | |||
36 | bool use12Clock() const; | ||
37 | bool weekStartsMonday() const; | ||
38 | |||
39 | QString weekDayName(int,bool=false) const; | ||
40 | QString monthName(int,bool=false) const; | ||
41 | |||
42 | QString country() const; | ||
43 | |||
44 | QString dateFormat() const; | ||
45 | QString dateFormatShort() const; | ||
46 | QString timeFormat() const; | ||
47 | |||
48 | private: | ||
49 | QTime readTime(const QString &str, bool seconds, bool *ok) const; | ||
50 | QDate readDate(const QString &str, bool shortFormat, bool *ok) const; | ||
51 | }; | ||
52 | |||
53 | #endif | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kmessagebox.cpp b/noncore/apps/tinykate/libkate/microkde/kmessagebox.cpp new file mode 100644 index 0000000..fd305cd --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kmessagebox.cpp | |||
@@ -0,0 +1,90 @@ | |||
1 | #include "kmessagebox.h" | ||
2 | #include "klocale.h" | ||
3 | |||
4 | #include <qmessagebox.h> | ||
5 | |||
6 | void KMessageBox::sorry( QWidget *parent, | ||
7 | const QString &text, | ||
8 | const QString &caption, bool ) | ||
9 | { | ||
10 | QString cap = caption; | ||
11 | |||
12 | if (cap.isEmpty()) { | ||
13 | cap = i18n("Sorry"); | ||
14 | } | ||
15 | |||
16 | QMessageBox::warning( parent, cap, text ); | ||
17 | } | ||
18 | |||
19 | int KMessageBox::warningYesNoCancel(QWidget *parent, const QString &text) | ||
20 | { | ||
21 | int result = QMessageBox::warning(parent,i18n("Warning"),text,QMessageBox::Yes, | ||
22 | QMessageBox::No, QMessageBox::Cancel); | ||
23 | switch (result) { | ||
24 | case QMessageBox::Yes: return Yes; | ||
25 | case QMessageBox::No: return No; | ||
26 | case QMessageBox::Cancel: return Cancel; | ||
27 | } | ||
28 | } | ||
29 | |||
30 | int KMessageBox::questionYesNo(QWidget *parent, | ||
31 | const QString &text, | ||
32 | const QString &textYes, | ||
33 | const QString &textNo, | ||
34 | bool notify=true ) | ||
35 | { | ||
36 | int result =QMessageBox::warning(parent,i18n("Question"),text,textYes,textNo); | ||
37 | if ( result == 0 ) return KMessageBox::Yes; | ||
38 | return KMessageBox::No; | ||
39 | } | ||
40 | |||
41 | |||
42 | |||
43 | |||
44 | int KMessageBox::warningContinueCancel( QWidget *parent, | ||
45 | const QString &text, | ||
46 | const QString &caption, | ||
47 | const QString &buttonContinue, | ||
48 | const QString &dontAskAgainName, | ||
49 | bool notify ) | ||
50 | { | ||
51 | QString cap = caption; | ||
52 | |||
53 | if (cap.isEmpty()) { | ||
54 | cap = i18n("Warning"); | ||
55 | } | ||
56 | |||
57 | int result = QMessageBox::warning( parent, cap, text, i18n("Ok"), | ||
58 | i18n("Cancel") ); | ||
59 | |||
60 | if ( result == 0 ) return KMessageBox::Continue; | ||
61 | return KMessageBox::Cancel; | ||
62 | } | ||
63 | |||
64 | void KMessageBox::error( QWidget *parent, | ||
65 | const QString &text, | ||
66 | const QString &caption, bool notify ) | ||
67 | { | ||
68 | QString cap = caption; | ||
69 | |||
70 | if (cap.isEmpty()) { | ||
71 | cap = i18n("Error"); | ||
72 | } | ||
73 | |||
74 | QMessageBox::critical( parent, cap, text ); | ||
75 | } | ||
76 | |||
77 | void KMessageBox::information( QWidget *parent, | ||
78 | const QString &text, | ||
79 | const QString &caption, | ||
80 | const QString &, | ||
81 | bool ) | ||
82 | { | ||
83 | QString cap = caption; | ||
84 | |||
85 | if (cap.isEmpty()) { | ||
86 | cap = i18n("Information"); | ||
87 | } | ||
88 | |||
89 | QMessageBox::information( parent, cap, text ); | ||
90 | } | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kmessagebox.h b/noncore/apps/tinykate/libkate/microkde/kmessagebox.h new file mode 100644 index 0000000..d7c971f --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kmessagebox.h | |||
@@ -0,0 +1,46 @@ | |||
1 | #ifndef MINIKDE_KMESSAGEBOX_H | ||
2 | #define MINIKDE_KMESSAGEBOX_H | ||
3 | |||
4 | #include <qstring.h> | ||
5 | |||
6 | class QWidget; | ||
7 | |||
8 | class KMessageBox | ||
9 | { | ||
10 | public: | ||
11 | enum { Ok = 1, Cancel = 2, Yes = 3, No = 4, Continue = 5 }; | ||
12 | |||
13 | static void sorry(QWidget *parent, | ||
14 | const QString &text, | ||
15 | const QString &caption = QString::null, bool notify=true); | ||
16 | |||
17 | static int warningContinueCancel(QWidget *parent, | ||
18 | const QString &text, | ||
19 | const QString &caption = QString::null, | ||
20 | const QString &buttonContinue = QString::null, | ||
21 | const QString &dontAskAgainName = QString::null, | ||
22 | bool notify=true ); | ||
23 | |||
24 | |||
25 | static int questionYesNo(QWidget *parent, | ||
26 | const QString &text, | ||
27 | const QString &textYes, | ||
28 | const QString &textNo, | ||
29 | bool notify=true ); | ||
30 | |||
31 | static int warningYesNoCancel(QWidget *parent, const QString &text); | ||
32 | |||
33 | |||
34 | static void error(QWidget *parent, | ||
35 | const QString &text, | ||
36 | const QString &caption = QString::null, bool notify=true); | ||
37 | |||
38 | static void information(QWidget *parent, | ||
39 | const QString &text, | ||
40 | const QString &caption = QString::null, | ||
41 | const QString &dontShowAgainName = QString::null, | ||
42 | bool notify=true); | ||
43 | }; | ||
44 | |||
45 | |||
46 | #endif | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/knotifyclient.h b/noncore/apps/tinykate/libkate/microkde/knotifyclient.h new file mode 100644 index 0000000..118026a --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/knotifyclient.h | |||
@@ -0,0 +1,14 @@ | |||
1 | #ifndef MINIKDE_KNOTIFYCLIENT_H | ||
2 | #define MINIKDE_KNOTIFYCLIENT_H | ||
3 | |||
4 | #include <qstring.h> | ||
5 | |||
6 | class KNotifyClient | ||
7 | { | ||
8 | public: | ||
9 | |||
10 | static void beep() {} | ||
11 | static void beep( const QString & ) {} | ||
12 | }; | ||
13 | |||
14 | #endif | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/knumvalidator.cpp b/noncore/apps/tinykate/libkate/microkde/knumvalidator.cpp new file mode 100644 index 0000000..67e632f --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/knumvalidator.cpp | |||
@@ -0,0 +1,8 @@ | |||
1 | #include <qlineedit.h> | ||
2 | |||
3 | #include "knumvalidator.h" | ||
4 | |||
5 | KIntValidator::KIntValidator( int a, int b, QLineEdit *c ) | ||
6 | : QIntValidator( a, b, c ) | ||
7 | { | ||
8 | } | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/knumvalidator.h b/noncore/apps/tinykate/libkate/microkde/knumvalidator.h new file mode 100644 index 0000000..92eda01 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/knumvalidator.h | |||
@@ -0,0 +1,14 @@ | |||
1 | #ifndef MINIKDE_KNUMVALIDATOR_H | ||
2 | #define MINIKDE_KNUMVALIDATOR_H | ||
3 | |||
4 | #include <qvalidator.h> | ||
5 | |||
6 | class QLineEdit; | ||
7 | |||
8 | class KIntValidator : public QIntValidator | ||
9 | { | ||
10 | public: | ||
11 | KIntValidator( int, int, QLineEdit * ); | ||
12 | }; | ||
13 | |||
14 | #endif | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kpopupmenu.h b/noncore/apps/tinykate/libkate/microkde/kpopupmenu.h new file mode 100644 index 0000000..fb35943 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kpopupmenu.h | |||
@@ -0,0 +1,8 @@ | |||
1 | #ifndef _MYKPOPUPMENU_H_ | ||
2 | #define _MYKPOPUPMENU_H_ | ||
3 | |||
4 | #include <qpopupmenu.h> | ||
5 | |||
6 | #define KPopupMenu QPopupMenu | ||
7 | |||
8 | #endif | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kprinter.h b/noncore/apps/tinykate/libkate/microkde/kprinter.h new file mode 100644 index 0000000..b99d689 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kprinter.h | |||
@@ -0,0 +1,8 @@ | |||
1 | #ifndef MINIKDE_KPRINTER_H | ||
2 | #define MINIKDE_KPRINTER_H | ||
3 | |||
4 | #include <qprinter.h> | ||
5 | |||
6 | #define KPrinter QPrinter | ||
7 | |||
8 | #endif | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kprocess.cpp b/noncore/apps/tinykate/libkate/microkde/kprocess.cpp new file mode 100644 index 0000000..62033e9 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kprocess.cpp | |||
@@ -0,0 +1,15 @@ | |||
1 | #include "kprocess.h" | ||
2 | |||
3 | void KProcess::clearArguments() | ||
4 | { | ||
5 | } | ||
6 | |||
7 | KProcess & KProcess::operator<<( const QString & ) | ||
8 | { | ||
9 | return *this; | ||
10 | } | ||
11 | |||
12 | bool KProcess::start() | ||
13 | { | ||
14 | return false; | ||
15 | } | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kprocess.h b/noncore/apps/tinykate/libkate/microkde/kprocess.h new file mode 100644 index 0000000..96dce54 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kprocess.h | |||
@@ -0,0 +1,16 @@ | |||
1 | #ifndef MINIKDE_KPROCESS_H | ||
2 | #define MINIKDE_KPROCESS_H | ||
3 | |||
4 | #include <qobject.h> | ||
5 | |||
6 | class KProcess : public QObject | ||
7 | { | ||
8 | public: | ||
9 | void clearArguments(); | ||
10 | |||
11 | KProcess & operator<<( const QString & ); | ||
12 | |||
13 | bool start(); | ||
14 | }; | ||
15 | |||
16 | #endif | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/krestrictedline.h b/noncore/apps/tinykate/libkate/microkde/krestrictedline.h new file mode 100644 index 0000000..200546c --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/krestrictedline.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef MINIKDE_KRESTRICTEDLINE_H | ||
2 | #define MINIKDE_KRESTRICTEDLINE_H | ||
3 | |||
4 | #include "klineedit.h" | ||
5 | |||
6 | class KRestrictedLine : public KLineEdit | ||
7 | { | ||
8 | public: | ||
9 | KRestrictedLine( QWidget *parent, const char *, const QString & ) : | ||
10 | KLineEdit( parent ) {} | ||
11 | }; | ||
12 | |||
13 | #endif | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/krun.cpp b/noncore/apps/tinykate/libkate/microkde/krun.cpp new file mode 100644 index 0000000..a170add --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/krun.cpp | |||
@@ -0,0 +1,6 @@ | |||
1 | #include "krun.h" | ||
2 | |||
3 | bool KRun::runCommand(const QString &, const QString &, const QString &) | ||
4 | { | ||
5 | return false; | ||
6 | } | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/krun.h b/noncore/apps/tinykate/libkate/microkde/krun.h new file mode 100644 index 0000000..1b63cb7 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/krun.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef MINIKDE_KRUN_H | ||
2 | #define MINIKDE_KRUN_H | ||
3 | |||
4 | #include <qstring.h> | ||
5 | |||
6 | class KRun | ||
7 | { | ||
8 | public: | ||
9 | static bool runCommand(const QString &a, const QString &b=QString::null, | ||
10 | const QString &c=QString::null); | ||
11 | }; | ||
12 | |||
13 | #endif | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kseparator.h b/noncore/apps/tinykate/libkate/microkde/kseparator.h new file mode 100644 index 0000000..9fc0b51 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kseparator.h | |||
@@ -0,0 +1,8 @@ | |||
1 | #ifndef MINIKDE_KSEPARATOR_H | ||
2 | #define MINIKDE_KSEPARATOR_H | ||
3 | |||
4 | class KSeparator | ||
5 | { | ||
6 | }; | ||
7 | |||
8 | #endif | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/ksharedptr.h b/noncore/apps/tinykate/libkate/microkde/ksharedptr.h new file mode 100644 index 0000000..55ed2e9 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/ksharedptr.h | |||
@@ -0,0 +1,142 @@ | |||
1 | /* This file is part of the KDE libraries | ||
2 | Copyright (c) 1999 Waldo Bastian <bastian@kde.org> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Library General Public | ||
6 | License version 2 as published by the Free Software Foundation. | ||
7 | |||
8 | This library is distributed in the hope that it will be useful, | ||
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
11 | Library General Public License for more details. | ||
12 | |||
13 | You should have received a copy of the GNU Library General Public License | ||
14 | along with this library; see the file COPYING.LIB. If not, write to | ||
15 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
16 | Boston, MA 02111-1307, USA. | ||
17 | */ | ||
18 | #ifndef KSharedPTR_H | ||
19 | #define KSharedPTR_H | ||
20 | |||
21 | /** | ||
22 | * Reference counting for shared objects. If you derive your object | ||
23 | * from this class, then you may use it in conjunction with | ||
24 | * @ref KSharedPtr to control the lifetime of your object. | ||
25 | * | ||
26 | * Specifically, all classes that derive from KShared have an internal | ||
27 | * counter keeping track of how many other objects have a reference to | ||
28 | * their object. If used with @ref KSharedPtr, then your object will | ||
29 | * not be deleted until all references to the object have been | ||
30 | * released. | ||
31 | * | ||
32 | * You should probably not ever use any of the methods in this class | ||
33 | * directly -- let the @ref KSharedPtr take care of that. Just derive | ||
34 | * your class from KShared and forget about it. | ||
35 | * | ||
36 | * @author Waldo Bastian <bastian@kde.org> | ||
37 | * @version $Id$ | ||
38 | */ | ||
39 | class KShared { | ||
40 | public: | ||
41 | /** | ||
42 | * Standard constructor. This will initialize the reference count | ||
43 | * on this object to 0 | ||
44 | */ | ||
45 | KShared() : count(0) { } | ||
46 | |||
47 | /** | ||
48 | * Copy constructor. This will @em not actually copy the objects | ||
49 | * but it will initialize the reference count on this object to 0 | ||
50 | */ | ||
51 | KShared( const KShared & ) : count(0) { } | ||
52 | |||
53 | /** | ||
54 | * Overloaded assignment operator | ||
55 | */ | ||
56 | KShared &operator=(const KShared & ) { return *this; } | ||
57 | |||
58 | /** | ||
59 | * Increases the reference count by one | ||
60 | */ | ||
61 | void _KShared_ref() { count++; } | ||
62 | |||
63 | /** | ||
64 | * Releases a reference (decreases the reference count by one). If | ||
65 | * the count goes to 0, this object will delete itself | ||
66 | */ | ||
67 | void _KShared_unref() { if (!--count) delete this; } | ||
68 | |||
69 | /** | ||
70 | * Return the current number of references held | ||
71 | * | ||
72 | * @return Number of references | ||
73 | */ | ||
74 | int _KShared_count() { return count; } | ||
75 | |||
76 | protected: | ||
77 | virtual ~KShared() { } | ||
78 | int count; // ### KDE 3.0: rename to something like _KShared_count | ||
79 | // or make private | ||
80 | }; | ||
81 | |||
82 | /** | ||
83 | * Can be used to control the lifetime of an object that has derived | ||
84 | * @ref KShared. As long a someone holds a KSharedPtr on some KShared | ||
85 | * object it won't become deleted but is deleted once its reference | ||
86 | * count is 0. This struct emulates C++ pointers perfectly. So just | ||
87 | * use it like a simple C++ pointer. | ||
88 | * | ||
89 | * KShared and KSharedPtr are preferred over QShared / QSharedPtr | ||
90 | * since they are more safe. | ||
91 | * | ||
92 | * @author Waldo Bastian <bastian@kde.org> | ||
93 | * @version $Id$ | ||
94 | */ | ||
95 | template< class T > | ||
96 | struct KSharedPtr | ||
97 | { | ||
98 | public: | ||
99 | KSharedPtr() | ||
100 | : ptr(0) { } | ||
101 | KSharedPtr( T* t ) | ||
102 | : ptr(t) { if ( ptr ) ptr->_KShared_ref(); } | ||
103 | KSharedPtr( const KSharedPtr& p ) | ||
104 | : ptr(p.ptr) { if ( ptr ) ptr->_KShared_ref(); } | ||
105 | |||
106 | ~KSharedPtr() { if ( ptr ) ptr->_KShared_unref(); } | ||
107 | |||
108 | KSharedPtr<T>& operator= ( const KSharedPtr<T>& p ) { | ||
109 | if ( ptr == p.ptr ) return *this; | ||
110 | if ( ptr ) ptr->_KShared_unref(); | ||
111 | ptr = p.ptr; | ||
112 | if ( ptr ) ptr->_KShared_ref(); | ||
113 | return *this; | ||
114 | } | ||
115 | KSharedPtr<T>& operator= ( T* p ) { | ||
116 | if ( ptr == p ) return *this; | ||
117 | if ( ptr ) ptr->_KShared_unref(); | ||
118 | ptr = p; | ||
119 | if ( ptr ) ptr->_KShared_ref(); | ||
120 | return *this; | ||
121 | } | ||
122 | bool operator== ( const KSharedPtr<T>& p ) const { return ( ptr == p.ptr ); } | ||
123 | bool operator!= ( const KSharedPtr<T>& p ) const { return ( ptr != p.ptr ); } | ||
124 | bool operator== ( const T* p ) const { return ( ptr == p ); } | ||
125 | bool operator!= ( const T* p ) const { return ( ptr != p ); } | ||
126 | bool operator!() const { return ( ptr == 0 ); } | ||
127 | operator T*() const { return ptr; } | ||
128 | |||
129 | T* data() { return ptr; } | ||
130 | const T* data() const { return ptr; } | ||
131 | |||
132 | const T& operator*() const { return *ptr; } | ||
133 | T& operator*() { return *ptr; } | ||
134 | const T* operator->() const { return ptr; } | ||
135 | T* operator->() { return ptr; } | ||
136 | |||
137 | int count() const { return ptr->_KShared_count(); } // for debugging purposes | ||
138 | private: | ||
139 | T* ptr; | ||
140 | }; | ||
141 | |||
142 | #endif | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/ksimpleconfig.h b/noncore/apps/tinykate/libkate/microkde/ksimpleconfig.h new file mode 100644 index 0000000..1efd982 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/ksimpleconfig.h | |||
@@ -0,0 +1,12 @@ | |||
1 | #ifndef MINIKDE_KSIMPLECONFIG_H | ||
2 | #define MINIKDE_KSIMPLECONFIG_H | ||
3 | |||
4 | #include "kconfig.h" | ||
5 | |||
6 | class KSimpleConfig : public KConfig | ||
7 | { | ||
8 | public: | ||
9 | KSimpleConfig( const QString &file ) : KConfig( file ) {} | ||
10 | }; | ||
11 | |||
12 | #endif | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kstandarddirs.cpp b/noncore/apps/tinykate/libkate/microkde/kstandarddirs.cpp new file mode 100644 index 0000000..befa667 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kstandarddirs.cpp | |||
@@ -0,0 +1,39 @@ | |||
1 | #include "kdebug.h" | ||
2 | |||
3 | #include "kstandarddirs.h" | ||
4 | |||
5 | QString KStandardDirs::mAppDir = QString::null; | ||
6 | |||
7 | QString locate( const char *type, const QString& filename ) | ||
8 | { | ||
9 | QString path = KStandardDirs::appDir() + type + "_" + filename; | ||
10 | |||
11 | kdDebug() << "locate: '" << path << "'" << endl; | ||
12 | |||
13 | return path; | ||
14 | } | ||
15 | |||
16 | QString locateLocal( const char *type, const QString& filename ) | ||
17 | { | ||
18 | return locate( type, filename ); | ||
19 | } | ||
20 | |||
21 | QStringList KStandardDirs::findAllResources( const QString &, const QString &, bool, bool) | ||
22 | { | ||
23 | QStringList list; | ||
24 | list.append("/cpp.xml"); | ||
25 | return list; | ||
26 | // return QStringList(); | ||
27 | } | ||
28 | |||
29 | QString KStandardDirs::findResourceDir( const QString &, const QString & ) | ||
30 | { | ||
31 | return QString::null; | ||
32 | } | ||
33 | |||
34 | void KStandardDirs::setAppDir( const QString &appDir ) | ||
35 | { | ||
36 | mAppDir = appDir; | ||
37 | |||
38 | if ( mAppDir.right( 1 ) != "/" ) mAppDir += "/"; | ||
39 | } | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kstandarddirs.h b/noncore/apps/tinykate/libkate/microkde/kstandarddirs.h new file mode 100644 index 0000000..fa5e460 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kstandarddirs.h | |||
@@ -0,0 +1,23 @@ | |||
1 | #ifndef MINIKDE_KSTANDARDDIRS_H | ||
2 | #define MINIKDE_KSTANDARDDIRS_H | ||
3 | |||
4 | #include <qstring.h> | ||
5 | #include <qstringlist.h> | ||
6 | |||
7 | QString locate( const char *type, const QString& filename ); | ||
8 | QString locateLocal( const char *type, const QString& filename ); | ||
9 | |||
10 | class KStandardDirs | ||
11 | { | ||
12 | public: | ||
13 | QStringList findAllResources( const QString &, const QString &, bool, bool); | ||
14 | QString findResourceDir( const QString &, const QString & ); | ||
15 | |||
16 | static void setAppDir( const QString & ); | ||
17 | static QString appDir() { return mAppDir; } | ||
18 | |||
19 | private: | ||
20 | static QString mAppDir; | ||
21 | }; | ||
22 | |||
23 | #endif | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kstaticdeleter.h b/noncore/apps/tinykate/libkate/microkde/kstaticdeleter.h new file mode 100644 index 0000000..190f3e4 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kstaticdeleter.h | |||
@@ -0,0 +1,35 @@ | |||
1 | /* | ||
2 | * This file is part of the KDE Libraries | ||
3 | * Copyright (C) 2000 Stephan Kulow <coolo@kde.org> | ||
4 | * 2001 KDE Team | ||
5 | * | ||
6 | * This library is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU Library General Public | ||
8 | * License as published by the Free Software Foundation; either | ||
9 | * version 2 of the License, or (at your option) any later version. | ||
10 | * | ||
11 | * This library is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * Library General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU Library General Public License | ||
17 | * along with this library; see the file COPYING.LIB. If not, write to | ||
18 | * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
19 | * Boston, MA 02111-1307, USA. | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #ifndef _KSTATIC_DELETER_H_ | ||
24 | #define _KSTATIC_DELETER_H_ | ||
25 | |||
26 | template<class type> | ||
27 | class KStaticDeleter | ||
28 | { | ||
29 | public: | ||
30 | KStaticDeleter() {}; | ||
31 | type *setObject( type *obj, bool isArray = false) { return obj; } | ||
32 | virtual ~KStaticDeleter() {}; | ||
33 | }; | ||
34 | |||
35 | #endif | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kstddirs.h b/noncore/apps/tinykate/libkate/microkde/kstddirs.h new file mode 100644 index 0000000..fa5e460 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kstddirs.h | |||
@@ -0,0 +1,23 @@ | |||
1 | #ifndef MINIKDE_KSTANDARDDIRS_H | ||
2 | #define MINIKDE_KSTANDARDDIRS_H | ||
3 | |||
4 | #include <qstring.h> | ||
5 | #include <qstringlist.h> | ||
6 | |||
7 | QString locate( const char *type, const QString& filename ); | ||
8 | QString locateLocal( const char *type, const QString& filename ); | ||
9 | |||
10 | class KStandardDirs | ||
11 | { | ||
12 | public: | ||
13 | QStringList findAllResources( const QString &, const QString &, bool, bool); | ||
14 | QString findResourceDir( const QString &, const QString & ); | ||
15 | |||
16 | static void setAppDir( const QString & ); | ||
17 | static QString appDir() { return mAppDir; } | ||
18 | |||
19 | private: | ||
20 | static QString mAppDir; | ||
21 | }; | ||
22 | |||
23 | #endif | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/ktempfile.cpp b/noncore/apps/tinykate/libkate/microkde/ktempfile.cpp new file mode 100644 index 0000000..b9166bd --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/ktempfile.cpp | |||
@@ -0,0 +1,25 @@ | |||
1 | #include <qtextstream.h> | ||
2 | |||
3 | #include "ktempfile.h" | ||
4 | |||
5 | KTempFile::KTempFile() | ||
6 | { | ||
7 | } | ||
8 | |||
9 | KTempFile::KTempFile( const QString &filename, const QString &extension ) | ||
10 | { | ||
11 | } | ||
12 | |||
13 | void KTempFile::setAutoDelete( bool ) | ||
14 | { | ||
15 | } | ||
16 | |||
17 | QString KTempFile::name() | ||
18 | { | ||
19 | return QString::null; | ||
20 | } | ||
21 | |||
22 | QTextStream *KTempFile::textStream() | ||
23 | { | ||
24 | return 0; | ||
25 | } | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/ktempfile.h b/noncore/apps/tinykate/libkate/microkde/ktempfile.h new file mode 100644 index 0000000..20dfa82 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/ktempfile.h | |||
@@ -0,0 +1,20 @@ | |||
1 | #ifndef MINIKDE_KTEMPFILE_H | ||
2 | #define MINIKDE_KTEMPFILE_H | ||
3 | |||
4 | #include <qstring.h> | ||
5 | |||
6 | class QTextStream; | ||
7 | |||
8 | class KTempFile | ||
9 | { | ||
10 | public: | ||
11 | KTempFile(); | ||
12 | KTempFile( const QString &filename, const QString &extension ); | ||
13 | |||
14 | void setAutoDelete( bool ); | ||
15 | QString name(); | ||
16 | |||
17 | QTextStream *textStream(); | ||
18 | }; | ||
19 | |||
20 | #endif | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kunload.h b/noncore/apps/tinykate/libkate/microkde/kunload.h new file mode 100644 index 0000000..1c3d00f --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kunload.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef MINIKDE_KUNLOAD_H | ||
2 | #define MINIKDE_KUNLOAD_H | ||
3 | |||
4 | #define _UNLOAD(p) | ||
5 | |||
6 | #endif | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kurlrequester.cpp b/noncore/apps/tinykate/libkate/microkde/kurlrequester.cpp new file mode 100644 index 0000000..29d173b --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kurlrequester.cpp | |||
@@ -0,0 +1,14 @@ | |||
1 | #include "klineedit.h" | ||
2 | |||
3 | #include "kurlrequester.h" | ||
4 | |||
5 | KURLRequester::KURLRequester( QWidget *parent ) : | ||
6 | QWidget( parent ) | ||
7 | { | ||
8 | mLineEdit = new KLineEdit( parent ); | ||
9 | } | ||
10 | |||
11 | KLineEdit *KURLRequester::lineEdit() | ||
12 | { | ||
13 | return mLineEdit; | ||
14 | } | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kurlrequester.h b/noncore/apps/tinykate/libkate/microkde/kurlrequester.h new file mode 100644 index 0000000..8b39196 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/microkde/kurlrequester.h | |||
@@ -0,0 +1,17 @@ | |||
1 | #ifndef MINIKDE_KURLREQUESTER_H | ||
2 | #define MINIKDE_KURLREQUESTER_H | ||
3 | |||
4 | class KLineEdit; | ||
5 | |||
6 | class KURLRequester : public QWidget | ||
7 | { | ||
8 | public: | ||
9 | KURLRequester( QWidget *parent ); | ||
10 | |||
11 | KLineEdit *lineEdit(); | ||
12 | |||
13 | private: | ||
14 | KLineEdit *mLineEdit; | ||
15 | }; | ||
16 | |||
17 | #endif | ||