29 #include <QtGui/QLabel>
30 #include <QtGui/QCheckBox>
31 #include <QtGui/QDoubleSpinBox>
32 #include <QtGui/QDateEdit>
33 #include <QtGui/QPixmap>
34 #include <QtGui/QImage>
35 #include <QtGui/QLayout>
36 #include <QtGui/QSizePolicy>
37 #include <QtGui/QDoubleValidator>
39 class KFileMetaInfoWidgetPrivate
70 :
QWidget(parent), d(new KFileMetaInfoWidgetPrivate(this))
72 d->m_value = item.
value();
82 :
QWidget(parent), d(new KFileMetaInfoWidgetPrivate(this))
84 d->m_value = item.
value();
93 kDebug(7033) << "*** item " << m_item.name()
94 << " is a " << m_value.typeName() << endl;
97 m_widget = q->makeWidget();
99 switch (m_value.type())
101 case QVariant::Image :
103 m_widget->setObjectName(QLatin1String(
"info image"));
104 static_cast<QLabel*
>(m_widget)->setPixmap(QPixmap::fromImage(m_value.value<QImage>()));
106 case QVariant::Pixmap :
108 m_widget->setObjectName(QLatin1String(
"info pixmap"));
109 static_cast<QLabel*
>(m_widget)->setPixmap(m_value.value<QPixmap>());
112 m_widget =
new QLabel(m_value.toString(), q);
113 m_widget->setObjectName(QLatin1String(
"info label"));
116 QHBoxLayout* lay =
new QHBoxLayout(q);
118 lay->addWidget(m_widget);
120 QSizePolicy sp = q->sizePolicy();
121 sp.setVerticalPolicy(QSizePolicy::Minimum);
122 q->setSizePolicy(sp);
132 return d->m_item.isEditable() && d->m_item.setValue(d->m_value);
147 return d->m_validator;
160 switch (d->m_value.type()) {
161 case QVariant::Invalid:
164 w->setObjectName(QLatin1String(
"label"));
176 case QVariant::Double:
189 case QVariant::DateTime:
195 case QVariant::String:
198 case QVariant::StringList:
200 case QVariant::Pixmap:
201 case QVariant::Brush:
203 case QVariant::Color:
204 case QVariant::Palette:
205 case QVariant::ColorGroup:
206 case QCoreVariant::Icon:
207 case QVariant::Point:
208 case QVariant::Image:
209 case QVariant::CString:
210 case QVariant::PointArray:
211 case QVariant::Region:
212 case QVariant::Bitmap:
213 case QVariant::Cursor:
214 case QVariant::ByteArray:
215 case QVariant::BitArray:
216 case QVariant::SizePolicy:
217 case QVariant::KeySequence:
223 kDebug(7033) <<
"*** item " << d->m_item.name()
224 <<
"is a " << d->m_item.value().typeName() << endl;
226 kDebug(7033) <<
" and validator is a "
227 << d->m_validator->metaObject()->className() << endl;
229 kDebug(7033) <<
"*** created a " << w->metaObject()->className()
241 QCheckBox* cb =
new QCheckBox(
this);
242 cb->setObjectName(QLatin1String(
"metainfo bool widget"));
243 cb->setChecked(d->m_item.value().toBool());
244 connect(cb, SIGNAL(toggled(
bool)),
this, SLOT(slotChanged(
bool)));
251 sb->setObjectName(QLatin1String(
"metainfo integer widget"));
252 sb->setValue(d->m_item.value().toInt());
254 if (d->m_validator) {
255 if (QIntValidator* iv = qobject_cast<QIntValidator*>(d->m_validator)) {
256 sb->setMinimum(iv->bottom());
257 sb->setMaximum(iv->top());
263 #ifndef KDE_NO_DEPRECATED
265 if (d->m_item.properties().type() == QVariant::UInt)
266 sb->setMinimum(qMax(sb->minimum(), 0));
269 connect(sb, SIGNAL(
valueChanged(
int)),
this, SLOT(slotChanged(
int)));
275 double value = d->m_item.value().toDouble();
279 value,
this, 0.01 ,2);
282 if (d->m_validator) {
283 if (
QDoubleValidator* dv = qobject_cast<QDoubleValidator*>(d->m_validator)) {
290 connect(dni, SIGNAL(
valueChanged(
double)),
this, SLOT(slotChanged(
double)));
298 b->addItems(val->stringList());
299 int i = b->findText(d->m_item.value().toString());
301 b->setCurrentIndex(i);
303 b->setEditText(d->m_item.value().toString());
304 connect(b, SIGNAL(activated(
QString)),
this, SLOT(slotComboChanged(
QString)));
305 b->setValidator(val);
310 #ifndef KDE_NO_DEPRECATED
313 edit->setAcceptRichText(
false);
314 edit->setPlainText(d->m_item.value().toString());
315 connect( edit, SIGNAL(textChanged()),
316 this, SLOT(slotMultiLineEditChanged()));
325 if (d->m_validator) {
326 e->setValidator(d->m_validator);
329 connect(e, SIGNAL(textChanged(
QString)),
330 this, SLOT(slotLineEditChanged(
QString)));
336 QWidget *e =
new QDateEdit(d->m_item.value().toDate(),
this);
338 this, SLOT(slotDateChanged(QDate)));
344 return new QTimeEdit(d->m_item.value().toTime(),
this);
349 return new QDateTimeEdit(d->m_item.value().toDateTime(),
this);
355 if ( !validator->parent() )
356 validator->setParent( widget );
363 void KFileMetaInfoWidget::slotChanged(
bool value)
365 Q_ASSERT(qobject_cast<QComboBox*>(d->m_widget));
371 void KFileMetaInfoWidget::slotChanged(
int value)
373 Q_ASSERT(qobject_cast<QSpinBox*>(d->m_widget));
379 void KFileMetaInfoWidget::slotChanged(
double value)
381 Q_ASSERT(qobject_cast<KDoubleNumInput*>(d->m_widget));
387 void KFileMetaInfoWidget::slotComboChanged(
const QString &value)
389 Q_ASSERT(qobject_cast<KComboBox*>(d->m_widget));
395 void KFileMetaInfoWidget::slotLineEditChanged(
const QString& value)
397 Q_ASSERT(qobject_cast<KLineEdit*>(d->m_widget));
404 void KFileMetaInfoWidget::slotMultiLineEditChanged()
406 Q_ASSERT(qobject_cast<KTextEdit*>(d->m_widget));
407 d->m_value =
QVariant(static_cast<const KTextEdit*>(sender())->toPlainText());
412 void KFileMetaInfoWidget::slotDateChanged(
const QDate& value)
414 Q_ASSERT(qobject_cast<QDateEdit*>(d->m_widget));
420 void KFileMetaInfoWidget::slotTimeChanged(
const QTime& value)
422 Q_ASSERT(qobject_cast<QTimeEdit*>(d->m_widget));
428 void KFileMetaInfoWidget::slotDateTimeChanged(
const QDateTime& value)
430 Q_ASSERT(qobject_cast<QDateTimeEdit*>(d->m_widget));
436 #include "kfilemetainfowidget.moc"
QString i18n(const char *text)
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
This attribute says that a string item is likely to be more than one line long, so for editing...