This commit is contained in:
Martin Rotter 2022-01-14 08:15:45 +01:00
parent 361a0f2b31
commit 217a3c9706
4 changed files with 39 additions and 2 deletions

View File

@ -178,6 +178,7 @@ QList<QAction*> FormMain::allActions() const {
actions << m_ui->m_actionStopRunningItemsUpdate;
actions << m_ui->m_actionEditSelectedItem;
actions << m_ui->m_actionCopyUrlSelectedFeed;
actions << m_ui->m_actionCopyUrlSelectedArticles;
actions << m_ui->m_actionDeleteSelectedItem;
actions << m_ui->m_actionServiceAdd;
actions << m_ui->m_actionServiceEdit;
@ -428,6 +429,7 @@ void FormMain::updateMessageButtonsAvailability() {
m_ui->m_actionMarkSelectedMessagesAsUnread->setEnabled(atleast_one_message_selected);
m_ui->m_actionOpenSelectedMessagesInternally->setEnabled(atleast_one_message_selected);
m_ui->m_actionOpenSelectedSourceArticlesExternally->setEnabled(atleast_one_message_selected);
m_ui->m_actionCopyUrlSelectedArticles->setEnabled(atleast_one_message_selected);
m_ui->m_actionSendMessageViaEmail->setEnabled(one_message_selected);
m_ui->m_actionSwitchImportanceOfSelectedMessages->setEnabled(atleast_one_message_selected);
}
@ -543,6 +545,7 @@ void FormMain::setupIcons() {
m_ui->m_actionDeleteSelectedMessages->setIcon(icon_theme_factory->fromTheme(QSL("mail-mark-junk")));
m_ui->m_actionEditSelectedItem->setIcon(icon_theme_factory->fromTheme(QSL("document-edit")));
m_ui->m_actionCopyUrlSelectedFeed->setIcon(icon_theme_factory->fromTheme(QSL("edit-copy")));
m_ui->m_actionCopyUrlSelectedArticles->setIcon(icon_theme_factory->fromTheme(QSL("edit-copy")));
m_ui->m_actionMarkAllItemsRead->setIcon(icon_theme_factory->fromTheme(QSL("mail-mark-read")));
m_ui->m_actionMarkSelectedItemsAsRead->setIcon(icon_theme_factory->fromTheme(QSL("mail-mark-read")));
m_ui->m_actionMarkSelectedItemsAsUnread->setIcon(icon_theme_factory->fromTheme(QSL("mail-mark-unread")));
@ -789,6 +792,8 @@ void FormMain::createConnections() {
&QAction::triggered, qApp->feedReader(), &FeedReader::stopRunningFeedUpdate);
connect(m_ui->m_actionCopyUrlSelectedFeed,
&QAction::triggered, tabWidget()->feedMessageViewer()->feedsView(), &FeedsView::copyUrlOfSelectedFeeds);
connect(m_ui->m_actionCopyUrlSelectedArticles,
&QAction::triggered, tabWidget()->feedMessageViewer()->messagesView(), &MessagesView::copyUrlOfSelectedArticles);
connect(m_ui->m_actionEditSelectedItem,
&QAction::triggered, tabWidget()->feedMessageViewer()->feedsView(), &FeedsView::editSelectedItem);
connect(m_ui->m_actionViewSelectedItemsNewspaperMode,

View File

@ -45,7 +45,7 @@
<x>0</x>
<y>0</y>
<width>1296</width>
<height>21</height>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="m_menuFile">
@ -148,6 +148,7 @@
<addaction name="m_actionSelectPreviousMessage"/>
<addaction name="m_actionSelectNextUnreadMessage"/>
<addaction name="separator"/>
<addaction name="m_actionCopyUrlSelectedArticles"/>
<addaction name="m_actionMarkSelectedMessagesAsRead"/>
<addaction name="m_actionMarkSelectedMessagesAsUnread"/>
<addaction name="m_actionSwitchImportanceOfSelectedMessages"/>
@ -775,7 +776,7 @@
</action>
<action name="m_actionCopyUrlSelectedFeed">
<property name="text">
<string>&amp;Copy URLs of selected item</string>
<string>&amp;Copy URL of selected item</string>
</property>
</action>
<action name="m_actionShowOnlyUnreadMessages">
@ -841,6 +842,11 @@
<string>Close &amp;current tab</string>
</property>
</action>
<action name="m_actionCopyUrlSelectedArticles">
<property name="text">
<string>&amp;Copy URLs of selected articles</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>

View File

@ -5,6 +5,7 @@
#include "3rd-party/boolinq/boolinq.h"
#include "core/messagesmodel.h"
#include "core/messagesproxymodel.h"
#include "definitions/definitions.h"
#include "gui/dialogs/formmain.h"
#include "gui/messagebox.h"
#include "gui/reusable/labelsmenu.h"
@ -15,9 +16,11 @@
#include "miscellaneous/settings.h"
#include "network-web/networkfactory.h"
#include "network-web/webfactory.h"
#include "qnamespace.h"
#include "services/abstract/labelsnode.h"
#include "services/abstract/serviceroot.h"
#include <QClipboard>
#include <QFileIconProvider>
#include <QKeyEvent>
#include <QMenu>
@ -110,6 +113,26 @@ void MessagesView::restoreHeaderState(const QByteArray& dta) {
}
}
void MessagesView::copyUrlOfSelectedArticles() const {
const QModelIndexList selected_indexes = selectionModel()->selectedRows();
if (selected_indexes.isEmpty()) {
return;
}
const QModelIndexList mapped_indexes = m_proxyModel->mapListToSource(selected_indexes);
QStringList urls;
for (const auto article_idx : mapped_indexes) {
urls << m_sourceModel->data(m_sourceModel->index(article_idx.row(), MSG_DB_URL_INDEX),
Qt::ItemDataRole::EditRole).toString();
}
if (qApp->clipboard() != nullptr && !urls.isEmpty()) {
qApp->clipboard()->setText(urls.join(TextFactory::newline()));
}
}
void MessagesView::sort(int column, Qt::SortOrder order,
bool repopulate_data, bool change_header,
bool emit_changed_from_header,
@ -346,6 +369,7 @@ void MessagesView::initializeContextMenu() {
<< qApp->mainForm()->m_ui->m_actionSendMessageViaEmail
<< qApp->mainForm()->m_ui->m_actionOpenSelectedSourceArticlesExternally
<< qApp->mainForm()->m_ui->m_actionOpenSelectedMessagesInternally
<< qApp->mainForm()->m_ui->m_actionCopyUrlSelectedArticles
<< qApp->mainForm()->m_ui->m_actionMarkSelectedMessagesAsRead
<< qApp->mainForm()->m_ui->m_actionMarkSelectedMessagesAsUnread
<< qApp->mainForm()->m_ui->m_actionSwitchImportanceOfSelectedMessages

View File

@ -28,6 +28,8 @@ class MessagesView : public BaseTreeView {
void restoreHeaderState(const QByteArray& dta);
public slots:
void copyUrlOfSelectedArticles() const;
void keyboardSearch(const QString& search);
// Called after data got changed externally