Ticket #4556: mythtv-special_storage_groups.patch

File mythtv-special_storage_groups.patch, 5.0 KB (added by sphery <mtdean@…>, 12 years ago)
  • libs/libmythtv/storagegroup.h

     
    2929    static void CheckAllStorageGroupDirs(void);
    3030
    3131    static const char *kDefaultStorageDir;
     32    static const QStringList kSpecialGroups;
    3233
    3334    static QStringList getRecordingsGroups(void);
    3435
  • libs/libmythtv/storagegroup.cpp

     
    1313
    1414const char *StorageGroup::kDefaultStorageDir = "/mnt/store";
    1515
     16const QStringList StorageGroup::kSpecialGroups = QStringList()
     17    << "LiveTV"
     18//    << "Thumbnails"
     19//    << "DB Backups"
     20    ;
     21
    1622/****************************************************************************/
    1723
    1824/** \brief StorageGroup constructor.
     
    289295
    290296    MSqlQuery query(MSqlQuery::InitCon());
    291297
    292     query.prepare("SELECT DISTINCT groupname "
     298    QString sql = "SELECT DISTINCT groupname "
    293299                  "FROM storagegroup "
    294                   ";");
    295 //                  "WHERE groupname NOT IN "
    296 //                      "('DB Backups', 'Thumbnails');");
     300                  "WHERE groupname NOT IN (";
     301    for (QStringList::const_iterator it = StorageGroup::kSpecialGroups.begin();
     302         it != StorageGroup::kSpecialGroups.end(); ++it)
     303        sql.append(QString(" '%1',").arg(*it));
     304    sql = sql.left(sql.length() - 1);
     305    sql.append(" );");
     306
     307    query.prepare(sql);
    297308    if (query.exec() && query.isActive() && query.size() > 0)
    298309        while (query.next())
    299310            groups += QString::fromUtf8(query.value(0).toString());
     
    351362
    352363    if (group == "Default")
    353364        dispGroup = QObject::tr("Default");
    354     else if (group == "LiveTV")
    355         dispGroup = QObject::tr("LiveTV");
     365    else if (StorageGroup::kSpecialGroups.contains(group))
     366        dispGroup = QObject::tr(group);
    356367
    357368    if (gContext->GetSetting("MasterServerIP","master") ==
    358369            gContext->GetSetting("BackendServerIP","me"))
     
    577588    QString dispGroup = name;
    578589    if (name == "Default")
    579590        dispGroup = QObject::tr("Default");
    580     else if (name == "LiveTV")
    581         dispGroup = QObject::tr("LiveTV");
     591    else if (StorageGroup::kSpecialGroups.contains(name))
     592        dispGroup = QObject::tr(name);
    582593
    583594    QString message = tr("Delete '%1' Storage Group?").arg(dispGroup);
    584595
     
    612623    QStringList names;
    613624    QStringList masterNames;
    614625    bool createAddDefaultButton = false;
    615     bool createAddLiveTVButton = false;
     626    bool createAddSpecialGroupButton[StorageGroup::kSpecialGroups.size()];
    616627    bool isMaster = (gContext->GetSetting("MasterServerIP","master") ==
    617628                     gContext->GetSetting("BackendServerIP","me"));
    618629
     
    653664    else
    654665        createAddDefaultButton = true;
    655666
    656     if (names.contains("LiveTV"))
    657         listbox->addSelection(QObject::tr("LiveTV"), "LiveTV");
    658     else
    659         createAddLiveTVButton = true;
     667    unsigned int curGroup = 0;
     668    QString groupName;
     669    while (curGroup < StorageGroup::kSpecialGroups.size())
     670    {
     671        groupName = StorageGroup::kSpecialGroups[curGroup];
     672        if (names.contains(groupName))
     673        {
     674            listbox->addSelection(QObject::tr(groupName), groupName);
     675            createAddSpecialGroupButton[curGroup] = false;
     676        }
     677        else
     678            createAddSpecialGroupButton[curGroup] = true;
     679        curGroup++;
     680    }
    660681
    661682    unsigned int curName = 0;
    662683    while (curName < names.size())
    663684    {
    664685        if ((names[curName] != "Default") &&
    665             (names[curName] != "LiveTV"))
     686            (!StorageGroup::kSpecialGroups.contains(names[curName])))
    666687            listbox->addSelection(names[curName]);
    667688        curName++;
    668689    }
     
    674695        lastValue = "Default";
    675696    }
    676697
    677     if (createAddLiveTVButton)
    678         listbox->addSelection(tr("(Create %1 group)").arg("LiveTV"),
    679             "__CREATE_NEW_STORAGE_GROUP__LiveTV");
     698    curGroup = 0;
     699    while (curGroup < StorageGroup::kSpecialGroups.size())
     700    {
     701        groupName = StorageGroup::kSpecialGroups[curGroup];
     702        if (createAddSpecialGroupButton[curGroup])
     703            listbox->addSelection(tr("(Create %1 group)").arg(groupName),
     704                QString("__CREATE_NEW_STORAGE_GROUP__%1").arg(groupName));
     705        curGroup++;
     706    }
    680707
    681708    if (isMaster)
    682709        listbox->addSelection(tr("(Create %1 group)").arg("new"),
     
    687714        while (curName < masterNames.size())
    688715        {
    689716            if ((masterNames[curName] != "Default") &&
    690                 (masterNames[curName] != "LiveTV") &&
     717                (!StorageGroup::kSpecialGroups.contains(masterNames[curName])) &&
    691718                (!names.contains(masterNames[curName])))
    692719                listbox->addSelection(tr("(Create %1 group)")
    693720                                         .arg(masterNames[curName]),