List Info

Thread: KDE/kdebase/apps/konqueror/src




KDE/kdebase/apps/konqueror/src
user name
2008-03-26 09:48:54
SVN commit 790338 by dfaure:

GUI: now that back/forward are submenus in the menu too, we
don't need the History submenu anymore.
Fixed porting bug in KonqMostOftenURLSAction::slotFillMenu()
which made "Most Often Visited" always empty and
disabled.


 M  +36 -81    konqactions.cpp  
 M  +16 -16    konqactions.h  
 M  +10 -6     konqmainwindow.cpp  
 M  +4 -0      konqmainwindow.h  


--- trunk/KDE/kdebase/apps/konqueror/src/konqactions.cpp
#790337:790338
 -43,13
+43,14 
 
 /////////////////
 
-//static - used by KonqHistoryAction and
KonqBidiHistoryAction
-void KonqBidiHistoryAction::fillHistoryPopup( const
QList<HistoryEntry*> &history, int historyIndex,
-                                          QMenu * popup,
-                                          bool onlyBack,
-                                          bool
onlyForward,
-                                          bool
checkCurrentItem,
-                                          int startPos )
+//static - used by back/forward popups in KonqMainWindow
+// and by the (now removed) KonqBidiHistoryAction (was the
history list)
+void KonqActions::fillHistoryPopup(const
QList<HistoryEntry*> &history, int historyIndex,
+                                   QMenu * popup,
+                                   bool onlyBack,
+                                   bool onlyForward,
+                                   bool checkCurrentItem,
+                                   int startPos)
 {
   assert ( popup ); // kill me if this 0... :/
 
 -86,59
+87,28 
 
 ///////////////////////////////
 
+#if 0
 KonqBidiHistoryAction::KonqBidiHistoryAction ( const
QString & text, QObject *parent )
-  : KAction( text, parent )
+    : KToolBarPopupAction( KIcon() /*TODO*/, text, parent
)
 {
   setShortcutConfigurable(false);
-  m_firstIndex = 0;
-  setMenu(new KMenu);
 
-  connect( menu(), SIGNAL( aboutToShow() ), SIGNAL(
menuAboutToShow() ) );
-  connect( menu(), SIGNAL( triggered( QAction* ) ), SLOT(
slotTriggered( QAction* ) ) );
+  connect( menu(), SIGNAL(aboutToShow() ),
SIGNAL(menuAboutToShow()) );
+  connect( menu(), SIGNAL(triggered(QAction*) ),
SLOT(slotTriggered(QAction*)) );
 }
 
-KonqBidiHistoryAction::~ KonqBidiHistoryAction( )
+KonqBidiHistoryAction::~KonqBidiHistoryAction( )
 {
-  delete menu();
 }
 
-QWidget * KonqBidiHistoryAction::createWidget( QWidget *
parent )
-{
-  QToolBar *toolbar =
qobject_cast<QToolBar*>(parent);
-
-  if (!toolbar)
-    return NULL;
-
-  QToolButton* button = new QToolButton(parent);
-  button->setAutoRaise(true);
-  button->setFocusPolicy(Qt::NoFocus);
-  button->setIconSize(toolbar->iconSize());
- 
button->setToolButtonStyle(toolbar->toolButtonStyle())
;
-  QObject::connect(toolbar, SIGNAL(iconSizeChanged(const
QSize&)),
-                   toolbar, SLOT(setIconSize(const
QSize&)));
-  QObject::connect(toolbar,
SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)),
-                   button,
SLOT(setToolButtonStyle(Qt::ToolButtonStyle)));
-  button->setDefaultAction(this);
-  QObject::connect(button, SIGNAL(triggered(QAction*)),
toolbar, SIGNAL(actionTriggered(QAction*)));
-
-  button->setPopupMode(QToolButton::MenuButtonPopup);
-
-  m_firstIndex = menu()->actions().count();
-
-  return button;
-}
-
 void KonqBidiHistoryAction::fillGoMenu( const
QList<HistoryEntry*> & history, int historyIndex
)
 {
     if (history.isEmpty())
         return; // nothing to do
 
     //kDebug(1202) << "fillGoMenu position:
" << history.at();
-    if ( m_firstIndex == 0 ) // should never happen since
done in plug
-        m_firstIndex = menu()->actions().count();
-    else
     { // Clean up old history (from the end, to avoid
shifts)
-        for ( int i = menu()->actions().count()-1 ; i
>= m_firstIndex; i-- )
+        for ( int i = menu()->actions().count()-1 ; i
>= 0 /*m_firstIndex*/; i-- )
             menu()->removeAction(
menu()->actions()[i] );
     }
     // TODO perhaps smarter algorithm (rename existing
items, create new ones only if not enough) ?
 -166,13
+136,15 
         return;
     }
     m_currentPos = historyIndex; // for slotActivated
