void PlaylistWindow::savePlaylist() { //保存配置 QFile *playlistFile = new QFile("playlist.txt"); if (!playlistFile->open(QIODevice::WriteOnly | QIODevice::Text)){ qDebug() << "save playlist file failed" << endl; } QString playlistStr = "{\nplaylist:\n[\n"; for (int i = 0; i < listWidget->count(); i++) { QString listitem = "{\n"; QListWidgetItem *item = listWidget->item(i); if (item->whatsThis() == "") { //local file listitem += "\"is_local\":\"1\",\n"; listitem += "\"name\":\"" + QString(item->toolTip()) + "\"\n"; } else { listitem += "\"is_local\": \"0\",\n"; listitem += "\"name\":\"" + QString(item->toolTip()) + "\",\n"; listitem += "\"link\":\"" + QString(playlist->media(i).canonicalUrl().toString()) + "\",\n"; listitem += "\"id\":\"" + QString(item->whatsThis()) + "\"\n"; } listitem += "},\n"; playlistStr += listitem; } playlistStr += "]\n}"; playlistFile->write(playlistStr.toLocal8Bit()); playlistFile->close(); }
// ================= // PRIVATE SLOTS // ================= void DirWidget::startLoadThumbs(){ //This just runs through the dir and loads all the thumbnails as needed if(DEBUG){ qDebug() << "Start Loading Thumbnails:" << needThumbs; } if(needThumbs.isEmpty()){ return; } needThumbs.removeDuplicates(); //just in case //QTime updatetime = QTime::currentTime().addMSecs(500); for(int i=0; i<needThumbs.length() && !stopload; i++){ if(showDetails){ //Use the tree widget QList<QTreeWidgetItem*> items = treeWidget->findItems(needThumbs[i], Qt::MatchExactly); if(items.isEmpty()){ continue; } //invalid item for some reason if(stopload){ return; } //stop right now QTreeWidgetItem *it = items.first(); it->setIcon(0, QIcon( QPixmap(it->whatsThis(0).section("::::",1,100)).scaled(listWidget->iconSize(),Qt::IgnoreAspectRatio, Qt::FastTransformation) ) ); }else{ //Use the list widget QList<QListWidgetItem*> items = listWidget->findItems(needThumbs[i], Qt::MatchExactly); if(items.isEmpty()){ continue; } if(stopload){ return; } //stop right now QListWidgetItem *it = items.first(); it->setIcon(QIcon( QPixmap(it->whatsThis().section("::::",1,100)).scaled(listWidget->iconSize(),Qt::IgnoreAspectRatio, Qt::FastTransformation) ) ); } //if(QTime::currentTime() > updatetime){ QApplication::processEvents(); updatetime = QTime::currentTime().addMSecs(500); }//keep the UI snappy while loading a directory } }
void TodoDialog::on_newItemEdit_textChanged(const QString &arg1) { // search notes when at least 2 characters were entered if (arg1.count() >= 2) { QList<QString> noteNameList = CalendarItem::searchAsUidList( arg1, ui->todoListSelector->currentText()); firstVisibleTodoListRow = -1; for (int i = 0; i < ui->todoList->count(); ++i) { QListWidgetItem *item = ui->todoList->item(i); if (noteNameList.indexOf(item->whatsThis()) < 0) { item->setHidden(true); } else { if (firstVisibleTodoListRow < 0) { firstVisibleTodoListRow = i; } item->setHidden(false); } } } else { // show all items otherwise firstVisibleTodoListRow = 0; for (int i = 0; i < ui->todoList->count(); ++i) { QListWidgetItem *item = ui->todoList->item(i); item->setHidden(false); } } // let's highlight the text from the search line edit searchForSearchLineTextInNoteTextEdit(); }
/** * @brief Searches a todo item by uid in the todo list * @param uid * @return Returns the row of the todo item in the todo list, returns -1 if not found */ int TodoDialog::findTodoItemRowByUID(QString uid) { int count = ui->todoList->count(); if (count == 0) { return -1; } for (int i = 0; i < count; i++) { QListWidgetItem *item = ui->todoList->item(i); if (item->whatsThis() == uid) { return i; } } return -1; }
void ObjectExplorer::groupItemSelectionChanged() { for(int i=0; i<mObjectList->count(); i++){ mObjectList->item(i)->setHidden(true); } QString groupName; QListWidgetItem * item = nullptr; QList<QListWidgetItem *> items; items = mGroupList->selectedItems(); for(int i=0; i<items.size(); i++) { groupName = items.at(i)->text(); for(int j=0; j<mObjectList->count(); j++){ item = mObjectList->item(j); if(item->whatsThis() == groupName){ item->setHidden(false); } } } }
void MobileApp::downloadStart() { downloadsList.clear(); hashs.clear(); for (int i=0; i<ui->downloadListWidget->count(); i++) { QListWidgetItem *item = ui->downloadListWidget->item(i); if (item->checkState() == Qt::Checked) { //Generate download urls int n; if (ToNum(item->whatsThis(), &n)) { if (groups.size() > n) { for (int j=0; j<groups[n].books.size(); j++) { if (groups[n].books[j].needToDownload) { QString url = groups[n].books[j].URL; downloadsList << url; hashs << groups[n].books[j].hash; } } } } } } downloadNum = downloadsList.size(); ui->downloadInfo->toolTip() = ""; ui->downloadListWidget->setEnabled(false); ui->downloadBTN->setEnabled(false); // download the next file in downloadsList. downloadNext(); }