itom
Loading...
Searching...
No Matches
pyCodeReferenceRenamer.h
1/* ********************************************************************
2 itom software
3 URL: http://www.uni-stuttgart.de/ito
4 Copyright (C) 2024, Institut für Technische Optik (ITO),
5 Universität Stuttgart, Germany
6
7 This file is part of itom.
8
9 itom is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Library General Public Licence as published by
11 the Free Software Foundation; either version 2 of the Licence, or (at
12 your option) any later version.
13
14 itom is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
17 General Public Licence for more details.
18
19 You should have received a copy of the GNU Library General Public License
20 along with itom. If not, see <http://www.gnu.org/licenses/>.
21
22*********************************************************************** */
23
24#pragma once
25
26#include "../python/pythonJedi.h"
27#include <qabstractbutton.h>
28#include <qdialog.h>
29#include <qdialogbuttonbox.h>
30#include <qevent.h>
31#include <qlineedit.h>
32#include <qtreewidget.h>
33#include <qwidget.h>
34
35#include "common/retVal.h"
36
37namespace ito {
38
39class PyCodeReferenceRenamer : public QObject
40{
41 Q_OBJECT
42public:
43 PyCodeReferenceRenamer(QWidget* parent = nullptr);
45 RetVal rename(const int& line, const int& column, const QString& filepath);
46
47 enum RenamerRetVal
48 {
49 CodeYetNotAvailable = 100,
50 CouldNotOpenFile = 101
51 };
52
54 {
55 };
56
57private:
58 QObject* m_pPythonEngine;
59 QDialog* m_renameDialog;
60 QLineEdit* m_newNameUserInput;
61 QTreeWidget* m_treeWidgetReferences;
62 QDialogButtonBox* m_dialogButtonBox;
63 ito::JediRenameRequest m_request;
64 QWidget* m_pParent;
65
66 enum RenamerRole
67 {
68 RoleFilePath = Qt::UserRole,
69 RoleMainFile = Qt::UserRole + 1,
70 RoleFileOpened = Qt::UserRole + 2,
71 RoleFileModified = Qt::UserRole + 3,
72 RoleFileRenameItem = Qt::UserRole + 4,
73 RoleFileUntitled = Qt::UserRole + 5
74 };
75
76 QStringList readFirstNLinesFromFile(const QString& filepath, int n) const;
77
78private slots:
79 void onJediRenameResultAvailable(
80 const QVector<ito::JediRename>& filesToChange,
81 const QString& oldValue,
82 bool success,
83 QString errorText);
84 void onApply();
85 void onCanceled();
86 void onItemChanged(QTreeWidgetItem* item, int column);
87 void keyPressEvent(QKeyEvent* event);
88 void clearAndHideTreeWidget();
89 void onItemDoubleClick(QTreeWidget* treeWidget, QTreeWidgetItem* item);
90
91
92 ito::RetVal replaceOccurencesInFile(
93 const QString& filePath,
94 const QString& newValue,
95 const QVector<ito::FileRenameItem>& renameItems);
96
97signals:
98};
99
100}; // namespace ito
Definition pyCodeReferenceRenamer.h:40
RetVal rename(const int &line, const int &column, const QString &filepath)
starts a variable rename operation for the word under the given cursor position
Definition pyCodeReferenceRenamer.cpp:134
Class for managing status values (like errors or warning)
Definition retVal.h:54
Definition apiFunctionsGraph.cpp:40
Definition pythonJedi.h:154
Definition pyCodeReferenceRenamer.h:54