From 32b867e37d14f3062ee81fc1f534e903215982d0 Mon Sep 17 00:00:00 2001 From: sungmin ha Date: Thu, 26 Mar 2015 13:30:35 +0900 Subject: [PATCH] detailed info: modified table width to contents Change-Id: I8c7f9616ebf328916b96f42830ffc530b01bcbf3 Signed-off-by: sungmin ha --- tizen/src/ui/menu/detailedinfodialog.cpp | 63 ++++++++++++++---------- tizen/src/ui/menu/detailedinfodialog.h | 4 ++ 2 files changed, 42 insertions(+), 25 deletions(-) diff --git a/tizen/src/ui/menu/detailedinfodialog.cpp b/tizen/src/ui/menu/detailedinfodialog.cpp index ecc7084fff..9cbe2db80a 100644 --- a/tizen/src/ui/menu/detailedinfodialog.cpp +++ b/tizen/src/ui/menu/detailedinfodialog.cpp @@ -54,7 +54,7 @@ DetailedInfoDialog::DetailedInfoDialog(QWidget *parent) : upsideLayout->setSpacing(0); /* tab */ - QTabWidget *tabWidget = new QTabWidget(this); + tabWidget = new QTabWidget(this); QWidget *vmInfo = new QWidget; QWidget *shortcutInfo = new QWidget; tabWidget->addTab(vmInfo, tr("VM Info")); @@ -65,16 +65,23 @@ DetailedInfoDialog::DetailedInfoDialog(QWidget *parent) : vmInfoTable->setColumnCount(2); vmInfoTable->setEditTriggers(QAbstractItemView::NoEditTriggers); vmInfoTable->setAlternatingRowColors(true); - vmInfoTable->verticalHeader()->hide(); - vmInfoTable->resizeRowsToContents(); - vmInfoTable->horizontalHeader()->setStretchLastSection(true); - vmInfoTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); QStringList header; header << "Feature" << "Value"; vmInfoTable->setHorizontalHeaderLabels(header); + /* shortcut info table */ + shortcutInfoTable = new QTableWidget(shortcutInfo); + shortcutInfoTable->setColumnCount(2); + shortcutInfoTable->setEditTriggers(QAbstractItemView::NoEditTriggers); + shortcutInfoTable->setAlternatingRowColors(true); + shortcutInfoTable->verticalHeader()->hide(); + + header.clear(); + header << "Function" << "Key sequence"; + shortcutInfoTable->setHorizontalHeaderLabels(header); + /* table items */ int index = 0; setDataTable(vmInfoTable, "VM Name", win->uiInfo->vmName, index++); @@ -110,28 +117,13 @@ DetailedInfoDialog::DetailedInfoDialog(QWidget *parent) : int tableHeight = vmInfoTable->horizontalHeader()->height(); for (int i = 0; i < vmInfoTable->rowCount(); i++) { - tableHeight += vmInfoTable->rowHeight(i); + tableHeight += vmInfoTable->rowHeight(i); } - vmInfoTable->setMinimumWidth(200); - vmInfoTable->setMinimumHeight(tableHeight + 2/*border*/); + vmInfoTable->setMinimumHeight(tableHeight + TABLE_BORDER_SIZE); + shortcutInfoTable->setMinimumHeight(tableHeight + TABLE_BORDER_SIZE); - /* shortcut info table */ - shortcutInfoTable = new QTableWidget(shortcutInfo); - shortcutInfoTable->setColumnCount(2); - shortcutInfoTable->setEditTriggers(QAbstractItemView::NoEditTriggers); - shortcutInfoTable->setAlternatingRowColors(true); - - shortcutInfoTable->verticalHeader()->hide(); - shortcutInfoTable->horizontalHeader()->setStretchLastSection(true); - shortcutInfoTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); - shortcutInfoTable->setMinimumHeight(tableHeight + 2); - - header.clear(); - header << "Function" << "Key sequence"; - shortcutInfoTable->setHorizontalHeaderLabels(header); - - tabWidget->setMinimumWidth(vmInfoTable->width() + 60); - tabWidget->setMinimumHeight(vmInfoTable->height() + 30); + QSize tabSize = tabWidget->tabBar()->sizeHint(); + tabWidget->setMinimumHeight(vmInfoTable->height() + tabSize.height() + TABLE_BORDER_SIZE); upsideLayout->addWidget(tabWidget); @@ -166,6 +158,24 @@ void DetailedInfoDialog::setDataTable(QTableWidget* table, QString key, QString table->setItem(index, 0, item); item = new QTableWidgetItem(value); table->setItem(index, 1, item); + + resizeTableWidth(); +} + +void DetailedInfoDialog::resizeTableWidth() +{ + vmInfoTable->resizeColumnsToContents(); + shortcutInfoTable->resizeColumnsToContents(); + + QSize scrollBarSize = shortcutInfoTable->verticalScrollBar()->sizeHint(); + int vtWidth = vmInfoTable->columnWidth(0) + vmInfoTable->columnWidth(1) + TABLE_BORDER_SIZE; + int stWidth = shortcutInfoTable->columnWidth(0) + shortcutInfoTable->columnWidth(1) + + scrollBarSize.width() + TABLE_BORDER_SIZE; + int tableMinWidth = (vtWidth > stWidth) ? vtWidth : stWidth; + + vmInfoTable->setMinimumWidth(tableMinWidth); + shortcutInfoTable->setMinimumWidth(tableMinWidth); + tabWidget->setMinimumWidth(tableMinWidth + TAB_BORDER_SIZE); } void DetailedInfoDialog::removeDataTable(QTableWidget* table, int startIndex, int lastIndex) @@ -242,6 +252,9 @@ void DetailedInfoDialog::showEvent(QShowEvent *event) setShortcutInfoTable(keyboardShortcut->getPopupMenuShortcutMap()); setShortcutInfoTable(keyboardShortcut->getHwKeyShortcutMap()); setShortcutInfoTable(keyboardShortcut->getControllerShortcutMap()); + + vmInfoTable->horizontalHeader()->setStretchLastSection(true); + shortcutInfoTable->horizontalHeader()->setStretchLastSection(true); } QTableWidget *DetailedInfoDialog::getShortcutInfoTable() diff --git a/tizen/src/ui/menu/detailedinfodialog.h b/tizen/src/ui/menu/detailedinfodialog.h index c63b114a32..cd65f6f797 100644 --- a/tizen/src/ui/menu/detailedinfodialog.h +++ b/tizen/src/ui/menu/detailedinfodialog.h @@ -36,6 +36,8 @@ #include "keyboardshortcut.h" #define DETAILED_INFO_TITLE "Detailed Info" +#define TABLE_BORDER_SIZE 2 +#define TAB_BORDER_SIZE 4 class DetailedInfoDialog : public QDialog { @@ -57,6 +59,7 @@ public slots: void slotDoubleClicked(int nRow, int nCol); private: + void resizeTableWidth(); QStringList getImagePathList(); QVBoxLayout *baseLayout; QHBoxLayout *upsideLayout; @@ -66,6 +69,7 @@ private: QHBoxLayout *downsideLayout; QPushButton *okBtn; KeyboardShortcut* keyboardShortcut; + QTabWidget *tabWidget; }; #endif // DETAILEDINFODIALOG_H -- 2.34.1