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

List:       kde-commits
Subject:    KDE/kdelibs/kio/bookmarks
From:       Daniel Teske <teske () squorn ! de>
Date:       2006-08-24 15:18:50
Message-ID: 1156432730.859307.28522.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 576669 by teske:

Simplfied code.



 M  +1 -8      kbookmarkbar.cc  
 M  +36 -58    kbookmarkmenu.cc  
 M  +17 -11    kbookmarkmenu.h  
 M  +9 -26     kbookmarkmenu_p.h  


--- trunk/KDE/kdelibs/kio/bookmarks/kbookmarkbar.cc #576668:576669
@@ -195,17 +195,10 @@
                 m_toolBar->addSeparator();
             else
             {
-                KAction *action = new KBookmarkAction( text, bm.icon(), 0, \
m_actionCollection, 0 ); +                KAction *action = new KBookmarkAction( bm, \
m_actionCollection );  connect(action, SIGNAL( triggered(bool) ),
                         this, SLOT( slotBookmarkSelected() ));
-
-                action->setProperty( "url", bm.url().url() );
-                action->setProperty( "address", bm.address() );
-
-                action->setToolTip( bm.url().pathOrUrl() );
-
                 m_toolBar->addAction(action);
-
                 d->m_actions.append( action );
             }
         }
--- trunk/KDE/kdelibs/kio/bookmarks/kbookmarkmenu.cc #576668:576669
@@ -89,10 +89,6 @@
 {
   m_parentMenu->setKeyboardShortcutsEnabled( true );
 
-
-  connect( m_parentMenu, SIGNAL( hovered( QAction * ) ),
-           this, SLOT( slotActionHoovered( QAction * ) ) );
-
   m_bNSBookmark = m_parentAddress.isNull();
   if ( !m_bNSBookmark ) // not for the netscape bookmark
   {
@@ -152,29 +148,6 @@
   }
 }
 
-QString KBookmarkMenu::s_highlightedImportType;
-QString KBookmarkMenu::s_highlightedImportLocation;
-
-void KBookmarkMenu::slotActionHoovered( QAction* action )
-{
-  if (qobject_cast<KBookmarkActionMenu*>(action) ||
-      qobject_cast<KBookmarkAction*>(action))
-  {
-    m_highlightedAddress = action->property("address").toString();
-  }
-  else if (qobject_cast<KImportedBookmarksActionMenu*>(action))
-  {
-    s_highlightedImportType = action->property("type").toString();
-    s_highlightedImportLocation = action->property("location").toString();
-  }
-  else
-  {
-    m_highlightedAddress.clear();
-    s_highlightedImportType.clear();
-    s_highlightedImportLocation.clear();
-  }
-}
-
 /********************************************************************/
 /********************************************************************/
 /********************************************************************/
@@ -212,7 +185,8 @@
 
 void KBookmarkMenu::contextMenu( const QPoint & pos )
 {
-  showContextMenu(m_highlightedAddress, pos);
+  QAction * action = m_parentMenu->actionAt(pos);
+  showContextMenu(action->property("address").toString(), pos);
 }
 
 void RMB::fillContextMenu( const QString & address)
