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

List:       kde-commits
Subject:    [kdelibs/frameworks] tier1/kwidgetsaddons/src: Add KSelectAction::insertAction()
From:       David Edmundson <kde () davidedmundson ! co ! uk>
Date:       2013-09-17 17:30:44
Message-ID: E1VLz6q-0000ZH-MW () scm ! kde ! org
[Download RAW message or body]

Git commit 72b7a62a379495c9bea09baf25ce0ebd559b3426 by David Edmundson.
Committed on 17/09/2013 at 18:27.
Pushed by davidedmundson into branch 'frameworks'.

Add KSelectAction::insertAction()

This is required by krecentfilesaction to always the newest
item into the top of the list.

Previously it manipulated prviate members of KSelectAction which no
longer works when it is in a different framework

M  +24   -20   tier1/kwidgetsaddons/src/kselectaction.cpp
M  +10   -1    tier1/kwidgetsaddons/src/kselectaction.h

http://commits.kde.org/kdelibs/72b7a62a379495c9bea09baf25ce0ebd559b3426

diff --git a/tier1/kwidgetsaddons/src/kselectaction.cpp b/tier1/kwidgetsadd=
ons/src/kselectaction.cpp
index 3aa0797..2022466 100644
--- a/tier1/kwidgetsaddons/src/kselectaction.cpp
+++ b/tier1/kwidgetsaddons/src/kselectaction.cpp
@@ -239,26 +239,7 @@ void KSelectAction::setMaxComboViewCount( int n )
 =

 void KSelectAction::addAction(QAction* action)
 {
-  Q_D(KSelectAction);
-  //qDebug () << "KSelectAction::addAction(" << action << ")";
-
-  action->setActionGroup(selectableActionGroup());
-
-  // Re-Enable when an action is added
-  setEnabled(true);
-
-  // Keep in sync with createToolBarWidget()
-  foreach (QToolButton* button, d->m_buttons) {
-    button->setEnabled(true);
-    button->addAction(action);
-  }
-
-  foreach (QComboBox* comboBox, d->m_comboBoxes) {
-    comboBox->setEnabled(true);
-    comboBox->addAction(action);
-  }
-
-  menu()->addAction(action);
+  insertAction(0, action);
 }
 =

 QAction* KSelectAction::addAction(const QString &text)
@@ -316,6 +297,29 @@ QAction* KSelectAction::removeAction(QAction* action)
   return action;
 }
 =

+void KSelectAction::insertAction(QAction* before, QAction* action)
+{
+    Q_D(KSelectAction);
+    action->setActionGroup(selectableActionGroup());
+
+    // Re-Enable when an action is added
+    setEnabled(true);
+
+    // Keep in sync with createToolBarWidget()
+    foreach (QToolButton* button, d->m_buttons) {
+        button->setEnabled(true);
+        button->insertAction(before, action);
+    }
+
+    foreach (QComboBox* comboBox, d->m_comboBoxes) {
+        comboBox->setEnabled(true);
+        comboBox->insertAction(before, action);
+    }
+
+    menu()->insertAction(before, action);
+}
+
+
 void KSelectAction::actionTriggered(QAction* action)
 {
   // cache values so we don't need access to members in the action
diff --git a/tier1/kwidgetsaddons/src/kselectaction.h b/tier1/kwidgetsaddon=
s/src/kselectaction.h
index 07afaa9..f737915 100644
--- a/tier1/kwidgetsaddons/src/kselectaction.h
+++ b/tier1/kwidgetsaddons/src/kselectaction.h
@@ -215,7 +215,7 @@ public:
     /**
      * Add \a action to the list of selectable actions.
      */
-    virtual void addAction(QAction* action);
+    void addAction(QAction* action);
 =

     /**
      * \overload addAction(QAction* action)
@@ -245,6 +245,15 @@ public:
     virtual QAction* removeAction(QAction* action);
 =

     /**
+     * Inserts the action action to this widget's list of actions, before =
the action before.
+     * It appends the action if before is 0 or before is not a valid actio=
n for this widget.
+     *
+     * @since 5.0
+     */
+    virtual void insertAction(QAction* before, QAction* action);
+
+
+    /**
      * Convenience function to create the list of selectable items.
      * Any previously existing items will be cleared.
      */

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

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