⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qdl.cpp

📁 Trolltech公司发布的图形界面操作系统。可在qt-embedded-2.3.10平台上编译为嵌入式图形界面操作系统。
💻 CPP
📖 第 1 页 / 共 3 页
字号:
	    case u3:	    case u4:	    case u5:	    case u6:	    case u7:	    case u8:	    case u9:		break; // do nothing	    default:		t += lidText[i];	}    }    return t;}/*!  Encodes the string \a ahref so that it may be included as part of a QDL link.*/QString QDL::encodeAhref( const QString &ahref ){    QString encAhref = ahref;    return encAhref.replace( QRegExp(":"), "%3A" );}/*!  Decodes the string \a ahref that was encoded as part of a QDL link.*/QString QDL::decodeAhref( const QString &ahref ){    QString decAhref = ahref;    return decAhref.replace( QRegExp("%3A"), ":" );}/*!  \class QDLLink qdl.h  \brief The QDLLink class encapsulates the data of a link.  The QDLLink class encapsulates the data of a link.  A link is made up of four elements. They are:  <ol>    <li>Application Reference (QCString)- A reference to the application which contains the data to be linked.    This is the application's filename (eg. addressbook)    <li>Data Reference (QByteArray)- Binary data that the source uses which uniquely identifies the data to be linked.    <li>Description (QString)- A description of the link to display to the user.    <li>Icon (QCString) The name of an icon which qualifies the link in some way	    (eg. as a link to a contact, an event etc). 	    Passed to Resource::loadPixmap()  </ol>  \ingroup qtopiaemb*//*   \relates QDLLink   Reads \a link from the \a stream*/QDataStream &operator>>( QDataStream &stream, QDLLink &link ){    QCString appRef, icon;    QByteArray dataRef;    QString desc;    stream >> appRef >> dataRef >> desc >> icon;    link.setAppRef( appRef );    link.setDataRef( dataRef );    link.setDescription( desc );    link.setIcon( icon );    return stream;}/*   \relates QDLLink   Writes \a link to the \a stream*/QDataStream &operator<<( QDataStream &stream, const QDLLink &link ){    stream << link.appRef() << link.dataRef() << link.description() << link.icon();    return stream;}/*!   Constructs a null link.*/QDLLink::QDLLink(){}/*!  Constructs a link from   the application reference \a appRef, the data reference \a dataRef,   the description \a desc and the icon \a icon.*/QDLLink::QDLLink( const QCString &appRef, const QByteArray &dataRef,    const QString &desc, const QCString &icon ) {    mAppRef = appRef;    mDataRef = dataRef;    mDescription = desc;    mIcon = icon;}/*!  Copy constructor. Performs a deep copy of the link specified by \a other.*/QDLLink::QDLLink( const QDLLink &other )    : QObject(){    mAppRef = other.mAppRef;    mDataRef = other.mDataRef;    mDescription = other.mDescription;    mIcon = other.mIcon;}/*!  Deep copies the link specified by \a other.*/QDLLink &QDLLink::operator=( const QDLLink &other ){    mAppRef = other.mAppRef;    mDataRef = other.mDataRef;    mDescription = other.mDescription;    mIcon = other.mIcon;    return *this;}/*!  Returns TRUE if the link is null, otherwise returns FALSE.  A null link has no application or data reference.*/bool QDLLink::isNull() const{    return mAppRef.isEmpty() || mDataRef.isEmpty();}/*!  Sets the application reference of the link to \a ref.*/void QDLLink::setAppRef( const QCString &ref ){    mAppRef = ref;}/*!  Returns the application reference of the link.*/QCString QDLLink::appRef() const{    return mAppRef;}/*!  Sets the data reference of the link to \a ref.*/void QDLLink::setDataRef( const QByteArray &ref ){    mDataRef = ref;}/*!  Returns the data reference of the link.*/QByteArray QDLLink::dataRef() const{    return mDataRef;}/*!  Sets the description of the link to \a desc.*/void QDLLink::setDescription( const QString &desc ){    mDescription = desc;}/*!  Returns the description of the link.*/QString QDLLink::description() const{    return mDescription;}/*!  Sets the icon of the link to \a icon.*/void QDLLink::setIcon( const QCString &icon ){    mIcon = icon;}/*!  Returns the icon of the link.*/QCString QDLLink::icon() const{    return mIcon;}class QDLHeartBeatPrivate{public:    QDLHeartBeatPrivate( const QString &cid )	: clientID( cid )    {	timer = new QTimer();    }    ~QDLHeartBeatPrivate()    {	delete timer;    }    QString clientID;    QTimer *timer;};/*!   \class QDLHeartBeat qdl.h   \brief The QDLHeartBeat class automates the sending of a heart beat to clients.    QDLHeartBeat automates the sending of a heart beat to   a QDLClient. It begins sending a heart beat when constructed   and terminates when it is destructed (eg goes out of scope).   This is used by a source application to let a client know that   the request it made is being actively processed.   \sa QDLClient  \ingroup qtopiaemb*//*!  Constructs a QDLHeartBeat and begins sending heart beats to the   client specified by \a clientID immediately.*/QDLHeartBeat::QDLHeartBeat( const QString &clientID ){    d = new QDLHeartBeatPrivate( clientID );    connect( d->timer, SIGNAL(timeout()), this, SLOT(beat()) );    d->timer->start( 3000, FALSE );    beat(); //force an update right now}/*!  Destructs the QDLHeartBeat so that it no longer sends heart beats.*/QDLHeartBeat::~QDLHeartBeat(){    delete d;}/*!  Sends a heart beat. Simply calls QDL::sendHeartBeat() with the id of the client.*/void QDLHeartBeat::beat(){    QDL::sendHeartBeat( d->clientID );}class QDLClientPrivate{public:    QDLClientPrivate()	: timeout( 5000 )    {	lc = 0;	timer = new QTimer();	uid = Global::generateUuid();    }    ~QDLClientPrivate()    {	delete timer;    }    QCopChannel *lc;    QString hint;    QTimer *timer;    const uint timeout;    QUuid uid;    QMap<uint, QDLLink> links;};/*!   \class QDLClient qdl.h   \brief The QDLClient class provides a set of links and communication with a data source.       A QDLClient contains a set of links and handles communication with a data source.   A single client can have an unlimited number of links. To load and save links to and from a client   you can use the utility functions QDL::loadLinks() and QDL::saveLinks() respectively.   This class operates independently of any other object. The subclass QDLWidgetClient extends    this class to operate on a widget and its text dependently.   \sa QDLWidgetClient  \ingroup qtopiaemb*//*!  Constructs a QDLClient. \a parent and \a name are passed on to QObject.*/QDLClient::QDLClient( QObject *parent, const char *name )    : QObject( parent, name ){    d = new QDLClientPrivate();    connect( d->timer, SIGNAL(timeout()), this, SLOT(requestTimeout()) );}/*!  Clears all links in the client.*/void QDLClient::clear(){    d->links.clear();}/*!   Adds \a newLink to the client. A new link identifier is generated.*/void QDLClient::addLink( const QDLLink &newLink ){    if( newLink.isNull() ) 	return;    setLink( nextLID(), newLink );}/*!    Sets the link specified by the link identifier \a lid to \a newLink.   If no link for \a lid currently exists, it is created.*/void QDLClient::setLink( uint lid, const QDLLink &newLink ){    if( newLink.isNull() ) 	return;    d->links[lid] = newLink;}/*!    Removes the link specified by the link identifier \a lid.*/void QDLClient::removeLink( uint lid ){    if( d->links.contains( lid ) )	d->links.remove( lid );}/*!  Returns TRUE if a request for links is active, otherwise returns FALSE.*/bool QDLClient::isRequestActive() const{    if( d->lc )	return TRUE;    return FALSE;}/*!  Returns the link specified by the link identifier \a lid.  If no such link exists a null link is returned. */QDLLink QDLClient::link( uint lid ) const{    if( !d->links.contains( lid ) )	return QDLLink();    return d->links[lid];}/*!  Returns a link identifier to QDLLink map of all links in the client.*/QMap<uint, QDLLink> QDLClient::links() const{    return d->links;}/*!  Returns the number of links in the client.*/uint QDLClient::count() const{    return d->links.count();}/*!  Sets the request hint for the client to \a hint.  A hint is sent to a data source as part of the request to help it determine   pertinent data.  A hint can only be used with a QDLClient by calling setHint() explicitly.  \sa QDLWidgetClient*/void QDLClient::setHint( const QString &hint ){    d->hint = hint;}/*!  Returns the request hint for this client.    Subclasses may override this function if they wish to dynamically determine a hint.  \sa QDLWidgetClient::hint()*/QString QDLClient::hint() const{    return d->hint;}/*!  Sends a request for links to the data source listening on \a channel.*/void QDLClient::requestLink( const QString &channel ){#ifndef QT_NO_QCOP    if( isRequestActive() )	return;    QString h = hint();    QCopEnvelope e( channel.latin1(), "QDLRequestLink(QString,QString)" );    e << d->uid.toString() << h;    d->lc = new QCopChannel( QDL::CLIENT_CHANNEL, this );    connect( d->lc, SIGNAL(received(const QCString&, const QByteArray&)), this, 	    SLOT(receiveLinks(const QCString&, const QByteArray&)) );    d->timer->start( d->timeout, TRUE );#else    qDebug("QDLClient - Can't request link because QCop not enabled.");#endif}/*! \overload  Prompts the user to select a data source application, determines source  application's channel  based on the user's selection, and then passes it to the above function.  \a parent is the parent of the dialog used.*/void QDLClient::requestLink( QWidget *parent ){    QDLSourceSelector *s = new QDLSourceSelector( parent, "sourceSelector" );#ifndef QTOPIA_DESKTOP    if( QPEApplication::execDialog( s ) == QDialog::Accepted )#else    if( d->exec() == QDialog::Accepted )#endif    {	QMap<QString, QString> sources = s->selected();	QMap<QString, QString>::ConstIterator sit;	for( sit = sources.begin() ; sit != sources.end() ; ++sit )	    requestLink( sit.data() );    }    delete s;}/*! \internal    Processes messages from a data source.*/void QDLClient::receiveLinks( const QCString &sig, const QByteArray &data ){    if( !isRequestActive() )	return;    QDataStream s( data, IO_ReadOnly );	        //first argument is already the id    QString id;    s >> id;    if( d->uid.toString() != id )	return; // message isn't for this client    if( sig == "QDLProvideLink(QString,int,...)" )    {	uint numLinks = 0;	s >> numLinks;	for( uint i = 0 ; i < numLinks ; ++i )	{	    QDLLink newLink;	    s >> newLink;	    addLink( newLink );	}	d->timer->stop();	delete d->lc;	d->lc = 0;    }    else if( sig == "QDLHeartBeat(QString)" )    {	//reset next timeout time	d->timer->stop();	d->timer->start( d->timeout, TRUE );    }}/*!  Verifies that all links in the client are valid. The default implementation does nothing,  This function is called from QDL::saveLinks().  Subclasses that wish to perform any verification processing should override this function.*/void QDLClient::verifyLinks(){}/*! \internal  Kills an active request.*/void QDLClient::requestTimeout(){    if( !isRequestActive() )	return;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -