00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "filedialog_binding.h"
00023
00024 #include <QtCore/QStringList>
00025 #include <QtCore/QProcess>
00026 #include <QtGui/QFileDialog>
00027 #include <QtCore/QDebug>
00028
00029 #include <kjs/object.h>
00030
00031 #include "static_binding.h"
00032
00033 using namespace KJSEmbed;
00034
00035 KJS::JSValue *callGetExistingDirectory( KJS::ExecState *exec, KJS::JSObject * , const KJS::List &args )
00036 {
00037 QWidget *parent = KJSEmbed::extractObject<QWidget>(exec, args, 0, 0);
00038 QString caption = KJSEmbed::extractVariant<QString>(exec, args, 1, QString());
00039 QString dir = KJSEmbed::extractVariant<QString>(exec, args, 2, QString());
00040 QFileDialog::Options options = (QFileDialog::Options)KJSEmbed::extractVariant<uint>(exec, args, 3, QFileDialog::ShowDirsOnly);
00041
00042 return KJS::jsString( QFileDialog::getExistingDirectory(parent, caption, dir, options) );
00043 }
00044
00045 KJS::JSValue *callGetOpenFileName( KJS::ExecState *exec, KJS::JSObject * , const KJS::List &args )
00046 {
00047 QWidget *parent = KJSEmbed::extractObject<QWidget>(exec, args, 0, 0);
00048 QString caption = KJSEmbed::extractVariant<QString>(exec, args, 1, "");
00049 QString dir = KJSEmbed::extractVariant<QString>(exec, args, 2, "");
00050 QString filter = KJSEmbed::extractVariant<QString>(exec, args, 3, "");
00051
00052 QFileDialog::Options options = (QFileDialog::Options)KJSEmbed::extractVariant<uint>(exec, args, 4, 0);
00053
00054 return KJS::jsString( QFileDialog::getOpenFileName(parent, caption, dir, filter, 0, options) );
00055 }
00056
00057 KJS::JSValue *callGetOpenFileNames( KJS::ExecState *exec, KJS::JSObject * , const KJS::List &args )
00058 {
00059 QWidget *parent = KJSEmbed::extractObject<QWidget>(exec, args, 0, 0);
00060 QString caption = KJSEmbed::extractVariant<QString>(exec, args, 1, QString());
00061 QString dir = KJSEmbed::extractVariant<QString>(exec, args, 2, QString());
00062 QString filter = KJSEmbed::extractVariant<QString>(exec, args, 3, QString());
00063
00064 QFileDialog::Options options = (QFileDialog::Options)KJSEmbed::extractVariant<uint>(exec, args, 4, 0);
00065
00066 QStringList fileNames = QFileDialog::getOpenFileNames(parent, caption, dir, filter, 0, options);
00067
00068 return convertToValue(exec, fileNames);
00069 }
00070
00071 KJS::JSValue *callGetSaveFileName( KJS::ExecState *exec, KJS::JSObject * , const KJS::List &args )
00072 {
00073 QWidget *parent = KJSEmbed::extractObject<QWidget>(exec, args, 0, 0);
00074 QString caption = KJSEmbed::extractVariant<QString>(exec, args, 1, QString());
00075 QString dir = KJSEmbed::extractVariant<QString>(exec, args, 2, QString());
00076 QString filter = KJSEmbed::extractVariant<QString>(exec, args, 3, QString());
00077
00078 QFileDialog::Options options = (QFileDialog::Options)KJSEmbed::extractVariant<uint>(exec, args, 4, 0);
00079
00080 return KJS::jsString( QFileDialog::getSaveFileName(parent, caption, dir, filter, 0, options) );
00081 }
00082 const Method FileDialog::FileDialogMethods[] =
00083 {
00084 {"getExistingDirectory", 1, KJS::DontDelete|KJS::ReadOnly, &callGetExistingDirectory },
00085 {"getOpenFileName", 1, KJS::DontDelete|KJS::ReadOnly, &callGetOpenFileName },
00086 {"getOpenFileNames", 1, KJS::DontDelete|KJS::ReadOnly, &callGetOpenFileNames },
00087 {"getSaveFileName", 0, KJS::DontDelete|KJS::ReadOnly, &callGetSaveFileName },
00088 {0, 0, 0, 0 }
00089 };
00090