00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include "startmenu.h"
00029 #include "taskbar.h"
00030 #include "serverinterface.h"
00031 #include "launcherview.h"
00032 #include "launcher.h"
00033 #include "server.h"
00034
00035 #include <opie2/odebug.h>
00036 #include <opie2/oresource.h>
00037 using namespace Opie::Core;
00038
00039 #include <qtopia/global.h>
00040 #ifdef Q_WS_QWS
00041 #include <qtopia/qcopenvelope_qws.h>
00042 #endif
00043 #include <qtopia/applnk.h>
00044 #include <qtopia/config.h>
00045 #include <qtopia/qpeapplication.h>
00046 #include <qtopia/mimetype.h>
00047 #include <qtopia/private/categories.h>
00048 #define QTOPIA_INTERNAL_FSLP
00049 #include <qtopia/lnkproperties.h>
00050
00051
00052 #include <qdir.h>
00053 #ifdef Q_WS_QWS
00054 #include <qkeyboard_qws.h>
00055 #include <qwindowsystem_qws.h>
00056 #endif
00057 #include <qtimer.h>
00058 #include <qcombobox.h>
00059 #include <qvbox.h>
00060 #include <qlayout.h>
00061 #include <qstyle.h>
00062 #include <qpushbutton.h>
00063 #include <qtabbar.h>
00064 #include <qwidgetstack.h>
00065 #include <qregexp.h>
00066 #include <qmessagebox.h>
00067 #include <qframe.h>
00068 #include <qpainter.h>
00069 #include <qlabel.h>
00070 #include <qtextstream.h>
00071 #include <qpopupmenu.h>
00072
00073
00074 #include <stdlib.h>
00075 #include <assert.h>
00076 #if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
00077 #include <unistd.h>
00078 #include <stdio.h>
00079 #include <sys/vfs.h>
00080 #include <mntent.h>
00081 #endif
00082
00083
00084 static bool isVisibleWindow( int );
00085
00086
00087 LauncherTabWidget::LauncherTabWidget( Launcher* parent ) :
00088 QVBox( parent ), docview( 0 ),docTabEnabled(true),m_DocumentTabId(0)
00089 {
00090 docLoadingWidgetEnabled = false;
00091 docLoadingWidget = 0;
00092 docLoadingWidgetProgress = 0;
00093 launcher = parent;
00094 categoryBar = new LauncherTabBar( this );
00095 QPalette pal = categoryBar->palette();
00096 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) );
00097 pal.setColor( QColorGroup::Background, pal.active().background().light(110) );
00098 categoryBar->setPalette( pal );
00099 stack = new QWidgetStack(this);
00100 connect( categoryBar, SIGNAL(selected(int)), this, SLOT(raiseTabWidget()) );
00101 categoryBar->show();
00102 stack->show();
00103
00104 #if defined(Q_WS_QWS) && !defined(QT_NO_COP)
00105 QCopChannel *channel = new QCopChannel( "QPE/Launcher", this );
00106 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
00107 this, SLOT(launcherMessage(const QCString&,const QByteArray&)) );
00108 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)),
00109 this, SLOT(appMessage(const QCString&,const QByteArray&)));
00110 #endif
00111
00112 createDocLoadingWidget();
00113 }
00114
00115 void LauncherTabWidget::createDocLoadingWidget()
00116 {
00117
00118
00119
00120
00121
00122 docLoadingWidget = new LauncherView( stack );
00123 docLoadingWidget->hideIcons();
00124 QVBox *docLoadingVBox = new QVBox( docLoadingWidget );
00125
00126 docLoadingVBox->setSpacing( 20 );
00127 docLoadingVBox->setMargin( 10 );
00128
00129 QWidget *space1 = new QWidget( docLoadingVBox );
00130 docLoadingVBox->setStretchFactor( space1, 1 );
00131
00132 QLabel *waitPixmap = new QLabel( "Please Wait...", docLoadingVBox );
00133 waitPixmap->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, waitPixmap->sizePolicy().hasHeightForWidth() ) );
00134 waitPixmap->setAlignment( int( QLabel::AlignCenter ) );
00135
00136 Config cfg( "Launcher" );
00137 cfg.setGroup( "DocTab" );
00138 docTabEnabled = cfg.readBoolEntry( "Enable", true );
00139
00140 QLabel *textLabel = new QLabel( docLoadingVBox );
00141 textLabel->setAlignment( int( QLabel::AlignCenter ) );
00142 docLoadingWidgetProgress = new QProgressBar( docLoadingVBox );
00143 docLoadingWidgetProgress->setProgress( 0 );
00144 docLoadingWidgetProgress->setCenterIndicator( TRUE );
00145 docLoadingWidgetProgress->setBackgroundMode( NoBackground );
00146 setProgressStyle();
00147
00148 if ( docTabEnabled )
00149 {
00150 textLabel->setText( tr( "<b>Finding Documents...</b>" ) );
00151 }
00152 else
00153 {
00154 textLabel->setText( tr( "<b>The Documents Tab<p>has been disabled.<p>"
00155 "Use Settings->Launcher->DocTab<p>to reenable it.</b></center>" ) );
00156 docLoadingWidgetProgress->hide();
00157 docLoadingWidgetEnabled = true;
00158 }
00159
00160 QWidget *space2 = new QWidget( docLoadingVBox );
00161 docLoadingVBox->setStretchFactor( space2, 1 );
00162
00163 cfg.setGroup( "Tab Documents" );
00164 setTabViewAppearance( docLoadingWidget, cfg );
00165
00166 stack->addWidget( docLoadingWidget, 0 );
00167 }
00168
00169 void LauncherTabWidget::initLayout()
00170 {
00171 layout()->activate();
00172 docView()->setFocus();
00173 categoryBar->showTab("Documents");
00174 }
00175
00176 void LauncherTabWidget::appMessage(const QCString& message, const QByteArray&)
00177 {
00178 if ( message == "nextView()" )
00179 categoryBar->nextTab();
00180 }
00181
00182 void LauncherTabWidget::raiseTabWidget()
00183 {
00184 if ( categoryBar->currentView() == docView()
00185 && docLoadingWidgetEnabled ) {
00186 stack->raiseWidget( docLoadingWidget );
00187 docLoadingWidget->updateGeometry();
00188 } else {
00189 stack->raiseWidget( categoryBar->currentView() );
00190 }
00191 }
00192
00193 void LauncherTabWidget::tabProperties()
00194 {
00195 LauncherView *view = categoryBar->currentView();
00196 QPopupMenu *m = new QPopupMenu( this );
00197 m->insertItem( tr("Icon View"), LauncherView::Icon );
00198 m->insertItem( tr("List View"), LauncherView::List );
00199 m->setItemChecked( (int)view->viewMode(), TRUE );
00200 int rv = m->exec( QCursor::pos() );
00201 if ( rv >= 0 && rv != view->viewMode() ) {
00202 view->setViewMode( (LauncherView::ViewMode)rv );
00203 }
00204
00205 delete m;
00206 }
00207
00208 void LauncherTabWidget::deleteView( const QString& id )
00209 {
00210 LauncherTab *t = categoryBar->launcherTab(id);
00211 if ( t ) {
00212 stack->removeWidget( t->view );
00213 delete t->view;
00214 categoryBar->removeTab( t );
00215 }
00216 }
00217
00218 LauncherView* LauncherTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label )
00219 {
00220 LauncherView* view = new LauncherView( stack );
00221 connect( view, SIGNAL(clicked(const AppLnk*)),
00222 this, SIGNAL(clicked(const AppLnk*)));
00223 connect( view, SIGNAL(rightPressed(AppLnk*)),
00224 this, SIGNAL(rightPressed(AppLnk*)));
00225
00226
00227 int n = categoryBar->count();
00228
00229 stack->addWidget( view, n );
00230
00231 LauncherTab *tab = new LauncherTab( id, view, pm, label );
00232 categoryBar->insertTab( tab, n-1 );
00233 if ( id == "Documents" ) {
00234 docview = view;
00235 m_DocumentTabId = n;
00236 }
00237
00238 odebug << "inserting " << id << " at " << n-1 << "" << oendl;
00239
00240 Config cfg("Launcher");
00241 setTabAppearance( tab, cfg );
00242
00243 cfg.setGroup( "GUI" );
00244 view->setBusyIndicatorType( cfg.readEntry( "BusyType", QString::null ) );
00245
00246 return view;
00247 }
00248
00249 LauncherView *LauncherTabWidget::view( const QString &id )
00250 {
00251 LauncherTab *t = categoryBar->launcherTab(id);
00252 if ( !t )
00253 return 0;
00254 return t->view;
00255 }
00256
00257 LauncherView *LauncherTabWidget::docView()
00258 {
00259 return docview;
00260 }
00261
00262 void LauncherTabWidget::setLoadingWidgetEnabled( bool v )
00263 {
00264 if ( v != docLoadingWidgetEnabled && docLoadingWidget ) {
00265 docLoadingWidgetEnabled = v;
00266 raiseTabWidget();
00267 }
00268 }
00269
00270 void LauncherTabWidget::setLoadingProgress( int percent )
00271 {
00272 docLoadingWidgetProgress->setProgress( (percent / 4) * 4 );
00273 }
00274
00275
00276 void LauncherTabWidget::setTabViewAppearance( LauncherView *v, Config &cfg )
00277 {
00278
00279 QString view = cfg.readEntry( "View", "Icon" );
00280 if ( view == "List" )
00281 v->setViewMode( LauncherView::List );
00282 QString bgType = cfg.readEntry( "BackgroundType", "Image" );
00283 if ( bgType == "Image" ) {
00284 QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" );
00285 v->setBackgroundType( LauncherView::Image, pm );
00286 } else if ( bgType == "SolidColor" ) {
00287 QString c = cfg.readEntry( "BackgroundColor" );
00288 v->setBackgroundType( LauncherView::SolidColor, c );
00289 } else {
00290 v->setBackgroundType( LauncherView::Ruled, QString::null );
00291 }
00292 QString textCol = cfg.readEntry( "TextColor" );
00293 if ( textCol.isEmpty() )
00294 v->setTextColor( QColor() );
00295 else
00296 v->setTextColor( QColor(textCol) );
00297
00298
00299 v->setColNumber( cfg.readNumEntry( "Columns", 0 ) );
00300
00301 QStringList font = cfg.readListEntry( "Font", ',' );
00302 if ( font.count() == 4 )
00303 v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) );
00304
00305
00306
00307 }
00308
00309
00310 void LauncherTabWidget::setTabAppearance( LauncherTab *tab, Config &cfg )
00311 {
00312 cfg.setGroup( QString( "Tab %1" ).arg(tab->type) );
00313
00314 setTabViewAppearance( tab->view, cfg );
00315
00316
00317 QString tabCol = cfg.readEntry( "TabColor" );
00318 if ( tabCol.isEmpty() )
00319 tab->bgColor = QColor();
00320 else
00321 tab->bgColor = QColor(tabCol);
00322 QString tabTextCol = cfg.readEntry( "TabTextColor" );
00323 if ( tabTextCol.isEmpty() )
00324 tab->fgColor = QColor();
00325 else
00326 tab->fgColor = QColor(tabTextCol);
00327 }
00328
00329 void LauncherTabWidget::paletteChange( const QPalette &p )
00330 {
00331 QVBox::paletteChange( p );
00332 QPalette pal = palette();
00333 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) );
00334 pal.setColor( QColorGroup::Background, pal.active().background().light(110) );
00335 categoryBar->setPalette( pal );
00336 categoryBar->update();
00337 }
00338
00339 void LauncherTabWidget::styleChange( QStyle & )
00340 {
00341 QTimer::singleShot( 0, this, SLOT(setProgressStyle()) );
00342 }
00343
00344 void LauncherTabWidget::setProgressStyle()
00345 {
00346 if (docLoadingWidgetProgress) {
00347 docLoadingWidgetProgress->setFrameShape( QProgressBar::Box );
00348 docLoadingWidgetProgress->setFrameShadow( QProgressBar::Plain );
00349 docLoadingWidgetProgress->setMargin( 1 );
00350 docLoadingWidgetProgress->setLineWidth( 1 );
00351 }
00352 }
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365 void LauncherTabWidget::setBusy(bool on)
00366 {
00367 if ( on )
00368 currentView()->setBusy(TRUE);
00369 else {
00370 for ( int i = 0; i < categoryBar->count(); i++ ) {
00371 if (categoryBar->tab(i)) {
00372 LauncherView *view = ((LauncherTab *)categoryBar->tab(i))->view;
00373 view->setBusy( FALSE );
00374 } else {
00375 odebug << "Averting Disaster with tab " << i << " == NULL! " << oendl;
00376 }
00377 }
00378 }
00379 }
00380
00381 void LauncherTabWidget::setBusyIndicatorType( const QString& str ) {
00382 for (int i = 0; i < categoryBar->count(); i++ ) {
00383 LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view;
00384 view->setBusyIndicatorType( str );
00385 }
00386 }
00387
00388 LauncherView *LauncherTabWidget::currentView(void)
00389 {
00390 return (LauncherView*)stack->visibleWidget();
00391 }
00392
00393
00394
00395 void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &data)
00396 {
00397 QDataStream stream( data, IO_ReadOnly );
00398 if ( msg == "setTabView(QString,int)" ) {
00399 QString id;
00400 stream >> id;
00401 int mode;
00402 stream >> mode;
00403 if ( view(id) )
00404 view(id)->setViewMode( (LauncherView::ViewMode)mode );
00405 } else if ( msg == "setTabBackground(QString,int,QString)" ) {
00406 QString id;
00407 stream >> id;
00408 int mode;
00409 stream >> mode;
00410 QString pixmapOrColor;
00411 stream >> pixmapOrColor;
00412 if ( view(id) )
00413 view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor );
00414 if ( id == "Documents" )
00415 docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor );
00416 } else if ( msg == "setTextColor(QString,QString)" ) {
00417 QString id;
00418 stream >> id;
00419 QString color;
00420 stream >> color;
00421 if ( view(id) )
00422 view(id)->setTextColor( QColor(color) );
00423 if ( id == "Documents" )
00424 docLoadingWidget->setTextColor( QColor(color) );
00425 } else if ( msg == "setIconColumns(QString,int)" ) {
00426 QString id;
00427 stream >> id;
00428 int number;
00429 stream >> number;
00430 if ( view(id ) )
00431 view(id)->setColNumber( number );
00432 } else if ( msg == "setFont(QString,QString,int,int,int)" ) {
00433 QString id;
00434 stream >> id;
00435 QString fam;
00436 stream >> fam;
00437 int size;
00438 stream >> size;
00439 int weight;
00440 stream >> weight;
00441 int italic;
00442 stream >> italic;
00443 if ( view(id) ) {
00444 if ( !fam.isEmpty() ) {
00445 view(id)->setViewFont( QFont(fam, size, weight, italic!=0) );
00446 odebug << "setFont: " << fam << ", " << size << ", " << weight << ", " << italic << "" << oendl;
00447 } else {
00448 view(id)->clearViewFont();
00449 }
00450 }
00451 }else if ( msg == "setBusyIndicatorType(QString)" ) {
00452 QString type;
00453 stream >> type;
00454 setBusyIndicatorType( type );
00455 }else if ( msg == "home()" ) {
00456 if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) {
00457 if (categoryBar)
00458 categoryBar->nextTab();
00459 }else {
00460 static_cast<QWidget*>(parent())->raise();
00461 }
00462 } else if (msg=="doctabEnabled(int)") {
00463 int id; stream >> id;
00464 odebug << "Doctab enabled " << id << oendl;
00465 reCheckDoctab(id);
00466 } else if ( msg == "setStaticBackground(bool)" ) {
00467 int set; stream >> set;
00468 odebug << "setStaticBackground " << set << oendl;
00469 for (int i = 0; i < categoryBar->count(); i++ )
00470 {
00471 LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view;
00472 view->iconView()->setStaticBackgroundPicture( set );
00473 }
00474 }
00475 }
00476
00477 void LauncherTabWidget::reCheckDoctab(int how)
00478 {
00479 if ((bool)how == docTabEnabled) {
00480
00481 return;
00482 }
00483 if (docLoadingWidget) {
00484 stack->removeWidget(docLoadingWidget);
00485 delete docLoadingWidget;
00486 docLoadingWidget = 0;
00487 }
00488 createDocLoadingWidget();
00489 {
00490 QCopEnvelope( "QPE/System", "reforceDocuments()" );
00491 odebug << "Sending doc rescan" << oendl;
00492 }
00493 }
00494
00495
00496
00497 Launcher::Launcher()
00498 : QMainWindow( 0, "PDA User Interface", QWidget::WStyle_Customize | QWidget::WGroupLeader )
00499 {
00500 tabs = 0;
00501 tb = 0;
00502 Config cfg( "Launcher" );
00503 cfg.setGroup( "DocTab" );
00504 docTabEnabled = cfg.readBoolEntry( "Enable", true );
00505 }
00506
00507 void Launcher::createGUI()
00508 {
00509 setCaption( tr("Launcher") );
00510
00511
00512 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() );
00513
00514 tb = new TaskBar;
00515 tabs = new LauncherTabWidget( this );
00516 setCentralWidget( tabs );
00517
00518 ServerInterface::dockWidget( tb, ServerInterface::Bottom );
00519 tb->show();
00520
00521 qApp->installEventFilter( this );
00522
00523 connect( tb, SIGNAL(tabSelected(const QString&)),
00524 this, SLOT(showTab(const QString&)) );
00525 connect( tabs, SIGNAL(selected(const QString&)),
00526 this, SLOT(viewSelected(const QString&)) );
00527 connect( tabs, SIGNAL(clicked(const AppLnk*)),
00528 this, SLOT(select(const AppLnk*)));
00529 connect( tabs, SIGNAL(rightPressed(AppLnk*)),
00530 this, SLOT(properties(AppLnk*)));
00531
00532 #if defined(Q_WS_QWS) && !defined(QT_NO_COP)
00533 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this );
00534 connect( sysChannel, SIGNAL(received(const QCString&,const QByteArray&)),
00535 this, SLOT(systemMessage(const QCString&,const QByteArray&)) );
00536 #endif
00537
00538
00539 QPixmap pm = OResource::loadPixmap( "DocsIcon", OResource::SmallIcon );
00540
00541 tabs->newView("Documents", pm, tr("Documents") )->setToolsEnabled( TRUE );
00542
00543 QTimer::singleShot( 0, tabs, SLOT( initLayout() ) );
00544 qApp->setMainWidget( this );
00545 QTimer::singleShot( 500, this, SLOT( makeVisible() ) );
00546 }
00547
00548 Launcher::~Launcher()
00549 {
00550 if ( tb )
00551 destroyGUI();
00552 }
00553
00554 bool Launcher::requiresDocuments() const
00555 {
00556 Config cfg( "Launcher" );
00557 cfg.setGroup( "DocTab" );
00558 return cfg.readBoolEntry( "Enable", true );
00559 }
00560
00561 void Launcher::makeVisible()
00562 {
00563 showMaximized();
00564 }
00565
00566 void Launcher::destroyGUI()
00567 {
00568 delete tb;
00569 tb = 0;
00570 delete tabs;
00571 tabs =0;
00572 }
00573
00574 bool Launcher::eventFilter( QObject*, QEvent *ev )
00575 {
00576 #ifdef QT_QWS_CUSTOM
00577 if ( ev->type() == QEvent::KeyPress ) {
00578 QKeyEvent *ke = (QKeyEvent *)ev;
00579 if ( ke->key() == Qt::Key_F11 ) {
00580 QWidget *active = qApp->activeWindow();
00581 if ( active && active->isPopup() )
00582 active->close();
00583 else {
00584 Global::terminateBuiltin("calibrate");
00585 tb->launchStartMenu();
00586 }
00587 return TRUE;
00588 }
00589 }
00590 #else
00591 Q_UNUSED(ev);
00592 #endif
00593 return FALSE;
00594 }
00595
00596 static bool isVisibleWindow(int wid)
00597 {
00598 #ifdef Q_WS_QWS
00599 const QList<QWSWindow> &list = qwsServer->clientWindows();
00600 QWSWindow* w;
00601 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
00602 if ( w->winId() == wid )
00603 return !w->isFullyObscured();
00604 }
00605 #endif
00606 return FALSE;
00607 }
00608
00609 void Launcher::viewSelected(const QString& s)
00610 {
00611 setCaption( s + tr(" - Launcher") );
00612 }
00613
00614 void Launcher::showTab(const QString& id)
00615 {
00616 tabs->categoryBar->showTab(id);
00617 raise();
00618 }
00619
00620 void Launcher::select( const AppLnk *appLnk )
00621 {
00622 if ( appLnk->type() == "Folder" ) {
00623
00624 } else {
00625 if ( appLnk->exec().isNull() ) {
00626 int i = QMessageBox::information(this,tr("No application"),
00627 tr("<p>No application is defined for this document."
00628 "<p>Type is %1.").arg(appLnk->type()), tr("OK"), tr("View as text"), 0, 0, 1);
00629
00630
00631 if ( i == 1 )
00632 Global::execute("textedit",appLnk->file());
00633
00634 return;
00635 }
00636 tabs->setBusy(TRUE);
00637 emit executing( appLnk );
00638 appLnk->execute();
00639 }
00640 }
00641
00642 void Launcher::properties( AppLnk *appLnk )
00643 {
00644 if ( appLnk->type() == "Folder" ) {
00645
00646 } else {
00647
00648 LnkProperties prop(appLnk,0 );
00649
00650 if (QPEApplication::execDialog( &prop )==QDialog::Accepted && tabs->currentView()==tabs->docView()) {
00651 }
00652 }
00653 }
00654
00655 void Launcher::storageChanged( const QList<FileSystem> & )
00656 {
00657
00658 }
00659
00660 void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
00661 {
00662 QDataStream stream( data, IO_ReadOnly );
00663 if ( msg == "busy()" ) {
00664 tb->startWait();
00665 } else if ( msg == "notBusy(QString)" ) {
00666 QString app;
00667 stream >> app;
00668 tabs->setBusy(FALSE);
00669 tb->stopWait(app);
00670 } else if (msg == "applyStyle()") {
00671 tabs->currentView()->relayout();
00672 }
00673 }
00674
00675
00676 void Launcher::typeAdded( const QString& type, const QString& name,
00677 const QPixmap& pixmap, const QPixmap& )
00678 {
00679 tabs->newView( type, pixmap, name );
00680 ids.append( type );
00681
00682
00683
00684 static bool first = TRUE;
00685 if ( first ) {
00686 first = FALSE;
00687 tabs->categoryBar->showTab(type);
00688 }
00689
00690 tabs->view( type )->setUpdatesEnabled( FALSE );
00691 tabs->view( type )->setSortEnabled( FALSE );
00692 }
00693
00694 void Launcher::typeRemoved( const QString& type )
00695 {
00696 tabs->view( type )->removeAllItems();
00697 tabs->deleteView( type );
00698 ids.remove( type );
00699
00700
00701 }
00702
00703 void Launcher::applicationAdded( const QString& type, const AppLnk& app )
00704 {
00705 if ( app.type() == "Separator" )
00706 return;
00707
00708 LauncherView *view = tabs->view( type );
00709 if ( view )
00710 view->addItem( new AppLnk( app ), FALSE );
00711 else
00712 owarn << "addAppLnk: No view for type " << type.latin1() << ". Can't add app "
00713 << app.name().latin1() << "!",
00714
00715 MimeType::registerApp( app );
00716 }
00717
00718 void Launcher::applicationRemoved( const QString& type, const AppLnk& app )
00719 {
00720 LauncherView *view = tabs->view( type );
00721 if ( view )
00722 view->removeLink( app.linkFile() );
00723 else
00724 owarn << "removeAppLnk: No view for " << type << "!" << oendl;
00725 }
00726
00727 void Launcher::allApplicationsRemoved()
00728 {
00729 MimeType::clear();
00730 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it)
00731 tabs->view( (*it) )->removeAllItems();
00732 }
00733
00734 void Launcher::documentAdded( const DocLnk& doc )
00735 {
00736 tabs->docView()->addItem( new DocLnk( doc ), FALSE );
00737 }
00738
00739 void Launcher::aboutToAddBegin()
00740 {
00741 tabs->docView()->setUpdatesEnabled( false );
00742 }
00743
00744 void Launcher::aboutToAddEnd()
00745 {
00746 tabs->docView()->setUpdatesEnabled( true );
00747 }
00748
00749 void Launcher::showLoadingDocs()
00750 {
00751 tabs->docView()->hide();
00752 }
00753
00754 void Launcher::showDocTab()
00755 {
00756 if ( tabs->categoryBar->currentView() == tabs->docView() )
00757 tabs->docView()->show();
00758 }
00759
00760 void Launcher::documentRemoved( const DocLnk& doc )
00761 {
00762 tabs->docView()->removeLink( doc.linkFile() );
00763 }
00764
00765 void Launcher::documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc )
00766 {
00767 #if 0
00768 documentRemoved( oldDoc );
00769 documentAdded( newDoc );
00770
00771 #else
00772 tabs->docView()->changeItem(oldDoc,new DocLnk(newDoc));
00773 #endif
00774 }
00775
00776 void Launcher::allDocumentsRemoved()
00777 {
00778 tabs->docView()->removeAllItems();
00779 }
00780
00781 void Launcher::applicationStateChanged( const QString& name, ApplicationState state )
00782 {
00783 tb->setApplicationState( name, state );
00784 }
00785
00786 void Launcher::applicationScanningProgress( int percent )
00787 {
00788 switch ( percent ) {
00789 case 0: {
00790 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) {
00791 tabs->view( (*it) )->setUpdatesEnabled( FALSE );
00792 tabs->view( (*it) )->setSortEnabled( FALSE );
00793 }
00794 break;
00795 }
00796 case 100: {
00797 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) {
00798 tabs->view( (*it) )->setUpdatesEnabled( TRUE );
00799 tabs->view( (*it) )->setSortEnabled( TRUE );
00800 }
00801 tb->refreshStartMenu();
00802 break;
00803 }
00804 default:
00805 break;
00806 }
00807 }
00808
00809 void Launcher::documentScanningProgress( int percent )
00810 {
00811 switch ( percent ) {
00812 case 0: {
00813 tabs->setLoadingProgress( 0 );
00814 tabs->setLoadingWidgetEnabled( TRUE );
00815 tabs->docView()->setUpdatesEnabled( FALSE );
00816 tabs->docView()->setSortEnabled( FALSE );
00817 break;
00818 }
00819 case 100: {
00820 tabs->docView()->updateTools();
00821 tabs->docView()->setSortEnabled( TRUE );
00822 tabs->docView()->setUpdatesEnabled( TRUE );
00823 tabs->setLoadingWidgetEnabled( FALSE );
00824 break;
00825 }
00826 default:
00827 tabs->setLoadingProgress( percent );
00828 break;
00829 }
00830 }
00831