Work on auto-updates.
This commit is contained in:
parent
d42f7b2490
commit
52e72ece7b
9 changed files with 103 additions and 62 deletions
|
@ -35,6 +35,8 @@ CREATE TABLE IF NOT EXISTS Feeds (
|
|||
protected INTEGER(1) NOT NULL CHECK (protected >= 0 AND protected <= 1),
|
||||
username TEXT,
|
||||
password TEXT,
|
||||
update_type INTEGER(1) NOT NULL CHECK (update_type >= 0),
|
||||
update_interval INTEGER NOT NULL CHECK (update_interval >= 5) DEFAULT 15,
|
||||
type INTEGER NOT NULL CHECK (type >= 0)
|
||||
);
|
||||
-- !
|
||||
|
@ -70,14 +72,14 @@ INSERT INTO Categories (id, parent_id, title, description, date_created, type, i
|
|||
-- !
|
||||
INSERT INTO Categories (id, parent_id, title, description, date_created, type, icon) VALUES (2, -1, 'RSS Guard', 'News and updates on RSS Guard.', 1388678961000, 0, 'AAAAIgBRAFAAaQB4AG0AYQBwAEkAYwBvAG4ARQBuAGcAaQBuAGUAAAABAAAAAYlQTkcNChoKAAAADUlIRFIAAABAAAAAQAgGAAAAqmlx3gAAAAlwSFlzAAAOxAAADsQBlSsOGwAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxMS0wNy0yOVQxNToxOTo1MCswMzowMMnGKbgAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTEtMDctMjlUMTU6MTg6MzcrMDM6MDBUkc0zAAAHP0lEQVR4nO1bzW4byRGu6u6RhqRImiJlErQBWQgPWgJrR9cY2D3swTDyBntIgN08RE55gCB5gzxA7jn5sMcA0cJGYishEIRrQ7sytdFfRIW0VsPpqhw0Qw+H3UOO5RVHm/2AAcmZ/qmqrv66qtkD8CP+v4FzPMc5ysXBkSvTSFJM1ut1t1gs5jc3N6u5XM5J0a5++fLlwbNnz04BwL+ijN8rlOW+qFar+XK5XHv48OGnlUrll4hYRMSZI8rMCACj27dv/1Ep9fvt7e0jANDvVer3CKMB2u22Ojw8LFQqlc1CofArrfU95nTe7DjO561W6+n29vafAOA7yOh0MBpgOBwKIYQLAFU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AHQAdABlAHIALwBEAG8AYwB1AG0AZQBuAHQAcwAvAFAAcgBvAGoAZQBrAHQAeQAvAHIAcwBzAGcAdQBhAHIAZAAtAGIAdQBpAGwAZAAvAGkAYwBvAG4AcwAvAG0AaQBuAGkALQBrAGYAYQBlAG4AegBhAC8AZgBvAGwAZABlAHIALQBiAGwAYQBjAGsALgBwAG4AZwAAAEAAAABAAAAAAAAAAAE=');
|
||||
-- !
|
||||
INSERT INTO Feeds (title, description, date_created, category, encoding, url, protected, type) VALUES ('Linux Today', 'Linux Today - Linux News on Internet Time.', 1388678961000, 1, 'UTF-8', 'http://feeds.feedburner.com/linuxtoday/linux?format=xml', 0, 1);
|
||||
INSERT INTO Feeds (title, description, date_created, category, encoding, url, protected, update_type, type) VALUES ('Linux Today', 'Linux Today - Linux News on Internet Time.', 1388678961000, 1, 'UTF-8', 'http://feeds.feedburner.com/linuxtoday/linux?format=xml', 0, 0, 1);
|
||||
-- !
|
||||
INSERT INTO Feeds (title, description, date_created, category, encoding, url, protected, type) VALUES ('LinuxInsider', 'LinuxInsider: Linux News & Information from Around the World.', 1388678961000, 1, 'UTF-8', 'http://www.linuxinsider.com/perl/syndication/rssfull.pl', 0, 2);
|
||||
INSERT INTO Feeds (title, description, date_created, category, encoding, url, protected, update_type, type) VALUES ('LinuxInsider', 'LinuxInsider: Linux News & Information from Around the World.', 1388678961000, 1, 'UTF-8', 'http://www.linuxinsider.com/perl/syndication/rssfull.pl', 0, 0, 2);
|
||||
-- !
|
||||
INSERT INTO Feeds (title, description, date_created, category, encoding, url, protected, type) VALUES ('LXer: Linux News', 'The world is talking about GNU/Linux and Free/Open Source Software.', 1388678961000, 1, 'UTF-8', 'http://lxer.com/module/newswire/headlines.rss', 0, 2);
|
||||
INSERT INTO Feeds (title, description, date_created, category, encoding, url, protected, update_type, type) VALUES ('LXer: Linux News', 'The world is talking about GNU/Linux and Free/Open Source Software.', 1388678961000, 1, 'UTF-8', 'http://lxer.com/module/newswire/headlines.rss', 0, 0, 2);
|
||||
-- !
|
||||
INSERT INTO Feeds (title, description, date_created, category, encoding, url, protected, type) VALUES ('Recent Commits', 'Recent commits for RSS Guard project.', 1388678961000, 2, 'UTF-8', 'https://github.com/martinrotter/rssguard/commits/master.atom', 0, 3);
|
||||
INSERT INTO Feeds (title, description, date_created, category, encoding, url, protected, update_type, update_interval, type) VALUES ('Recent Commits', 'Recent commits for RSS Guard project.', 1388678961000, 2, 'UTF-8', 'https://github.com/martinrotter/rssguard/commits/master.atom', 0, 2, 30, 3);
|
||||
-- !
|
||||
INSERT INTO Feeds (title, description, date_created, category, encoding, url, protected, type) VALUES ('Releases', 'Releases for RSS Guard.', 1388678961000, 2, 'UTF-8', 'https://github.com/martinrotter/rssguard/releases.atom', 0, 3);
|
||||
INSERT INTO Feeds (title, description, date_created, category, encoding, url, protected, update_type, update_interval, type) VALUES ('Releases', 'Releases for RSS Guard.', 1388678961000, 2, 'UTF-8', 'https://github.com/martinrotter/rssguard/releases.atom', 0, 2, 30, 3);
|
||||
-- !
|
||||
INSERT INTO Feeds (title, description, date_created, category, encoding, url, protected, type) VALUES ('Author''s Activity', 'RSS Guard author public activity overview.', 1388678961000, 2, 'UTF-8', 'https://github.com/martinrotter.atom', 0, 3);
|
||||
INSERT INTO Feeds (title, description, date_created, category, encoding, url, protected, update_type, update_interval, type) VALUES ('Author''s Activity', 'RSS Guard author public activity overview.', 1388678961000, 2, 'UTF-8', 'https://github.com/martinrotter.atom', 0, 2, 30, 3);
|
|
@ -35,6 +35,8 @@ CREATE TABLE IF NOT EXISTS Feeds (
|
|||
protected INTEGER(1) NOT NULL CHECK (protected >= 0 AND protected <= 1),
|
||||
username TEXT,
|
||||
password TEXT,
|
||||
update_type INTEGER(1) NOT NULL CHECK (update_type >= 0),
|
||||
update_interval INTEGER NOT NULL CHECK (update_interval >= 5) DEFAULT 15,
|
||||
type INTEGER NOT NULL CHECK (type >= 0)
|
||||
);
|
||||
-- !
|
||||
|
|
|
@ -23,22 +23,23 @@
|
|||
#define APP_VERSION "@APP_VERSION@"
|
||||
#define APP_USERAGENT QString("@APP_NAME@/@APP_VERSION@ (@APP_URL@) on @CMAKE_SYSTEM@; Webkit/") + qWebKitVersion()
|
||||
|
||||
#define DEFAULT_FEED_ENCODING "UTF-8"
|
||||
#define URL_REGEXP "^(http|https|feed|ftp):\\/\\/[\\w\\-_]+(\\.[\\w\\-_]+)+([\\w\\-\\.,@?^=%&:/~\\+#]*[\\w\\-\\@?^=%&/~\\+#])?$"
|
||||
#define USER_AGENT_HTTP_HEADER "User-Agent"
|
||||
#define TEXT_TITLE_LIMIT 30
|
||||
#define MAX_ZOOM_FACTOR 10.0
|
||||
#define ICON_SIZE_SETTINGS 16
|
||||
#define DATABASE_DRIVER "QSQLITE"
|
||||
#define NO_PARENT_CATEGORY -1
|
||||
#define TRAY_ICON_BUBBLE_TIMEOUT 15000
|
||||
#define KEY_MESSAGES_VIEW "messages_view_column_"
|
||||
#define CLOSE_LOCK_TIMEOUT 3000
|
||||
#define DOWNLOAD_TIMEOUT 5000
|
||||
#define MESSAGES_VIEW_DEFAULT_COL 170
|
||||
#define ELLIPSIS_LENGTH 3
|
||||
#define MIN_CATEGORY_NAME_LENGTH 3
|
||||
#define INTERNAL_URL_NEWSPAPER "@APP_LOW_NAME@:newspaper"
|
||||
#define DEFAULT_FEED_ENCODING "UTF-8"
|
||||
#define URL_REGEXP "^(http|https|feed|ftp):\\/\\/[\\w\\-_]+(\\.[\\w\\-_]+)+([\\w\\-\\.,@?^=%&:/~\\+#]*[\\w\\-\\@?^=%&/~\\+#])?$"
|
||||
#define USER_AGENT_HTTP_HEADER "User-Agent"
|
||||
#define TEXT_TITLE_LIMIT 30
|
||||
#define MAX_ZOOM_FACTOR 10.0
|
||||
#define ICON_SIZE_SETTINGS 16
|
||||
#define DATABASE_DRIVER "QSQLITE"
|
||||
#define NO_PARENT_CATEGORY -1
|
||||
#define TRAY_ICON_BUBBLE_TIMEOUT 15000
|
||||
#define KEY_MESSAGES_VIEW "messages_view_column_"
|
||||
#define CLOSE_LOCK_TIMEOUT 3000
|
||||
#define DOWNLOAD_TIMEOUT 5000
|
||||
#define MESSAGES_VIEW_DEFAULT_COL 170
|
||||
#define ELLIPSIS_LENGTH 3
|
||||
#define MIN_CATEGORY_NAME_LENGTH 3
|
||||
#define INTERNAL_URL_NEWSPAPER "@APP_LOW_NAME@:newspaper"
|
||||
#define DEFAULT_AUTO_UPDATE_INTERVAL 15
|
||||
|
||||
#define APP_DB_INIT_FILE "db_init.sql"
|
||||
#define APP_DB_INIT_MEMORY "db_init_memory.sql"
|
||||
|
@ -88,18 +89,20 @@
|
|||
#define CAT_DB_TYPE_INDEX 6
|
||||
|
||||
// Indexes of columns as they are DEFINED IN THE TABLE for FEEDS.
|
||||
#define FDS_DB_ID_INDEX 0
|
||||
#define FDS_DB_TITLE_INDEX 1
|
||||
#define FDS_DB_DESCRIPTION_INDEX 2
|
||||
#define FDS_DB_DCREATED_INDEX 3
|
||||
#define FDS_DB_ICON_INDEX 4
|
||||
#define FDS_DB_CATEGORY_INDEX 5
|
||||
#define FDS_DB_ENCODING_INDEX 6
|
||||
#define FDS_DB_URL_INDEX 7
|
||||
#define FDS_DB_PROTECTED_INDEX 8
|
||||
#define FDS_DB_USERNAME_INDEX 9
|
||||
#define FDS_DB_PASSWORD_INDEX 10
|
||||
#define FDS_DB_TYPE_INDEX 11
|
||||
#define FDS_DB_ID_INDEX 0
|
||||
#define FDS_DB_TITLE_INDEX 1
|
||||
#define FDS_DB_DESCRIPTION_INDEX 2
|
||||
#define FDS_DB_DCREATED_INDEX 3
|
||||
#define FDS_DB_ICON_INDEX 4
|
||||
#define FDS_DB_CATEGORY_INDEX 5
|
||||
#define FDS_DB_ENCODING_INDEX 6
|
||||
#define FDS_DB_URL_INDEX 7
|
||||
#define FDS_DB_PROTECTED_INDEX 8
|
||||
#define FDS_DB_USERNAME_INDEX 9
|
||||
#define FDS_DB_PASSWORD_INDEX 10
|
||||
#define FDS_DB_UPDATE_TYPE_INDEX 11
|
||||
#define FDS_DB_UPDATE_INTERVAL_INDEX 12
|
||||
#define FDS_DB_TYPE_INDEX 13
|
||||
|
||||
// Indexes of columns for feed models.
|
||||
#define FDS_MODEL_TITLE_INDEX 0
|
||||
|
|
|
@ -274,8 +274,8 @@ bool FeedsModel::addStandardFeed(FeedsModelStandardFeed *feed,
|
|||
|
||||
query_add_feed.setForwardOnly(true);
|
||||
query_add_feed.prepare("INSERT INTO Feeds "
|
||||
"(title, description, date_created, icon, category, encoding, url, protected, username, password, type) "
|
||||
"VALUES (:title, :description, :date_created, :icon, :category, :encoding, :url, :protected, :username, :password, :type);");
|
||||
"(title, description, date_created, icon, category, encoding, url, protected, username, password, update_type, update_interval, type) "
|
||||
"VALUES (:title, :description, :date_created, :icon, :category, :encoding, :url, :protected, :username, :password, :update_type, :update_interval, :type);");
|
||||
query_add_feed.bindValue(":title", feed->title());
|
||||
query_add_feed.bindValue(":description", feed->description());
|
||||
query_add_feed.bindValue(":date_created", feed->creationDate().toMSecsSinceEpoch());
|
||||
|
@ -286,6 +286,8 @@ bool FeedsModel::addStandardFeed(FeedsModelStandardFeed *feed,
|
|||
query_add_feed.bindValue(":protected", (int) feed->passwordProtected());
|
||||
query_add_feed.bindValue(":username", feed->username());
|
||||
query_add_feed.bindValue(":password", feed->password());
|
||||
query_add_feed.bindValue(":update_type", (int) feed->autoUpdateType());
|
||||
query_add_feed.bindValue(":update_interval", feed->autoUpdateInterval());
|
||||
query_add_feed.bindValue(":type", (int) FeedsModelCategory::Standard);
|
||||
|
||||
if (!query_add_feed.exec()) {
|
||||
|
@ -324,7 +326,7 @@ bool FeedsModel::editStandardFeed(FeedsModelStandardFeed *original_feed,
|
|||
|
||||
query_update_feed.setForwardOnly(true);
|
||||
query_update_feed.prepare("UPDATE Feeds "
|
||||
"SET title = :title, description = :description, icon = :icon, category = :category, encoding = :encoding, url = :url, protected = :protected, username = :username, password = :password, type = :type "
|
||||
"SET title = :title, description = :description, icon = :icon, category = :category, encoding = :encoding, url = :url, protected = :protected, username = :username, password = :password, update_type = :update_type, update_interval = :update_interval, type = :type "
|
||||
"WHERE id = :id;");
|
||||
query_update_feed.bindValue(":title", new_feed->title());
|
||||
query_update_feed.bindValue(":description", new_feed->description());
|
||||
|
@ -335,12 +337,12 @@ bool FeedsModel::editStandardFeed(FeedsModelStandardFeed *original_feed,
|
|||
query_update_feed.bindValue(":protected", (int) new_feed->passwordProtected());
|
||||
query_update_feed.bindValue(":username", new_feed->username());
|
||||
query_update_feed.bindValue(":password", new_feed->password());
|
||||
query_update_feed.bindValue(":update_type", (int) new_feed->autoUpdateType());
|
||||
query_update_feed.bindValue(":update_interval", new_feed->autoUpdateInterval());
|
||||
query_update_feed.bindValue(":type", new_feed->type());
|
||||
query_update_feed.bindValue(":id", original_feed->id());
|
||||
|
||||
if (!query_update_feed.exec()) {
|
||||
QString aaa = query_update_feed.lastError().databaseText();
|
||||
|
||||
// Persistent storage update failed, no way to continue now.
|
||||
return false;
|
||||
}
|
||||
|
@ -355,6 +357,8 @@ bool FeedsModel::editStandardFeed(FeedsModelStandardFeed *original_feed,
|
|||
original_feed->setPasswordProtected(new_feed->passwordProtected());
|
||||
original_feed->setUsername(new_feed->username());
|
||||
original_feed->setPassword(new_feed->password());
|
||||
original_feed->setAutoUpdateType(new_feed->autoUpdateType());
|
||||
original_feed->setAutoUpdateInterval(new_feed->autoUpdateInterval());
|
||||
original_feed->setType(new_feed->type());
|
||||
|
||||
if (original_parent != new_parent) {
|
||||
|
|
|
@ -15,7 +15,9 @@
|
|||
|
||||
|
||||
FeedsModelStandardFeed::FeedsModelStandardFeed(FeedsModelRootItem *parent_item)
|
||||
: FeedsModelFeed(parent_item), m_autoUpdateInterval(-1) {
|
||||
: FeedsModelFeed(parent_item),
|
||||
m_autoUpdateType(DontAutoUpdate),
|
||||
m_autoUpdateInterval(DEFAULT_AUTO_UPDATE_INTERVAL) {
|
||||
}
|
||||
|
||||
FeedsModelStandardFeed::~FeedsModelStandardFeed() {
|
||||
|
@ -35,6 +37,8 @@ FeedsModelStandardFeed *FeedsModelStandardFeed::loadFromRecord(const QSqlRecord
|
|||
feed->setPasswordProtected(record.value(FDS_DB_PROTECTED_INDEX).toBool());
|
||||
feed->setUsername(record.value(FDS_DB_USERNAME_INDEX).toString());
|
||||
feed->setPassword(record.value(FDS_DB_PASSWORD_INDEX).toString());
|
||||
feed->setAutoUpdateType(static_cast<FeedsModelStandardFeed::AutoUpdateType>(record.value(FDS_DB_UPDATE_TYPE_INDEX).toInt()));
|
||||
feed->setAutoUpdateInterval(record.value(FDS_DB_UPDATE_INTERVAL_INDEX).toInt());
|
||||
feed->updateCounts();
|
||||
|
||||
return feed;
|
||||
|
@ -280,7 +284,3 @@ void FeedsModelStandardFeed::updateMessages(const QList<Message> &messages) {
|
|||
qDebug("Transaction commit for message downloader failed.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -14,6 +14,12 @@ class Message;
|
|||
// So, parent item is either root item or category.
|
||||
class FeedsModelStandardFeed : public FeedsModelFeed {
|
||||
public:
|
||||
enum AutoUpdateType {
|
||||
DontAutoUpdate = 0,
|
||||
DefaultAutpUpdate = 1,
|
||||
SpecificAutoUpdate = 2
|
||||
};
|
||||
|
||||
// Constructors and destructors.
|
||||
explicit FeedsModelStandardFeed(FeedsModelRootItem *parent_item = NULL);
|
||||
virtual ~FeedsModelStandardFeed();
|
||||
|
@ -53,6 +59,14 @@ class FeedsModelStandardFeed : public FeedsModelFeed {
|
|||
m_autoUpdateInterval = auto_update_interval;
|
||||
}
|
||||
|
||||
inline AutoUpdateType autoUpdateType() const {
|
||||
return m_autoUpdateType;
|
||||
}
|
||||
|
||||
inline void setAutoUpdateType(const AutoUpdateType &autoUpdateType) {
|
||||
m_autoUpdateType = autoUpdateType;
|
||||
}
|
||||
|
||||
// Loads standard feed object from given SQL record.
|
||||
static FeedsModelStandardFeed *loadFromRecord(const QSqlRecord &record);
|
||||
|
||||
|
@ -63,6 +77,7 @@ class FeedsModelStandardFeed : public FeedsModelFeed {
|
|||
void updateMessages(const QList<Message> &messages);
|
||||
|
||||
private:
|
||||
AutoUpdateType m_autoUpdateType;
|
||||
// NOTE: Number -1 means "do not auto-update", number
|
||||
// 0 means "auto-update with global interval" and number
|
||||
// > 0 means "auto-update with specific interval".
|
||||
|
|
|
@ -131,6 +131,21 @@ void FormStandardFeedDetails::onAuthenticationSwitched() {
|
|||
onPasswordChanged(m_ui->m_txtPassword->lineEdit()->text());
|
||||
}
|
||||
|
||||
void FormStandardFeedDetails::onAutoUpdateTypeChanged(int new_index) {
|
||||
FeedsModelStandardFeed::AutoUpdateType auto_update_type = static_cast<FeedsModelStandardFeed::AutoUpdateType>(m_ui->m_cmbAutoUpdateType->itemData(new_index).toInt());
|
||||
|
||||
switch (auto_update_type) {
|
||||
case FeedsModelStandardFeed::DontAutoUpdate:
|
||||
case FeedsModelStandardFeed::DefaultAutpUpdate:
|
||||
m_ui->m_spinAutoUpdateInterval->setEnabled(false);
|
||||
break;
|
||||
|
||||
case FeedsModelStandardFeed::SpecificAutoUpdate:
|
||||
default:
|
||||
m_ui->m_spinAutoUpdateInterval->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void FormStandardFeedDetails::checkOkButtonEnabled() {
|
||||
LineEditWithStatus::StatusType title_status = m_ui->m_txtTitle->status();
|
||||
LineEditWithStatus::StatusType url_status = m_ui->m_txtUrl->status();
|
||||
|
@ -182,6 +197,8 @@ void FormStandardFeedDetails::apply() {
|
|||
new_feed->setPasswordProtected(m_ui->m_gbAuthentication->isChecked());
|
||||
new_feed->setUsername(m_ui->m_txtUsername->lineEdit()->text());
|
||||
new_feed->setPassword(m_ui->m_txtPassword->lineEdit()->text());
|
||||
new_feed->setAutoUpdateType(static_cast<FeedsModelStandardFeed::AutoUpdateType>(m_ui->m_cmbAutoUpdateType->itemData(m_ui->m_cmbAutoUpdateType->currentIndex()).toInt()));
|
||||
new_feed->setAutoUpdateInterval(m_ui->m_spinAutoUpdateInterval->value());
|
||||
new_feed->setParent(parent);
|
||||
|
||||
if (m_editableFeed == NULL) {
|
||||
|
@ -240,6 +257,8 @@ void FormStandardFeedDetails::createConnections() {
|
|||
this, SLOT(onPasswordChanged(QString)));
|
||||
connect(m_ui->m_gbAuthentication, SIGNAL(toggled(bool)),
|
||||
this, SLOT(onAuthenticationSwitched()));
|
||||
connect(m_ui->m_cmbAutoUpdateType, SIGNAL(currentIndexChanged(int)),
|
||||
this, SLOT(onAutoUpdateTypeChanged(int)));
|
||||
|
||||
// Icon connections.
|
||||
connect(m_actionLoadIconFromFile, SIGNAL(triggered()), this, SLOT(onLoadIconFromFile()));
|
||||
|
@ -260,6 +279,8 @@ void FormStandardFeedDetails::setEditableFeed(FeedsModelStandardFeed *editable_f
|
|||
m_ui->m_txtUsername->lineEdit()->setText(editable_feed->username());
|
||||
m_ui->m_txtPassword->lineEdit()->setText(editable_feed->password());
|
||||
m_ui->m_txtUrl->lineEdit()->setText(editable_feed->url());
|
||||
m_ui->m_cmbAutoUpdateType->setCurrentIndex(m_ui->m_cmbAutoUpdateType->findData(QVariant::fromValue((int) editable_feed->autoUpdateType())));
|
||||
m_ui->m_spinAutoUpdateInterval->setValue(editable_feed->autoUpdateInterval());
|
||||
}
|
||||
|
||||
void FormStandardFeedDetails::initialize() {
|
||||
|
@ -331,6 +352,12 @@ void FormStandardFeedDetails::initialize() {
|
|||
m_iconMenu->addAction(m_actionNoIcon);
|
||||
m_ui->m_btnIcon->setMenu(m_iconMenu);
|
||||
|
||||
// Setup auto-update options.
|
||||
m_ui->m_spinAutoUpdateInterval->setValue(DEFAULT_AUTO_UPDATE_INTERVAL);
|
||||
m_ui->m_cmbAutoUpdateType->addItem(tr("Do not auto-update at all"), QVariant::fromValue((int) FeedsModelStandardFeed::DontAutoUpdate));
|
||||
m_ui->m_cmbAutoUpdateType->addItem(tr("Auto-update using global interval"), QVariant::fromValue((int) FeedsModelStandardFeed::DefaultAutpUpdate));
|
||||
m_ui->m_cmbAutoUpdateType->addItem(tr("Auto-update every"), QVariant::fromValue((int) FeedsModelStandardFeed::SpecificAutoUpdate));
|
||||
|
||||
// Set tab order.
|
||||
setTabOrder(m_ui->m_buttonBox, m_ui->m_cmbParentCategory);
|
||||
setTabOrder(m_ui->m_cmbParentCategory, m_ui->m_cmbType);
|
||||
|
|
|
@ -38,6 +38,7 @@ class FormStandardFeedDetails : public QDialog {
|
|||
void onUsernameChanged(const QString &new_username);
|
||||
void onPasswordChanged(const QString &new_password);
|
||||
void onAuthenticationSwitched();
|
||||
void onAutoUpdateTypeChanged(int new_index);
|
||||
|
||||
// Check if "OK" button can be enabled or not.
|
||||
void checkOkButtonEnabled();
|
||||
|
|
|
@ -109,26 +109,13 @@
|
|||
<item row="6" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QComboBox" name="m_cmbAutoUpdateType">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Do not auto-update at all</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Auto-update using global interval</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Auto-update every</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="m_cmbAutoUpdateType"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="m_spinAutoUpdateInterval">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>130</width>
|
||||
|
@ -142,7 +129,7 @@
|
|||
<number>5</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
<number>240</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>15</number>
|
||||
|
|
Loading…
Add table
Reference in a new issue