void PropertiesWidget::loadTorrentInfos(BitTorrent::TorrentHandle *const torrent) { clear(); m_torrent = torrent; if (!m_torrent) return; // Save path updateSavePath(m_torrent); // Hash hash_lbl->setText(m_torrent->hash()); PropListModel->model()->clear(); if (m_torrent->hasMetadata()) { // Creation date lbl_creationDate->setText(m_torrent->creationDate().toString(Qt::DefaultLocaleShortDate)); label_total_size_val->setText(Utils::Misc::friendlyUnit(m_torrent->totalSize())); // Comment comment_text->setText(Utils::Misc::parseHtmlLinks(m_torrent->comment())); // URL seeds loadUrlSeeds(); label_created_by_val->setText(m_torrent->creator()); // List files in torrent PropListModel->model()->setupModelData(m_torrent->info()); filesList->setExpanded(PropListModel->index(0, 0), true); // Load file priorities PropListModel->model()->updateFilesPriorities(m_torrent->filePriorities()); } // Load dynamic data loadDynamicData(); }
int main(int argc, const char * argv[]) { FILE * revenue = NULL, * lost = NULL, * save = NULL; char * save_path = calloc(1, STRLEN), * bk = calloc(1, STRLEN); save_path = firstOpen_update(save); bk = strdup(save_path); if (save_path == '\0') updateSavePath(); else { revenue = fopen(strcat(save_path, "/revenue.json"), "r"); strcpy(save_path, bk); lost = fopen(strcat(bk, "/lost.json"), "r"); } createRevenueMovementList(revenue); createLostMovementList(lost); fclose(revenue); fclose(lost); strcpy(bk, save_path); getTotal(bk); selection(save_path); return 0; }
int selection(char * save_path) { char c; char * bk = calloc(1, STRLEN); while (1) { printf("dimmi cosa vuoi fare: 'a' per aggiungere, 'u' per aggiornare," " 'd' per eliminare, 'l' per visualizzare i movimenti, 's' per salvare i movimenti" " 'f' per modficare la cartella di salvataggio e 'e' per uscire\n"); scanf("%c", &c); getchar(); switch (c) { case 'f' : updateSavePath(); break; case 'a': printf("vuoi aggiungere un positivo (p) o un negativo (n)? \n"); scanf("%c", &c); getchar(); if (c == 'P' || c == 'p') { addNewRevenueMovement(); } if (c == 'n' || c == 'N') { addNewLostMovement(); } break; case 'u': printf("vuoi aggiornare un positivo (p) o un negativo (n)? \n"); scanf("%c", &c); getchar(); if (c == 'P' || c == 'p') { updateRevenue(); } if (c == 'n' || c == 'N') { updateLost(); } break; case 'd': printf("vuoi cancellare un positivo (p) o un negativo (n)? \n"); scanf("%c", &c); getchar(); if (c == 'P' || c == 'p') { deleteRevenue(); } if (c == 'n' || c == 'N') { deleteLost(); } break; case 'l': listAllMovements(); break; case 's': saveLostMovements(save_path); saveRevenueMovements(bk); break; case 'e': updateTotal(); bk = strdup(save_path); saveLostMovements(save_path); saveRevenueMovements(bk); freeRevenue(); freeLost(); printf("goodBye\n"); return 0; break; default: printf("comando non riconosciuto riprovare!!\n"); break; } } }