//Credit to amaroK for this //Seems like it can become the next plugin to do since amarok is really cool (just missing plugin arch) bool SongList::eventFilter(QObject *o, QEvent *e ) { if(o == header() && e->type() == QEvent::MouseButtonPress && static_cast<QMouseEvent*>(e)->button() == Qt::RightButton ) { KPopupMenu popup; //popup.setFont(this->font()); popup.setCheckable(true); popup.insertTitle(i18n("Available Columns")); int colcount=columns(); for( int i = 0; i < colcount; ++i ) //columns() references a property { popup.insertItem(columnText(i),i,i+1 ); popup.setItemChecked(i,columnWidth(i)!=0); } int col = popup.exec( static_cast<QMouseEvent *>(e)->globalPos() ); if( col != -1 ) { //TODO can result in massively wide column appearing! if( columnWidth( col ) == 0 ) { adjustColumn( col ); header()->setResizeEnabled( true, col ); } else hideColumn( col ); } //determine first visible column again, since it has changed //eat event return TRUE; } return KListView::eventFilter(o,e); }
ICNView::ICNView(ICNDocument *icnDocument, ViewContainer *viewContainer, uint viewAreaId, const char *name) : ItemView(icnDocument, viewContainer, viewAreaId, name) { bool manualRouting = (icnDocument->m_cmManager->cmState() & CMManager::cms_manual_route); KActionCollection * ac = actionCollection(); //BEGIN Routing Actions // These actions get inserted into the main menu m_pAutoRoutingAction = new KRadioAction(i18n("Automatic"), "", 0, this, SLOT(slotSetRoutingAuto()), ac, "routing_mode_auto"); m_pAutoRoutingAction->setExclusiveGroup("routing_mode"); if (!manualRouting) m_pAutoRoutingAction->setChecked(true); m_pManualRoutingAction = new KRadioAction(i18n("Manual"), "", 0, this, SLOT(slotSetRoutingManual()), ac, "routing_mode_manual"); m_pManualRoutingAction->setExclusiveGroup("routing_mode"); if (manualRouting) m_pManualRoutingAction->setChecked(true); // This popup gets inserted into the toolbar m_pRoutingModeToolbarPopup = new KToolBarPopupAction(i18n("Connection Routing Mode"), "pencil", 0, 0, 0, ac, "routing_mode"); m_pRoutingModeToolbarPopup->setDelayed(false); KPopupMenu *m = m_pRoutingModeToolbarPopup->popupMenu(); m->insertTitle(i18n("Connection Routing Mode")); m->insertItem(/*KGlobal::iconLoader()->loadIcon( "routing_mode_auto", KIcon::Small ), */i18n("Automatic"), 0); m->insertItem(/*KGlobal::iconLoader()->loadIcon( "routing_mode_manual", KIcon::Small ),*/ i18n("Manual"), 1); m->setCheckable(true); m->setItemChecked(manualRouting ? 1 : 0, true); connect(m, SIGNAL(activated(int)), this, SLOT(slotSetRoutingMode(int))); //END Routing Actions connect(icnDocument->m_cmManager, SIGNAL(manualRoutingChanged(bool)), this, SLOT(slotUpdateRoutingToggles(bool))); }