mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2813 Origin import dialog. Copy file name context menu
This commit is contained in:
parent
6715ef5a8a
commit
39cfc687bd
@ -52,6 +52,7 @@
|
||||
#include <QAbstractItemView>
|
||||
#include <QMenu>
|
||||
#include <QDateTime>
|
||||
#include <QClipboard>
|
||||
|
||||
#include <cvfAssert.h>
|
||||
|
||||
@ -509,6 +510,10 @@ void RicSummaryCaseRestartDialog::appendFileInfoToGridLayout(QGridLayout* gridLa
|
||||
gridLayout->addWidget(fileNameLabel, rowCount, 0);
|
||||
gridLayout->addWidget(dateLabel, rowCount, 1);
|
||||
|
||||
// File name copy context menu
|
||||
fileNameLabel->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(fileNameLabel, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(slotFileNameCopyCustomMenuRequested(const QPoint&)));
|
||||
|
||||
// Full path in tooltip
|
||||
fileNameLabel->setToolTip(fullPathFileName);
|
||||
}
|
||||
@ -535,6 +540,22 @@ void RicSummaryCaseRestartDialog::displayWarningsIfAny(const QStringList& warnin
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RicSummaryCaseRestartDialog::fullFileName(const QString& shortOrFullFileName)
|
||||
{
|
||||
for (const auto& fileInfos : m_fileLists)
|
||||
{
|
||||
for (const auto& fileInfo : fileInfos)
|
||||
{
|
||||
if (fileInfo.first.fileName == shortOrFullFileName || fileInfo.second == shortOrFullFileName)
|
||||
return fileInfo.second;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -559,3 +580,38 @@ void RicSummaryCaseRestartDialog::slotDialogButtonClicked(QAbstractButton* butto
|
||||
if (cancelButtonClicked) reject();
|
||||
else accept();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSummaryCaseRestartDialog::slotFileNameCopyCustomMenuRequested(const QPoint& point)
|
||||
{
|
||||
QMenu menu;
|
||||
QPoint globalPoint = point;
|
||||
QAction* action;
|
||||
|
||||
QLabel* sourceLabel = dynamic_cast<QLabel*>(sender());
|
||||
|
||||
action = new QAction("Copy file name", this);
|
||||
action->setData(fullFileName(sourceLabel->text()));
|
||||
connect(action, SIGNAL(triggered()), SLOT(slotCopyFileNameToClipboard()));
|
||||
menu.addAction(action);
|
||||
|
||||
globalPoint = sourceLabel->mapToGlobal(point);
|
||||
menu.exec(globalPoint);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSummaryCaseRestartDialog::slotCopyFileNameToClipboard()
|
||||
{
|
||||
QAction* a = dynamic_cast<QAction*>(sender());
|
||||
|
||||
QClipboard* cb = RiaApplication::clipboard();
|
||||
if (cb)
|
||||
{
|
||||
QString fullFileName = a->data().toString();
|
||||
cb->setText(QDir::toNativeSeparators(fullFileName));
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "cafPdmPointer.h"
|
||||
|
||||
#include <QDialog>
|
||||
#include <QMenu>
|
||||
|
||||
class QLabel;
|
||||
class QRadioButton;
|
||||
@ -78,10 +79,13 @@ private:
|
||||
void appendFileInfoToGridLayout(QGridLayout* gridLayout, const RifRestartFileInfo& fileInfo, const QString& fullPathFileName);
|
||||
RifRestartFileInfo getFileInfo(const QString& summaryHeaderFile);
|
||||
void displayWarningsIfAny(const QStringList& warnings);
|
||||
QString fullFileName(const QString& shortOrFullFileName);
|
||||
|
||||
private slots:
|
||||
void slotShowFullPathToggled(int state);
|
||||
void slotDialogButtonClicked(QAbstractButton* button);
|
||||
void slotFileNameCopyCustomMenuRequested(const QPoint& point);
|
||||
void slotCopyFileNameToClipboard();
|
||||
|
||||
private:
|
||||
QGroupBox* m_currentFilesGroup;
|
||||
@ -149,4 +153,4 @@ public:
|
||||
QStringList summaryFiles;
|
||||
QStringList gridFiles;
|
||||
bool applyToAll;
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user