Example #1
0
void TextShow::setSource(const QString &name)
{
#ifndef QT_NO_CURSOR
    if ( isVisible() )
        qApp->setOverrideCursor( waitCursor );
#endif
    QString source = name;
    QString mark;
    int hash = name.find('#');
    if ( hash != -1) {
        source = name.left( hash );
        mark = name.mid( hash+1 );
    }
    if ( source.left(5) == "file:" )
        source = source.mid(6);

    QString url = mimeSourceFactory()->makeAbsolute( source, context() );
    QString txt;

    if (!mark.isEmpty()) {
        url += "#";
        url += mark;
    }

    QCString s = url.local8Bit();
    Event e(EventGoURL, (void*)(const char*)url);
    e.process();

#ifndef QT_NO_CURSOR
    if ( isVisible() )
        qApp->restoreOverrideCursor();
#endif
}
Example #2
0
void InfoPage::setSource ( const QString& name )
{
#ifdef QT_ONLY
    mimeSourceFactory()->setFilePath( QStringList() << QString::fromLatin1("manual/"));
    QString nm = name;
    if ( nm.endsWith("/") )
        nm = nm.left( nm.length()-1);

    if ( nm.startsWith("mailto:") ) {
        QMessageBox::information( this, tr("Support mail"), tr("Please send the mail to [email protected]") );
        return;
    }
    if ( nm.startsWith( "http:" ) )
        return;


    if ( nm == "doc://" )
        nm = "doc://index";

    if ( nm.startsWith( QString::fromLocal8Bit("doc://") ) ) {
        nm = nm.mid(6) + ".html";
    }

    QTextBrowser::setSource( nm );
#else
  if ( name.startsWith( QString::fromLocal8Bit("doc://") ) ) {
    kapp->invokeHelp( name.mid(6, name.length()-7), QString::fromLocal8Bit("KRegExpEditor") );
  }
  else {
    KTextBrowser::setSource( name ); // handle mailto and other links
  }
#endif
}
Example #3
0
void Q3TextBrowser::setSource(const QString& name)
{
#ifndef QT_NO_CURSOR
    if (isVisible())
        qApp->setOverrideCursor(Qt::WaitCursor);
#endif
    d->textOrSourceChanged = true;
    QString source = name;
    QString mark;
    int hash = name.indexOf(QLatin1Char('#'));
    if (hash != -1) {
        source = name.left(hash);
        mark = name.mid(hash+1);
    }

    if (source.left(5) == QLatin1String("file:"))
        source = source.mid(6);

    QString url = mimeSourceFactory()->makeAbsolute(source, context());
    QString txt;
    bool dosettext = false;

    if (!source.isEmpty() && url != d->curmain) {
        const QMimeSource* m =
                    mimeSourceFactory()->data(source, context());
        if (!m){
            qWarning("Q3TextBrowser: no mimesource for %s", source.latin1());
        }
        else {
            if (!Q3TextDrag::decode(m, txt)) {
                qWarning("Q3TextBrowser: cannot decode %s", source.latin1());
            }
        }
        if (isVisible()) {
            QString firstTag = txt.left(txt.indexOf(QLatin1Char('>')) + 1);
            if (firstTag.left(3) == QLatin1String("<qt") && firstTag.contains(QLatin1String("type")) && firstTag.contains(QLatin1String("detail"))) {
                popupDetail(txt, QCursor::pos());
#ifndef QT_NO_CURSOR
                qApp->restoreOverrideCursor();
#endif
                return;
            }
        }

        d->curmain = url;
        dosettext = true;
    }

    d->curmark = mark;

    if (!mark.isEmpty()) {
        url += QLatin1Char('#');
        url += mark;
    }
    if (d->home.count() == 0)
        d->home = url;

    if (d->stack.isEmpty() || d->stack.top() != url)
        d->stack.push(url);

    int stackCount = (int)d->stack.count();
    if (d->stack.top() == url)
        stackCount--;
    emit backwardAvailable(stackCount > 0);
    stackCount = (int)d->forwardStack.count();
    if (d->forwardStack.isEmpty() || d->forwardStack.top() == url)
        stackCount--;
    emit forwardAvailable(stackCount > 0);

    if (dosettext)
        Q3TextEdit::setText(txt, url);

    if (!mark.isEmpty())
        scrollToAnchor(mark);
    else
        setContentsPos(0, 0);

#ifndef QT_NO_CURSOR
    if (isVisible())
        qApp->restoreOverrideCursor();
#endif

    emit sourceChanged(url);
}
Example #4
0
/*!
  Sets the text document with the given \a name to be displayed.  The
  name is looked up in the mimeSourceFactory() of the browser.

  In addition to the factory lookup, this functions also checks for
  optional anchors and scrolls the document accordingly.

  If the first tag in the document is \c &lt;qt \c type=detail&gt;, it is
  displayed as a popup rather than as new document in the browser
  window itself. Otherwise, the document is set normally via
  setText(), with \a name as new context.

  If you are using the filesystem access capabilities of the mime
  source factory, you have to ensure that the factory knows about the
  encoding of specified text files, otherwise no data will be
  available. The default factory handles a couple of common file
  extensions such as \c *.html and \c *.txt with reasonable defaults. See
  QMimeSourceFactory::data() for details.

*/
void QTextBrowser::setSource(const QString& name)
{
#ifndef QT_NO_CURSOR
    if ( isVisible() )
	qApp->setOverrideCursor( waitCursor );
#endif
    QString source = name;
    QString mark;
    int hash = name.find('#');
    if ( hash != -1) {
	source  = name.left( hash );
	mark = name.mid( hash+1 );
    }

    if ( source.left(5) == "file:" )
	source = source.mid(6);

    QString url = mimeSourceFactory()->makeAbsolute( source, context() );
    QString txt;
    bool dosettext = FALSE;

    if ( !source.isEmpty() && url != d->curmain ) {
	const QMimeSource* m =
		    mimeSourceFactory()->data( source, context() );
	if ( !m ){
	    qWarning("QTextBrowser: no mimesource for %s", source.latin1() );
	}
	else {
	    if ( !QTextDrag::decode( m, txt ) ) {
		qWarning("QTextBrowser: cannot decode %s", source.latin1() );
	    }
	}

 	if ( isVisible() ) {
 	    QString firstTag = txt.left( txt.find('>' )+1 );
 	    QRichText* tmp = new QRichText( firstTag, QApplication::font() );
 	    static QString s_type = QString::fromLatin1("type");
 	    static QString s_detail = QString::fromLatin1("detail");
	    bool doReturn = FALSE;
 	    if ( tmp->attributes().contains(s_type)
		 && tmp->attributes()[s_type] == s_detail )
		doReturn = TRUE;
	    QTextFormatCollection* formats = tmp->formats;
	    delete tmp;
	    delete formats; //#### fix inheritance structure in rich text
	    if ( doReturn ) {
 		popupDetail( txt, d->lastClick );
#ifndef QT_NO_CURSOR
 		qApp->restoreOverrideCursor();
#endif
 		return;
 	    }
 	}

	d->curmain = url;
	dosettext = TRUE;
    }

    d->curmark = mark;

    if ( !mark.isEmpty() ) {
	url += "#";
	url += mark;
    }
    if ( !d->home )
	d->home = url;

    if ( d->stack.isEmpty() || d->stack.top() != url) {
	d->stack.push( url );
    }

    int stackCount = d->stack.count();
    if ( d->stack.top() == url )
	stackCount--;
    emit backwardAvailable( stackCount > 0 );
    stackCount = d->forwardStack.count();
    if ( d->forwardStack.top() == url )
	stackCount--;
    emit forwardAvailable( stackCount > 0 );

    if ( dosettext )
	setText( txt, url );

    if ( isVisible() && !mark.isEmpty() )
	scrollToAnchor( mark );
    else
	setContentsPos( 0, 0 );

#ifndef QT_NO_CURSOR
    if ( isVisible() )
	qApp->restoreOverrideCursor();
#endif
}
Example #5
0
void FLSmtpClient::startSend()
{
  emit sendStarted();

  emit sendTotalSteps(attachments_.count() + 3);

  int step = 0;

  emit sendStepNumber(++step);

  changeStatus(tr("Componiendo mensaje"), Composing);

  // only send logo when configured
  if (FLUtil::readSettingEntry("email/sendMailLogo", "true").toBool()) {
    QString logo(FLUtil::readSettingEntry("email/mailLogo",
                                          AQ_DATA + "/logo_mail.png").toString());
    if (!QFile::exists(logo)) {
      logo = AQ_DISKCACHE_DIRPATH + "/logo.png";
      QPixmap::fromMimeSource("logo_abanq.png").save(logo, "PNG");
    }

    attachments_ << logo;
    mapAttachCid_.insert(logo, QFileInfo(logo).fileName() + "@3d8b627b6292");
  }

  QString headerStr(QString::fromLatin1("from: ") + from_);
  if (!replyTo_.isEmpty())
    headerStr += QString::fromLatin1("\nreply-to: ") + replyTo_;
  headerStr += QString::fromLatin1("\nto: ") + to_ +
               QString::fromLatin1("\nsubject: ") + subject_;
  if (!cc_.isEmpty())
    headerStr += QString::fromLatin1("\ncc: ") + cc_;
  if (!bcc_.isEmpty())
    headerStr += QString::fromLatin1("\nbcc: ") + bcc_;
  if (!organization_.isEmpty())
    headerStr += QString::fromLatin1("\norganization: ") + organization_;
  if (priority_ > 0)
    headerStr += QString::fromLatin1("\npriority: ") +
                 QString::number(priority_);

  CharSets chS;
  HeaderClass hdr(headerStr.local8Bit());
  MessageClass msg(hdr);
  LocalMailFolder folder(AQ_DISKCACHE_DIRPATH + '/');
  QString idMessage = folder.createMessage(body_.local8Bit(), QCString(), QDateTime::currentDateTime(), "", &msg);
  IndexClass *idx = folder.indexIDict()[ idMessage ];
  MessageDevice msgDev(idx);

  MimePart *part0 = new MimePart();
  part0->charset = chS.getDefaultCharset();

  part0->mimetype = (mimeType_.isEmpty() ? "text/plain" : mimeType_);
  part0->encoding = "quoted-printable";
  part0->name = "body";
  part0->type = "text";
  QByteArray partData0 = body_.local8Bit();
  part0->length = partData0.count();
  int npart0 = idx->addPart(part0, false);
  msgDev.setPartData(npart0, partData0);

  emit sendStepNumber(++step);

  for (uint i = 0; i < textParts_.count(); i += 2) {
    part0 = new MimePart();
    part0->charset = chS.getDefaultCharset();
    part0->mimetype = textParts_[i + 1];
    part0->encoding = "quoted-printable";
    part0->type = "text";
    partData0 = textParts_[i].local8Bit();
    part0->length = partData0.count();
    npart0 = idx->addPart(part0, false);
    msgDev.setPartData(npart0, partData0);

    emit sendStepNumber(++step);
  }

  QStringList::Iterator itAttach;
  QString fileName;
  for (uint i = 0; i < attachments_.count(); i++) {
    itAttach = attachments_.at(i);
    fileName = *itAttach;

    changeStatus(tr("Adjuntando %1").arg(QFileInfo(fileName).fileName()), Attach);

    MimePart *part1 = new MimePart();
    part1->charset = chS.getDefaultCharset();
    QFile f(fileName);
    f.open(IO_Raw | IO_ReadOnly);
    QByteArray partData1 = f.readAll();
    f.close();
    part1->length = partData1.count();
    part1->name = QFileInfo(fileName).fileName();
    if (mapAttachCid_.contains(fileName))
      part1->cid = mapAttachCid_[fileName];
    const QMimeSource *mime = 0;
    QMimeSourceFactory *mimeFactory = mimeSourceFactory();
    if (mimeFactory) {
      mime = mimeFactory->data(fileName);
    } else {
      mime = QMimeSourceFactory::defaultFactory()->data(fileName);
    }
    if (mime && mime->format()) {
      part1->mimetype = mime->format();
      part1->encoding =  "base64";
    }
    int npart1 = idx->addPart(part1, false);
    msgDev.setPartData(npart1, partData1);

    emit sendStepNumber(++step);
  }

  QStringList rcpts(hdr.To.toQStringList());
  rcpts += hdr.Cc.toQStringList();
  rcpts += hdr.Bcc.toQStringList();

  Smtp *smtp = new Smtp(from_, rcpts, msgDev.rfc822Header(),
                        mailServer_, port_, this);

  smtp->setUser(user_);
  smtp->setPassword(password_);
  smtp->setConnectionType(connectionType_);
  smtp->setAuthMethod(authMethod_);

  emit sendStepNumber(++step);

  connect(smtp, SIGNAL(destroyed()),
          this, SIGNAL(sendEnded()));
  connect(smtp, SIGNAL(statusChanged(const QString &, int)),
          this, SLOT(changeStatus(const QString &, int)));
  smtp->init();
}