Commit 87476d42 authored by Thomas Zander's avatar Thomas Zander

Cleanup API

* api docs
* remove unused parameters / variables.
* d pointer

svn path=/trunk/koffice/; revision=650328
parent cf5ecf7e
/* This file is part of the KDE project
Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
Copyright (C) 2007 Thomas Zander <zander@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......@@ -28,12 +29,19 @@
#include <kdebug.h>
#include <KStandardGuiItem>
class KoCharSelectDia::Private {
public:
Private() : charSelect(0) {}
KCharSelect *charSelect;
};
/******************************************************************/
/* class KoCharSelectDia */
/******************************************************************/
KoCharSelectDia::KoCharSelectDia( QWidget *parent, const char *name, const QChar &_chr, const QString &_font, bool _enableFont , bool _modal)
: KDialog( parent )
KoCharSelectDia::KoCharSelectDia( QWidget *parent, const char *name, const QChar &_chr, const QString &_font, bool _modal)
: KDialog( parent ),
d(new Private())
{
setCaption( i18n("Select Character") );
setModal( _modal );
......@@ -41,7 +49,7 @@ KoCharSelectDia::KoCharSelectDia( QWidget *parent, const char *name, const QChar
setDefaultButton( Ok );
setObjectName( name );
initDialog(_chr,_font,_enableFont);
initDialog(_chr,_font);
KGuiItem okItem = KStandardGuiItem::ok(); // start from std item to keep the OK icon...
okItem.setText( i18n("&Insert") );
......@@ -50,7 +58,8 @@ KoCharSelectDia::KoCharSelectDia( QWidget *parent, const char *name, const QChar
}
KoCharSelectDia::KoCharSelectDia( QWidget *parent, const char *name, const QString &_font, const QChar &_chr, bool _modal )
: KDialog( parent )
: KDialog( parent ),
d(new Private())
{
setCaption( i18n("Select Character") );
setModal( _modal );
......@@ -58,37 +67,38 @@ KoCharSelectDia::KoCharSelectDia( QWidget *parent, const char *name, const QStri
setDefaultButton( User1 );
setObjectName( name );
initDialog(_chr,_font,true);
initDialog(_chr,_font);
setButtonText( User1, i18n("&Insert") );
setButtonToolTip( User1, i18n("Insert the selected character in the text") );
connect(this,SIGNAL(user1Clicked()),this,SLOT(slotUser1()));
}
void KoCharSelectDia::initDialog(const QChar &_chr, const QString &_font, bool /*_enableFont*/)
void KoCharSelectDia::initDialog(const QChar &_chr, const QString &_font)
{
QWidget *page = mainWidget()/*plainPage()*/;
grid = new QGridLayout( page );
QGridLayout *grid = new QGridLayout( page );
grid->setMargin(0);
grid->setSpacing(KDialog::spacingHint());
charSelect = new KCharSelect( page );
charSelect->setCurrentChar( _chr );
charSelect->setCurrentFont( QFont(_font) );
connect(charSelect, SIGNAL(charSelected()),this, SLOT(slotDoubleClicked()));
charSelect->resize( charSelect->sizeHint() );
// charSelect->enableFontCombo( true );
grid->addWidget( charSelect, 0, 0 );
d->charSelect = new KCharSelect( page );
d->charSelect->setCurrentChar( _chr );
d->charSelect->setCurrentFont( QFont(_font) );
connect(d->charSelect, SIGNAL(charSelected()),this, SLOT(slotDoubleClicked()));
d->charSelect->resize( d->charSelect->sizeHint() );
// d->charSelect->enableFontCombo( true );
grid->addWidget( d->charSelect, 0, 0 );
grid->addItem( new QSpacerItem( charSelect->width(), 0 ), 0, 0 );
grid->addItem( new QSpacerItem( 0, charSelect->height() ), 0, 0 );
grid->addItem( new QSpacerItem( d->charSelect->width(), 0 ), 0, 0 );
grid->addItem( new QSpacerItem( 0, d->charSelect->height() ), 0, 0 );
grid->setRowStretch( 0, 0 );
charSelect->setFocus();
d->charSelect->setFocus();
}
KoCharSelectDia::~KoCharSelectDia()
{
delete d;
}
void KoCharSelectDia::closeDialog()
......@@ -96,11 +106,12 @@ void KoCharSelectDia::closeDialog()
KDialog::close();
}
bool KoCharSelectDia::selectChar( QString &_font, QChar &_chr, bool _enableFont, QWidget* parent, const char* name )
// static
bool KoCharSelectDia::selectChar( QString &_font, QChar &_chr, QWidget* parent, const char* name)
{
bool res = false;
KoCharSelectDia *dlg = new KoCharSelectDia( parent, name, _chr, _font, _enableFont );
KoCharSelectDia *dlg = new KoCharSelectDia( parent, name, _chr, _font);
dlg->setFocus();
if ( dlg->exec() == Accepted )
{
......@@ -116,12 +127,12 @@ bool KoCharSelectDia::selectChar( QString &_font, QChar &_chr, bool _enableFont,
QChar KoCharSelectDia::chr() const
{
return charSelect->currentChar();
return d->charSelect->currentChar();
}
QString KoCharSelectDia::font() const
{
return charSelect->font().family();
return d->charSelect->font().family();
}
void KoCharSelectDia::slotUser1()
......
/* This file is part of the KDE project
Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
Copyright (C) 2007 Thomas Zander <zander@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......@@ -29,48 +30,52 @@ class QPushButton;
class KCharSelect;
class KButtonBox;
/******************************************************************/
/* class KoCharSelectDia */
/******************************************************************/
/**
* A dialog for selecting a character.
*/
class KOFFICEUI_EXPORT KoCharSelectDia : public KDialog
{
Q_OBJECT
public:
// constructor - destructor
// constructor
KoCharSelectDia( QWidget *parent, const char *name, const QChar &_chr,
const QString &_font, bool _enableFont, bool _modal=true );
const QString &_font, bool _modal=true );
//constructor when you want to insert multi char
KoCharSelectDia( QWidget *parent, const char *name, const QString &_font,
const QChar &_chr, bool _modal=true );
~KoCharSelectDia();
// select char dialog
KOFFICEUI_EXPORT static bool selectChar( QString &_font, QChar &_chr, bool _enableFont = true, QWidget* parent = 0, const char* name = 0);
/**
* Shows the selection dialog and returns true if user pressed ok, after filling the font and character parameters.
* @param font will be filled when the user pressed Ok with the selected font.
* @param character will be filled when the user pressed Ok with the selected character.
* @param parent the parent widget this dialog will be associated with.
*/
KOFFICEUI_EXPORT static bool selectChar( QString &font, QChar &character, QWidget* parent = 0, const char* name = 0);
signals:
/**
* Emitted when the user presses the 'insert' button.
* @param character the character that the user selected
* @param font the font name that was selected when the user inserted the character.
*/
void insertChar(QChar character ,const QString &font);
// internal
private:
void initDialog(const QChar &_chr, const QString &_font);
QChar chr() const;
QString font() const;
void closeDialog();
private:
void initDialog(const QChar &_chr, const QString &_font, bool _enableFont);
private slots:
void slotUser1();
void slotDoubleClicked();
protected:
// dialog objects
QGridLayout *grid;
KButtonBox *bbox;
QPushButton *bOk, *bCancel;
KCharSelect *charSelect;
signals:
void insertChar(QChar,const QString &);
private:
class Private;
Private * const d;
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment