Commit 25869ff1 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit

clang-format: fix code formatting

This run of `clang-format` cleanups indentation and spacing to match
ParaView style.
parent 6aa39647
......@@ -7,7 +7,7 @@
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
......@@ -36,21 +36,21 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "QtTestingConfigure.h"
#if defined(QTTESTING_BUILD_SHARED_LIBS)
# if defined(QtTesting_EXPORTS)
# if defined(WIN32)
# define QTTESTING_EXPORT __declspec(dllexport)
# elif defined(__GNUC__) && __GNUC__ >= 4
# define QTTESTING_EXPORT __attribute__ ((visibility("default")))
# endif
# else
# if defined(WIN32)
# define QTTESTING_EXPORT __declspec(dllimport)
# endif
# endif
#if defined(QtTesting_EXPORTS)
#if defined(WIN32)
#define QTTESTING_EXPORT __declspec(dllexport)
#elif defined(__GNUC__) && __GNUC__ >= 4
#define QTTESTING_EXPORT __attribute__((visibility("default")))
#endif
#else
#if defined(WIN32)
#define QTTESTING_EXPORT __declspec(dllimport)
#endif
#endif
#endif
#ifndef QTTESTING_EXPORT
# define QTTESTING_EXPORT
#define QTTESTING_EXPORT
#endif
#endif // !_QtTestingExport_h
......@@ -35,46 +35,45 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <QApplication>
#include <QKeyEvent>
#include <QMouseEvent>
#include <QtDebug>
#include <QRegExp>
#include <QWidget>
#include <QtDebug>
pq3DViewEventPlayer::pq3DViewEventPlayer(const QByteArray& classname, QObject * p)
: pqWidgetEventPlayer(p), mClassType(classname)
pq3DViewEventPlayer::pq3DViewEventPlayer(const QByteArray& classname, QObject* p)
: pqWidgetEventPlayer(p)
, mClassType(classname)
{
}
bool pq3DViewEventPlayer::playEvent(QObject* Object,
const QString& Command,
const QString& Arguments,
bool& Error)
bool pq3DViewEventPlayer::playEvent(
QObject* Object, const QString& Command, const QString& Arguments, bool& Error)
{
QWidget* widget = qobject_cast<QWidget*>(Object);
if(widget && Object->inherits(mClassType.data()))
QWidget* widget = qobject_cast<QWidget*>(Object);
if (widget && Object->inherits(mClassType.data()))
{
if (Command == "mousePress" || Command == "mouseRelease" || Command == "mouseMove")
{
QRegExp mouseRegExp("\\(([^,]*),([^,]*),([^,]),([^,]),([^,]*)\\)");
if (mouseRegExp.indexIn(Arguments) != -1)
{
if (Command == "mousePress" || Command=="mouseRelease" || Command=="mouseMove")
{
QRegExp mouseRegExp("\\(([^,]*),([^,]*),([^,]),([^,]),([^,]*)\\)");
if (mouseRegExp.indexIn(Arguments)!= -1)
{
QVariant v = mouseRegExp.cap(1);
int x = static_cast<int>(v.toDouble() * widget->size().width());
v = mouseRegExp.cap(2);
int y = static_cast<int>(v.toDouble() * widget->size().height());
v = mouseRegExp.cap(3);
Qt::MouseButton button = static_cast<Qt::MouseButton>(v.toInt());
v = mouseRegExp.cap(4);
Qt::MouseButtons buttons = static_cast<Qt::MouseButton>(v.toInt());
v = mouseRegExp.cap(5);
Qt::KeyboardModifiers keym = static_cast<Qt::KeyboardModifier>(v.toInt());
QEvent::Type type = (Command == "mousePress")? QEvent::MouseButtonPress :
((Command=="mouseMove")? QEvent::MouseMove : QEvent::MouseButtonRelease);
QMouseEvent e(type, QPoint(x,y), button, buttons, keym);
qApp->notify(Object, &e);
}
return true;
}
QVariant v = mouseRegExp.cap(1);
int x = static_cast<int>(v.toDouble() * widget->size().width());
v = mouseRegExp.cap(2);
int y = static_cast<int>(v.toDouble() * widget->size().height());
v = mouseRegExp.cap(3);
Qt::MouseButton button = static_cast<Qt::MouseButton>(v.toInt());
v = mouseRegExp.cap(4);
Qt::MouseButtons buttons = static_cast<Qt::MouseButton>(v.toInt());
v = mouseRegExp.cap(5);
Qt::KeyboardModifiers keym = static_cast<Qt::KeyboardModifier>(v.toInt());
QEvent::Type type = (Command == "mousePress")
? QEvent::MouseButtonPress
: ((Command == "mouseMove") ? QEvent::MouseMove : QEvent::MouseButtonRelease);
QMouseEvent e(type, QPoint(x, y), button, buttons, keym);
qApp->notify(Object, &e);
}
return this->Superclass::playEvent(Object, Command, Arguments, Error);
return true;
}
}
return this->Superclass::playEvent(Object, Command, Arguments, Error);
}
......@@ -36,13 +36,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "pqWidgetEventPlayer.h"
/**
Concrete implementation of pqWidgetEventPlayer that handles playback of "activate" events for 3d views.
Concrete implementation of pqWidgetEventPlayer that handles playback of "activate" events for 3d
views.
It is not registered by default, and user can register with their own 3d view type.
\sa pqEventPlayer
*/
class QTTESTING_EXPORT pq3DViewEventPlayer :
public pqWidgetEventPlayer
class QTTESTING_EXPORT pq3DViewEventPlayer : public pqWidgetEventPlayer
{
Q_OBJECT
typedef pqWidgetEventPlayer Superclass;
......@@ -51,13 +51,13 @@ public:
pq3DViewEventPlayer(const QByteArray& classname, QObject* p = 0);
using Superclass::playEvent;
bool playEvent(QObject* Object, const QString& Command, const QString& Arguments, bool& Error) override;
bool playEvent(
QObject* Object, const QString& Command, const QString& Arguments, bool& Error) override;
protected:
QByteArray mClassType;
private:
pq3DViewEventPlayer(const pq3DViewEventPlayer&);
pq3DViewEventPlayer& operator=(const pq3DViewEventPlayer&);
};
......
......@@ -33,14 +33,15 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "pq3DViewEventTranslator.h"
#include <QEvent>
#include <QMouseEvent>
#include <QKeyEvent>
#include <QMouseEvent>
#include <QWidget>
pq3DViewEventTranslator::pq3DViewEventTranslator(const QByteArray& classname, QObject* p)
: pqWidgetEventTranslator(p), mClassType(classname),
lastMoveEvent(QEvent::MouseButtonPress, QPoint(), Qt::MouseButton(),
Qt::MouseButtons(), Qt::KeyboardModifiers())
: pqWidgetEventTranslator(p)
, mClassType(classname)
, lastMoveEvent(QEvent::MouseButtonPress, QPoint(), Qt::MouseButton(), Qt::MouseButtons(),
Qt::KeyboardModifiers())
{
}
......@@ -48,128 +49,125 @@ pq3DViewEventTranslator::~pq3DViewEventTranslator()
{
}
bool pq3DViewEventTranslator::translateEvent(QObject* Object, QEvent* Event,
bool& Error)
bool pq3DViewEventTranslator::translateEvent(QObject* Object, QEvent* Event, bool& Error)
{
QWidget* widget = qobject_cast<QWidget*>(Object);
if(!widget || !Object->inherits(mClassType.data()))
{
if (!widget || !Object->inherits(mClassType.data()))
{
return false;
}
}
switch(Event->type())
{
switch (Event->type())
{
case QEvent::ContextMenu:
{
{
return true;
break;
}
}
case QEvent::MouseButtonPress:
{
{
QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(Event);
if (mouseEvent)
{
{
QSize size = widget->size();
double normalized_x = mouseEvent->x()/static_cast<double>(size.width());
double normalized_y = mouseEvent->y()/static_cast<double>(size.height());
double normalized_x = mouseEvent->x() / static_cast<double>(size.width());
double normalized_y = mouseEvent->y() / static_cast<double>(size.height());
int button = mouseEvent->button();
int buttons = mouseEvent->buttons();
int modifiers = mouseEvent->modifiers();
emit recordEvent(Object, "mousePress", QString("(%1,%2,%3,%4,%5)")
.arg(normalized_x)
.arg(normalized_y)
.arg(button)
.arg(buttons)
.arg(modifiers));
}
.arg(normalized_x)
.arg(normalized_y)
.arg(button)
.arg(buttons)
.arg(modifiers));
}
// reset lastMoveEvent
QMouseEvent e(QEvent::MouseButtonPress, QPoint(), Qt::MouseButton(),
Qt::MouseButtons(), Qt::KeyboardModifiers());
QMouseEvent e(QEvent::MouseButtonPress, QPoint(), Qt::MouseButton(), Qt::MouseButtons(),
Qt::KeyboardModifiers());
lastMoveEvent = e;
return true;
break;
}
}
case QEvent::MouseMove:
{
{
QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(Event);
if (mouseEvent)
{
{
QMouseEvent e(QEvent::MouseMove, QPoint(mouseEvent->x(), mouseEvent->y()),
mouseEvent->button(), mouseEvent->buttons(),
mouseEvent->modifiers());
mouseEvent->button(), mouseEvent->buttons(), mouseEvent->modifiers());
lastMoveEvent = e;
}
}
return true;
break;
}
}
case QEvent::MouseButtonRelease:
{
{
QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(Event);
if (mouseEvent)
{
{
QSize size = widget->size();
// record last move event if it is valid
if(lastMoveEvent.type() == QEvent::MouseMove)
{
double normalized_x = lastMoveEvent.x()/static_cast<double>(size.width());
double normalized_y = lastMoveEvent.y()/static_cast<double>(size.height());
if (lastMoveEvent.type() == QEvent::MouseMove)
{
double normalized_x = lastMoveEvent.x() / static_cast<double>(size.width());
double normalized_y = lastMoveEvent.y() / static_cast<double>(size.height());
int button = lastMoveEvent.button();
int buttons = lastMoveEvent.buttons();
int modifiers = lastMoveEvent.modifiers();
emit recordEvent(Object, "mouseMove", QString("(%1,%2,%3,%4,%5)")
.arg(normalized_x)
.arg(normalized_y)
.arg(button)
.arg(buttons)
.arg(modifiers));
}
.arg(normalized_x)
.arg(normalized_y)
.arg(button)
.arg(buttons)
.arg(modifiers));
}
double normalized_x = mouseEvent->x()/static_cast<double>(size.width());
double normalized_y = mouseEvent->y()/static_cast<double>(size.height());
double normalized_x = mouseEvent->x() / static_cast<double>(size.width());
double normalized_y = mouseEvent->y() / static_cast<double>(size.height());
int button = mouseEvent->button();
int buttons = mouseEvent->buttons();
int modifiers = mouseEvent->modifiers();
emit recordEvent(Object, "mouseRelease", QString("(%1,%2,%3,%4,%5)")
.arg(normalized_x)
.arg(normalized_y)
.arg(button)
.arg(buttons)
.arg(modifiers));
}
.arg(normalized_x)
.arg(normalized_y)
.arg(button)
.arg(buttons)
.arg(modifiers));
}
return true;
break;
}
}
case QEvent::KeyPress:
case QEvent::KeyRelease:
{
{
QKeyEvent* ke = static_cast<QKeyEvent*>(Event);
QString data =QString("%1:%2:%3:%4:%5:%6")
.arg(ke->type())
.arg(ke->key())
.arg(static_cast<int>(ke->modifiers()))
.arg(ke->text())
.arg(ke->isAutoRepeat())
.arg(ke->count());
QString data = QString("%1:%2:%3:%4:%5:%6")
.arg(ke->type())
.arg(ke->key())
.arg(static_cast<int>(ke->modifiers()))
.arg(ke->text())
.arg(ke->isAutoRepeat())
.arg(ke->count());
emit recordEvent(Object, "keyEvent", data);
return true;
break;
}
}
default:
{
{
break;
}
}
}
return this->Superclass::translateEvent(Object, Event, Error);
}
......@@ -42,14 +42,13 @@ Translates low-level Qt events into high-level ParaView events that can be recor
\sa pqEventTranslator
*/
class QTTESTING_EXPORT pq3DViewEventTranslator :
public pqWidgetEventTranslator
class QTTESTING_EXPORT pq3DViewEventTranslator : public pqWidgetEventTranslator
{
Q_OBJECT
typedef pqWidgetEventTranslator Superclass;
public:
pq3DViewEventTranslator(const QByteArray& classname, QObject* p=0);
pq3DViewEventTranslator(const QByteArray& classname, QObject* p = 0);
~pq3DViewEventTranslator() override;
using Superclass::translateEvent;
......@@ -62,7 +61,6 @@ protected:
private:
pq3DViewEventTranslator(const pq3DViewEventTranslator&);
pq3DViewEventTranslator& operator=(const pq3DViewEventTranslator&);
};
#endif // !_pq3DViewEventTranslator_h
......@@ -38,85 +38,82 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <QMenu>
#include <QMenuBar>
#include <QPushButton>
#include <QtDebug>
#include <QToolButton>
#include <QtDebug>
#include "pqEventDispatcher.h"
pqAbstractActivateEventPlayer::pqAbstractActivateEventPlayer(QObject * p)
pqAbstractActivateEventPlayer::pqAbstractActivateEventPlayer(QObject* p)
: pqWidgetEventPlayer(p)
{
}
bool pqAbstractActivateEventPlayer::playEvent(QObject* Object,
const QString& Command,
const QString& Arguments,
bool& Error)
bool pqAbstractActivateEventPlayer::playEvent(
QObject* Object, const QString& Command, const QString& Arguments, bool& Error)
{
if(Command != "activate" && Command != "longActivate")
return false;
if (Command != "activate" && Command != "longActivate")
return false;
if (QMenuBar* const menu_bar = qobject_cast<QMenuBar*>(Object))
{
if (QMenuBar* const menu_bar = qobject_cast<QMenuBar*>(Object))
{
QAction* action = findAction(menu_bar, Arguments);
if (action)
{
{
menu_bar->setActiveAction(action);
return true;
}
}
qCritical() << "couldn't find action " << Arguments;
Error = true;
return true;
}
}
if(QMenu* const object = qobject_cast<QMenu*>(Object))
{
if (QMenu* const object = qobject_cast<QMenu*>(Object))
{
QAction* action = findAction(object, Arguments);
if(!action)
{
if (!action)
{
qCritical() << "couldn't find action " << Arguments;
Error = true;
return true;
}
}
// get a list of menus that must be navigated to
// click on the action
QObjectList menus;
for(QObject* p = object;
qobject_cast<QMenu*>(p) || qobject_cast<QMenuBar*>(p);
p = p->parent())
{
for (QObject* p = object; qobject_cast<QMenu*>(p) || qobject_cast<QMenuBar*>(p);
p = p->parent())
{
menus.push_front(p);
}
}
// unfold menus to make action visible
int i;
int numMenus = menus.size() - 1;
for(i=0; i < numMenus; ++i)
{
for (i = 0; i < numMenus; ++i)
{
QObject* p = menus[i];
QMenu* next = qobject_cast<QMenu*>(menus[i+1]);
if(QMenuBar* menu_bar = qobject_cast<QMenuBar*>(p))
{
QMenu* next = qobject_cast<QMenu*>(menus[i + 1]);
if (QMenuBar* menu_bar = qobject_cast<QMenuBar*>(p))
{
menu_bar->setActiveAction(next->menuAction());
int max_wait = 0;
while(!next->isVisible() && (++max_wait) <= 2)
{
while (!next->isVisible() && (++max_wait) <= 2)
{
pqEventDispatcher::processEventsAndWait(100);
}
}
else if(QMenu* menu = qobject_cast<QMenu*>(p))
{
}
else if (QMenu* menu = qobject_cast<QMenu*>(p))
{
menu->setActiveAction(next->menuAction());
int max_wait = 0;
while(!next->isVisible() && (++max_wait) <= 2)
{
while (!next->isVisible() && (++max_wait) <= 2)
{
pqEventDispatcher::processEventsAndWait(100);
}
}
}
}
// set active action, will cause scrollable menus to scroll
// to make action visible
......@@ -129,35 +126,35 @@ bool pqAbstractActivateEventPlayer::playEvent(QObject* Object,
qApp->notify(object, &keyDown);
qApp->notify(object, &keyUp);
//QApplication::processEvents();
// QApplication::processEvents();
return true;
}
}
if(QAbstractButton* const object = qobject_cast<QAbstractButton*>(Object))
{
if (QAbstractButton* const object = qobject_cast<QAbstractButton*>(Object))
{
if (Command == "activate")
{
{
object->click();
//QApplication::processEvents();
// QApplication::processEvents();
return true;
}
if(Command == "longActivate")
{
}
if (Command == "longActivate")
{
QToolButton* tButton = qobject_cast<QToolButton*>(Object);
if(tButton)
{
if (tButton)
{
tButton->showMenu();
return true;
}
}
}
}
if (QAction* const action = qobject_cast<QAction*>(Object))
{
{
action->activate(QAction::Trigger);
//QApplication::processEvents();
// QApplication::processEvents();
return true;
}
}
qCritical() << "calling activate on unhandled type " << Object;
Error = true;
......@@ -168,26 +165,26 @@ QAction* pqAbstractActivateEventPlayer::findAction(QMenuBar* p, const QString& n
{
QList<QAction*> actions = p->actions();
QAction* action = NULL;
foreach(QAction* a, actions)
foreach (QAction* a, actions)
{
if (a->menu()->objectName() == name)
{
if(a->menu()->objectName() == name)
{
action = a;
break;
}
}
}
if(!action)
if (!action)
{
foreach (QAction* a, actions)
{
foreach(QAction* a, actions)
if (a->text() == name)
{
if(a->text() == name)
{
action = a;
break;
}
}
}
}
return action;
}
......@@ -196,26 +193,26 @@ QAction* pqAbstractActivateEventPlayer::findAction(QMenu* p, const QString& name
{
QList<QAction*> actions = p->actions();
QAction* action = NULL;
foreach(QAction* a, actions)
foreach (QAction* a, actions)
{
if (a->objectName() == name)
{
if(a->objectName() == name)
{
action = a;
break;
}
}
}
if(!action)
if (!action)
{
foreach (QAction* a, actions)
{
foreach(QAction* a, actions)
if (a->text() == name)
{
if(a->text() == name)
{
action = a;
break;
}
}
}
}
return action;
}
......@@ -7,7 +7,7 @@
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
......@@ -39,12 +39,12 @@ class QMenuBar;
class QMenu;
/**
Concrete implementation of pqWidgetEventPlayer that handles playback of "activate" events for buttons and menus.
Concrete implementation of pqWidgetEventPlayer that handles playback of "activate" events for
buttons and menus.
\sa pqEventPlayer
*/
class QTTESTING_EXPORT pqAbstractActivateEventPlayer :
public pqWidgetEventPlayer
class QTTESTING_EXPORT pqAbstractActivateEventPlayer : public pqWidgetEventPlayer
{
Q_OBJECT
typedef pqWidgetEventPlayer Superclass;
......@@ -53,10 +53,10 @@ public:
pqAbstractActivateEventPlayer(QObject* p = 0);
using Superclass::playEvent;
bool playEvent(QObject* Object, const QString& Command, const QString& Arguments, bool& Error) override;
bool playEvent(
QObject* Object, const QString& Command, const QString& Arguments, bool& Error) override;
private:
QAction* findAction(QMenu* p, const QString& name);
QAction* findAction(QMenuBar* p, const QString& name);
......@@ -65,4 +65,3 @@ private:
};
#endif // !_pqAbstractActivateEventPlayer_h
......@@ -7,7 +7,7 @@
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
......@@ -33,48 +33,48 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "pqAbstractBooleanEventPlayer.h"
#include <QAbstractButton>
#include <QAction>