author | zecke <zecke> | 2002-03-22 22:39:51 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-03-22 22:39:51 (UTC) |
commit | f0add730524cb63fd3bcce741da2e1fba83acb9f (patch) (side-by-side diff) | |
tree | 029b1bfb012cff89cf57ef1009a657bc7fee168c | |
parent | 796cb4b76f2e949b1baea3d4cf7a70b24186939d (diff) | |
download | opie-f0add730524cb63fd3bcce741da2e1fba83acb9f.zip opie-f0add730524cb63fd3bcce741da2e1fba83acb9f.tar.gz opie-f0add730524cb63fd3bcce741da2e1fba83acb9f.tar.bz2 |
make some people happy
-rw-r--r-- | core/launcher/launcher.cpp | 31 | ||||
-rw-r--r-- | core/launcher/launcher.h | 2 | ||||
-rw-r--r-- | core/launcher/mediummountgui.cpp | 4 |
3 files changed, 32 insertions, 5 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index b26bd8b..dcc3ba1 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp @@ -28,96 +28,100 @@ #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> #include <qpe/palmtoprecord.h> #include <qdatetime.h> #include <qdir.h> #include <qwindowsystem_qws.h> #include <qtimer.h> #include <qcombobox.h> #include <qvbox.h> #include <qlayout.h> #include <qstyle.h> #include <qpushbutton.h> #include <qtabbar.h> #include <qwidgetstack.h> #include <qlayout.h> #include <qregexp.h> #include <qmessagebox.h> #include <qframe.h> #include <qpainter.h> #include <qlabel.h> #include <qtextstream.h> #include "launcherview.h" #include "launcher.h" #include "syncdialog.h" #include "desktop.h" #include <qpe/lnkproperties.h> #include "mrulist.h" #include "qrsync.h" #include <stdlib.h> #include <unistd.h> #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) #include <stdio.h> #include <sys/vfs.h> #include <mntent.h> #endif #include <qpe/storage.h> #include "mediummountgui.h" //#define SHOW_ALL +// uidGen + +// uidGen + CategoryTabWidget::CategoryTabWidget( QWidget* parent ) : QVBox( parent ) { categoryBar = 0; stack = 0; } void CategoryTabWidget::prevTab() { if ( categoryBar ) { int n = categoryBar->count(); int tab = categoryBar->currentTab(); if ( tab >= 0 ) categoryBar->setCurrentTab( (tab - 1 + n)%n ); } } void CategoryTabWidget::nextTab() { if ( categoryBar ) { int n = categoryBar->count(); int tab = categoryBar->currentTab(); categoryBar->setCurrentTab( (tab + 1)%n ); } } void CategoryTabWidget::addItem( const QString& linkfile ) { int i=0; AppLnk *app = new AppLnk(linkfile); if ( !app->isValid() ) { delete app; return; } if ( !app->file().isEmpty() ) { // A document delete app; app = new DocLnk(linkfile); ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app); return; } for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) { if ( !(*it).isEmpty() ) { QRegExp tf(*it,FALSE,TRUE); if ( tf.match(app->type()) >= 0 ) { ((LauncherView*)stack->widget(i))->addItem(app); return; } @@ -377,206 +381,227 @@ void CategoryTabBar::paintLabel( QPainter* p, const QRect&, if ( t->iconSet() ) { // the tab has an iconset, draw it in the right mode QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; if ( mode == QIconSet::Normal && has_focus ) mode = QIconSet::Active; QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); int pixw = pixmap.width(); int pixh = pixmap.height(); p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); r.setLeft( r.left() + pixw + 5 ); } QRect tr = r; if ( r.width() < 20 ) return; if ( t->isEnabled() && isEnabled() ) { #if defined(_WS_WIN32_) if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) p->setPen( colorGroup().buttonText() ); else p->setPen( colorGroup().foreground() ); #else p->setPen( colorGroup().foreground() ); #endif p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); } else { p->setPen( palette().disabled().foreground() ); p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); } } //--------------------------------------------------------------------------- Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) : QMainWindow( parent, name, fl ) { setCaption( tr("Launcher") ); syncDialog = 0; // we have a pretty good idea how big we'll be setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); tabs = 0; rootFolder = 0; docsFolder = 0; - m_timeStamp = QDateTime::currentDateTime().toString(); + int stamp = uidgen.generate(); + uidgen.store( stamp ); + m_timeStamp = QString::number( stamp ); tabs = new CategoryTabWidget( this ); tabs->setMaximumWidth( qApp->desktop()->width() ); setCentralWidget( tabs ); 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(Q_WS_QWS) && !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 &)) ); #endif storage = new StorageInfo( this ); connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) ); updateTabs(); preloadApps(); in_lnk_props = FALSE; got_lnk_change = FALSE; } Launcher::~Launcher() { } static bool isVisibleWindow(int wid) { const QList<QWSWindow> &list = qwsServer->clientWindows(); QWSWindow* w; for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { if ( w->winId() == wid ) return !w->isFullyObscured(); } return FALSE; } void Launcher::showMaximized() { if ( isVisibleWindow( winId() ) ) doMaximize(); else QTimer::singleShot( 20, this, SLOT(doMaximize()) ); } void Launcher::doMaximize() { QMainWindow::showMaximized(); } void Launcher::updateMimeTypes() { MimeType::clear(); updateMimeTypes(rootFolder); } void Launcher::updateMimeTypes(AppLnkSet* folder) { for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { AppLnk *app = it.current(); if ( app->type() == "Folder" ) updateMimeTypes((AppLnkSet *)app); else { MimeType::registerApp(*app); } } } void Launcher::loadDocs() // ok here comes a hack belonging to Global:: { + qWarning("loading Documents" ); + qWarning("The currentTimeStamp is: %s", m_timeStamp.latin1() ); delete docsFolder; docsFolder = new DocLnkSet; + qWarning("new DocLnkSet" ); // 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 - QString newStamp = QDateTime::currentDateTime().toString(); + int stamp = uidgen.generate(); + + QString newStamp = QString::number( stamp ); + qWarning("new time stamp is: %s", newStamp.latin1() ); StorageInfo storage; const QList<FileSystem> &fileSystems = storage.fileSystems(); + qWarning("QList<FileSystem>" ); QListIterator<FileSystem> it ( fileSystems ); + qWarning("iterator initiliazed" ); for ( ; it.current(); ++it ) { + qWarning("inside for loop" ); + qWarning("checking device %s", (*it)->path().latin1() ); if ( (*it)->isRemovable() ) { // let's find out if we should search on it + qWarning("%s is removeable", (*it)->path().latin1() ); OConfig cfg( (*it)->path() + "/.opiestorage.cf"); cfg.setGroup("main"); QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); if( stamp == m_timeStamp ){ // ok we know this card + qWarning("time stamp match" ); cfg.writeEntry("timestamp", newStamp ); // we need to scan the list now. Hopefully the cache will be there }else{ // come up with the gui - MediumMountGui medium((*it)->path() + "/.opiestorage.cf" ); + qWarning("time stamp doesn't match" ); + MediumMountGui medium((*it)->path() ); + qWarning("medium mount gui created" ); if( medium.check() ){ + qWarning("need to check this device" ); if( medium.exec() ){ //ok // speicher + qWarning("execed" ); cfg.writeEntry("timestamp", newStamp ); } }else{ + qWarning("wrong :(" ); // do something different see what we need to do } } } } + qWarning("findDocuments" ); Global::findDocuments(docsFolder); // get rid of this call later + qWarning("done" ); m_timeStamp = newStamp; } 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()); } void Launcher::viewSelected(const QString& s) { setCaption( s + tr(" - Launcher") ); } void Launcher::nextView() { tabs->nextTab(); } void Launcher::select( const AppLnk *appLnk ) { if ( appLnk->type() == "Folder" ) { // Not supported: flat is simpler for the user } else { if ( appLnk->exec().isNull() ) { QMessageBox::information(this,tr("No application"), tr("<p>No application is defined for this document." "<p>Type is %1.").arg(appLnk->type())); return; } tabs->setBusy(TRUE); emit executing( appLnk ); appLnk->execute(); } } diff --git a/core/launcher/launcher.h b/core/launcher/launcher.h index 197bd19..d2efa58 100644 --- a/core/launcher/launcher.h +++ b/core/launcher/launcher.h @@ -1,75 +1,76 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of 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. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef LAUNCHER_H #define LAUNCHER_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 CategoryTabBar : public QTabBar { Q_OBJECT public: CategoryTabBar( QWidget *parent=0, const char *name=0 ); ~CategoryTabBar(); 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 updateLink(const QString& linkfile); void setBusy(bool on); signals: void selected(const QString&); void clicked(const AppLnk*); void rightPressed(AppLnk*); public slots: void nextTab(); void prevTab(); protected: void paletteChange( const QPalette &p ); private: @@ -87,52 +88,53 @@ class Launcher : public QMainWindow Q_OBJECT friend class LauncherPrivate; public: Launcher( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~Launcher(); static QString appsFolderName(); virtual void showMaximized(); static bool mkdir(const QString &path); public slots: void viewSelected(const QString&); void select( const AppLnk * ); void externalSelected( const AppLnk *); void properties( AppLnk * ); void nextView(); signals: void executing( const AppLnk * ); void busy(); void notBusy(const QString&); private slots: void doMaximize(); void systemMessage( const QCString &, const QByteArray &); void storageChanged(); void cancelSync(); private: void updateApps(); void loadDocs(); void updateDocs(); void updateTabs(); void updateMimeTypes(); void updateMimeTypes(AppLnkSet*); void preloadApps(); AppLnkSet *rootFolder; DocLnkSet *docsFolder; CategoryTabWidget *tabs; StorageInfo *storage; SyncDialog *syncDialog; void updateLink(const QString& link); bool in_lnk_props; bool got_lnk_change; QString lnk_change; QString m_timeStamp; + Qtopia::UidGen uidgen; }; #endif // LAUNCHERVIEW_H diff --git a/core/launcher/mediummountgui.cpp b/core/launcher/mediummountgui.cpp index f193024..6ad97e1 100644 --- a/core/launcher/mediummountgui.cpp +++ b/core/launcher/mediummountgui.cpp @@ -1,90 +1,90 @@ #include "mediummountgui.h" #include <qvariant.h> #include <qcheckbox.h> #include <qgroupbox.h> #include <qlabel.h> #include <qlineedit.h> #include <qpushbutton.h> #include <qlayout.h> #include <qtooltip.h> #include <qwhatsthis.h> #include <qimage.h> #include <qpixmap.h> #include <qpe/resource.h> #include <opie/oconfig.h> #include <qapplication.h> MediumMountGui::MediumMountGui( const QString &path ,QWidget* parent, const char* name, bool modal, WFlags fl ) - : QDialog( parent, name, modal, fl ) { + : QDialog( parent, name, true ) { QWidget *d = QApplication::desktop(); int w=d->width(); int h=d->height(); resize( w , h ); setCaption( tr( "Medium inserted" ) ); mediumPath = path; readConfig(); startGui(); } void MediumMountGui::readConfig(){ OConfig cfg (mediumPath +"/.opiestorage.cf"); cfg.setGroup("main"); - checkagain = cfg.readBoolEntry("check", false); + checkagain = cfg.readBoolEntry("check", true); cfg.setGroup("mimetypes"); checkmimeaudio = cfg.readBoolEntry("audio", true); checkmimeimage = cfg.readBoolEntry("image", true); checkmimetext = cfg.readBoolEntry("text", true); checkmimevideo = cfg.readBoolEntry("video", true); checkmimeall = cfg.readBoolEntry("all", true); cfg.setGroup("dirs"); limittodirs = cfg.readEntry("dirs", ""); } bool MediumMountGui::check() { return checkagain; } QStringList MediumMountGui::dirs() { QStringList list = QStringList::split(",", limittodirs ); return list; } void MediumMountGui::writeConfig(bool autocheck) { OConfig cfg (mediumPath +"/.opiestorage.cf"); cfg.setGroup("main"); cfg.writeEntry("check", AskBox->isChecked() ); cfg.writeEntry("autocheck", autocheck ); cfg.setGroup("mimetypes"); cfg.writeEntry("audio", CheckBoxAudio->isChecked() ); cfg.writeEntry("image",CheckBoxImage->isChecked() ); cfg.writeEntry("text",CheckBoxImage->isChecked() ); cfg.writeEntry("video",CheckBoxVideo->isChecked() ); cfg.writeEntry("all",CheckBoxAll->isChecked() ); cfg.setGroup("dirs"); cfg.writeEntry("dirs", ""); // if all is checked then add only "null" to the list. if (checkmimeall) { mimeTypeList += ("null"); } else { if (checkmimeaudio) { mimeTypeList += ("audio//*"); } if (checkmimetext) { |