Ejemplo n.º 1
0
bool KoReportHTMLTableRenderer::render(const KoReportRendererContext& context, ORODocument *document, int page)
{
    Q_UNUSED(page);
    KTemporaryFile tempHtmlFile; // auto removed by default on destruction
    if (!tempHtmlFile.open()) {
        kWarning() << "Couldn't create temporary file to write into";
        return false;
    }

    QTextStream out(&tempHtmlFile);

    QString dirSuffix = ".files";
    QDir tempDir;
    QFileInfo fi(tempHtmlFile);

    QString tempFileName = fi.absoluteFilePath();
    m_tempDirName = tempFileName + dirSuffix;
    m_actualDirName = context.destinationUrl.fileName() + dirSuffix;

    if (!tempDir.mkpath(m_tempDirName))
        return false;

    out << renderTable(document);

    out.flush();
    tempHtmlFile.close();

    bool status = false;
    if (KIO::NetAccess::upload(tempFileName, context.destinationUrl, 0) && KIO::NetAccess::dircopy(KUrl(m_tempDirName),  KUrl(context.destinationUrl.url() + dirSuffix), 0)) {
        status = true;
    }

    // cleanup the temporary directory
    tempDir.setPath(m_tempDirName);
    QStringList fileList = tempDir.entryList();
    foreach(const QString& fileName, fileList) {
        tempDir.remove(fileName);
    }
Ejemplo n.º 2
0
//static
KexiTemplateInfoList KexiTemplateLoader::loadListInfo()
{
    KexiTemplateInfoList list;
// const QString subdir = QString(kapp->instanceName()) + "/templates";
#ifdef __GNUC
#ifdef __GNUC__
#warning KexiTemplateLoader::loadListInfo() -- OK? KGlobal::mainComponent().componentName()
#else
#pragma WARNING( KexiTemplateLoader::loadListInfo() -- OK? KGlobal::mainComponent().componentName() )
#endif
#endif
    const QString subdir = KGlobal::mainComponent().componentName() + "/templates";
    QString lang(KGlobal::locale()->language());
    QStringList dirs(KGlobal::dirs()->findDirs("data", subdir));
    while (true) {
        foreach(const QString &dirname, dirs) {
            QDir dir(dirname + lang);
            if (!dir.exists())
                continue;
            if (!dir.isReadable()) {
                kWarning() << "\"" << dir.absolutePath() << "\" not readable!";
                continue;
            }
            const QStringList templateDirs(dir.entryList(QDir::Dirs, QDir::Name));
            const QString absDirPath(dir.absolutePath() + '/');
            foreach(const QString &templateDir, templateDirs) {
                if (templateDir == "." || templateDir == "..")
                    continue;
                KexiTemplateInfo info = KexiTemplateLoader::loadInfo(absDirPath + templateDir);
                if (!info.name.isEmpty())
                    list.append(info);
            }
        }
        if (lang != "en" && list.isEmpty()) //not found for current locale, try "en"
            lang = "en";
        else
            break;
    }
Ejemplo n.º 3
0
static Picture createPicture( Pixmap pix, int depth )
    {
    if( pix == None )
        return None;
    if( renderformats[ depth ] == NULL )
        {
        switch( depth)
            {
            case 1:
                renderformats[ 1 ] = XRenderFindStandardFormat( display(), PictStandardA1 );
              break;
            case 8:
                renderformats[ 8 ] = XRenderFindStandardFormat( display(), PictStandardA8 );
              break;
            case 24:
                renderformats[ 24 ] = XRenderFindStandardFormat( display(), PictStandardRGB24 );
              break;
            case 32:
                renderformats[ 32 ] = XRenderFindStandardFormat( display(), PictStandardARGB32 );
              break;
            default:
                {
                XRenderPictFormat req;
                long mask = PictFormatType | PictFormatDepth;
                req.type = PictTypeDirect;
                req.depth = depth;
                renderformats[ depth ] = XRenderFindFormat( display(), mask, &req, 0 );
              break;
                }
            }
        if( renderformats[ depth ] == NULL )
            {
            kWarning( 1212 ) << "Could not find XRender format for depth" << depth;
            return None;
            }
        }
    return XRenderCreatePicture( display(), pix, renderformats[ depth ], 0, NULL );
    }
Ejemplo n.º 4
0
Plugin *PluginManager::loadPluginInternal( const QString &pluginId )
{
    kDebug() << "Loading Plugin: " << pluginId;

    KPluginInfo info = infoForPluginId( pluginId );
    if ( !info.isValid() )
    {
        kWarning() << "Unable to find a plugin named '" << pluginId << "'!";
        return 0L;
    }

    if ( _kpmp->loadedPlugins.contains( info ) )
        return _kpmp->loadedPlugins[ info ];

    QString error;
    Plugin *plugin = KServiceTypeTrader::createInstanceFromQuery<Plugin>( QString::fromLatin1( "Choqok/Plugin" ), QString::fromLatin1( "[X-KDE-PluginInfo-Name]=='%1'" ).arg( pluginId ), this, QVariantList(), &error );

    if ( plugin )
    {
        _kpmp->loadedPlugins.insert( info, plugin );
        info.setPluginEnabled( true );

        connect( plugin, SIGNAL( destroyed( QObject * ) ), this, SLOT( slotPluginDestroyed( QObject * ) ) );
        connect( plugin, SIGNAL( readyForUnload() ), this, SLOT( slotPluginReadyForUnload() ) );

        kDebug() << "Successfully loaded plugin '" << pluginId << "'";

        if( plugin->pluginInfo().category() != "MicroBlogs" && plugin->pluginInfo().category() != "Shorteners" ){
            kDebug()<<"Emitting pluginLoaded()";
            emit pluginLoaded( plugin );
        }

//         Protocol* protocol = dynamic_cast<Protocol*>( plugin );
//         if ( protocol )
//             emit protocolLoaded( protocol );
    }
    else
    {
/** Creates a new RestoreOperation.
	@param d the Device to restore the Partition to
	@param p pointer to the Partition that will be restored. May not be NULL.
	@param filename name of the image file to restore from
*/
RestoreOperation::RestoreOperation(Device& d, Partition* p, const QString& filename) :
	Operation(),
	m_TargetDevice(d),
	m_RestorePartition(p),
	m_FileName(filename),
	m_OverwrittenPartition(NULL),
	m_MustDeleteOverwritten(false),
	m_ImageLength(QFileInfo(filename).size() / 512), // 512 being the "sector size" of an image file.
	m_CreatePartitionJob(NULL),
	m_RestoreJob(NULL),
	m_CheckTargetJob(NULL),
	m_MaximizeJob(NULL)
{
	restorePartition().setState(Partition::StateRestore);

	Q_ASSERT(targetDevice().partitionTable());

	Partition* dest = targetDevice().partitionTable()->findPartitionBySector(restorePartition().firstSector(), PartitionRole(PartitionRole::Primary | PartitionRole::Logical | PartitionRole::Unallocated));

	Q_ASSERT(dest);

	if (dest == NULL)
		kWarning() << "destination partition not found at sector " << restorePartition().firstSector();

	if (dest && !dest->roles().has(PartitionRole::Unallocated))
	{
		restorePartition().setLastSector(dest->lastSector());
		setOverwrittenPartition(dest);
		removePreviewPartition(targetDevice(), *dest);
	}

	if (!overwrittenPartition())
		addJob(m_CreatePartitionJob = new CreatePartitionJob(targetDevice(), restorePartition()));

	addJob(m_RestoreJob = new RestoreFileSystemJob(targetDevice(), restorePartition(), fileName()));
	addJob(m_CheckTargetJob = new CheckFileSystemJob(restorePartition()));
	addJob(m_MaximizeJob = new ResizeFileSystemJob(targetDevice(), restorePartition()));
}
void QGpgMECryptoConfig::runGpgConf( bool showErrors )
{
  // Run gpgconf --list-components to make the list of components
  KProcess process;

  process << gpgConfPath();
  process << "--list-components";


  connect( &process, SIGNAL(readyReadStandardOutput()),
           this, SLOT(slotCollectStdOut()) );

  // run the process:
  int rc = 0;
  process.setOutputChannelMode( KProcess::OnlyStdoutChannel );
  process.start();
  if ( !process.waitForFinished() )
    rc = -2;
  else if ( process.exitStatus() == QProcess::NormalExit )
    rc = process.exitCode();
  else
    rc = -1;

  // handle errors, if any (and if requested)
  if ( showErrors && rc != 0 ) {
    QString reason;
    if ( rc == -1 )
        reason = i18n( "program terminated unexpectedly" );
    else if ( rc == -2 )
        reason = i18n( "program not found or cannot be started" );
    else
      reason = QString::fromLocal8Bit( strerror(rc) ); // XXX errno as an exit code?
    QString wmsg = i18n("<qt>Failed to execute gpgconf:<p>%1</p></qt>", reason);
    kWarning(5150) << wmsg; // to see it from test_cryptoconfig.cpp
    KMessageBox::error(0, wmsg);
  }
  mParsed = true;
}
Ejemplo n.º 7
0
KShortcut::KShortcut(const QString &s)
 : d(new KShortcutPrivate)
{
    qRegisterMetaType<KShortcut>();
    if (s == QLatin1String("none"))
        return;

    QStringList sCuts = s.split("; ");
    if (sCuts.count() > 2)
        kWarning() << "asked to store more than two key sequences but can only hold two.";

    //TODO: what is the "(default)" thingie used for?
    for( int i=0; i < sCuts.count(); i++)
        if( sCuts[i].startsWith( QLatin1String("default(") ) )
            sCuts[i] = sCuts[i].mid( 8, sCuts[i].length() - 9 );

    if (sCuts.count() >= 1) {
        QString k = sCuts.at(0);
        k.replace( "Win+", "Meta+" ); // workaround for KDE3-style shortcuts
        k.replace("Plus", "+"); // workaround for KDE3-style "Alt+Plus"
        k.replace("Minus", "-"); // workaround for KDE3-style "Alt+Plus"
        d->primary = QKeySequence::fromString(k);
        // Complain about a unusable shortcuts sequence only if we have got
        // something.
        if (d->primary.isEmpty() && !k.isEmpty()) {
            kDebug(240) << "unusable primary shortcut sequence " << sCuts[0];
        }
    }

    if (sCuts.count() >= 2) {
        QString k = sCuts.at(1);
        k.replace( "Win+", "Meta+" ); // workaround for KDE3-style shortcuts
        d->alternate = QKeySequence::fromString(k);
        if (d->alternate.isEmpty()) {
            kDebug(240) << "unusable alternate shortcut sequence " << sCuts[1];
        }
    }
}
Ejemplo n.º 8
0
OscarProtocol::OscarProtocol( const KComponentData &instance, QObject *parent, bool canAddMyself )
	: Kopete::Protocol( instance, parent, canAddMyself ),
	statusTitle(Kopete::Global::Properties::self()->statusTitle()),
	statusMessage(Kopete::Global::Properties::self()->statusMessage()),
	clientFeatures("clientFeatures", i18n("Client Features"), 0),
	buddyIconHash("iconHash", i18n("Buddy Icon MD5 Hash"), QString(), Kopete::PropertyTmpl::PersistentProperty | Kopete::PropertyTmpl::PrivateProperty),
	contactEncoding("contactEncoding", i18n("Contact Encoding"), QString(), Kopete::PropertyTmpl::PersistentProperty | Kopete::PropertyTmpl::PrivateProperty),
	memberSince("memberSince", i18n("Member Since"), QString(), 0),
	client("client", i18n("Client"), QString(), 0),
	protocolVersion("protocolVersion", i18n("Protocol Version"), QString(), 0)
{
	KConfigGroup config( KGlobal::config(), "OscarProtocol" );
	if ( config.hasKey( "StartFlapSequences" ) )
	{
		kWarning(OSCAR_GEN_DEBUG) << "Overriding default start flap sequence algorithm!";

		QList<Oscar::WORD> startFlapSequenceList;
		QList<int> flapSequenceList = config.readEntry( "StartFlapSequences", QList<int>() );
		foreach ( int flapSeq, flapSequenceList )
			startFlapSequenceList << flapSeq;

		Connection::setStartFlapSequenceList( startFlapSequenceList );
	}
Ejemplo n.º 9
0
Archivo: segment.cpp Proyecto: KDE/kget
void Segment::slotWriteRest()
{
    if (m_buffer.isEmpty()) {
        return;
    }
    kDebug() << this;

    if (writeBuffer()) {
        m_errorCount = 0;
        if (m_findFilesize) {
            emit finishedDownload(m_bytesWritten);
        }
        return;
    }

    if (++m_errorCount >= 100) {
        kWarning() << "Failed to write to the file:" << m_url << this;
        emit error(this, i18n("Failed to write to the file."), Transfer::Log_Error);
    } else {
        kDebug() << "Wait 50 msec:" << this;
        QTimer::singleShot(50, this, SLOT(slotWriteRest()));
    }
}
Ejemplo n.º 10
0
void KPrPicturesImport::import(KPrView *view)
{
    m_factory = KoShapeRegistry::instance()->value("PictureShape");
    Q_ASSERT(m_factory);
    if (m_factory) {
        m_urls = KFileDialog::getOpenUrls(KUrl(), "image/png image/jpeg image/gif");

        // TODO there should be a progress bar
        // instead of the progress bar opening for each loaded picture
        m_currentPage = view->activePage();
        KoPAPage *activePage = dynamic_cast<KoPAPage*>(m_currentPage);
        if (activePage) {
            m_masterPage = activePage->masterPage();

            m_doc = view->kprDocument();
            m_cmd = new KUndo2Command(kundo2_i18n("Insert Pictures"));
            import();
        }
    }
    else {
        kWarning(33001) << "picture shape factory not found";
    }
}
Ejemplo n.º 11
0
const QPixmap &KoTemplate::loadPicture()
{
    if (m_cached)
        return m_pixmap;
    m_cached = true;
    if (m_picture[ 0 ] == '/') {
        QImage img(m_picture);
        if (img.isNull()) {
            kWarning() << "Couldn't find icon " << m_picture;
            m_pixmap = QPixmap();
            return m_pixmap;
        }
        const int maxHeightWidth = 128; // ### TODO: some people would surely like to have 128x128
        if (img.width() > maxHeightWidth || img.height() > maxHeightWidth) {
            img = img.scaled(maxHeightWidth, maxHeightWidth, Qt::KeepAspectRatio, Qt::SmoothTransformation);
        }
        m_pixmap = QPixmap::fromImage(img);
        return m_pixmap;
    } else { // relative path
        m_pixmap = KIconLoader::global()->loadIcon(m_picture, KIconLoader::Desktop, 128);
        return m_pixmap;
    }
}
Ejemplo n.º 12
0
void KBuildSycocaProgressDialog::rebuildKSycoca(QWidget *parent)
{
  KBuildSycocaProgressDialog dlg(parent,
                                 i18n("Updating System Configuration"),
                                 i18n("Updating system configuration."));

  QDBusInterface kbuildsycoca("org.kde.kded", "/kbuildsycoca",
                              "org.kde.kbuildsycoca");
  if (kbuildsycoca.isValid()) {
     kbuildsycoca.callWithCallback("recreate", QVariantList(), &dlg, SLOT(_k_slotFinished()));
  } else {
      // kded not running, e.g. when using keditfiletype out of a KDE session
      QObject::connect(KSycoca::self(), SIGNAL(databaseChanged(QStringList)), &dlg, SLOT(_k_slotFinished()));
#ifndef EMSCRIPTEN
      KProcess* proc = new KProcess(&dlg);
      (*proc) << KStandardDirs::findExe(KBUILDSYCOCA_EXENAME);
      proc->start();
#else
      kWarning() << "Running " << KBUILDSYCOCA_EXENAME << " not supported in Emscripten!";
#endif
  }
  dlg.exec();
}
Ejemplo n.º 13
0
 //! Creates action for toggling to view mode @a mode. @a slot should have signature
 //! matching switchedTo(Kexi::ViewMode mode) signal.
 KexiToggleViewModeAction(Kexi::ViewMode mode, QObject* parent)
     : KAction(
         KIcon(Kexi::iconNameForViewMode(mode)),
         Kexi::nameForViewMode(mode, true/*withAmpersand*/),
         parent)
 {
     setCheckable(true);
     if (mode == Kexi::DataViewMode) {
         setObjectName("view_data_mode");
         setToolTip(i18n("Switch to data view"));
         setWhatsThis(i18n("Switches to data view."));
     } else if (mode == Kexi::DesignViewMode) {
         setObjectName("view_design_mode");
         setToolTip(i18n("Switch to design view"));
         setWhatsThis(i18n("Switches to design view."));
     } else if (mode == Kexi::TextViewMode) {
         setObjectName("view_text_mode");
         setToolTip(i18n("Switch to text view"));
         setWhatsThis(i18n("Switches to text view."));
     } else {
         kWarning() << "KexiToggleViewModeAction: invalid mode " << mode;
     }
 }
Ejemplo n.º 14
0
Plugin * PluginManager::loadPlugin( const QString &_pluginId, PluginLoadMode mode /* = LoadSync */ )
{
    QString pluginId = _pluginId;

    // Try to find legacy code
    // FIXME: Find any cases causing this, remove them, and remove this too - Richard
    if ( pluginId.endsWith( QLatin1String( ".desktop" ) ) )
    {
        kWarning() << "Trying to use old-style API!" << endl << kBacktrace();
        pluginId = pluginId.remove( QRegExp( QLatin1String( ".desktop$" ) ) );
    }

    if ( mode == LoadSync )
    {
        return loadPluginInternal( pluginId );
    }
    else
    {
        _kpmp->pluginsToLoad.push( pluginId );
        QTimer::singleShot( 0, this, SLOT( slotLoadNextPlugin() ) );
        return 0L;
    }
}
Ejemplo n.º 15
0
void PollingWatcher::addFactory(PollingPlayerFactory* factory)
{
    if (factory->exists()) {
        Player::Ptr player = factory->create();
        if (!player.isNull()) {
            m_players.insert(player);
            m_usedFactories.insert(factory);
            emit newPlayer(player);
        } else {
            kWarning() << "Failed to create a player";
            m_polledFactories.insert(factory);
        }
    } else {
        m_polledFactories.insert(factory);
    }

    if (!m_timer) {
        m_timer = new QTimer(this);
        m_timer->setInterval(5000);
        connect(m_timer, SIGNAL(timeout()), this, SLOT(checkPlayers()));
        m_timer->start();
    }
}
Ejemplo n.º 16
0
KoTextLoader::KoTextLoader(KoShapeLoadingContext &context)
        : QObject()
        , d(new Private(context))
{
    KoSharedLoadingData *sharedData = context.sharedData(KOTEXT_SHARED_LOADING_ID);
    if (sharedData) {
        d->textSharedData = dynamic_cast<KoTextSharedLoadingData *>(sharedData);
    }

    kDebug(32500) << "sharedData" << sharedData << "textSharedData" << d->textSharedData;

    if (!d->textSharedData) {
        d->textSharedData = new KoTextSharedLoadingData();
        // TODO pass style manager so that on copy and paste we can recognice the same styles
        d->textSharedData->loadOdfStyles(context.odfLoadingContext(), 0);
        if (!sharedData) {
            context.addSharedData(KOTEXT_SHARED_LOADING_ID, d->textSharedData);
        } else {
            kWarning(32500) << "A different type of sharedData was found under the" << KOTEXT_SHARED_LOADING_ID;
            Q_ASSERT(false);
        }
    }
}
boolean fill_input_buffer(j_decompress_ptr cinfo)
{
    my_source_mgr* src = (my_source_mgr*)cinfo->src;
    Q_ASSERT(src->inDevice);
    int readSize       = src->inDevice->read((char*)src->buffer, BUFFER_SIZE);
    if (readSize > 0)
    {
        src->pub.next_input_byte = src->buffer;
        src->pub.bytes_in_buffer = readSize;
    }
    else
    {
        /**
        * JPEG file is broken. We feed the decoder with fake EOI, as specified
        * in the libjpeg documentation.
        */
        static JOCTET fakeEOI[2] = { JOCTET(0xFF), JOCTET(JPEG_EOI)};
        kWarning() << "Image is incomplete";
        src->pub.next_input_byte = fakeEOI;
        src->pub.bytes_in_buffer = 2;
    }
    return true;
}
Ejemplo n.º 18
0
// Note: This method is one of the major rate determining factors in how fast the map pans / zooms in or out
void SkyPoint::updateCoords( KSNumbers *num, bool /*includePlanets*/, const dms *lat, const dms *LST, bool forceRecompute ) {
    //Correct the catalog coordinates for the time-dependent effects
    //of precession, nutation and aberration
    bool recompute, lens;

    // NOTE: The same short-circuiting checks are also implemented in
    // StarObject::JITUpdate(), even before calling
    // updateCoords(). While this is code-duplication, these bits of
    // code need to be really optimized, at least for stars. For
    // optimization purposes, the code is left duplicated in two
    // places. Please be wary of changing one without changing the
    // other.

    Q_ASSERT( isfinite( lastPrecessJD ) );

    if( Options::useRelativistic() && checkBendLight() ) {
        recompute = true;
        lens = true;
    }
    else {
        recompute = ( Options::alwaysRecomputeCoordinates() ||
                      ( lastPrecessJD - num->getJD() ) >= 0.0005 ||
                      (lastPrecessJD - num->getJD() ) <= -0.0005 || forceRecompute ); // 0.0005 solar days is less than a minute
        lens = false;
    }
    if( recompute ) {
        precess(num);
        nutate(num);
        if( lens )
            bendlight();
        aberrate(num);
        lastPrecessJD = num->getJD();
    }

    if ( lat || LST )
        kWarning() << i18n( "lat and LST parameters should only be used in KSPlanetBase objects." ) ;
}
Ejemplo n.º 19
0
void AdiumThemeView::addStatusMessage(const AdiumThemeStatusInfo& statusMessage)
{
    QString styleHtml;
    bool consecutiveMessage = false;
    bool willAddMoreContentObjects = false; // TODO Find out how this is used in Adium
    bool replaceLastContent = false; // TODO use this

    // statusMessage is const, we need a non-const one to append message classes
    AdiumThemeStatusInfo message(statusMessage);

    if (m_lastContent.type() == message.type() && !m_chatStyle->disableCombineConsecutive()) {
        consecutiveMessage = true;
        message.appendMessageClass(QLatin1String("consecutive"));
    }

    m_lastContent = AdiumThemeContentInfo(statusMessage.type());

    switch (message.type()) {
    case AdiumThemeMessageInfo::Status:
        styleHtml = m_chatStyle->getStatusHtml();
        break;
    case AdiumThemeMessageInfo::HistoryStatus:
        styleHtml = m_chatStyle->getStatusHistoryHtml();
        break;
    default:
        kWarning() << "Unexpected message type to addStatusMessage";
    }

    replaceStatusKeywords(styleHtml, message);

    AppendMode mode = appendMode(message,
                                 consecutiveMessage,
                                 willAddMoreContentObjects,
                                 replaceLastContent);

    appendMessage(styleHtml, mode);
}
Ejemplo n.º 20
0
KoStore* KoStore::createStore(QIODevice *device, Mode mode, const QByteArray & appIdentification, Backend backend)
{
    bool automatic = false;
    if (backend == Auto) {
        automatic = true;
        if (mode == KoStore::Write)
            backend = DefaultFormat;
        else {
            if (device->open(QIODevice::ReadOnly)) {
                backend = determineBackend(device);
                device->close();
            }
        }
    }
    switch (backend) {
    case Tar:
        return new KoTarStore(device, mode, appIdentification);
    case Directory:
        kError(30002) << "Can't create a Directory store for a memory buffer!" << endl;
        // fallback
    case Zip:
#ifdef QCA2
        if (automatic && mode == Read) {
            // When automatically detecting, this might as well be an encrypted file. We'll need to check anyway, so we'll just use the encrypted store.
            return new KoEncryptedStore(device, Read, appIdentification);
        }
#endif
        return new KoZipStore(device, mode, appIdentification);
#ifdef QCA2
    case Encrypted:
        return new KoEncryptedStore(device, mode, appIdentification);
#endif
    default:
        kWarning(30002) << "Unsupported backend requested for KoStore : " << backend;
        return 0;
    }
}
Ejemplo n.º 21
0
/**
 * update the start and end text for this ownedhierarchicalcodeblock.
 */
void XMLElementCodeBlock::updateContent ( )
{

    QString endLine = getNewLineEndingChars();

    QString nodeName = getNodeName();

    // Now update START/ENDING Text
    QString startText = '<' + nodeName;
    QString endText = "";

    UMLAttributeList * alist = getAttributeList();
    for (UMLAttribute *at = alist->first(); at; at=alist->next())
    {
        if(at->getInitialValue().isEmpty())
            kWarning()<<" XMLElementCodeBlock : cant print out attribute that lacks an initial value"<<endl;
        else {
            startText.append(" " +at->getName()+"=\"");
            startText.append(at->getInitialValue()+"\"");
        }
    }

    // now set close of starting/ending node, the style depending on whether we have child text or not
    if(getTextBlockList()->count())
    {
        startText.append(">");
        endText = "</" + nodeName + '>';
    } else {
        startText.append("/>");
        endText = "";
    }

    setStartText(startText);
    setEndText(endText);

}
void RecordItNowPluginManager::loadInfos(const QString &type)
{

    KConfig cfg("recorditnowrc");
    KConfigGroup pCfg(&cfg, "Plugins");

    KService::List offers = KServiceTypeTrader::self()->query(type);
    KService::List::const_iterator iter;

    for (iter = offers.begin(); iter < offers.end(); ++iter) {
        KService::Ptr service = *iter;
        KPluginInfo info(service);

        if (!info.isValid()) {
            kWarning() << "invalid plugin info:" << service->entryPath();
            continue;
        } else {
            info.setConfig(pCfg);
            info.load(pCfg);
            m_plugins[info] = 0;
        }
    }

}
Ejemplo n.º 23
0
bool KPrSoundEventAction::loadOdf( const KoXmlElement & element, KoShapeLoadingContext &context )
{
    KoXmlElement sound = KoXml::namedItemNS( element, KoXmlNS::presentation, "sound" );

    bool retval = false;

    if ( ! sound.isNull() ) {
        KPrSoundCollection *soundCollection = context.documentResourceManager()->resource(KPresenter::SoundCollection).value<KPrSoundCollection*>();

        if ( soundCollection ) {
            QString href = sound.attributeNS( KoXmlNS::xlink, "href" );
            if ( !href.isEmpty() ) {
                m_soundData = new KPrSoundData( soundCollection, href );
                retval = true;
            }
        }
        else {
            kWarning(33000) << "sound collection could not be found";
            Q_ASSERT( soundCollection );
        }
    }

    return retval;
}
Ejemplo n.º 24
0
QHash<QString, QVariant>  KSParser::DummyRow() {
    kWarning() << "File named " << filename_ << " encountered an error while reading";
    QHash<QString, QVariant> newRow;
    for (int i = 0; i < name_type_sequence_.length(); ++i) {
        switch (name_type_sequence_[i].second) {
        case D_QSTRING:
            newRow[name_type_sequence_[i].first] = EBROKEN_QSTRING;
            break;
        case D_DOUBLE:
            newRow[name_type_sequence_[i].first] = EBROKEN_DOUBLE;
            break;
        case D_INT:
            newRow[name_type_sequence_[i].first] = EBROKEN_INT;
            break;
        case D_FLOAT:
            newRow[name_type_sequence_[i].first] = EBROKEN_FLOAT;
            break;
        case D_SKIP:
        default:
            break;
        }
    }
    return newRow;
}
void KonqSidebarTree::loadModuleFactories()
{
    pluginFactories.clear();
    pluginInfo.clear();
    KStandardDirs *dirs=KGlobal::dirs();
    const QStringList list=dirs->findAllResources("data","konqsidebartng/dirtree/*.desktop",KStandardDirs::NoDuplicates);


    for (QStringList::ConstIterator it=list.begin(); it!=list.end(); ++it)
    {
        KConfig _ksc( *it, KConfig::SimpleConfig );
        KConfigGroup ksc(&_ksc, "Desktop Entry");
        QString name    = ksc.readEntry("X-KDE-TreeModule");
        QString libName = ksc.readEntry("X-KDE-TreeModule-Lib");
        if ((name.isEmpty()) || (libName.isEmpty()))
        {
            kWarning()<<"Bad Configuration file for a dirtree module "<<*it;
            continue;
        }

        //Register the library info.
        pluginInfo[name] = libName;
    }
}
Ejemplo n.º 26
0
void EditACLEntryDialog::slotOk()
{
    KACLListView::EntryType type = static_cast<KACLListView::EntryType>( m_buttonIds[m_buttonGroup->checkedButton()] );

    kWarning() << "Type 2: " << type;

    QString qualifier;
    if ( type == KACLListView::NamedUser )
        qualifier = m_usersCombo->currentText();
    if ( type == KACLListView::NamedGroup )
        qualifier = m_groupsCombo->currentText();

    if ( !m_item ) {
        m_item = new KACLListViewItem( m_listView, type, ACL_READ | ACL_WRITE | ACL_EXECUTE, false, qualifier );
    } else {
        m_item->type = type;
        m_item->qualifier = qualifier;
    }
    if ( m_defaultCB )
        m_item->isDefault = m_defaultCB->isChecked();
    m_item->repaint();

    KDialog::accept();
}
Ejemplo n.º 27
0
void OffsetImage::slotOffsetLayer()
{
    KisImageWSP image = m_view->image();
    if (image) {

    DlgOffsetImage * dlgOffsetImage = new DlgOffsetImage(m_view, "OffsetLayer", offsetWrapRect().size());
    Q_CHECK_PTR(dlgOffsetImage);

    QString actionName = i18n("Offset Layer");
    dlgOffsetImage->setCaption(actionName);

    if (dlgOffsetImage->exec() == QDialog::Accepted) {
        QPoint offsetPoint = QPoint(dlgOffsetImage->offsetX(), dlgOffsetImage->offsetY());
        KisNodeSP activeNode = m_view->activeNode();
        offsetImpl(actionName, activeNode, offsetPoint);
    }
    delete dlgOffsetImage;

    }
    else
    {
        kWarning() << "KisImage not available";
    }
}
Ejemplo n.º 28
0
QDomDocument Database::loadDataBase()
{
    kDebug() << "loading database: " << m_dbfile;
    QFile file(m_dbfile);
    QDomDocument document;

    if (!file.exists()) {
        if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
            QTextStream ts(&file);
            document.appendChild(document.createElement("projects"));
            ts << document.toString();
            file.close();
        }
    }
    
    if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
        if (!document.setContent(file.readAll()))
            kWarning() << file.fileName() << " is corrupted!";

        file.close();
    }

    return document;
}
Ejemplo n.º 29
0
    void renameImportedUrl(const KUrl& src)
    {
        KUrl dst = src;
        dst.cd("..");
        QString fileName;
        if (mFileNameFormater.get()) {
            KFileItem item(KFileItem::Unknown, KFileItem::Unknown, src, true /* delayedMimeTypes */);
            // Get the document time, but do not cache the result because the
            // 'src' url is temporary: if we import "foo/image.jpg" and
            // "bar/image.jpg", both images will be temporarily saved in the
            // 'src' url.
            KDateTime dateTime = TimeUtils::dateTimeForFileItem(item, TimeUtils::SkipCache);
            fileName = mFileNameFormater->format(src, dateTime);
        } else {
            fileName = src.fileName();
        }
        dst.setFileName(fileName);

        FileUtils::RenameResult result = FileUtils::rename(src, dst, mAuthWindow);
        switch (result) {
        case FileUtils::RenamedOK:
            mImportedUrlList << mCurrentUrl;
            break;
        case FileUtils::RenamedUnderNewName:
            mRenamedCount++;
            mImportedUrlList << mCurrentUrl;
            break;
        case FileUtils::Skipped:
            mSkippedUrlList << mCurrentUrl;
            break;
        case FileUtils::RenameFailed:
            kWarning() << "Rename failed for" << mCurrentUrl;
        }
        q->advance();
        importNext();
    }
Ejemplo n.º 30
0
KFileItem ProjectModel::itemForIndex(const QModelIndex& index) const
{
    if (!index.isValid())
    {
        //file item for root node.
        return m_poModel.itemForIndex(index);
    }
    QModelIndex poIndex = poIndexForOuter(index);
    QModelIndex potIndex = potIndexForOuter(index);

    if (poIndex.isValid())
        return m_poModel.itemForIndex(poIndex);
    else if (potIndex.isValid())
        return m_potModel.itemForIndex(potIndex);

    kWarning()<<"returning empty KFileItem()"<<index.row()<<index.column();
    kWarning()<<"returning empty KFileItem()"<<index.parent().isValid();
    kWarning()<<"returning empty KFileItem()"<<index.parent().internalPointer();
    kWarning()<<"returning empty KFileItem()"<<index.parent().data().toString();
    kWarning()<<"returning empty KFileItem()"<<index.internalPointer();
    kWarning()<<"returning empty KFileItem()"<<static_cast<ProjectNode*>(index.internalPointer())->untranslated<<static_cast<ProjectNode*>(index.internalPointer())->sourceDate;
    return KFileItem();
}