ParaView
pqCoreUtilities.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: pqCoreUtilities.h
5 
6  Copyright (c) 2005,2006 Sandia Corporation, Kitware Inc.
7  All rights reserved.
8 
9  ParaView is a free software; you can redistribute it and/or modify it
10  under the terms of the ParaView license version 1.2.
11 
12  See License_v1.2.txt for the full ParaView license.
13  A copy of this license can be obtained by contacting
14  Kitware Inc.
15  28 Corporate Drive
16  Clifton Park, NY 12065
17  USA
18 
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
23 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 ========================================================================*/
32 #ifndef pqCoreUtilities_h
33 #define pqCoreUtilities_h
34 
35 #include "pqCoreModule.h"
36 #include "pqEventDispatcher.h"
37 
38 #include <QDir>
39 #include <QEventLoop>
40 #include <QFile>
41 #include <QFileInfo>
42 #include <QMessageBox>
43 #include <QPointer>
44 #include <QString>
45 #include <QStringList>
46 #include <QWidget>
47 
48 class vtkObject;
49 
52 class PQCORE_EXPORT pqCoreUtilitiesEventHelper : public QObject
53 {
54  Q_OBJECT;
55  typedef QObject Superclass;
56 public:
57  pqCoreUtilitiesEventHelper(QObject* parent);
59 
60 signals:
61  void eventInvoked(vtkObject*, unsigned long, void*);
62 
63 private:
64  Q_DISABLE_COPY(pqCoreUtilitiesEventHelper)
65 
66  void executeEvent(vtkObject*, unsigned long, void*);
67  class pqInternal;
68  pqInternal* Interal;
69  friend class pqCoreUtilities;
70 };
71 
74 class PQCORE_EXPORT pqCoreUtilities
75 {
76 public:
81  static void setMainWidget(QWidget* widget)
82  {
83  pqCoreUtilities::MainWidget = widget;
84  }
85  static QWidget* mainWidget()
86  {
87  if (!pqCoreUtilities::MainWidget)
88  {
89  pqCoreUtilities::MainWidget = pqCoreUtilities::findMainWindow();
90  }
91  return pqCoreUtilities::MainWidget;
92  }
93 
96  static void processEvents(QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents)
97  {
98  pqEventDispatcher::processEvents(flags);
99  }
100 
102  static QString getParaViewUserDirectory();
103 
105  static QString getParaViewApplicationDirectory();
106 
109  static QStringList findParaviewPaths(QString directoryOrFileName,
110  bool lookupInAppDir,
111  bool lookupInUserDir);
112  static QString getNoneExistingFileName(QString expectedFilePath);
113 
121  static unsigned long connect(
122  vtkObject* vtk_object, int vtk_event_id,
123  QObject* qobject, const char* signal_or_slot,
124  Qt::ConnectionType type = Qt::AutoConnection);
125 
142  static bool promptUser(
143  const QString& settingsKey, QMessageBox::Icon icon,
144  const QString& title, const QString& message,
145  QMessageBox::StandardButtons buttons,
146  QWidget* parentWdg=NULL);
147 
148 private:
149  static QWidget* findMainWindow();
150  static QPointer<QWidget> MainWidget;
151 };
152 
153 #endif
154 
155 
static QWidget * mainWidget()
INTERNAL CLASS (DO NOT USE).
pqCoreUtilities is a collection of arbitrary utility functions that can be used by the application...
static void processEvents(QEventLoop::ProcessEventsFlags flags=QEventLoop::AllEvents)
Call QApplication::processEvents plus make sure the testing framework is.
static void setMainWidget(QWidget *widget)
When popuping up dialogs, it&#39;s generally better if we set the parent widget for those dialogs to be t...