Work on feeds dialog.

This commit is contained in:
Martin Rotter 2014-01-29 15:04:52 +01:00
parent 16a98a57ba
commit a03be036c1
4 changed files with 194 additions and 19 deletions

View File

@ -59,4 +59,6 @@ class FeedsModelFeed : public FeedsModelRootItem {
int m_unreadCount;
};
Q_DECLARE_METATYPE(FeedsModelFeed::Type)
#endif // FEEDSMODELFEED_H

View File

@ -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.

View File

@ -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 <QPushButton>
#include <QTextCodec>
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<QByteArray> 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);
}

View File

@ -6,30 +6,172 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
<width>375</width>
<height>269</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QDialogButtonBox" name="m_buttonBox">
<property name="geometry">
<rect>
<x>30</x>
<y>240</y>
<width>341</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="m_lblParentCategory">
<property name="text">
<string>Parent category</string>
</property>
<property name="buddy">
<cstring>m_cmbParentCategory</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="m_cmbParentCategory">
<property name="toolTip">
<string>Select parent item for your category.</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Type</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="m_cmbType">
<property name="toolTip">
<string>Select type of the standard feed.</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="m_lblTitle">
<property name="text">
<string>Title</string>
</property>
<property name="buddy">
<cstring>m_txtTitle</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="LineEditWithStatus" name="m_txtTitle" native="true"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="m_lblDescription">
<property name="text">
<string>Description</string>
</property>
<property name="buddy">
<cstring>m_txtDescription</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="LineEditWithStatus" name="m_txtDescription" native="true"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>URL</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="LineEditWithStatus" name="widget" native="true"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Encoding</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="m_cmbEncoding">
<property name="toolTip">
<string>Select encoding of the standard feed. If you are unsure about the encoding, then select &quot;UTF-8&quot; encoding.</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="m_lblIcon">
<property name="text">
<string>Icon</string>
</property>
<property name="buddy">
<cstring>m_btnIcon</cstring>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QToolButton" name="m_btnIcon">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>40</width>
<height>40</height>
</size>
</property>
<property name="toolTip">
<string>Select icon for your category.</string>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="popupMode">
<enum>QToolButton::InstantPopup</enum>
</property>
<property name="autoRaise">
<bool>false</bool>
</property>
<property name="arrowType">
<enum>Qt::NoArrow</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="m_buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
<property name="centerButtons">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>LineEditWithStatus</class>
<extends>QWidget</extends>
<header>lineeditwithstatus.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>