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 
55 {
56  Q_OBJECT;
57  typedef QObject Superclass;
58 
59 public:
60  pqCoreUtilitiesEventHelper(QObject* parent);
61  ~pqCoreUtilitiesEventHelper() override;
62 
63 Q_SIGNALS:
64  void eventInvoked(vtkObject*, unsigned long, void*);
65 
66 private:
67  Q_DISABLE_COPY(pqCoreUtilitiesEventHelper)
68 
69  void executeEvent(vtkObject*, unsigned long, void*);
70  class pqInternal;
71  pqInternal* Interal;
72  friend class pqCoreUtilities;
73 };
74 
80 {
81 public:
88  static void setMainWidget(QWidget* widget) { pqCoreUtilities::MainWidget = widget; }
89  static QWidget* mainWidget()
90  {
91  if (!pqCoreUtilities::MainWidget)
92  {
93  pqCoreUtilities::MainWidget = pqCoreUtilities::findMainWindow();
94  }
95  return pqCoreUtilities::MainWidget;
96  }
97 
102  static void processEvents(QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents)
103  {
104  pqEventDispatcher::processEvents(flags);
105  }
106 
110  static QString getParaViewUserDirectory();
111 
115  static QString getParaViewApplicationDirectory();
116 
121  static QStringList findParaviewPaths(
122  QString directoryOrFileName, bool lookupInAppDir, bool lookupInUserDir);
123  static QString getNoneExistingFileName(QString expectedFilePath);
124 
134  static unsigned long connect(vtkObject* vtk_object, int vtk_event_id, QObject* qobject,
135  const char* signal_or_slot, Qt::ConnectionType type = Qt::AutoConnection);
136 
155  static bool promptUser(const QString& settingsKey, QMessageBox::Icon icon, const QString& title,
156  const QString& message, QMessageBox::StandardButtons buttons, QWidget* parentWdg = NULL);
157 
163  static QString number(double value);
164 
165 private:
166  static QWidget* findMainWindow();
167  static QPointer<QWidget> MainWidget;
168 };
169 
170 #endif
type
static QWidget * mainWidget()
#define PQCORE_EXPORT
Definition: pqCoreModule.h:15
connect
value
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...
title