From a03be036c13d39b4d27329fbdb60d3c5b3922e27 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Wed, 29 Jan 2014 15:04:52 +0100 Subject: [PATCH] Work on feeds dialog. --- src/core/feedsmodelfeed.h | 2 + src/core/textfactory.h | 4 + src/gui/formstandardfeeddetails.cpp | 29 ++++- src/gui/formstandardfeeddetails.ui | 178 +++++++++++++++++++++++++--- 4 files changed, 194 insertions(+), 19 deletions(-) diff --git a/src/core/feedsmodelfeed.h b/src/core/feedsmodelfeed.h index 57d5d1174..1e62c92b9 100755 --- a/src/core/feedsmodelfeed.h +++ b/src/core/feedsmodelfeed.h @@ -59,4 +59,6 @@ class FeedsModelFeed : public FeedsModelRootItem { int m_unreadCount; }; +Q_DECLARE_METATYPE(FeedsModelFeed::Type) + #endif // FEEDSMODELFEED_H diff --git a/src/core/textfactory.h b/src/core/textfactory.h index a88535cc5..1b229ba94 100644 --- a/src/core/textfactory.h +++ b/src/core/textfactory.h @@ -13,6 +13,10 @@ class TextFactory { explicit TextFactory(); public: + static bool isCaseInsensitiveLessThan(const QString &lhs, const QString &rhs) { + return lhs.toLower() < rhs.toLower(); + } + // Tries to parse input textual date/time representation. // Returns invalid date/time if processing fails. // NOTE: This method tries to always return time in UTC+00:00. diff --git a/src/gui/formstandardfeeddetails.cpp b/src/gui/formstandardfeeddetails.cpp index bf1200e9a..401f8e243 100644 --- a/src/gui/formstandardfeeddetails.cpp +++ b/src/gui/formstandardfeeddetails.cpp @@ -1,6 +1,9 @@ #include "gui/formstandardfeeddetails.h" +#include "core/textfactory.h" #include "core/feedsmodel.h" +#include "core/feedsmodelfeed.h" +#include "core/feedsmodelstandardfeed.h" #include "gui/iconthemefactory.h" #if !defined(Q_OS_WIN) @@ -8,6 +11,8 @@ #endif #include +#include + FormStandardFeedDetails::FormStandardFeedDetails(FeedsModel *model, QWidget *parent) : QDialog(parent) { @@ -26,9 +31,13 @@ int FormStandardFeedDetails::exec(FeedsModelStandardFeed *input_feed) { else { // User is editing existing category. setWindowTitle(tr("Edit existing standard feed")); + // TODO: set editable feed. } - return 0; + // TODO: Load categories. + + // Run the dialog. + return QDialog::exec(); } void FormStandardFeedDetails::initialize() { @@ -45,4 +54,22 @@ void FormStandardFeedDetails::initialize() { #if !defined(Q_OS_WIN) MessageBox::iconify(m_ui->m_buttonBox); #endif + + // Add standard feed types. + m_ui->m_cmbType->addItem(FeedsModelFeed::typeToString(FeedsModelFeed::StandardAtom10), QVariant::fromValue(FeedsModelFeed::StandardAtom10)); + m_ui->m_cmbType->addItem(FeedsModelFeed::typeToString(FeedsModelFeed::StandardRdf), QVariant::fromValue(FeedsModelFeed::StandardRdf)); + m_ui->m_cmbType->addItem(FeedsModelFeed::typeToString(FeedsModelFeed::StandardRss0X), QVariant::fromValue(FeedsModelFeed::StandardRss0X)); + m_ui->m_cmbType->addItem(FeedsModelFeed::typeToString(FeedsModelFeed::StandardRss2X), QVariant::fromValue(FeedsModelFeed::StandardRss2X)); + + // Load available encodings. + QList encodings = QTextCodec::availableCodecs(); + QStringList encoded_encodings; + + foreach (const QByteArray &encoding, encodings) { + encoded_encodings.append(encoding); + } + + qSort(encoded_encodings.begin(), encoded_encodings.end(), TextFactory::isCaseInsensitiveLessThan); + m_ui->m_cmbEncoding->addItems(encoded_encodings); + } diff --git a/src/gui/formstandardfeeddetails.ui b/src/gui/formstandardfeeddetails.ui index 20e7a547e..ca95604e6 100644 --- a/src/gui/formstandardfeeddetails.ui +++ b/src/gui/formstandardfeeddetails.ui @@ -6,30 +6,172 @@ 0 0 - 400 - 300 + 375 + 269 Dialog - - - - 30 - 240 - 341 - 32 - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - + + + + + QFormLayout::AllNonFixedFieldsGrow + + + + + Parent category + + + m_cmbParentCategory + + + + + + + Select parent item for your category. + + + + + + + Type + + + + + + + Select type of the standard feed. + + + + + + + Title + + + m_txtTitle + + + + + + + + + + Description + + + m_txtDescription + + + + + + + + + + URL + + + + + + + + + + Encoding + + + + + + + Select encoding of the standard feed. If you are unsure about the encoding, then select "UTF-8" encoding. + + + + + + + Icon + + + m_btnIcon + + + + + + + + 0 + 0 + + + + + 40 + 40 + + + + Select icon for your category. + + + + + + + 20 + 20 + + + + QToolButton::InstantPopup + + + false + + + Qt::NoArrow + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + false + + + + + + + LineEditWithStatus + QWidget +
lineeditwithstatus.h
+ 1 +
+