Skip to content

Commit

Permalink
Merge pull request #142 from code-mancers/implement-view-file-everywhere
Browse files Browse the repository at this point in the history
View file can be very valuable
  • Loading branch information
Hemant Kumar committed Jan 11, 2015
2 parents efaaf06 + 7dcdedc commit 1e1bd15
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 19 deletions.
2 changes: 1 addition & 1 deletion rbkit-lib/ui/diffviewform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
39 changes: 25 additions & 14 deletions rbkit-lib/ui/heapdumpform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -117,32 +121,39 @@ 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<RBKit::BaseHeapItem *>(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);
}
}

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()));
}

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()));
Expand Down
13 changes: 10 additions & 3 deletions rbkit-lib/ui/heapdumpform.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ namespace Ui {
class HeapDumpForm;
}

enum class RbkitContextDetail {
ALL = 0,
ONLY_FILE = 1,
NONE = 2
};

class RbkitMainWindow;

class HeapDumpForm : public QWidget
Expand All @@ -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();
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion rbkit-lib/ui/rbkitmainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ void RbkitMainWindow::onDiffSnapshotsSelected(QList<int> 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"));
}
Expand Down

0 comments on commit 1e1bd15

Please sign in to comment.