2 #include "ui_qcepdatasetbrowserdialog.h"
12 #include <QMessageBox>
18 #include <QFileDialog>
31 connect(m_DatasetBrowserView, SIGNAL(doubleClicked(QModelIndex)),
this, SLOT(
onDoubleClicked(QModelIndex)));
33 m_DatasetBrowserView -> setContextMenuPolicy(Qt::CustomContextMenu);
34 m_DatasetBrowserView -> header() -> setSectionResizeMode(QHeaderView::Stretch);
46 QModelIndex index = m_DatasetBrowserView->indexAt(pt);
54 QMenu menu(NULL, NULL);
56 QString name = (obj ? obj->
pathName() :
"");
58 QAction *tt = menu.addAction(
"Data operations...");
60 tt->setDisabled(
true);
62 QMenu *nm = menu.addMenu(
"Create New");
63 QAction *ng = nm->addAction(tr(
"New Group in %1").arg(name));
68 nc = nm->addAction(tr(
"New Data Column in %1").arg(name));
70 nc = nm->addAction(tr(
"Insert Data Column after %1").arg(name));
73 QAction *ns = nm->addAction(tr(
"New Column Scan in %1").arg(name));
74 QAction *ni = nm->addAction(tr(
"New Image in %1").arg(name));
75 QAction *na = nm->addAction(tr(
"New Array in %1").arg(name));
76 QAction *rd = menu.addAction(tr(
"Read Data into %1 ...").arg(name));
77 QAction *sv = menu.addAction(tr(
"Save %1 as ...").arg(name));
78 QAction *og = menu.addAction(tr(
"Open %1 in graph window").arg(name));
79 QAction *os = menu.addAction(tr(
"Open %1 in spreadsheet window").arg(name));
80 QAction *op = menu.addAction(tr(
"Open %1 in properties window").arg(name));
81 QAction *dl = menu.addAction(tr(
"Delete %1").arg(name));
83 ng->setEnabled(grp != NULL && scn == NULL);
84 nc->setEnabled(grp != NULL || psc != NULL);
85 ns->setEnabled(grp != NULL && scn == NULL);
86 ni->setEnabled(grp != NULL && scn == NULL);
87 na->setEnabled(grp != NULL && scn == NULL);
89 nm->setEnabled(ng->isEnabled()
95 rd->setEnabled(grp != NULL);
98 QAction *action = menu.exec(QCursor::pos(), tt);
102 }
else if (action == nc) {
104 }
else if (action == ns) {
106 }
else if (action == ni) {
108 }
else if (action == na) {
110 }
else if (action == rd) {
112 }
else if (action == sv) {
114 }
else if (action == og) {
116 }
else if (action == os) {
118 }
else if (action == op) {
120 }
else if (action == dl) {
130 expt->printMessage(tr(
"QcepDatasetBrowserDialog::onDoubleClicked([%1,%2])").arg(idx.row()).arg(idx.column()));
243 static QString selectedFilter;
244 QString theFile = QFileDialog::getSaveFileName(
this,
245 "Save data in", obj->get_FileName(),
248 if (theFile.length()) {
259 if (QMessageBox::question(NULL,
"Delete Object?",
260 tr(
"Do you really want to delete %1").arg(obj->
get_Name()),
261 QMessageBox::Ok | QMessageBox::No, QMessageBox::No) == QMessageBox::Ok) {
void saveData(const QModelIndex &idx)
void onCustomContextMenuRequested(QPoint pt)
QcepDatasetBrowserDialog(QcepExperimentWPtr expt, QcepDatasetModelPtr ds, QWidget *parent=0)
void openGraph(const QModelIndex &idx)
void newGroup(const QModelIndex &idx)
virtual QcepDataGroupPtr parentItem() const
QWeakPointer< QcepExperiment > QcepExperimentWPtr
void newColumnScan(const QModelIndex &idx)
void openProperties(const QModelIndex &idx)
virtual QString fileFormatFilterString()
virtual ~QcepDatasetBrowserDialog()
void newImage(const QModelIndex &idx)
QcepDatasetModelPtr m_DatasetModel
void newArray(const QModelIndex &idx)
void newDataColumn(const QModelIndex &idx)
void readData(const QModelIndex &idx)
void openSpreadsheet(const QModelIndex &idx)
QcepExperimentWPtr m_Experiment
void onDoubleClicked(QModelIndex idx)
void deleteData(const QModelIndex &idx)
QSharedPointer< QcepExperiment > QcepExperimentPtr
QSharedPointer< QcepDatasetModel > QcepDatasetModelPtr