[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdevplatform] 624f37a: Add back some context menu entries to the
From:       Andras Mantia <Andras.Mantia.amantia () kde ! org>
Date:       2010-07-05 21:09:04
Message-ID: 201007052109.o65L943G022054 () kore ! kollide ! net
[Download RAW message or body]

commit 624f37ae2501a2d0b5b09786f27db659a2fd07d3
Author: Andras Mantia <Andras Mantia amantia@kde.org>
Date:   Mon Jul 5 23:37:43 2010 +0300

    Add back some context menu entries to the breakpoint widget: \
Disable/Enable/Remove All

diff --git a/debugger/breakpoint/breakpointmodel.cpp \
b/debugger/breakpoint/breakpointmodel.cpp index db4f03d..12cd93c 100644
--- a/debugger/breakpoint/breakpointmodel.cpp
+++ b/debugger/breakpoint/breakpointmodel.cpp
@@ -115,20 +115,30 @@ void BreakpointModel::textDocumentCreated(KDevelop::IDocument* \
doc)  QVariant 
 BreakpointModel::headerData(int section, Qt::Orientation orientation,
                                  int role) const
-{ 
-    if (orientation == Qt::Horizontal && role == Qt::DecorationRole
-        && section == 0)
-        return KIcon("dialog-ok-apply");
-    else if (orientation == Qt::Horizontal && role == Qt::DecorationRole
-             && section == 1)
-        return KIcon("system-switch-user");
-
-    if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
+{
+    if (orientation == Qt::Vertical)
+        return QVariant();
+    
+    if (role == Qt::DecorationRole ) {
+        if (section == 0)
+            return KIcon("dialog-ok-apply");
+        else if (section == 1)
+            return KIcon("system-switch-user");
+    }
+
+    if (role == Qt::DisplayRole) {
         if (section == 0 || section == 1) return "";
         if (section == 2) return i18n("Type");
         if (section == 3) return i18n("Location");
         if (section == 4) return i18n("Condition");
     }
+
+    if (role == Qt::ToolTipRole) {
+        if (section == 0) return i18n("Active status");
+        if (section == 1) return i18n("State");
+        return headerData(section, orientation, Qt::DisplayRole);
+        
+    }
     return QVariant();
 }
 
diff --git a/debugger/breakpoint/breakpointwidget.cpp \
b/debugger/breakpoint/breakpointwidget.cpp index 9c28f07..da0ff14 100644
--- a/debugger/breakpoint/breakpointwidget.cpp
+++ b/debugger/breakpoint/breakpointwidget.cpp
@@ -45,7 +45,8 @@
 using namespace KDevelop;
 
 BreakpointWidget::BreakpointWidget(DebugController *controller, QWidget *parent)
-: QWidget(parent), firstShow_(true), m_debugController(controller)
+: QWidget(parent), firstShow_(true), m_debugController(controller),
+  breakpointDisableAll_(0), breakpointEnableAll_(0), breakpointRemoveAll_(0)
 {
     setWindowTitle(i18n("Debugger Breakpoints"));
     setWhatsThis(i18n("<b>Breakpoint list</b><p>"
@@ -97,10 +98,10 @@ void BreakpointWidget::setupPopupMenu()
 {
     popup_ = new QMenu(this);
 
-    QMenu* newBreakpoint = popup_->addMenu( i18nc("New breakpoint", "New") );
+    QMenu* newBreakpoint = popup_->addMenu( i18nc("New breakpoint", "&New") );
 
     QAction* action = newBreakpoint->addAction(
-        i18nc("Code breakpoint", "Code"),
+        i18nc("Code breakpoint", "&Code"),
         this,
         SLOT(slotAddBlankBreakpoint()) );
     // Use this action also to provide a local shortcut
@@ -109,13 +110,13 @@ void BreakpointWidget::setupPopupMenu()
     addAction(action);
 
     newBreakpoint->addAction(
-        i18nc("Data breakpoint", "Data write"),
+        i18nc("Data breakpoint", "Data &write"),
         this, SLOT(slotAddBlankWatchpoint()));
     newBreakpoint->addAction(
-        i18nc("Data read breakpoint", "Data read"),
+        i18nc("Data read breakpoint", "Data &read"),
         this, SLOT(slotAddBlankReadWatchpoint()));
     newBreakpoint->addAction(
-        i18nc("Data access breakpoint", "Data access"),
+        i18nc("Data access breakpoint", "Data &access"),
         this, SLOT(slotAddBlankAccessWatchpoint()));
 
     #if 0
@@ -130,20 +131,20 @@ void BreakpointWidget::setupPopupMenu()
 
     QAction* breakpointDelete = popup_->addAction(
         KIcon("breakpoint_delete"),
-        i18n( "Delete" ),
+        i18n( "&Delete" ),
         this,
         SLOT(slotRemoveBreakpoint()));
     breakpointDelete->setShortcut(Qt::Key_Delete);
     breakpointDelete->setShortcutContext(Qt::WidgetWithChildrenShortcut);
     addAction(breakpointDelete);
 
-    #if 0
-    m_ctxMenu->addSeparator();
 
-    m_breakpointDisableAll = m_ctxMenu->addAction( i18n( "Disable all") );
-    m_breakpointEnableAll = m_ctxMenu->addAction( i18n( "Enable all") );
-    m_breakpointDeleteAll = m_ctxMenu->addAction( i18n( "Delete all"), this, \
                SLOT(slotRemoveAllBreakpoints()));
-    #endif
+    popup_->addSeparator();
+    breakpointDisableAll_ = popup_->addAction(i18n("Disable &all"), this, \
SLOT(slotDisableAllBreakpoints())); +    breakpointEnableAll_ = \
popup_->addAction(i18n("&Enable all"), this, SLOT(slotEnableAllBreakpoints())); +    \
breakpointRemoveAll_ = popup_->addAction(i18n("&Remove all"), this, \
SLOT(slotRemoveAllBreakpoints())); +
+    connect(popup_,SIGNAL(aboutToShow()), this, SLOT(slotPopupMenuAboutToShow()));
 
 #if 0
     connect( m_ctxMenu,     SIGNAL(triggered(QAction*)),
@@ -195,6 +196,30 @@ void BreakpointWidget::contextMenuEvent(QContextMenuEvent* \
event)  popup_->popup(event->globalPos());
 }
 
+void BreakpointWidget::slotPopupMenuAboutToShow()
+{
+    if (m_debugController->breakpointModel()->rowCount() < 2) {
+        breakpointDisableAll_->setDisabled(true);
+        breakpointEnableAll_->setDisabled(true);
+        breakpointRemoveAll_->setDisabled(true);
+    } else {
+        breakpointRemoveAll_->setEnabled(true);
+        bool allDisabled = true;
+        bool allEnabled = true;
+        for (int i = 0; i < m_debugController->breakpointModel()->rowCount() - 1 ; \
i++) { +            Breakpoint *bp = \
m_debugController->breakpointModel()->breakpoint(i); +            if (bp->enabled())
+                allDisabled = false;
+            else
+                allEnabled = false;
+        }
+        breakpointDisableAll_->setDisabled(allDisabled);
+        breakpointEnableAll_->setDisabled(allEnabled);
+    }
+       
+}
+
+
 #if 0
 void slotContextMenuSelect( QAction* action )
 {
@@ -289,6 +314,12 @@ void BreakpointWidget::slotRemoveBreakpoint()
     }
 }
 
+void BreakpointWidget::slotRemoveAllBreakpoints()
+{
+    m_debugController->breakpointModel()->removeRows(0, \
m_debugController->breakpointModel()->rowCount()); +}
+
+
 void BreakpointWidget::slotUpdateBreakpointDetail()
 {
     QModelIndexList selected = table_->selectionModel()->selectedIndexes();
@@ -336,11 +367,28 @@ void BreakpointWidget::slotRowClicked(const QModelIndex& index)
 {
     if (index.column() != Breakpoint::LocationColumn)
         return;
-    Breakpoint *bp = \
static_cast<BreakpointModel*>(table_->model())->breakpoint(index.row()); +    \
Breakpoint *bp = m_debugController->breakpointModel()->breakpoint(index.row());  if \
(!bp)  return;
    ICore::self()->documentController()->openDocument(bp->url().pathOrUrl(KUrl::RemoveTrailingSlash), \
KTextEditor::Cursor(bp->line(), 0));  
 }
 
+void BreakpointWidget::slotDisableAllBreakpoints()
+{
+    for (int i = 0; i < m_debugController->breakpointModel()->rowCount() - 1 ; i++) \
{ +        Breakpoint *bp = m_debugController->breakpointModel()->breakpoint(i);
+        bp->setData(Breakpoint::EnableColumn, Qt::Unchecked);
+    }
+}
+
+void BreakpointWidget::slotEnableAllBreakpoints()
+{
+    for (int i = 0; i < m_debugController->breakpointModel()->rowCount() - 1 ; i++) \
{ +        Breakpoint *bp = m_debugController->breakpointModel()->breakpoint(i);
+        bp->setData(Breakpoint::EnableColumn, Qt::Checked);
+    }
+}
+
+
 #include "breakpointwidget.moc"
diff --git a/debugger/breakpoint/breakpointwidget.h \
b/debugger/breakpoint/breakpointwidget.h index e05846f..fe6fa98 100644
--- a/debugger/breakpoint/breakpointwidget.h
+++ b/debugger/breakpoint/breakpointwidget.h
@@ -63,13 +63,20 @@ private Q_SLOTS:
     void slotRowClicked(const QModelIndex& index);
     void breakpointError(KDevelop::Breakpoint *b, const QString& msg, int column);
     void breakpointHit(KDevelop::Breakpoint *b);
-
+    void slotDisableAllBreakpoints();
+    void slotEnableAllBreakpoints();
+    void slotRemoveAllBreakpoints();
+    void slotPopupMenuAboutToShow();
+    
 private:
     QTableView* table_;
     BreakpointDetails* details_;
     QMenu* popup_;
     bool firstShow_;
     DebugController *m_debugController;
+    QAction* breakpointDisableAll_;
+    QAction* breakpointEnableAll_;
+    QAction* breakpointRemoveAll_;
 };
 
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic