Merge pull request #601 from Blubbz0r/#2913-Open-Containing-Folder
Added context menu item Open containing folder (Ticket #2913)
This commit is contained in:
commit
a029ba39f6
|
@ -34,6 +34,8 @@
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
#include <QUrl>
|
||||||
#include <QContextMenuEvent>
|
#include <QContextMenuEvent>
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
@ -130,7 +132,7 @@ bool ResultsTree::AddErrorItem(const ErrorItem &item)
|
||||||
line.severity = item.severity;
|
line.severity = item.severity;
|
||||||
//Create the base item for the error and ensure it has a proper
|
//Create the base item for the error and ensure it has a proper
|
||||||
//file item as a parent
|
//file item as a parent
|
||||||
QStandardItem *stditem = AddBacktraceFiles(EnsureFileItem(line.file, item.file0, hide),
|
QStandardItem *stditem = AddBacktraceFiles(EnsureFileItem(item.files[0], item.file0, hide),
|
||||||
line,
|
line,
|
||||||
hide,
|
hide,
|
||||||
SeverityToIcon(line.severity));
|
SeverityToIcon(line.severity));
|
||||||
|
@ -536,6 +538,7 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
|
||||||
QAction *copymessageid = new QAction(tr("Copy message id"), &menu);
|
QAction *copymessageid = new QAction(tr("Copy message id"), &menu);
|
||||||
QAction *hide = new QAction(tr("Hide"), &menu);
|
QAction *hide = new QAction(tr("Hide"), &menu);
|
||||||
QAction *hideallid = new QAction(tr("Hide all with id"), &menu);
|
QAction *hideallid = new QAction(tr("Hide all with id"), &menu);
|
||||||
|
QAction *opencontainingfolder = new QAction(tr("Open containing folder"), &menu);
|
||||||
|
|
||||||
if (multipleSelection) {
|
if (multipleSelection) {
|
||||||
copyfilename->setDisabled(true);
|
copyfilename->setDisabled(true);
|
||||||
|
@ -543,6 +546,7 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
|
||||||
copymessage->setDisabled(true);
|
copymessage->setDisabled(true);
|
||||||
copymessageid->setDisabled(true);
|
copymessageid->setDisabled(true);
|
||||||
hideallid->setDisabled(true);
|
hideallid->setDisabled(true);
|
||||||
|
opencontainingfolder->setDisabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
menu.addAction(copyfilename);
|
menu.addAction(copyfilename);
|
||||||
|
@ -551,6 +555,7 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
|
||||||
menu.addAction(copymessageid);
|
menu.addAction(copymessageid);
|
||||||
menu.addAction(hide);
|
menu.addAction(hide);
|
||||||
menu.addAction(hideallid);
|
menu.addAction(hideallid);
|
||||||
|
menu.addAction(opencontainingfolder);
|
||||||
|
|
||||||
connect(copyfilename, SIGNAL(triggered()), this, SLOT(CopyFilename()));
|
connect(copyfilename, SIGNAL(triggered()), this, SLOT(CopyFilename()));
|
||||||
connect(copypath, SIGNAL(triggered()), this, SLOT(CopyFullPath()));
|
connect(copypath, SIGNAL(triggered()), this, SLOT(CopyFullPath()));
|
||||||
|
@ -558,6 +563,7 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
|
||||||
connect(copymessageid, SIGNAL(triggered()), this, SLOT(CopyMessageId()));
|
connect(copymessageid, SIGNAL(triggered()), this, SLOT(CopyMessageId()));
|
||||||
connect(hide, SIGNAL(triggered()), this, SLOT(HideResult()));
|
connect(hide, SIGNAL(triggered()), this, SLOT(HideResult()));
|
||||||
connect(hideallid, SIGNAL(triggered()), this, SLOT(HideAllIdResult()));
|
connect(hideallid, SIGNAL(triggered()), this, SLOT(HideAllIdResult()));
|
||||||
|
connect(opencontainingfolder, SIGNAL(triggered()), this, SLOT(OpenContainingFolder()));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Start the menu
|
//Start the menu
|
||||||
|
@ -705,12 +711,12 @@ QString ResultsTree::AskFileDir(const QString &file)
|
||||||
|
|
||||||
void ResultsTree::CopyFilename()
|
void ResultsTree::CopyFilename()
|
||||||
{
|
{
|
||||||
CopyPath(mContextItem, false);
|
CopyPathToClipboard(mContextItem, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResultsTree::CopyFullPath()
|
void ResultsTree::CopyFullPath()
|
||||||
{
|
{
|
||||||
CopyPath(mContextItem, true);
|
CopyPathToClipboard(mContextItem, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResultsTree::CopyMessage()
|
void ResultsTree::CopyMessage()
|
||||||
|
@ -810,6 +816,16 @@ void ResultsTree::HideAllIdResult()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ResultsTree::OpenContainingFolder()
|
||||||
|
{
|
||||||
|
QString filePath = GetFilePath(mContextItem, true);
|
||||||
|
if (!filePath.isEmpty())
|
||||||
|
{
|
||||||
|
filePath = QFileInfo(filePath).absolutePath();
|
||||||
|
QDesktopServices::openUrl(QUrl::fromLocalFile(filePath));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ResultsTree::Context(int application)
|
void ResultsTree::Context(int application)
|
||||||
{
|
{
|
||||||
StartApplication(mContextItem, application);
|
StartApplication(mContextItem, application);
|
||||||
|
@ -820,7 +836,13 @@ void ResultsTree::QuickStartApplication(const QModelIndex &index)
|
||||||
StartApplication(mModel.itemFromIndex(index));
|
StartApplication(mModel.itemFromIndex(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResultsTree::CopyPath(QStandardItem *target, bool fullPath)
|
void ResultsTree::CopyPathToClipboard(QStandardItem *target, bool fullPath)
|
||||||
|
{
|
||||||
|
QClipboard *clipboard = QApplication::clipboard();
|
||||||
|
clipboard->setText(GetFilePath(target, fullPath));
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ResultsTree::GetFilePath(QStandardItem *target, bool fullPath)
|
||||||
{
|
{
|
||||||
if (target) {
|
if (target) {
|
||||||
// Make sure we are working with the first column
|
// Make sure we are working with the first column
|
||||||
|
@ -838,9 +860,10 @@ void ResultsTree::CopyPath(QStandardItem *target, bool fullPath)
|
||||||
pathStr = fi.fileName();
|
pathStr = fi.fileName();
|
||||||
}
|
}
|
||||||
|
|
||||||
QClipboard *clipboard = QApplication::clipboard();
|
return pathStr;
|
||||||
clipboard->setText(pathStr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ResultsTree::SeverityToIcon(Severity::SeverityType severity) const
|
QString ResultsTree::SeverityToIcon(Severity::SeverityType severity) const
|
||||||
|
|
|
@ -223,6 +223,11 @@ protected slots:
|
||||||
*/
|
*/
|
||||||
void HideAllIdResult();
|
void HideAllIdResult();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Slot for context menu item to open the folder containing the current file.
|
||||||
|
*/
|
||||||
|
void OpenContainingFolder();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Slot for selection change in the results tree.
|
* @brief Slot for selection change in the results tree.
|
||||||
*
|
*
|
||||||
|
@ -285,7 +290,15 @@ protected:
|
||||||
* @param target Error tree item to open
|
* @param target Error tree item to open
|
||||||
* @param fullPath Are we copying full path or only filename?
|
* @param fullPath Are we copying full path or only filename?
|
||||||
*/
|
*/
|
||||||
void CopyPath(QStandardItem *target, bool fullPath);
|
void CopyPathToClipboard(QStandardItem *target, bool fullPath);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Helper function returning the filename/full path of the error tree item \a target.
|
||||||
|
*
|
||||||
|
* @param target The error tree item containing the filename/full path
|
||||||
|
* @param fullPath Whether or not to retrieve the full path or only the filename.
|
||||||
|
*/
|
||||||
|
QString GetFilePath(QStandardItem *target, bool fullPath);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Context menu event (user right clicked on the tree)
|
* @brief Context menu event (user right clicked on the tree)
|
||||||
|
|
Loading…
Reference in New Issue