Example #1
0
/*
 *  Display new playlist dialog, write playlist name to playlists table
 */
void playlist::createNewPL(){

    pNewList = fileObj();
    pNewItems = fileObj();
    pNewList.initFile(10);
    pNewItems.initFile(20);

    plDialog.show();
    if(plDialog.exec()==QDialog::Accepted){
        pNewList.set(pNewList.getSize(), 0, 0, plDialog.getName().c_str());
        pNewList.setID(pNewList.getSize(), dbCon->writeDB(&pNewList, "playlists"));
    }
}
Example #2
0
int MainWindow::onExtractArchive(QString path)
{
   QByteArray pathArray = path.toUtf8();
   const char *file = pathArray.constData();
   file_archive_transfer_t state;
   struct archive_extract_userdata userdata;
   struct string_list *file_list = file_archive_get_file_list(file, NULL);
   bool returnerr = true;
   unsigned i;

   if (!file_list || file_list->size == 0)
   {
      showMessageBox("Error: Archive is empty.", MainWindow::MSGBOX_TYPE_ERROR, Qt::ApplicationModal, false);
      RARCH_ERR("[Qt]: Downloaded archive is empty?\n");
      return -1;
   }

   for (i = 0; i < file_list->size; i++)
   {
      QFile fileObj(file_list->elems[i].data);

      if (fileObj.exists())
      {
         if (!fileObj.remove())
         {
            /* if we cannot delete the existing file to update it, rename it for now and delete later */
            QFile fileTemp(fileObj.fileName() + TEMP_EXTENSION);

            if (fileTemp.exists())
            {
               if (!fileTemp.remove())
               {
                  showMessageBox(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_COULD_NOT_DELETE_FILE), MainWindow::MSGBOX_TYPE_ERROR, Qt::ApplicationModal, false);
                  RARCH_ERR("[Qt]: Could not delete file: %s\n", file_list->elems[i].data);
                  return -1;
               }
            }

            if (!fileObj.rename(fileTemp.fileName()))
            {
               showMessageBox(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_COULD_NOT_RENAME_FILE), MainWindow::MSGBOX_TYPE_ERROR, Qt::ApplicationModal, false);
               RARCH_ERR("[Qt]: Could not rename file: %s\n", file_list->elems[i].data);
               return -1;
            }
         }
      }
   }

   string_list_free(file_list);

   memset(&state, 0, sizeof(state));
   memset(&userdata, 0, sizeof(userdata));

   state.type = ARCHIVE_TRANSFER_INIT;

   m_updateProgressDialog->setWindowModality(Qt::NonModal);
   m_updateProgressDialog->setMinimumDuration(0);
   m_updateProgressDialog->setRange(0, 0);
   m_updateProgressDialog->setAutoClose(true);
   m_updateProgressDialog->setAutoReset(true);
   m_updateProgressDialog->setValue(0);
   m_updateProgressDialog->setLabelText(QString(msg_hash_to_str(MSG_EXTRACTING)) + "...");
   m_updateProgressDialog->setCancelButtonText(QString());
   m_updateProgressDialog->show();

   if (!task_push_decompress(file, ".",
            NULL, NULL, NULL,
            extractCB, this))
   {
      m_updateProgressDialog->cancel();
      return -1;
   }

   return returnerr;
}
Example #3
0
/*
 * Add to a current playlist
 */
void playlist::addToCurrent(int parid, string track, string path){
    pNewList = fileObj();
    pNewList.initFile(10);
    pNewList.set(0, 0, parid, track.c_str(), path.c_str());
    dbCon->writeDB(&pNewList, "playlist_items");
}
Example #4
0
/*
 * Add to new playlist object, insert into playlist_items table
 */
void playlist::addToNewPL(string track, string path){
    pNewItems = fileObj();
    pNewItems.initFile(10);
    pNewItems.set(pNewItems.getSize(), 0, pNewList.getID(pNewList.getSize()), track.c_str(), path.c_str());
    dbCon->writeDB(&pNewItems, "playlist_items");
}