kmdi Library API Documentation

kmdidockcontainer.cpp

00001 /* This file is part of the KDE project 00002 Copyright (C) 2002 Christoph Cullmann <cullmann@kde.org> 00003 Copyright (C) 2002,2003 Joseph Wenninger <jowenn@kde.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License version 2 as published by the Free Software Foundation. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00017 Boston, MA 02111-1307, USA. 00018 */ 00019 00020 #include "kmdimainfrm.h" 00021 #include "kmdidockcontainer.h" 00022 #include "kmdidockcontainer.moc" 00023 00024 #include "kdockwidget_private.h" 00025 00026 #include <qwidgetstack.h> 00027 #include <qlayout.h> 00028 #include <qtimer.h> 00029 #include <qtooltip.h> 00030 #include <kmultitabbar.h> 00031 00032 #include <kdebug.h> 00033 #include <kiconloader.h> 00034 #include <kapplication.h> 00035 #include <kconfig.h> 00036 #include <klocale.h> 00037 00038 //TODO: Well, this is already defined in kdeui/kdockwidget.cpp 00039 static const char* const kmdi_not_close_xpm[]={ 00040 "5 5 2 1", 00041 "# c black", 00042 ". c None", 00043 "#####", 00044 "#...#", 00045 "#...#", 00046 "#...#", 00047 "#####"}; 00048 00049 KMdiDockContainer::KMdiDockContainer(QWidget *parent, QWidget *win, int position, int flags) 00050 : QWidget(parent),KDockContainer() 00051 { 00052 m_tabSwitching = false; 00053 m_block=false; 00054 m_inserted=-1; 00055 m_mainWin = win; 00056 oldtab=-1; 00057 mTabCnt=0; 00058 m_position = position; 00059 m_previousTab=-1; 00060 m_separatorPos = 17; 00061 00062 kdDebug(760)<<"KMdiDockContainer created"<<endl; 00063 00064 QBoxLayout *l; 00065 m_vertical=!((position==KDockWidget::DockTop) || (position==KDockWidget::DockBottom)); 00066 00067 if (!m_vertical) 00068 l=new QVBoxLayout(this); 00069 else 00070 l=new QHBoxLayout(this); 00071 00072 l->setAutoAdd(false); 00073 00074 m_tb=new KMultiTabBar(((position==KDockWidget::DockTop) || (position==KDockWidget::DockBottom))? 00075 KMultiTabBar::Horizontal:KMultiTabBar::Vertical,this); 00076 00077 m_tb->setStyle(KMultiTabBar::KMultiTabBarStyle(flags)); 00078 m_tb->showActiveTabTexts(true); 00079 00080 m_tb->setPosition((position==KDockWidget::DockLeft)?KMultiTabBar::Left: 00081 (position==KDockWidget::DockBottom)?KMultiTabBar::Bottom: 00082 (position==KDockWidget::DockTop)?KMultiTabBar::Top:KMultiTabBar::Right); 00083 00084 m_ws=new QWidgetStack(this); 00085 00086 m_ws->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); 00087 00088 if ( (position==KDockWidget::DockLeft) || (position==KDockWidget::DockTop)) 00089 { 00090 l->add(m_tb); 00091 l->add(m_ws); 00092 } 00093 else 00094 { 00095 l->add(m_ws); 00096 l->add(m_tb); 00097 } 00098 00099 l->activate(); 00100 m_ws->hide(); 00101 00102 } 00103 00104 void KMdiDockContainer::setStyle(int style) { 00105 if (m_tb) m_tb->setStyle(KMultiTabBar::KMultiTabBarStyle(style)); 00106 } 00107 00108 KMdiDockContainer::~KMdiDockContainer() 00109 { 00110 QMap<KDockWidget*,int>::iterator it; 00111 while (m_map.count()) { 00112 it = m_map.begin(); 00113 KDockWidget *w=it.key(); 00114 if (m_overlapButtons.contains(w)) { 00115 (static_cast<KDockWidgetHeader*>(w->getHeader()->qt_cast("KDockWidgetHeader")))->removeButton(m_overlapButtons[w]); 00116 m_overlapButtons.remove(w); 00117 } 00118 m_map.remove(w); 00119 w->undock(); 00120 } 00121 deactivated(this); 00122 } 00123 00124 00125 void KMdiDockContainer::init() 00126 { 00127 if (m_vertical) 00128 { 00129 parentDockWidget()->setForcedFixedWidth(m_tb->width()); 00130 activateOverlapMode(m_tb->width()); 00131 } 00132 else 00133 { 00134 parentDockWidget()->setForcedFixedHeight(m_tb->height()); 00135 activateOverlapMode(m_tb->height()); 00136 } 00137 00138 // try to restore splitter size 00139 if ( parentDockWidget() && parentDockWidget()->parent() ) 00140 { 00141 KDockSplitter *sp= static_cast<KDockSplitter*>(parentDockWidget()-> 00142 parent()->qt_cast("KDockSplitter")); 00143 if ( sp ) 00144 sp->setSeparatorPosX( m_separatorPos ); 00145 } 00146 } 00147 00148 KDockWidget *KMdiDockContainer::parentDockWidget() 00149 { 00150 return ((KDockWidget*)parent()); 00151 } 00152 00153 void KMdiDockContainer::insertWidget (KDockWidget *dwdg, QPixmap pixmap, const QString &text, int &) 00154 { 00155 KDockWidget* w = (KDockWidget*) dwdg; 00156 int tab; 00157 bool alreadyThere=m_map.contains(w); 00158 00159 if (alreadyThere) 00160 { 00161 tab=m_map[w]; 00162 if (m_ws->addWidget(w,tab)!=tab) kdDebug(760)<<"ERROR COULDN'T READD WIDGET************"<<endl; 00163 kdDebug(760)<<"READDED WIDGET***********************************"<<endl; 00164 /*JOWENN m_tb->setTab(tab,true); 00165 tabClicked(tab);*/ 00166 } 00167 else 00168 { 00169 tab=m_ws->addWidget(w); 00170 m_map.insert(w,tab); 00171 m_revMap.insert(tab,w); 00172 00173 if (((KDockWidget*)parentWidget())->mayBeShow()) 00174 ((KDockWidget*)parentWidget())->dockBack(); 00175 00176 if (w->getHeader()->qt_cast("KDockWidgetHeader")) 00177 { 00178 kdDebug(760)<<"*** KDockWidgetHeader has been found"<<endl; 00179 00180 KDockWidgetHeader *hdr=static_cast<KDockWidgetHeader*>(w->getHeader()-> 00181 qt_cast("KDockWidgetHeader")); 00182 00183 KDockButton_Private *btn = new KDockButton_Private( hdr, "OverlapButton" ); 00184 00185 QToolTip::add( btn, i18n("Switch between overlap and side by side mode", "Overlap") ); 00186 00187 btn->setToggleButton( true ); 00188 btn->setPixmap( const_cast< const char** >(kmdi_not_close_xpm) ); 00189 hdr->addButton(btn); 00190 m_overlapButtons.insert(w,btn); 00191 btn->setOn(!isOverlapMode()); 00192 00193 connect(btn,SIGNAL(clicked()),this,SLOT(changeOverlapMode())); 00194 } 00195 00196 m_tb->appendTab(pixmap.isNull()?SmallIcon("misc"):pixmap,tab,w->tabPageLabel()); 00197 00198 kdDebug(760)<<"NAMENAMENAMENAME:===========================:"<<w->tabPageLabel()<<endl; 00199 00200 //FB m_tb->setTab(tab,true); 00201 00202 connect(m_tb->tab(tab),SIGNAL(clicked(int)),this,SLOT(tabClicked(int))); 00203 00204 kdDebug(760)<<"KMdiDockContainer::insertWidget()"<<endl; 00205 00206 //FB m_tb->setTab(oldtab,false); 00207 00208 mTabCnt++; 00209 m_inserted=tab; 00210 int dummy=0; 00211 //FB tabClicked(tab); 00212 KDockContainer::insertWidget(w,pixmap,text,dummy); 00213 itemNames.append(w->name()); 00214 tabCaptions.insert(w->name(),w->tabPageLabel()); 00215 tabTooltips.insert(w->name(),w->toolTipString()); 00216 } 00217 00218 //FB m_ws->raiseWidget(tab); 00219 } 00220 00221 void KMdiDockContainer::showWidget(KDockWidget *w) { 00222 if (!m_map.contains(w)) return; 00223 int id=m_map[w]; 00224 m_tb->setTab(id,true); 00225 tabClicked(id); 00226 } 00227 00228 void KMdiDockContainer::changeOverlapMode() 00229 { 00230 const KDockButton_Private *btn=dynamic_cast<const KDockButton_Private*>(sender()); 00231 00232 kdDebug(760)<<"KMdiDockContainer::changeOverlapMode: button=="<<btn<<endl; 00233 00234 if (!btn) return; 00235 00236 if (!btn->isOn()) { 00237 kdDebug(760)<<"KMdiDockContainer::changeOverlapMode: activateOverlapMode"<<endl; 00238 if (m_vertical) { 00239 activateOverlapMode(m_tb->width()); 00240 } 00241 else 00242 { 00243 activateOverlapMode(m_tb->height()); 00244 } 00245 } else { 00246 kdDebug(760)<<"KMdiDockContainer::changeOverlapMode: deactivateOverlapMode"<<endl; 00247 deactivateOverlapMode(); 00248 } 00249 00250 for (QMap<KDockWidget*,KDockButton_Private*>::iterator it=m_overlapButtons.begin(); 00251 it!=m_overlapButtons.end();++it) 00252 it.data()->setOn(!isOverlapMode()); 00253 } 00254 00255 void KMdiDockContainer::hideIfNeeded() { 00256 kdDebug(760)<<"************************* hideIfNeeded *************************"<<endl; 00257 if (!itemNames.count()) 00258 ((KDockWidget*)parentWidget())->undock(); 00259 } 00260 00261 void KMdiDockContainer::removeWidget(KDockWidget* dwdg) 00262 { 00263 KDockWidget* w = (KDockWidget*) dwdg; 00264 if (!m_map.contains(w)) return; 00265 int id=m_map[w]; 00266 if (m_tb->isTabRaised(id)) { 00267 m_tb->setTab(id,false); 00268 tabClicked(id); 00269 } 00270 m_tb->removeTab(id); 00271 m_ws->removeWidget(w); 00272 m_map.remove(w); 00273 m_revMap.remove(id); 00274 if (m_overlapButtons.contains(w)) { 00275 (static_cast<KDockWidgetHeader*>(w->getHeader()->qt_cast("KDockWidgetHeader")))->removeButton(m_overlapButtons[w]); 00276 m_overlapButtons.remove(w); 00277 } 00278 KDockContainer::removeWidget(w); 00279 itemNames.remove(w->name()); 00280 tabCaptions.remove(w->name()); 00281 tabTooltips.remove(w->name()); 00282 if (!itemNames.count()) 00283 ((KDockWidget*)parentWidget())->undock(); 00284 } 00285 00286 void KMdiDockContainer::undockWidget(KDockWidget *dwdg) 00287 { 00288 KDockWidget* w = (KDockWidget*) dwdg; 00289 00290 if (!m_map.contains(w)) 00291 return; 00292 00293 int id=m_map[w]; 00294 if (m_tb->isTabRaised(id)) { 00295 kdDebug(760)<<"Wiget has been undocked, setting tab down"<<endl; 00296 m_tb->setTab(id,false); 00297 tabClicked(id); 00298 } 00299 } 00300 00301 void KMdiDockContainer::tabClicked(int t) 00302 { 00303 kdDebug(760)<<"KMdiDockContainer::tabClicked()"<<endl; 00304 bool call_makeVisible=!m_tabSwitching; 00305 m_tabSwitching=true; 00306 if (m_tb->isTabRaised(t)) 00307 { 00308 00309 if (m_ws->isHidden()) 00310 { 00311 m_ws->show (); 00312 parentDockWidget()->restoreFromForcedFixedSize(); 00313 } 00314 if (!m_ws->widget(t)) 00315 { 00316 m_revMap[t]->manualDock(parentDockWidget(),KDockWidget::DockCenter,20); 00317 if (call_makeVisible) m_revMap[t]->makeDockVisible();//manualDock(parentDockWidget(),KDockWidget::DockCenter,20); 00318 m_tabSwitching=false; 00319 emit activated(this); 00320 return; 00321 } 00322 m_ws->raiseWidget(t); 00323 if (m_ws->widget(t)) { 00324 KDockWidget *tmpDw=static_cast<KDockWidget*>(m_ws->widget(t)->qt_cast("KDockWidget")); 00325 if (tmpDw) { 00326 if (tmpDw->getWidget()) tmpDw->getWidget()->setFocus(); 00327 } else kdDebug(760)<<"Something really weird is going on"<<endl; 00328 } else 00329 kdDebug(760)<<"KMdiDockContainer::tabClicked(int): m_ws->widget(t)==0 "<<endl; 00330 00331 if (oldtab!=t) m_tb->setTab(oldtab,false); 00332 m_tabSwitching=true; 00333 oldtab=t; 00334 emit activated(this); 00335 } 00336 else 00337 { 00338 // try save splitter position 00339 if ( parentDockWidget() && parentDockWidget()->parent() ) 00340 { 00341 KDockSplitter *sp= static_cast<KDockSplitter*>(parentDockWidget()-> 00342 parent()->qt_cast("KDockSplitter")); 00343 if ( sp ) 00344 m_separatorPos = sp->separatorPos(); 00345 } 00346 m_previousTab=t; 00347 // oldtab=-1; 00348 if (m_block) return; 00349 emit deactivated(this); 00350 m_block=true; 00351 if (m_ws->widget(t)) 00352 { 00353 // ((KDockWidget*)m_ws->widget(t))->undock(); 00354 } 00355 m_block=false; 00356 m_ws->hide (); 00357 00358 00359 kdDebug(760)<<"Fixed Width:"<<m_tb->width()<<endl; 00360 if (m_vertical) 00361 parentDockWidget()->setForcedFixedWidth(m_tb->width()+2); // strange why it worked before at all 00362 else 00363 parentDockWidget()->setForcedFixedHeight(m_tb->height()+2); // strange why it worked before at all 00364 } 00365 m_tabSwitching=false; 00366 } 00367 00368 void KMdiDockContainer::setToolTip (KDockWidget *, QString &s) 00369 { 00370 kdDebug(760)<<"***********************************Setting tooltip for a widget: "<<s<<endl; 00371 } 00372 00373 void KMdiDockContainer::setPixmap(KDockWidget* widget ,const QPixmap& pixmap) 00374 { 00375 int id=m_ws->id(widget); 00376 if (id==-1) return; 00377 KMultiTabBarTab *tab=m_tb->tab(id); 00378 tab->setIcon(pixmap.isNull()?SmallIcon("misc"):pixmap); 00379 } 00380 00381 void KMdiDockContainer::save(QDomElement& dockEl) 00382 { 00383 QDomDocument doc=dockEl.ownerDocument(); 00384 QDomElement el; 00385 el=doc.createElement("name"); 00386 el.appendChild(doc.createTextNode(QString("%1").arg(parent()->name()))); 00387 dockEl.appendChild(el); 00388 el=doc.createElement("overlapMode"); 00389 el.appendChild(doc.createTextNode(isOverlapMode() ?"true":"false")); 00390 dockEl.appendChild(el); 00391 QPtrList<KMultiTabBarTab>* tl=m_tb->tabs(); 00392 QPtrListIterator<KMultiTabBarTab> it(*tl); 00393 QStringList::Iterator it2=itemNames.begin(); 00394 int i=0; 00395 for (;it.current()!=0;++it,++it2) 00396 { 00397 el=doc.createElement("child"); 00398 el.setAttribute("pos",QString("%1").arg(i)); 00399 QString s=tabCaptions[*it2]; 00400 if (!s.isEmpty()) { 00401 el.setAttribute("tabCaption",s); 00402 } 00403 s=tabTooltips[*it2]; 00404 if (!s.isEmpty()) { 00405 el.setAttribute("tabTooltip",s); 00406 } 00407 el.appendChild(doc.createTextNode(*it2)); 00408 dockEl.appendChild(el); 00409 if (m_tb->isTabRaised(it.current()->id())) 00410 { 00411 QDomElement el2=doc.createElement("raised"); 00412 el2.appendChild(doc.createTextNode(m_ws->widget(it.current()->id())->name())); 00413 el.appendChild(el2); 00414 } 00415 ++i; 00416 } 00417 00418 00419 } 00420 00421 void KMdiDockContainer::load(QDomElement& dockEl) 00422 { 00423 QString raise; 00424 00425 for (QDomNode n=dockEl.firstChild();!n.isNull();n=n.nextSibling()) { 00426 QDomElement el=n.toElement(); 00427 if (el.isNull()) continue; 00428 if (el.tagName()=="overlapMode") { 00429 if (el.attribute("overlapMode")!="false") 00430 activateOverlapMode(m_tb->width()); 00431 else 00432 deactivateOverlapMode(); 00433 } else if (el.tagName()=="child") { 00434 KDockWidget *dw=((KDockWidget*)parent())->dockManager()->getDockWidgetFromName(el.text()); 00435 if (dw) 00436 { 00437 if (el.hasAttribute("tabCaption")) { 00438 dw->setTabPageLabel(el.attribute("tabCaption")); 00439 } 00440 if (el.hasAttribute("tabTooltip")) { 00441 dw->setToolTipString(el.attribute("tabTooltip")); 00442 } 00443 dw->manualDock((KDockWidget*)parent(),KDockWidget::DockCenter); 00444 } 00445 } 00446 } 00447 00448 00449 QPtrList<KMultiTabBarTab>* tl=m_tb->tabs(); 00450 QPtrListIterator<KMultiTabBarTab> it1(*tl); 00451 m_ws->hide(); 00452 if (m_vertical) 00453 parentDockWidget()->setForcedFixedWidth(m_tb->width()); 00454 else 00455 parentDockWidget()->setForcedFixedHeight(m_tb->height()); 00456 for (;it1.current()!=0;++it1) 00457 { 00458 m_tb->setTab(it1.current()->id(),false); 00459 } 00460 kapp->syncX(); 00461 m_delayedRaise=-1; 00462 00463 for (QMap<KDockWidget*,KDockButton_Private*>::iterator it=m_overlapButtons.begin(); 00464 it!=m_overlapButtons.end();++it) 00465 it.data()->setOn(!isOverlapMode()); 00466 00467 if (!raise.isEmpty()) 00468 { 00469 for (QMap<KDockWidget*,int>::iterator it=m_map.begin();it!=m_map.end();++it) 00470 { 00471 if (it.key()->name()==raise) 00472 { 00473 m_delayedRaise=it.data(); 00474 QTimer::singleShot(0,this,SLOT(delayedRaise())); 00475 kdDebug(760)<<"************** raising *******: "<<it.key()->name()<<endl; 00476 break; 00477 } 00478 } 00479 00480 } 00481 if (m_delayedRaise==-1) QTimer::singleShot(0,this,SLOT(init())); 00482 00483 00484 00485 00486 } 00487 00488 00489 00490 00491 00492 00493 00494 00495 00496 00497 00498 00499 00500 00501 00502 void KMdiDockContainer::save(KConfig* cfg,const QString& group_or_prefix) 00503 { 00504 QString grp=cfg->group(); 00505 cfg->deleteGroup(group_or_prefix+QString("::%1").arg(parent()->name())); 00506 cfg->setGroup(group_or_prefix+QString("::%1").arg(parent()->name())); 00507 00508 if (isOverlapMode()) cfg->writeEntry("overlapMode","true"); 00509 else cfg->writeEntry("overlapMode","false"); 00510 00511 // try to save the splitter position 00512 if ( parentDockWidget() && parentDockWidget()->parent() ) 00513 { 00514 KDockSplitter *sp= static_cast<KDockSplitter*>(parentDockWidget()-> 00515 parent()->qt_cast("KDockSplitter")); 00516 if ( sp ) 00517 cfg->writeEntry( "separatorPos", m_separatorPos ); 00518 } 00519 00520 QPtrList<KMultiTabBarTab>* tl=m_tb->tabs(); 00521 QPtrListIterator<KMultiTabBarTab> it(*tl); 00522 QStringList::Iterator it2=itemNames.begin(); 00523 int i=0; 00524 for (;it.current()!=0;++it,++it2) 00525 { 00526 // cfg->writeEntry(QString("widget%1").arg(i),m_ws->widget(it.current()->id())->name()); 00527 cfg->writeEntry(QString("widget%1").arg(i),(*it2)); 00528 QString s=tabCaptions[*it2]; 00529 if (!s.isEmpty()) { 00530 cfg->writeEntry(QString("widget%1-tabCaption").arg(i),s); 00531 } 00532 s=tabTooltips[*it2]; 00533 if (!s.isEmpty()) { 00534 cfg->writeEntry(QString("widget%1-tabTooltip").arg(i),s); 00535 } 00536 // kdDebug(760)<<"****************************************Saving: "<<m_ws->widget(it.current()->id())->name()<<endl; 00537 if (m_tb->isTabRaised(it.current()->id())) 00538 cfg->writeEntry(m_ws->widget(it.current()->id())->name(),true); 00539 ++i; 00540 } 00541 cfg->sync(); 00542 cfg->setGroup(grp); 00543 00544 } 00545 00546 void KMdiDockContainer::load(KConfig* cfg,const QString& group_or_prefix) 00547 { 00548 QString grp=cfg->group(); 00549 cfg->setGroup(group_or_prefix+QString("::%1").arg(parent()->name())); 00550 00551 if (cfg->readEntry("overlapMode")!="false") 00552 activateOverlapMode(m_tb->width()); 00553 else 00554 deactivateOverlapMode(); 00555 00556 m_separatorPos = cfg->readNumEntry( "separatorPos", 18 ); 00557 00558 int i=0; 00559 QString raise; 00560 while (true) 00561 { 00562 QString dwn=cfg->readEntry(QString("widget%1").arg(i)); 00563 if (dwn.isEmpty()) break; 00564 kdDebug(760)<<"*************************************************************Configuring dockwidget :"<<dwn<<endl; 00565 KDockWidget *dw=((KDockWidget*)parent())->dockManager()->getDockWidgetFromName(dwn); 00566 if (dw) 00567 { 00568 QString s=cfg->readEntry(QString("widget%1-tabCaption").arg(i)); 00569 if (!s.isEmpty()) { 00570 dw->setTabPageLabel(s); 00571 } 00572 s=cfg->readEntry(QString("widget%1-tabTooltip").arg(i)); 00573 if (!s.isEmpty()) { 00574 dw->setToolTipString(s); 00575 } 00576 dw->manualDock((KDockWidget*)parent(),KDockWidget::DockCenter); 00577 } 00578 if (cfg->readBoolEntry(dwn,false)) raise=dwn; 00579 i++; 00580 00581 } 00582 00583 QPtrList<KMultiTabBarTab>* tl=m_tb->tabs(); 00584 QPtrListIterator<KMultiTabBarTab> it1(*tl); 00585 m_ws->hide(); 00586 if (m_vertical) 00587 parentDockWidget()->setForcedFixedWidth(m_tb->width()); 00588 else 00589 parentDockWidget()->setForcedFixedHeight(m_tb->height()); 00590 for (;it1.current()!=0;++it1) 00591 { 00592 m_tb->setTab(it1.current()->id(),false); 00593 } 00594 kapp->syncX(); 00595 m_delayedRaise=-1; 00596 00597 for (QMap<KDockWidget*,KDockButton_Private*>::iterator it=m_overlapButtons.begin(); 00598 it!=m_overlapButtons.end();++it) 00599 it.data()->setOn(!isOverlapMode()); 00600 00601 if (!raise.isEmpty()) 00602 { 00603 for (QMap<KDockWidget*,int>::iterator it=m_map.begin();it!=m_map.end();++it) 00604 { 00605 if (it.key()->name()==raise) 00606 { 00607 /* tabClicked(it.data()); 00608 m_tb->setTab(it.data(),true); 00609 tabClicked(it.data()); 00610 m_ws->raiseWidget(it.key()); 00611 kapp->sendPostedEvents(); 00612 kapp->syncX();*/ 00613 00614 m_delayedRaise=it.data(); 00615 QTimer::singleShot(0,this,SLOT(delayedRaise())); 00616 kdDebug(760)<<"************** raising *******: "<<it.key()->name()<<endl; 00617 break; 00618 } 00619 } 00620 00621 } 00622 if (m_delayedRaise==-1) QTimer::singleShot(0,this,SLOT(init())); 00623 cfg->setGroup(grp); 00624 00625 } 00626 00627 void KMdiDockContainer::delayedRaise() 00628 { 00629 m_tb->setTab(m_delayedRaise,true); 00630 tabClicked(m_delayedRaise); 00631 } 00632 00633 void KMdiDockContainer::collapseOverlapped() 00634 { 00635 if (m_tabSwitching) return; 00636 if (isOverlapMode()){ 00637 QPtrList<KMultiTabBarTab>* tl=m_tb->tabs(); 00638 QPtrListIterator<KMultiTabBarTab> it(*tl); 00639 for(;it.current();++it) { 00640 if (it.current()->isOn()) { 00641 kdDebug(760)<<"Lowering TAB"<<endl; 00642 it.current()->setState(false); 00643 tabClicked(it.current()->id()); 00644 } 00645 } 00646 } 00647 } 00648 00649 void KMdiDockContainer::toggle() { 00650 kdDebug(760)<<"DockContainer:activate"<<endl; 00651 if (m_tb->isTabRaised(oldtab)) { 00652 m_tb->setTab(oldtab,false); 00653 tabClicked(oldtab); 00654 KMdiMainFrm *mainFrm = dynamic_cast<KMdiMainFrm*>(m_mainWin); 00655 if (mainFrm && mainFrm->activeWindow() ) 00656 mainFrm->activeWindow()->setFocus(); 00657 00658 } else { 00659 kdDebug(760)<<"KMdiDockContainer::toggle(): raising tab"<<endl; 00660 if (m_tb->tab(m_previousTab)==0) { 00661 if (m_tb->tabs()->count()==0) return; 00662 m_previousTab=m_tb->tabs()->getFirst()->id(); 00663 } 00664 m_tb->setTab(m_previousTab,true); 00665 tabClicked(m_previousTab); 00666 } 00667 } 00668 00669 void KMdiDockContainer::prevToolView() { 00670 QPtrList<KMultiTabBarTab>* tabs=m_tb->tabs(); 00671 int pos=tabs->findRef(m_tb->tab(oldtab)); 00672 if (pos==-1) return; 00673 pos--; 00674 if (pos<0) pos=tabs->count()-1; 00675 KMultiTabBarTab *tab=tabs->at(pos); 00676 if (!tab) return; //can never happen here, but who knows 00677 m_tb->setTab(tab->id(),true); 00678 tabClicked(tab->id()); 00679 } 00680 00681 void KMdiDockContainer::nextToolView() { 00682 QPtrList<KMultiTabBarTab>* tabs=m_tb->tabs(); 00683 int pos=tabs->findRef(m_tb->tab(oldtab)); 00684 if (pos==-1) return; 00685 pos++; 00686 if (pos>=(int)tabs->count()) pos=0; 00687 KMultiTabBarTab *tab=tabs->at(pos); 00688 if (!tab) return; //can never happen here, but who knows 00689 m_tb->setTab(tab->id(),true); 00690 tabClicked(tab->id()); 00691 } 00692 00693 // kate: space-indent on; indent-width 2; replace-tabs on;
KDE Logo
This file is part of the documentation for kmdi Library Version 3.3.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sun Oct 17 11:33:17 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003