From 7dcdedc39f66f71f1532b63a13679e02673ef43f Mon Sep 17 00:00:00 2001 From: Hemant Kumar Date: Sat, 10 Jan 2015 08:55:08 -0500 Subject: [PATCH] View file can be very valuable lets add it in all snapshot views. --- rbkit-lib/ui/diffviewform.cpp | 2 +- rbkit-lib/ui/heapdumpform.cpp | 39 ++++++++++++++++++++------------ rbkit-lib/ui/heapdumpform.h | 13 ++++++++--- rbkit-lib/ui/rbkitmainwindow.cpp | 2 +- 4 files changed, 37 insertions(+), 19 deletions(-) diff --git a/rbkit-lib/ui/diffviewform.cpp b/rbkit-lib/ui/diffviewform.cpp index 4358324..7efe321 100644 --- a/rbkit-lib/ui/diffviewform.cpp +++ b/rbkit-lib/ui/diffviewform.cpp @@ -52,7 +52,7 @@ void DiffViewForm::initializeParentView() ui->treeVerticalLayout->addWidget(parentLabel); parentViewForm = new HeapDumpForm(this, -1); parentViewForm->setMaximumHeight(200); - parentViewForm->setDisableRightClick(true); + parentViewForm->setContextDetail(RbkitContextDetail::ONLY_FILE); parentViewForm->setParentWindow(getParentWindow()); ui->treeVerticalLayout->addWidget(parentViewForm); parentViewForm->show(); diff --git a/rbkit-lib/ui/heapdumpform.cpp b/rbkit-lib/ui/heapdumpform.cpp index 7623ec7..dfac8b3 100644 --- a/rbkit-lib/ui/heapdumpform.cpp +++ b/rbkit-lib/ui/heapdumpform.cpp @@ -21,8 +21,19 @@ RBKit::BaseHeapItem *HeapDumpForm::getRootItem() const return rootItem; } + +RbkitContextDetail HeapDumpForm::getContextDetail() const +{ + return contextDetail; +} + +void HeapDumpForm::setContextDetail(const RbkitContextDetail &value) +{ + contextDetail = value; +} + HeapDumpForm::HeapDumpForm(QWidget* parent, int _snapShotVersion) - : QWidget(parent), ui(new Ui::HeapDumpForm), snapShotVersion(_snapShotVersion), disableRightClick(false) + : QWidget(parent), ui(new Ui::HeapDumpForm), snapShotVersion(_snapShotVersion), contextDetail(RbkitContextDetail::ALL) { selecteItem = NULL; ui->setupUi(this); @@ -54,13 +65,6 @@ HeapDumpForm::~HeapDumpForm() delete viewRefAct; } -void HeapDumpForm::setDisableRightClick(bool value) { - disableRightClick = value; -} - -bool HeapDumpForm::getDisableRightClick() const { - return disableRightClick; -} void HeapDumpForm::setTreeModel(SortObjectProxyModel *model) { @@ -117,16 +121,23 @@ void HeapDumpForm::adjustColumnWidth() void HeapDumpForm::onCustomContextMenu(const QPoint &point) { - if (disableRightClick) + if (contextDetail == RbkitContextDetail::NONE) return; QPoint localPoint = ui->treeView->viewport()->mapToGlobal(point); QModelIndex index = proxyModel->mapToSource(ui->treeView->indexAt(point)); if (index.isValid()) { selecteItem = static_cast(index.internalPointer()); QMenu menu(this); - menu.addAction(viewRefAct); - menu.addAction(viewParentsAct); - menu.addAction(viewFileAct); + switch (contextDetail) { + case RbkitContextDetail::ONLY_FILE: + menu.addAction(viewFileAct); + break; + case RbkitContextDetail::ALL: + menu.addAction(viewRefAct); + menu.addAction(viewParentsAct); + menu.addAction(viewFileAct); + break; + } menu.exec(localPoint); } } @@ -134,7 +145,7 @@ void HeapDumpForm::onCustomContextMenu(const QPoint &point) void HeapDumpForm::viewReferences() { HeapDumpForm *form = new HeapDumpForm(this, 0); - form->setDisableRightClick(true); + form->setContextDetail(RbkitContextDetail::ONLY_FILE); form->loadSelectedReferences(selecteItem); parentWindow->addTabWidget(form, QString("References for : %0").arg(selecteItem->shortLeadingIdentifier())); } @@ -142,7 +153,7 @@ void HeapDumpForm::viewReferences() void HeapDumpForm::viewParents() { HeapDumpForm *form = new HeapDumpForm(this, -1); - form->setDisableRightClick(true); + form->setContextDetail(RbkitContextDetail::ONLY_FILE); RBKit::BaseHeapItem *parentHeapItem = selecteItem->getObjectParents(rootItem); form->loadFromSpecifiedRoot(parentHeapItem); parentWindow->addTabWidget(form, QString("Parents for : %0").arg(selecteItem->shortLeadingIdentifier())); diff --git a/rbkit-lib/ui/heapdumpform.h b/rbkit-lib/ui/heapdumpform.h index fb22a05..82f7339 100644 --- a/rbkit-lib/ui/heapdumpform.h +++ b/rbkit-lib/ui/heapdumpform.h @@ -21,6 +21,12 @@ namespace Ui { class HeapDumpForm; } +enum class RbkitContextDetail { + ALL = 0, + ONLY_FILE = 1, + NONE = 2 +}; + class RbkitMainWindow; class HeapDumpForm : public QWidget @@ -35,7 +41,7 @@ class HeapDumpForm : public QWidget SortObjectProxyModel *proxyModel; RBKit::BaseHeapItem *selecteItem; RbkitMainWindow *parentWindow; - bool disableRightClick; + RbkitContextDetail contextDetail; public: explicit HeapDumpForm(QWidget *parent = 0, int _snapShotVersion = 0); virtual ~HeapDumpForm(); @@ -45,13 +51,14 @@ class HeapDumpForm : public QWidget void loadFromSpecifiedRoot(RBKit::BaseHeapItem*_rootItem); RbkitMainWindow *getParentWindow() const; void setParentWindow(RbkitMainWindow *value); - void setDisableRightClick(bool value); - bool getDisableRightClick() const; void setTreeModel(SortObjectProxyModel* model); void reset(); RBKit::BaseHeapItem *getRootItem() const; Ui::HeapDumpForm *ui; + RbkitContextDetail getContextDetail() const; + void setContextDetail(const RbkitContextDetail &value); + private: int snapShotVersion; public slots: diff --git a/rbkit-lib/ui/rbkitmainwindow.cpp b/rbkit-lib/ui/rbkitmainwindow.cpp index c16cc8e..03aa781 100644 --- a/rbkit-lib/ui/rbkitmainwindow.cpp +++ b/rbkit-lib/ui/rbkitmainwindow.cpp @@ -260,7 +260,7 @@ void RbkitMainWindow::onDiffSnapshotsSelected(QList selectedSnapshots) DiffViewForm *form = new DiffViewForm(this, -1); form->setSnapshotDiffNumbers(selectedSnapshots); - form->setDisableRightClick(true); + form->setContextDetail(RbkitContextDetail::ONLY_FILE); form->loadFromSpecifiedRoot(newRootItem); addTabWidget(form, QString("Comapre Snapshots")); }