author | jowenn <jowenn> | 2002-11-10 21:08:01 (UTC) |
---|---|---|
committer | jowenn <jowenn> | 2002-11-10 21:08:01 (UTC) |
commit | e97a6da57804aa14907dec327fbae71bff9b383e (patch) (side-by-side diff) | |
tree | 15f6ee292dba24bdda72f5c72f6d2224c3516763 /noncore/apps/tinykate/libkate/microkde | |
parent | 7c012ee8cd16d8befacc6f6750711443fac0fd5e (diff) | |
download | opie-e97a6da57804aa14907dec327fbae71bff9b383e.zip opie-e97a6da57804aa14907dec327fbae71bff9b383e.tar.gz opie-e97a6da57804aa14907dec327fbae71bff9b383e.tar.bz2 |
import of tiny kate. (saving not possible yet)
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 @@ +#ifndef MINIKDE_KACTION_H +#define MINIKDE_KACTION_H + +#include <qaction.h> + +#define KAction QAction + +#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 @@ +#include <stdlib.h> + +#include "kapplication.h" + +int KApplication::random() +{ + return rand(); +} 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 @@ +#ifndef MINIKDE_KAPPLICATION_H +#define MINIKDE_KAPPLICATION_H + +class KApplication +{ + public: + static int random(); + static int cursorFlashTime() { return 1000; } +}; + +#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 @@ +/* This file is part of the KDE libraries + Copyright (C) 1997 Martin Jones (mjones@kde.org) + Copyright (C) 1999 Cristian Tibirna (ctibirna@kde.org) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#include <qdialog.h> +#include <qpainter.h> +#include <qdrawutil.h> +#include <qapplication.h> +#include <kglobalsettings.h> +#include "kcolordialog.h" +#include "kcolorbtn.h" + +KColorButton::KColorButton( QWidget *parent, const char *name ) + : QPushButton( parent, name ), dragFlag(false) +{ + // 2000-10-15 (putzer): fixes broken keyboard usage + connect (this, SIGNAL(clicked()), this, SLOT(chooseColor())); +} + +KColorButton::KColorButton( const QColor &c, QWidget *parent, + const char *name ) + : QPushButton( parent, name ), col(c), dragFlag(false) +{ + + // 2000-10-15 (putzer): fixes broken keyboard usage + connect (this, SIGNAL(clicked()), this, SLOT(chooseColor())); +} + +void KColorButton::setColor( const QColor &c ) +{ + col = c; + repaint( false ); +} + +void KColorButton::drawButtonLabel( QPainter *painter ) +{ + QRect r = QApplication::style().buttonRect( 0, 0, width(), height() ); + int l = r.x(); + int t = r.y(); + int w = r.width(); + int h = r.height(); + int b = 5; + + QColor lnCol = colorGroup().text(); + QColor fillCol = isEnabled() ? col : backgroundColor(); + + if ( isDown() ) { + qDrawPlainRect( painter, l+b+1, t+b+1, w-b*2, h-b*2, lnCol, 1, 0 ); + b++; + painter->fillRect( l+b+1, t+b+1, w-b*2, h-b*2, fillCol ); + } else { + qDrawPlainRect( painter, l+b, t+b, w-b*2, h-b*2, lnCol, 1, 0 ); + b++; + painter->fillRect( l+b, t+b, w-b*2, h-b*2, fillCol ); + } +} + +void KColorButton::chooseColor() +{ + if( KColorDialog::getColor( col) == QDialog::Rejected ) + { + return; + } + + repaint( false ); + emit changed( col ); +} + 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 @@ +/* This file is part of the KDE libraries + Copyright (C) 1997 Martin Jones (mjones@kde.org) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef __COLBTN_H__ +#define __COLBTN_H__ + +#include <qpushbutton.h> + +/** +* This widget can be used to display or allow user selection of a colour. +* +* @see KColorDialog +* +* @short A pushbutton to display or allow user selection of a colour. +* @version $Id$ +*/ +class KColorButton : public QPushButton +{ + Q_OBJECT + Q_PROPERTY( QColor color READ color WRITE setColor ) + +public: + /** + * Constructor. Create a KColorButton. + */ + KColorButton( QWidget *parent, const char *name = 0L ); + /** + * Constructor. Create a KColorButton. + * @param c The initial colour of the button. + */ + KColorButton( const QColor &c, QWidget *parent, const char *name = 0L ); + /** + * Destructor. + */ + virtual ~KColorButton() {} + + /** + * The current colour. + * @return The current colour. + */ + QColor color() const + { return col; } + /** + * Set the current colour. + * + * @param c The colour to set. + */ + void setColor( const QColor &c ); + +signals: + /** + * This signal will be emitted when the colour of the widget + * is changed, either with @ref #setColor() or via user selection. + */ + void changed( const QColor &newColor ); + +protected slots: + void chooseColor(); + +protected: + /** + * @reimplemented + */ + virtual void drawButtonLabel( QPainter *p ); + +private: + QColor col; + QPoint mPos; + bool dragFlag; + + class KColorButtonPrivate; + KColorButtonPrivate *d; +}; + +#endif + 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 @@ +#ifndef K_COLOR_BUTTON_H +#define K_COLOR_BUTTON_H +#include <kcolorbtn.h> +#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 @@ +#include "kcolordialog.h" + +int KColorDialog::getColor( const QColor & ) +{ + return 0; +} 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 @@ +#ifndef MINIKDE_KCOLORDIALOG_H +#define MINIKDE_KCOLORDIALOG_H + +#include <qcolor.h> + +class KColorDialog +{ + public: + enum { Accepted }; + + static int getColor( const QColor & ); +}; + +#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 @@ +#include <qfile.h> +#include <qtextstream.h> + +#include "kdebug.h" + +#include "kconfig.h" + +QString KConfig::mGroup = ""; +//QString KConfig::mGroup = "General"; + +KConfig::KConfig( const QString &fileName ) + : mFileName( fileName ), mDirty( false ) +{ + kdDebug() << "KConfig::KConfig(): '" << fileName << "'" << endl; + + load(); +} + + +KConfig::~KConfig() +{ + sync(); +} + +void KConfig::setGroup( const QString &group ) +{ + return; + +// kdDebug() << "KConfig::setGroup(): '" << group << "'" << endl; + + mGroup = group; + + if ( mGroup.right( 1 ) != "/" ) mGroup += "/"; +} + + +QValueList<int> KConfig::readIntListEntry( const QString & ) +{ + QValueList<int> l; + return l; +} + +int KConfig::readNumEntry( const QString &, int def ) +{ + return def; +} + +QString KConfig::readEntry( const QString &key, const QString &def ) +{ + QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key ); + + if ( it == mStringMap.end() ) { + return def; + } + + return *it; +} + +QStringList KConfig::readListEntry( const QString & ) +{ + return QStringList(); +} + +bool KConfig::readBoolEntry( const QString &key, bool def ) +{ + QMap<QString,bool>::ConstIterator it = mBoolMap.find( mGroup + key ); + + if ( it == mBoolMap.end() ) { + return def; + } + + return *it; +} + +QColor KConfig::readColorEntry( const QString &, QColor *def ) +{ + if ( def ) return *def; + return QColor(); +} + +QFont KConfig::readFontEntry( const QString &, QFont *def ) +{ + if ( def ) return *def; + return QFont(); +} + + +void KConfig::writeEntry( const QString &, QValueList<int> ) +{ +} + +void KConfig::writeEntry( const QString &, int ) +{ +} + +void KConfig::writeEntry( const QString &key, const QString &value ) +{ + mStringMap.insert( mGroup + key, value ); + + mDirty = true; +} + +void KConfig::writeEntry( const QString &, const QStringList & ) +{ +} + +void KConfig::writeEntry( const QString &key, bool value) +{ + mBoolMap.insert( mGroup + key, value ); + + mDirty = true; +} + +void KConfig::writeEntry( const QString &, const QColor & ) +{ +} + +void KConfig::writeEntry( const QString &, const QFont & ) +{ +} + +void KConfig::load() +{ + mBoolMap.clear(); + mStringMap.clear(); + + QFile f( mFileName ); + if ( !f.open( IO_ReadOnly ) ) { + kdDebug() << "KConfig::load(): Can't open file '" << mFileName << "'" + << endl; + return; + } + + + QTextStream t( &f ); + + QString line = t.readLine(); + + while ( !line.isNull() ) { + QStringList tokens = QStringList::split( ",", line ); + if ( tokens[0] == "bool" ) { + bool value = false; + if ( tokens[2] == "1" ) value = true; + + mBoolMap.insert( tokens[1], value ); + } else if ( tokens[0] == "QString" ) { + QString value = tokens[2]; + mStringMap.insert( tokens[1], value ); + } + + line = t.readLine(); + } +} + +void KConfig::sync() +{ + if ( !mDirty ) return; + + QFile f( mFileName ); + if ( !f.open( IO_WriteOnly ) ) { + kdDebug() << "KConfig::sync(): Can't open file '" << mFileName << "'" + << endl; + return; + } + + QTextStream t( &f ); + + QMap<QString,bool>::ConstIterator itBool; + for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) { + t << "bool," << itBool.key() << "," << (*itBool ) << endl; + } + + QMap<QString,QString>::ConstIterator itString; + for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) { + t << "QString," << itString.key() << "," << (*itString ) << endl; + } + + f.close(); + + mDirty = false; +} 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 @@ +#ifndef MINIKDE_KCONFIG_H +#define MINIKDE_KCONFIG_H + +#include <qstring.h> +#include <qstringlist.h> +#include <qvaluelist.h> +#include <qcolor.h> +#include <qfont.h> +#include <qmap.h> + +class KConfig +{ + public: + KConfig( const QString & ); + ~KConfig(); + + void setGroup( const QString & ); + + bool hasGroup( const QString &) {return false;} + + QValueList<int> readIntListEntry( const QString & ); + int readNumEntry( const QString &, int def=0 ); + QString readEntry( const QString &, const QString &def=QString::null ); + QStringList readListEntry( const QString & ); + bool readBoolEntry( const QString &, bool def=false ); + QColor readColorEntry( const QString &, QColor * ); + QFont readFontEntry( const QString &, QFont * ); + + void writeEntry( const QString &, QValueList<int> ); + void writeEntry( const QString &, int ); + void writeEntry( const QString &, const QString & ); + void writeEntry( const QString &, const QStringList & ); + void writeEntry( const QString &, bool ); + void writeEntry( const QString &, const QColor & ); + void writeEntry( const QString &, const QFont & ); + + void load(); + void sync(); + + private: + static QString mGroup; + + QString mFileName; + + QMap<QString,bool> mBoolMap; + QMap<QString,QString> mStringMap; + + bool mDirty; +}; + +#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 @@ +/* -*- C++ -*- + This file is part of the KDE libraries + Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) + (C) 1998-2001 Mirko Boehm (mirko@kde.org) + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#include "kdatepicker.h" +#include <kglobal.h> +#include <kapplication.h> +#include <klocale.h> +#include <kiconloader.h> +#include <qframe.h> +#include <qpainter.h> +#include <qdialog.h> +#include <qtoolbutton.h> +#include <qfont.h> +#include <qlineedit.h> +#include <qvalidator.h> +#include <kdebug.h> +#include <knotifyclient.h> +#include "kdatetbl.h" +#include "kdatepicker.moc" + + +KDatePicker::KDatePicker(QWidget *parent, QDate dt, const char *name) + : QFrame(parent,name), + yearForward(new QToolButton(this)), + yearBackward(new QToolButton(this)), + monthForward(new QToolButton(this)), + monthBackward(new QToolButton(this)), + selectMonth(new QToolButton(this)), + selectYear(new QToolButton(this)), + line(new QLineEdit(this)), + val(new KDateValidator(this)), + table(new KDateTable(this)), + fontsize(10) +{ + // ----- + setFontSize(10); + line->setValidator(val); + yearForward->setPixmap(BarIcon(QString::fromLatin1("2rightarrow"))); + yearBackward->setPixmap(BarIcon(QString::fromLatin1("2leftarrow"))); + monthForward->setPixmap(BarIcon(QString::fromLatin1("1rightarrow"))); + monthBackward->setPixmap(BarIcon(QString::fromLatin1("1leftarrow"))); + setDate(dt); // set button texts + connect(table, SIGNAL(dateChanged(QDate)), SLOT(dateChangedSlot(QDate))); + connect(table, SIGNAL(tableClicked()), SLOT(tableClickedSlot())); + connect(monthForward, SIGNAL(clicked()), SLOT(monthForwardClicked())); + connect(monthBackward, SIGNAL(clicked()), SLOT(monthBackwardClicked())); + connect(yearForward, SIGNAL(clicked()), SLOT(yearForwardClicked())); + connect(yearBackward, SIGNAL(clicked()), SLOT(yearBackwardClicked())); + connect(selectMonth, SIGNAL(clicked()), SLOT(selectMonthClicked())); + connect(selectYear, SIGNAL(clicked()), SLOT(selectYearClicked())); + connect(line, SIGNAL(returnPressed()), SLOT(lineEnterPressed())); +} + +KDatePicker::~KDatePicker() +{ +} + +void +KDatePicker::resizeEvent(QResizeEvent*) +{ + QWidget *buttons[] = { + yearBackward, + monthBackward, + selectMonth, + selectYear, + monthForward, + yearForward }; + const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]); + QSize sizes[NoOfButtons]; + int buttonHeight=0; + int count; + int w; + int x=0; + // ----- calculate button row height: + for(count=0; count<NoOfButtons; ++count) { + sizes[count]=buttons[count]->sizeHint(); + buttonHeight=QMAX(buttonHeight, sizes[count].height()); + } + // ----- calculate size of the month button: + w=0; + for(count=0; count<NoOfButtons; ++count) { + if(buttons[count]!=selectMonth) + { + w+=sizes[count].width(); + } else { + x=count; + } + } + sizes[x].setWidth(width()-w); // stretch the month button + // ----- place the buttons: + x=0; + for(count=0; count<NoOfButtons; ++count) + { + w=sizes[count].width(); + buttons[count]->setGeometry(x, 0, w, buttonHeight); + x+=w; + } + // ----- place the line edit for direct input: + sizes[0]=line->sizeHint(); + line->setGeometry(0, height()-sizes[0].height(), width(), sizes[0].height()); + // ----- adjust the table: + table->setGeometry(0, buttonHeight, width(), + height()-buttonHeight-sizes[0].height()); +} + +void +KDatePicker::dateChangedSlot(QDate date) +{ + kdDebug() << "KDatePicker::dateChangedSlot: date changed (" << date.year() << "/" << date.month() << "/" << date.day() << ")." << endl; + line->setText(KGlobal::locale()->formatDate(date, true)); + emit(dateChanged(date)); +} + +void +KDatePicker::tableClickedSlot() +{ + kdDebug() << "KDatePicker::tableClickedSlot: table clicked." << endl; + emit(dateSelected(table->getDate())); + emit(tableClicked()); +} + +const QDate& +KDatePicker::getDate() const +{ + return table->getDate(); +} + +const QDate & +KDatePicker::date() const +{ + return table->getDate(); +} + +bool +KDatePicker::setDate(const QDate& date) +{ + if(date.isValid()) { + QString temp; + // ----- + table->setDate(date); + selectMonth->setText(KGlobal::locale()->monthName(date.month(), false)); + temp.setNum(date.year()); + selectYear->setText(temp); + line->setText(KGlobal::locale()->formatDate(date, true)); + return true; + } else { + kdDebug() << "KDatePicker::setDate: refusing to set invalid date." << endl; + return false; + } +} + +void +KDatePicker::monthForwardClicked() +{ + QDate temp=table->getDate(); + int day=temp.day(); + // ----- + if(temp.month()==12) { + temp.setYMD(temp.year()+1, 1, 1); + } else { + temp.setYMD(temp.year(), temp.month()+1, 1); + } + if(temp.daysInMonth()<day) { + temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); + } else { + temp.setYMD(temp.year(), temp.month(), day); + } + // assert(temp.isValid()); + setDate(temp); +} + +void +KDatePicker::monthBackwardClicked() +{ + QDate temp=table->getDate(); + int day=temp.day(); + // ----- + if(temp.month()==1) + { + temp.setYMD(temp.year()-1, 12, 1); + } else { + temp.setYMD(temp.year(), temp.month()-1, 1); + } + if(temp.daysInMonth()<day) + { + temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); + } else { + temp.setYMD(temp.year(), temp.month(), day); + } + // assert(temp.isValid()); + setDate(temp); +} + +void +KDatePicker::yearForwardClicked() +{ + QDate temp=table->getDate(); + int day=temp.day(); + // ----- + temp.setYMD(temp.year()+1, temp.month(), 1); + if(temp.daysInMonth()<day) + { + temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); + } else { + temp.setYMD(temp.year(), temp.month(), day); + } + // assert(temp.isValid()); + setDate(temp); +} + +void +KDatePicker::yearBackwardClicked() +{ + QDate temp=table->getDate(); + int day=temp.day(); + // ----- + temp.setYMD(temp.year()-1, temp.month(), 1); + if(temp.daysInMonth()<day) + { + temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); + } else { + temp.setYMD(temp.year(), temp.month(), day); + } + // assert(temp.isValid()); + setDate(temp); +} + +void +KDatePicker::selectMonthClicked() +{ + int month; + KPopupFrame* popup = new KPopupFrame(this); + KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(fontsize, popup); + // ----- + picker->resize(picker->sizeHint()); + popup->setMainWidget(picker); + picker->setFocus(); + connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); + if(popup->exec(selectMonth->mapToGlobal(QPoint(0, selectMonth->height())))) + { + QDate date; + int day; + // ----- + month=picker->getResult(); + date=table->getDate(); + day=date.day(); + // ----- construct a valid date in this month: + date.setYMD(date.year(), month, 1); + date.setYMD(date.year(), month, QMIN(day, date.daysInMonth())); + // ----- set this month + setDate(date); + } else { + KNotifyClient::beep(); + } + delete popup; +} + +void +KDatePicker::selectYearClicked() +{ + int year; + KPopupFrame* popup = new KPopupFrame(this); + KDateInternalYearSelector* picker = new KDateInternalYearSelector(fontsize, popup); + // ----- + picker->resize(picker->sizeHint()); + popup->setMainWidget(picker); + connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); + picker->setFocus(); + if(popup->exec(selectYear->mapToGlobal(QPoint(0, selectMonth->height())))) + { + QDate date; + int day; + // ----- + year=picker->getYear(); + date=table->getDate(); + day=date.day(); + // ----- construct a valid date in this month: + date.setYMD(year, date.month(), 1); + date.setYMD(year, date.month(), QMIN(day, date.daysInMonth())); + // ----- set this month + setDate(date); + } else { + KNotifyClient::beep(); + } + delete popup; +} + +void +KDatePicker::setEnabled(bool enable) +{ + QWidget *widgets[]= { + yearForward, yearBackward, monthForward, monthBackward, + selectMonth, selectYear, + line, table }; + const int Size=sizeof(widgets)/sizeof(widgets[0]); + int count; + // ----- + for(count=0; count<Size; ++count) + { + widgets[count]->setEnabled(enable); + } +} + +void +KDatePicker::lineEnterPressed() +{ + QDate temp; + // ----- + if(val->date(line->text(), temp)==QValidator::Acceptable) + { + kdDebug() << "KDatePicker::lineEnterPressed: valid date entered." << endl; + emit(dateEntered(temp)); + setDate(temp); + } else { + KNotifyClient::beep(); + kdDebug() << "KDatePicker::lineEnterPressed: invalid date entered." << endl; + } +} + +QSize +KDatePicker::sizeHint() const +{ + QSize tableSize=table->sizeHint(); + QWidget *buttons[]={ + yearBackward, + monthBackward, + selectMonth, + selectYear, + monthForward, + yearForward }; + const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]); + QSize sizes[NoOfButtons]; + int cx=0, cy=0, count; + // ----- store the size hints: + for(count=0; count<NoOfButtons; ++count) + { + sizes[count]=buttons[count]->sizeHint(); + if(buttons[count]==selectMonth) + { + cx+=maxMonthRect.width(); + } else { + cx+=sizes[count].width(); + } + cy=QMAX(sizes[count].height(), cy); + } + // ----- calculate width hint: + cx=QMAX(cx, tableSize.width()); // line edit ignored + // ----- calculate height hint: + cy+=tableSize.height()+line->sizeHint().height(); + return QSize(cx, cy); +} + +void +KDatePicker::setFontSize(int s) +{ + QWidget *buttons[]= { + // yearBackward, + // monthBackward, + selectMonth, + selectYear, + // monthForward, + // yearForward + }; + const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]); + int count; + QFont font; + QRect r; + // ----- + fontsize=s; + for(count=0; count<NoOfButtons; ++count) + { + font=buttons[count]->font(); + font.setPointSize(s); + buttons[count]->setFont(font); + } + QFontMetrics metrics(selectMonth->fontMetrics()); + for(int i=1; i <= 12; ++i) + { // maxMonthRect is used by sizeHint() + r=metrics.boundingRect(KGlobal::locale()->monthName(i, false)); + maxMonthRect.setWidth(QMAX(r.width(), maxMonthRect.width())); + maxMonthRect.setHeight(QMAX(r.height(), maxMonthRect.height())); + } + table->setFontSize(s); +} + +void KDatePicker::virtual_hook( int id, void* data ) +{ /*BASE::virtual_hook( id, data );*/ } + 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 @@ +/* -*- C++ -*- + This file is part of the KDE libraries + Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) + (C) 1998-2001 Mirko Boehm (mirko@kde.org) + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ +#ifndef MICROKDE_KDATEPICKER_H +#define MICROKDE_KDATEPICKER_H +#include <qdatetime.h> +#include <qframe.h> + +class QLineEdit; +class QToolButton; +class KDateValidator; +class KDateTable; + +/** + * Provides a widget for calendar date input. + * + * Different from the + * previous versions, it now emits two types of signals, either + * @ref dateSelected() or @ref dateEntered() (see documentation for both + * signals). + * + * A line edit has been added in the newer versions to allow the user + * to select a date directly by entering numbers like 19990101 + * or 990101. + * + * @image kdatepicker.png KDatePicker + * + * @version $Id$ + * @author Tim Gilman, Mirko Boehm + * + * @short A date selection widget. + **/ +class KDatePicker: public QFrame +{ + Q_OBJECT +public: + /** The usual constructor. The given date will be displayed + * initially. + **/ + KDatePicker(QWidget *parent=0, + QDate=QDate::currentDate(), + const char *name=0); + /** + * The destructor. + **/ + virtual ~KDatePicker(); + + /** The size hint for date pickers. The size hint recommends the + * minimum size of the widget so that all elements may be placed + * without clipping. This sometimes looks ugly, so when using the + * size hint, try adding 28 to each of the reported numbers of + * pixels. + **/ + QSize sizeHint() const; + + /** + * Sets the date. + * + * @returns @p false and does not change anything + * if the date given is invalid. + **/ + bool setDate(const QDate&); + + /** + * Returns the selected date. + * @deprecated + **/ + const QDate& getDate() const; + + /** + * @returns the selected date. + */ + const QDate &date() const; + + /** + * Enables or disables the widget. + **/ + void setEnabled(bool); + + /** + * Sets the font size of the widgets elements. + **/ + void setFontSize(int); + /** + * Returns the font size of the widget elements. + */ + int fontSize() const + { return fontsize; } + +protected: + /// the resize event + void resizeEvent(QResizeEvent*); + /// the year forward button + QToolButton *yearForward; + /// the year backward button + QToolButton *yearBackward; + /// the month forward button + QToolButton *monthForward; + /// the month backward button + QToolButton *monthBackward; + /// the button for selecting the month directly + QToolButton *selectMonth; + /// the button for selecting the year directly + QToolButton *selectYear; + /// the line edit to enter the date directly + QLineEdit *line; + /// the validator for the line edit: + KDateValidator *val; + /// the date table + KDateTable *table; + /// the size calculated during resize events + // QSize sizehint; + /// the widest month string in pixels: + QSize maxMonthRect; +protected slots: + void dateChangedSlot(QDate); + void tableClickedSlot(); + void monthForwardClicked(); + void monthBackwardClicked(); + void yearForwardClicked(); + void yearBackwardClicked(); + void selectMonthClicked(); + void selectYearClicked(); + void lineEnterPressed(); +signals: + /** This signal is emitted each time the selected date is changed. + * Usually, this does not mean that the date has been entered, + * since the date also changes, for example, when another month is + * selected. + * @see dateSelected + */ + void dateChanged(QDate); + /** This signal is emitted each time a day has been selected by + * clicking on the table (hitting a day in the current month). It + * has the same meaning as dateSelected() in older versions of + * KDatePicker. + */ + void dateSelected(QDate); + /** This signal is emitted when enter is pressed and a VALID date + * has been entered before into the line edit. Connect to both + * dateEntered() and dateSelected() to receive all events where the + * user really enters a date. + */ + void dateEntered(QDate); + /** This signal is emitted when the day has been selected by + * clicking on it in the table. + */ + void tableClicked(); + +private: + /// the font size for the widget + int fontsize; + +protected: + virtual void virtual_hook( int id, void* data ); +private: + class KDatePickerPrivate; + KDatePickerPrivate *d; +}; + +#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 @@ +/* -*- C++ -*- + This file is part of the KDE libraries + Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) + (C) 1998-2001 Mirko Boehm (mirko@kde.org) + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +/////////////////// KDateTable widget class ////////////////////// +// +// Copyright (C) 1997 Tim D. Gilman +// (C) 1998-2001 Mirko Boehm +// Written using Qt (http://www.troll.no) for the +// KDE project (http://www.kde.org) +// +// This is a support class for the KDatePicker class. It just +// draws the calender table without titles, but could theoretically +// be used as a standalone. +// +// When a date is selected by the user, it emits a signal: +// dateSelected(QDate) + +#include <kglobal.h> +#include <kglobalsettings.h> +#include <kapplication.h> +#include <klocale.h> +#include <kdebug.h> +#include <knotifyclient.h> +#include "kdatetbl.h" +#include <qdatetime.h> +#include <qstring.h> +#include <qpen.h> +#include <qpainter.h> +#include <qdialog.h> +#include <assert.h> +#include <qapplication.h> + +KDateValidator::KDateValidator(QWidget* parent, const char* name) + : QValidator(parent, name) +{ +} + +QValidator::State +KDateValidator::validate(QString& text, int&) const +{ + QDate temp; + // ----- everything is tested in date(): + return date(text, temp); +} + +QValidator::State +KDateValidator::date(const QString& text, QDate& d) const +{ + QDate tmp = KGlobal::locale()->readDate(text); + if (!tmp.isNull()) + { + d = tmp; + return Acceptable; + } else + return Valid; +} + +void +KDateValidator::fixup( QString& ) const +{ + +} + +KDateTable::KDateTable(QWidget *parent, QDate date_, const char* name, WFlags f) + : QGridView(parent, name, f) +{ + setFontSize(10); + if(!date_.isValid()) + { + kdDebug() << "KDateTable ctor: WARNING: Given date is invalid, using current date." << endl; + date_=QDate::currentDate(); + } + setFocusPolicy( QWidget::StrongFocus ); + setNumRows(7); // 6 weeks max + headline + setNumCols(7); // 7 days a week + setHScrollBarMode(AlwaysOff); + setVScrollBarMode(AlwaysOff); +#if 0 + viewport()->setEraseColor(lightGray); +#endif + setDate(date_); // this initializes firstday, numdays, numDaysPrevMonth +} + +void +KDateTable::paintCell(QPainter *painter, int row, int col) +{ + QRect rect; + QString text; + QPen pen; + int w=cellWidth(); + int h=cellHeight(); + int pos; + QBrush brushBlue(blue); + QBrush brushLightblue(lightGray); + QFont font=KGlobalSettings::generalFont(); + // ----- + font.setPointSize(fontsize); + if(row==0) + { // we are drawing the headline + font.setBold(true); + painter->setFont(font); + bool normalday = true; + QString daystr; + if (KGlobal::locale()->weekStartsMonday()) + { + daystr = KGlobal::locale()->weekDayName(col+1, true); + if (col == 5 || col == 6) + normalday = false; + } else { + daystr = KGlobal::locale()->weekDayName(col==0? 7 : col, true); + if (col == 0 || col == 6) + normalday = false; + } + if (!normalday) + { + painter->setPen(lightGray); + painter->setBrush(brushLightblue); + painter->drawRect(0, 0, w, h); + painter->setPen(blue); + } else { + painter->setPen(blue); + painter->setBrush(brushBlue); + painter->drawRect(0, 0, w, h); + painter->setPen(white); + } + painter->drawText(0, 0, w, h-1, AlignCenter, + daystr, -1, &rect); + painter->setPen(black); + painter->moveTo(0, h-1); + painter->lineTo(w-1, h-1); + // ----- draw the weekday: + } else { + painter->setFont(font); + pos=7*(row-1)+col; + if (KGlobal::locale()->weekStartsMonday()) + pos++; + if(pos<firstday || (firstday+numdays<=pos)) + { // we are either + // ° painting a day of the previous month or + // ° painting a day of the following month + if(pos<firstday) + { // previous month + text.setNum(numDaysPrevMonth+pos-firstday+1); + } else { // following month + text.setNum(pos-firstday-numdays+1); + } + painter->setPen(gray); + } else { // paint a day of the current month + text.setNum(pos-firstday+1); + painter->setPen(black); + } + + pen=painter->pen(); + if(firstday+date.day()-1==pos) + { + if(hasFocus()) + { // draw the currently selected date + painter->setPen(red); + painter->setBrush(darkRed); + pen=white; + } else { + painter->setPen(darkGray); + painter->setBrush(darkGray); + pen=white; + } + } else { + painter->setBrush(lightGray); + painter->setPen(lightGray); + } + painter->drawRect(0, 0, w, h); + painter->setPen(pen); + painter->drawText(0, 0, w, h, AlignCenter, text, -1, &rect); + } + if(rect.width()>maxCell.width()) maxCell.setWidth(rect.width()); + if(rect.height()>maxCell.height()) maxCell.setHeight(rect.height()); +} + +void +KDateTable::keyPressEvent( QKeyEvent *e ) +{ + if ( e->key() == Qt::Key_Prior ) { + if ( date.month() == 1 ) { + KNotifyClient::beep(); + return; + } + int day = date.day(); + if ( day > 27 ) + while ( !QDate::isValid( date.year(), date.month()-1, day ) ) + day--; + setDate(QDate(date.year(), date.month()-1, day)); + return; + } + if ( e->key() == Qt::Key_Next ) { + if ( date.month() == 12 ) { + KNotifyClient::beep(); + return; + } + int day = date.day(); + if ( day > 27 ) + while ( !QDate::isValid( date.year(), date.month()+1, day ) ) + day--; + setDate(QDate(date.year(), date.month()+1, day)); + return; + } + + int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; + + int temp=firstday+date.day()-dayoff; + int pos = temp; + + if ( e->key() == Qt::Key_Up ) { + pos -= 7; + } + if ( e->key() == Qt::Key_Down ) { + pos += 7; + } + if ( e->key() == Qt::Key_Left ) { + pos--; + } + if ( e->key() == Qt::Key_Right ) { + pos++; + } + + if(pos+dayoff<=firstday) + { // this day is in the previous month + KNotifyClient::beep(); + return; + } + if(firstday+numdays<pos+dayoff) + { // this date is in the next month + KNotifyClient::beep(i18n( "Month not long enough" )); + return; + } + + if ( pos == temp ) + return; + + setDate(QDate(date.year(), date.month(), pos-firstday+dayoff)); + updateCell(temp/7+1, temp%7); // Update the previously selected cell + updateCell(pos/7+1, pos%7); // Update the selected cell + assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); +} + +void +KDateTable::viewportResizeEvent(QResizeEvent * e) +{ + QGridView::viewportResizeEvent(e); + + setCellWidth(viewport()->width()/7); + setCellHeight(viewport()->height()/7); +} + +void +KDateTable::setFontSize(int size) +{ + int count; + QFontMetrics metrics(fontMetrics()); + QRect rect; + // ----- store rectangles: + fontsize=size; + // ----- find largest day name: + maxCell.setWidth(0); + maxCell.setHeight(0); + for(count=0; count<7; ++count) + { + rect=metrics.boundingRect(KGlobal::locale()->weekDayName(count+1, true)); + maxCell.setWidth(QMAX(maxCell.width(), rect.width())); + maxCell.setHeight(QMAX(maxCell.height(), rect.height())); + } + // ----- compare with a real wide number and add some space: + rect=metrics.boundingRect(QString::fromLatin1("88")); + maxCell.setWidth(QMAX(maxCell.width()+2, rect.width())); + maxCell.setHeight(QMAX(maxCell.height()+4, rect.height())); +} + +void +KDateTable::contentsMousePressEvent(QMouseEvent *e) +{ + if(e->type()!=QEvent::MouseButtonPress) + { // the KDatePicker only reacts on mouse press events: + return; + } + if(!isEnabled()) + { + KNotifyClient::beep(); + return; + } + + int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; + // ----- + int row, col, pos, temp; + QPoint mouseCoord; + // ----- + mouseCoord = e->pos(); + row=rowAt(mouseCoord.y()); + col=columnAt(mouseCoord.x()); + if(row<0 || col<0) + { // the user clicked on the frame of the table + return; + } + pos=7*(row-1)+col+1; + if(pos+dayoff<=firstday) + { // this day is in the previous month + KNotifyClient::beep(); + return; + } + if(firstday+numdays<pos+dayoff) + { // this date is in the next month + KNotifyClient::beep(); + return; + } + temp=firstday+date.day()-dayoff-1; + setDate(QDate(date.year(), date.month(), pos-firstday+dayoff)); + updateCell(temp/7+1, temp%7); // Update the previously selected cell + updateCell(row, col); // Update the selected cell + // assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); + emit(tableClicked()); +} + +bool +KDateTable::setDate(const QDate& date_) +{ + bool changed=false; + QDate temp; + // ----- + if(!date_.isValid()) + { + kdDebug() << "KDateTable::setDate: refusing to set invalid date." << endl; + return false; + } + if(date!=date_) + { + date=date_; + changed=true; + } + temp.setYMD(date.year(), date.month(), 1); + firstday=temp.dayOfWeek(); + if(firstday==1) firstday=8; + numdays=date.daysInMonth(); + if(date.month()==1) + { // set to december of previous year + temp.setYMD(date.year()-1, 12, 1); + } else { // set to previous month + temp.setYMD(date.year(), date.month()-1, 1); + } + numDaysPrevMonth=temp.daysInMonth(); + if(changed) + { + repaintContents(false); + } + emit(dateChanged(date)); + return true; +} + +const QDate& +KDateTable::getDate() const +{ + return date; +} + +void KDateTable::focusInEvent( QFocusEvent *e ) +{ + repaintContents(false); + QGridView::focusInEvent( e ); +} + +void KDateTable::focusOutEvent( QFocusEvent *e ) +{ + repaintContents(false); + QGridView::focusOutEvent( e ); +} + +QSize +KDateTable::sizeHint() const +{ + if(maxCell.height()>0 && maxCell.width()>0) + { + return QSize(maxCell.width()*numCols()+2*frameWidth(), + (maxCell.height()+2)*numRows()+2*frameWidth()); + } else { + kdDebug() << "KDateTable::sizeHint: obscure failure - " << endl; + return QSize(-1, -1); + } +} + +KDateInternalMonthPicker::KDateInternalMonthPicker +(int fontsize, QWidget* parent, const char* name) + : QGridView(parent, name), + result(0) // invalid +{ + QRect rect; + QFont font; + // ----- + activeCol = -1; + activeRow = -1; + font=KGlobalSettings::generalFont(); + font.setPointSize(fontsize); + setFont(font); + setHScrollBarMode(AlwaysOff); + setVScrollBarMode(AlwaysOff); + setFrameStyle(QFrame::NoFrame); + setNumRows(4); + setNumCols(3); + // enable to find drawing failures: + // setTableFlags(Tbl_clipCellPainting); +#if 0 + viewport()->setEraseColor(lightGray); // for consistency with the datepicker +#endif + // ----- find the preferred size + // (this is slow, possibly, but unfortunatly it is needed here): + QFontMetrics metrics(font); + for(int i=1; i <= 12; ++i) + { + rect=metrics.boundingRect(KGlobal::locale()->monthName(i, false)); + if(max.width()<rect.width()) max.setWidth(rect.width()); + if(max.height()<rect.height()) max.setHeight(rect.height()); + } + +} + +QSize +KDateInternalMonthPicker::sizeHint() const +{ + return QSize((max.width()+6)*numCols()+2*frameWidth(), + (max.height()+6)*numRows()+2*frameWidth()); +} + +int +KDateInternalMonthPicker::getResult() const +{ + return result; +} + +void +KDateInternalMonthPicker::setupPainter(QPainter *p) +{ + p->setPen(black); +} + +void +KDateInternalMonthPicker::viewportResizeEvent(QResizeEvent*) +{ + setCellWidth(width()/3); + setCellHeight(height()/4); +} + +void +KDateInternalMonthPicker::paintCell(QPainter* painter, int row, int col) +{ + int index; + QString text; + // ----- find the number of the cell: + index=3*row+col+1; + text=KGlobal::locale()->monthName(index, false); + painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text); + if ( activeCol == col && activeRow == row ) + painter->drawRect( 0, 0, cellWidth(), cellHeight() ); +} + +void +KDateInternalMonthPicker::contentsMousePressEvent(QMouseEvent *e) +{ + if(!isEnabled() || e->button() != LeftButton) + { + KNotifyClient::beep(); + return; + } + // ----- + int row, col; + QPoint mouseCoord; + // ----- + mouseCoord = e->pos(); + row=rowAt(mouseCoord.y()); + col=columnAt(mouseCoord.x()); + + if(row<0 || col<0) + { // the user clicked on the frame of the table + activeCol = -1; + activeRow = -1; + } else { + activeCol = col; + activeRow = row; + updateCell( row, col /*, false */ ); + } +} + +void +KDateInternalMonthPicker::contentsMouseMoveEvent(QMouseEvent *e) +{ + if (e->state() & LeftButton) + { + int row, col; + QPoint mouseCoord; + // ----- + mouseCoord = e->pos(); + row=rowAt(mouseCoord.y()); + col=columnAt(mouseCoord.x()); + int tmpRow = -1, tmpCol = -1; + if(row<0 || col<0) + { // the user clicked on the frame of the table + if ( activeCol > -1 ) + { + tmpRow = activeRow; + tmpCol = activeCol; + } + activeCol = -1; + activeRow = -1; + } else { + bool differentCell = (activeRow != row || activeCol != col); + if ( activeCol > -1 && differentCell) + { + tmpRow = activeRow; + tmpCol = activeCol; + } + if ( differentCell) + { + activeRow = row; + activeCol = col; + updateCell( row, col /*, false */ ); // mark the new active cell + } + } + if ( tmpRow > -1 ) // repaint the former active cell + updateCell( tmpRow, tmpCol /*, true */ ); + } +} + +void +KDateInternalMonthPicker::contentsMouseReleaseEvent(QMouseEvent *e) +{ + if(!isEnabled()) + { + return; + } + // ----- + int row, col, pos; + QPoint mouseCoord; + // ----- + mouseCoord = e->pos(); + row=rowAt(mouseCoord.y()); + col=columnAt(mouseCoord.x()); + if(row<0 || col<0) + { // the user clicked on the frame of the table + emit(closeMe(0)); + } + pos=3*row+col+1; + result=pos; + emit(closeMe(1)); +} + + + +KDateInternalYearSelector::KDateInternalYearSelector +(int fontsize, QWidget* parent, const char* name) + : QLineEdit(parent, name), + val(new QIntValidator(this)), + result(0) +{ + QFont font; + // ----- + font=KGlobalSettings::generalFont(); + font.setPointSize(fontsize); + setFont(font); +#if 0 + setFrameStyle(QFrame::NoFrame); +#endif + // we have to respect the limits of QDate here, I fear: + val->setRange(0, 8000); + setValidator(val); + connect(this, SIGNAL(returnPressed()), SLOT(yearEnteredSlot())); +} + +void +KDateInternalYearSelector::yearEnteredSlot() +{ + bool ok; + int year; + QDate date; + // ----- check if this is a valid year: + year=text().toInt(&ok); + if(!ok) + { + KNotifyClient::beep(); + return; + } + date.setYMD(year, 1, 1); + if(!date.isValid()) + { + KNotifyClient::beep(); + return; + } + result=year; + emit(closeMe(1)); +} + +int +KDateInternalYearSelector::getYear() +{ + return result; +} + +void +KDateInternalYearSelector::setYear(int year) +{ + QString temp; + // ----- + temp.setNum(year); + setText(temp); +} + +KPopupFrame::KPopupFrame(QWidget* parent, const char* name) + : QFrame(parent, name, WType_Popup), + result(0), // rejected + main(0) +{ + setFrameStyle(QFrame::Box|QFrame::Raised); + setMidLineWidth(2); +} + +void +KPopupFrame::keyPressEvent(QKeyEvent* e) +{ + if(e->key()==Key_Escape) + { + result=0; // rejected + qApp->exit_loop(); + } +} + +void +KPopupFrame::close(int r) +{ + result=r; + qApp->exit_loop(); +} + +void +KPopupFrame::setMainWidget(QWidget* m) +{ + main=m; + if(main!=0) + { + resize(main->width()+2*frameWidth(), main->height()+2*frameWidth()); + } +} + +void +KPopupFrame::resizeEvent(QResizeEvent*) +{ + if(main!=0) + { + main->setGeometry(frameWidth(), frameWidth(), + width()-2*frameWidth(), height()-2*frameWidth()); + } +} + +void +KPopupFrame::popup(const QPoint &pos) +{ + // Make sure the whole popup is visible. + QRect d = QApplication::desktop()->frameGeometry(); + int x = pos.x(); + int y = pos.y(); + int w = width(); + int h = height(); + if (x+w > d.x()+d.width()) + x = d.width() - w; + if (y+h > d.y()+d.height()) + y = d.height() - h; + if (x < d.x()) + x = 0; + if (y < d.y()) + y = 0; + + // Pop the thingy up. + move(x, y); + show(); +} + +int +KPopupFrame::exec(QPoint pos) +{ + popup(pos); + repaint(); + qApp->enter_loop(); + hide(); + return result; +} + +int +KPopupFrame::exec(int x, int y) +{ + return exec(QPoint(x, y)); +} + +void KPopupFrame::virtual_hook( int, void* ) +{ /*BASE::virtual_hook( id, data );*/ } + +void KDateTable::virtual_hook( int, void* ) +{ /*BASE::virtual_hook( id, data );*/ } + +#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 @@ +/* -*- C++ -*- + This file is part of the KDE libraries + Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) + (C) 1998-2001 Mirko Boehm (mirko@kde.org) + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ +#ifndef KDATETBL_H +#define KDATETBL_H + +#include <qvalidator.h> +#include <qgridview.h> +#include <qlineedit.h> +#include <qdatetime.h> + +/** +* A table containing month names. It is used to pick a month directly. +* @internal +* @version $Id$ +* @author Tim Gilman, Mirko Boehm +*/ +class KDateInternalMonthPicker : public QGridView +{ + Q_OBJECT +protected: + /** + * Store the month that has been clicked [1..12]. + */ + int result; + /** + * the cell under mouse cursor when LBM is pressed + */ + short int activeCol; + short int activeRow; + /** + * Contains the largest rectangle needed by the month names. + */ + QRect max; +signals: + /** + * This is send from the mouse click event handler. + */ + void closeMe(int); +public: + /** + * The constructor. + */ + KDateInternalMonthPicker(int fontsize, QWidget* parent, const char* name=0); + /** + * The size hint. + */ + QSize sizeHint() const; + /** + * Return the result. 0 means no selection (reject()), 1..12 are the + * months. + */ + int getResult() const; +protected: + /** + * Set up the painter. + */ + void setupPainter(QPainter *p); + /** + * The resize event. + */ + void viewportResizeEvent(QResizeEvent*); + /** + * Paint a cell. This simply draws the month names in it. + */ + virtual void paintCell(QPainter* painter, int row, int col); + /** + * Catch mouse click and move events to paint a rectangle around the item. + */ + void contentsMousePressEvent(QMouseEvent *e); + void contentsMouseMoveEvent(QMouseEvent *e); + /** + * Emit monthSelected(int) when a cell has been released. + */ + void contentsMouseReleaseEvent(QMouseEvent *e); + +private: + class KDateInternalMonthPrivate; + KDateInternalMonthPrivate *d; +}; + +/** Year selection widget. +* @internal +* @version $Id$ +* @author Tim Gilman, Mirko Boehm +*/ +class KDateInternalYearSelector : public QLineEdit +{ + Q_OBJECT +protected: + QIntValidator *val; + int result; +public slots: + void yearEnteredSlot(); +signals: + void closeMe(int); +public: + KDateInternalYearSelector(int fontsize, + QWidget* parent=0, + const char* name=0); + int getYear(); + void setYear(int year); + +private: + class KDateInternalYearPrivate; + KDateInternalYearPrivate *d; +}; + +/** + * Frame with popup menu behaviour. + * @author Tim Gilman, Mirko Boehm + * @version $Id$ + */ +class KPopupFrame : public QFrame +{ + Q_OBJECT +protected: + /** + * The result. It is returned from exec() when the popup window closes. + */ + int result; + /** + * Catch key press events. + */ + void keyPressEvent(QKeyEvent* e); + /** + * The only subwidget that uses the whole dialog window. + */ + QWidget *main; +public slots: + /** + * Close the popup window. This is called from the main widget, usually. + * @p r is the result returned from exec(). + */ + void close(int r); +public: + /** + * The contructor. Creates a dialog without buttons. + */ + KPopupFrame(QWidget* parent=0, const char* name=0); + /** + * Set the main widget. You cannot set the main widget from the constructor, + * since it must be a child of the frame itselfes. + * Be careful: the size is set to the main widgets size. It is up to you to + * set the main widgets correct size before setting it as the main + * widget. + */ + void setMainWidget(QWidget* m); + /** + * The resize event. Simply resizes the main widget to the whole + * widgets client size. + */ + void resizeEvent(QResizeEvent*); + /** + * Open the popup window at position pos. + */ + void popup(const QPoint &pos); + /** + * Execute the popup window. + */ + int exec(QPoint p); + /** + * Dito. + */ + int exec(int x, int y); + +private: + + virtual bool close(bool alsoDelete) { return QFrame::close(alsoDelete); } +protected: + virtual void virtual_hook( int id, void* data ); +private: + class KPopupFramePrivate; + KPopupFramePrivate *d; +}; + +/** +* Validates user-entered dates. +*/ +class KDateValidator : public QValidator +{ +public: + KDateValidator(QWidget* parent=0, const char* name=0); + virtual State validate(QString&, int&) const; + virtual void fixup ( QString & input ) const; + State date(const QString&, QDate&) const; +}; + +/** + * Date selection table. + * This is a support class for the KDatePicker class. It just + * draws the calender table without titles, but could theoretically + * be used as a standalone. + * + * When a date is selected by the user, it emits a signal: + * dateSelected(QDate) + * + * @internal + * @version $Id$ + * @author Tim Gilman, Mirko Boehm + */ +class KDateTable : public QGridView +{ + Q_OBJECT +public: + /** + * The constructor. + */ + KDateTable(QWidget *parent=0, + QDate date=QDate::currentDate(), + const char* name=0, WFlags f=0); + /** + * Returns a recommended size for the widget. + * To save some time, the size of the largest used cell content is + * calculated in each paintCell() call, since all calculations have + * to be done there anyway. The size is stored in maxCell. The + * sizeHint() simply returns a multiple of maxCell. + */ + virtual QSize sizeHint() const; + /** + * Set the font size of the date table. + */ + void setFontSize(int size); + /** + * Select and display this date. + */ + bool setDate(const QDate&); + const QDate& getDate() const; + + +protected: + /** + * Paint a cell. + */ + virtual void paintCell(QPainter*, int, int); + /** + * Handle the resize events. + */ + virtual void viewportResizeEvent(QResizeEvent *); + /** + * React on mouse clicks that select a date. + */ + virtual void contentsMousePressEvent(QMouseEvent *); + virtual void keyPressEvent( QKeyEvent *e ); + virtual void focusInEvent( QFocusEvent *e ); + virtual void focusOutEvent( QFocusEvent *e ); + /** + * The font size of the displayed text. + */ + int fontsize; + /** + * The currently selected date. + */ + QDate date; + /** + * The day of the first day in the month [1..7]. + */ + int firstday; + /** + * The number of days in the current month. + */ + int numdays; + /** + * The number of days in the previous month. + */ + int numDaysPrevMonth; + /** + * unused + */ + bool unused_hasSelection; + /** + * Save the size of the largest used cell content. + */ + QRect maxCell; +signals: + /** + * The selected date changed. + */ + void dateChanged(QDate); + /** + * A date has been selected by clicking on the table. + */ + void tableClicked(); + +protected: + virtual void virtual_hook( int id, void* data ); +private: + class KDateTablePrivate; + KDateTablePrivate *d; +}; + +#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 @@ +#ifndef MINIKDE_KDEBUG_H +#define MINIKDE_KDEBUG_H + +#include <stdio.h> + +#include <qstring.h> + +class kdbgstream; +typedef kdbgstream & (*KDBGFUNC)(kdbgstream &); // manipulator function + +class kdbgstream { + public: + kdbgstream(unsigned int _area, unsigned int _level, bool _print = true) : + area(_area), level(_level), print(_print) { } + kdbgstream(const char * initialString, unsigned int _area, unsigned int _level, bool _print = true) : + output(QString::fromLatin1(initialString)), area(_area), level(_level), print(_print) { } + ~kdbgstream() + { + if (!output.isEmpty()) { + fprintf(stderr,"ASSERT: debug output not ended with \\n\n"); + *this << "\n"; + } + } + kdbgstream &operator<<(bool i) { + if (!print) return *this; + output += QString::fromLatin1(i ? "true" : "false"); + return *this; + } + kdbgstream &operator<<(short i) { + if (!print) return *this; + QString tmp; tmp.setNum(i); output += tmp; + return *this; + } + kdbgstream &operator<<(unsigned short i) { + if (!print) return *this; + QString tmp; tmp.setNum(i); output += tmp; + return *this; + } + kdbgstream &operator<<(char i) { + if (!print) return *this; + QString tmp; tmp.setNum(int(i)); output += tmp; + return *this; + } + kdbgstream &operator<<(unsigned char i) { + if (!print) return *this; + QString tmp; tmp.setNum(static_cast<unsigned int>(i)); output += tmp; + return *this; + } + + kdbgstream &operator<<(int i) { + if (!print) return *this; + QString tmp; tmp.setNum(i); output += tmp; + return *this; + } + kdbgstream &operator<<(unsigned int i) { + if (!print) return *this; + QString tmp; tmp.setNum(i); output += tmp; + return *this; + } + kdbgstream &operator<<(long i) { + if (!print) return *this; + QString tmp; tmp.setNum(i); output += tmp; + return *this; + } + kdbgstream &operator<<(unsigned long i) { + if (!print) return *this; + QString tmp; tmp.setNum(i); output += tmp; + return *this; + } + kdbgstream &operator<<(const QString& string) { + if (!print) return *this; + output += string; + if (output.at(output.length() -1 ) == '\n') + flush(); + return *this; + } + kdbgstream &operator<<(const char *string) { + if (!print) return *this; + output += QString::fromUtf8(string); + if (output.at(output.length() - 1) == '\n') + flush(); + return *this; + } + kdbgstream &operator<<(const QCString& string) { + *this << string.data(); + return *this; + } + kdbgstream& operator<<(KDBGFUNC f) { + if (!print) return *this; + return (*f)(*this); + } + kdbgstream& operator<<(double d) { + QString tmp; tmp.setNum(d); output += tmp; + return *this; + } + void flush() { + if (output.isEmpty() || !print) + return; + printf("%s",output.latin1()); + output = QString::null; + } + private: + QString output; + unsigned int area, level; + bool print; +}; + +inline kdbgstream &endl( kdbgstream &s) { s << "\n"; return s; } + +inline kdbgstream kdDebug(int area = 0) { return kdbgstream(area, 0); } + +#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 @@ +#ifndef MINIKDE_KDIALOG_H +#define MINIKDE_KDIALOG_H + +#include <qdialog.h> + +class KDialog : public QDialog +{ + public: + KDialog( QWidget *parent=0, const char *name=0, bool modal=true ) : + QDialog( parent, name, modal ) {} + + static int spacingHint() { return 3; } + static int marginHint() { return 3; } +}; + +#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 @@ +#include <qtabwidget.h> +#include <qpushbutton.h> +#include <qlayout.h> +#include <qframe.h> + +#include "klocale.h" +#include "kdebug.h" + +#include "kdialogbase.h" + +KDialogBase::KDialogBase() +{ +} + +KDialogBase::KDialogBase( QWidget *parent, const char *name, bool modal, + const QString &caption, + int buttonMask, ButtonCode defaultButton, + bool separator, + const QString &user1, + const QString &user2, + const QString &user3) : + KDialog( parent, name, modal ) +{ + init( caption, buttonMask, user1 ); +} + +KDialogBase::KDialogBase( int dialogFace, const QString &caption, + int buttonMask, ButtonCode defaultButton, + QWidget *parent, const char *name, bool modal, + bool separator, + const QString &user1, + const QString &user2, + const QString &user3) : + KDialog( parent, name, modal ) +{ + init( caption, buttonMask, user1 ); +} + +KDialogBase::~KDialogBase() +{ +} + +void KDialogBase::init( const QString &caption, int buttonMask, + const QString &user1 ) +{ + mMainWidget = 0; + mTabWidget = 0; + mPlainPage = 0; + mTopLayout = 0; + + if ( !caption.isEmpty() ) { + setCaption( caption ); + } + + if ( buttonMask & User1 ) { + mUser1Button = new QPushButton( user1, this ); + connect( mUser1Button, SIGNAL( clicked() ), SLOT( slotUser1() ) ); + } else { + mUser1Button = 0; + } + + if ( buttonMask & Ok ) { + mOkButton = new QPushButton( i18n("Ok"), this ); + connect( mOkButton, SIGNAL( clicked() ), SLOT( slotOk() ) ); + } else { + mOkButton = 0; + } + + if ( buttonMask & Apply ) { + mApplyButton = new QPushButton( i18n("Apply"), this ); + connect( mApplyButton, SIGNAL( clicked() ), SLOT( slotApply() ) ); + } else { + mApplyButton = 0; + } + + if ( buttonMask & Cancel ) { + mCancelButton = new QPushButton( i18n("Cancel"), this ); + connect( mCancelButton, SIGNAL( clicked() ), SLOT( slotCancel() ) ); + } else { + mCancelButton = 0; + } + + if ( buttonMask & Close ) { + mCloseButton = new QPushButton( i18n("Close"), this ); + connect( mCloseButton, SIGNAL( clicked() ), SLOT( slotClose() ) ); + } else { + mCloseButton = 0; + } +} + +QTabWidget *KDialogBase::tabWidget() +{ + if ( !mTabWidget ) { + mTabWidget = new QTabWidget( this ); + setMainWidget( mTabWidget ); + } + return mTabWidget; +} + +void KDialogBase::initLayout() +{ + delete mTopLayout; + mTopLayout = new QVBoxLayout( this ); + mTopLayout->setMargin( marginHint() ); + mTopLayout->setSpacing( spacingHint() ); + + mTopLayout->addWidget( mMainWidget ); + + QBoxLayout *buttonLayout = new QHBoxLayout; + mTopLayout->addLayout( buttonLayout ); + + if ( mUser1Button ) buttonLayout->addWidget( mUser1Button ); + if ( mOkButton ) buttonLayout->addWidget( mOkButton ); + if ( mApplyButton ) buttonLayout->addWidget( mApplyButton ); + if ( mCancelButton ) buttonLayout->addWidget( mCancelButton ); + if ( mCloseButton ) buttonLayout->addWidget( mCloseButton ); +} + +QFrame *KDialogBase::addPage( const QString &name ) +{ +// kdDebug() << "KDialogBase::addPage(): " << name << endl; + + QFrame *frame = new QFrame( tabWidget() ); + tabWidget()->addTab( frame, name ); + return frame; +} + +QFrame *KDialogBase::addPage( const QString &name, int, const QPixmap & ) +{ + return addPage( name ); +} + + +void KDialogBase::setMainWidget( QWidget *widget ) +{ + kdDebug() << "KDialogBase::setMainWidget()" << endl; + + mMainWidget = widget; + initLayout(); +} + + +void KDialogBase::enableButton( ButtonCode id, bool state ) +{ + QPushButton *button = 0; + switch ( id ) { + case Ok: + button = mOkButton; + break; + case Apply: + button = mApplyButton; + break; + default: + break; + } + if ( button ) { + button->setEnabled( state ); + } +} + +void KDialogBase::enableButtonOK( bool state ) +{ + enableButton( Ok, state ); +} + +void KDialogBase::enableButtonApply( bool state ) +{ + enableButton( Apply, state ); +} + + +int KDialogBase::pageIndex( QWidget *widget ) const +{ + return 0; +} + + +bool KDialogBase::showPage( int index ) +{ + return false; +} + +QFrame *KDialogBase::plainPage() +{ + if ( !mPlainPage ) { + mPlainPage = new QFrame( this ); + setMainWidget( mPlainPage ); + } + return mPlainPage; +} + +void KDialogBase::slotOk() +{ + accept(); +} + +void KDialogBase::slotApply() +{ +} + +void KDialogBase::slotCancel() +{ + reject(); +} + +void KDialogBase::slotClose() +{ + accept(); +} + +void KDialogBase::slotUser1() +{ + emit user1Clicked(); +} 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 @@ +#ifndef MINIKDE_KDIALOGBASE_H +#define MINIKDE_KDIALOGBASE_H + +#include <qframe.h> + +#include "kdialog.h" + +class QPushButton; +class QLayout; +class QTabWidget; +class QBoxLayout; + +class KDialogBase : public KDialog +{ + Q_OBJECT + public: + enum ButtonCode + { + Help = 0x00000001, + Default = 0x00000002, + Ok = 0x00000004, + Apply = 0x00000008, + Try = 0x00000010, + Cancel = 0x00000020, + Close = 0x00000040, + User1 = 0x00000080, + User2 = 0x00000100, + User3 = 0x00000200, + No = 0x00000080, + Yes = 0x00000100, + Details = 0x00000400, + Filler = 0x40000000, + Stretch = 0x80000000 + }; + + enum DialogType + { + TreeList, + Tabbed, + Plain, + Swallow, + IconList + }; + + KDialogBase(); + KDialogBase( QWidget *parent=0, const char *name=0, bool modal=true, + const QString &caption=QString::null, + int buttonMask=Ok|Apply|Cancel, ButtonCode defaultButton=Ok, + bool separator=false, + const QString &user1=QString::null, + const QString &user2=QString::null, + const QString &user3=QString::null); + KDialogBase( int dialogFace, const QString &caption, + int buttonMask, ButtonCode defaultButton, + QWidget *parent=0, const char *name=0, bool modal=true, + bool separator=false, + const QString &user1=QString::null, + const QString &user2=QString::null, + const QString &user3=QString::null); + virtual ~KDialogBase(); + + QFrame *addPage( const QString & ); + QFrame *addPage( const QString &, int, const QPixmap & ); + + void setMainWidget( QWidget *widget ); + + void enableButton( ButtonCode id, bool state ); + void enableButtonOK( bool state ); + void enableButtonApply( bool state ); + + int pageIndex( QWidget *widget ) const; + + bool showPage( int index ); + + QFrame *plainPage(); + + signals: + void user1Clicked(); + + protected slots: + virtual void slotOk(); + virtual void slotApply(); + virtual void slotCancel(); + virtual void slotClose(); + virtual void slotUser1(); + + private: + QTabWidget *tabWidget(); + void init( const QString &caption, int buttonMask, + const QString &user1=QString::null ); + void initLayout(); + + QWidget *mMainWidget; + QTabWidget *mTabWidget; + QFrame *mPlainPage; + QBoxLayout *mTopLayout; + + QPushButton *mUser1Button; + QPushButton *mCloseButton; + QPushButton *mOkButton; + QPushButton *mApplyButton; + QPushButton *mCancelButton; +}; + +#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 @@ +#include "kemailsettings.h" + +QString KEMailSettings::getSetting(KEMailSettings::Setting s) +{ + return QString::null; +} 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 @@ +#ifndef MINIKDE_KEMAILSETTINGS_H +#define MINIKDE_KEMAILSETTINGS_H + +#include <qstring.h> + +class KEMailSettings +{ + public: + enum Setting { + ClientProgram, + ClientTerminal, + RealName, + EmailAddress, + ReplyToAddress, + Organization, + OutServer, + OutServerLogin, + OutServerPass, + OutServerType, + OutServerCommand, + OutServerTLS, + InServer, + InServerLogin, + InServerPass, + InServerType, + InServerMBXType, + InServerTLS + }; + QString getSetting(KEMailSettings::Setting s); +}; + +#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 @@ +#ifndef MICROKDE_KFILEDIALOG_H +#define MICROKDE_KFILEDIALOG_H + +class KFileDialog +{ + public: + + static QString getSaveFileName( const QString &, + const QString &, QWidget * ) + { + return QString::null; + } + + static QString getOpenFileName( const QString &, + const QString &, QWidget * ) + { + return QString::null; + } +}; + +#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 @@ +#include "kfontdialog.h" + +int KFontDialog::getFont( const QFont & ) +{ + return 0; +} 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 @@ +#ifndef MINIKDE_KFONTDIALOG_H +#define MINIKDE_KFONTDIALOG_H + +#include <qfont.h> + +class KFontDialog +{ + public: + enum { Accepted }; + + static int getFont( const QFont & ); +}; + +#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 @@ +#include "kglobal.h" + +KLocale *KGlobal::mLocale = 0; +KConfig *KGlobal::mConfig = 0; +KIconLoader *KGlobal::mIconLoader = 0; +KStandardDirs *KGlobal::mDirs = 0; + +QString KGlobal::mAppName = "godot"; + +KLocale *KGlobal::locale() +{ + if ( !mLocale ) { + mLocale = new KLocale(); + } + + return mLocale; +} + +KConfig *KGlobal::config() +{ + if ( !mConfig ) { + mConfig = new KConfig( KStandardDirs::appDir() + mAppName + "rc" ); + } + + return mConfig; +} + +KIconLoader *KGlobal::iconLoader() +{ + if ( !mIconLoader ) { + mIconLoader = new KIconLoader(); + } + + return mIconLoader; +} + +KStandardDirs *KGlobal::dirs() +{ + if ( !mDirs ) { + mDirs = new KStandardDirs(); + } + + return mDirs; +} + +void KGlobal::setAppName( const QString &appName ) +{ + mAppName = appName; +} 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 @@ +#ifndef MINIKDE_KGLOBAL_H +#define MINIKDE_KGLOBAL_H + +#include "klocale.h" +#include "kiconloader.h" +#include "kstandarddirs.h" +#include "kconfig.h" + +class KGlobal { + public: + static KLocale *locale(); + static KConfig *config(); + static KIconLoader *iconLoader(); + static KStandardDirs *dirs(); + + static void setAppName( const QString & ); + + private: + static KLocale *mLocale; + static KConfig *mConfig; + static KIconLoader *mIconLoader; + static KStandardDirs *mDirs; + + static QString mAppName; +}; + +#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 @@ +#include "kglobalsettings.h" + +QFont KGlobalSettings::generalFont() +{ + return QFont("fixed",12); +} + +QColor KGlobalSettings::baseColor() +{ + return Qt::white; +} + +QColor KGlobalSettings::highlightColor() +{ + return Qt::blue; +} + 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 @@ +#ifndef MICROKDE_KGLOBALSETTINGS_H +#define MICROKDE_KGLOBALSETTINGS_H + +#include <qfont.h> +#include <qcolor.h> + +class KGlobalSettings +{ + public: + static QFont generalFont(); + static QColor baseColor(); + static QColor highlightColor(); +}; + +#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 @@ +#include <qpe/resource.h> + +#include "kiconloader.h" + +QPixmap KIconLoader::loadIcon( const QString &name, int ) +{ + return Resource::loadPixmap( "kate/" + name ); +} + +QString KIconLoader::iconPath( const QString &, int ) +{ + return QString::null; +} + +QPixmap BarIcon( const QString &name ) +{ + return Resource::loadPixmap( "kate/" + name ); +} + +QPixmap DesktopIcon( const QString &name, int ) +{ + return Resource::loadPixmap( "kate/" + name ); +} + +QPixmap SmallIcon( const QString &name ) +{ + return Resource::loadPixmap( "kate/" + name ); +} + +QPixmap SmallIconSet( const QString &name ) +{ + return Resource::loadPixmap( "kate/" + name ); +} 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 @@ +#ifndef MINIKDE_KICONLOADER_H +#define MINIKDE_KICONLOADER_H + +#include <qpixmap.h> +#include <qstring.h> + +class KIcon +{ + public: + enum Group { NoGroup=-1, Desktop=0, Toolbar, MainToolbar, Small, + Panel, LastGroup, User }; + enum StdSizes { SizeSmall=16, SizeMedium=32, SizeLarge=48 }; +}; + +class KIconLoader +{ + public: + QPixmap loadIcon( const QString &name, int ); + + QString iconPath( const QString &, int ); +}; + +QPixmap BarIcon(const QString& name); + +QPixmap DesktopIcon(const QString& name, int); + +QPixmap SmallIcon(const QString& name); + +QPixmap SmallIconSet( const QString &name ); + +#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 @@ +#ifndef MINIKDE_KLINEEDIT_H +#define MINIKDE_KLINEEDIT_H + +#include <qlineedit.h> + +class KLineEdit : public QLineEdit +{ + public: + KLineEdit( QWidget *parent=0, const char *name=0 ) : + QLineEdit( parent, name ) {} +}; + +#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 @@ +#ifndef _mykdelineeditdlg_h_ +#define _mykdelineeditdlg_h_ + +#include <qinputdialog.h> + +#define KLineEditDlg QInputDialog + +#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 @@ +#ifndef MICROKDE_KLISTVIEW_H +#define MICROKDE_KLISTVIEW_H + +#include <qlistview.h> +#include <qpoint.h> +#include <qstring.h> + +class KConfig; + +class KListView : public QListView +{ + Q_OBJECT + public: + KListView( QWidget *parent=0, const char *name=0 ) + : QListView( parent, name ) {} + + void saveLayout( KConfig *, const QString & ) {} + void restoreLayout( KConfig *, const QString & ) {} + + signals: + void doubleClicked( QListViewItem *, QPoint, int ); +}; + +#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 @@ +#include <qregexp.h> + +#include "kdebug.h" + +#include "klocale.h" + +QString i18n(const char *text) +{ + return QString( text ); +} + +QString i18n(const char *,const char *text) +{ + return QString( text ); +} + +inline void put_it_in( QChar *buffer, uint& index, const QString &s ) +{ + for ( uint l = 0; l < s.length(); l++ ) + buffer[index++] = s.at( l ); +} + +inline void put_it_in( QChar *buffer, uint& index, int number ) +{ + buffer[index++] = number / 10 + '0'; + buffer[index++] = number % 10 + '0'; +} + +static int readInt(const QString &str, uint &pos) +{ + if (!str.at(pos).isDigit()) return -1; + int result = 0; + for (; str.length() > pos && str.at(pos).isDigit(); pos++) + { + result *= 10; + result += str.at(pos).digitValue(); + } + + return result; +} + +QString KLocale::formatTime(const QTime &pTime, bool includeSecs) const +{ + const QString rst = timeFormat(); + + // only "pm/am" here can grow, the rest shrinks, but + // I'm rather safe than sorry + QChar *buffer = new QChar[rst.length() * 3 / 2 + 30]; + + uint index = 0; + bool escape = false; + int number = 0; + + for ( uint format_index = 0; format_index < rst.length(); format_index++ ) + { + if ( !escape ) + { + if ( rst.at( format_index ).unicode() == '%' ) + escape = true; + else + buffer[index++] = rst.at( format_index ); + } + else + { + switch ( rst.at( format_index ).unicode() ) + { + case '%': + buffer[index++] = '%'; + break; + case 'H': + put_it_in( buffer, index, pTime.hour() ); + break; + case 'I': + put_it_in( buffer, index, ( pTime.hour() + 11) % 12 + 1 ); + break; + case 'M': + put_it_in( buffer, index, pTime.minute() ); + break; + case 'S': + if (includeSecs) + put_it_in( buffer, index, pTime.second() ); + else + { + // we remove the seperator sign before the seconds and + // assume that works everywhere + --index; + break; + } + break; + case 'k': + number = pTime.hour(); + case 'l': + // to share the code + if ( rst.at( format_index ).unicode() == 'l' ) + number = (pTime.hour() + 11) % 12 + 1; + if ( number / 10 ) + buffer[index++] = number / 10 + '0'; + buffer[index++] = number % 10 + '0'; + break; + case 'p': + { + QString s; + if ( pTime.hour() >= 12 ) + put_it_in( buffer, index, i18n("pm") ); + else + put_it_in( buffer, index, i18n("am") ); + break; + } + default: + buffer[index++] = rst.at( format_index ); + break; + } + escape = false; + } + } + QString ret( buffer, index ); + delete [] buffer; + return ret; +} + +QString KLocale::formatDate(const QDate &pDate, bool shortFormat) const +{ + const QString rst = shortFormat?dateFormatShort():dateFormat(); + + // I'm rather safe than sorry + QChar *buffer = new QChar[rst.length() * 3 / 2 + 50]; + + unsigned int index = 0; + bool escape = false; + int number = 0; + + for ( uint format_index = 0; format_index < rst.length(); ++format_index ) + { + if ( !escape ) + { + if ( rst.at( format_index ).unicode() == '%' ) + escape = true; + else + buffer[index++] = rst.at( format_index ); + } + else + { + switch ( rst.at( format_index ).unicode() ) + { + case '%': + buffer[index++] = '%'; + break; + case 'Y': + put_it_in( buffer, index, pDate.year() / 100 ); + case 'y': + put_it_in( buffer, index, pDate.year() % 100 ); + break; + case 'n': + number = pDate.month(); + case 'e': + // to share the code + if ( rst.at( format_index ).unicode() == 'e' ) + number = pDate.day(); + if ( number / 10 ) + buffer[index++] = number / 10 + '0'; + buffer[index++] = number % 10 + '0'; + break; + case 'm': + put_it_in( buffer, index, pDate.month() ); + break; + case 'b': + put_it_in( buffer, index, monthName(pDate.month(), true) ); + break; + case 'B': + put_it_in( buffer, index, monthName(pDate.month(), false) ); + break; + case 'd': + put_it_in( buffer, index, pDate.day() ); + break; + case 'a': + put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), true) ); + break; + case 'A': + put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), false) ); + break; + default: + buffer[index++] = rst.at( format_index ); + break; + } + escape = false; + } + } + QString ret( buffer, index ); + delete [] buffer; + return ret; +} + +QString KLocale::formatDateTime(const QDateTime &pDateTime, + bool shortFormat, + bool includeSeconds) const +{ + return i18n("concatenation of dates and time", "%1 %2") + .arg( formatDate( pDateTime.date(), shortFormat ) ) + .arg( formatTime( pDateTime.time(), includeSeconds ) ); +} + +QString KLocale::formatDateTime(const QDateTime &pDateTime) const +{ + return formatDateTime(pDateTime, true); +} + +QDate KLocale::readDate(const QString &intstr, bool* ok) const +{ + QDate date; + date = readDate(intstr, true, ok); + if (date.isValid()) return date; + return readDate(intstr, false, ok); +} + +QDate KLocale::readDate(const QString &intstr, bool shortFormat, bool* ok) const +{ + QString fmt = (shortFormat ? dateFormatShort() : dateFormat()).simplifyWhiteSpace(); + return readDate( intstr, fmt, ok ); +} + +QDate KLocale::readDate(const QString &intstr, const QString &fmt, bool* ok) const +{ + //kdDebug(173) << "KLocale::readDate intstr=" << intstr << " fmt=" << fmt << endl; + QString str = intstr.simplifyWhiteSpace().lower(); + int day = -1, month = -1; + // allow the year to be omitted if not in the format + int year = QDate::currentDate().year(); + uint strpos = 0; + uint fmtpos = 0; + + while (fmt.length() > fmtpos || str.length() > strpos) + { + if ( !(fmt.length() > fmtpos && str.length() > strpos) ) + goto error; + + QChar c = fmt.at(fmtpos++); + + if (c != '%') { + if (c.isSpace()) + strpos++; + else if (c != str.at(strpos++)) + goto error; + continue; + } + + // remove space at the begining + if (str.length() > strpos && str.at(strpos).isSpace()) + strpos++; + + c = fmt.at(fmtpos++); + switch (c) + { + case 'a': + case 'A': + // this will just be ignored + { // Cristian Tache: porting to Win: Block added because of "j" redefinition + for (int j = 1; j < 8; j++) { + QString s = weekDayName(j, c == 'a').lower(); + int len = s.length(); + if (str.mid(strpos, len) == s) + strpos += len; + } + break; + } + case 'b': + case 'B': + { // Cristian Tache: porting to Win: Block added because of "j" redefinition + for (int j = 1; j < 13; j++) { + QString s = monthName(j, c == 'b').lower(); + int len = s.length(); + if (str.mid(strpos, len) == s) { + month = j; + strpos += len; + } + } + break; + } + case 'd': + case 'e': + day = readInt(str, strpos); + if (day < 1 || day > 31) + goto error; + + break; + + case 'n': + case 'm': + month = readInt(str, strpos); + if (month < 1 || month > 12) + goto error; + + break; + + case 'Y': + case 'y': + year = readInt(str, strpos); + if (year < 0) + goto error; + // Qt treats a year in the range 0-100 as 1900-1999. + // It is nicer for the user if we treat 0-68 as 2000-2068 + if (year < 69) + year += 2000; + else if (c == 'y') + year += 1900; + + break; + } + } + //kdDebug(173) << "KLocale::readDate day=" << day << " month=" << month << " year=" << year << endl; + if ( year != -1 && month != -1 && day != -1 ) + { + if (ok) *ok = true; + return QDate(year, month, day); + } + error: + if (ok) *ok = false; + return QDate(); // invalid date +} + +QTime KLocale::readTime(const QString &intstr, bool *ok) const +{ + QTime _time; + _time = readTime(intstr, true, ok); + if (_time.isValid()) return _time; + return readTime(intstr, false, ok); +} + +QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const +{ + QString str = intstr.simplifyWhiteSpace().lower(); + QString Format = timeFormat().simplifyWhiteSpace(); + if (!seconds) + Format.replace(QRegExp(QString::fromLatin1(".%S")), QString::null); + + int hour = -1, minute = -1, second = seconds ? -1 : 0; // don't require seconds + bool g_12h = false; + bool pm = false; + uint strpos = 0; + uint Formatpos = 0; + + while (Format.length() > Formatpos || str.length() > strpos) + { + if ( !(Format.length() > Formatpos && str.length() > strpos) ) goto error; + + QChar c = Format.at(Formatpos++); + + if (c != '%') + { + if (c.isSpace()) + strpos++; + else if (c != str.at(strpos++)) + goto error; + continue; + } + + // remove space at the begining + if (str.length() > strpos && str.at(strpos).isSpace()) + strpos++; + + c = Format.at(Formatpos++); + switch (c) + { + case 'p': + { + QString s; + s = i18n("pm").lower(); + int len = s.length(); + if (str.mid(strpos, len) == s) + { + pm = true; + strpos += len; + } + else + { + s = i18n("am").lower(); + len = s.length(); + if (str.mid(strpos, len) == s) { + pm = false; + strpos += len; + } + else + goto error; + } + } + break; + + case 'k': + case 'H': + g_12h = false; + hour = readInt(str, strpos); + if (hour < 0 || hour > 23) + goto error; + + break; + + case 'l': + case 'I': + g_12h = true; + hour = readInt(str, strpos); + if (hour < 1 || hour > 12) + goto error; + + break; + + case 'M': + minute = readInt(str, strpos); + if (minute < 0 || minute > 59) + goto error; + + break; + + case 'S': + second = readInt(str, strpos); + if (second < 0 || second > 59) + goto error; + + break; + } + } + if (g_12h) + { + hour %= 12; + if (pm) hour += 12; + } + + if (ok) *ok = true; + return QTime(hour, minute, second); + + error: + if (ok) *ok = false; + return QTime(-1, -1, -1); // return invalid date if it didn't work + // This will be removed in the near future, since it gives a warning on stderr. + // The presence of the bool* (since KDE-3.0) removes the need for an invalid QTime. +} + +bool KLocale::use12Clock() const +{ + return false; +} + +bool KLocale::weekStartsMonday() const +{ + return true; +} + +QString KLocale::weekDayName(int i,bool shortName) const +{ + if ( shortName ) + switch ( i ) + { + case 1: return i18n("Monday", "Mon"); + case 2: return i18n("Tuesday", "Tue"); + case 3: return i18n("Wednesday", "Wed"); + case 4: return i18n("Thursday", "Thu"); + case 5: return i18n("Friday", "Fri"); + case 6: return i18n("Saturday", "Sat"); + case 7: return i18n("Sunday", "Sun"); + } + else + switch ( i ) + { + case 1: return i18n("Monday"); + case 2: return i18n("Tuesday"); + case 3: return i18n("Wednesday"); + case 4: return i18n("Thursday"); + case 5: return i18n("Friday"); + case 6: return i18n("Saturday"); + case 7: return i18n("Sunday"); + } + + return QString::null; +} + +QString KLocale::monthName(int i,bool shortName) const +{ + if ( shortName ) + switch ( i ) + { + case 1: return i18n("January", "Jan"); + case 2: return i18n("February", "Feb"); + case 3: return i18n("March", "Mar"); + case 4: return i18n("April", "Apr"); + case 5: return i18n("May short", "May"); + case 6: return i18n("June", "Jun"); + case 7: return i18n("July", "Jul"); + case 8: return i18n("August", "Aug"); + case 9: return i18n("September", "Sep"); + case 10: return i18n("October", "Oct"); + case 11: return i18n("November", "Nov"); + case 12: return i18n("December", "Dec"); + } + else + switch (i) + { + case 1: return i18n("January"); + case 2: return i18n("February"); + case 3: return i18n("March"); + case 4: return i18n("April"); + case 5: return i18n("May long", "May"); + case 6: return i18n("June"); + case 7: return i18n("July"); + case 8: return i18n("August"); + case 9: return i18n("September"); + case 10: return i18n("October"); + case 11: return i18n("November"); + case 12: return i18n("December"); + } + + return QString::null; +} + +QString KLocale::country() const +{ + return QString::null; +} + +QString KLocale::dateFormat() const +{ + return "%A %d %B %Y"; +} + +QString KLocale::dateFormatShort() const +{ + return "%d.%m.%Y"; +} + +QString KLocale::timeFormat() const +{ + return "%H:%M:%S"; +} 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 @@ +#ifndef MINIKDE_KLOCALE_H +#define MINIKDE_KLOCALE_H + +#include <qstring.h> +#include <qdatetime.h> + + +#define I18N_NOOP(x) x + + +QString i18n(const char *text); +QString i18n(const char *hint, const char *text); + +// Qt3's uic generates i18n( "msg", "comment" ) calls which conflict +// with our i18n method. we use uic -tr tr2i18n to redirect +// to the right i18n() function +inline QString tr2i18n(const char* message, const char* =0) { + return i18n( message); +} + +class KLocale +{ + public: + + QString formatDate(const QDate &pDate, bool shortFormat = false) const; + QString formatTime(const QTime &pTime, bool includeSecs = false) const; + QString formatDateTime(const QDateTime &pDateTime) const; + QString formatDateTime(const QDateTime &pDateTime, + bool shortFormat, + bool includeSecs = false) const; + + QDate readDate(const QString &str, bool* ok = 0) const; + QDate readDate( const QString &intstr, const QString &fmt, bool* ok = 0) const; + QTime readTime(const QString &str, bool* ok = 0) const; + + bool use12Clock() const; + bool weekStartsMonday() const; + + QString weekDayName(int,bool=false) const; + QString monthName(int,bool=false) const; + + QString country() const; + + QString dateFormat() const; + QString dateFormatShort() const; + QString timeFormat() const; + + private: + QTime readTime(const QString &str, bool seconds, bool *ok) const; + QDate readDate(const QString &str, bool shortFormat, bool *ok) const; +}; + +#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 @@ +#include "kmessagebox.h" +#include "klocale.h" + +#include <qmessagebox.h> + +void KMessageBox::sorry( QWidget *parent, + const QString &text, + const QString &caption, bool ) +{ + QString cap = caption; + + if (cap.isEmpty()) { + cap = i18n("Sorry"); + } + + QMessageBox::warning( parent, cap, text ); +} + +int KMessageBox::warningYesNoCancel(QWidget *parent, const QString &text) +{ + int result = QMessageBox::warning(parent,i18n("Warning"),text,QMessageBox::Yes, + QMessageBox::No, QMessageBox::Cancel); + switch (result) { + case QMessageBox::Yes: return Yes; + case QMessageBox::No: return No; + case QMessageBox::Cancel: return Cancel; + } +} + +int KMessageBox::questionYesNo(QWidget *parent, + const QString &text, + const QString &textYes, + const QString &textNo, + bool notify=true ) +{ + int result =QMessageBox::warning(parent,i18n("Question"),text,textYes,textNo); + if ( result == 0 ) return KMessageBox::Yes; + return KMessageBox::No; +} + + + + +int KMessageBox::warningContinueCancel( QWidget *parent, + const QString &text, + const QString &caption, + const QString &buttonContinue, + const QString &dontAskAgainName, + bool notify ) +{ + QString cap = caption; + + if (cap.isEmpty()) { + cap = i18n("Warning"); + } + + int result = QMessageBox::warning( parent, cap, text, i18n("Ok"), + i18n("Cancel") ); + + if ( result == 0 ) return KMessageBox::Continue; + return KMessageBox::Cancel; +} + +void KMessageBox::error( QWidget *parent, + const QString &text, + const QString &caption, bool notify ) +{ + QString cap = caption; + + if (cap.isEmpty()) { + cap = i18n("Error"); + } + + QMessageBox::critical( parent, cap, text ); +} + +void KMessageBox::information( QWidget *parent, + const QString &text, + const QString &caption, + const QString &, + bool ) +{ + QString cap = caption; + + if (cap.isEmpty()) { + cap = i18n("Information"); + } + + QMessageBox::information( parent, cap, text ); +} 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 @@ +#ifndef MINIKDE_KMESSAGEBOX_H +#define MINIKDE_KMESSAGEBOX_H + +#include <qstring.h> + +class QWidget; + +class KMessageBox +{ + public: + enum { Ok = 1, Cancel = 2, Yes = 3, No = 4, Continue = 5 }; + + static void sorry(QWidget *parent, + const QString &text, + const QString &caption = QString::null, bool notify=true); + + static int warningContinueCancel(QWidget *parent, + const QString &text, + const QString &caption = QString::null, + const QString &buttonContinue = QString::null, + const QString &dontAskAgainName = QString::null, + bool notify=true ); + + + static int questionYesNo(QWidget *parent, + const QString &text, + const QString &textYes, + const QString &textNo, + bool notify=true ); + + static int warningYesNoCancel(QWidget *parent, const QString &text); + + + static void error(QWidget *parent, + const QString &text, + const QString &caption = QString::null, bool notify=true); + + static void information(QWidget *parent, + const QString &text, + const QString &caption = QString::null, + const QString &dontShowAgainName = QString::null, + bool notify=true); +}; + + +#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 @@ +#ifndef MINIKDE_KNOTIFYCLIENT_H +#define MINIKDE_KNOTIFYCLIENT_H + +#include <qstring.h> + +class KNotifyClient +{ + public: + + static void beep() {} + static void beep( const QString & ) {} +}; + +#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 @@ +#include <qlineedit.h> + +#include "knumvalidator.h" + +KIntValidator::KIntValidator( int a, int b, QLineEdit *c ) + : QIntValidator( a, b, c ) +{ +} 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 @@ +#ifndef MINIKDE_KNUMVALIDATOR_H +#define MINIKDE_KNUMVALIDATOR_H + +#include <qvalidator.h> + +class QLineEdit; + +class KIntValidator : public QIntValidator +{ + public: + KIntValidator( int, int, QLineEdit * ); +}; + +#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 @@ +#ifndef _MYKPOPUPMENU_H_ +#define _MYKPOPUPMENU_H_ + +#include <qpopupmenu.h> + +#define KPopupMenu QPopupMenu + +#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 @@ +#ifndef MINIKDE_KPRINTER_H +#define MINIKDE_KPRINTER_H + +#include <qprinter.h> + +#define KPrinter QPrinter + +#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 @@ +#include "kprocess.h" + +void KProcess::clearArguments() +{ +} + +KProcess & KProcess::operator<<( const QString & ) +{ + return *this; +} + +bool KProcess::start() +{ + return false; +} 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 @@ +#ifndef MINIKDE_KPROCESS_H +#define MINIKDE_KPROCESS_H + +#include <qobject.h> + +class KProcess : public QObject +{ + public: + void clearArguments(); + + KProcess & operator<<( const QString & ); + + bool start(); +}; + +#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 @@ +#ifndef MINIKDE_KRESTRICTEDLINE_H +#define MINIKDE_KRESTRICTEDLINE_H + +#include "klineedit.h" + +class KRestrictedLine : public KLineEdit +{ + public: + KRestrictedLine( QWidget *parent, const char *, const QString & ) : + KLineEdit( parent ) {} +}; + +#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 @@ +#include "krun.h" + +bool KRun::runCommand(const QString &, const QString &, const QString &) +{ + return false; +} 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 @@ +#ifndef MINIKDE_KRUN_H +#define MINIKDE_KRUN_H + +#include <qstring.h> + +class KRun +{ + public: + static bool runCommand(const QString &a, const QString &b=QString::null, + const QString &c=QString::null); +}; + +#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 @@ +#ifndef MINIKDE_KSEPARATOR_H +#define MINIKDE_KSEPARATOR_H + +class KSeparator +{ +}; + +#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 @@ +/* This file is part of the KDE libraries + Copyright (c) 1999 Waldo Bastian <bastian@kde.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ +#ifndef KSharedPTR_H +#define KSharedPTR_H + +/** + * Reference counting for shared objects. If you derive your object + * from this class, then you may use it in conjunction with + * @ref KSharedPtr to control the lifetime of your object. + * + * Specifically, all classes that derive from KShared have an internal + * counter keeping track of how many other objects have a reference to + * their object. If used with @ref KSharedPtr, then your object will + * not be deleted until all references to the object have been + * released. + * + * You should probably not ever use any of the methods in this class + * directly -- let the @ref KSharedPtr take care of that. Just derive + * your class from KShared and forget about it. + * + * @author Waldo Bastian <bastian@kde.org> + * @version $Id$ + */ +class KShared { +public: + /** + * Standard constructor. This will initialize the reference count + * on this object to 0 + */ + KShared() : count(0) { } + + /** + * Copy constructor. This will @em not actually copy the objects + * but it will initialize the reference count on this object to 0 + */ + KShared( const KShared & ) : count(0) { } + + /** + * Overloaded assignment operator + */ + KShared &operator=(const KShared & ) { return *this; } + + /** + * Increases the reference count by one + */ + void _KShared_ref() { count++; } + + /** + * Releases a reference (decreases the reference count by one). If + * the count goes to 0, this object will delete itself + */ + void _KShared_unref() { if (!--count) delete this; } + + /** + * Return the current number of references held + * + * @return Number of references + */ + int _KShared_count() { return count; } + +protected: + virtual ~KShared() { } + int count; // ### KDE 3.0: rename to something like _KShared_count + // or make private +}; + +/** + * Can be used to control the lifetime of an object that has derived + * @ref KShared. As long a someone holds a KSharedPtr on some KShared + * object it won't become deleted but is deleted once its reference + * count is 0. This struct emulates C++ pointers perfectly. So just + * use it like a simple C++ pointer. + * + * KShared and KSharedPtr are preferred over QShared / QSharedPtr + * since they are more safe. + * + * @author Waldo Bastian <bastian@kde.org> + * @version $Id$ + */ +template< class T > +struct KSharedPtr +{ +public: + KSharedPtr() + : ptr(0) { } + KSharedPtr( T* t ) + : ptr(t) { if ( ptr ) ptr->_KShared_ref(); } + KSharedPtr( const KSharedPtr& p ) + : ptr(p.ptr) { if ( ptr ) ptr->_KShared_ref(); } + + ~KSharedPtr() { if ( ptr ) ptr->_KShared_unref(); } + + KSharedPtr<T>& operator= ( const KSharedPtr<T>& p ) { + if ( ptr == p.ptr ) return *this; + if ( ptr ) ptr->_KShared_unref(); + ptr = p.ptr; + if ( ptr ) ptr->_KShared_ref(); + return *this; + } + KSharedPtr<T>& operator= ( T* p ) { + if ( ptr == p ) return *this; + if ( ptr ) ptr->_KShared_unref(); + ptr = p; + if ( ptr ) ptr->_KShared_ref(); + return *this; + } + bool operator== ( const KSharedPtr<T>& p ) const { return ( ptr == p.ptr ); } + bool operator!= ( const KSharedPtr<T>& p ) const { return ( ptr != p.ptr ); } + bool operator== ( const T* p ) const { return ( ptr == p ); } + bool operator!= ( const T* p ) const { return ( ptr != p ); } + bool operator!() const { return ( ptr == 0 ); } + operator T*() const { return ptr; } + + T* data() { return ptr; } + const T* data() const { return ptr; } + + const T& operator*() const { return *ptr; } + T& operator*() { return *ptr; } + const T* operator->() const { return ptr; } + T* operator->() { return ptr; } + + int count() const { return ptr->_KShared_count(); } // for debugging purposes +private: + T* ptr; +}; + +#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 @@ +#ifndef MINIKDE_KSIMPLECONFIG_H +#define MINIKDE_KSIMPLECONFIG_H + +#include "kconfig.h" + +class KSimpleConfig : public KConfig +{ + public: + KSimpleConfig( const QString &file ) : KConfig( file ) {} +}; + +#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 @@ +#include "kdebug.h" + +#include "kstandarddirs.h" + +QString KStandardDirs::mAppDir = QString::null; + +QString locate( const char *type, const QString& filename ) +{ + QString path = KStandardDirs::appDir() + type + "_" + filename; + + kdDebug() << "locate: '" << path << "'" << endl; + + return path; +} + +QString locateLocal( const char *type, const QString& filename ) +{ + return locate( type, filename ); +} + +QStringList KStandardDirs::findAllResources( const QString &, const QString &, bool, bool) +{ + QStringList list; + list.append("/cpp.xml"); + return list; +// return QStringList(); +} + +QString KStandardDirs::findResourceDir( const QString &, const QString & ) +{ + return QString::null; +} + +void KStandardDirs::setAppDir( const QString &appDir ) +{ + mAppDir = appDir; + + if ( mAppDir.right( 1 ) != "/" ) mAppDir += "/"; +} 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 @@ +#ifndef MINIKDE_KSTANDARDDIRS_H +#define MINIKDE_KSTANDARDDIRS_H + +#include <qstring.h> +#include <qstringlist.h> + +QString locate( const char *type, const QString& filename ); +QString locateLocal( const char *type, const QString& filename ); + +class KStandardDirs +{ + public: + QStringList findAllResources( const QString &, const QString &, bool, bool); + QString findResourceDir( const QString &, const QString & ); + + static void setAppDir( const QString & ); + static QString appDir() { return mAppDir; } + + private: + static QString mAppDir; +}; + +#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 @@ +/* + * This file is part of the KDE Libraries + * Copyright (C) 2000 Stephan Kulow <coolo@kde.org> + * 2001 KDE Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +#ifndef _KSTATIC_DELETER_H_ +#define _KSTATIC_DELETER_H_ + +template<class type> +class KStaticDeleter +{ + public: + KStaticDeleter() {}; + type *setObject( type *obj, bool isArray = false) { return obj; } + virtual ~KStaticDeleter() {}; +}; + +#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 @@ +#ifndef MINIKDE_KSTANDARDDIRS_H +#define MINIKDE_KSTANDARDDIRS_H + +#include <qstring.h> +#include <qstringlist.h> + +QString locate( const char *type, const QString& filename ); +QString locateLocal( const char *type, const QString& filename ); + +class KStandardDirs +{ + public: + QStringList findAllResources( const QString &, const QString &, bool, bool); + QString findResourceDir( const QString &, const QString & ); + + static void setAppDir( const QString & ); + static QString appDir() { return mAppDir; } + + private: + static QString mAppDir; +}; + +#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 @@ +#include <qtextstream.h> + +#include "ktempfile.h" + +KTempFile::KTempFile() +{ +} + +KTempFile::KTempFile( const QString &filename, const QString &extension ) +{ +} + +void KTempFile::setAutoDelete( bool ) +{ +} + +QString KTempFile::name() +{ + return QString::null; +} + +QTextStream *KTempFile::textStream() +{ + return 0; +} 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 @@ +#ifndef MINIKDE_KTEMPFILE_H +#define MINIKDE_KTEMPFILE_H + +#include <qstring.h> + +class QTextStream; + +class KTempFile +{ + public: + KTempFile(); + KTempFile( const QString &filename, const QString &extension ); + + void setAutoDelete( bool ); + QString name(); + + QTextStream *textStream(); +}; + +#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 @@ +#ifndef MINIKDE_KUNLOAD_H +#define MINIKDE_KUNLOAD_H + +#define _UNLOAD(p) + +#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 @@ +#include "klineedit.h" + +#include "kurlrequester.h" + +KURLRequester::KURLRequester( QWidget *parent ) : + QWidget( parent ) +{ + mLineEdit = new KLineEdit( parent ); +} + +KLineEdit *KURLRequester::lineEdit() +{ + return mLineEdit; +} 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 @@ +#ifndef MINIKDE_KURLREQUESTER_H +#define MINIKDE_KURLREQUESTER_H + +class KLineEdit; + +class KURLRequester : public QWidget +{ + public: + KURLRequester( QWidget *parent ); + + KLineEdit *lineEdit(); + + private: + KLineEdit *mLineEdit; +}; + +#endif |