Content selector: allow to copy paths to clipboard (feature #2847)

pull/1948/head
Capostrophic 6 years ago
parent 5fa9b32e76
commit f20f49daa6

@ -135,6 +135,7 @@
Feature #1617: Editor: Enchantment effect record verifier
Feature #1645: Casting effects from objects
Feature #2606: Editor: Implemented (optional) case sensitive global search
Feature #2847: Content selector: allow to copy the path to a file by using the context menu
Feature #3083: Play animation when NPC is casting spell via script
Feature #3103: Provide option for disposition to get increased by successful trade
Feature #3276: Editor: Search - Show number of (remaining) search results and indicate a search without any results

@ -48,6 +48,8 @@ namespace ContentSelectorModel
QModelIndex indexFromItem(const EsmFile *item) const;
const EsmFile *item(const QString &name) const;
const EsmFile *item(int row) const;
EsmFile *item(int row);
QStringList gameFiles() const;
bool isEnabled (QModelIndex index) const;
@ -65,8 +67,6 @@ namespace ContentSelectorModel
private:
void addFile(EsmFile *file);
const EsmFile *item(int row) const;
EsmFile *item(int row);
void sortFiles();

@ -7,6 +7,7 @@
#include <QMenu>
#include <QContextMenuEvent>
#include <QClipboard>
#include <QGridLayout>
#include <QMessageBox>
#include <QModelIndex>
@ -67,6 +68,7 @@ void ContentSelectorView::ContentSelector::buildContextMenu()
mContextMenu = new QMenu(ui.addonView);
mContextMenu->addAction(tr("&Check Selected"), this, SLOT(slotCheckMultiSelectedItems()));
mContextMenu->addAction(tr("&Uncheck Selected"), this, SLOT(slotUncheckMultiSelectedItems()));
mContextMenu->addAction(tr("&Copy Path(s) to Clipboard"), this, SLOT(slotCopySelectedItemsPaths()));
}
void ContentSelectorView::ContentSelector::setProfileContent(const QStringList &fileList)
@ -245,3 +247,20 @@ void ContentSelectorView::ContentSelector::slotCheckMultiSelectedItems()
{
setCheckStateForMultiSelectedItems(true);
}
void ContentSelectorView::ContentSelector::slotCopySelectedItemsPaths()
{
QClipboard *clipboard = QApplication::clipboard();
QString filepaths;
foreach (const QModelIndex& index, ui.addonView->selectionModel()->selectedIndexes())
{
int row = mAddonProxyModel->mapToSource(index).row();
const ContentSelectorModel::EsmFile *file = mContentModel->item(row);
filepaths += file->filePath() + "\n";
}
if (!filepaths.isEmpty())
{
clipboard->setText(filepaths);
}
}

@ -70,6 +70,7 @@ namespace ContentSelectorView
void slotShowContextMenu(const QPoint& pos);
void slotCheckMultiSelectedItems();
void slotUncheckMultiSelectedItems();
void slotCopySelectedItemsPaths();
};
}

@ -62,7 +62,7 @@
</sizepolicy>
</property>
<property name="toolTip">
<string>Select a profiile</string>
<string>Select a content list</string>
</property>
</widget>
</item>

Loading…
Cancel
Save