-    KonqBidiHistoryAction::fillHistoryPopup( history,
historyIndex, menu(), false, false, true, m_startPos );
+    KonqActions::fillHistoryPopup( history, historyIndex,
menu(), false, false, true, m_startPos );
 }
 
 void KonqBidiHistoryAction::slotTriggered( QAction* action
)
 {
   // 1 for first item in the list, etc.
-  int index = menu()->actions().indexOf(action) -
m_firstIndex + 1;
+
+    // TODO use setData
+    int index = menu()->actions().indexOf(action) /*-
m_firstIndex*/ + 1;
   if ( index > 0 )
   {
       kDebug(1202) << "Item clicked has index
" << index;
 -182,6
+154,7 
       emit step( steps );
   }
 }
+#endif
 
 ///////////////////////////////
 
 -193,10
+166,8 
 {
     setDelayed( false );
 
-    connect( menu(), SIGNAL( aboutToShow() ), SLOT(
slotFillMenu() ));
-    //connect( popupMenu(), SIGNAL( aboutToHide() ), SLOT(
slotClearMenu() ));
-    connect( menu(), SIGNAL( activated( int ) ),
-	     SLOT( slotActivated(int) ));
+    connect( menu(), SIGNAL(aboutToShow()),
SLOT(slotFillMenu()));
+    connect( menu(), SIGNAL(activated(QAction*)),
SLOT(slotActivated(QAction*)));
     // Need to do all this upfront for a correct initial
state
     init();
 }
 -285,50
+256,34 
 
 void KonqMostOftenURLSAction::slotFillMenu()
 {
-    if ( !s_mostEntries ) // first time
+    if ( s_mostEntries->isEmpty() ) // first time
 	parseHistory();
 
     menu()->clear();
-    m_popupList.clear();
 
     for ( int id = s_mostEntries->count() - 1; id >=
0; --id ) {
         const KonqHistoryEntry entry =
s_mostEntries->at( id );
 	// we take either title, typedUrl or URL (in this order)
-	QString text = entry.title.isEmpty() ?
(entry.typedUrl.isEmpty() ?
-						 entry.url.prettyUrl() :
-						 entry.typedUrl) :
-		       entry.title;
-
-	menu()->insertItem(
-		   
KIcon(KonqPixmapProvider::self()->iconNameFor(entry.url))
,
-		    text, id );
-        // Keep a copy of the URLs being shown in the menu
-        // This prevents crashes when another process tells
us to remove an entry.
-        m_popupList.prepend( entry.url );
+	const QString text = entry.title.isEmpty() ?
(entry.typedUrl.isEmpty() ?
+                                                     
entry.url.prettyUrl() :
+                                                     
entry.typedUrl) :
+                             entry.title;
+        QAction* action = new QAction(
+           
KIcon(KonqPixmapProvider::self()->iconNameFor(entry.url))
,
+            text, menu());
+        action->setData(entry.url);
+        menu()->addAction(action);
     }
     setEnabled( !s_mostEntries->isEmpty() );
-    Q_ASSERT( (int)s_mostEntries->count() ==
m_popupList.count() );
 }
 
-#if 0
-void KonqMostOftenURLSAction::slotClearMenu()
+void KonqMostOftenURLSAction::slotActivated(QAction*
action)
 {
-    // Warning this is called _before_ slotActivated, when
activating a menu item.
-    // So e.g. don't clear m_popupList here.
-}
-#endif
-
-void KonqMostOftenURLSAction::slotActivated( int id )
-{
-    Q_ASSERT( !m_popupList.isEmpty() ); // can not happen
-    Q_ASSERT( id < (int)m_popupList.count() );
-
-    KUrl url = m_popupList[ id ];
-    if ( url.isValid() )
-	emit activated( url );
+    const KUrl url =
action->data().value<KUrl>();
+    if (url.isValid())
+	emit activated(url);
     else
-	kWarning() << "Invalid url: " <<
url.prettyUrl() ;
-    m_popupList.clear();
+	kWarning() << "Invalid url:" <<
url;
 }
 
 #include "konqactions.moc"
--- trunk/KDE/kdebase/apps/konqueror/src/konqactions.h
#790337:790338
 -20,6
+20,7 
 #ifndef __konq_actions_h__
 #define __konq_actions_h__
 
+#include <ktoolbarpopupaction.h>
 #include <konqhistorymanager.h>
 #include <kactionmenu.h>
 #include <QtGui/QWidget>
 -29,11
+30,22 
 struct HistoryEntry;
 class QMenu;
 
+namespace KonqActions {
+    // Used by KonqHistoryAction and KonqBidiHistoryAction
+    void fillHistoryPopup( const QList<HistoryEntry*>
&history, int historyIndex,
+                           QMenu * popup,
+                           bool onlyBack = false,
+                           bool onlyForward = false,
+                           bool checkCurrentItem = false,
+                           int startPos = 0 );
+}
+
+#if 0
 /**
  * Plug this action into a menu to get a bidirectional
history
  * (both back and forward, including current location)
  */
