Qt 4.8
Public Functions | Properties | List of all members
QFileOpenEvent Class Reference

The QFileOpenEvent class provides an event that will be sent when there is a request to open a file or a URL. More...

#include <qevent.h>

Inheritance diagram for QFileOpenEvent:
QEvent

Public Functions

QString file () const
 Returns the file that is being opened. More...
 
bool openFile (QFile &file, QIODevice::OpenMode flags) const
 Opens a QFile on the file referenced by this event in the mode specified by flags. More...
 
 QFileOpenEvent (const QString &file)
 Constructs a file open event for the given file. More...
 
 QFileOpenEvent (const QUrl &url)
 Constructs a file open event for the given url. More...
 
QUrl url () const
 Returns the url that is being opened. More...
 
 ~QFileOpenEvent ()
 
- Public Functions inherited from QEvent
void accept ()
 Sets the accept flag of the event object, the equivalent of calling setAccepted(true). More...
 
void ignore ()
 Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false). More...
 
bool isAccepted () const
 
 QEvent (Type type)
 Contructs an event object of type type. More...
 
void setAccepted (bool accepted)
 
bool spontaneous () const
 Returns true if the event originated outside the application (a system event); otherwise returns false. More...
 
Type type () const
 Returns the event type. More...
 
virtual ~QEvent ()
 Destroys the event. More...
 

Properties

QString f
 

Additional Inherited Members

- Public Types inherited from QEvent
enum  Type {
  None = 0, Timer = 1, MouseButtonPress = 2, MouseButtonRelease = 3,
  MouseButtonDblClick = 4, MouseMove = 5, KeyPress = 6, KeyRelease = 7,
  FocusIn = 8, FocusOut = 9, Enter = 10, Leave = 11,
  Paint = 12, Move = 13, Resize = 14, Create = 15,
  Destroy = 16, Show = 17, Hide = 18, Close = 19,
  Quit = 20, ParentChange = 21, ParentAboutToChange = 131, ThreadChange = 22,
  WindowActivate = 24, WindowDeactivate = 25, ShowToParent = 26, HideToParent = 27,
  Wheel = 31, WindowTitleChange = 33, WindowIconChange = 34, ApplicationWindowIconChange = 35,
  ApplicationFontChange = 36, ApplicationLayoutDirectionChange = 37, ApplicationPaletteChange = 38, PaletteChange = 39,
  Clipboard = 40, Speech = 42, MetaCall = 43, SockAct = 50,
  WinEventAct = 132, DeferredDelete = 52, DragEnter = 60, DragMove = 61,
  DragLeave = 62, Drop = 63, DragResponse = 64, ChildAdded = 68,
  ChildPolished = 69, ChildRemoved = 71, ShowWindowRequest = 73, PolishRequest = 74,
  Polish = 75, LayoutRequest = 76, UpdateRequest = 77, UpdateLater = 78,
  EmbeddingControl = 79, ActivateControl = 80, DeactivateControl = 81, ContextMenu = 82,
  InputMethod = 83, AccessibilityPrepare = 86, TabletMove = 87, LocaleChange = 88,
  LanguageChange = 89, LayoutDirectionChange = 90, Style = 91, TabletPress = 92,
  TabletRelease = 93, OkRequest = 94, HelpRequest = 95, IconDrag = 96,
  FontChange = 97, EnabledChange = 98, ActivationChange = 99, StyleChange = 100,
  IconTextChange = 101, ModifiedChange = 102, MouseTrackingChange = 109, WindowBlocked = 103,
  WindowUnblocked = 104, WindowStateChange = 105, ToolTip = 110, WhatsThis = 111,
  StatusTip = 112, ActionChanged = 113, ActionAdded = 114, ActionRemoved = 115,
  FileOpen = 116, Shortcut = 117, ShortcutOverride = 51, WhatsThisClicked = 118,
  ToolBarChange = 120, ApplicationActivate = 121, ApplicationActivated = ApplicationActivate, ApplicationDeactivate = 122,
  ApplicationDeactivated = ApplicationDeactivate, QueryWhatsThis = 123, EnterWhatsThisMode = 124, LeaveWhatsThisMode = 125,
  ZOrderChange = 126, HoverEnter = 127, HoverLeave = 128, HoverMove = 129,
  AccessibilityHelp = 119, AccessibilityDescription = 130, AcceptDropsChange = 152, MenubarUpdated = 153,
  ZeroTimerEvent = 154, GraphicsSceneMouseMove = 155, GraphicsSceneMousePress = 156, GraphicsSceneMouseRelease = 157,
  GraphicsSceneMouseDoubleClick = 158, GraphicsSceneContextMenu = 159, GraphicsSceneHoverEnter = 160, GraphicsSceneHoverMove = 161,
  GraphicsSceneHoverLeave = 162, GraphicsSceneHelp = 163, GraphicsSceneDragEnter = 164, GraphicsSceneDragMove = 165,
  GraphicsSceneDragLeave = 166, GraphicsSceneDrop = 167, GraphicsSceneWheel = 168, KeyboardLayoutChange = 169,
  DynamicPropertyChange = 170, TabletEnterProximity = 171, TabletLeaveProximity = 172, NonClientAreaMouseMove = 173,
  NonClientAreaMouseButtonPress = 174, NonClientAreaMouseButtonRelease = 175, NonClientAreaMouseButtonDblClick = 176, MacSizeChange = 177,
  ContentsRectChange = 178, MacGLWindowChange = 179, FutureCallOut = 180, GraphicsSceneResize = 181,
  GraphicsSceneMove = 182, CursorChange = 183, ToolTipChange = 184, NetworkReplyUpdated = 185,
  GrabMouse = 186, UngrabMouse = 187, GrabKeyboard = 188, UngrabKeyboard = 189,
  MacGLClearDrawable = 191, StateMachineSignal = 192, StateMachineWrapped = 193, TouchBegin = 194,
  TouchUpdate = 195, TouchEnd = 196, NativeGesture = 197, RequestSoftwareInputPanel = 199,
  CloseSoftwareInputPanel = 200, UpdateSoftKeys = 201, WinIdChange = 203, Gesture = 198,
  GestureOverride = 202, PlatformPanel = 212, User = 1000, MaxUser = 65535
}
 This enum type defines the valid event types in Qt. More...
 
