author | llornkcor <llornkcor> | 2003-07-05 15:30:22 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-07-05 15:30:22 (UTC) |
commit | 2f6b0ede633948b44a5ed3ee1ec641395620f076 (patch) (side-by-side diff) | |
tree | 1c3d86b2932fe0ae18ce50f72c680949b1b22ee8 | |
parent | 51cb7e4cd9a7ec7f1bf864884928c61b9f2db3b0 (diff) | |
download | opie-2f6b0ede633948b44a5ed3ee1ec641395620f076.zip opie-2f6b0ede633948b44a5ed3ee1ec641395620f076.tar.gz opie-2f6b0ede633948b44a5ed3ee1ec641395620f076.tar.bz2 |
initial new doc tab using ofileselector
-rw-r--r-- | core/launcher/launcher.cpp | 102 | ||||
-rw-r--r-- | core/launcher/launcher.h | 29 |
2 files changed, 93 insertions, 38 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index bcc2495..d9fc8e4 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp @@ -17,16 +17,18 @@ ** not clear to you. ** **********************************************************************/ // WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT // have this class. #define QTOPIA_INTERNAL_FSLP +//#include <opie/ofiledialog.h> +#include <opie/ofileselector.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/resource.h> #include <qpe/applnk.h> #include <qpe/config.h> #include <qpe/global.h> #include <qpe/qpeapplication.h> #include <qpe/mimetype.h> #include <qpe/storage.h> @@ -192,17 +194,17 @@ void CategoryTabWidget::addItem( const QString& linkfile ) i++; } } QCopEnvelope e("QPE/TaskBar","reloadApps()"); } void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, - AppLnkSet* docFolder, const QList<FileSystem> &fs) + AppLnkSet* /*docFolder*/, const QList<FileSystem> & /*fs*/) { QString current; if ( categoryBar ) { int c = categoryBar->currentTab(); if ( c >= 0 ) current = ids[c]; } delete categoryBar; @@ -246,41 +248,62 @@ void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, rootFolder->detachChildren(); for (int i=0; i<tabs; i++) ((LauncherView*)stack->widget(i))->sort(); // all documents QImage img( Resource::loadImage( "DocsIcon" ) ); QPixmap pm; pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); - docview = newView( "Documents", // No tr - pm, tr("Documents")); - docview->populate( docFolder, QString::null ); - docFolder->detachChildren(); - docview->setFileSystems(fs); - docview->setToolsEnabled(TRUE); - setTabAppearance( "Documents", cfg ); // No tr + + //ljpotter + CategoryTab *catTab ; + catTab = new CategoryTab( pm, "Documents" ); + + categoryBar->addTab( catTab ); + + fileSel = new DocumentTab( stack, 4, 0, "/",""); + stack->addWidget( fileSel, tabs++ ); + + // fileSel->hide(); + + connect( fileSel, SIGNAL( fileSelected( const DocLnk & )), + this, SLOT(clickie(const DocLnk&)) ); + +// connect( fileSel, SIGNAL( fileSelected( const QString & )), +// this, SLOT(clickie(const QString&)) ); connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) ); ((LauncherView*)stack->widget(0))->setFocus(); cfg. setGroup ( "GUI" ); setBusyIndicatorType ( cfg. readEntry ( "BusyType", QString::null )); if ( !current.isNull() ) { showTab(current); } categoryBar->show(); stack->show(); + QCopEnvelope e("QPE/TaskBar","reloadApps()"); } +void CategoryTabWidget::clickie(const DocLnk &lnk) { + lnk.execute(); + // fileSel->reparse(); +} + +void CategoryTabWidget::clickie(const QString &appStr) { +// DocLnk lnk(appStr); +// lnk.execute(); +} + void CategoryTabWidget::setTabAppearance( const QString &id, Config &cfg ) { QString grp( "Tab %1" ); // No tr cfg.setGroup( grp.arg(id) ); LauncherView *v = view( id ); int idx = ids.findIndex( id ); CategoryTab *tab = (CategoryTab *)categoryBar->tab( idx ); @@ -313,23 +336,20 @@ void CategoryTabWidget::setTabAppearance( const QString &id, Config &cfg ) tab->bgColor = QColor(tabCol); QString tabTextCol = cfg.readEntry( "TabTextColor" ); if ( tabTextCol.isEmpty() ) tab->fgColor = QColor(); else tab->fgColor = QColor(tabTextCol); } -void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs) -{ - docview->populate( docFolder, QString::null ); - docFolder->detachChildren(); - docview->setFileSystems(fs); - docview->updateTools(); -} +//void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> & /*fs*/) +//{ + // docFolder->detachChildren(); +//} void CategoryTabWidget::tabProperties() { LauncherView *view = (LauncherView*)stack->widget( categoryBar->currentTab() ); QPopupMenu *m = new QPopupMenu( this ); m->insertItem( tr("Icon View"), LauncherView::Icon ); m->insertItem( tr("List View"), LauncherView::List ); m->setItemChecked( (int)view->viewMode(), TRUE ); @@ -338,17 +358,17 @@ void CategoryTabWidget::tabProperties() view->setViewMode( (LauncherView::ViewMode)rv ); } delete m; } QString CategoryTabWidget::getAllDocLinkInfo() const { - return docview->getAllDocLinkInfo(); + return ""; } LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) { LauncherView* view = new LauncherView( stack ); connect( view, SIGNAL(clicked(const AppLnk*)), this, SIGNAL(clicked(const AppLnk*))); connect( view, SIGNAL(rightPressed(AppLnk*)), @@ -356,25 +376,24 @@ LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, ids.append(id); categoryBar->addTab( new CategoryTab( pm, label ) ); stack->addWidget( view, tabs++ ); return view; } void CategoryTabWidget::updateLink(const QString& linkfile) { - int i=0; - LauncherView* view; + // LauncherView* view; qApp->processEvents(); - while ((view = (LauncherView*)stack->widget(i++))) { - if ( view->removeLink(linkfile) ) - break; - } - addItem(linkfile); - docview->updateTools(); +// while ((view = (LauncherView*)stack->widget(i++))) { +// if ( view->removeLink(linkfile) ) +// break; +// } + // addItem(linkfile); + fileSel->reparse(); } void CategoryTabWidget::paletteChange( const QPalette &p ) { QVBox::paletteChange( p ); QPalette pal = palette(); pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); @@ -382,17 +401,17 @@ void CategoryTabWidget::paletteChange( const QPalette &p ) categoryBar->update(); } void CategoryTabWidget::setBusy(bool on) { if ( on ) ((LauncherView*)stack->visibleWidget())->setBusy(TRUE); else - for (int i=0; i<tabs; i++) + for (int i=0; i<tabs-1; i++) ((LauncherView*)stack->widget(i))->setBusy(FALSE); } LauncherView *CategoryTabWidget::view( const QString &id ) { int idx = ids.findIndex( id ); return (LauncherView *)stack->widget(idx); } @@ -643,16 +662,17 @@ Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) connect( tabs, SIGNAL(selected(const QString&)), this, SLOT(viewSelected(const QString&)) ); connect( tabs, SIGNAL(clicked(const AppLnk*)), this, SLOT(select(const AppLnk*))); connect( tabs, SIGNAL(rightPressed(AppLnk*)), this, SLOT(properties(AppLnk*))); + #if !defined(QT_NO_COP) QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); QCopChannel *channel = new QCopChannel( "QPE/Launcher", this ); connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(launcherMessage(const QCString&, const QByteArray&)) ); #endif @@ -727,26 +747,23 @@ void Launcher::updateMimeTypes(AppLnkSet* folder) * all removable medium * b) the user enabled medium checking globally and we need to use this mimefilter * c) the user enabled medium checking on a per medium bases * c1) we already checked and its not ask again turns * c2) we need to ask and then apply the mimefilter */ void Launcher::loadDocs() // ok here comes a hack belonging to Global:: { - OWait *owait = new OWait(); Global::statusMessage( tr( "Finding documents" ) ); owait->show(); qApp->processEvents(); - - delete docsFolder; + if(docsFolder) delete docsFolder; docsFolder = new DocLnkSet; - DocLnkSet *tmp = 0; QString home = QString(getenv("HOME")) + "/Documents"; tmp = new DocLnkSet( home , QString::null); docsFolder->appendFrom( *tmp ); delete tmp; // RAM documents StorageInfo storage; @@ -759,19 +776,21 @@ void Launcher::loadDocs() // ok here comes a hack belonging to Global:: docsFolder->appendFrom( *tmp ); delete tmp; } } Config mediumCfg( "medium"); mediumCfg.setGroup("main"); // a) -zecke we don't want to check - if(!mediumCfg.readBoolEntry("use", true ) ) + if(!mediumCfg.readBoolEntry("use", true ) ) { + owait->hide(); + delete owait; return; - + } // find out wich filesystems are new in this round // We will do this by having a timestamp inside each mountpoint // if the current timestamp doesn't match this is a new file system and // come up with our MediumMountGui :) let the hacking begin int stamp = uidgen.generate(); QString newStamp = QString::number( stamp ); // generates newtime Stamp @@ -780,16 +799,18 @@ void Launcher::loadDocs() // ok here comes a hack belonging to Global:: QString mime = configToMime(&mediumCfg).join(";"); for( it.toFirst(); it.current(); ++it ){ if( (*it)->isRemovable() ){ tmp = new DocLnkSet( (*it)->path(), mime ); docsFolder->appendFrom( *tmp ); delete tmp; } } // done + owait->hide(); + delete owait; return; // save the else } // c) zecke for ( it.toFirst(); it.current(); ++it ) { if ( (*it)->isRemovable() ) { // let's find out if we should search on it Config cfg( (*it)->path() + "/.opiestorage.cf", Config::File); cfg.setGroup("main"); QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); @@ -843,29 +864,28 @@ void Launcher::loadDocs() // ok here comes a hack belonging to Global:: m_timeStamp = newStamp; owait->hide(); delete owait; } void Launcher::updateTabs() { MimeType::updateApplications(); // ### reads all applnks twice - delete rootFolder; rootFolder = new AppLnkSet( MimeType::appsFolderName() ); loadDocs(); tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); } void Launcher::updateDocs() { loadDocs(); - tabs->updateDocs(docsFolder,storage->fileSystems()); + // tabs->updateDocs(docsFolder,storage->fileSystems()); } void Launcher::viewSelected(const QString& s) { setCaption( s + tr(" - Launcher") ); } void Launcher::nextView() @@ -1312,8 +1332,24 @@ void Launcher::preloadApps() cfg.setGroup("Preload"); QStringList apps = cfg.readListEntry("Apps",','); for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { #ifndef QT_NO_COP QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); #endif } } + +DocumentTab::DocumentTab( QWidget *parent, int mode, int selector, const QString &dirName, const QString &fileName) + : OFileSelector(parent,mode,selector,dirName,fileName) +{ + setYesCancelVisible(false); + setToolbarVisible(true); + setPermissionBarVisible(false); + setLineEditVisible(false) ; + //setChooserVisible( bool chooser ); + +} + +DocumentTab::~DocumentTab() { + +} + diff --git a/core/launcher/launcher.h b/core/launcher/launcher.h index c92ef5d..0616734 100644 --- a/core/launcher/launcher.h +++ b/core/launcher/launcher.h @@ -1,13 +1,12 @@ /********************************************************************** ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** -** This file is part of the Qtopia Environment. -** +** This file is part of the Qtopia Environment.** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** @@ -16,69 +15,89 @@ ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef LAUNCHER_H #define LAUNCHER_H #include <qpe/config.h> +#include <qpe/applnk.h> + +#include <opie/ofileselector.h> + #include <qmainwindow.h> #include <qtabbar.h> #include <qstringlist.h> #include <qvbox.h> #include <qlist.h> #include <qpe/palmtopuidgen.h> #include "launcherview.h" class AppLnk; class AppLnkSet; class DocLnkSet; class QWidgetStack; class StorageInfo; class SyncDialog; + +class DocumentTab : public OFileSelector +{ + Q_OBJECT +public: + DocumentTab( QWidget *parent, int mode, int selector, const QString &dirName, const QString &fileName);//, 4,0, "/",""); +~DocumentTab(); +private: + +}; + class CategoryTabBar : public QTabBar { Q_OBJECT public: CategoryTabBar( QWidget *parent=0, const char *name=0 ); ~CategoryTabBar(); +signals: + protected slots: virtual void layoutTabs(); protected: void paint ( QPainter *p, QTab *t, bool f ) const; void paintLabel( QPainter* p, const QRect& br, QTab* t, bool has_focus ) const; + }; class CategoryTabWidget : public QVBox { // can't use a QTabWidget, since it won't let us set the frame style. Q_OBJECT public: CategoryTabWidget( QWidget* parent ); void initializeCategories(AppLnkSet* rootFolder, AppLnkSet* docFolder, const QList<FileSystem> &); - void updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs); +// void updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs); void updateLink(const QString& linkfile); void setBusy(bool on); QString getAllDocLinkInfo() const; LauncherView *view( const QString &id ); void setBusyIndicatorType ( const QString &type ); + DocumentTab *fileSel; signals: void selected(const QString&); void clicked(const AppLnk*); void rightPressed(AppLnk*); - + void ofileSel(const DocLnk &); public slots: void nextTab(); void prevTab(); void showTab(const QString&); - + void clickie(const DocLnk&); + void clickie(const QString &); protected slots: void tabProperties(); protected: void setTabAppearance( const QString &id, Config &cfg ); void paletteChange( const QPalette &p ); private: |