Skip to content

Commit

Permalink
Plugins: adpapt to new API
Browse files Browse the repository at this point in the history
Pass file names by const reference.
  • Loading branch information
diegoiast committed Jan 24, 2025
1 parent 1d41821 commit 7b7a1d6
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 13 deletions.
5 changes: 2 additions & 3 deletions src/plugins/hexviewer/hexviewer_plg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ QStringList HexViewrPlugin::myExtensions() {
return s;
}

int HexViewrPlugin::canOpenFile(const QString fileName) {
int HexViewrPlugin::canOpenFile(const QString &fileName) {
static const QStringList extensions = {".bin", ".img", "blob", ".so", ".AppImage",
".a", ".exe", ".dll", ".dlib", ".pdf"};
for (const QString &ext : extensions) {
Expand All @@ -161,9 +161,8 @@ int HexViewrPlugin::canOpenFile(const QString fileName) {
return 2;
}

bool HexViewrPlugin::openFile(const QString fileName, int, int, int) {
bool HexViewrPlugin::openFile(const QString &fileName, int, int, int) {
auto tabWidget = dynamic_cast<QTabWidget *>(mdiServer);
auto fi = QFileInfo(fileName);
auto viewer = new qmdiHexViewer(tabWidget, fileName);
mdiServer->addClient(viewer);
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/hexviewer/hexviewer_plg.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ class HexViewrPlugin : public IPlugin {
~HexViewrPlugin();

QStringList myExtensions() override;
int canOpenFile(const QString fileName) override;
bool openFile(const QString fileName, int x = -1, int y = -1, int z = -1) override;
int canOpenFile(const QString &fileName) override;
bool openFile(const QString &fileName, int x = -1, int y = -1, int z = -1) override;
};
4 changes: 2 additions & 2 deletions src/plugins/imageviewer/imageviewer_plg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ QStringList ImageViewrPlugin::myExtensions() {
return s;
}

int ImageViewrPlugin::canOpenFile(const QString fileName) {
int ImageViewrPlugin::canOpenFile(const QString &fileName) {
if (fileName.endsWith(".jpg", Qt::CaseInsensitive)) {
return 5;
} else if (fileName.endsWith(".jpeg", Qt::CaseInsensitive)) {
Expand All @@ -102,7 +102,7 @@ int ImageViewrPlugin::canOpenFile(const QString fileName) {
}
}

bool ImageViewrPlugin::openFile(const QString fileName, int, int, int) {
bool ImageViewrPlugin::openFile(const QString &fileName, int, int, int) {
auto tabWidget = dynamic_cast<QTabWidget *>(mdiServer);
auto viewer = new qmdiImageViewer(tabWidget, fileName);
mdiServer->addClient(viewer);
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/imageviewer/imageviewer_plg.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ class ImageViewrPlugin : public IPlugin {
~ImageViewrPlugin();

QStringList myExtensions() override;
int canOpenFile(const QString fileName) override;
bool openFile(const QString fileName, int x = -1, int y = -1, int z = -1) override;
int canOpenFile(const QString &fileName) override;
bool openFile(const QString &fileName, int x = -1, int y = -1, int z = -1) override;
};
4 changes: 2 additions & 2 deletions src/plugins/texteditor/texteditor_plg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ QStringList TextEditorPlugin::myExtensions() {
return s;
}

int TextEditorPlugin::canOpenFile(const QString fileName) {
int TextEditorPlugin::canOpenFile(const QString &fileName) {
if (fileName.isEmpty()) {
return 5;
}
Expand Down Expand Up @@ -406,7 +406,7 @@ int TextEditorPlugin::canOpenFile(const QString fileName) {
return 1;
}

bool TextEditorPlugin::openFile(const QString fileName, int x, int y, int zoom) {
bool TextEditorPlugin::openFile(const QString &fileName, int x, int y, int zoom) {
auto editor = new qmdiEditor(dynamic_cast<QMainWindow *>(mdiServer), themeManager);

// In the future - the zoom, will be used to set state to the lines, if the value is really
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/texteditor/texteditor_plg.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ class TextEditorPlugin : public IPlugin {
virtual void saveConfig(QSettings &settings) override;

QStringList myExtensions() override;
int canOpenFile(const QString fileName) override;
bool openFile(const QString fileName, int x = -1, int y = -1, int z = -1) override;
int canOpenFile(const QString &fileName) override;
bool openFile(const QString &fileName, int x = -1, int y = -1, int z = -1) override;
void navigateFile(qmdiClient *client, int x, int y, int z) override;
void applySettings(qmdiEditor *editor);

Expand Down

0 comments on commit 7b7a1d6

Please sign in to comment.