mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 10:22:48 +00:00
kdeui: format and indent
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
942e50f279
commit
c23e68ad4d
2 changed files with 406 additions and 429 deletions
|
@ -43,10 +43,14 @@ K_GLOBAL_STATIC(MyHash, s_changedMap)
|
|||
// see kdebug.areas
|
||||
static const int s_kconfigdialogmanagerarea = 300;
|
||||
|
||||
class KConfigDialogManager::Private {
|
||||
|
||||
class KConfigDialogManager::Private
|
||||
{
|
||||
public:
|
||||
Private(KConfigDialogManager *q) : q(q), insideGroupBox(false) { }
|
||||
Private(KConfigDialogManager *q)
|
||||
: q(q),
|
||||
insideGroupBox(false)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
KConfigDialogManager *q;
|
||||
|
@ -59,16 +63,17 @@ public:
|
|||
/**
|
||||
* Dialog being managed
|
||||
*/
|
||||
QWidget *m_dialog;
|
||||
QWidget* m_dialog;
|
||||
|
||||
QHash<QString, QWidget *> knownWidget;
|
||||
QHash<QString, QWidget *> buddyWidget;
|
||||
bool insideGroupBox : 1;
|
||||
bool trackChanges : 1;
|
||||
QHash<QString, QWidget*> knownWidget;
|
||||
QHash<QString, QWidget*> buddyWidget;
|
||||
bool insideGroupBox;
|
||||
bool trackChanges;
|
||||
};
|
||||
|
||||
KConfigDialogManager::KConfigDialogManager(QWidget *parent, KCoreConfigSkeleton *conf)
|
||||
: QObject(parent), d(new Private(this))
|
||||
: QObject(parent),
|
||||
d(new Private(this))
|
||||
{
|
||||
d->m_conf = conf;
|
||||
d->m_dialog = parent;
|
||||
|
@ -76,7 +81,8 @@ KConfigDialogManager::KConfigDialogManager(QWidget *parent, KCoreConfigSkeleton
|
|||
}
|
||||
|
||||
KConfigDialogManager::KConfigDialogManager(QWidget *parent, KConfigSkeleton *conf)
|
||||
: QObject(parent), d(new Private(this))
|
||||
: QObject(parent),
|
||||
d(new Private(this))
|
||||
{
|
||||
d->m_conf = conf;
|
||||
d->m_dialog = parent;
|
||||
|
@ -90,7 +96,7 @@ KConfigDialogManager::~KConfigDialogManager()
|
|||
|
||||
void KConfigDialogManager::initMaps()
|
||||
{
|
||||
if ( s_propertyMap->isEmpty() ) {
|
||||
if (s_propertyMap->isEmpty()) {
|
||||
s_propertyMap->insert("QCheckBox", "checked");
|
||||
s_propertyMap->insert("QPushButton", "toggled");
|
||||
s_propertyMap->insert("QRadioButton", "checked");
|
||||
|
@ -128,8 +134,7 @@ void KConfigDialogManager::initMaps()
|
|||
s_propertyMap->insert("KButtonGroup", "current");
|
||||
}
|
||||
|
||||
if( s_changedMap->isEmpty() )
|
||||
{
|
||||
if (s_changedMap->isEmpty()) {
|
||||
// Katie
|
||||
s_changedMap->insert("QCheckBox", SIGNAL(stateChanged(int)));
|
||||
s_changedMap->insert("QPushButton", SIGNAL(clicked(bool)));
|
||||
|
@ -203,57 +208,58 @@ void KConfigDialogManager::addWidget(QWidget *widget)
|
|||
void KConfigDialogManager::setupWidget(QWidget *widget, KConfigSkeletonItem *item)
|
||||
{
|
||||
QVariant minValue = item->minValue();
|
||||
if (minValue.isValid())
|
||||
{
|
||||
if (minValue.isValid()) {
|
||||
// Only q3datetimeedit is using this property we can remove it if we stop supporting Qt3Support
|
||||
if (widget->metaObject()->indexOfProperty("minValue") != -1)
|
||||
if (widget->metaObject()->indexOfProperty("minValue") != -1) {
|
||||
widget->setProperty("minValue", minValue);
|
||||
if (widget->metaObject()->indexOfProperty("minimum") != -1)
|
||||
}
|
||||
if (widget->metaObject()->indexOfProperty("minimum") != -1) {
|
||||
widget->setProperty("minimum", minValue);
|
||||
}
|
||||
}
|
||||
QVariant maxValue = item->maxValue();
|
||||
if (maxValue.isValid())
|
||||
{
|
||||
if (maxValue.isValid()) {
|
||||
// Only q3datetimeedit is using that property we can remove it if we stop supporting Qt3Support
|
||||
if (widget->metaObject()->indexOfProperty("maxValue") != -1)
|
||||
if (widget->metaObject()->indexOfProperty("maxValue") != -1) {
|
||||
widget->setProperty("maxValue", maxValue);
|
||||
if (widget->metaObject()->indexOfProperty("maximum") != -1)
|
||||
}
|
||||
if (widget->metaObject()->indexOfProperty("maximum") != -1) {
|
||||
widget->setProperty("maximum", maxValue);
|
||||
}
|
||||
}
|
||||
|
||||
if (widget->whatsThis().isEmpty())
|
||||
{
|
||||
if (widget->whatsThis().isEmpty()) {
|
||||
QString whatsThis = item->whatsThis();
|
||||
if ( !whatsThis.isEmpty() )
|
||||
{
|
||||
widget->setWhatsThis(whatsThis );
|
||||
if (!whatsThis.isEmpty()) {
|
||||
widget->setWhatsThis(whatsThis);
|
||||
}
|
||||
}
|
||||
|
||||
if (widget->toolTip().isEmpty())
|
||||
{
|
||||
if (widget->toolTip().isEmpty()) {
|
||||
QString toolTip = item->toolTip();
|
||||
if ( !toolTip.isEmpty() )
|
||||
{
|
||||
if (!toolTip.isEmpty()) {
|
||||
widget->setToolTip(toolTip);
|
||||
}
|
||||
}
|
||||
|
||||
if(!item->isEqual( property(widget) ))
|
||||
setProperty( widget, item->property() );
|
||||
if (!item->isEqual(property(widget))) {
|
||||
setProperty(widget, item->property());
|
||||
}
|
||||
}
|
||||
|
||||
bool KConfigDialogManager::parseChildren(const QWidget *widget, bool trackChanges)
|
||||
{
|
||||
bool valueChanged = false;
|
||||
const QList<QObject*> listOfChildren = widget->children();
|
||||
if(listOfChildren.count()==0) //?? XXX
|
||||
if (listOfChildren.count() == 0) {
|
||||
return valueChanged;
|
||||
}
|
||||
|
||||
foreach ( QObject *object, listOfChildren )
|
||||
{
|
||||
if(!object->isWidgetType())
|
||||
continue; // Skip non-widgets
|
||||
foreach (QObject *object, listOfChildren) {
|
||||
if(!object->isWidgetType()) {
|
||||
// Skip non-widgets
|
||||
continue;
|
||||
}
|
||||
|
||||
QWidget *childWidget = static_cast<QWidget *>(object);
|
||||
|
||||
|
@ -261,86 +267,75 @@ bool KConfigDialogManager::parseChildren(const QWidget *widget, bool trackChange
|
|||
bool bParseChildren = true;
|
||||
bool bSaveInsideGroupBox = d->insideGroupBox;
|
||||
|
||||
if (widgetName.startsWith(QLatin1String("kcfg_")))
|
||||
{
|
||||
if (widgetName.startsWith(QLatin1String("kcfg_"))) {
|
||||
// This is one of our widgets!
|
||||
QString configId = widgetName.mid(5);
|
||||
KConfigSkeletonItem *item = d->m_conf->findItem(configId);
|
||||
if (item)
|
||||
{
|
||||
if (item) {
|
||||
d->knownWidget.insert(configId, childWidget);
|
||||
|
||||
setupWidget(childWidget, item);
|
||||
|
||||
if ( d->trackChanges ) {
|
||||
if (d->trackChanges) {
|
||||
QHash<QString, QByteArray>::const_iterator changedIt = s_changedMap->constFind(childWidget->metaObject()->className());
|
||||
|
||||
if (changedIt == s_changedMap->constEnd())
|
||||
{
|
||||
if (changedIt == s_changedMap->constEnd()) {
|
||||
// If the class name of the widget wasn't in the monitored widgets map, then look for
|
||||
// it again using the super class name. This fixes a problem with using QtRuby/Korundum
|
||||
// widgets with KConfigXT where 'Qt::Widget' wasn't being seen a the real deal, even
|
||||
// though it was a 'QWidget'.
|
||||
if ( childWidget->metaObject()->superClass() )
|
||||
if ( childWidget->metaObject()->superClass()) {
|
||||
changedIt = s_changedMap->constFind(childWidget->metaObject()->superClass()->className());
|
||||
else
|
||||
} else {
|
||||
changedIt = s_changedMap->constFind(QString());
|
||||
}
|
||||
|
||||
if (changedIt == s_changedMap->constEnd())
|
||||
{
|
||||
kWarning(s_kconfigdialogmanagerarea) << "Don't know how to monitor widget '" << childWidget->metaObject()->className() << "' for changes!";
|
||||
}
|
||||
else
|
||||
{
|
||||
connect(childWidget, *changedIt,
|
||||
this, SIGNAL(widgetModified()));
|
||||
|
||||
if (changedIt == s_changedMap->constEnd()) {
|
||||
kWarning(s_kconfigdialogmanagerarea) << "Don't know how to monitor widget '" << childWidget->metaObject()->className() << "' for changes!";
|
||||
} else {
|
||||
connect(childWidget, *changedIt, this, SIGNAL(widgetModified()));
|
||||
|
||||
QComboBox *cb = qobject_cast<QComboBox *>(childWidget);
|
||||
if (cb && cb->isEditable())
|
||||
connect(cb, SIGNAL(editTextChanged(QString)),
|
||||
this, SIGNAL(widgetModified()));
|
||||
connect(cb, SIGNAL(editTextChanged(QString)), this, SIGNAL(widgetModified()));
|
||||
}
|
||||
}
|
||||
QGroupBox *gb = qobject_cast<QGroupBox *>(childWidget);
|
||||
if (!gb)
|
||||
if (!gb) {
|
||||
bParseChildren = false;
|
||||
else
|
||||
} else {
|
||||
d->insideGroupBox = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
kWarning(s_kconfigdialogmanagerarea) << "A widget named '" << widgetName << "' was found but there is no setting named '" << configId << "'";
|
||||
}
|
||||
}
|
||||
else if (QLabel *label = qobject_cast<QLabel*>(childWidget))
|
||||
{
|
||||
} else if (QLabel *label = qobject_cast<QLabel*>(childWidget)) {
|
||||
QWidget *buddy = label->buddy();
|
||||
if (!buddy)
|
||||
if (!buddy) {
|
||||
continue;
|
||||
}
|
||||
QString buddyName = buddy->objectName();
|
||||
if (buddyName.startsWith(QLatin1String("kcfg_")))
|
||||
{
|
||||
if (buddyName.startsWith(QLatin1String("kcfg_"))) {
|
||||
// This is one of our widgets!
|
||||
QString configId = buddyName.mid(5);
|
||||
d->buddyWidget.insert(configId, childWidget);
|
||||
}
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
else if (!widgetName.isEmpty() && d->trackChanges)
|
||||
{
|
||||
else if (!widgetName.isEmpty() && d->trackChanges) {
|
||||
QHash<QString, QByteArray>::const_iterator changedIt = s_changedMap->constFind(childWidget->metaObject()->className());
|
||||
if (changedIt != s_changedMap->constEnd())
|
||||
{
|
||||
if (changedIt != s_changedMap->constEnd()) {
|
||||
if ((!d->insideGroupBox || !qobject_cast<QRadioButton*>(childWidget)) &&
|
||||
!qobject_cast<QGroupBox*>(childWidget) &&!qobject_cast<QTabWidget*>(childWidget) )
|
||||
!qobject_cast<QGroupBox*>(childWidget) &&!qobject_cast<QTabWidget*>(childWidget)) {
|
||||
kDebug(s_kconfigdialogmanagerarea) << "Widget '" << widgetName << "' (" << childWidget->metaObject()->className() << ") remains unmanaged.";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if(bParseChildren)
|
||||
{
|
||||
if (bParseChildren) {
|
||||
// this widget is not known as something we can store.
|
||||
// Maybe we can store one of its children.
|
||||
valueChanged |= parseChildren(childWidget, trackChanges);
|
||||
|
@ -357,36 +352,35 @@ void KConfigDialogManager::updateWidgets()
|
|||
blockSignals(true);
|
||||
|
||||
QWidget *widget;
|
||||
QHashIterator<QString, QWidget *> it( d->knownWidget );
|
||||
QHashIterator<QString, QWidget*> it(d->knownWidget);
|
||||
while(it.hasNext()) {
|
||||
it.next();
|
||||
widget = it.value();
|
||||
|
||||
KConfigSkeletonItem *item = d->m_conf->findItem(it.key());
|
||||
if (!item)
|
||||
{
|
||||
KConfigSkeletonItem* item = d->m_conf->findItem(it.key());
|
||||
if (!item) {
|
||||
kWarning(s_kconfigdialogmanagerarea) << "The setting '" << it.key() << "' has disappeared!";
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!item->isEqual( property(widget) ))
|
||||
{
|
||||
setProperty( widget, item->property() );
|
||||
// kDebug(s_kconfigdialogmanagerarea) << "The setting '" << it.key() << "' [" << widget->className() << "] has changed";
|
||||
if (!item->isEqual(property(widget))) {
|
||||
setProperty(widget, item->property());
|
||||
// kDebug(s_kconfigdialogmanagerarea) << "The setting '" << it.key() << "' [" << widget->className() << "] has changed";
|
||||
changed = true;
|
||||
}
|
||||
if (item->isImmutable())
|
||||
{
|
||||
if (item->isImmutable()) {
|
||||
widget->setEnabled(false);
|
||||
QWidget *buddy = d->buddyWidget.value(it.key(), 0);
|
||||
if (buddy)
|
||||
if (buddy) {
|
||||
buddy->setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
blockSignals(bSignalsBlocked);
|
||||
|
||||
if (changed)
|
||||
if (changed) {
|
||||
QTimer::singleShot(0, this, SIGNAL(widgetModified()));
|
||||
}
|
||||
}
|
||||
|
||||
void KConfigDialogManager::updateWidgetsDefault()
|
||||
|
@ -401,7 +395,7 @@ void KConfigDialogManager::updateSettings()
|
|||
bool changed = false;
|
||||
|
||||
QWidget *widget;
|
||||
QHashIterator<QString, QWidget *> it( d->knownWidget );
|
||||
QHashIterator<QString, QWidget*> it(d->knownWidget);
|
||||
while(it.hasNext()) {
|
||||
it.next();
|
||||
widget = it.value();
|
||||
|
@ -413,13 +407,12 @@ void KConfigDialogManager::updateSettings()
|
|||
}
|
||||
|
||||
QVariant fromWidget = property(widget);
|
||||
if(!item->isEqual( fromWidget )) {
|
||||
if(!item->isEqual(fromWidget)) {
|
||||
item->setProperty( fromWidget );
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if (changed)
|
||||
{
|
||||
if (changed) {
|
||||
d->m_conf->writeConfig();
|
||||
emit settingsChanged();
|
||||
}
|
||||
|
@ -441,15 +434,6 @@ QByteArray KConfigDialogManager::getCustomProperty(const QWidget *widget) const
|
|||
|
||||
void KConfigDialogManager::setProperty(QWidget *w, const QVariant &v)
|
||||
{
|
||||
/* QButtonGroup *bg = qobject_cast<QButtonGroup *>(w);
|
||||
if (bg)
|
||||
{
|
||||
QAbstractButton *b = bg->button(v.toInt());
|
||||
if (b)
|
||||
b->setDown(true);
|
||||
return;
|
||||
}*/
|
||||
|
||||
QByteArray customproperty = getCustomProperty(w);
|
||||
if (customproperty.isEmpty()) {
|
||||
customproperty = s_propertyMap->value(w->metaObject()->className());
|
||||
|
@ -480,10 +464,6 @@ void KConfigDialogManager::setProperty(QWidget *w, const QVariant &v)
|
|||
|
||||
QVariant KConfigDialogManager::property(QWidget *w) const
|
||||
{
|
||||
/* QButtonGroup *bg = qobject_cast<QButtonGroup *>(w);
|
||||
if (bg && bg->checkedButton())
|
||||
return QVariant(bg->id(bg->checkedButton()));*/
|
||||
|
||||
QByteArray customproperty = getCustomProperty(w);
|
||||
if (customproperty.isEmpty()) {
|
||||
customproperty = s_propertyMap->value(w->metaObject()->className());
|
||||
|
@ -509,7 +489,7 @@ QVariant KConfigDialogManager::property(QWidget *w) const
|
|||
bool KConfigDialogManager::hasChanged() const
|
||||
{
|
||||
QWidget *widget;
|
||||
QHashIterator<QString, QWidget *> it( d->knownWidget) ;
|
||||
QHashIterator<QString, QWidget*> it(d->knownWidget);
|
||||
while(it.hasNext()) {
|
||||
it.next();
|
||||
widget = it.value();
|
||||
|
@ -520,7 +500,7 @@ bool KConfigDialogManager::hasChanged() const
|
|||
continue;
|
||||
}
|
||||
|
||||
if(!item->isEqual( property(widget) )) {
|
||||
if(!item->isEqual( property(widget))) {
|
||||
// kDebug(s_kconfigdialogmanagerarea) << "Widget for '" << it.key() << "' has changed.";
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -82,9 +82,9 @@ class KConfigSkeletonItem;
|
|||
* @author Benjamin C Meyer <ben+kdelibs at meyerhome dot net>
|
||||
* @author Waldo Bastian <bastian@kde.org>
|
||||
*/
|
||||
class KDEUI_EXPORT KConfigDialogManager : public QObject {
|
||||
|
||||
Q_OBJECT
|
||||
class KDEUI_EXPORT KConfigDialogManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
|
@ -101,7 +101,7 @@ Q_SIGNALS:
|
|||
* contains the one or more modified setting.
|
||||
* @see settingsChanged()
|
||||
*/
|
||||
void settingsChanged( QWidget *widget );
|
||||
void settingsChanged(QWidget *widget);
|
||||
|
||||
/**
|
||||
* If retrieveSettings() was told to track changes then if
|
||||
|
@ -112,9 +112,7 @@ Q_SIGNALS:
|
|||
*/
|
||||
void widgetModified();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param parent Dialog widget to manage
|
||||
|
@ -155,12 +153,12 @@ public:
|
|||
/**
|
||||
* Retrieve the property map
|
||||
*/
|
||||
static QHash<QString, QByteArray> *propertyMap();
|
||||
static QHash<QString, QByteArray>* propertyMap();
|
||||
|
||||
/**
|
||||
* Retrieve the widget change map
|
||||
*/
|
||||
static QHash<QString, QByteArray> *changedMap();
|
||||
static QHash<QString, QByteArray>* changedMap();
|
||||
|
||||
public Q_SLOTS:
|
||||
/**
|
||||
|
@ -189,7 +187,6 @@ public Q_SLOTS:
|
|||
void updateWidgetsDefault();
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* @param trackChanges - If any changes by the widgets should be tracked
|
||||
* set true. This causes the emitting the modified() signal when
|
||||
|
|
Loading…
Add table
Reference in a new issue