Skip to content

Commit

Permalink
* Open newly created query
Browse files Browse the repository at this point in the history
  • Loading branch information
trueromanus committed Dec 4, 2023
1 parent 78dfb26 commit 27d549a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
6 changes: 5 additions & 1 deletion org.emptyflow.ArdorQuery.appdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
</screenshots>

<releases>
<release version="0.0.11" date="2023-11-20"/>
<release version="0.0.12" date="2023-11-20">
<description>
<p>This stable release fixes bugs.</p>
</description>
</release>
</releases>

<content_rating type="oars-1.0" />
Expand Down
6 changes: 6 additions & 0 deletions src/ListModels/requestscommandpalettelistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ void RequestsCommandPaletteListModel::selectNext()
refresh();
}

void RequestsCommandPaletteListModel::forceSelectItem(QUuid id)
{
m_selected = m_history.indexOf(id);
selectItem();
}

void RequestsCommandPaletteListModel::refresh(bool needRecreateHistory)
{
beginResetModel();
Expand Down
1 change: 1 addition & 0 deletions src/ListModels/requestscommandpalettelistmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class RequestsCommandPaletteListModel : public QAbstractListModel

void selectItem();
void selectNext();
void forceSelectItem(QUuid id);
void refresh(bool needRecreateHistory = false);
void recreateHistory();

Expand Down
9 changes: 7 additions & 2 deletions src/ViewModels/backendviewmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void BackendViewModel::setFocusedHelpTextField(bool focusedHelpTextField) noexce
emit focusedHelpTextFieldChanged();
}

void BackendViewModel::addNewRequest()
void BackendViewModel::addNewRequest(bool forceSelectedAddedItem)
{
auto model = new HttpRequestModel(this);

Expand All @@ -51,6 +51,11 @@ void BackendViewModel::addNewRequest()
request->setSelectedItem(0); // select first empty field for new request

m_requests->addItem(model);

if (forceSelectedAddedItem) {
m_requestsCommandPaletter->refresh(true); // recreate history
m_requestsCommandPaletter->forceSelectItem(model->requestId()); // force selection of added element
}
}

bool BackendViewModel::shortcutHandler(const QString &shortcut) noexcept
Expand Down Expand Up @@ -111,7 +116,7 @@ bool BackendViewModel::shortcutHandler(const QString &shortcut) noexcept
} else if (command == m_toggleTabsCommand) {
m_tabs->toggleTabs();
} else if (command == m_addQueryCommand) {
addNewRequest();
addNewRequest(true);
} else if (command == m_deleteSelectedQueryCommand) {
deleteCurrentRequest();
} else if (command == m_selectLastFieldCommand) {
Expand Down
2 changes: 1 addition & 1 deletion src/ViewModels/backendviewmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class BackendViewModel : public QObject
bool focusedHelpTextField() const noexcept { return m_focusedHelpTextField; }
void setFocusedHelpTextField(bool focusedHelpTextField) noexcept;

Q_INVOKABLE void addNewRequest();
Q_INVOKABLE void addNewRequest(bool forceSelectedAddedItem = false);
Q_INVOKABLE bool shortcutHandler(const QString& shortcut) noexcept;
Q_INVOKABLE void refreshFindedIndex() noexcept;
Q_INVOKABLE void openedFile(const QString& filePath) noexcept;
Expand Down

0 comments on commit 27d549a

Please sign in to comment.