-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from urobots-io/files-navigation
Files navigation
- Loading branch information
Showing
20 changed files
with
622 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,35 @@ | ||
<RCC> | ||
<qresource prefix="/MainWindow"> | ||
<file>Resources/paste.ico</file> | ||
<file>Resources/3d.ico</file> | ||
<file>Resources/open.ico</file> | ||
<file>Resources/save.ico</file> | ||
<file>Resources/Redo.ico</file> | ||
<file>Resources/Undo.ico</file> | ||
<file>Resources/file.ico</file> | ||
<file>Resources/folder.ico</file> | ||
<file>Resources/image.ico</file> | ||
<file>Resources/delete.ico</file> | ||
<file>Resources/refresh.ico</file> | ||
<file>Resources/configuration.ico</file> | ||
<file>Resources/folder_network.ico</file> | ||
<file>Resources/file_blue.ico</file> | ||
<file>Resources/add.ico</file> | ||
<file>Resources/fit_to_size.ico</file> | ||
<file>Resources/fix.ico</file> | ||
<file>Resources/restart.ico</file> | ||
<file>Resources/select.png</file> | ||
<file>Resources/anno.ico</file> | ||
<file>Resources/new.ico</file> | ||
<file>Resources/copy.ico</file> | ||
<file>Resources/find.ico</file> | ||
<file>Resources/nav_back.ico</file> | ||
<file>Resources/nav_forward.ico</file> | ||
<file>Resources/rename.ico</file> | ||
<file>Resources/clean.ico</file> | ||
<file>Resources/tree_view.ico</file> | ||
<file>Resources/component.ico</file> | ||
<file>Resources/search-inside.ico</file> | ||
</qresource> | ||
<qresource prefix="/MainWindow"> | ||
<file>Resources/paste.ico</file> | ||
<file>Resources/info.ico</file> | ||
<file>Resources/3d.ico</file> | ||
<file>Resources/open.ico</file> | ||
<file>Resources/save.ico</file> | ||
<file>Resources/Redo.ico</file> | ||
<file>Resources/Undo.ico</file> | ||
<file>Resources/file.ico</file> | ||
<file>Resources/folder.ico</file> | ||
<file>Resources/image.ico</file> | ||
<file>Resources/delete.ico</file> | ||
<file>Resources/refresh.ico</file> | ||
<file>Resources/configuration.ico</file> | ||
<file>Resources/folder_network.ico</file> | ||
<file>Resources/file_blue.ico</file> | ||
<file>Resources/add.ico</file> | ||
<file>Resources/fit_to_size.ico</file> | ||
<file>Resources/fix.ico</file> | ||
<file>Resources/restart.ico</file> | ||
<file>Resources/select.png</file> | ||
<file>Resources/anno.ico</file> | ||
<file>Resources/new.ico</file> | ||
<file>Resources/copy.ico</file> | ||
<file>Resources/find.ico</file> | ||
<file>Resources/nav_back.ico</file> | ||
<file>Resources/nav_forward.ico</file> | ||
<file>Resources/rename.ico</file> | ||
<file>Resources/clean.ico</file> | ||
<file>Resources/tree_view.ico</file> | ||
<file>Resources/component.ico</file> | ||
<file>Resources/search-inside.ico</file> | ||
</qresource> | ||
</RCC> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include "NavigationModel.h" | ||
|
||
void NavigationModel::Clear() { | ||
paths_.clear(); | ||
set_current_path({}); | ||
set_can_back(false); | ||
set_can_forward(false); | ||
} | ||
|
||
void NavigationModel::SetPath(const QString & path) { | ||
if (path.isEmpty()) { | ||
return; | ||
} | ||
|
||
while (index_ + 1 < paths_.size()) { | ||
paths_.removeLast(); | ||
} | ||
|
||
while (paths_.size() > 100) { | ||
paths_.removeFirst(); | ||
} | ||
|
||
paths_ << path; | ||
index_ = paths_.size() - 1; | ||
|
||
set_current_path(path); | ||
set_can_back(index_ > 0); | ||
set_can_forward(false); | ||
|
||
} | ||
|
||
void NavigationModel::Back() { | ||
if (index_ > 0) { | ||
index_--; | ||
set_current_path(paths_[index_]); | ||
set_can_back(index_ > 0); | ||
set_can_forward(true); | ||
} | ||
} | ||
|
||
void NavigationModel::Forward() { | ||
if (index_ + 1 < paths_.size()) { | ||
index_++; | ||
set_current_path(paths_[index_]); | ||
set_can_back(true); | ||
set_can_forward(index_ + 1 < paths_.size()); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#pragma once | ||
#include <QObject> | ||
#include <QString> | ||
#include "implement_q_property.h" | ||
|
||
class NavigationModel : public QObject { | ||
Q_OBJECT | ||
|
||
public: | ||
NavigationModel(QObject *parent) : QObject(parent) {} | ||
~NavigationModel() {} | ||
|
||
Q_PROPERTY(QString current_path READ get_current_path WRITE set_current_path NOTIFY current_path_changed); | ||
Q_PROPERTY(bool can_back READ get_can_back WRITE set_can_back NOTIFY can_back_changed); | ||
Q_PROPERTY(bool can_forward READ get_can_forward WRITE set_can_forward NOTIFY can_forward_changed); | ||
|
||
void SetPath(const QString & path); | ||
|
||
signals: | ||
void current_path_changed(QString); | ||
void can_back_changed(bool); | ||
void can_forward_changed(bool); | ||
|
||
public slots: | ||
void Back(); | ||
void Forward(); | ||
void Clear(); | ||
|
||
private: | ||
IMPLEMENT_Q_PROPERTY_WRITE(QString, current_path); | ||
IMPLEMENT_Q_PROPERTY_WRITE(bool, can_back); | ||
IMPLEMENT_Q_PROPERTY_WRITE(bool, can_forward); | ||
|
||
private: | ||
QString current_path_; | ||
|
||
bool can_back_ = false; | ||
bool can_forward_ = false; | ||
|
||
int index_ = 0; | ||
|
||
QStringList paths_; | ||
|
||
public: | ||
IMPLEMENT_Q_PROPERTY_READ(current_path); | ||
IMPLEMENT_Q_PROPERTY_READ(can_back); | ||
IMPLEMENT_Q_PROPERTY_READ(can_forward); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Anno Labeling Tool | ||
// 2020-2024 (c) urobots GmbH, https://urobots.io/en/portfolio/anno/ | ||
#include "NavigationWidget.h" | ||
|
||
NavigationWidget::NavigationWidget(NavigationModel *model, QWidget *parent) | ||
: QWidget(parent) | ||
, model_(model) | ||
{ | ||
ui.setupUi(this); | ||
|
||
connect(model_, &NavigationModel::current_path_changed, ui.filename_lineEdit, &QLineEdit::setText); | ||
connect(model_, &NavigationModel::can_back_changed, ui.back_toolButton, &QToolButton::setEnabled); | ||
connect(model_, &NavigationModel::can_forward_changed, ui.forward_toolButton, &QToolButton::setEnabled); | ||
|
||
connect(ui.back_toolButton, &QToolButton::clicked, model_, &NavigationModel::Back); | ||
connect(ui.forward_toolButton, &QToolButton::clicked, model_, &NavigationModel::Forward); | ||
|
||
ui.back_toolButton->setEnabled(false); | ||
ui.forward_toolButton->setEnabled(false); | ||
} | ||
|
||
NavigationWidget::~NavigationWidget() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#pragma once | ||
#include "NavigationModel.h" | ||
#include "ui_NavigationWidget.h" | ||
#include <QWidget> | ||
|
||
|
||
class NavigationWidget : public QWidget | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
NavigationWidget(NavigationModel *model, QWidget *parent = nullptr); | ||
~NavigationWidget(); | ||
|
||
signals: | ||
|
||
public slots: | ||
|
||
|
||
private: | ||
Ui::NavigationWidget ui; | ||
NavigationModel *model_; | ||
}; |
Oops, something went wrong.