2 * Copyright 2009 Parker Coates <parker.coates@gmail.com>
4 * This file is part of Killbots.
6 * Killbots is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 2 of the License, or
9 * (at your option) any later version.
11 * Killbots is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with Killbots. If not, see <http://www.gnu.org/licenses/>.
20 #include "rulesetdetailsdialog.h"
24 #include <KDE/KLocale>
26 #include <QtGui/QFormLayout>
27 #include <QtGui/QLabel>
28 #include <QtGui/QScrollArea>
30 const QStringList
Killbots::RulesetDetailsDialog::maskedItems
= QStringList() << "Name" << "Author" << "AuthorContact" << "Description";
31 const QStringList
Killbots::RulesetDetailsDialog::junkheapEnumText
= QStringList()
32 << i18nc("Quantity of junkheaps that can be pushed", "None")
33 << i18nc("Quantity of junkheaps that can be pushed", "One")
34 << i18nc("Quantity of junkheaps that can be pushed", "Many");
37 Killbots::RulesetDetailsDialog::RulesetDetailsDialog( QWidget
* parent
)
40 setButtons( KDialog::Close
);
44 void Killbots::RulesetDetailsDialog::loadRuleset( const Ruleset
* ruleset
)
46 if ( m_labels
.size() == 0 )
48 // QScrollArea * scroll = new QScrollArea( this );
49 QWidget
* widget
= new QWidget();
50 QFormLayout
* layout
= new QFormLayout( widget
);
52 foreach ( const KConfigSkeletonItem
* item
, ruleset
->items() )
54 if ( !maskedItems
.contains( item
->name() ) )
56 QString labelText
= item
->label().isEmpty() ? item
->name() : item
->label();
57 labelText
= i18nc( "%1 is a pretranslated string that we're turning into a label", "%1:", labelText
);
59 QLabel
* valueLabel
= new QLabel();
60 m_labels
[ item
->name() ] = valueLabel
;
61 layout
->addRow( new QLabel( labelText
), valueLabel
);
64 // widget->adjustSize();
65 // scroll->setWidget( widget );
66 // scroll->setWidgetResizable( true );
67 // scroll->setAlignment( Qt::AlignHCenter | Qt:: AlignTop );
68 // scroll->resize( widget->size() );
69 // setMainWidget( scroll );
70 setMainWidget( widget
);
73 foreach ( const KConfigSkeletonItem
* item
, ruleset
->items() )
75 if ( !maskedItems
.contains( item
->name() ) )
78 if ( dynamic_cast<const KCoreConfigSkeleton::ItemBool
*>( item
) )
79 valueText
= item
->property().toBool() ? i18n("Yes") : i18n("No");
80 else if ( item
->name() == "PushableJunkheaps" )
81 valueText
= junkheapEnumText
.at( item
->property().toInt() );
83 valueText
= item
->property().toString();
85 m_labels
.value( item
->name() )->setText( valueText
);
89 setCaption( i18n("Details of %1 Game Type", ruleset
->name() ) );