~ubuntu-branches/debian/sid/kexi/sid

« back to all changes in this revision

Viewing changes to src/plugins/forms/widgets/webbrowser/WebBrowserFactory.cpp

  • Committer: Package Import Robot
  • Author(s): Pino Toscano
  • Date: 2017-06-24 20:10:10 UTC
  • Revision ID: package-import@ubuntu.com-20170624201010-5lrzd5r2vwthwifp
Tags: upstream-3.0.1.1
ImportĀ upstreamĀ versionĀ 3.0.1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    <The basic code for the web widget in Kexi forms>
 
3
    Copyright (C) 2011  Shreya Pandit <shreya@shreyapandit.com>
 
4
 
 
5
    This library is free software; you can redistribute it and/or
 
6
    modify it under the terms of the GNU Lesser General Public
 
7
    License as published by the Free Software Foundation; either
 
8
    version 2.1 of the License, or (at your option) any later version.
 
9
 
 
10
    This library is distributed in the hope that it will be useful,
 
11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
    Lesser General Public License for more details.
 
14
 
 
15
    You should have received a copy of the GNU Lesser General Public
 
16
    License along with this library; if not, write to the Free Software
 
17
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
18
*/
 
19
 
 
20
 
 
21
#include "WebBrowserFactory.h"
 
22
#include <formeditor/WidgetInfo.h>
 
23
#include <formeditor/formIO.h>
 
24
#include "kexidataawarewidgetinfo.h"
 
25
#include "WebBrowserWidget.h"
 
26
#include <KexiIcon.h>
 
27
#include <kexi.h>
 
28
 
 
29
#include <KLocalizedString>
 
30
 
 
31
#include <QVariant>
 
32
#include <QVariantList>
 
33
#include <QDebug>
 
34
 
 
35
KEXI_PLUGIN_FACTORY(WebBrowserFactory, "kexiforms_webbrowserwidgetplugin.json")
 
36
 
 
37
WebBrowserFactory::WebBrowserFactory(QObject* parent, const QVariantList& args)
 
38
  : KexiDBFactoryBase(parent)
 
39
{
 
40
    Q_UNUSED(args);
 
41
    KexiDataAwareWidgetInfo* webBrowser = new KexiDataAwareWidgetInfo(this);
 
42
    webBrowser->setIconName(koIconName("web_browser"));
 
43
    webBrowser->setClassName("WebBrowserWidget");
 
44
    webBrowser->setName(xi18n("Web Browser"));
 
45
    webBrowser->setNamePrefix(
 
46
        xi18nc("A prefix for identifiers of web browser widgets. Based on that, identifiers such as "
 
47
            "webBrowser1, webBrowser2 are generated. "
 
48
            "This string can be used to refer the widget object as variables in programming "
 
49
            "languages or macros so it must _not_ contain white spaces and non latin1 characters, "
 
50
            "should start with lower case letter and if there are subsequent words, these should "
 
51
            "start with upper case letter. Example: smallCamelCase. "
 
52
            "Moreover, try to make this prefix as short as possible.",
 
53
            "webBrowser"));
 
54
    webBrowser->setDescription(xi18n("Web widget with browsing features."));
 
55
    webBrowser->setInlineEditingEnabledWhenDataSourceSet(false);
 
56
    addClass(webBrowser);
 
57
 
 
58
    setPropertyDescription("textScale", xi18n("Text Scale"));
 
59
    setPropertyDescription("zoomFactor", xi18n("Zoom Factor"));
 
60
    setPropertyDescription("url", xi18n("Url"));
 
61
}
 
62
 
 
63
WebBrowserFactory::~WebBrowserFactory()
 
64
{
 
65
 
 
66
}
 
67
 
 
68
QWidget* WebBrowserFactory::createWidget(const QByteArray& classname,
 
69
                            QWidget* parent,
 
70
                            const char* name,
 
71
                            KFormDesigner::Container* container,
 
72
                            KFormDesigner::WidgetFactory::CreateWidgetOptions options)
 
73
{
 
74
    Q_UNUSED(options);
 
75
    QWidget *w = 0;
 
76
    QString text(container->form()->library()->textForWidgetName(name, classname));
 
77
 
 
78
    if (classname == "WebBrowserWidget")
 
79
        w = new WebBrowserWidget(parent);
 
80
 
 
81
    if (w){
 
82
        w->setObjectName(name);
 
83
        qDebug() << w << w->objectName() << "created";
 
84
        return w;
 
85
    }
 
86
    qWarning() << "w == 0";
 
87
    return 0;
 
88
}
 
89
 
 
90
bool WebBrowserFactory::createMenuActions(const QByteArray &classname, QWidget *w,
 
91
                                    QMenu *menu, KFormDesigner::Container *container)
 
92
{
 
93
    Q_UNUSED(classname);
 
94
    Q_UNUSED(w);
 
95
    Q_UNUSED(menu);
 
96
    Q_UNUSED(container);
 
97
    return false;
 
98
}
 
99
 
 
100
bool WebBrowserFactory::startInlineEditing(InlineEditorCreationArguments& args)
 
101
{
 
102
    Q_UNUSED(args);
 
103
    return false;
 
104
}
 
105
 
 
106
bool WebBrowserFactory::previewWidget(const QByteArray &classname,
 
107
                                QWidget *widget, KFormDesigner::Container *)
 
108
{
 
109
    Q_UNUSED(classname);
 
110
    Q_UNUSED(widget);
 
111
    return true;
 
112
}
 
113
 
 
114
#include "WebBrowserFactory.moc"