~ubuntu-branches/ubuntu/wily/psi/wily-proposed

« back to all changes in this revision

Viewing changes to src/tools/optionstree/varianttree.cpp

  • Committer: Package Import Robot
  • Author(s): Jan Niehusmann
  • Date: 2014-07-01 21:49:34 UTC
  • mfrom: (6.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20140701214934-gt4dkgm94byi4vnn
Tags: 0.15-1
* New upstream version
* set debhelper compat level to 9
* set Standards-Version to 3.9.5 (no further changes)
* add lintian override regarding license-problem-non-free-RFC
* use qconf to regenerate configure script
* implement hardening using buildflags instead of hardening-wrapper

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 *
15
15
 * You should have received a copy of the GNU General Public License
16
16
 * along with this library; if not, write to the Free Software
17
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
18
 *
19
19
 */
20
20
 
27
27
#include <QDomDocumentFragment>
28
28
#include <QKeySequence>
29
29
#include <QStringList>
30
 
#include <QtDebug>
 
30
#include <QColor>
31
31
#include "xmpp/base64/base64.h"
32
32
 
33
33
using namespace XMPP;
115
115
                {
116
116
                        if (values_.contains(key))
117
117
                        {
118
 
                                qWarning() << QString("Error: Trying to add option node %1 but it already exists as a value").arg(key);
 
118
                                qWarning("Error: Trying to add option node %s but it already exists as a value", qPrintable(key));
119
119
                                return;
120
120
                        }
121
121
                        //create a new tier
128
128
                Q_ASSERT(isValidNodeName(node));
129
129
                if (trees_.contains(node))
130
130
                {
131
 
                        qWarning() << QString("Error: Trying to add option value %1 but it already exists as a subtree").arg(node);
 
131
                        qWarning("Error: Trying to add option value %s but it already exists as a subtree", qPrintable(node));
132
132
                        return;
133
133
                }
134
134
                values_[node]=value;
166
166
                        return trees_[key]->remove(subnode, internal_nodes);
167
167
                }
168
168
        } else {
 
169
                VariantTree *tree;
169
170
                //this tier
170
171
                if (values_.contains(node)) {
171
172
                        values_.remove(node);
172
173
                        return true;
173
 
                } else if (internal_nodes && trees_.contains(node)) {
174
 
                        trees_.remove(node);
 
174
                } else if (internal_nodes && (tree = trees_.take(node))) {
 
175
                        delete tree;
175
176
                        return true;
176
177
                }
177
178
        }
215
216
                {
216
217
                        if (values_.contains(key))
217
218
                        {
218
 
                                qWarning() << QString("Error: Trying to add option node %1 but it already exists as a value").arg(key);
 
219
                                qWarning("Error: Trying to add option node %s but it already exists as a value", qPrintable(key));
219
220
                                return;
220
221
                        }
221
222
                        //create a new tier
495
496
void VariantTree::variantToElement(const QVariant& var, QDomElement& e)
496
497
{
497
498
        QString type = var.typeName();
 
499
        // TODO use switch from QVariant::type()
498
500
        if (type == "QVariantList") {
499
501
                foreach(QVariant v, var.toList()) {
500
502
                        QDomElement item_element = e.ownerDocument().createElement("item");
543
545
                QDomText text = e.ownerDocument().createTextNode(k.toString());
544
546
                e.appendChild(text);
545
547
        }
 
548
        else if (type == "QColor") { // save invalid colors as empty string
 
549
                if (var.value<QColor>().isValid()) {
 
550
                        QDomText text = e.ownerDocument().createTextNode(var.toString());
 
551
                        e.appendChild(text);
 
552
                }
 
553
        }
546
554
        else {
547
555
                QDomText text = e.ownerDocument().createTextNode(var.toString());
548
556
                e.appendChild(text);