Skip to content

Commit

Permalink
fix files import
Browse files Browse the repository at this point in the history
  • Loading branch information
ctlcltd committed Jul 25, 2024
1 parent 0dc20df commit ca7c952
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 9 deletions.
65 changes: 57 additions & 8 deletions src/gui/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1352,7 +1352,7 @@ string gui::saveFileDialog(string path)
return nw_path;
}

vector<string> gui::importFileDialog(GUI_DPORTS gde)
vector<string> gui::importFileDialog(GUI_DPORTS gde, int& bit)
{
debug("importFileDialog");

Expand Down Expand Up @@ -1400,36 +1400,79 @@ vector<string> gui::importFileDialog(GUI_DPORTS gde)
opts.append(QString("%1 (*)").arg(tr("All Files", "file-dialog")));
break;
default:
//TODO TEST
//TODO improve
// fmode = QFileDialog::AnyFile;
// opts.append("Enigma2 folder (*)");
// opts.append("Neutrino folder (*)");
opts.append("Lamedb 2.4 (lamedb)");
opts.append("Lamedb 2.5 (lamedb5)");
opts.append("Lamedb 2.3 (services)");
opts.append("Lamedb 2.2 (services)");
opts.append("Enigma2 folder (*)");
opts.append("Userbouquet (userbouquet.*)");
opts.append("Bouquet (bouquets.*)");
opts.append("Bouquet epl (*.epl)");
opts.append("Userbouquet (userbouquet.*)");
opts.append("Parental lock blacklist (blacklist)");
opts.append("Parental lock whitelist (whitelist)");
opts.append("Parental lock services (services.locked)");
opts.append("Tuner settings (*.xml)");
opts.append("Neutrino Services (services.xml)");
opts.append("Neutrino folder (*)");
opts.append("Neutrino Bouquets (ubouquets.xml)");
opts.append("Neutrino api-1 Bouquets (bouquets.xml)");
opts.append("Parental lock blacklist (blacklist)");
opts.append("Parental lock whitelist (whitelist)");
opts.append("Parental lock services (services.locked)");
opts.append(QString("%1 (*)").arg(tr("All Files", "file-dialog")));
}

vector<string> paths;

QString selected;
QFileDialog fdial = QFileDialog(mwid, caption);
fdial.setAcceptMode(QFileDialog::AcceptOpen);
fdial.setFileMode(fmode);
fdial.setNameFilters(opts);
fdial.setLabelText(QFileDialog::Accept, tr("Import", "file-dialog"));
if (fdial.exec() == QDialog::Accepted)
{
selected = fdial.selectedNameFilter();

// straight copy of e2db_abstract::FPORTS
if (selected == "Enigma2 folder (*)")
bit = 0x0001;
else if (selected == "Neutrino folder (*)")
bit = 0x0001;
else if (selected == "Lamedb 2.4 (lamedb)")
bit = 0x1224;
else if (selected == "Lamedb 2.5 (lamedb5)")
bit = 0x1225;
else if (selected == "Lamedb 2.3 (services)")
bit = 0x1223;
else if (selected == "Lamedb 2.2 (services)")
bit = 0x1222;
else if (selected == "Neutrino default (services.xml)")
bit = 0x1010;
else if (selected == "Neutrino api-4 (services.xml)")
bit = 0x1014;
else if (selected == "Neutrino api-3 (services.xml)")
bit = 0x1013;
else if (selected == "Neutrino api-2 (services.xml)")
bit = 0x1012;
else if (selected == "Neutrino api-1 (services.xml)")
bit = 0x1011;
else if (selected == "Bouquet epl (*.epl)")
bit = 0x0020;
else if (selected == "Neutrino api-4 Bouquets (ubouquets.xml)")
bit = 0x4014;
else if (selected == "Neutrino api-3 Bouquets (ubouquets.xml)")
bit = 0x4013;
else if (selected == "Neutrino api-2 Bouquets (ubouquets.xml)")
bit = 0x4012;
else if (selected == "Neutrino api-1 Bouquets (bouquets.xml)")
bit = 0x4011;
else if (selected == "Parental lock blacklist (blacklist)")
bit = 0xfa;
else if (selected == "Parental lock whitelist (whitelist)")
bit = 0xfe;
else if (selected == "Parental lock services (services.locked)")
bit = 0xff;

for (QUrl & url : fdial.selectedUrls())
{
if (url.isLocalFile() || url.isEmpty())
Expand All @@ -1440,6 +1483,12 @@ vector<string> gui::importFileDialog(GUI_DPORTS gde)
return paths;
}

vector<string> gui::importFileDialog(GUI_DPORTS gde)
{
int bit = 0;
return importFileDialog(gde, bit);
}

string gui::exportFileDialog(GUI_DPORTS gde, string path, int& bit)
{
debug("exportFileDialog", "path", path);
Expand Down
1 change: 1 addition & 0 deletions src/gui/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ class gui : protected e2se::log_factory
void closeAllTabs();
string openFileDialog();
string saveFileDialog(string path);
vector<string> importFileDialog(gui::GUI_DPORTS gde, int& bit);
vector<string> importFileDialog(gui::GUI_DPORTS gde);
string exportFileDialog(GUI_DPORTS gde, string path, int& bit);
string exportFileDialog(GUI_DPORTS gde, string path);
Expand Down
14 changes: 13 additions & 1 deletion src/gui/tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,7 @@ void tab::importFile()
gui::TAB_VIEW current = getTabView();
gui::GUI_DPORTS gde = gui::GUI_DPORTS::AllFiles;
vector<string> paths;
int bit = -1;

// other views
if (current == gui::TAB_VIEW::picons || current == gui::TAB_VIEW::channelBook)
Expand All @@ -817,11 +818,22 @@ void tab::importFile()
return;
}

paths = gid->importFileDialog(gde);
paths = gid->importFileDialog(gde, bit);

if (paths.empty())
return;

// directories
if (bit == 0x0001)
{
for (string & path : paths)
{
path = std::filesystem::path(path).parent_path().u8string();
}

qDebug() << paths;
}

if (statusBarIsVisible())
{
string filename;
Expand Down

0 comments on commit ca7c952

Please sign in to comment.