- Static Public Functions inherited from QEvent
static int registerEventType (int hint=-1)
 Registers and returns a custom event type. More...
 
- Protected Variables inherited from QEvent
QEventPrivate * d
 
ushort t
 

Detailed Description

The QFileOpenEvent class provides an event that will be sent when there is a request to open a file or a URL.

File open events will be sent to the QApplication::instance() when the operating system requests that a file or URL should be opened. This is a high-level event that can be caused by different user actions depending on the user's desktop environment; for example, double clicking on an file icon in the Finder on Mac OS X.

This event is only used to notify the application of a request. It may be safely ignored.

Note
This class is currently supported for Mac OS X and Symbian only.

Definition at line 644 of file qevent.h.

Constructors and Destructors

◆ QFileOpenEvent() [1/2]

QFileOpenEvent::QFileOpenEvent ( const QString file)

Constructs a file open event for the given file.

Warning
This function is not part of the public interface.

Definition at line 3458 of file qevent.cpp.

Referenced by QFileOpenEvent().

3459  : QEvent(FileOpen), f(file)
3460 {
3461  d = reinterpret_cast<QEventPrivate *>(new QFileOpenEventPrivate(QUrl::fromLocalFile(file)));
3462 }
QEvent(Type type)
Contructs an event object of type type.
Definition: qcoreevent.cpp:289
QEventPrivate * d
Definition: qcoreevent.h:315
QString f
Definition: qevent.h:658
static QUrl fromLocalFile(const QString &localfile)
Returns a QUrl representation of localFile, interpreted as a local file.
Definition: qurl.cpp:6374

