Continued work on TXT file import.
This commit is contained in:
parent
5b9b031150
commit
d1b423ae18
@ -102,7 +102,7 @@ void FormStandardImportExport::selectFile() {
|
||||
|
||||
void FormStandardImportExport::selectExportFile() {
|
||||
QString filter_opml20 = tr("OPML 2.0 files (*.opml)");
|
||||
QString filter_txt_url_per_line = tr("TXT files (one URL per line) (.txt)");
|
||||
QString filter_txt_url_per_line = tr("TXT files (one URL per line) (*.txt)");
|
||||
|
||||
QString filter;
|
||||
QString selected_filter;
|
||||
@ -139,7 +139,7 @@ void FormStandardImportExport::selectExportFile() {
|
||||
|
||||
void FormStandardImportExport::selectImportFile() {
|
||||
QString filter_opml20 = tr("OPML 2.0 files (*.opml)");
|
||||
QString filter_txt_url_per_line = tr("TXT files (one URL per line) (.txt)");
|
||||
QString filter_txt_url_per_line = tr("TXT files (one URL per line) (*.txt)");
|
||||
|
||||
QString filter;
|
||||
QString selected_filter;
|
||||
@ -187,8 +187,13 @@ void FormStandardImportExport::parseImportFile(const QString &file_name) {
|
||||
break;
|
||||
|
||||
case TXTUrlPerLine:
|
||||
// TODO: TODO
|
||||
//parsing_result = m_model->importAsTxtURLPerLine(input_data);
|
||||
parsing_result = m_model->importAsTxtURLPerLine(input_data);
|
||||
break;
|
||||
|
||||
// TODO: V celém kódu nově zavést pořádně všude const, i v lokálních metodových proměnných
|
||||
|
||||
// TODO: Kompletně nahradit všechny ukazatele za QScopedPointer tak,
|
||||
// aby se nikde v kodu nevolalo delete či deleteLater().
|
||||
|
||||
default:
|
||||
return;
|
||||
|
@ -200,7 +200,6 @@ bool FeedsImportExportModel::importAsOPML20(const QByteArray &data) {
|
||||
new_feed->setUrl(feed_url);
|
||||
new_feed->setCreationDate(QDateTime::currentDateTime());
|
||||
new_feed->setIcon(feed_icon.isNull() ? qApp->icons()->fromTheme(QSL("folder-feed")) : feed_icon);
|
||||
new_feed->setAutoUpdateType(StandardFeed::DefaultAutoUpdate);
|
||||
|
||||
if (feed_type == QL1S("RSS1")) {
|
||||
new_feed->setType(StandardFeed::Rdf);
|
||||
@ -264,6 +263,30 @@ bool FeedsImportExportModel::exportToTxtURLPerLine(QByteArray &result) {
|
||||
}
|
||||
|
||||
bool FeedsImportExportModel::importAsTxtURLPerLine(const QByteArray &data) {
|
||||
StandardServiceRoot *root_item = new StandardServiceRoot();
|
||||
|
||||
foreach (const QByteArray &url, data.split('\n')) {
|
||||
if (!url.isEmpty()) {
|
||||
|
||||
StandardFeed *feed = new StandardFeed();
|
||||
|
||||
// TODO: co guessovat ten feed?
|
||||
|
||||
feed->setUrl(url);
|
||||
feed->setTitle(url);
|
||||
feed->setCreationDate(QDateTime::currentDateTime());
|
||||
feed->setIcon(qApp->icons()->fromTheme(QSL("folder-feed")));
|
||||
feed->setEncoding(DEFAULT_FEED_ENCODING);
|
||||
|
||||
root_item->appendChild(feed);
|
||||
}
|
||||
}
|
||||
|
||||
// Now, XML is processed and we have result in form of pointer item structure.
|
||||
emit layoutAboutToBeChanged();
|
||||
setRootItem(root_item);
|
||||
emit layoutChanged();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user