Exemplo n.º 1
0
void WmWidget::slotApplyTitle()
{
    kDebug() << "ApplyTitle";

    QString givenTitle = title();
    QString imageTitle;
    QString number;
    QString originalExtension;
    QString currentExtension;
    KUrl::List urls;
    QMap<QString, QString> imageMetaData;
    QList<QTreeWidgetItem*> selectedItems = d->imgList->listView()->selectedItems();
    QStringList parts;

    const int minLength = givenTitle.count("#");

    // Build the list of items to rename
    for (int i = 0; i < selectedItems.size(); ++i)
    {
        KPImagesListViewItem* l_item = dynamic_cast<KPImagesListViewItem*>(selectedItems.at(i));
        urls.append(l_item->url());
    }

    for (int i = 0; i < urls.size(); ++i)
    {
        imageMetaData = d->imagesDescInfo[urls.at(i).path()];
        imageTitle = givenTitle;

        // If there is at least one #, replace it the correct number
        if(minLength > 0)
        {
            parts = imageTitle.split("#", QString::KeepEmptyParts);
            imageTitle = parts.first().append("#").append(parts.last());
            number = QString::number(i + 1);
            while (number.length() < minLength)
            {
                number.prepend("0");
            }
            imageTitle.replace(imageTitle.indexOf("#"), 1, number);
        }

        // Add original extension if removed
        currentExtension = imageTitle.split('.').last();
        originalExtension = urls.at(i).path().split('.').last();
        if(QString::compare(currentExtension, originalExtension, Qt::CaseInsensitive) != 0)
        {
            imageTitle.append(".").append(originalExtension);
            d->titleEdit->setText(imageTitle);
        }

        kDebug() << urls.at(i).path() << "renamed to" << imageTitle;
        imageMetaData["title"] = imageTitle;
        d->imagesDescInfo[urls.at(i).path()] = imageMetaData;
    }
}
Exemplo n.º 2
0
void WmWidget::loadImageInfoFirstLoad()
{
    KUrl::List urls = d->imgList->imageUrls(false);

    QString title;
    QString date;
    QString description;
    QString currentCategories;
    QString latitude;
    QString longitude;

    for(int j = 0; j < urls.size(); j++)
    {
        KPImageInfo info(urls.at(j).path());
        QStringList keywar = info.keywords();
        date               = info.date().toString(Qt::ISODate);
        date               = date.replace("T", " ", Qt::CaseSensitive);
        title              = info.name();
        description        = info.title();
        currentCategories  = "";

        for( int i = 0; i < keywar.size(); i++)
        {
            if(i == keywar.size()-1)
            {
                currentCategories.append(keywar.at(i));
            }
            else
            {
                currentCategories.append(keywar.at(i)).append("\n");
            }
        }

        if(info.hasLatitude())
        {
            latitude = QString::number(info.latitude());
        }

        if(info.hasLongitude())
        {
            longitude = QString::number(info.longitude());
        }

        QMap<QString, QString> imageMetaData;
        imageMetaData["title"]       = title;
        imageMetaData["date"]        = date;
        imageMetaData["categories"]  = currentCategories;
        imageMetaData["description"] = description;
        imageMetaData["latitude"]    = latitude;
        imageMetaData["longitude"]   = longitude;
        d->imagesDescInfo.insert(urls.at(j).path(), imageMetaData);
    }
}
Exemplo n.º 3
0
void PlaylistModel::sort(int column, Qt::SortOrder order)
{
    if (m_tracks.count() < 2)
    {
        return;
    }

    QMultiMap<QString, KUrl> keyMap;
    QMultiMap<qint64, KUrl> durationMap;
    KUrl::List tracks;
    const KUrl url = m_tracks.value(m_currentTrack);

    if (column == DurationColumn)
    {
        for (int i = 0; i < m_tracks.count(); ++i)
        {
            durationMap.insert(MetaDataManager::duration(m_tracks.at(i)), m_tracks.at(i));
        }

        tracks = durationMap.values();
    }
    else if (column > FileNameColumn && column < DurationColumn)
    {
        const MetaDataKey key = translateColumn(column);

        for (int i = 0; i < m_tracks.count(); ++i)
        {
            keyMap.insert(MetaDataManager::metaData(m_tracks.at(i), key), m_tracks.at(i));
        }

        tracks = keyMap.values();
    }
    else
    {
        for (int i = 0; i < m_tracks.count(); ++i)
        {
            keyMap.insert(m_tracks.at(i).pathOrUrl(), m_tracks.at(i));
        }

        tracks = keyMap.values();
    }

    if (order == Qt::AscendingOrder)
    {
        KUrl::List items;

        for (int i = (tracks.count() - 1); i >= 0; --i)
        {
            items.append(tracks.at(i));
        }

        tracks = items;
    }

    m_tracks = tracks;

    setCurrentTrack(findTrack(url));

    emit tracksChanged();
}
Exemplo n.º 4
0
void PlaylistModel::processedTracks(const KUrl::List &tracks, int position, PlayerReaction reaction)
{
    for (int i = (tracks.count() - 1); i >= 0; --i)
    {
        m_tracks.insert(position, tracks.at(i));
    }

    if (reaction == PlayReaction)
    {
        setCurrentTrack(position, reaction);
    }
    else if (position <= m_currentTrack)
    {
        if (m_tracks.count() == tracks.count())
        {
            setCurrentTrack(0, reaction);
        }
        else
        {
            setCurrentTrack(qMin((m_currentTrack + tracks.count()), (m_tracks.count() - 1)), reaction);
        }
    }

    MetaDataManager::resolveTracks(tracks);

    emit tracksChanged();
    emit modified();
}
Exemplo n.º 5
0
QMap <QString,QMap <QString,QString> > WmWidget::allImagesDesc()
{
    KUrl::List urls = d->imgList->imageUrls(false);

    for (int i = 0; i < urls.size(); ++i)
    {

        QMap<QString, QString> imageMetaData = d->imagesDescInfo[urls.at(i).path()];
        imageMetaData["author"]              = author();
        imageMetaData["source"]              = source();
        imageMetaData["license"]             = license();
        imageMetaData["genCategories"]       = genCategories();
        imageMetaData["genText"]             = genText();
        d->imagesDescInfo[urls.at(i).path()] = imageMetaData;
    }

    return d->imagesDescInfo;
}
Exemplo n.º 6
0
void WmWidget::slotApplyImagesDesc(){

    //-- enregistrement des edit dans la map

    KUrl::List urls;
    QList<QTreeWidgetItem *> selectedItems=m_imgList->listView()->selectedItems();

    for (int i = 0; i < selectedItems.size(); ++i){
        KPImagesListViewItem* l_item = dynamic_cast<KPImagesListViewItem*>(selectedItems.at(i));
    urls.append(l_item->url());
    }

    for (int i = 0; i < urls.size(); ++i)
    {

        QMap<QString, QString> imageMetaData;
        imageMetaData = m_imagesDescInfo[urls.at(i).path()];

        if(m_titleCheck->isChecked()){
            QString url = urls.at(i).path().split('/').last();
            url = title();
            if(url.split('.').last().isEmpty()){
                url = url +"."+urls.at(i).path().split('.').last();
                m_titleEdit->setText(url);
            }
            kDebug()<<" Url in the if "<<url;
            imageMetaData["title"]   = url;
            kDebug()<<" Url after if "<<url;
        }

        if(m_dateCheck->isChecked()){
            imageMetaData["time"] = date();
        }
        if(m_categoryCheck->isChecked()){
            imageMetaData["categories"] = categories();
        }
        if(m_descCheck->isChecked()){
            imageMetaData["description"] = description();
        }
        m_imagesDescInfo[urls.at(i).path()]=imageMetaData;

    }

}
Exemplo n.º 7
0
void WmWidget::slotApplyLongitude()
{
    KUrl::List urls;
    QList<QTreeWidgetItem*> selectedItems = d->imgList->listView()->selectedItems();

    for (int i = 0; i < selectedItems.size(); ++i)
    {
        KPImagesListViewItem* l_item = dynamic_cast<KPImagesListViewItem*>(selectedItems.at(i));
        urls.append(l_item->url());
    }

    for (int i = 0; i < urls.size(); ++i)
    {
        QMap<QString, QString> imageMetaData;
        imageMetaData                       = d->imagesDescInfo[urls.at(i).path()];
        imageMetaData["longitude"]          = longitude();
        d->imagesDescInfo[urls.at(i).path()] = imageMetaData;
    }
}
Exemplo n.º 8
0
QMap <QString,QMap <QString,QString> > WmWidget::allImagesDesc()
{

    KUrl::List urls = m_imgList->imageUrls(false);


    for (int i = 0; i < urls.size(); ++i)
    {

        QMap<QString, QString> imageMetaData = m_imagesDescInfo[urls.at(i).path()];

            imageMetaData["author"] = author();
            imageMetaData["license"] = license();

        m_imagesDescInfo[urls.at(i).path()]=imageMetaData;

    }

    return m_imagesDescInfo;
}
Exemplo n.º 9
0
void WMWindow::slotStartTransfer()
{
    saveSettings();
    KUrl::List urls = iface()->currentSelection().images();


    QMap <QString,QMap <QString,QString> > imagesDesc=m_widget->allImagesDesc();


    for (int i = 0; i < urls.size(); ++i)
    {

        QString caption;
        QString url;
        if(m_widget->resize()){

            prepareImageForUpload(urls.at(i).path(), caption);

            ;
            imagesDesc.insert(m_tmpPath, imagesDesc.take(urls.at(i).path()));

        }
    }

    m_uploadJob->setImageMap(imagesDesc);

    m_widget->progressBar()->setRange(0, 100);
    m_widget->progressBar()->setValue(0);

    connect(m_uploadJob, SIGNAL(uploadProgress(int)),
            m_widget->progressBar(), SLOT(setValue(int)));

    connect(m_uploadJob, SIGNAL(endUpload()),
            this, SLOT(slotEndUpload()));

    m_widget->progressBar()->show();
    m_widget->progressBar()->progressScheduled(i18n("Wiki Export"), true, true);
    m_widget->progressBar()->progressThumbnailChanged(KIcon("kipi").pixmap(22, 22));
    m_uploadJob->begin();
}
Exemplo n.º 10
0
void SpellCheck::dropEvent(QGraphicsSceneDragDropEvent *event)
{
    if (m_dragTimer) {
        killTimer(m_dragTimer);
    }

    if (!KUrl::List::canDecode(event->mimeData())) {
        if (event->mimeData()->hasText()) {
            if (!m_spellingDialog || !m_spellingDialog->isVisible()) {
                toggleDialog(false);
            }

            m_textEdit->setText(event->mimeData()->text());

            event->accept();
        } else {
            event->ignore();
        }

        return;
    }

    if (!m_spellingDialog || !m_spellingDialog->isVisible()) {
        toggleDialog(false);

        m_textEdit->clear();
    }

    KUrl::List droppedUrls = KUrl::List::fromMimeData(event->mimeData());
    QTextCursor cursor = m_textEdit->textCursor();

    for (int i = 0; i < droppedUrls.count(); ++i) {
        QFile file(droppedUrls.at(i).toLocalFile());

        if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
            QTextStream contents(file.readAll());
            contents.setAutoDetectUnicode(true);

            cursor.insertText(contents.readAll());
        }

        file.close();
    }

    event->accept();
}
Exemplo n.º 11
0
void SoundtrackDialog::slotSoundFilesButtonSave()
{
    QPointer<KFileDialog> dlg = new KFileDialog(QString(), QString(), this);
    dlg->setOperationMode(KFileDialog::Saving);
    dlg->setMode(KFile::File);
    dlg->setFilter(QString("*.m3u|Playlist (*.m3u)"));
    dlg->setWindowTitle(i18n("Save playlist"));

    if (dlg->exec() != KFileDialog::Accepted)
    {
	delete dlg;
        return;
    }

    QString filename = dlg->selectedFile();

    if (!filename.isEmpty())
    {
        QFile file(filename);
        if (file.open(QIODevice::WriteOnly|QIODevice::Text))
        {
            QTextStream out(&file);
            KUrl::List playlistFiles = m_SoundFilesListBox->fileUrls();

            for (int i = 0; i < playlistFiles.count(); ++i)
            {
                KUrl fUrl(playlistFiles.at(i));
                if (fUrl.isValid())
                {
                    if (fUrl.isLocalFile())
                    {
                        out << fUrl.toLocalFile() << endl;
                    }
                }
            }
            file.close();
        }
    }

    delete dlg;
}