[DOC] Update d-pointer

master
Ulrich Van Den Hekke 12 years ago
parent 0039693244
commit 2cbe7fb0b0

@ -19,6 +19,7 @@
// Xinx header
#include "pluginelement.h"
#include "pluginelement_p.h"
/* PluginElement */
@ -34,9 +35,9 @@
*/
//! Initialise the plugin element
PluginElement::PluginElement() : m_isActivated(true)
PluginElement::PluginElement() : d(new PluginElementPrivate)
{
d->m_isActivated = true;
}
//! Destroy the plugin element
@ -71,7 +72,7 @@ PluginElement::~PluginElement()
*/
bool PluginElement::isActivated() const
{
return m_isActivated || (! isModifiable());
return d->m_isActivated || (! isModifiable());
}
/*!
@ -80,9 +81,9 @@ bool PluginElement::isActivated() const
*/
void PluginElement::setActivated(bool activated)
{
if (m_isActivated != activated)
if (d->m_isActivated != activated)
{
m_isActivated = activated;
d->m_isActivated = activated;
}
}

@ -27,6 +27,8 @@
#include <components-config.h>
class PluginElementPrivate;
class COMPONENTSEXPORT PluginElement
{
public:
@ -44,7 +46,7 @@ public:
virtual QString name() const = 0;
virtual QString description() const = 0;
private:
bool m_isActivated;
QScopedPointer<PluginElementPrivate> d;
};
#endif // _PLUGINELEMENT_H_

