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 QPalette;
49 class vtkObject;
50 
56 {
57  Q_OBJECT;
58  typedef QObject Superclass;
59 
60 public:
61  pqCoreUtilitiesEventHelper(QObject* parent);
62  ~pqCoreUtilitiesEventHelper() override;
63 
64 Q_SIGNALS:
65  void eventInvoked(vtkObject*, unsigned long, void*);
66 
67 private:
68  Q_DISABLE_COPY(pqCoreUtilitiesEventHelper)
69 
70  void executeEvent(vtkObject*, unsigned long, void*);
71  class pqInternal;
72  pqInternal* Interal;
73  friend class pqCoreUtilities;
74 };
75 
81 {
82 public:
89  static void setMainWidget(QWidget* widget) { pqCoreUtilities::MainWidget = widget; }
90  static QWidget* mainWidget()
91  {
92  if (!pqCoreUtilities::MainWidget)
93  {
94  pqCoreUtilities::MainWidget = pqCoreUtilities::findMainWindow();
95  }
96  return pqCoreUtilities::MainWidget;
97  }
98 
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 = nullptr);
157 
164  static QMessageBox::Button promptUserGeneric(const QString& title, const QString& message,
165  QMessageBox::Icon icon, QMessageBox::StandardButtons buttons, QWidget* parentWidget);
166 
172  static QString number(double value);
173 
179  static QString formatMemoryFromKiBValue(double memoryInKB, int precision = 2);
180 
186  static void initializeClickMeButton(QAbstractButton* button);
187 
192  static void setPaletteHighlightToOk(QPalette& palette);
193 
198  static void setPaletteHighlightToWarning(QPalette& palette);
199 
204  static void setPaletteHighlightToCritical(QPalette& palette);
205 
210  static void removeRecursively(QDir dir);
211 
216  static void remove(const QString& filePath);
217 
218 private:
219  static QWidget* findMainWindow();
220  static QPointer<QWidget> MainWidget;
221 };
222 
223 #endif
type
dir
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