void MythBrowser::slotLoadStarted(void) { MythUIButtonListItem *item = m_pageList->GetItemCurrent(); if (item) item->SetText(tr("Loading...")); }
void MythUIFileBrowser::updateLocalFileList() { QDir d; d.setPath(m_subDirectory); d.setNameFilters(m_nameFilter); d.setFilter(m_typeFilter); d.setSorting(QDir::Name | QDir::DirsFirst | QDir::IgnoreCase); if (!d.exists()) { LOG(VB_GENERAL, LOG_ERR, "MythUIFileBrowser: current directory does not exist!"); m_locationEdit->SetText("/"); m_subDirectory = "/"; d.setPath("/"); } QFileInfoList list = d.entryInfoList(); bool showBackButton = false; if (list.isEmpty()) { MythUIButtonListItem *item = new MythUIButtonListItem(m_fileList, tr("Parent Directory")); item->DisplayState("upfolder", "nodetype"); } else { QFileInfoList::const_iterator it = list.begin(); const QFileInfo *fi; while (it != list.end()) { fi = &(*it); MFileInfo finfo(fi->filePath()); if (finfo.fileName() == ".") { ++it; continue; } QString displayName = finfo.fileName(); QString type; if (displayName == "..") { if (m_subDirectory.endsWith("/")) { ++it; continue; } displayName = tr("Parent"); type = "upfolder"; showBackButton = true; } else if (finfo.isDir()) { type = "folder"; } else if (finfo.isExecutable()) { type = "executable"; } else if (finfo.isFile()) { type = "file"; } MythUIButtonListItem *item = new MythUIButtonListItem(m_fileList, displayName, qVariantFromValue(finfo)); if (IsImage(finfo.suffix())) { item->SetImage(finfo.absoluteFilePath()); type = "image"; } item->SetText(FormatSize(finfo.size()), "filesize"); item->SetText(finfo.absoluteFilePath(), "fullpath"); item->DisplayState(type, "nodetype"); ++it; } } if (m_backButton) m_backButton->SetEnabled(showBackButton); m_locationEdit->SetText(m_subDirectory); }
void MythBurn::updateArchiveList(void) { QString message = tr("Retrieving File Information. Please Wait..."); MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack"); MythUIBusyDialog *busyPopup = new MythUIBusyDialog(message, popupStack, "mythburnbusydialog"); if (busyPopup->Create()) popupStack->AddScreen(busyPopup, false); else { delete busyPopup; busyPopup = NULL; } qApp->processEvents(); m_archiveButtonList->Reset(); if (m_archiveList.size() == 0) { m_nofilesText->Show(); } else { ArchiveItem *a; for (int x = 0; x < m_archiveList.size(); x++) { qApp->processEvents(); a = m_archiveList.at(x); // get duration of this file if (a->duration == 0) { if (!getFileDetails(a)) LOG(VB_GENERAL, LOG_ERR, QString("MythBurn: failed to get file details for: %1").arg(a->filename)); } // get default encoding profile if needed if (a->encoderProfile == NULL) a->encoderProfile = getDefaultProfile(a); recalcItemSize(a); MythUIButtonListItem* item = new MythUIButtonListItem(m_archiveButtonList, a->title); item->SetData(qVariantFromValue(a)); item->SetText(a->subtitle, "subtitle"); item->SetText(a->startDate + " " + a->startTime, "date"); item->SetText(formatSize(a->newsize / 1024, 2), "size"); if (a->hasCutlist) { if (a->useCutlist) { item->SetText(tr("Using Cut List"), "cutlist"); item->DisplayState("using", "cutliststatus"); } else { item->SetText(tr("Not Using Cut List"), "cutlist"); item->DisplayState("notusing", "cutliststatus"); } } else { item->SetText(tr("No Cut List"), "cutlist"); item->DisplayState("none", "cutliststatus"); } item->SetText(tr("Encoder: ") + a->encoderProfile->name, "profile"); } m_nofilesText->Hide(); m_archiveButtonList->SetItemCurrent( m_archiveButtonList->GetItemFirst()); } updateSizeBar(); if (busyPopup) busyPopup->Close(); }
void FileSelector::updateFileList() { if (!m_fileButtonList) return; m_fileButtonList->Reset(); while (!m_fileData.isEmpty()) delete m_fileData.takeFirst(); m_fileData.clear(); QDir d; d.setPath(m_curDirectory); if (d.exists()) { // first get a list of directory's in the current directory QStringList filters; filters << "*"; QFileInfoList list = d.entryInfoList(filters, QDir::Dirs, QDir::Name); QFileInfo fi; for (int x = 0; x < list.size(); x++) { fi = list.at(x); if (fi.fileName() != ".") { FileData *data = new FileData; data->selected = false; data->directory = true; data->filename = fi.fileName(); data->size = 0; m_fileData.append(data); // add a row to the MythUIButtonList MythUIButtonListItem* item = new MythUIButtonListItem(m_fileButtonList, data->filename); item->setCheckable(false); item->SetImage("ma_folder.png"); item->SetData(qVariantFromValue(data)); } } if (m_selectorType != FSTYPE_DIRECTORY) { // second get a list of file's in the current directory filters.clear(); filters = m_filemask.split(" ", QString::SkipEmptyParts); list = d.entryInfoList(filters, QDir::Files, QDir::Name); for (int x = 0; x < list.size(); x++) { fi = list.at(x); FileData *data = new FileData; data->selected = false; data->directory = false; data->filename = fi.fileName(); data->size = fi.size(); m_fileData.append(data); // add a row to the UIListBtnArea MythUIButtonListItem* item = new MythUIButtonListItem(m_fileButtonList, data->filename); item->SetText(formatSize(data->size / 1024, 2), "size"); if (m_selectorType == FSTYPE_FILELIST) { item->setCheckable(true); QString fullPath = m_curDirectory; if (!fullPath.endsWith("/")) fullPath += "/"; fullPath += data->filename; if (m_selectedList.indexOf(fullPath) != -1) { item->setChecked(MythUIButtonListItem::FullChecked); } else { item->setChecked(MythUIButtonListItem::NotChecked); } } else item->setCheckable(false); item->SetData(qVariantFromValue(data)); } } m_locationEdit->SetText(m_curDirectory); } else { m_locationEdit->SetText("/"); LOG(VB_GENERAL, LOG_ERR, "MythArchive: current directory does not exist!"); } }
void MythUIFileBrowser::updateRemoteFileList() { QStringList sgdirlist; QString sgdir; QStringList slist; if (!m_baseDirectory.endsWith("/")) m_baseDirectory.append("/"); QString dirURL = QString("%1%2").arg(m_baseDirectory) .arg(m_subDirectory); if (!GetRemoteFileList(m_baseDirectory, sgdir, sgdirlist)) { LOG(VB_GENERAL, LOG_ERR, "GetRemoteFileList failed to get " "Storage Group dirs"); return; } if ((sgdirlist.size() == 1) && (sgdirlist[0].startsWith("sgdir::"))) { QStringList tokens = sgdirlist[0].split("::"); m_storageGroupDir = tokens[1]; } if (!GetRemoteFileList(dirURL, m_storageGroupDir, slist)) { LOG(VB_GENERAL, LOG_ERR, QString("GetRemoteFileList failed for '%1' in '%2' SG dir") .arg(dirURL).arg(m_storageGroupDir)); return; } m_locationEdit->SetText(dirURL); QString displayName; QString dataName; QString type; if ((sgdirlist.size() > 1 && !m_storageGroupDir.isEmpty()) || (!m_subDirectory.isEmpty())) { displayName = tr("Parent"); type = "upfolder"; m_parentDir = m_baseDirectory; if (!m_subDirectory.isEmpty()) { m_parentDir += "/" + m_subDirectory; int pos = m_parentDir.lastIndexOf('/'); if (pos > 0) m_parentDir = m_parentDir.left(pos); } MFileInfo finfo(m_parentDir, m_storageGroupDir, true); m_parentSGDir = m_storageGroupDir; if (m_subDirectory.isEmpty() && m_parentDir == m_baseDirectory) { finfo.setSGDir(""); m_parentSGDir = ""; } MythUIButtonListItem *item = new MythUIButtonListItem( m_fileList, displayName, qVariantFromValue(finfo)); item->SetText(QString("0"), "filesize"); item->SetText(m_parentDir, "fullpath"); item->DisplayState(type, "nodetype"); if (m_backButton) m_backButton->SetEnabled(true); } else { if (m_backButton) m_backButton->SetEnabled(false); } QStringList::const_iterator it = slist.begin(); while (it != slist.end()) { QStringList tokens = (*it).split("::"); if (tokens.size() < 2) { LOG(VB_GENERAL, LOG_ERR, QString("failed to parse '%1'.").arg(*it)); ++it; continue; } displayName = tokens[1]; if (tokens[0] == "sgdir") dataName = m_baseDirectory; else if (m_subDirectory.isEmpty()) dataName = QString("%1%2").arg(m_baseDirectory) .arg(displayName); else dataName = QString("%1%2/%3").arg(m_baseDirectory) .arg(m_subDirectory).arg(displayName); MFileInfo finfo(dataName, m_storageGroupDir); if ((tokens[0] == "dir") && (m_typeFilter & (QDir::Dirs | QDir::AllDirs))) { type = "folder"; finfo.setIsDir(true); finfo.setSGDir(m_storageGroupDir); finfo.setSize(0); } else if ((tokens[0] == "sgdir") && (m_typeFilter & (QDir::Dirs | QDir::AllDirs))) { type = "folder"; finfo.setIsDir(true); finfo.setSGDir(displayName); finfo.setSize(0); } else if ((tokens[0] == "file") && (m_typeFilter & QDir::Files)) { finfo.setIsDir(false); finfo.setSize(tokens[2].toInt()); if (IsImage(finfo.suffix())) type = "image"; else type = "file"; } else { // unknown type or filtered out ++it; continue; } MythUIButtonListItem *item = new MythUIButtonListItem(m_fileList, displayName, qVariantFromValue(finfo)); if (finfo.size()) item->SetText(FormatSize(finfo.size()), "filesize"); if (type == "image") item->SetImage(dataName); item->SetText(dataName, "fullpath"); item->DisplayState(type, "nodetype"); ++it; } }
void ChannelEditor::fillList(void) { QString currentValue = m_channelList->GetValue(); uint currentIndex = qMax(m_channelList->GetCurrentPos(), 0); m_channelList->Reset(); QString newchanlabel = tr("(Add New Channel)"); MythUIButtonListItem *item = new MythUIButtonListItem(m_channelList, ""); item->SetText(newchanlabel, "compoundname"); item->SetText(newchanlabel, "name"); bool fAllSources = true; QString querystr = "SELECT channel.name,channum,chanid,callsign,icon," "visible ,videosource.name FROM channel " "LEFT JOIN videosource ON " "(channel.sourceid = videosource.sourceid) "; if (m_sourceFilter == FILTER_ALL) { fAllSources = true; } else { querystr += QString(" WHERE channel.sourceid='%1' ") .arg(m_sourceFilter); fAllSources = false; } if (m_currentSortMode == tr("Channel Name")) { querystr += " ORDER BY channel.name"; } else if (m_currentSortMode == tr("Channel Number")) { querystr += " ORDER BY channum + 0"; } MSqlQuery query(MSqlQuery::InitCon()); query.prepare(querystr); uint selidx = 0, idx = 1; if (query.exec() && query.size() > 0) { for (; query.next() ; idx++) { QString name = query.value(0).toString(); QString channum = query.value(1).toString(); QString chanid = query.value(2).toString(); QString callsign = query.value(3).toString(); QString icon = query.value(4).toString(); bool visible = query.value(5).toBool(); QString sourceid = "Unassigned"; QString state = "normal"; if (!visible) state = "disabled"; if (!query.value(6).toString().isEmpty()) { sourceid = query.value(6).toString(); if (fAllSources && m_sourceFilter == FILTER_UNASSIGNED) continue; } else state = "warning"; if (channum.isEmpty() && m_currentHideMode) continue; if (name.isEmpty()) name = "(Unnamed : " + chanid + ")"; QString compoundname = name; if (m_currentSortMode == tr("Channel Name")) { if (!channum.isEmpty()) compoundname += " (" + channum + ")"; } else if (m_currentSortMode == tr("Channel Number")) { if (!channum.isEmpty()) compoundname = channum + ". " + compoundname; else compoundname = "???. " + compoundname; } if (m_sourceFilter == FILTER_ALL) compoundname += " (" + sourceid + ")"; bool sel = (chanid == currentValue); selidx = (sel) ? idx : selidx; item = new MythUIButtonListItem(m_channelList, "", qVariantFromValue(chanid)); item->SetText(compoundname, "compoundname"); item->SetText(name, "name"); item->SetText(channum, "channum"); item->SetText(chanid, "chanid"); item->SetText(callsign, "callsign"); item->SetText(sourceid, "sourcename"); item->SetImage(icon); item->SetImage(icon, "icon"); item->DisplayState(state, "status"); } } // Make sure we select the current item, or the following one after // deletion, with wrap around to "(New Channel)" after deleting last item. m_channelList->SetItemCurrent((!selidx && currentIndex < idx) ? currentIndex : selidx); }
void RecordingSelector::updateRecordingList(void) { if (!m_recordingList || m_recordingList->empty()) return; m_recordingButtonList->Reset(); if (m_categorySelector) { ProgramInfo *p; vector<ProgramInfo *>::iterator i = m_recordingList->begin(); for ( ; i != m_recordingList->end(); ++i) { p = *i; if (p->GetTitle() == m_categorySelector->GetValue() || m_categorySelector->GetValue() == tr("All Recordings")) { MythUIButtonListItem* item = new MythUIButtonListItem( m_recordingButtonList, p->GetTitle() + " ~ " + p->GetScheduledStartTime().toLocalTime() .toString("dd MMM yy (hh:mm)")); item->setCheckable(true); if (m_selectedList.indexOf((ProgramInfo *) p) != -1) { item->setChecked(MythUIButtonListItem::FullChecked); } else { item->setChecked(MythUIButtonListItem::NotChecked); } QString title = p->GetTitle(); QString subtitle = p->GetSubtitle(); QDateTime recstartts = p->GetScheduledStartTime(); QDateTime recendts = p->GetScheduledEndTime(); QString timedate = QString("%1 - %2") .arg(MythDate::toString(recstartts,MythDate::kDateTimeFull)) .arg(MythDate::toString(recendts, MythDate::kTime)); uint season = p->GetSeason(); uint episode = p->GetEpisode(); QString seasone, seasonx; if (season && episode) { seasone = QString("s%1e%2") .arg(format_season_and_episode(season, 2)) .arg(format_season_and_episode(episode, 2)); seasonx = QString("%1x%2") .arg(format_season_and_episode(season, 1)) .arg(format_season_and_episode(episode, 2)); } item->SetText(title, "title"); item->SetText(subtitle, "subtitle"); if (subtitle.isEmpty()) item->SetText(title, "titlesubtitle"); else item->SetText(title + " - \"" + subtitle + '"', "titlesubtitle"); item->SetText(timedate, "timedate"); item->SetText(p->GetDescription(), "description"); item->SetText(formatSize(p->GetFilesize() / 1024), "filesize_str"); item->SetText(QString::number(season), "season"); item->SetText(QString::number(episode), "episode"); item->SetText(seasonx, "00x00"); item->SetText(seasone, "s00e00"); item->DisplayState(p->HasCutlist() ? "yes" : "no", "cutlist"); item->SetData(qVariantFromValue(p)); } qApp->processEvents(); } } m_recordingButtonList->SetItemCurrent(m_recordingButtonList->GetItemFirst()); titleChanged(m_recordingButtonList->GetItemCurrent()); }
bool ImportIconsWizard::search(const QString& strParam) { QString strParam1 = QUrl::toPercentEncoding(strParam); bool retVal = false; enableControls(STATE_SEARCHING); QUrl url(m_url+"/search"); CSVEntry entry2 = (*m_missingIter); QString channelcsv = QString("%1,%2,%3,%4,%5,%6,%7,%8\n") .arg(escape_csv(entry2.strName)) .arg(escape_csv(entry2.strXmlTvId)) .arg(escape_csv(entry2.strCallsign)) .arg(escape_csv(entry2.strTransportId)) .arg(escape_csv(entry2.strAtscMajorChan)) .arg(escape_csv(entry2.strAtscMinorChan)) .arg(escape_csv(entry2.strNetworkId)) .arg(escape_csv(entry2.strServiceId)); QString message = QObject::tr("Searching for icons for channel %1") .arg(entry2.strName); OpenBusyPopup(message); QString str = wget(url,"s="+strParam1+"&csv="+channelcsv); m_listSearch.clear(); m_iconsList->Reset(); if (str.isEmpty() || str.startsWith("#") || str.startsWith("Error", Qt::CaseInsensitive)) { LOG(VB_GENERAL, LOG_ERR, QString("Error from search : %1").arg(str)); retVal = false; } else { LOG(VB_CHANNEL, LOG_INFO, QString("Icon Import: Working search : %1").arg(str)); QStringList strSplit = str.split("\n"); // HACK HACK HACK -- begin // This is needed since the user can't escape out of the progress dialog // and the result set may contain thousands of channels. if (strSplit.size() > 36*3) { LOG(VB_GENERAL, LOG_WARNING, QString("Warning: Result set contains %1 items, " "truncating to the first %2 results") .arg(strSplit.size()).arg(18*3)); while (strSplit.size() > 18*3) strSplit.removeLast(); } // HACK HACK HACK -- end QString prevIconName; int namei = 1; for (int x = 0; x < strSplit.size(); ++x) { QString row = strSplit[x]; if (row != "#" ) { QStringList ret = extract_csv(row); LOG(VB_CHANNEL, LOG_INFO, QString("Icon Import: search : %1 %2 %3") .arg(ret[0]).arg(ret[1]).arg(ret[2])); SearchEntry entry; entry.strID = ret[0]; entry.strName = ret[1]; entry.strLogo = ret[2]; m_listSearch.append(entry); MythUIButtonListItem *item; if (prevIconName == entry.strName) { QString newname = QString("%1 (%2)").arg(entry.strName) .arg(namei); item = new MythUIButtonListItem(m_iconsList, newname, qVariantFromValue(entry)); namei++; } else { item = new MythUIButtonListItem(m_iconsList, entry.strName, qVariantFromValue(entry)); namei=1; } QString iconname = entry.strName; item->SetImage(entry.strLogo, "icon", false); item->SetText(iconname, "iconname"); prevIconName = entry.strName; } } retVal = true; } enableControls(STATE_NORMAL, retVal); CloseBusyPopup(); return retVal; }
void IconView::customEvent(QEvent *event) { if (event->type() == ThumbGenEvent::kEventType) { ThumbGenEvent *tge = dynamic_cast<ThumbGenEvent *>(event); if (!tge) return; ThumbData *td = tge->thumbData; if (!td) return; ThumbItem *thumbitem = m_itemHash.value(td->fileName); if (thumbitem) { int rotateAngle = thumbitem->GetRotationAngle(); if (rotateAngle) { QMatrix matrix; matrix.rotate(rotateAngle); td->thumb = td->thumb.transformed( matrix, Qt::SmoothTransformation); } int pos = m_itemList.indexOf(thumbitem); LoadThumbnail(thumbitem); MythUIButtonListItem *item = m_imageList->GetItemAt(pos); if (QFile(thumbitem->GetImageFilename()).exists()) item->SetImage(thumbitem->GetImageFilename()); if (m_imageList->GetCurrentPos() == pos) UpdateImage(item); } delete td; } else if (event->type() == ChildCountEvent::kEventType) { ChildCountEvent *cce = dynamic_cast<ChildCountEvent *>(event); if (!cce) return; ChildCountData *ccd = cce->childCountData; if (!ccd) return; ThumbItem *thumbitem = m_itemHash.value(ccd->fileName); if (thumbitem) { int pos = m_itemList.indexOf(thumbitem); MythUIButtonListItem *item = m_imageList->GetItemAt(pos); if (item) item->SetText(QString("%1").arg(ccd->count), "childcount"); } delete ccd; } else if (event->type() == DialogCompletionEvent::kEventType) { DialogCompletionEvent *dce = (DialogCompletionEvent*)(event); QString resultid = dce->GetId(); int buttonnum = dce->GetResult(); if (resultid == "mainmenu") { switch (buttonnum) { case 0: HandleSlideShow(); break; case 1: HandleRandomShow(); break; case 2: break; case 3: break; case 4: HandleSubMenuFilter(); break; case 5: break; case 6: HandleSettings(); break; } } else if (resultid == "metadatamenu") { switch (buttonnum) { case 0: HandleRotateCW(); break; case 1: HandleRotateCCW(); break; } } else if (resultid == "markingmenu") { switch (buttonnum) { case 0: HandleSelectOne(); break; case 1: HandleClearOneMarked(); break; case 2: HandleSelectAll(); break; case 3: HandleClearMarked(); break; } } else if (resultid == "filemenu") { switch (buttonnum) { case 0: HandleShowDevices(); break; case 1: HandleEject(); break; case 2: HandleImport(); break; case 3: HandleCopyHere(); break; case 4: HandleMoveHere(); break; case 5: HandleDelete(); break; case 6: HandleMkDir(); break; case 7: HandleRename(); break; } } m_menuPopup = NULL; } }
void MythBrowser::slotTitleChanged(const QString &title) { MythUIButtonListItem *item = m_pageList->GetItemCurrent(); if (item) item->SetText(title); }