• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegraphics API Reference
  • KDE Home
  • Contact Us
 

okular

  • sources
  • kde-4.12
  • kdegraphics
  • okular
  • core
  • script
kjs_data.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2008 by Pino Toscano <pino@kde.org> *
3  * Copyright (C) 2008 by Harri Porten <porten@kde.org> *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  ***************************************************************************/
10 
11 #include "kjs_data_p.h"
12 
13 #include <kjs/kjsobject.h>
14 #include <kjs/kjsprototype.h>
15 
16 #include <qdatetime.h>
17 
18 #include "../document.h"
19 
20 using namespace Okular;
21 
22 static KJSPrototype *g_dataProto;
23 
24 static KJSObject dataGetCreationDate( KJSContext *ctx, void *object )
25 {
26  const EmbeddedFile *file = reinterpret_cast< EmbeddedFile * >( object );
27 
28  return KJSDate( ctx, file->creationDate() );
29 }
30 
31 static KJSObject dataGetDescription( KJSContext *, void *object )
32 {
33  const EmbeddedFile *file = reinterpret_cast< EmbeddedFile * >( object );
34 
35  return KJSString( file->description() );
36 }
37 
38 static KJSObject dataGetMIMEType( KJSContext *, void * )
39 {
40  return KJSString( "" );
41 }
42 
43 static KJSObject dataGetModDate( KJSContext *ctx, void *object )
44 {
45  const EmbeddedFile *file = reinterpret_cast< EmbeddedFile * >( object );
46 
47  return KJSDate( ctx, file->modificationDate() );
48 }
49 
50 static KJSObject dataGetName( KJSContext *, void *object )
51 {
52  const EmbeddedFile *file = reinterpret_cast< EmbeddedFile * >( object );
53 
54  return KJSString( file->name() );
55 }
56 
57 static KJSObject dataGetPath( KJSContext *, void * )
58 {
59  return KJSString( "" );
60 }
61 
62 static KJSObject dataGetSize( KJSContext *, void *object )
63 {
64  const EmbeddedFile *file = reinterpret_cast< EmbeddedFile * >( object );
65  return KJSNumber( file->size() );
66 }
67 
68 void JSData::initType( KJSContext *ctx )
69 {
70  static bool initialized = false;
71  if ( initialized )
72  return;
73  initialized = true;
74 
75  if ( !g_dataProto )
76  g_dataProto = new KJSPrototype();
77 
78  g_dataProto->defineProperty( ctx, "creationDate", dataGetCreationDate );
79  g_dataProto->defineProperty( ctx, "description", dataGetDescription );
80  g_dataProto->defineProperty( ctx, "MIMEType", dataGetMIMEType );
81  g_dataProto->defineProperty( ctx, "modDate", dataGetModDate );
82  g_dataProto->defineProperty( ctx, "name", dataGetName );
83  g_dataProto->defineProperty( ctx, "path", dataGetPath );
84  g_dataProto->defineProperty( ctx, "size", dataGetSize );
85 }
86 
87 KJSObject JSData::wrapFile( KJSContext *ctx, EmbeddedFile *f )
88 {
89  return g_dataProto->constructObject( ctx, f );
90 }
dataGetMIMEType
static KJSObject dataGetMIMEType(KJSContext *, void *)
Definition: kjs_data.cpp:38
Okular::EmbeddedFile::modificationDate
virtual QDateTime modificationDate() const =0
Returns the modification date of the file, or an invalid date if not available.
g_dataProto
static KJSPrototype * g_dataProto
Definition: kjs_data.cpp:22
dataGetDescription
static KJSObject dataGetDescription(KJSContext *, void *object)
Definition: kjs_data.cpp:31
dataGetSize
static KJSObject dataGetSize(KJSContext *, void *object)
Definition: kjs_data.cpp:62
Okular::EmbeddedFile
An embedded file into the document.
Definition: document.h:1178
Okular::EmbeddedFile::name
virtual QString name() const =0
Returns the name of the file.
Okular::JSData::initType
static void initType(KJSContext *ctx)
Definition: kjs_data.cpp:68
dataGetModDate
static KJSObject dataGetModDate(KJSContext *ctx, void *object)
Definition: kjs_data.cpp:43
dataGetCreationDate
static KJSObject dataGetCreationDate(KJSContext *ctx, void *object)
Definition: kjs_data.cpp:24
dataGetName
static KJSObject dataGetName(KJSContext *, void *object)
Definition: kjs_data.cpp:50
dataGetPath
static KJSObject dataGetPath(KJSContext *, void *)
Definition: kjs_data.cpp:57
Okular::EmbeddedFile::size
virtual int size() const =0
Returns the size (in bytes) of the file, if available, or -1 otherwise.
Okular::EmbeddedFile::creationDate
virtual QDateTime creationDate() const =0
Returns the creation date of the file, or an invalid date if not available.
Okular::EmbeddedFile::description
virtual QString description() const =0
Returns the description of the file, or an empty string if not available.
kjs_data_p.h
Okular::JSData::wrapFile
static KJSObject wrapFile(KJSContext *ctx, EmbeddedFile *f)
Definition: kjs_data.cpp:87
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:45:02 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

okular

Skip menu "okular"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdegraphics API Reference

Skip menu "kdegraphics API Reference"
  •     libkdcraw
  •     libkexiv2
  •     libkipi
  •     libksane
  • okular

Search



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