summaryrefslogtreecommitdiff
path: root/core/launcher/launcher.cpp
Side-by-side diff
Diffstat (limited to 'core/launcher/launcher.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcher.cpp35
1 files changed, 29 insertions, 6 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp
index e74301c..3eb561a 100644
--- a/core/launcher/launcher.cpp
+++ b/core/launcher/launcher.cpp
@@ -34,48 +34,51 @@
#include <qpe/version.h>
#include <qdir.h>
#ifdef QWS
#include <qwindowsystem_qws.h>
#endif
#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 <qpopupmenu.h>
+#include <opie/owait.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"
namespace {
QStringList configToMime( Config *cfg ){
QStringList mimes;
bool tmpMime = true;
cfg->setGroup("mimetypes" );
@@ -339,48 +342,49 @@ void CategoryTabWidget::tabProperties()
}
QString CategoryTabWidget::getAllDocLinkInfo() const
{
return docview->getAllDocLinkInfo();
}
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*)),
this, SIGNAL(rightPressed(AppLnk*)));
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;
+ qApp->processEvents();
while ((view = (LauncherView*)stack->widget(i++))) {
if ( view->removeLink(linkfile) )
break;
}
addItem(linkfile);
docview->updateTools();
}
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) );
categoryBar->setPalette( pal );
categoryBar->update();
}
void CategoryTabWidget::setBusy(bool on)
{
if ( on )
((LauncherView*)stack->visibleWidget())->setBusy(TRUE);
else
for (int i=0; i<tabs; i++)
@@ -707,48 +711,55 @@ void Launcher::updateMimeTypes(AppLnkSet* folder)
{
for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) {
AppLnk *app = it.current();
if ( app->type() == "Folder" ) // No tr
updateMimeTypes((AppLnkSet *)app);
else {
MimeType::registerApp(*app);
}
}
}
/** This is a HACK....
* Reason: scanning huge mediums, microdirvers for examples
* consomes time. To avoid that we invented the MediumMountCheck
*
* a) the user globally disabled medium checking. We can ignore
* 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;
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;
const QList<FileSystem> &fileSystems = storage.fileSystems();
QListIterator<FileSystem> it ( fileSystems );
for ( ; it.current(); ++it ) {
if ( (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) {
tmp = new DocLnkSet( (*it)->path(), QString::null );
docsFolder->appendFrom( *tmp );
delete tmp;
}
}
Config mediumCfg( "medium");
mediumCfg.setGroup("main");
@@ -767,83 +778,92 @@ void Launcher::loadDocs() // ok here comes a hack belonging to Global::
// b)
if( mediumCfg.readBoolEntry("global", true ) ){
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
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() );
/** This medium is uptodate
*/
if( stamp == m_timeStamp ){ // ok we know this card
cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp
// we need to scan the list now. Hopefully the cache will be there
// read the mimetypes from the config and search for documents
- QStringList mimetypes = configToMime( &cfg);
- tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") );
+ QStringList mimetypes = configToMime( &cfg);
+ qApp->processEvents();
+ Global::statusMessage( tr( "Searching documents" ) );
+ tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") );
docsFolder->appendFrom( *tmp );
delete tmp;
}else{ // come up with the gui cause this a new card
MediumMountGui medium(&cfg, (*it)->path() );
if( medium.check() ){ // we did not ask before or ask again is off
/** c2) */
if( medium.exec() ){ // he clicked yes so search it
// speicher
//cfg.read(); // cause of a race we need to reread - fixed
cfg.setGroup("main");
cfg.writeEntry("timestamp", newStamp );
cfg.write();
- tmp = new DocLnkSet( (*it)->path(), medium.mimeTypes().join(";" ) );
- docsFolder->appendFrom( *tmp );
+
+ qApp->processEvents();
+ tmp = new DocLnkSet( (*it)->path(), medium.mimeTypes().join(";" ) );
+ docsFolder->appendFrom( *tmp );
delete tmp;
}// no else
/** c1) */
}else{ // we checked
// do something different see what we need to do
// let's see if we should check the device
cfg.setGroup("main" );
bool check = cfg.readBoolEntry("autocheck", true );
if( check ){ // find the documents
- tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") );
+
+ qApp->processEvents();
+ Global::statusMessage( tr( "Searching documents" ) );
+ tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") );
docsFolder->appendFrom( *tmp );
delete tmp;
}
}
}
}
}
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());
}
void Launcher::viewSelected(const QString& s)
{
setCaption( s + tr(" - Launcher") );
}
@@ -1083,49 +1103,52 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
//cfg.readEntry( app ).latin1() );
} else if ( msg == "setSyncDate(QString,QString)" ) {
QString app, date;
stream >> app >> date;
Config cfg( "qpe" );
cfg.setGroup("SyncDate");
cfg.writeEntry( app, date );
//qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1());
} else if ( msg == "startSync(QString)" ) {
QString what;
stream >> what;
delete syncDialog; syncDialog = 0;
syncDialog = new SyncDialog( this, "syncProgress", FALSE,
WStyle_Tool | WStyle_Customize |
Qt::WStyle_StaysOnTop );
syncDialog->showMaximized();
syncDialog->whatLabel->setText( "<b>" + what + "</b>" );
connect( syncDialog->buttonCancel, SIGNAL( clicked() ),
SLOT( cancelSync() ) );
} else if ( msg == "stopSync()") {
delete syncDialog; syncDialog = 0;
} else if ( msg == "getAllDocLinks()" ) {
loadDocs();
- QString contents;
+ // directly show updated docs in document tab
+ updateDocs();
+
+ QString contents;
// Categories cats;
for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) {
DocLnk *doc = it.current();
QFileInfo fi( doc->file() );
if ( !fi.exists() )
continue;
bool fake = !doc->linkFileKnown();
if ( !fake ) {
QFile f( doc->linkFile() );
if ( f.open( IO_ReadOnly ) ) {
QTextStream ts( &f );
ts.setEncoding( QTextStream::UnicodeUTF8 );
contents += ts.read();
f.close();
} else
fake = TRUE;
}
if (fake) {
contents += "[Desktop Entry]\n";
contents += "Categories = " + // No tr
// cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr
Qtopia::Record::idsToString( doc->categories() ) + "\n";