-class KonqBidiHistoryAction : public KAction
+class KonqBidiHistoryAction : public KToolBarPopupAction
 {
   Q_OBJECT
 public:
 -42,16
+54,6 
 
     void fillGoMenu( const QList<HistoryEntry*>
&history, int historyIndex );
 
-    // Used by KonqHistoryAction and KonqBidiHistoryAction
-    static void fillHistoryPopup( const
QList<HistoryEntry*> &history, int historyIndex,
-                           QMenu * popup,
-                           bool onlyBack = false,
-                           bool onlyForward = false,
-                           bool checkCurrentItem = false,
-                           int startPos = 0 );
-
-    virtual QWidget* createWidget(QWidget* parent);
-
 protected Q_SLOTS:
     void slotTriggered( QAction* action );
 
 -60,11
+62,12 
     // -1 for one step back, 0 for don't move, +1 for one
step forward, etc.
     void step( int );
 private:
-    int m_firstIndex; // first index in the Go menu
     int m_startPos;
     int m_currentPos; // == history.at()
 };
 
+#endif
+
 /////
 
 class KonqMostOftenURLSAction : public KActionMenu
 -88,16
+91,13 
     void slotEntryRemoved( const KonqHistoryEntry&
entry );
 
     void slotFillMenu();
-    //void slotClearMenu();
 
-    void slotActivated( int );
+    void slotActivated(QAction* action);
 
 private:
     void init();
     void parseHistory();
     static void inSort( const KonqHistoryEntry& entry
);
-
-    KUrl::List m_popupList;
 };
 
 #endif
--- trunk/KDE/kdebase/apps/konqueror/src/konqmainwindow.cpp
#790337:790338
 -2815,12
+2815,14 
     openUrl( 0, action->data().value<KUrl>() );
 }
 
+#if 0
 void KonqMainWindow::slotGoMenuAboutToShow()
 {
   kDebug(1202) <<
"KonqMainWindow::slotGoMenuAboutToShow";
   if ( m_paHistory && m_currentView ) // (maybe
this is before initialisation)
       m_paHistory->fillGoMenu(
m_currentView->history(),
m_currentView->historyIndex() );
 }
+#endif
 
 void KonqMainWindow::slotGoHistoryActivated( int steps )
 {
 -2885,9
+2887,9 
 
 void KonqMainWindow::slotBackAboutToShow()
 {
-  m_paBack->menu()->clear();
-  if ( m_currentView )
-      KonqBidiHistoryAction::fillHistoryPopup(
m_currentView->history(),
m_currentView->historyIndex(), m_paBack->menu(), true,
false );
+    m_paBack->menu()->clear();
+    if (m_currentView)
+       
KonqActions::fillHistoryPopup(m_currentView->history(),
m_currentView->historyIndex(), m_paBack->menu(), true,
false);
 }
 
 
 -2939,9
+2941,9 
 
 void KonqMainWindow::slotForwardAboutToShow()
 {
-  m_paForward->menu()->clear();
-  if ( m_currentView )
-      KonqBidiHistoryAction::fillHistoryPopup(
m_currentView->history(),
m_currentView->historyIndex(), m_paForward->menu(),
false, true );
+    m_paForward->menu()->clear();
+    if (m_currentView)
+       
KonqActions::fillHistoryPopup(m_currentView->history(),
m_currentView->historyIndex(), m_paForward->menu(),
false, true);
 }
 
 void KonqMainWindow::slotForward()
 -3578,10
+3580,12 
   connect( m_paForward->menu(), SIGNAL( aboutToShow() ),
this, SLOT( slotForwardAboutToShow() ) );
   connect( m_paForward->menu(),
SIGNAL(triggered(QAction*)), this,
SLOT(slotForwardActivated(QAction *)) );
 
+#if 0
   m_paHistory = new KonqBidiHistoryAction(
i18n("History"), this );
   actionCollection()->addAction( "history",
m_paHistory );
   connect( m_paHistory, SIGNAL( menuAboutToShow() ), this,
SLOT( slotGoMenuAboutToShow() ) );
   connect( m_paHistory, SIGNAL( step( int ) ), this, SLOT(
slotGoHistoryActivated( int ) ) );
+#endif
 
   m_paHome = actionCollection()->addAction(
KStandardAction::Home );
   m_paHome->setEnabled( true );
--- trunk/KDE/kdebase/apps/konqueror/src/konqmainwindow.h
#790337:790338
 -455,7
+455,9 
 
   void slotOpenWith();
 
+#if 0
   void slotGoMenuAboutToShow();
+#endif
   void slotUpAboutToShow();
   void slotBackAboutToShow();
   void slotForwardAboutToShow();
 -615,7
+617,9 
   KToolBarPopupAction *m_paClosedItems;
   KAction *m_paHome;
 
+#if 0
   KonqBidiHistoryAction *m_paHistory;
+#endif
 
   KAction *m_paSaveViewProfile;
 
_______________________________________________
kde-docbook mailing list
kde-docbookkde.org
htt
ps://mail.kde.org/mailman/listinfo/kde-docbook

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )