Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions src/scriptable/scriptableproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@
QVariantMap ScriptableProxy::nextItem(const QString &tabName, int where)
{
INVOKE(nextItem, (tabName, where));
ClipboardBrowser *c = fetchBrowser(tabName);
ClipboardBrowser *c = fetchExistingBrowser(tabName);
if (!c)
return QVariantMap();

Expand All @@ -1097,7 +1097,7 @@
void ScriptableProxy::browserMoveToClipboard(const QString &tabName, int row)
{
INVOKE2(browserMoveToClipboard, (tabName, row));
ClipboardBrowser *c = fetchBrowser(tabName);
ClipboardBrowser *c = fetchExistingBrowser(tabName);
m_wnd->moveToClipboard(c, row);
}

Expand Down Expand Up @@ -1138,7 +1138,7 @@
{
INVOKE2(browserMoveSelected, (targetRow, tabName));

ClipboardBrowser *c = fetchBrowser(tabName);
ClipboardBrowser *c = fetchExistingBrowser(tabName);
if (c == nullptr)
return;

Expand Down Expand Up @@ -1291,7 +1291,7 @@
int ScriptableProxy::browserLength(const QString &tabName)
{
INVOKE(browserLength, (tabName));
ClipboardBrowser *c = fetchBrowser(tabName);
ClipboardBrowser *c = fetchExistingBrowser(tabName);
return c ? c->length() : 0;
}

Expand Down Expand Up @@ -1381,7 +1381,7 @@
{
INVOKE(currentItem, (tabName));

ClipboardBrowser *c = fetchBrowser(tabName);
ClipboardBrowser *c = fetchExistingBrowser(tabName);
if (!c)
return -1;

Expand Down Expand Up @@ -1415,7 +1415,7 @@
{
INVOKE(selectedItems, (tabName));

ClipboardBrowser *c = fetchBrowser(tabName);
ClipboardBrowser *c = fetchExistingBrowser(tabName);
if (c == nullptr)
return {};

Expand Down Expand Up @@ -1443,7 +1443,7 @@
{
INVOKE(selectedItemData, (selectedIndex, tabName));

ClipboardBrowser *c = fetchBrowser(tabName);
ClipboardBrowser *c = fetchExistingBrowser(tabName);
if (c == nullptr)
return {};

Expand Down Expand Up @@ -1473,7 +1473,7 @@
{
INVOKE(selectedItemsData, (tabName));

ClipboardBrowser *c = fetchBrowser(tabName);
ClipboardBrowser *c = fetchExistingBrowser(tabName);
if (c == nullptr)
return {};

Expand Down Expand Up @@ -2404,11 +2404,28 @@
{
if (tabName.isEmpty()) {
const QString defaultTabName = m_actionData.value(mimeCurrentTab).toString();
if (!defaultTabName.isEmpty())

Check warning on line 2407 in src/scriptable/scriptableproxy.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use the init-statement to declare "defaultTabName" inside the if statement.

See more on https://sonarcloud.io/project/issues?id=hluk_CopyQ&issues=AZrJNf2OJDYOMKshhRRi&open=AZrJNf2OJDYOMKshhRRi&pullRequest=3333
return fetchBrowser(defaultTabName);
return m_wnd->browser(0);
}

return m_wnd->tab(tabName);
}

ClipboardBrowser *ScriptableProxy::fetchExistingBrowser(const QString &tabName)
{
if (tabName.isEmpty()) {
const QString defaultTabName = m_actionData.value(mimeCurrentTab).toString();
if (!defaultTabName.isEmpty())

Check warning on line 2419 in src/scriptable/scriptableproxy.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use the init-statement to declare "defaultTabName" inside the if statement.

See more on https://sonarcloud.io/project/issues?id=hluk_CopyQ&issues=AZrJNf2OJDYOMKshhRRj&open=AZrJNf2OJDYOMKshhRRj&pullRequest=3333
return fetchExistingBrowser(defaultTabName);
return m_wnd->browser(0);
}

return tabName.isEmpty() ? m_wnd->browser(0) : m_wnd->tab(tabName);
const int i = m_wnd->findTabIndex(tabName);
if (i == -1)
return nullptr;

return m_wnd->browser(i);
}

ClipboardBrowser *ScriptableProxy::selectedBrowser()
Expand All @@ -2424,7 +2441,7 @@

QVariantMap ScriptableProxy::itemData(const QString &tabName, int i)
{
auto c = fetchBrowser(tabName);
auto c = fetchExistingBrowser(tabName);
return c ? c->copyIndex( c->index(i) ) : QVariantMap();
}

Expand Down
1 change: 1 addition & 0 deletions src/scriptable/scriptableproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ public slots:

private:
ClipboardBrowser *fetchBrowser(const QString &tabName);
ClipboardBrowser *fetchExistingBrowser(const QString &tabName);

ClipboardBrowser *selectedBrowser();

Expand Down
6 changes: 3 additions & 3 deletions src/tests/tests_other.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,10 +451,10 @@ void Tests::externalEditor()
void Tests::nextPreviousTab()
{
const auto tab1 = testTab(1);
RUN("tab" << tab1 << "size", "0\n");

const auto tab2 = testTab(2);
RUN("tab" << tab2 << "size", "0\n");
const auto setTabsCommand =
QStringLiteral("config('tabs', ['%1','%2'])").arg(tab1, tab2);
RUN(setTabsCommand, tab1 + "\n" + tab2 + "\n");

using KeyPair = QPair<QString, QString>;
const QList<KeyPair> keyPairs = QList<KeyPair>()
Expand Down
Loading