From: hyunjin816.lee Date: Thu, 4 Sep 2014 11:49:24 +0000 (+0900) Subject: ui: open the folder when double click the path in DetailInfo Dialog X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F79%2F29079%2F2;p=sdk%2Femulator%2Fqemu.git ui: open the folder when double click the path in DetailInfo Dialog Change-Id: Idffd95e2d47a67c1e42fd0c2d8983afd9f8e64dd Signed-off-by: hyunjin816.lee --- diff --git a/tizen/src/ui/menu/detailedinfodialog.cpp b/tizen/src/ui/menu/detailedinfodialog.cpp index 2cc3441b42..9d9e415f44 100644 --- a/tizen/src/ui/menu/detailedinfodialog.cpp +++ b/tizen/src/ui/menu/detailedinfodialog.cpp @@ -27,8 +27,6 @@ * */ -#include - #include "detailedinfodialog.h" #include "mainwindow.h" @@ -41,17 +39,17 @@ DetailedInfoDialog::DetailedInfoDialog(QWidget *parent) : setWindowTitle("Detailed Info"); - QVBoxLayout *baseLayout = new QVBoxLayout(this); + baseLayout = new QVBoxLayout(this); baseLayout->setMargin(10); baseLayout->setSpacing(10); /* upside */ - QHBoxLayout *upsideLayout = new QHBoxLayout(); + upsideLayout = new QHBoxLayout(this); upsideLayout->setMargin(0); upsideLayout->setSpacing(0); /* VM information table */ - QTableWidget *infoTable = new QTableWidget(this); + infoTable = new QTableWidget(this); infoTable->setRowCount(11); infoTable->setColumnCount(2); infoTable->setEditTriggers(QAbstractItemView::NoEditTriggers); @@ -68,7 +66,7 @@ DetailedInfoDialog::DetailedInfoDialog(QWidget *parent) : /* table items */ int index = 0; - QTableWidgetItem *item = new QTableWidgetItem("VM Name"); + item = new QTableWidgetItem("VM Name"); infoTable->setItem(index, 0, item); item = new QTableWidgetItem(win->uiInfo->vmName); infoTable->setItem(index++, 1, item); @@ -133,6 +131,9 @@ DetailedInfoDialog::DetailedInfoDialog(QWidget *parent) : item = new QTableWidgetItem(QString::number(get_emul_serial_port())); infoTable->setItem(index++, 1, item); + /* add double click event listener */ + connect(infoTable, SIGNAL(cellDoubleClicked(int, int)), this, SLOT(slotDoubleClicked(int, int))); + int tableHeight = infoTable->horizontalHeader()->height(); for (int i = 0; i < infoTable->rowCount(); i++) { tableHeight += infoTable->rowHeight(i); @@ -145,17 +146,55 @@ DetailedInfoDialog::DetailedInfoDialog(QWidget *parent) : baseLayout->addLayout(upsideLayout); /* downside */ - QHBoxLayout *downsideLayout = new QHBoxLayout(); + downsideLayout = new QHBoxLayout(this); downsideLayout->setAlignment(Qt::AlignRight); downsideLayout->setMargin(0); - QPushButton *okBtn = new QPushButton("OK", this); + okBtn = new QPushButton("OK", this); connect(okBtn, SIGNAL(clicked()), this, SLOT(close())); downsideLayout->addWidget(okBtn); baseLayout->addLayout(downsideLayout); } +void DetailedInfoDialog::slotDoubleClicked(int nRow, int nCol) +{ + QTableWidgetItem *item; + QString string; + + /* Feature side double click event is occured, ignore it */ + if (nCol == 0) + return; + + item = infoTable->item(nRow, 0); + if (item->text().compare("File Sharing Path", Qt::CaseInsensitive) == 0 || + item->text().compare("Image Path", Qt::CaseInsensitive) == 0 || + item->text().compare("Log Path", Qt::CaseInsensitive) == 0) { + /* get path name */ + item = infoTable->item(nRow, nCol); + if (item->text().compare("None", Qt::CaseInsensitive) == 0 || + item->text().compare("", Qt::CaseInsensitive) == 0) { + /* ignore this event */ + return; + } + } else { + /* ignore this event */ + return; + } + + if (QFileInfo(item->text()).isDir() == true) { + /* path name is a directory name */ + QDesktopServices::openUrl(QUrl("file:///" + item->text(), QUrl::TolerantMode)); + } else if (QFileInfo(item->text()).isFile() == true) { + /* path name is a file name */ + QDesktopServices::openUrl(QUrl("file:///" + QFileInfo(item->text()).absolutePath(), QUrl::TolerantMode)); + } else { + qDebug("wrong path name"); + } + + return; +} + void DetailedInfoDialog::showEvent(QShowEvent *event) { Q_UNUSED(event) @@ -167,5 +206,14 @@ void DetailedInfoDialog::showEvent(QShowEvent *event) DetailedInfoDialog::~DetailedInfoDialog() { + QTableWidgetItem *item; + + for (int i = 0; i < infoTable->rowCount(); i++) { + for (int j = 0; j < infoTable->columnCount(); j++) { + item = infoTable->item(i, j); + delete item; + } + } + qDebug("destroy detailed info dialog"); } diff --git a/tizen/src/ui/menu/detailedinfodialog.h b/tizen/src/ui/menu/detailedinfodialog.h index b494528f13..3af63bed58 100644 --- a/tizen/src/ui/menu/detailedinfodialog.h +++ b/tizen/src/ui/menu/detailedinfodialog.h @@ -30,6 +30,7 @@ #ifndef DETAILEDINFODIALOG_H #define DETAILEDINFODIALOG_H +#include #include class DetailedInfoDialog : public QDialog @@ -42,6 +43,17 @@ public: protected: void showEvent(QShowEvent *event); + +public slots: + void slotDoubleClicked(int nRow, int nCol); + +private: + QVBoxLayout *baseLayout; + QHBoxLayout *upsideLayout; + QTableWidget *infoTable; + QTableWidgetItem *item; + QHBoxLayout *downsideLayout; + QPushButton *okBtn; }; #endif // DETAILEDINFODIALOG_H