From 6840a507858b5eaa321f73b35f06c74d05b33b17 Mon Sep 17 00:00:00 2001 From: Date: Sat, 26 Apr 2008 11:00:06 +0000 Subject: [PATCH] bugfix 2422 --- src/gui/RuleGroupPanel.cpp | 13 +++++++-- src/gui/RuleGroupPanel.h | 3 ++- src/gui/RuleSetView.cpp | 54 +++++++++++++++++++++++++++++++++----- src/gui/RuleSetView.h | 1 + src/gui/rulegrouppanel.ui | 16 +++++------ 5 files changed, 69 insertions(+), 18 deletions(-) diff --git a/src/gui/RuleGroupPanel.cpp b/src/gui/RuleGroupPanel.cpp index df3fab391..e2883d67f 100644 --- a/src/gui/RuleGroupPanel.cpp +++ b/src/gui/RuleGroupPanel.cpp @@ -30,11 +30,20 @@ RuleGroupPanel::RuleGroupPanel (QWidget * parent,RuleSetView * rsv, int row) : Q this->row= row; this->rsv = rsv; this->setupUi(this); - setContentsMargins (0,0,0,0); - showHideRuleGroupButton->setText("Collapse Group"); + setContentsMargins (3,3,3,3); + //showHideRuleGroupButton->setText("Collapse Group"); connect (showHideRuleGroupButton, SIGNAL(pressed()),this,SLOT(showHideRuleGroup())); } +void RuleGroupPanel::mousePressEvent ( QMouseEvent * event ) +{ + if (event->buttons () == Qt::RightButton) + { + rsv->firstSelectedRule = row; + rsv->contextMenu (row,0,event->globalPos ()); + } +} + void RuleGroupPanel::showHideRuleGroup() { rsv->showHideRuleGroup(this); diff --git a/src/gui/RuleGroupPanel.h b/src/gui/RuleGroupPanel.h index 53a692f5c..d901ca8aa 100644 --- a/src/gui/RuleGroupPanel.h +++ b/src/gui/RuleGroupPanel.h @@ -38,5 +38,6 @@ public: RuleGroupPanel (QWidget * parent,RuleSetView * rsv, int row) ; public slots: void showHideRuleGroup(); - +public: + virtual void mousePressEvent ( QMouseEvent * event ); }; diff --git a/src/gui/RuleSetView.cpp b/src/gui/RuleSetView.cpp index 289e55908..7bedffd44 100644 --- a/src/gui/RuleSetView.cpp +++ b/src/gui/RuleSetView.cpp @@ -888,10 +888,12 @@ void RuleSetView::addRuleGroupPanel (int row) grouppanel->ruleGroupName->setText(rri->groupName); if (!hide) { + grouppanel->showHideRuleGroupButton->setCheckState(Qt::Unchecked); grouppanel->showHideRuleGroupButton->setText ("Collapse Group"); } else { + grouppanel->showHideRuleGroupButton->setCheckState(Qt::Checked); grouppanel->showHideRuleGroupButton->setText ("Expand Group"); } setIndexWidget (model()->index(row,1),grouppanel); @@ -2307,15 +2309,44 @@ void RuleSetView::newGroup() int row = firstSelectedRule; int count = lastSelectedRule - firstSelectedRule +1; createGroup(row,count,text+postfix); - - } - -// SimpleTextEditor * ste = new SimpleTextEditor(this, "New Group", false, "New Group2"); -// ste->setModal (true); -// ste->show(); -// QString text = ste->text(); + } } +void RuleSetView::renameGroup() +{ + bool ok = false ; + QString oldGroup = ""; + if (rowsInfo[ firstSelectedRule ] != NULL) + { + oldGroup = rowsInfo[ firstSelectedRule ]->groupName; + } + + QString text = QInputDialog::getText(this, "Rename group", + tr("Enter group name:"), QLineEdit::Normal, + oldGroup, &ok); + if (ok && !text.isEmpty()) + { + if (oldGroup==""||text=="") + return ; + QString postfix = ""; + int counter = 0 ; + for (int i =0 ; i < rowsInfo.size(); i++) + { + Rule * r = Rule::cast(ruleIndex[i]); + if (r!=NULL) + { + if (r->getRuleGroupName ().c_str() == oldGroup) + { + r->setRuleGroupName (text.toAscii().data()); + } + } + } + updateGroups(); + + } +} + + void RuleSetView::addToGroupAbove () { int row = firstSelectedRule; @@ -2499,6 +2530,15 @@ void RuleSetView::contextMenu(int row, int col, const QPoint &pos) } popup->addSeparator (); } + else + { + popup->addAction( tr("Rename group"), this, SLOT( renameGroup() )); + popup->exec( pos ); + + delete popup; + return ; + + } diff --git a/src/gui/RuleSetView.h b/src/gui/RuleSetView.h index a064313f5..c6035f665 100644 --- a/src/gui/RuleSetView.h +++ b/src/gui/RuleSetView.h @@ -158,6 +158,7 @@ class RuleSetView : public QTableView void contextMenuRequested ( const QPoint &p ); void newGroup(); + void renameGroup(); void addToGroupAbove (); void addToGroupBelow(); void removeFromGroup(); diff --git a/src/gui/rulegrouppanel.ui b/src/gui/rulegrouppanel.ui index 38464a0f2..4b923ec0b 100755 --- a/src/gui/rulegrouppanel.ui +++ b/src/gui/rulegrouppanel.ui @@ -26,18 +26,11 @@ 2 - 2 + 20 2 - - - - PushButton - - - @@ -58,6 +51,13 @@ + + + + + + +