~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to krita/plugins/extensions/metadataeditor/kis_meta_data_editor.cc

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-09-21 15:36:35 UTC
  • mfrom: (1.4.1 upstream) (60.2.11 maverick)
  • Revision ID: james.westby@ubuntu.com-20100921153635-6tejqkiro2u21ydi
Tags: 1:2.2.2-0ubuntu3
Add kubuntu_03_fix-crash-on-closing-sqlite-connection-2.2.2.diff and
kubuntu_04_support-large-memo-values-for-msaccess-2.2.2.diff as
recommended by upstream http://kexi-
project.org/wiki/wikiview/index.php@Kexi2.2_Patches.html#sqlite_stab
ility

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 *  Copyright (c) 2007 Cyrille Berger <cberger@cberger.net>
 
2
 *  Copyright (c) 2007,2010 Cyrille Berger <cberger@cberger.net>
3
3
 *
4
4
 *  This program is free software; you can redistribute it and/or modify
5
5
 *  it under the terms of the GNU Lesser General Public License as published by
33
33
#include <kis_meta_data_schema_registry.h>
34
34
 
35
35
#include "kis_entry_editor.h"
 
36
#include <qtableview.h>
 
37
#include "kis_meta_data_model.h"
 
38
#include <QHeaderView>
36
39
 
37
40
struct KisMetaDataEditor::Private {
38
41
    KisMetaData::Store* originalStore;
39
42
    KisMetaData::Store* store;
40
 
    QMultiHash<KisMetaData::Value*, KisEntryEditor*> entryEditors;
 
43
    QMultiHash<QString, KisEntryEditor*> entryEditors;
41
44
};
42
45
 
43
46
 
92
95
            const QString editorSignal = '2' + elem.attribute("editorSignal");
93
96
            const QString propertyName = elem.attribute("propertyName");
94
97
            const QString structureField = elem.attribute("structureField");
 
98
            bool ok;
 
99
            int arrayIndex = elem.attribute("arrayIndex", "-1").toInt(&ok);
 
100
            if (!ok) arrayIndex = -1;
 
101
            dbgPlugins << ppVar(editorName) << ppVar(arrayIndex);
95
102
 
96
103
            QWidget* obj = widget->findChild<QWidget*>(editorName);
97
104
            if (obj) {
100
107
                    if (!d->store->containsEntry(schema, entryName)) {
101
108
                        dbgPlugins << " Store does not have yet entry :" << entryName << " in" << schemaUri  << " ==" << schema->generateQualifiedName(entryName);
102
109
                    }
103
 
                    KisMetaData::Value& value = d->store->getEntry(schema, entryName).value();
104
 
                    KisEntryEditor* ee = 0;
105
 
                    if (value.type() == KisMetaData::Value::Structure && !structureField.isEmpty()) {
106
 
                        QMap<QString, KisMetaData::Value>* structure = value.asStructure();
107
 
                        ee = new KisEntryEditor(obj, &(*structure)[ structureField ], propertyName);
108
 
                    } else {
109
 
                        ee = new KisEntryEditor(obj, &value, propertyName);
110
 
                    }
 
110
                    QString key = schema->generateQualifiedName(entryName);
 
111
                    KisEntryEditor* ee = new KisEntryEditor(obj, d->store, key, propertyName, structureField, arrayIndex);
111
112
                    connect(obj, editorSignal.toAscii(), ee, SLOT(valueEdited()));
112
 
                    QList<KisEntryEditor*> otherEditors = d->entryEditors.values(&value);
 
113
                    QList<KisEntryEditor*> otherEditors = d->entryEditors.values(key);
113
114
                    foreach(KisEntryEditor* oe, otherEditors) {
114
115
                        connect(ee, SIGNAL(valueHasBeenEdited()), oe, SLOT(valueChanged()));
115
116
                        connect(oe, SIGNAL(valueHasBeenEdited()), ee, SLOT(valueChanged()));
116
117
                    }
117
 
                    d->entryEditors.insert(&value, ee);
 
118
                    d->entryEditors.insert(key, ee);
118
119
                } else {
119
120
                    dbgPlugins << "Unknown schema :" << schemaUri;
120
121
                }
130
131
        }
131
132
        addPage(page);
132
133
    }
 
134
 
 
135
    // Add the list page
 
136
    QTableView* tableView = new QTableView;
 
137
    KisMetaDataModel* model = new KisMetaDataModel(d->store);
 
138
    tableView->setModel(model);
 
139
    tableView->verticalHeader()->setVisible(false);
 
140
    tableView->resizeColumnsToContents();
 
141
    KPageWidgetItem *page = new KPageWidgetItem(tableView, i18n("List"));
 
142
    page->setIcon(KIcon("format-list-unordered"));
 
143
    addPage(page);
133
144
}
134
145
 
135
146
KisMetaDataEditor::~KisMetaDataEditor()