bool Sidebar_Widget::addButton(const QString &desktoppath,int pos) { int lastbtn = m_buttons.count(); m_buttons.resize(m_buttons.size()+1); KSimpleConfig *confFile; kdDebug() << "addButton:" << (m_path+desktoppath) << endl; confFile = new KSimpleConfig(m_path+desktoppath,true); confFile->setGroup("Desktop Entry"); QString icon = confFile->readEntry("Icon"); QString name = confFile->readEntry("Name"); QString comment = confFile->readEntry("Comment"); QString url = confFile->readPathEntry("URL",QString::null); QString lib = confFile->readEntry("X-KDE-KonqSidebarModule"); delete confFile; if (pos == -1) { m_buttonBar->appendTab(SmallIcon(icon), lastbtn, name); ButtonInfo *bi = new ButtonInfo(desktoppath, ((KonqSidebar*)m_partParent),0, url, lib, name, icon, this); /*int id=*/m_buttons.insert(lastbtn, bi); KMultiTabBarTab *tab = m_buttonBar->tab(lastbtn); tab->installEventFilter(this); connect(tab,SIGNAL(clicked(int)),this,SLOT(showHidePage(int))); // Set Whats This help // This uses the comments in the .desktop files QWhatsThis::add(tab, comment); }
void KMultiTabBarInternal::resizeEvent(QResizeEvent *ev) { /* kdDebug()<<"KMultiTabBarInternal::resizeEvent"<<endl; kdDebug()<<"KMultiTabBarInternal::resizeEvent - box geometry"<<box->geometry()<<endl; kdDebug()<<"KMultiTabBarInternal::resizeEvent - geometry"<<geometry()<<endl;*/ if(ev) QScrollView::resizeEvent(ev); if((m_style == KMultiTabBar::KDEV3) || (m_style == KMultiTabBar::KDEV3ICON)) { box->setGeometry(0, 0, width(), height()); int lines = 1; uint space; float tmp = 0; if((m_position == KMultiTabBar::Bottom) || (m_position == KMultiTabBar::Top)) space = width(); else space = height(); int cnt = 0; // CALCULATE LINES const uint tabCount = m_tabs.count(); for(uint i = 0; i < tabCount; i++) { cnt++; tmp += m_tabs.at(i)->neededSize(); if(tmp > space) { if(cnt > 1) i--; else if(i == (tabCount - 1)) break; cnt = 0; tmp = 0; lines++; } } // SET SIZE & PLACE float diff = 0; cnt = 0; if((m_position == KMultiTabBar::Bottom) || (m_position == KMultiTabBar::Top)) { setFixedHeight(lines * 24); box->setFixedHeight(lines * 24); m_lines = height() / 24 - 1; lines = 0; CALCDIFF(m_tabs, diff, 0) tmp = -diff; // kdDebug()<<"m_lines recalculated="<<m_lines<<endl; for(uint i = 0; i < tabCount; i++) { KMultiTabBarTab *tab = m_tabs.at(i); cnt++; tmp += tab->neededSize() + diff; if(tmp > space) { // kdDebug()<<"about to start new line"<<endl; if(cnt > 1) { CALCDIFF(m_tabs, diff, i) i--; } else { // kdDebug()<<"placing line on old line"<<endl; kdDebug() << "diff=" << diff << endl; tab->removeEventFilter(this); tab->move(NEARBYINT(tmp - tab->neededSize()), lines * 24); // tab->setFixedWidth(tab->neededSize()+diff); tab->setFixedWidth(NEARBYINT(tmp + diff) - tab->x()); ; tab->installEventFilter(this); CALCDIFF(m_tabs, diff, (i + 1)) } tmp = -diff; cnt = 0; lines++; // kdDebug()<<"starting new line:"<<lines<<endl; } else { // kdDebug()<<"Placing line on line:"<<lines<<" pos: (x/y)=("<<tmp-m_tabs.at(i)->neededSize()<<"/"<<lines*24<<")"<<endl; // kdDebug()<<"diff="<<diff<<endl; tab->removeEventFilter(this); tab->move(NEARBYINT(tmp - tab->neededSize()), lines * 24); tab->setFixedWidth(NEARBYINT(tmp + diff) - tab->x()); ; // tab->setFixedWidth(tab->neededSize()+diff); tab->installEventFilter(this); } }