@ -0,0 +1,31 @@
/*
XINX
Copyright (C) 2007-2011 by Ulrich Van Den Hekke
xinx@shadoware.org
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful.
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#ifndef _PLUGINELEMENT_P_H_
#define _PLUGINELEMENT_P_H_
//! \private
class PluginElementPrivate
{
public:
bool m_isActivated;
};
#endif // _PLUGINELEMENT_P_H_

@ -28,7 +28,7 @@
* Ulrich Van Den Hekke ( 21/03/2007 ) Simplified version of KLineEdit from KDE4.
*/
#include "xinxlineedit.h"
#include "xinxlineedit_p.h"
#include <QStyleOption>
#include <QApplication>
@ -86,72 +86,25 @@ void XinxLineEditButton::paintEvent(QPaintEvent *event)
p.drawPixmap((width() - m_pixmap.width()) / 2, (height() - m_pixmap.height()) / 2, m_pixmap);
}
/* XinxLineEditPrivate */
/* XinxLineEdit */
/*!
* \ingroup Components
* \class XinxLineEdit
* \since 0.9.0.0
*
* \brief The class XinxLineEdit provides a line edit with a clear button.
*
* QLineEdit with an include button to clear the line edit.This class is inspired
* from the class of the KDE project.
*
* \image html xinxlineedit.png
* \image latex xinxlineedit.png
*/
/*!
* \brief Constructs a XinxLineEdit object with a default text, a parent, and a name.
*
* \param string Text to be shown in the edit widget.
* \param parent The parent widget of the line edit.
*/
XinxLineEdit::XinxLineEdit(const QString &string, QWidget *parent) : QLineEdit(string, parent)
{
init();
}
/*!
* \brief Constructs a line edit
* \param parent The parent widget of the line edit.
*/
XinxLineEdit::XinxLineEdit(QWidget *parent) : QLineEdit(parent)
{
init();
}
//! Destroys the object
XinxLineEdit::~XinxLineEdit()
{
}
/**
* \fn void XinxLineEdit::clearButtonClicked();
* \brief Emitted when the user clicked on the clear button
*/
void XinxLineEdit::init()
void XinxLineEditPrivate::init()
{
clearButton = 0;
clickInClear = false;
wideEnoughForClear = true;
clearButton = new XinxLineEditButton(this);
clearButton = new XinxLineEditButton(edit);
clearButton->setCursor(Qt::ArrowCursor);
updateClearButtonIcon(text());
updateClearButtonIcon(edit->text());
//updateClearButton();
connect(this, SIGNAL(textChanged(QString)), this, SLOT(updateClearButtonIcon(QString)));
connect(edit, SIGNAL(textChanged(QString)), this, SLOT(updateClearButtonIcon(QString)));
}
void XinxLineEdit::updateClearButtonIcon(const QString& text)
void XinxLineEditPrivate::updateClearButtonIcon(const QString& text)
{
if (isReadOnly())
if (edit->isReadOnly())
{
return;
}
@ -170,7 +123,7 @@ void XinxLineEdit::updateClearButtonIcon(const QString& text)
return;
}
if (layoutDirection() == Qt::LeftToRight)
if (edit->layoutDirection() == Qt::LeftToRight)
{
clearButton->setPixmap(QPixmap(":/images/edit-clear-locationbar-rtl.png"));
}
@ -182,20 +135,20 @@ void XinxLineEdit::updateClearButtonIcon(const QString& text)
clearButton->setVisible(text.length());
}
void XinxLineEdit::updateClearButton()
void XinxLineEditPrivate::updateClearButton()
{
if (isReadOnly())
if (edit->isReadOnly())
{
return;
}
const QSize geom = size();
const QSize geom = edit->size();
const int buttonWidth = clearButton->sizeHint().width();
const QSize newButtonSize(buttonWidth, geom.height());
const int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, this);
const int frameWidth = edit->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, edit);
const QFontMetrics fm(font());
const QFontMetrics fm(edit->font());
const int em = fm.width("m");
const bool wideEnough = geom.width() > 4 * em + buttonWidth + frameWidth;
@ -205,7 +158,7 @@ void XinxLineEdit::updateClearButton()
clearButton->resize(newButtonSize);
}
if (layoutDirection() == Qt::LeftToRight)
if (edit->layoutDirection() == Qt::LeftToRight)
{
clearButton->move(geom.width() - frameWidth - buttonWidth - 1, 0);
}
@ -217,17 +170,67 @@ void XinxLineEdit::updateClearButton()
if (wideEnough != wideEnoughForClear)
{
wideEnoughForClear = wideEnough;
updateClearButtonIcon(text());
updateClearButtonIcon(edit->text());
}
}
/* XinxLineEdit */
/*!
* \ingroup Components
* \class XinxLineEdit
* \since 0.9.0.0
*
* \brief The class XinxLineEdit provides a line edit with a clear button.
*
* QLineEdit with an include button to clear the line edit.This class is inspired
* from the class of the KDE project.
*
* \image html xinxlineedit.png
* \image latex xinxlineedit.png
*/
/*!
* \brief Constructs a XinxLineEdit object with a default text, a parent, and a name.
*
* \param string Text to be shown in the edit widget.
* \param parent The parent widget of the line edit.
*/
XinxLineEdit::XinxLineEdit(const QString &string, QWidget *parent) : QLineEdit(string, parent), d(new XinxLineEditPrivate)
{
d->edit = this;
d->init();
}
/*!
* \brief Constructs a line edit
* \param parent The parent widget of the line edit.
*/
XinxLineEdit::XinxLineEdit(QWidget *parent) : QLineEdit(parent), d(new XinxLineEditPrivate)
{
d->edit = this;
d->init();
}
//! Destroys the object
XinxLineEdit::~XinxLineEdit()
{
}
/**
* \fn void XinxLineEdit::clearButtonClicked();
* \brief Emitted when the user clicked on the clear button
*/
/*!
* Re-implemented for internal reasons. API not affected.
* \sa QLineEdit::resizeEvent().
*/
void XinxLineEdit::resizeEvent(QResizeEvent * ev)
{
updateClearButton();
d->updateClearButton();
QLineEdit::resizeEvent(ev);
}
@ -237,9 +240,9 @@ void XinxLineEdit::resizeEvent(QResizeEvent * ev)
*/
void XinxLineEdit::mousePressEvent(QMouseEvent* e)
{
if ((e->button() == Qt::LeftButton || e->button() == Qt::MidButton) && clearButton)
if ((e->button() == Qt::LeftButton || e->button() == Qt::MidButton) && d->clearButton)
{
clickInClear = clearButton->underMouse();
d->clickInClear = d->clearButton->underMouse();
}
QLineEdit::mousePressEvent(e);
@ -251,9 +254,9 @@ void XinxLineEdit::mousePressEvent(QMouseEvent* e)
*/
void XinxLineEdit::mouseReleaseEvent(QMouseEvent* e)
{
if (clickInClear)
if (d->clickInClear)
{
if (clearButton->underMouse())
if (d->clearButton->underMouse())
{
setSelection(0, text().size());
del();
@ -261,7 +264,7 @@ void XinxLineEdit::mouseReleaseEvent(QMouseEvent* e)
emit textChanged(QString());
}
clickInClear = false;
d->clickInClear = false;
e->accept();
return;
}

@ -41,23 +41,7 @@
#include <components-config.h>
class COMPONENTSEXPORT XinxLineEditButton : public QWidget
{
Q_OBJECT
public:
XinxLineEditButton(QWidget *parent);
QSize sizeHint() const;
void setPixmap(const QPixmap & p);
QPixmap pixmap();
protected:
void paintEvent(QPaintEvent *event);
private:
QPixmap m_pixmap;
};
class XinxLineEditPrivate;
class COMPONENTSEXPORT XinxLineEdit : public QLineEdit
{
@ -67,24 +51,17 @@ public:
explicit XinxLineEdit(QWidget *parent = 0);
virtual ~XinxLineEdit();
Q_SIGNALS:
signals:
void clearButtonClicked();
protected:
virtual void resizeEvent(QResizeEvent *);
virtual void mousePressEvent(QMouseEvent *);
virtual void mouseReleaseEvent(QMouseEvent *);
private Q_SLOTS:
void updateClearButtonIcon(const QString&);
private:
void init();
void updateClearButton();
bool clickInClear;
bool wideEnoughForClear;
XinxLineEditButton *clearButton;
QSharedPointer<XinxLineEditPrivate> d;
friend class XinxLineEditPrivate;
};
#endif

@ -0,0 +1,75 @@
/* This file is part of the KDE libraries
This class was originally inspired by Torben Weis'
fileentry.cpp for KFM II.
Copyright (C) 1997 Sven Radej <sven.radej@iname.com>
Copyright (c) 1999 Patrick Ward <PAT_WARD@HP-USA-om5.om.hp.com>
Copyright (c) 1999 Preston Brown <pbrown@kde.org>
Completely re-designed:
Copyright (c) 2000,2001 Dawit Alemayehu <adawit@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License (LGPL) 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
/*
* Ulrich Van Den Hekke ( 21/03/2007 ) Simplified version of KLineEdit from KDE4.
*/
#pragma once
#ifndef XINXLINEEDIT_P_H
#define XINXLINEEDIT_P_H
#include "xinxlineedit.h"
//! \private
class XinxLineEditButton : public QWidget
{
Q_OBJECT
public:
XinxLineEditButton(QWidget *parent);
QSize sizeHint() const;
void setPixmap(const QPixmap & p);
QPixmap pixmap();
protected:
void paintEvent(QPaintEvent *event);
private:
QPixmap m_pixmap;
};
//! \private
class XinxLineEditPrivate : public QObject
{
Q_OBJECT
public slots:
void updateClearButtonIcon(const QString&);
public:
void init();
void updateClearButton();
bool clickInClear;
bool wideEnoughForClear;
XinxLineEditButton *clearButton;
XinxLineEdit *edit;
};
#endif /* XINXLINEEDIT_P_H */

@ -58,12 +58,12 @@ public:
void add(const QString & value);
QString currentItem() const;
protected:
virtual QString addNewValue();
signals:
void defaultValueChanged(QString value);
void currentRowChanged(int value);
void itemChanged(const QString & text);
protected:
virtual QString addNewValue();
private:
QScopedPointer<XinxListWidgetImplPrivate> d;
friend class XinxListWidgetImplPrivate;

Loading…
Cancel
Save