Ejemplo n.º 1
0
void ExtractOneVideoFrame::markShortVideo(const DB::FileName &fileName)
{
    if (s_tokenForShortVideos.isNull()) {
        Utilities::StringSet usedTokens = MainWindow::TokenEditor::tokensInUse().toSet();
        for ( int ch = 'A'; ch <= 'Z'; ++ch ) {
            QString token = QChar::fromLatin1( (char) ch );
            if (!usedTokens.contains(token)) {
                s_tokenForShortVideos = token;
                break;
            }
        }

        if (s_tokenForShortVideos.isNull()) {
            // Hmmm, no free token. OK lets just skip setting tokens.
            return;
        }
        KMessageBox::information(MainWindow::Window::theMainWindow(),
                                 i18n("Unable to extract video thumbnails from some files. "
                                      "Either the file is damaged in some way, or the video is ultra short. "
                                      "For your convenience, the token '%1' "
                                      "has been set on those videos.\n\n"
                                      "(You might need to wait till the video extraction led in your status bar has stopped blinking, "
                                      "to see all affected videos.)",
                                      s_tokenForShortVideos));
    }

    DB::ImageInfoPtr info = DB::ImageDB::instance()->info(fileName);
    DB::CategoryPtr tokensCategory = DB::ImageDB::instance()->categoryCollection()->categoryForSpecial(DB::Category::TokensCategory);
    info->addCategoryInfo(tokensCategory->name(), s_tokenForShortVideos);
    MainWindow::DirtyIndicator::markDirty();
}
Ejemplo n.º 2
0
void XMLDB::XMLCategoryCollection::addCategory( DB::CategoryPtr category )
{
    m_categories.append( category );
    if (category->isSpecialCategory())
    {
        m_specialCategories[category->type()] = category;
    }
    connect( category.data(), SIGNAL(changed()), this, SIGNAL(categoryCollectionChanged()) );
    connect( category.data(), SIGNAL(itemRemoved(QString)), this, SLOT(itemRemoved(QString)) );
    connect( category.data(), SIGNAL(itemRenamed(QString,QString)), this, SLOT(itemRenamed(QString,QString)) );
    emit categoryCollectionChanged();
}
void Settings::BirthdayPage::changeCategory(int index)
{
    m_lastItem = nullptr;
    m_dataView->clear();
    m_dataView->setSortingEnabled(false);
    m_dataView->setHorizontalHeaderLabels(QStringList() << i18n("Name") << i18n("Birthday"));

    const QString categoryName = m_categoryBox->itemText(index);
    const DB::CategoryPtr category = DB::ImageDB::instance()->categoryCollection()->categoryForName(categoryName);
    QStringList items = category->items();

    m_dataView->setRowCount(items.count());
    int row = 0;

    for (const QString& text : items) {
        if (! m_filter->text().isEmpty()
            && text.indexOf(m_filter->text(), 0, Qt::CaseInsensitive) == -1) {
            m_dataView->setRowCount(m_dataView->rowCount() - 1);
            continue;
        }

        QTableWidgetItem* nameItem = new QTableWidgetItem(text);
        nameItem->setFlags(nameItem->flags() & ~Qt::ItemIsEditable & ~Qt::ItemIsSelectable);
        m_dataView->setItem(row, 0, nameItem);

        QDate dateForItem;
        if (m_changedData.contains(categoryName)) {
            if (m_changedData[categoryName].contains(text)) {
                dateForItem = m_changedData[categoryName][text];
            } else {
                dateForItem = category->birthDate(text);
            }
        } else {
            dateForItem = category->birthDate(text);
        }

        DateTableWidgetItem* dateItem = new DateTableWidgetItem(textForDate(dateForItem));
        dateItem->setData(Qt::UserRole, dateForItem);
        dateItem->setFlags(dateItem->flags() & ~Qt::ItemIsEditable & ~Qt::ItemIsSelectable);
        m_dataView->setItem(row, 1, dateItem);

        row++;
    }

    m_dataView->setSortingEnabled(true);
    m_dataView->sortItems(0);

    disableCalendar();
}
void Settings::BirthdayPage::saveSettings()
{
    QMapIterator<QString, QMap<QString, QDate>> changedCategory(m_changedData);
    while (changedCategory.hasNext()) {
        changedCategory.next();
        DB::CategoryPtr category = DB::ImageDB::instance()->categoryCollection()
                                                          ->categoryForName(changedCategory.key());

        QMapIterator<QString, QDate> changedItem(changedCategory.value());
        while (changedItem.hasNext()) {
            changedItem.next();
            category->setBirthDate(changedItem.key(), changedItem.value());
        }
    }

    if (m_changedData.size() > 0) {
        MainWindow::DirtyIndicator::markDirty();
        m_changedData.clear();
    }
}
Ejemplo n.º 5
0
void XMLDB::FileWriter::saveCategories( QXmlStreamWriter& writer )
{
    QStringList categories = DB::ImageDB::instance()->categoryCollection()->categoryNames();
    ElementWriter dummy(writer, QString::fromLatin1("Categories") );

    DB::CategoryPtr tokensCategory = DB::ImageDB::instance()->categoryCollection()->categoryForSpecial( DB::Category::TokensCategory );
    for (QString name : categories) {
        DB::CategoryPtr category = DB::ImageDB::instance()->categoryCollection()->categoryForName(name);

        if (! shouldSaveCategory(name)) {
            continue;
        }

        ElementWriter dummy(writer, QString::fromUtf8("Category"));
        writer.writeAttribute(QString::fromUtf8("name"),  name);
        writer.writeAttribute(QString::fromUtf8("icon"), category->iconName());
        writer.writeAttribute(QString::fromUtf8("show"), QString::number(category->doShow()));
        writer.writeAttribute(QString::fromUtf8("viewtype"), QString::number(category->viewType()));
        writer.writeAttribute(QString::fromUtf8("thumbnailsize"), QString::number(category->thumbnailSize()));
        writer.writeAttribute(QString::fromUtf8("positionable"), QString::number(category->positionable()));
        if (category == tokensCategory) {
            writer.writeAttribute(QString::fromUtf8("meta"),QString::fromUtf8("tokens"));
        }

        // FIXME (l3u):
        // Correct me if I'm wrong, but we don't need this, as the tags used as groups are
        // added to the respective category anyway when they're created, so there's no need to
        // re-add them here. Apart from this, adding an empty group (one without members) does
        // add an empty tag ("") doing so.
        /*
        QStringList list =
                Utilities::mergeListsUniqly(category->items(),
                                            m_db->_members.groups(name));
        */

        Q_FOREACH(const QString &tagName, category->items()) {
            ElementWriter dummy( writer, QString::fromLatin1("value") );
            writer.writeAttribute( QString::fromLatin1("value"), tagName );
            writer.writeAttribute( QString::fromLatin1( "id" ),
                                    QString::number(static_cast<XMLCategory*>( category.data() )->idForName( tagName ) ));
            QDate birthDate = category->birthDate(tagName);
            if (!birthDate.isNull())
                writer.writeAttribute( QString::fromUtf8("birthDate"), birthDate.toString(Qt::ISODate) );
        }
    }
}
void Settings::CategoryItem::submit(DB::MemberMap* memberMap)
{
    if (m_categoryOrig.isNull()) {
        // New Item
        DB::ImageDB::instance()->categoryCollection()->addCategory(m_category,
                                                                   m_icon,
                                                                   m_type,
                                                                   m_thumbnailSize,
                                                                   true);
        MainWindow::DirtyIndicator::markDirty();
    } else {
        DB::CategoryPtr category = DB::ImageDB::instance()->categoryCollection()->categoryForName(m_categoryOrig);

        if (m_category != m_categoryOrig) {
            renameCategory(memberMap);
        }

        if (m_positionable != m_positionableOrig) {
            category->setPositionable(m_positionable);
        }

        if (m_icon != m_iconOrig) {
            category->setIconName(m_icon);
        }

        if (m_type != m_typeOrig) {
            category->setViewType(m_type);
        }

        if (m_thumbnailSize != m_thumbnailSizeOrig) {
            category->setThumbnailSize(m_thumbnailSize);
        }
    }

    m_categoryOrig = m_category;
    m_iconOrig = m_icon;
    m_typeOrig = m_typeOrig;
    m_thumbnailSizeOrig = m_thumbnailSize;
    m_positionableOrig = m_positionable;
}
void DB::ImageInfo::createFolderCategoryItem( DB::CategoryPtr folderCategory, DB::MemberMap& memberMap )
{
    QString folderName = Utilities::relativeFolderName( m_fileName.relative() );
    if ( folderName.isEmpty() )
        return;

    QStringList directories = folderName.split(QString::fromLatin1( "/" ) );

    QString curPath;
    for( QStringList::ConstIterator directoryIt = directories.constBegin(); directoryIt != directories.constEnd(); ++directoryIt ) {
        if ( curPath.isEmpty() )
            curPath = *directoryIt;
        else {
            QString oldPath = curPath;
            curPath = curPath + QString::fromLatin1( "/" ) + *directoryIt;
            memberMap.addMemberToGroup( folderCategory->name(), oldPath, curPath );
        }
    }

    m_categoryInfomation.insert( folderCategory->name() , StringSet() << folderName );
    folderCategory->addItem( folderName );
}
AnnotationDialog::ListSelect::ListSelect( const DB::CategoryPtr& category, QWidget* parent )
    : QWidget( parent ), m_category( category ), m_baseTitle( )
{
    QVBoxLayout* layout = new QVBoxLayout( this );

    m_lineEdit = new CompletableLineEdit( this );
    m_lineEdit->setProperty( "FocusCandidate", true );
    m_lineEdit->setProperty( "WantsFocus", true );
    m_lineEdit->setObjectName( category->name() );
    layout->addWidget( m_lineEdit );

    // PENDING(blackie) rename instance variable to something better than _listView
    m_treeWidget = new CategoryListView::DragableTreeWidget( m_category, this );
    m_treeWidget->setHeaderLabel( QString::fromLatin1( "items" ) );
    m_treeWidget->header()->hide();
    connect( m_treeWidget, SIGNAL(itemClicked(QTreeWidgetItem*,int)),  this,  SLOT(itemSelected(QTreeWidgetItem*)) );
    m_treeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
    connect( m_treeWidget, SIGNAL(customContextMenuRequested(QPoint)),
             this, SLOT(showContextMenu(QPoint)));
    connect( m_treeWidget, SIGNAL(itemsChanged()), this, SLOT(rePopulate()) );
    connect( m_treeWidget, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(updateSelectionCount()) );

    layout->addWidget( m_treeWidget );

    // Merge CheckBox
    QHBoxLayout* lay2 = new QHBoxLayout;
    layout->addLayout( lay2 );

    m_or = new QRadioButton( i18n("or"), this );
    m_and = new QRadioButton( i18n("and"), this );
    lay2->addWidget( m_or );
    lay2->addWidget( m_and );
    lay2->addStretch(1);

    // Sorting tool button
    QButtonGroup* grp = new QButtonGroup( this );
    grp->setExclusive( true );

    m_alphaTreeSort = new QToolButton;
    m_alphaTreeSort->setIcon( SmallIcon( QString::fromLatin1( "view-list-tree" ) ) );
    m_alphaTreeSort->setCheckable( true );
    m_alphaTreeSort->setToolTip( i18n("Sort Alphabetically (Tree)") );
    grp->addButton( m_alphaTreeSort );

    m_alphaFlatSort = new QToolButton;
    m_alphaFlatSort->setIcon( SmallIcon( QString::fromLatin1( "draw-text" ) ) );
    m_alphaFlatSort->setCheckable( true );
    m_alphaFlatSort->setToolTip( i18n("Sort Alphabetically (Flat)") );
    grp->addButton( m_alphaFlatSort );

    m_dateSort = new QToolButton;
    m_dateSort->setIcon( SmallIcon( QString::fromLatin1( "x-office-calendar" ) ) );
    m_dateSort->setCheckable( true );
    m_dateSort->setToolTip( i18n("Sort by date") );
    grp->addButton( m_dateSort );

    m_showSelectedOnly = new QToolButton;
    m_showSelectedOnly->setIcon( SmallIcon( QString::fromLatin1( "view-filter" ) ) );
    m_showSelectedOnly->setCheckable( true );
    m_showSelectedOnly->setToolTip( i18n("Show only selected Ctrl+S") );
    m_showSelectedOnly->setChecked( ShowSelectionOnlyManager::instance().selectionIsLimited() );

    m_alphaTreeSort->setChecked( Settings::SettingsData::instance()->viewSortType() == Settings::SortAlphaTree );
    m_alphaFlatSort->setChecked( Settings::SettingsData::instance()->viewSortType() == Settings::SortAlphaFlat );
    m_dateSort->setChecked( Settings::SettingsData::instance()->viewSortType() == Settings::SortLastUse );
    connect( m_dateSort, SIGNAL(clicked()), this, SLOT(slotSortDate()) );
    connect( m_alphaTreeSort, SIGNAL(clicked()), this, SLOT(slotSortAlphaTree()) );
    connect( m_alphaFlatSort, SIGNAL(clicked()), this, SLOT(slotSortAlphaFlat()) );
    connect( m_showSelectedOnly, SIGNAL(clicked()), &ShowSelectionOnlyManager::instance(), SLOT(toggle()) );

    lay2->addWidget( m_alphaTreeSort );
    lay2->addWidget( m_alphaFlatSort );
    lay2->addWidget( m_dateSort );
    lay2->addWidget( m_showSelectedOnly );

    m_lineEdit->setListView( m_treeWidget );

    connect( m_lineEdit, SIGNAL(returnPressed(QString)),  this,  SLOT(slotReturn()) );

    populate();

    connect( Settings::SettingsData::instance(), SIGNAL(viewSortTypeChanged(Settings::ViewSortType)),
             this, SLOT(setViewSortType(Settings::ViewSortType)) );
    connect( Settings::SettingsData::instance(), SIGNAL(matchTypeChanged(AnnotationDialog::MatchType)),
             this, SLOT(updateListview()) );

    connect( &ShowSelectionOnlyManager::instance(), SIGNAL(limitToSelected()), this, SLOT(limitToSelection()) );
    connect( &ShowSelectionOnlyManager::instance(), SIGNAL(broaden()), this, SLOT(showAllChildren()) );
}
Ejemplo n.º 9
0
 Q_FOREACH( DB::CategoryPtr categoryPtr, m_categories ) {
     static_cast<XMLCategory*>(categoryPtr.data())->initIdMap();
 }