• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

kjsembed

  • kjsembed
  • kjsembed
filedialog_binding.cpp
Go to the documentation of this file.
1/* This file is part of the KDE libraries
2 Copyright (C) 2005, 2006 Ian Reinhart Geiser <geiseri@kde.org>
3 Copyright (C) 2005, 2006 Matt Broadstone <mbroadst@gmail.com>
4 Copyright (C) 2005, 2006 Richard J. Moore <rich@kde.org>
5 Copyright (C) 2005, 2006 Erik L. Bunce <kde@bunce.us>
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
21*/
22#include "filedialog_binding.h"
23
24#include <QtCore/QStringList>
25#include <QtCore/QProcess>
26#include <QtGui/QFileDialog>
27#include <QtCore/QDebug>
28
29#include <kjs/object.h>
30
31#include "static_binding.h"
32
33using namespace KJSEmbed;
34
35KJS::JSValue *callGetExistingDirectory( KJS::ExecState *exec, KJS::JSObject * /*self*/, const KJS::List &args )
36{
37 QWidget *parent = KJSEmbed::extractObject<QWidget>(exec, args, 0, 0);
38 QString caption = KJSEmbed::extractVariant<QString>(exec, args, 1, QString());
39 QString dir = KJSEmbed::extractVariant<QString>(exec, args, 2, QString());
40 QFileDialog::Options options = (QFileDialog::Options)KJSEmbed::extractVariant<uint>(exec, args, 3, QFileDialog::ShowDirsOnly);
41
42 return KJS::jsString( QFileDialog::getExistingDirectory(parent, caption, dir, options) );
43}
44
45KJS::JSValue *callGetOpenFileName( KJS::ExecState *exec, KJS::JSObject * /*self*/, const KJS::List &args )
46{
47 QWidget *parent = KJSEmbed::extractObject<QWidget>(exec, args, 0, 0);
48 QString caption = KJSEmbed::extractVariant<QString>(exec, args, 1, "");
49 QString dir = KJSEmbed::extractVariant<QString>(exec, args, 2, "");
50 QString filter = KJSEmbed::extractVariant<QString>(exec, args, 3, "");
51// QString *selectedFilter = KJSEmbed::extractVariant<QString>(exec, args, 4, 0);
52 QFileDialog::Options options = (QFileDialog::Options)KJSEmbed::extractVariant<uint>(exec, args, 4, 0);
53
54 return KJS::jsString( QFileDialog::getOpenFileName(parent, caption, dir, filter, 0, options) );
55}
56
57KJS::JSValue *callGetOpenFileNames( KJS::ExecState *exec, KJS::JSObject * /*self*/, const KJS::List &args )
58{
59 QWidget *parent = KJSEmbed::extractObject<QWidget>(exec, args, 0, 0);
60 QString caption = KJSEmbed::extractVariant<QString>(exec, args, 1, QString());
61 QString dir = KJSEmbed::extractVariant<QString>(exec, args, 2, QString());
62 QString filter = KJSEmbed::extractVariant<QString>(exec, args, 3, QString());
63// QString *selectedFilter = KJSEmbed::extractVariant<QString>(exec, args, 4, 0);
64 QFileDialog::Options options = (QFileDialog::Options)KJSEmbed::extractVariant<uint>(exec, args, 4, 0);
65
66 QStringList fileNames = QFileDialog::getOpenFileNames(parent, caption, dir, filter, 0, options);
67
68 return convertToValue(exec, fileNames);
69}
70
71KJS::JSValue *callGetSaveFileName( KJS::ExecState *exec, KJS::JSObject * /*self*/, const KJS::List &args )
72{
73 QWidget *parent = KJSEmbed::extractObject<QWidget>(exec, args, 0, 0);
74 QString caption = KJSEmbed::extractVariant<QString>(exec, args, 1, QString());
75 QString dir = KJSEmbed::extractVariant<QString>(exec, args, 2, QString());
76 QString filter = KJSEmbed::extractVariant<QString>(exec, args, 3, QString());
77// QString *selectedFilter = KJSEmbed::extractVariant<QString>(exec, args, 4, 0);
78 QFileDialog::Options options = (QFileDialog::Options)KJSEmbed::extractVariant<uint>(exec, args, 4, 0);
79
80 return KJS::jsString( QFileDialog::getSaveFileName(parent, caption, dir, filter, 0, options) );
81}
82const Method FileDialog::FileDialogMethods[] =
83{
84 {"getExistingDirectory", 1, KJS::DontDelete|KJS::ReadOnly, &callGetExistingDirectory },
85 {"getOpenFileName", 1, KJS::DontDelete|KJS::ReadOnly, &callGetOpenFileName },
86 {"getOpenFileNames", 1, KJS::DontDelete|KJS::ReadOnly, &callGetOpenFileNames },
87 {"getSaveFileName", 0, KJS::DontDelete|KJS::ReadOnly, &callGetSaveFileName },
88 {0, 0, 0, 0 }
89};
90//kate: indent-spaces on; indent-width 4; replace-tabs on; indent-mode cstyle;
KJSEmbed::FileDialog::FileDialogMethods
static const Method FileDialogMethods[]
Definition: filedialog_binding.h:35
QWidget
callGetSaveFileName
KJS::JSValue * callGetSaveFileName(KJS::ExecState *exec, KJS::JSObject *, const KJS::List &args)
Definition: filedialog_binding.cpp:71
callGetExistingDirectory
KJS::JSValue * callGetExistingDirectory(KJS::ExecState *exec, KJS::JSObject *, const KJS::List &args)
Definition: filedialog_binding.cpp:35
callGetOpenFileName
KJS::JSValue * callGetOpenFileName(KJS::ExecState *exec, KJS::JSObject *, const KJS::List &args)
Definition: filedialog_binding.cpp:45
callGetOpenFileNames
KJS::JSValue * callGetOpenFileNames(KJS::ExecState *exec, KJS::JSObject *, const KJS::List &args)
Definition: filedialog_binding.cpp:57
filedialog_binding.h
KJSEmbed
Definition: application.h:33
KJSEmbed::convertToValue
KJSEMBED_EXPORT KJS::JSValue * convertToValue(KJS::ExecState *exec, const QVariant &value)
Convert a QVariant to a KJS::JSValue.
Definition: variant_binding.cpp:298
KJS::jsString
KJS::JSCell * jsString(const QString &s)
Definition: kjseglobal.h:73
parent
QObject * parent
Definition: qaction_binding.cpp:48
static_binding.h
KJSEmbed::Method
Method structure.
Definition: binding_support.h:295
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kjsembed

Skip menu "kjsembed"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal