void KBookmarkBar::slotBookmarksChanged( const QString & group )
{
    KBookmarkGroup tb = getToolbar(); // heavy for non cached toolbar version
    kDebug(7043) << "KBookmarkBar::slotBookmarksChanged( " << group << " )";

    if ( tb.isNull() )
        return;

    if( d->m_filteredToolbar )
    {
        clear();
        fillBookmarkBar( tb );
    }
    else if ( KBookmark::commonParent(group, tb.address()) == group)  // Is group a parent of tb.address?
    {
        clear();
        fillBookmarkBar( tb );
    }
    else
    {
        // Iterate recursively into child menus
        for ( QList<KBookmarkMenu *>::ConstIterator smit = m_lstSubMenus.constBegin(), smend = m_lstSubMenus.constEnd();
              smit != smend; ++smit )
        {
            (*smit)->slotBookmarksChanged( group );
        }
    }
}
void KBookmarkBar::slotConfigChanged()
{
    KConfig config("kbookmarkrc", KConfig::NoGlobals);
    KConfigGroup cg(&config, "Bookmarks");
    d->m_filteredToolbar = cg.readEntry( "FilteredToolbar", false );
    d->m_contextMenu = cg.readEntry( "ContextMenuActions", true );
    clear();
    fillBookmarkBar(getToolbar());
}
void initClientLayout(GtkWidget *window) {
	GtkWidget	*menubar;
	GtkWidget	*main_vbox;		//main vertical box widget	
	GtkWidget	*button_hbox;		//buttons horizon box widget
	GtkWidget	*separator;		//separator widget

	//Create a vbox to put menubar, image, and 3 buttons
	main_vbox = gtk_vbox_new(FALSE, BOX_SPACING_SIZE);
	//Set the border width of man_vbox
	gtk_container_set_border_width(GTK_CONTAINER(main_vbox), BORDER_WIDTH_SIZE);
	//Add the main_vbox into the window
	gtk_container_add(GTK_CONTAINER(window), main_vbox);

	//Create the menubar from itemfactoryentry
	menubar = getMenubarMenu(window);
	//Pack the menubar into the main_vbox
	gtk_box_pack_start(GTK_BOX(main_vbox), menubar, FALSE, TRUE, 0);

	//Create the toolbar
	toolbar = getToolbar();
	//Pack the toolbar into the main_vbox
	gtk_box_pack_start(GTK_BOX(main_vbox), toolbar, FALSE, TRUE, 0);

	//Create a image to play the video
	image = gtk_image_new_from_file(VIDEO_ICON);
	//Pack the image into the main_vbox
	gtk_box_pack_start(GTK_BOX(main_vbox), image, TRUE, TRUE, 0);

	//Create a separator
	separator = gtk_hseparator_new();
	//Pack the separator into the main_vbox
	gtk_box_pack_start(GTK_BOX(main_vbox), separator, FALSE, TRUE, 0);

	//Create a hbox to put 3 buttons
	button_hbox = gtk_hbox_new(TRUE, BOX_SPACING_SIZE);
	//Pack the button_hbox into the main_vbox
	gtk_box_pack_start(GTK_BOX(main_vbox), button_hbox, FALSE, TRUE, 0);

	//Create the setup button
	setupButton = getButton(button_hbox, GTK_STOCK_NETWORK, "Setup", "Setup RTSP Connection");
	//Create the play button
	playButton = getButton(button_hbox, GTK_STOCK_MEDIA_PLAY, "Play", "Play Streaming Video");
	//Create the teardown button
	teardownButton = getButton(button_hbox, GTK_STOCK_MEDIA_STOP, "Teardown", "Teardown RTSP Connection");

	//Set the sensitive property of buttons
	setSensitive(TRUE, FALSE, FALSE);

	return;
}
KBookmarkBar::KBookmarkBar( KBookmarkManager* mgr,
                            KonqBookmarkOwner *_owner, KToolBar *_toolBar,
                            QObject *parent )
    : QObject( parent ), m_pOwner(_owner), m_toolBar(_toolBar),
      m_pManager( mgr ), d( new KBookmarkBarPrivate )
{
    m_toolBar->setAcceptDrops( true );
    m_toolBar->installEventFilter( this ); // for drops

    if (d->m_contextMenu)
    {
        m_toolBar->setContextMenuPolicy(Qt::CustomContextMenu);
        connect(m_toolBar, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenu(QPoint)));
    }

    connect( mgr, SIGNAL(changed(QString,QString)),
             SLOT(slotBookmarksChanged(QString)) );
    connect( mgr, SIGNAL(configChanged()),
             SLOT(slotConfigChanged()) );

    KBookmarkGroup toolbar = getToolbar();
    fillBookmarkBar( toolbar );
    m_toolBarSeparator = new KAction(this);
}
bool ToolbarItemComponent::isToolbarVertical() const
{
    const Toolbar* const t = getToolbar();
    return t != nullptr && t->isVertical();
}
// TODO    *** drop improvements ***
// open submenus on drop interactions
bool KBookmarkBar::eventFilter( QObject *, QEvent *e )
{
    if (d->m_filteredToolbar)
        return false; // todo: make this limit the actions

    if ( e->type() == QEvent::DragLeave )
    {
        removeTempSep();
    }
    else if ( e->type() == QEvent::Drop )
    {
        removeTempSep();

        QDropEvent *dev = static_cast<QDropEvent*>( e );
        QDomDocument doc;
        QList<KBookmark> list = KBookmark::List::fromMimeData( dev->mimeData(), doc );
        if ( list.isEmpty() )
            return false;
        if (list.count() > 1)
            kWarning(7043) << "Sorry, currently you can only drop one address "
                "onto the bookmark bar!";
        KBookmark toInsert = list.first();

        KBookmarkGroup parentBookmark = getToolbar();

        if(d->m_sepIndex == 0)
        {
            KBookmark newBookmark = parentBookmark.addBookmark(toInsert.fullText(), toInsert.url() );

            parentBookmark.moveBookmark( newBookmark, KBookmark() );
            m_pManager->emitChanged( parentBookmark );
            return true;
        }
        else
        {
            KBookmark after = parentBookmark.first();

            for(int i=0; i < d->m_sepIndex - 1 ; ++i)
                after = parentBookmark.next(after);
            KBookmark newBookmark = parentBookmark.addBookmark(toInsert.fullText(), toInsert.url() );

            parentBookmark.moveBookmark( newBookmark, after );
            m_pManager->emitChanged( parentBookmark );
            return true;
        }
    }
    else if ( e->type() == QEvent::DragMove || e->type() == QEvent::DragEnter )
    {
        QDragMoveEvent *dme = static_cast<QDragMoveEvent*>( e );
        if (!KBookmark::List::canDecode( dme->mimeData() ))
            return false;

        //cache text, save positions (inserting the temporary widget changes the positions)
        if(e->type() == QEvent::DragEnter)
        {
            QDomDocument doc;
            const QList<KBookmark> list = KBookmark::List::fromMimeData( dme->mimeData(), doc );
            if ( list.isEmpty() )
                return false;
            d->tempLabel  = list.first().url().pathOrUrl();

            d->widgetPositions.clear();

            for (int i = 0; i < m_toolBar->actions().count(); ++i)
                if (QWidget* button = m_toolBar->widgetForAction(m_toolBar->actions()[i])) {
                    if(m_toolBar->orientation() == Qt::Horizontal) {
                        if(QApplication::isLeftToRight()) {
                            d->widgetPositions.push_back(button->geometry().right());
                        } else {
                            d->widgetPositions.push_back(button->geometry().left());
                        }
                    } else {
                        d->widgetPositions.push_back(button->geometry().bottom());
                    }
                }
        }

        bool accept = handleToolbarDragMoveEvent(dme->pos(), d->m_actions, d->tempLabel);
        if (accept)
        {
            dme->accept();
            return true; //Really?
        }
    }
    return false;
}