00001 // 00002 // 00003 // C++ Implementation: $MODULE$ 00004 // 00005 // Description: 00006 // 00007 // 00008 // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 00009 // 00010 // Copyright: See COPYING file that comes with this distribution 00011 // 00012 // 00013 #include "doclnkitem.h" 00014 00015 #include <opie2/odebug.h> 00016 00017 #include <qpe/applnk.h> 00018 #include <qpe/qcopenvelope_qws.h> 00019 00020 #include <qtextstream.h> 00021 #include <qfileinfo.h> 00022 00023 DocLnkItem::DocLnkItem(OListViewItem* parent, DocLnk *app) 00024 : ResultItem(parent) 00025 { 00026 _doc = app; 00027 setText(0, _doc->name() ); 00028 setPixmap(0, _doc->pixmap() ); 00029 } 00030 00031 DocLnkItem::~DocLnkItem() 00032 { 00033 } 00034 00035 QString DocLnkItem::toRichText() 00036 { 00037 QString text; 00038 text += "<b><h3>" + _doc->name() + "</b></h3><br>"; 00039 text += _doc->comment() + "<br>"; 00040 text += QObject::tr("File: ") + _doc->file() + "<br>"; 00041 text += QObject::tr("Link: ") + _doc->linkFile() + "<br>"; 00042 text += QObject::tr("Mimetype: ") + _doc->type() + "<br>"; 00043 if ( _doc->type().contains( "text" ) ){ 00044 text += "<br><br><hr><br>"; 00045 QFile f(_doc->file()); 00046 if ( f.open(IO_ReadOnly) ) { 00047 QTextStream t( &f ); 00048 while ( !t.eof() ) 00049 text += t.readLine() + "<br>"; 00050 } 00051 f.close(); 00052 } 00053 /* text += "<br><br>`"; 00054 text += _doc->exec(); 00055 text += "`";*/ 00056 QStringList list = _doc->mimeTypes(); 00057 int i = 0; 00058 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 00059 text += QString::number( i++) + " - " + *it ; 00060 } 00061 return text; 00062 } 00063 00064 void DocLnkItem::action( int act ) 00065 { 00066 odebug << "action" << act << oendl; 00067 if (!_doc->isValid()) odebug << "INVALID" << oendl; 00068 if (act == 0) _doc->execute(); 00069 else if (act == 1){ 00070 QCopEnvelope e("QPE/Application/advancedfm", "setDocument(QString)"); 00071 e << _doc->file(); 00072 } 00073 } 00074 00075 QIntDict<QString> DocLnkItem::actions() 00076 { 00077 QIntDict<QString> result; 00078 result.insert( 0, new QString( QObject::tr("open with ") + _doc->exec() ) ); 00079 result.insert( 1, new QString( QObject::tr("open in filemanager") ) ); 00080 return result; 00081 }
1.4.2