Skip to content

Commit

Permalink
modified for clang format
Browse files Browse the repository at this point in the history
Signed-off-by: Vinayakjeet Singh Karki <139736674+vinayakjeet@users.noreply.github.com>
  • Loading branch information
vinayakjeet committed Apr 17, 2024
1 parent c8d21fd commit 38ed8b4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
25 changes: 14 additions & 11 deletions avogadro/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
#include <avogadro/rendering/glrenderer.h>
#include <avogadro/rendering/scene.h>

#include <QMouseEvent>
#include <QOpenGLFramebufferObject>
#include <QtCore/QDebug>
#include <QtCore/QFile>
#include <QtCore/QFileInfo>
Expand All @@ -50,8 +52,6 @@
#include <QtCore/QString>
#include <QtCore/QThread>
#include <QtCore/QTimer>
#include <QMouseEvent>
#include <QOpenGLFramebufferObject>
#include <QtGui/QClipboard>
#include <QtGui/QCloseEvent>
#include <QtGui/QDesktopServices>
Expand Down Expand Up @@ -228,7 +228,8 @@ using VTK::vtkGLWidget;
#endif

MainWindow::MainWindow(const QStringList& fileNames, bool disableSettings)
: QMainWindow(/* parent */), dragStartPosition()
: QMainWindow(/* parent */)
, dragStartPosition()
: m_molecule(nullptr)
, m_rwMolecule(nullptr)
, m_moleculeModel(nullptr)
Expand Down Expand Up @@ -368,26 +369,29 @@ void MainWindow::mouseMoveEvent(QMouseEvent* event)
{
if (!(event->buttons() & Qt::LeftButton))
return;
if ((event->pos() - dragStartPosition).manhattanLength() < QApplication::startDragDistance())
if ((event->pos() - dragStartPosition).manhattanLength() <
QApplication::startDragDistance())
return;

performDrag();
}

void MainWindow::performDrag()
{
// Assuming you have a method to get the currently selected molecule as a string in a specific format
// Assuming you have a method to get the currently selected molecule as a
// string in a specific format
QString moleculeData = /* method to get molecule data */;
if (moleculeData.isEmpty())
return;

auto* mimeData = new QMimeData;
mimeData->setText(moleculeData); // For demonstration, using plain text. Adjust based on actual data format.
mimeData->setText(moleculeData); // For demonstration, using plain text.
// Adjust based on actual data format.

// Create a drag object
auto* drag = new QDrag(this);
drag->setMimeData(mimeData);

// You can set an appropriate pixmap for the drag object if you like
// QPixmap pixmap(iconSize);
// QPainter painter(&pixmap);
Expand Down Expand Up @@ -568,16 +572,16 @@ void MainWindow::dropEvent(QDropEvent* event)
{
if (event->mimeData()->hasUrls()) {
QList<QUrl> urls = event->mimeData()->urls();
for (const QUrl &url : urls) {
for (const QUrl& url : urls) {
if (url.isLocalFile()) {
QString fileName = url.toLocalFile();
QFileInfo info(fileName);

// Distinguish Python scripts for special handling
if (info.suffix().compare("py", Qt::CaseInsensitive) == 0) {
addScript(fileName);
} else {

openFile(fileName);
}
}
Expand All @@ -588,7 +592,6 @@ void MainWindow::dropEvent(QDropEvent* event)
}
}


void MainWindow::moleculeReady(int)
{
auto* extension = qobject_cast<ExtensionPlugin*>(sender());
Expand Down
10 changes: 5 additions & 5 deletions avogadro/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
#ifndef AVOGADRO_MAINWINDOW_H
#define AVOGADRO_MAINWINDOW_H

#include <QDrag>
#include <QMimeData>
#include <QtCore/QStringList>
#include <QtCore/QVariantMap>
#include <QtWidgets/QMainWindow>
#include <QMimeData>
#include <QDrag>

#ifdef QTTESTING
class pqTestUtility;
Expand Down Expand Up @@ -163,7 +163,7 @@ public slots:
void moleculeChanged(QtGui::Molecule* molecue);

protected:
void mousePressEvent(QMouseEvent* event) override;
void mousePressEvent(QMouseEvent* event) override;
void mouseMoveEvent(QMouseEvent* event) override;

void closeEvent(QCloseEvent* event);
Expand Down Expand Up @@ -396,7 +396,7 @@ private slots:
void setProjectionPerspective();

private:
QPoint dragStartPosition; // To store the start position of a drag operation
QPoint dragStartPosition; // To store the start position of a drag operation
QtGui::Molecule* m_molecule;
QtGui::RWMolecule* m_rwMolecule;
QtGui::MoleculeModel* m_moleculeModel;
Expand Down Expand Up @@ -485,7 +485,7 @@ QPoint dragStartPosition; // To store the start position of a drag operation
* Initialize the tool plugins.
*/
void buildTools();
void performDrag();
void performDrag();
/**
* Convenience function that converts a file extension to a wildcard
* expression, e.g. "out" to "*.out". This method also checks for "extensions"
Expand Down

0 comments on commit 38ed8b4

Please sign in to comment.