@@ -245,7 +219,7 @@
 
 void RMB::slotEditAt()
 {
-  kDebug(7043) << "KBookmarkMenu::slotEditAt" << m_highlightedAddress << endl;
+  //kDebug(7043) << "KBookmarkMenu::slotEditAt" << m_highlightedAddress << endl;
 
   KBookmark bookmark = atAddress(m_highlightedAddress);
 
@@ -254,7 +228,7 @@
 
 void RMB::slotProperties()
 {
-  kDebug(7043) << "KBookmarkMenu::slotProperties" << m_highlightedAddress << endl;
+  //kDebug(7043) << "KBookmarkMenu::slotProperties" << m_highlightedAddress << endl;
 
   KBookmark bookmark = atAddress(m_highlightedAddress);
 
@@ -278,7 +252,7 @@
 
 void RMB::slotInsert()
 {
-  kDebug(7043) << "KBookmarkMenu::slotInsert" << m_highlightedAddress << endl;
+  //kDebug(7043) << "KBookmarkMenu::slotInsert" << m_highlightedAddress << endl;
 
   QString url = m_pOwner->currentURL();
   if (url.isEmpty())
@@ -361,7 +335,7 @@
 {
 
   delete m_rmb;
-  m_rmb = new RMB(m_parentAddress, m_highlightedAddress, m_pManager, m_pOwner, \
m_parentMenu); +  m_rmb = new RMB(m_parentAddress, address, m_pManager, m_pOwner, \
m_parentMenu);  m_rmb->fillContextMenu(address);
   emit aboutToShowContextMenu( m_rmb->atAddress(address), m_rmb->contextMenu());
   m_rmb->fillContextMenu2(address);
@@ -391,7 +365,7 @@
 
 void KBookmarkMenu::refill()
 {
-  //kDebug(7043) << "KBookmarkMenu::refill()" << endl;
+  kDebug(7043) << "KBookmarkMenu::refill()" << endl;
   qDeleteAll( m_lstSubMenus );
   m_lstSubMenus.clear();
 
@@ -511,40 +485,35 @@
        }
 
        KActionMenu * actionMenu;
-       actionMenu = new KImportedBookmarksActionMenu(
+       actionMenu = new KActionMenu(
                               KIcon(info.type), info.name,
                               m_actionCollection, "kbookmarkmenu" );
 
-       actionMenu->setProperty( "type", info.type );
-       actionMenu->setProperty( "location", info.location );
-
        m_parentMenu->addAction(actionMenu);
        m_actions.append( actionMenu );
 
-       KBookmarkMenu *subMenu =
-          new KBookmarkMenu( m_pManager, m_pOwner, actionMenu->menu(),
+       KImportedBookmarkMenu *subMenu =
+          new KImportedBookmarkMenu( m_pManager, m_pOwner, actionMenu->menu(),
                              m_actionCollection, false,
-                             m_bAddBookmark, QString() );
+                             m_bAddBookmark, QString(), info.type, info.location);
        connect( subMenu, SIGNAL( openBookmark( const QString &, Qt::MouseButtons, \
                Qt::KeyboardModifiers ) ),
                 this, SIGNAL( openBookmark( const QString &, Qt::MouseButtons, \
Qt::KeyboardModifiers ) ));  m_lstSubMenus.append( subMenu );
-
-       connect(actionMenu->menu(), SIGNAL(aboutToShow()), subMenu, \
SLOT(slotNSLoad()));  }
   }
 
   KBookmarkGroup parentBookmark = m_pManager->findByAddress( m_parentAddress \
).toGroup();  Q_ASSERT(!parentBookmark.isNull());
-  bool separatorInserted = false;
+
+  if ( m_bIsRoot && parentBookmark.first().isNull() ) // at least one bookmark
+  {
+      m_parentMenu->addSeparator();
+  }
+
   for ( KBookmark bm = parentBookmark.first(); !bm.isNull();  bm = \
parentBookmark.next(bm) )  {
     QString text = KStringHandler::csqueeze(bm.fullText(), 60);
     text.replace( '&', "&&" );
-    if ( !separatorInserted && m_bIsRoot) {
-      // inserted before the first konq bookmark, to avoid the separator if no konq \
                bookmark
-      m_parentMenu->addSeparator();
-      separatorInserted = true;
-    }
     if ( !bm.isGroup() )
     {
       if ( bm.isSeparator() )
@@ -554,14 +523,8 @@
       else
       {
         //kDebug(7043) << "Creating URL bookmark menu item for " << bm.text() << \
                endl;
-        KAction * action = new KBookmarkAction( text, bm.icon(), 0, \
m_actionCollection, 0 ); +        KAction * action = new KBookmarkAction( bm, \
                m_actionCollection);
         connect(action, SIGNAL( triggered(Qt::MouseButtons, Qt::KeyboardModifiers) \
                ), SLOT( slotBookmarkSelected(Qt::MouseButtons, \
                Qt::KeyboardModifiers) ));
-
-        action->setProperty( "url", bm.url().url() );
-        action->setProperty( "address", bm.address() );
-
-        action->setToolTip( bm.url().pathOrUrl() );
-
         m_parentMenu->addAction(action);
         m_actions.append( action );
       }
@@ -650,7 +613,7 @@
 
 void KBookmarkMenu::slotBookmarkSelected(Qt::MouseButtons mb, Qt::KeyboardModifiers \
km)  {
-  kDebug(7043) << "KBookmarkMenu::slotBookmarkSelected()" << endl;
+  //kDebug(7043) << "KBookmarkMenu::slotBookmarkSelected()" << endl;
   if ( !m_pOwner ) return; // this view doesn't handle bookmarks...
 
   if (qobject_cast<const KAction*>(sender()))
@@ -666,16 +629,31 @@
   return dynamic_cast<KExtendedBookmarkOwner*>(m_pOwner);
 }
 
-void KBookmarkMenu::slotNSLoad()
+void KImportedBookmarkMenu::slotNSLoad()
 {
+  kDebug(7043)<<"**** slotNSLoad  ****"<<m_type<<"  "<<m_location<<endl;
   // only fill menu once
   m_parentMenu->disconnect(SIGNAL(aboutToShow()));
 
   // not NSImporter, but kept old name for BC reasons
   KBookmarkMenuNSImporter importer( m_pManager, this, m_actionCollection );
-  importer.openBookmarks(s_highlightedImportLocation, s_highlightedImportType);
+  importer.openBookmarks(m_location, m_type);
 }
 
+KImportedBookmarkMenu::KImportedBookmarkMenu( KBookmarkManager* mgr,
+                 KBookmarkOwner * owner, KMenu * parentMenu,
+                 KActionCollection * collec, bool root, bool add,
+                 const QString & parentAddress, const QString & type, const QString \
& location ) +    :KBookmarkMenu(mgr, owner, parentMenu, collec, root, add, \
parentAddress), m_type(type), m_location(location) +{
+    connect(parentMenu, SIGNAL(aboutToShow()), this, SLOT(slotNSLoad()));
+}
+
+KImportedBookmarkMenu::~KImportedBookmarkMenu()
+{
+
+}
+
 /********************************************************************/
 /********************************************************************/
 /********************************************************************/
--- trunk/KDE/kdelibs/kio/bookmarks/kbookmarkmenu.h #576668:576669
@@ -161,18 +161,12 @@
 protected Q_SLOTS:
   void slotAboutToShow();
   void contextMenu( const QPoint & );
-  void slotActionHoovered( QAction * );
 
   void slotBookmarkSelected(Qt::MouseButtons, Qt::KeyboardModifiers);
   void slotAddBookmarksList();
   void slotAddBookmark();
   void slotNewFolder();
 
-  /**
-   * load Netscape's bookmarks
-   */
-  void slotNSLoad();
-
 protected:
   KExtendedBookmarkOwner* extOwner();
   void refill();
@@ -210,17 +204,29 @@
    */
   QString m_parentAddress;
 
-  QString m_highlightedAddress;
 
-  // TODO make non static!
-  static QString s_highlightedImportLocation;
-  static QString s_highlightedImportType;
-
   RMB *m_rmb;
 private:
   KBookmarkMenuPrivate* d;
 };
 
+class KImportedBookmarkMenu : public KBookmarkMenu
+{
+  Q_OBJECT
+public:
+  //TODO simplfy
+  KImportedBookmarkMenu( KBookmarkManager* mgr,
+                 KBookmarkOwner * owner, KMenu * parentMenu,
+                 KActionCollection * collec, bool root, bool add,
+                 const QString & parentAddress, const QString & type, const QString \
& location ); +  ~KImportedBookmarkMenu();
+protected Q_SLOTS:
+  void slotNSLoad();
+private:
+   QString m_type;
+   QString m_location;
+};
+
 /**
  * A class connected to KNSBookmarkImporter, to fill KActionMenus.
  */
--- trunk/KDE/kdelibs/kio/bookmarks/kbookmarkmenu_p.h #576668:576669
@@ -53,39 +53,13 @@
 class KBookmarkBar;
 class KMenu;
 
-class KImportedBookmarksActionMenu : public KActionMenu {
-  Q_OBJECT
-  Q_PROPERTY( QString type READ type WRITE setType )
-  Q_PROPERTY( QString location READ location WRITE setLocation )
-public:
-  const QString type() const { return m_type; }
-  void setType(const QString &type) { m_type = type; }
-  const QString location() const { return m_location; }
-  void setLocation(const QString &location) { m_location = location; }
-private:
-  QString m_type;
-  QString m_location;
-public:
-  KImportedBookmarksActionMenu(
-    const KIcon& icon, const QString &text,
-    KActionCollection* parent, const char* name)
-  : KActionMenu(icon, text, parent, name) {
-     ;
-  }
-};
 
 class KBookmarkActionMenu : public KActionMenu {
   Q_OBJECT
-  Q_PROPERTY( QString url READ url WRITE setUrl )
   Q_PROPERTY( QString address READ address WRITE setAddress )
-  Q_PROPERTY( bool readOnly READ readOnly WRITE setReadOnly )
 public:
-  const QString url() const { return m_url; }
-  void setUrl(const QString &url) { m_url = url; }
   const QString address() const { return m_address; }
   void setAddress(const QString &address) { m_address = address; }
-  bool readOnly() const { return m_readOnly; }
-  void setReadOnly(bool readOnly) { m_readOnly = readOnly; }
 private:
   QString m_url;
   QString m_address;
@@ -119,6 +93,15 @@
       setIcon( KIcon( sIconName ) );
       setShortcut( cut );
   }
+
+  KBookmarkAction(KBookmark bm, KActionCollection* parent)
+  : KAction( bm.text().replace('&', "&&"), parent, 0)
+  {
+      setIcon(KIcon(bm.icon()));
+      setProperty( "url", bm.url().url() );
+      setProperty( "address", bm.address() );
+      setToolTip( bm.url().pathOrUrl() );
+  }	
 };
 
 class KBookmarkEditFields {


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

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