summaryrefslogtreecommitdiff
authorzecke <zecke>2002-03-24 19:30:27 (UTC)
committer zecke <zecke>2002-03-24 19:30:27 (UTC)
commit4802684dd785274be50b472c87e315da0e325449 (patch) (side-by-side diff)
treee15bb479f443d5ce410ccbd9368e663213210517
parent6ce8bbff9eb16e0d731755010bda63e7fb43f70b (diff)
downloadopie-4802684dd785274be50b472c87e315da0e325449.zip
opie-4802684dd785274be50b472c87e315da0e325449.tar.gz
opie-4802684dd785274be50b472c87e315da0e325449.tar.bz2
Hija this adds the "Do you want to scan this device?"
to launcher and should speed up some things. Please test launcher and report bugs to me
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcher.cpp84
-rw-r--r--core/launcher/mediummountgui.cpp10
2 files changed, 66 insertions, 28 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp
index 1c38a05..cf1a3c8 100644
--- a/core/launcher/launcher.cpp
+++ b/core/launcher/launcher.cpp
@@ -47,64 +47,95 @@
#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
+namespace {
+ QStringList configToMime( Config *cfg ){
+ QStringList mimes;
+ bool tmpMime;
+ cfg->setGroup("mimetypes" );
+ tmpMime = cfg->readBoolEntry("all" ,false);
+ if( tmpMime ){
+ mimes << QString::null;
+ return mimes;
+ }else{
+ tmpMime = cfg->readBoolEntry("audio", true );
+ if(tmpMime )
+ mimes.append("audio//*" );
+
+ tmpMime = cfg->readBoolEntry("image", true );
+ if(tmpMime )
+ mimes.append("image//*" );
+
+ tmpMime = cfg->readBoolEntry("text", true );
+ if(tmpMime )
+ mimes.append("text//*");
+
+ tmpMime = cfg->readBoolEntry("video", true );
+ if(tmpMime )
+ mimes.append("video//*" );
+ }
+ return mimes;
+ }
+
+}
+
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() ) {
@@ -397,66 +428,66 @@ void CategoryTabBar::paintLabel( QPainter* p, const QRect&,
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;
- int stamp = uidgen.generate();
- uidgen.store( stamp );
+ int stamp = uidgen.generate(); // this is our timestamp to see which devices we know
+ //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()
{
@@ -482,111 +513,116 @@ void Launcher::showMaximized()
}
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" );
+ DocLnkSet *tmp = 0;
+ QString home = QString(getenv("HOME")) + "/Documents";
+ tmp = new DocLnkSet( home , QString::null);
+ docsFolder->appendFrom( *tmp );
+ delete tmp;
// 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 );
- qWarning("new time stamp is: %s", newStamp.latin1() );
+ QString newStamp = QString::number( stamp ); // generates newtime Stamp
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 );
+ cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp
// we need to scan the list now. Hopefully the cache will be there
- }else{ // come up with the gui
- qWarning("time stamp doesn't match" );
+ // read the mimetypes from the config and search for documents
+ QStringList mimetypes = configToMime( &cfg);
+ 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((*it)->path() );
- qWarning("medium mount gui created" );
- if( medium.check() ){
- qWarning("need to check this device" );
- if( medium.exec() ){ //ok
+ if( medium.check() ){ // we did not ask before or ask again is off
+ if( medium.exec() ){ // he clicked yes so search it
// speicher
- qWarning("execed" );
- cfg.read();
+ cfg.read(); // cause of a race we need to reread
cfg.writeEntry("timestamp", newStamp );
- }
- }else{
- qWarning("wrong :(" );
+ }// no else
+ }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(";") );
+ docsFolder->appendFrom( *tmp );
+ delete tmp;
+ }
}
}
}
}
- 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();
}
diff --git a/core/launcher/mediummountgui.cpp b/core/launcher/mediummountgui.cpp
index e3fa5bd..f0de85b 100644
--- a/core/launcher/mediummountgui.cpp
+++ b/core/launcher/mediummountgui.cpp
@@ -51,85 +51,87 @@ void MediumMountGui::readConfig(){
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 all is checked then add only "QString::null" to the list.
if (checkmimeall) {
- mimeTypeList += ("null");
+ mimeTypeList.clear();
+ mimeTypeList += QString::null;
} else {
if (checkmimeaudio) {
mimeTypeList += ("audio//*");
}
if (checkmimetext) {
mimeTypeList += ("text//*");
}
if (checkmimevideo) {
mimeTypeList += ("video//*");
}
if (checkmimeimage) {
mimeTypeList += ("image//*");
}
if (checkmimeall) {
- mimeTypeList << ("null");
+ mimeTypeList.clear();
+ mimeTypeList << QString::null;
}
}
- cfg.write();
+ cfg.write(); // not really needed here but just to be sure
}
void MediumMountGui::startGui() {
QPixmap image = Resource::loadPixmap( "HelpBrowser");
Text_2 = new QLabel( this );
Text_2->setGeometry( QRect( 10, 15, 40, 40 ) );
Text_2->setPixmap( image );
Text = new QLabel( this, "Text" );
Text->setGeometry( QRect( 55, 11, this->width()-50, 50 ) );
Text->setText( tr( "A <b>storage medium</b> was inserted. Should it be scanned for media files?" ) );
// media box
GroupBox1 = new QGroupBox( this, "GroupBox1" );
GroupBox1->setGeometry( QRect( 10, 80, (this->width())-25, 80 ) );
GroupBox1->setTitle( tr( "Which media files" ) );
CheckBoxAudio = new QCheckBox( GroupBox1, "CheckBoxAudio" );
CheckBoxAudio->setGeometry( QRect( 10, 15, (GroupBox1->width()/2)-15 , 15 ) );
CheckBoxAudio->setText( tr( "Audio" ) );
CheckBoxImage = new QCheckBox( GroupBox1, "CheckBoxImage" );
CheckBoxImage->setGeometry( QRect( 10, 35,(GroupBox1->width()/2)-15, 15 ) );
CheckBoxImage->setText( tr( "Image" ) );
CheckBoxText = new QCheckBox( GroupBox1, "CheckBoxText" );
CheckBoxText->setGeometry( QRect((GroupBox1->width()/2) , 15, (GroupBox1->width()/2)-15, 15 ) );
CheckBoxText->setText( tr( "Text" ) );
CheckBoxVideo = new QCheckBox( GroupBox1, "CheckBoxVideo" );