◆ QFileOpenEvent() [2/2]

QFileOpenEvent::QFileOpenEvent ( const QUrl url)

Constructs a file open event for the given url.

Warning
This function is not part of the public interface.

Definition at line 3472 of file qevent.cpp.

3473  : QEvent(FileOpen)
3474 {
3475  d = reinterpret_cast<QEventPrivate *>(new QFileOpenEventPrivate(url));
3476  f = url.toLocalFile();
3477 }
QEvent(Type type)
Contructs an event object of type type.
Definition: qcoreevent.cpp:289
QString toLocalFile() const
Returns the path of this URL formatted as a local file path.
Definition: qurl.cpp:6412
QEventPrivate * d
Definition: qcoreevent.h:315
QString f
Definition: qevent.h:658

◆ ~QFileOpenEvent()

QFileOpenEvent::~QFileOpenEvent ( )
Warning
This function is not part of the public interface.

Definition at line 3497 of file qevent.cpp.

3498 {
3499  delete reinterpret_cast<QFileOpenEventPrivate *>(d);
3500 }
QEventPrivate * d
Definition: qcoreevent.h:315

Functions

◆ file()

QString QFileOpenEvent::file ( ) const
inline

Returns the file that is being opened.

Definition at line 654 of file qevent.h.

654 { return f; }
QString f
Definition: qevent.h:658

◆ openFile()

bool QFileOpenEvent::openFile ( QFile file,
QIODevice::OpenMode  flags 
) const

Opens a QFile on the file referenced by this event in the mode specified by flags.

Returns true if successful; otherwise returns false.

This is necessary as some files cannot be opened by name, but require specific information stored in this event. For example, if this QFileOpenEvent contains a request to open a Symbian data caged file, the QFile could only be opened from the Symbian RFile used in the construction of this event.

Since
4.8

Definition at line 3542 of file qevent.cpp.

3543 {
3544  file.setFileName(f);
3545 #ifdef Q_OS_SYMBIAN
3546  const QFileOpenEventPrivate *priv = reinterpret_cast<const QFileOpenEventPrivate *>(d);
3547  if (priv->file.SubSessionHandle()) {
3548  RFile dup;
3549  // Duplicate here means that the opened QFile will continue to be valid beyond the lifetime of this QFileOpenEvent.
3550  // It also allows openFile to be used in threads other than the thread in which the QFileOpenEvent was created.
3551  if (dup.Duplicate(priv->file) == KErrNone) {
3553  bool open = file.open(dup, flags, QFile::AutoCloseHandle);
3554  dupCloser.take();
3555  return open;
3556  }
3557  }
3558 #endif
3559  return file.open(flags);
3560 }
bool open(OpenMode flags)
Opens the file using OpenMode mode, returning true if successful; otherwise false.
Definition: qfile.cpp:1064
The QScopedPointer class stores a pointer to a dynamically allocated object, and deletes it upon dest...
QEventPrivate * d
Definition: qcoreevent.h:315
QString f
Definition: qevent.h:658
static const QMetaObjectPrivate * priv(const uint *data)
void setFileName(const QString &name)
Sets the name of the file.
Definition: qfile.cpp:494
int open(const char *, int,...)

◆ url()

QUrl QFileOpenEvent::url ( ) const

Returns the url that is being opened.

Since
4.6

Definition at line 3521 of file qevent.cpp.

3522 {
3523  return reinterpret_cast<const QFileOpenEventPrivate *>(d)->url;
3524 }
QEventPrivate * d
Definition: qcoreevent.h:315
QUrl url() const
Returns the url that is being opened.
Definition: qevent.cpp:3521

Properties

◆ f

QString QFileOpenEvent::f
private

Definition at line 658 of file qevent.h.

Referenced by openFile(), and QFileOpenEvent().


The documentation for this class was generated from the following files: