2018-11-04 09:48:33 -05:00
|
|
|
/*******************************************************************************
|
|
|
|
* plugins/FeedReader/gui/PreviewFeedDialog.cpp *
|
|
|
|
* *
|
|
|
|
* Copyright (C) 2012 by Thunder <retroshare.project@gmail.com> *
|
|
|
|
* *
|
|
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU Affero General Public License as *
|
|
|
|
* published by the Free Software Foundation, either version 3 of the *
|
|
|
|
* License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU Affero General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Affero General Public License *
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
|
|
|
* *
|
|
|
|
*******************************************************************************/
|
2012-08-13 17:35:11 -04:00
|
|
|
|
2012-09-04 19:53:04 -04:00
|
|
|
//#include <QPainter>
|
|
|
|
#include <QMenu>
|
|
|
|
#include <QKeyEvent>
|
2012-08-13 17:35:11 -04:00
|
|
|
|
|
|
|
#include "PreviewFeedDialog.h"
|
|
|
|
#include "ui_PreviewFeedDialog.h"
|
|
|
|
#include "FeedReaderNotify.h"
|
|
|
|
#include "FeedReaderStringDefs.h"
|
|
|
|
#include "util/HandleRichText.h"
|
2012-09-04 19:53:04 -04:00
|
|
|
#include "gui/settings/rsharesettings.h"
|
2012-08-13 17:35:11 -04:00
|
|
|
|
|
|
|
#include "retroshare/rsiface.h"
|
|
|
|
#include "util/HTMLWrapper.h"
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
// not yet functional
|
|
|
|
//PreviewItemDelegate::PreviewItemDelegate(QTreeWidget *parent) : QItemDelegate(parent)
|
|
|
|
//{
|
|
|
|
// connect(parent->header(), SIGNAL(sectionResized(int,int,int)), SLOT(sectionResized(int,int,int)));
|
|
|
|
//}
|
|
|
|
|
|
|
|
//void PreviewItemDelegate::sectionResized(int logicalIndex, int /*oldSize*/, int /*newSize*/)
|
|
|
|
//{
|
|
|
|
// QHeaderView *header = dynamic_cast<QHeaderView*>(sender());
|
|
|
|
// if (header) {
|
|
|
|
// QTreeWidget *treeWidget = dynamic_cast<QTreeWidget*>(header->parent());
|
|
|
|
// if (treeWidget) {
|
|
|
|
// QModelIndex index = treeWidget->model()->index(0, logicalIndex, QModelIndex());
|
|
|
|
// emit sizeHintChanged(index);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
|
|
|
|
//void PreviewItemDelegate::drawDisplay(QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect, const QString &text) const
|
|
|
|
//{
|
|
|
|
// QPen pen(painter->pen());
|
|
|
|
// QFont font(painter->font());
|
|
|
|
// QPalette::ColorGroup colorgroup(option.state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled);
|
|
|
|
|
|
|
|
// QTextOption textOption;
|
|
|
|
// textOption.setWrapMode(QTextOption::WrapAnywhere);
|
|
|
|
// textOption.setAlignment(option.displayAlignment);
|
|
|
|
|
|
|
|
// QRect textRect = rect.adjusted(5, 0, -5, 0); // remove width padding
|
|
|
|
// textRect.setTop(qMin(rect.top(), option.rect.top()));
|
|
|
|
// textRect.setHeight(qMax(rect.height(), option.rect.height()));
|
|
|
|
|
|
|
|
// if (option.state & QStyle::State_Selected) {
|
|
|
|
// painter->fillRect(rect, option.palette.brush(colorgroup, QPalette::Highlight));
|
|
|
|
// painter->setPen(option.palette.color(colorgroup, QPalette::HighlightedText));
|
|
|
|
// } else {
|
|
|
|
// painter->setPen(option.palette.color(colorgroup, QPalette::Text));
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (option.state & QStyle::State_Editing) {
|
|
|
|
// painter->save();
|
|
|
|
// painter->setPen(option.palette.color(colorgroup, QPalette::Text));
|
|
|
|
// painter->drawRect(rect.adjusted( 0, 0, -1, -1));
|
|
|
|
// painter->restore();
|
|
|
|
// }
|
|
|
|
|
|
|
|
// painter->setFont(option.font);
|
|
|
|
// painter->drawText(textRect, text, textOption);
|
|
|
|
|
|
|
|
// // reset painter
|
|
|
|
// painter->setFont(font);
|
|
|
|
// painter->setPen(pen);
|
|
|
|
//}
|
|
|
|
|
|
|
|
//void PreviewItemDelegate::drawFocus(QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect) const
|
|
|
|
//{
|
|
|
|
// if (option.state & QStyle::State_HasFocus) {
|
|
|
|
// QRect textRect(rect);
|
|
|
|
// textRect.setTop(qMin(rect.top(), option.rect.top()));
|
|
|
|
// textRect.setHeight(qMax(rect.height(), option.rect.height()));
|
|
|
|
|
|
|
|
// QStyleOptionFocusRect optionFocusRect;
|
|
|
|
// optionFocusRect.QStyleOption::operator=(option);
|
|
|
|
// optionFocusRect.rect = textRect;
|
|
|
|
// optionFocusRect.state |= QStyle::State_KeyboardFocusChange;
|
|
|
|
// QPalette::ColorGroup colorgroup = (option.state & QStyle::State_Enabled) ? QPalette::Normal : QPalette::Disabled;
|
|
|
|
// optionFocusRect.backgroundColor = option.palette.color(colorgroup, (option.state & QStyle::State_Selected) ? QPalette::Highlight : QPalette::Background);
|
|
|
|
// QApplication::style()->drawPrimitive(QStyle::PE_FrameFocusRect, &optionFocusRect, painter);
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
|
|
|
|
//QSize PreviewItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
|
|
|
|
//{
|
|
|
|
//// static bool inSizeHint = false;
|
|
|
|
|
|
|
|
//// if (inSizeHint) {
|
|
|
|
//// return QSize();
|
|
|
|
//// }
|
|
|
|
//// inSizeHint = true;
|
|
|
|
|
|
|
|
// //d->viewport->width()
|
|
|
|
// QSize size = QItemDelegate::sizeHint(option, index);
|
|
|
|
// size.setHeight(50);
|
|
|
|
|
|
|
|
//// QTreeWidget *treeWidget = dynamic_cast<QTreeWidget*>(parent());
|
|
|
|
//// if (treeWidget) {
|
|
|
|
//// size.setWidth(treeWidget->header()->sectionSize(index.column()));
|
|
|
|
|
|
|
|
//// QString text = index.data(Qt::DisplayRole).toString();
|
|
|
|
//// QRect displayRect = textRectangle(NULL, QRect(0, 0, size.width(), size.height()), option.font, text);
|
|
|
|
//// QRect displayRect = treeWidget->visualRect(index);
|
|
|
|
//// int width = treeWidget->columnWidth(index.column());
|
|
|
|
//// int height = option.fontMetrics.boundingRect(QRect(0, 0, size.width(), 0), Qt::TextWrapAnywhere | Qt::TextLongestVariant, text).height();
|
|
|
|
|
|
|
|
//// if (height > size.height()) {
|
|
|
|
//// size.setHeight(height);
|
|
|
|
//// }
|
|
|
|
//// }
|
|
|
|
|
|
|
|
//// inSizeHint = false;
|
|
|
|
|
|
|
|
// return size;
|
|
|
|
//}
|
|
|
|
|
|
|
|
PreviewFeedDialog::PreviewFeedDialog(RsFeedReader *feedReader, FeedReaderNotify *notify, const FeedInfo &feedInfo, QWidget *parent) :
|
2012-09-04 19:53:04 -04:00
|
|
|
QDialog(parent, Qt::Window), mFeedReader(feedReader), mNotify(notify), ui(new Ui::PreviewFeedDialog)
|
2012-08-13 17:35:11 -04:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
2020-11-08 07:22:59 -05:00
|
|
|
mFeedId = 0;
|
|
|
|
|
2012-08-13 17:35:11 -04:00
|
|
|
ui->feedNameLabel->clear();
|
|
|
|
|
|
|
|
/* connect signals */
|
|
|
|
connect(ui->previousPushButton, SIGNAL(clicked()), this, SLOT(previousMsg()));
|
|
|
|
connect(ui->nextPushButton, SIGNAL(clicked()), this, SLOT(nextMsg()));
|
2013-01-21 19:11:43 -05:00
|
|
|
connect(ui->structureButton, SIGNAL(toggled(bool)), this, SLOT(showStructureFrame()));
|
2012-09-04 19:53:04 -04:00
|
|
|
connect(ui->xpathUseListWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(xpathListCustomPopupMenu(QPoint)));
|
|
|
|
connect(ui->xpathRemoveListWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(xpathListCustomPopupMenu(QPoint)));
|
|
|
|
connect(ui->xpathUseListWidget->itemDelegate(), SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)), this, SLOT(xpathCloseEditor(QWidget*,QAbstractItemDelegate::EndEditHint)));
|
|
|
|
connect(ui->xpathRemoveListWidget->itemDelegate(), SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)), this, SLOT(xpathCloseEditor(QWidget*,QAbstractItemDelegate::EndEditHint)));
|
2013-01-21 19:11:43 -05:00
|
|
|
connect(ui->transformationTypeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(transformationTypeChanged()));
|
2012-08-13 17:35:11 -04:00
|
|
|
|
2020-11-08 07:22:59 -05:00
|
|
|
connect(mNotify, &FeedReaderNotify::feedChanged, this, &PreviewFeedDialog::feedChanged, Qt::QueuedConnection);
|
|
|
|
connect(mNotify, &FeedReaderNotify::msgChanged, this, &PreviewFeedDialog::msgChanged, Qt::QueuedConnection);
|
2012-08-13 17:35:11 -04:00
|
|
|
|
2013-01-21 19:11:43 -05:00
|
|
|
ui->transformationTypeComboBox->addItem(FeedReaderStringDefs::transforationTypeString(RS_FEED_TRANSFORMATION_TYPE_NONE), RS_FEED_TRANSFORMATION_TYPE_NONE);
|
|
|
|
ui->transformationTypeComboBox->addItem(FeedReaderStringDefs::transforationTypeString(RS_FEED_TRANSFORMATION_TYPE_XPATH), RS_FEED_TRANSFORMATION_TYPE_XPATH);
|
|
|
|
ui->transformationTypeComboBox->addItem(FeedReaderStringDefs::transforationTypeString(RS_FEED_TRANSFORMATION_TYPE_XSLT), RS_FEED_TRANSFORMATION_TYPE_XSLT);
|
|
|
|
|
|
|
|
ui->xsltTextEdit->setPlaceholderText(tr("XSLT is used on focus lost or when Ctrl+Enter is pressed"));
|
|
|
|
|
2012-08-13 17:35:11 -04:00
|
|
|
// ui->documentTreeWidget->setItemDelegate(new PreviewItemDelegate(ui->documentTreeWidget));
|
2013-01-21 19:11:43 -05:00
|
|
|
showStructureFrame();
|
|
|
|
|
|
|
|
/* Set initial size the splitter */
|
|
|
|
// QList<int> sizes;
|
|
|
|
// sizes << 300 << 300 << 150; // Qt calculates the right sizes
|
|
|
|
// ui->splitter->setSizes(sizes);
|
2012-08-13 17:35:11 -04:00
|
|
|
|
2012-09-04 19:53:04 -04:00
|
|
|
if (mFeedReader->addPreviewFeed(feedInfo, mFeedId)) {
|
|
|
|
setFeedInfo("");
|
|
|
|
} else {
|
|
|
|
setFeedInfo(tr("Cannot create preview"));
|
|
|
|
}
|
2013-01-21 19:11:43 -05:00
|
|
|
setTransformationInfo("");
|
|
|
|
|
|
|
|
/* fill xpath/xslt expressions */
|
|
|
|
ui->transformationTypeComboBox->setCurrentIndex(ui->transformationTypeComboBox->findData(feedInfo.transformationType));
|
2012-09-04 19:53:04 -04:00
|
|
|
|
|
|
|
QListWidgetItem *item;
|
|
|
|
std::string xpath;
|
|
|
|
foreach(xpath, feedInfo.xpathsToUse){
|
|
|
|
item = new QListWidgetItem(QString::fromUtf8(xpath.c_str()));
|
|
|
|
item->setFlags(item->flags() | Qt::ItemIsEditable);
|
|
|
|
ui->xpathUseListWidget->addItem(item);
|
|
|
|
}
|
|
|
|
foreach(xpath, feedInfo.xpathsToRemove){
|
|
|
|
item = new QListWidgetItem(QString::fromUtf8(xpath.c_str()));
|
|
|
|
item->setFlags(item->flags() | Qt::ItemIsEditable);
|
|
|
|
ui->xpathRemoveListWidget->addItem(item);
|
2012-08-13 17:35:11 -04:00
|
|
|
}
|
|
|
|
|
2013-01-21 19:11:43 -05:00
|
|
|
ui->xsltTextEdit->setPlainText(QString::fromUtf8(feedInfo.xslt.c_str()));
|
|
|
|
|
2012-08-13 17:35:11 -04:00
|
|
|
updateMsgCount();
|
2012-09-04 19:53:04 -04:00
|
|
|
|
|
|
|
ui->xpathUseListWidget->installEventFilter(this);
|
2013-01-16 18:20:47 -05:00
|
|
|
ui->xpathUseListWidget->viewport()->installEventFilter(this);
|
2012-09-04 19:53:04 -04:00
|
|
|
ui->xpathRemoveListWidget->installEventFilter(this);
|
2013-01-16 18:20:47 -05:00
|
|
|
ui->xpathRemoveListWidget->viewport()->installEventFilter(this);
|
2013-01-21 19:11:43 -05:00
|
|
|
ui->xsltTextEdit->installEventFilter(this);
|
2012-09-04 19:53:04 -04:00
|
|
|
|
|
|
|
/* load settings */
|
|
|
|
processSettings(true);
|
2012-08-13 17:35:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
PreviewFeedDialog::~PreviewFeedDialog()
|
|
|
|
{
|
2012-09-04 19:53:04 -04:00
|
|
|
/* save settings */
|
|
|
|
processSettings(false);
|
|
|
|
|
2012-08-13 17:35:11 -04:00
|
|
|
disconnect(mNotify);
|
|
|
|
disconnect(mNotify);
|
|
|
|
|
2020-11-08 07:22:59 -05:00
|
|
|
if (mFeedId) {
|
2012-08-13 17:35:11 -04:00
|
|
|
mFeedReader->removeFeed(mFeedId);
|
|
|
|
}
|
|
|
|
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2012-09-04 19:53:04 -04:00
|
|
|
void PreviewFeedDialog::processSettings(bool load)
|
|
|
|
{
|
|
|
|
Settings->beginGroup(QString("PreviewFeedDialog"));
|
|
|
|
|
|
|
|
if (load) {
|
|
|
|
// load settings
|
|
|
|
QByteArray geometry = Settings->value("Geometry").toByteArray();
|
|
|
|
if (!geometry.isEmpty()) {
|
|
|
|
restoreGeometry(geometry);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// save settings
|
|
|
|
Settings->setValue("Geometry", saveGeometry());
|
|
|
|
}
|
|
|
|
|
|
|
|
Settings->endGroup();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PreviewFeedDialog::eventFilter(QObject *obj, QEvent *event)
|
|
|
|
{
|
|
|
|
if (event->type() == QEvent::KeyPress) {
|
|
|
|
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
|
|
|
|
if (keyEvent) {
|
|
|
|
if (keyEvent->key() == Qt::Key_Delete) {
|
|
|
|
/* Delete pressed */
|
|
|
|
if (obj == ui->xpathUseListWidget || obj == ui->xpathRemoveListWidget) {
|
|
|
|
QListWidget *listWidget = dynamic_cast<QListWidget*>(obj);
|
|
|
|
if (listWidget) {
|
|
|
|
QListWidgetItem *item = listWidget->currentItem();
|
|
|
|
if (item) {
|
|
|
|
delete(item);
|
2013-01-21 19:11:43 -05:00
|
|
|
processTransformation();
|
2012-09-04 19:53:04 -04:00
|
|
|
}
|
|
|
|
return true; // eat event
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-01-21 19:11:43 -05:00
|
|
|
if ((keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return) && (keyEvent->modifiers() & Qt::ControlModifier)) {
|
|
|
|
/* Ctrl+Enter pressed */
|
|
|
|
if (obj == ui->xsltTextEdit) {
|
|
|
|
processTransformation();
|
|
|
|
return true; // eat event
|
|
|
|
}
|
|
|
|
}
|
2012-09-04 19:53:04 -04:00
|
|
|
}
|
|
|
|
}
|
2013-01-16 18:20:47 -05:00
|
|
|
if (event->type() == QEvent::Drop) {
|
2013-01-21 19:11:43 -05:00
|
|
|
processTransformation();
|
|
|
|
}
|
|
|
|
if (event->type() == QEvent::FocusOut) {
|
|
|
|
if (obj == ui->xsltTextEdit) {
|
|
|
|
processTransformation();
|
|
|
|
}
|
2013-01-16 18:20:47 -05:00
|
|
|
}
|
2012-09-04 19:53:04 -04:00
|
|
|
/* pass the event on to the parent class */
|
|
|
|
return QDialog::eventFilter(obj, event);
|
|
|
|
}
|
|
|
|
|
2020-11-08 07:22:59 -05:00
|
|
|
void PreviewFeedDialog::feedChanged(uint32_t feedId, int type)
|
2012-08-13 17:35:11 -04:00
|
|
|
{
|
2020-11-08 07:22:59 -05:00
|
|
|
if (feedId == 0) {
|
2012-08-13 17:35:11 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-11-08 07:22:59 -05:00
|
|
|
if (feedId != mFeedId) {
|
2012-08-13 17:35:11 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type == NOTIFY_TYPE_DEL) {
|
|
|
|
/* feed deleted */
|
2020-11-08 07:22:59 -05:00
|
|
|
mFeedId = 0;
|
2012-08-13 17:35:11 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type == NOTIFY_TYPE_ADD || type == NOTIFY_TYPE_MOD) {
|
|
|
|
FeedInfo feedInfo;
|
|
|
|
if (!mFeedReader->getFeedInfo(mFeedId, feedInfo)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
fillFeedInfo(feedInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-08 07:22:59 -05:00
|
|
|
void PreviewFeedDialog::msgChanged(uint32_t feedId, const QString &msgId, int type)
|
2012-08-13 17:35:11 -04:00
|
|
|
{
|
2020-11-08 07:22:59 -05:00
|
|
|
if (feedId == 0 || msgId.isEmpty()) {
|
2012-08-13 17:35:11 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-11-08 07:22:59 -05:00
|
|
|
if (feedId != mFeedId) {
|
2012-08-13 17:35:11 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case NOTIFY_TYPE_ADD:
|
|
|
|
if (mMsgId.empty()) {
|
|
|
|
mMsgId = msgId.toStdString();
|
|
|
|
updateMsg();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NOTIFY_TYPE_MOD:
|
|
|
|
if (mMsgId == msgId.toStdString()) {
|
|
|
|
updateMsg();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NOTIFY_TYPE_DEL:
|
|
|
|
if (mMsgId == msgId.toStdString()) {
|
|
|
|
std::list<std::string>::iterator it = std::find(mMsgIds.begin(), mMsgIds.end(), mMsgId);
|
|
|
|
if (it != mMsgIds.end()) {
|
|
|
|
++it;
|
|
|
|
if (it != mMsgIds.end()) {
|
|
|
|
mMsgId = *it;
|
|
|
|
} else {
|
|
|
|
--it;
|
|
|
|
if (it != mMsgIds.begin()) {
|
|
|
|
--it;
|
|
|
|
mMsgId = *it;
|
|
|
|
} else {
|
|
|
|
mMsgId.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
updateMsg();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* calculate message count */
|
|
|
|
mMsgIds.clear();
|
|
|
|
mFeedReader->getFeedMsgIdList(mFeedId, mMsgIds);
|
|
|
|
|
|
|
|
updateMsgCount();
|
|
|
|
}
|
|
|
|
|
2013-01-21 19:11:43 -05:00
|
|
|
void PreviewFeedDialog::showStructureFrame()
|
2012-08-13 17:35:11 -04:00
|
|
|
{
|
2013-01-21 19:11:43 -05:00
|
|
|
bool show = ui->structureButton->isChecked();
|
|
|
|
RsFeedTransformationType transformationType = (RsFeedTransformationType) ui->transformationTypeComboBox->itemData(ui->transformationTypeComboBox->currentIndex()).toInt();
|
|
|
|
|
|
|
|
ui->structureTreeFrame->setVisible(show);
|
|
|
|
|
|
|
|
switch (transformationType) {
|
|
|
|
case RS_FEED_TRANSFORMATION_TYPE_NONE:
|
|
|
|
ui->msgTextOrg->hide();
|
|
|
|
ui->structureTreeWidgetOrg->hide();
|
|
|
|
ui->transformationFrame->hide();
|
|
|
|
ui->xpathFrame->hide();
|
|
|
|
ui->xsltFrame->hide();
|
|
|
|
break;
|
|
|
|
case RS_FEED_TRANSFORMATION_TYPE_XPATH:
|
|
|
|
ui->msgTextOrg->setVisible(show);
|
|
|
|
ui->structureTreeWidgetOrg->show();
|
|
|
|
ui->transformationFrame->setVisible(show);
|
|
|
|
ui->xpathFrame->show();
|
|
|
|
ui->xsltFrame->hide();
|
|
|
|
break;
|
|
|
|
case RS_FEED_TRANSFORMATION_TYPE_XSLT:
|
|
|
|
ui->msgTextOrg->setVisible(show);
|
|
|
|
ui->structureTreeWidgetOrg->show();
|
|
|
|
ui->transformationFrame->setVisible(show);
|
|
|
|
ui->xpathFrame->hide();
|
|
|
|
ui->xsltFrame->show();
|
|
|
|
break;
|
|
|
|
}
|
2012-08-13 17:35:11 -04:00
|
|
|
|
2013-01-21 19:11:43 -05:00
|
|
|
if (ui->msgTextOrg->isVisible()) {
|
|
|
|
QString msgTxt = RsHtml().formatText(ui->msgTextOrg->document(), QString::fromUtf8(mDescription.c_str()), RSHTML_FORMATTEXT_EMBED_LINKS);
|
|
|
|
ui->msgTextOrg->setHtml(msgTxt);
|
|
|
|
} else {
|
|
|
|
ui->msgTextOrg->clear();
|
2012-09-04 19:53:04 -04:00
|
|
|
}
|
2013-01-21 19:11:43 -05:00
|
|
|
fillStructureTree(false);
|
|
|
|
fillStructureTree(true);
|
2012-09-04 19:53:04 -04:00
|
|
|
}
|
|
|
|
|
2013-01-21 19:11:43 -05:00
|
|
|
void PreviewFeedDialog::transformationTypeChanged()
|
2012-09-04 19:53:04 -04:00
|
|
|
{
|
2013-01-21 19:11:43 -05:00
|
|
|
showStructureFrame();
|
|
|
|
processTransformation();
|
2012-09-04 19:53:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewFeedDialog::xpathListCustomPopupMenu(QPoint /*point*/)
|
|
|
|
{
|
|
|
|
QListWidgetItem *item = NULL;
|
|
|
|
|
|
|
|
if (sender() == ui->xpathUseListWidget) {
|
|
|
|
item = ui->xpathUseListWidget->currentItem();
|
|
|
|
} else if (sender() == ui->xpathRemoveListWidget) {
|
|
|
|
item = ui->xpathRemoveListWidget->currentItem();
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QMenu contextMnu(this);
|
|
|
|
|
|
|
|
QAction *action = contextMnu.addAction(QIcon(), tr("Add"), this, SLOT(addXPath()));
|
|
|
|
action->setData(QVariant::fromValue(sender()));
|
|
|
|
|
|
|
|
action = contextMnu.addAction(QIcon(), tr("Edit"), this, SLOT(editXPath()));
|
|
|
|
action->setData(QVariant::fromValue(sender()));
|
|
|
|
if (!item) {
|
|
|
|
action->setEnabled(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
action = contextMnu.addAction(QIcon(), tr("Delete"), this, SLOT(removeXPath()));
|
|
|
|
action->setData(QVariant::fromValue(sender()));
|
|
|
|
if (!item) {
|
|
|
|
action->setEnabled(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
contextMnu.exec(QCursor::pos());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PreviewFeedDialog::xpathCloseEditor(QWidget */*editor*/, QAbstractItemDelegate::EndEditHint /*hint*/)
|
|
|
|
{
|
2013-01-21 19:11:43 -05:00
|
|
|
processTransformation();
|
2012-09-04 19:53:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewFeedDialog::addXPath()
|
|
|
|
{
|
|
|
|
QAction *action = dynamic_cast<QAction*>(sender());
|
|
|
|
if (!action) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QObject *source = action->data().value<QObject*>();
|
|
|
|
|
|
|
|
QListWidget *listWidget;
|
|
|
|
if (source == ui->xpathUseListWidget) {
|
|
|
|
listWidget = ui->xpathUseListWidget;
|
|
|
|
} else if (source == ui->xpathRemoveListWidget) {
|
|
|
|
listWidget = ui->xpathRemoveListWidget;
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QListWidgetItem *item = new QListWidgetItem();
|
|
|
|
item->setFlags(item->flags() | Qt::ItemIsEditable);
|
|
|
|
listWidget->addItem(item);
|
|
|
|
|
|
|
|
listWidget->editItem(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewFeedDialog::editXPath()
|
|
|
|
{
|
|
|
|
QAction *action = dynamic_cast<QAction*>(sender());
|
|
|
|
if (!action) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QObject *source = action->data().value<QObject*>();
|
|
|
|
|
|
|
|
QListWidget *listWidget;
|
|
|
|
if (source == ui->xpathUseListWidget) {
|
|
|
|
listWidget = ui->xpathUseListWidget;
|
|
|
|
} else if (source == ui->xpathRemoveListWidget) {
|
|
|
|
listWidget = ui->xpathRemoveListWidget;
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
2012-08-13 17:35:11 -04:00
|
|
|
|
2012-09-04 19:53:04 -04:00
|
|
|
listWidget->editItem(listWidget->currentItem());
|
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewFeedDialog::removeXPath()
|
|
|
|
{
|
|
|
|
QAction *action = dynamic_cast<QAction*>(sender());
|
|
|
|
if (!action) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QObject *source = action->data().value<QObject*>();
|
|
|
|
|
|
|
|
QListWidget *listWidget;
|
|
|
|
if (source == ui->xpathUseListWidget) {
|
|
|
|
listWidget = ui->xpathUseListWidget;
|
|
|
|
} else if (source == ui->xpathRemoveListWidget) {
|
|
|
|
listWidget = ui->xpathRemoveListWidget;
|
2012-08-13 17:35:11 -04:00
|
|
|
} else {
|
2012-09-04 19:53:04 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QListWidgetItem *item = listWidget->currentItem();
|
|
|
|
if (item) {
|
|
|
|
delete(item);
|
2012-08-13 17:35:11 -04:00
|
|
|
}
|
2012-09-04 19:53:04 -04:00
|
|
|
|
2013-01-21 19:11:43 -05:00
|
|
|
processTransformation();
|
2012-08-13 17:35:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int PreviewFeedDialog::getMsgPos()
|
|
|
|
{
|
|
|
|
int pos = -1;
|
|
|
|
std::list<std::string>::iterator it;
|
|
|
|
for (it = mMsgIds.begin(); it != mMsgIds.end(); ++it) {
|
|
|
|
++pos;
|
|
|
|
if (*it == mMsgId) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
2012-09-04 19:53:04 -04:00
|
|
|
void PreviewFeedDialog::setFeedInfo(const QString &info)
|
2012-08-13 17:35:11 -04:00
|
|
|
{
|
|
|
|
ui->feedInfoLabel->setText(info);
|
|
|
|
ui->feedInfoLabel->setVisible(!info.isEmpty());
|
|
|
|
}
|
|
|
|
|
2013-01-21 19:11:43 -05:00
|
|
|
void PreviewFeedDialog::setTransformationInfo(const QString &info)
|
2012-09-04 19:53:04 -04:00
|
|
|
{
|
2013-01-21 19:11:43 -05:00
|
|
|
ui->transformationInfoLabel->setText(info);
|
|
|
|
ui->transformationInfoLabel->setVisible(!info.isEmpty());
|
2012-09-04 19:53:04 -04:00
|
|
|
}
|
|
|
|
|
2012-08-13 17:35:11 -04:00
|
|
|
void PreviewFeedDialog::fillFeedInfo(const FeedInfo &feedInfo)
|
|
|
|
{
|
|
|
|
QString name = feedInfo.name.empty() ? tr("No name") : QString::fromUtf8(feedInfo.name.c_str());
|
|
|
|
|
|
|
|
QString workState = FeedReaderStringDefs::workState(feedInfo.workstate);
|
|
|
|
if (!workState.isEmpty()) {
|
|
|
|
name += QString(" (%1)").arg(workState);
|
|
|
|
}
|
|
|
|
ui->feedNameLabel->setText(name);
|
|
|
|
|
2012-09-04 19:53:04 -04:00
|
|
|
setFeedInfo(FeedReaderStringDefs::errorString(feedInfo));
|
2012-08-13 17:35:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewFeedDialog::previousMsg()
|
|
|
|
{
|
|
|
|
std::list<std::string>::iterator it = std::find(mMsgIds.begin(), mMsgIds.end(), mMsgId);
|
|
|
|
if (it != mMsgIds.end()) {
|
|
|
|
if (it != mMsgIds.begin()) {
|
|
|
|
--it;
|
|
|
|
mMsgId = *it;
|
|
|
|
updateMsg();
|
|
|
|
updateMsgCount();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewFeedDialog::nextMsg()
|
|
|
|
{
|
|
|
|
std::list<std::string>::iterator it = std::find(mMsgIds.begin(), mMsgIds.end(), mMsgId);
|
|
|
|
if (it != mMsgIds.end()) {
|
|
|
|
++it;
|
|
|
|
if (it != mMsgIds.end()) {
|
|
|
|
mMsgId = *it;
|
|
|
|
updateMsg();
|
|
|
|
updateMsgCount();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewFeedDialog::updateMsgCount()
|
|
|
|
{
|
|
|
|
int pos = getMsgPos();
|
|
|
|
ui->messageCountLabel->setText(QString("%1/%2").arg(pos + 1).arg(mMsgIds.size()));
|
|
|
|
|
|
|
|
ui->previousPushButton->setEnabled(pos > 0);
|
|
|
|
ui->nextPushButton->setEnabled(pos + 1 < (int) mMsgIds.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewFeedDialog::updateMsg()
|
|
|
|
{
|
|
|
|
FeedMsgInfo msgInfo;
|
|
|
|
if (mMsgId.empty() || !mFeedReader->getMsgInfo(mFeedId, mMsgId, msgInfo)) {
|
|
|
|
ui->msgTitle->clear();
|
|
|
|
ui->msgText->clear();
|
2013-01-21 19:11:43 -05:00
|
|
|
ui->msgTextOrg->clear();
|
2012-08-13 17:35:11 -04:00
|
|
|
mDescription.clear();
|
2013-01-21 19:11:43 -05:00
|
|
|
mDescriptionTransformed.clear();
|
2012-08-13 17:35:11 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->msgTitle->setText(QString::fromUtf8(msgInfo.title.c_str()));
|
|
|
|
|
2012-09-04 19:53:04 -04:00
|
|
|
/* store description */
|
|
|
|
mDescription = msgInfo.description;
|
|
|
|
|
2013-01-21 19:11:43 -05:00
|
|
|
if (ui->msgTextOrg->isVisible()) {
|
|
|
|
QString msgTxt = RsHtml().formatText(ui->msgTextOrg->document(), QString::fromUtf8(mDescription.c_str()), RSHTML_FORMATTEXT_EMBED_LINKS);
|
|
|
|
ui->msgTextOrg->setHtml(msgTxt);
|
|
|
|
}
|
|
|
|
|
|
|
|
showStructureFrame();
|
|
|
|
|
2012-09-04 19:53:04 -04:00
|
|
|
/* process xpath */
|
2013-01-21 19:11:43 -05:00
|
|
|
processTransformation();
|
2012-08-13 17:35:11 -04:00
|
|
|
}
|
|
|
|
|
2012-09-04 19:53:04 -04:00
|
|
|
static void buildNodeText(HTMLWrapper &html, xmlNodePtr node, QString &text)
|
2012-08-13 17:35:11 -04:00
|
|
|
{
|
2012-09-04 19:53:04 -04:00
|
|
|
switch (node->type) {
|
|
|
|
case XML_ELEMENT_NODE:
|
2012-08-13 17:35:11 -04:00
|
|
|
text = QString("<%1 ").arg(QString::fromUtf8(html.nodeName(node).c_str()));
|
|
|
|
|
|
|
|
for (xmlAttrPtr attr = node->properties; attr; attr = attr->next) {
|
|
|
|
QString value = QString::fromUtf8(html.getAttr(node, attr).c_str());
|
|
|
|
if (value.length() > 100) {
|
|
|
|
value = value.left(100) + "...";
|
|
|
|
}
|
|
|
|
text += QString("%1=\"%2\" ").arg(QString::fromUtf8(html.attrName(attr).c_str()), value);
|
|
|
|
}
|
|
|
|
text = text.trimmed() + ">";
|
2012-09-04 19:53:04 -04:00
|
|
|
|
|
|
|
if (node->children && !node->children->next && node->children->type == XML_TEXT_NODE) {
|
|
|
|
/* only one text node as child */
|
|
|
|
std::string content;
|
2013-01-02 15:18:42 -05:00
|
|
|
if (html.getContent(node->children, content, false)) {
|
2012-09-04 19:53:04 -04:00
|
|
|
text += QString::fromUtf8(content.c_str());
|
|
|
|
} else {
|
|
|
|
text += QApplication::translate("PreviewFeedDialog", "Error getting content");
|
|
|
|
}
|
|
|
|
text += QString("<%1>").arg(QString::fromUtf8(html.nodeName(node).c_str()));
|
|
|
|
|
|
|
|
xmlUnlinkNode(node->children);
|
|
|
|
xmlFreeNode(node->children);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case XML_TEXT_NODE:
|
|
|
|
case XML_COMMENT_NODE:
|
|
|
|
{
|
|
|
|
if (node->type == XML_COMMENT_NODE) {
|
|
|
|
text = "<!-- ";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string content;
|
2013-01-02 15:18:42 -05:00
|
|
|
if (html.getContent(node, content, false)) {
|
2012-09-04 19:53:04 -04:00
|
|
|
text += QString::fromUtf8(content.c_str());
|
|
|
|
} else {
|
|
|
|
text += QApplication::translate("PreviewFeedDialog", "Error getting content");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (node->type == XML_COMMENT_NODE) {
|
|
|
|
text += " -->";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case XML_ATTRIBUTE_NODE:
|
|
|
|
case XML_CDATA_SECTION_NODE:
|
|
|
|
case XML_ENTITY_REF_NODE:
|
|
|
|
case XML_ENTITY_NODE:
|
|
|
|
case XML_PI_NODE:
|
|
|
|
case XML_DOCUMENT_NODE:
|
|
|
|
case XML_DOCUMENT_TYPE_NODE:
|
|
|
|
case XML_DOCUMENT_FRAG_NODE:
|
|
|
|
case XML_NOTATION_NODE:
|
|
|
|
case XML_HTML_DOCUMENT_NODE:
|
|
|
|
case XML_DTD_NODE:
|
|
|
|
case XML_ELEMENT_DECL:
|
|
|
|
case XML_ATTRIBUTE_DECL:
|
|
|
|
case XML_ENTITY_DECL:
|
|
|
|
case XML_NAMESPACE_DECL:
|
|
|
|
case XML_XINCLUDE_START:
|
|
|
|
case XML_XINCLUDE_END:
|
|
|
|
#ifdef LIBXML_DOCB_ENABLED
|
|
|
|
case XML_DOCB_DOCUMENT_NODE:
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void examineChildElements(QTreeWidget *treeWidget, HTMLWrapper &html, QList<xmlNodePtr> &nodes, QTreeWidgetItem *parentItem)
|
|
|
|
{
|
|
|
|
int childIndex = 0;
|
|
|
|
int childCount;
|
|
|
|
|
|
|
|
QList<QPair<xmlNodePtr, QTreeWidgetItem*> > nodeItems;
|
|
|
|
foreach (xmlNodePtr node, nodes) {
|
|
|
|
QString text;
|
|
|
|
buildNodeText(html, node, text);
|
|
|
|
|
|
|
|
QList<QTreeWidgetItem*> itemsToDelete;
|
|
|
|
QTreeWidgetItem *item = NULL;
|
|
|
|
|
|
|
|
childCount = parentItem->childCount();
|
|
|
|
for (int index = childIndex; index < childCount; ++index) {
|
|
|
|
QTreeWidgetItem *childItem = parentItem->child(index);
|
|
|
|
if (childItem->text(0) == text) {
|
|
|
|
/* reuse item */
|
|
|
|
item = childItem;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
itemsToDelete.push_back(childItem);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item) {
|
|
|
|
/* delete old items */
|
|
|
|
foreach (QTreeWidgetItem *item, itemsToDelete) {
|
|
|
|
delete(item);
|
|
|
|
}
|
|
|
|
++childIndex;
|
2012-08-13 17:35:11 -04:00
|
|
|
} else {
|
2012-09-04 19:53:04 -04:00
|
|
|
item = new QTreeWidgetItem;
|
|
|
|
item->setText(0, text);
|
|
|
|
parentItem->insertChild(childIndex, item);
|
|
|
|
item->setExpanded(true);
|
|
|
|
|
|
|
|
++childIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
nodeItems.push_back(QPair<xmlNodePtr, QTreeWidgetItem*>(node, item));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* delete not used items */
|
|
|
|
while (childIndex < parentItem->childCount()) {
|
|
|
|
delete(parentItem->child(childIndex));
|
|
|
|
}
|
|
|
|
|
|
|
|
QList<QPair<xmlNodePtr, QTreeWidgetItem*> >::iterator nodeItem;
|
|
|
|
for (nodeItem = nodeItems.begin(); nodeItem != nodeItems.end(); ++nodeItem) {
|
|
|
|
QList<xmlNodePtr> childNodes;
|
|
|
|
for (xmlNodePtr childNode = nodeItem->first->children; childNode; childNode = childNode->next) {
|
|
|
|
childNodes.push_back(childNode);
|
2012-08-13 17:35:11 -04:00
|
|
|
}
|
2012-09-04 19:53:04 -04:00
|
|
|
examineChildElements(treeWidget, html, childNodes, nodeItem->second);
|
2012-08-13 17:35:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// QLabel *label = new QLabel(text);
|
|
|
|
// label->setTextFormat(Qt::PlainText);
|
|
|
|
// label->setWordWrap(true);
|
|
|
|
// treeWidget->setItemWidget(item, 0, label);
|
|
|
|
}
|
|
|
|
|
2013-01-21 19:11:43 -05:00
|
|
|
void PreviewFeedDialog::fillStructureTree(bool transform)
|
2012-08-13 17:35:11 -04:00
|
|
|
{
|
2013-01-21 19:11:43 -05:00
|
|
|
if (transform && ui->structureTreeWidget->isVisible()) {
|
|
|
|
if (mDescriptionTransformed.empty()) {
|
|
|
|
ui->structureTreeWidget->clear();
|
|
|
|
} else {
|
|
|
|
HTMLWrapper html;
|
|
|
|
if (html.readHTML(mDescriptionTransformed.c_str(), "")) {
|
|
|
|
xmlNodePtr root = html.getRootElement();
|
|
|
|
if (root) {
|
|
|
|
QList<xmlNodePtr> nodes;
|
|
|
|
nodes.push_back(root);
|
|
|
|
examineChildElements(ui->structureTreeWidget, html, nodes, ui->structureTreeWidget->invisibleRootItem());
|
|
|
|
ui->structureTreeWidget->resizeColumnToContents(0);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
QTreeWidgetItem *item = new QTreeWidgetItem;
|
|
|
|
item->setText(0, tr("Error parsing document") + ": " + QString::fromUtf8(html.lastError().c_str()));
|
|
|
|
ui->structureTreeWidget->addTopLevelItem(item);
|
|
|
|
}
|
|
|
|
}
|
2012-08-13 17:35:11 -04:00
|
|
|
}
|
|
|
|
|
2013-01-21 19:11:43 -05:00
|
|
|
if (!transform && ui->structureTreeWidgetOrg->isVisible()) {
|
|
|
|
if (mDescription.empty()) {
|
|
|
|
ui->structureTreeWidgetOrg->clear();
|
|
|
|
} else {
|
|
|
|
HTMLWrapper html;
|
|
|
|
if (html.readHTML(mDescription.c_str(), "")) {
|
|
|
|
xmlNodePtr root = html.getRootElement();
|
|
|
|
if (root) {
|
|
|
|
QList<xmlNodePtr> nodes;
|
|
|
|
nodes.push_back(root);
|
|
|
|
examineChildElements(ui->structureTreeWidgetOrg, html, nodes, ui->structureTreeWidgetOrg->invisibleRootItem());
|
|
|
|
ui->structureTreeWidgetOrg->resizeColumnToContents(0);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
QTreeWidgetItem *item = new QTreeWidgetItem;
|
|
|
|
item->setText(0, tr("Error parsing document") + ": " + QString::fromUtf8(html.lastError().c_str()));
|
|
|
|
ui->structureTreeWidgetOrg->addTopLevelItem(item);
|
|
|
|
}
|
|
|
|
}
|
2012-08-13 17:35:11 -04:00
|
|
|
}
|
2012-09-04 19:53:04 -04:00
|
|
|
}
|
|
|
|
|
2013-01-21 19:11:43 -05:00
|
|
|
RsFeedTransformationType PreviewFeedDialog::getData(std::list<std::string> &xpathsToUse, std::list<std::string> &xpathsToRemove, std::string &xslt)
|
2012-09-04 19:53:04 -04:00
|
|
|
{
|
2013-01-16 18:20:47 -05:00
|
|
|
xpathsToUse.clear();
|
|
|
|
xpathsToRemove.clear();
|
|
|
|
|
2012-09-04 19:53:04 -04:00
|
|
|
int row;
|
|
|
|
int rowCount = ui->xpathUseListWidget->count();
|
|
|
|
for (row = 0; row < rowCount; ++row) {
|
|
|
|
xpathsToUse.push_back(ui->xpathUseListWidget->item(row)->text().toUtf8().constData());
|
|
|
|
}
|
|
|
|
|
|
|
|
rowCount = ui->xpathRemoveListWidget->count();
|
|
|
|
for (row = 0; row < rowCount; ++row) {
|
|
|
|
xpathsToRemove.push_back(ui->xpathRemoveListWidget->item(row)->text().toUtf8().constData());
|
|
|
|
}
|
2013-01-21 19:11:43 -05:00
|
|
|
|
|
|
|
xslt = ui->xsltTextEdit->toPlainText().toUtf8().constData();
|
|
|
|
|
|
|
|
return (RsFeedTransformationType) ui->transformationTypeComboBox->itemData(ui->transformationTypeComboBox->currentIndex()).toInt();
|
2012-09-04 19:53:04 -04:00
|
|
|
}
|
|
|
|
|
2013-01-21 19:11:43 -05:00
|
|
|
void PreviewFeedDialog::processTransformation()
|
2012-09-04 19:53:04 -04:00
|
|
|
{
|
|
|
|
std::list<std::string> xpathsToUse;
|
|
|
|
std::list<std::string> xpathsToRemove;
|
2013-01-21 19:11:43 -05:00
|
|
|
std::string xslt;
|
2012-09-04 19:53:04 -04:00
|
|
|
|
2013-01-21 19:11:43 -05:00
|
|
|
RsFeedTransformationType transformationType = getData(xpathsToUse, xpathsToRemove, xslt);
|
2012-09-04 19:53:04 -04:00
|
|
|
|
2013-01-21 19:11:43 -05:00
|
|
|
mDescriptionTransformed = mDescription;
|
2012-09-04 19:53:04 -04:00
|
|
|
std::string errorString;
|
2013-01-21 19:11:43 -05:00
|
|
|
|
|
|
|
RsFeedReaderErrorState result = RS_FEED_ERRORSTATE_OK;
|
|
|
|
switch (transformationType) {
|
|
|
|
case RS_FEED_TRANSFORMATION_TYPE_NONE:
|
|
|
|
break;
|
|
|
|
case RS_FEED_TRANSFORMATION_TYPE_XPATH:
|
|
|
|
result = mFeedReader->processXPath(xpathsToUse, xpathsToRemove, mDescriptionTransformed, errorString);
|
|
|
|
break;
|
|
|
|
case RS_FEED_TRANSFORMATION_TYPE_XSLT:
|
|
|
|
result = mFeedReader->processXslt(xslt, mDescriptionTransformed, errorString);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
setTransformationInfo(FeedReaderStringDefs::errorString(result, errorString));
|
2012-09-04 19:53:04 -04:00
|
|
|
|
|
|
|
/* fill message */
|
2013-01-21 19:11:43 -05:00
|
|
|
QString msgTxt = RsHtml().formatText(ui->msgText->document(), QString::fromUtf8(mDescriptionTransformed.c_str()), RSHTML_FORMATTEXT_EMBED_LINKS);
|
2012-09-04 19:53:04 -04:00
|
|
|
ui->msgText->setHtml(msgTxt);
|
|
|
|
|
|
|
|
/* fill structure */
|
2013-01-21 19:11:43 -05:00
|
|
|
fillStructureTree(true);
|
2012-08-13 17:35:11 -04:00
|
|
|
}
|