From e9ae80694875f869892f13f4fcaf1170a00dea41 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdewebdev@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- quanta/dialogs/tagdialogs/tagwidget.cpp | 119 ++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 quanta/dialogs/tagdialogs/tagwidget.cpp (limited to 'quanta/dialogs/tagdialogs/tagwidget.cpp') diff --git a/quanta/dialogs/tagdialogs/tagwidget.cpp b/quanta/dialogs/tagdialogs/tagwidget.cpp new file mode 100644 index 00000000..0d01f7a3 --- /dev/null +++ b/quanta/dialogs/tagdialogs/tagwidget.cpp @@ -0,0 +1,119 @@ +/*************************************************************************** + tagwidget.cpp - description + ------------------- + begin : Sat Apr 1 2000 + copyright : (C) 2000 by Yacovlev Alexander & Dmitry Poplavsky + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +// QT files +#include +#include +#include +#include +#include + +// KDE files +#include +#include + +// application's headers +#include "tagwidget.h" +#include "tagdialog.h" +#include "resource.h" + +TagWidget::TagWidget(QObject *parent, const char *) +{ + baseURL = ((TagDialog *)parent)->baseURL(); +} + +TagWidget::~TagWidget(){ +} + +void TagWidget::updateDict(const QString &attr, QComboBox *combo ) +{ + QString *s = new QString(combo->currentText()); + if (s->isEmpty()) + { + dict->remove(attr); + delete s; + } + else + dict->replace(attr, s); +} + +void TagWidget::setValue(const QString &val, QComboBox *combo) +{ + bool found = false; + int num = combo->count(); + + for ( int i = 0; i < num; i++) + { + if (val == combo->text(i)) + { + combo->setCurrentItem(i); + found = true; + } + } + + if (!found) + combo->setEditText(val); +} + +void TagWidget::setValue(const QString &val, QLineEdit *line) +{ + line->setText(val); +} + +void TagWidget::setValue(const QString &val, QSpinBox *spin) +{ + spin->setValue(val.toInt()); +} + +void TagWidget::setValue(const QString &val, KColorButton *button) +{ + button->setColor(val); +} + +void TagWidget::updateDict(const QString &attr, QLineEdit *line ) +{ + QString *s = new QString(line->text()); + if (s->isEmpty()) + { + dict->remove(attr); + delete s; + } + else + dict->replace(attr, s); +} + +void TagWidget::updateDict(const QString &attr, QSpinBox *spin ) +{ + QString *s = new QString(spin->text()); + if (s->isEmpty()) + { + dict->remove(attr); + delete s; + } + else + dict->replace(attr, s); +} + +void TagWidget::updateDict(const QString &attr, QCheckBox *check ) +{ + if (!check->isChecked()) + dict->remove(attr); + else + { + if (!dict->find(attr)) + dict->insert(attr, new QString("")); + } +} -- cgit v1.2.1