Some foreach cleanups.

This commit is contained in:
Martin Rotter 2013-12-26 15:56:37 +01:00
parent 3735267e31
commit b2cc920a70
8 changed files with 42 additions and 62 deletions

View File

@ -15,12 +15,11 @@ Localization::Localization() {
QList<Language> Localization::getInstalledLanguages() {
QList<Language> languages;
QDir file_dir(APP_LANG_PATH);
QFileInfoList file_list = file_dir.entryInfoList(QStringList() << "rssguard_*.qm",
QDir::Files,
QDir::Name);
QTranslator translator;
foreach (const QFileInfo &file, file_list) {
foreach (const QFileInfo &file, file_dir.entryInfoList(QStringList() << "rssguard_*.qm",
QDir::Files,
QDir::Name)) {
if (translator.load(file.absoluteFilePath())) {
Language new_language;
new_language.m_name = translator.translate("QObject", "LANG_NAME");

View File

@ -398,8 +398,8 @@ bool MessagesModel::setBatchMessagesRead(const QModelIndexList &messages, int re
}
int message_id;
QSqlQuery query_delete_msg(db_handle);
if (!query_delete_msg.prepare("UPDATE messages SET read = :read "
QSqlQuery query_read_msg(db_handle);
if (!query_read_msg.prepare("UPDATE messages SET read = :read "
"WHERE id = :id")) {
qWarning("Query preparation failed for message read change.");
@ -409,9 +409,9 @@ bool MessagesModel::setBatchMessagesRead(const QModelIndexList &messages, int re
foreach (const QModelIndex &message, messages) {
message_id = messageId(message.row());
query_delete_msg.bindValue(":id", message_id);
query_delete_msg.bindValue(":read", read);
query_delete_msg.exec();
query_read_msg.bindValue(":id", message_id);
query_read_msg.bindValue(":read", read);
query_read_msg.exec();
}
// Commit changes.

View File

@ -177,7 +177,7 @@ void FeedMessageViewer::createConnections() {
SIGNAL(triggered()), m_messagesView, SLOT(setAllMessagesRead()));
connect(FormMain::getInstance()->m_ui->m_actionMarkFeedsAsUnread,
SIGNAL(triggered()), m_messagesView, SLOT(setAllMessagesUnread()));
connect(FormMain::getInstance()->m_ui->m_actionDeleteAllMessages,
connect(FormMain::getInstance()->m_ui->m_actionClearFeeds,
SIGNAL(triggered()), m_messagesView, SLOT(setAllMessagesDeleted()));
connect(FormMain::getInstance()->m_ui->m_actionUpdateSelectedFeeds,
SIGNAL(triggered()), this, SLOT(updateSelectedFeeds()));
@ -200,8 +200,11 @@ void FeedMessageViewer::initialize() {
m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionDeleteSelectedFeeds);
m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionMarkFeedsAsRead);
m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionMarkFeedsAsUnread);
m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionClearFeeds);
m_toolBar->addSeparator();
m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionDeleteAllMessages);
m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionMarkSelectedMessagesAsRead);
m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionMarkSelectedMessagesAsUnread);
m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionDeleteSelectedMessages);
// Finish web/message browser setup.
m_messagesBrowser->setNavigationBarVisible(false);

View File

@ -39,9 +39,7 @@ QList<FeedsModelFeed *> FeedsView::allFeeds() const {
}
void FeedsView::updateCountsOfSelectedFeeds(bool update_total_too) {
QList<FeedsModelFeed*> feeds = selectedFeeds();
foreach (FeedsModelFeed *feed, feeds) {
foreach (FeedsModelFeed *feed, selectedFeeds()) {
feed->updateCounts(update_total_too);
}
@ -50,9 +48,7 @@ void FeedsView::updateCountsOfSelectedFeeds(bool update_total_too) {
}
void FeedsView::updateCountsOfAllFeeds(bool update_total_too) {
QList<FeedsModelFeed*> feeds = allFeeds();
foreach (FeedsModelFeed *feed, feeds) {
foreach (FeedsModelFeed *feed, allFeeds()) {
feed->updateCounts(update_total_too);
}
@ -86,12 +82,11 @@ void FeedsView::selectionChanged(const QItemSelection &selected,
const QItemSelection &deselected) {
QTreeView::selectionChanged(selected, deselected);
QList<FeedsModelFeed*> selected_feeds = selectedFeeds();
QList<int> feed_ids;
m_selectedFeeds.clear();
foreach (FeedsModelFeed *feed, selected_feeds) {
feed_ids << feed->id();
foreach (FeedsModelFeed *feed, selectedFeeds()) {
m_selectedFeeds << feed->id();
}
emit feedsSelected(feed_ids);
emit feedsSelected(m_selectedFeeds);
}

View File

@ -41,6 +41,7 @@ class FeedsView : public QTreeView {
void feedsSelected(const QList<int> &feed_ids);
private:
QList<int> m_selectedFeeds;
FeedsModel *m_sourceModel;
FeedsProxyModel *m_proxyModel;
};

View File

@ -83,7 +83,7 @@ QList<QAction*> FormMain::getActions() {
m_ui->m_actionOpenSelectedMessagesInternally <<
m_ui->m_actionMarkFeedsAsRead <<
m_ui->m_actionMarkFeedsAsUnread <<
m_ui->m_actionDeleteAllMessages <<
m_ui->m_actionClearFeeds <<
m_ui->m_actionMarkSelectedMessagesAsRead <<
m_ui->m_actionMarkSelectedMessagesAsUnread <<
m_ui->m_actionSwitchImportanceOfSelectedMessages <<
@ -217,11 +217,9 @@ void FormMain::setupIcons() {
// Feeds/messages.
m_ui->m_actionUpdateAllFeeds->setIcon(IconThemeFactory::getInstance()->fromTheme("document-save-as"));
m_ui->m_actionUpdateSelectedFeeds->setIcon(IconThemeFactory::getInstance()->fromTheme("document-save"));
m_ui->m_actionDeleteAllMessages->setIcon(IconThemeFactory::getInstance()->fromTheme("edit-delete"));
m_ui->m_actionClearFeeds->setIcon(IconThemeFactory::getInstance()->fromTheme("mail-mark-junk"));
m_ui->m_actionDeleteSelectedFeeds->setIcon(IconThemeFactory::getInstance()->fromTheme("edit-delete"));
m_ui->m_actionDeleteSelectedMessages->setIcon(IconThemeFactory::getInstance()->fromTheme("edit-delete"));
m_ui->m_actionDeleteSelectedMessages->setIcon(IconThemeFactory::getInstance()->fromTheme("mail-mark-junk"));
m_ui->m_actionAddNewCategory->setIcon(IconThemeFactory::getInstance()->fromTheme("document-new"));
m_ui->m_actionAddNewFeed->setIcon(IconThemeFactory::getInstance()->fromTheme("document-new"));
m_ui->m_actionEditSelectedFeed->setIcon(IconThemeFactory::getInstance()->fromTheme("gnome-other"));

View File

@ -46,9 +46,6 @@
<property name="title">
<string>&amp;File</string>
</property>
<addaction name="m_actionImport"/>
<addaction name="m_actionExport"/>
<addaction name="separator"/>
<addaction name="m_actionQuit"/>
</widget>
<widget class="QMenu" name="m_menuHelp">
@ -98,6 +95,7 @@
<addaction name="separator"/>
<addaction name="m_actionMarkFeedsAsRead"/>
<addaction name="m_actionMarkFeedsAsUnread"/>
<addaction name="m_actionClearFeeds"/>
</widget>
<widget class="QMenu" name="m_menuMessages">
<property name="title">
@ -106,9 +104,7 @@
<addaction name="m_actionMarkSelectedMessagesAsRead"/>
<addaction name="m_actionMarkSelectedMessagesAsUnread"/>
<addaction name="m_actionSwitchImportanceOfSelectedMessages"/>
<addaction name="separator"/>
<addaction name="m_actionDeleteSelectedMessages"/>
<addaction name="m_actionDeleteAllMessages"/>
</widget>
<addaction name="m_menuFile"/>
<addaction name="m_menuView"/>
@ -221,20 +217,6 @@
<string notr="true">Ctrl+Shift+C</string>
</property>
</action>
<action name="m_actionNoActions">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>&amp;No actions possible</string>
</property>
<property name="toolTip">
<string>No actions are possible at this point of time.</string>
</property>
<property name="shortcut">
<string notr="true"/>
</property>
</action>
<action name="m_actionUpdateAllFeeds">
<property name="text">
<string>Update &amp;all feeds</string>
@ -259,7 +241,7 @@
</action>
<action name="m_actionEditSelectedFeed">
<property name="text">
<string>&amp;Edit selected feed(s)/category(ies)</string>
<string>&amp;Edit selected feed/category</string>
</property>
<property name="toolTip">
<string>Edit selected feed/category.</string>
@ -314,7 +296,7 @@
</action>
<action name="m_actionMarkFeedsAsRead">
<property name="text">
<string>Mark &amp;selected feed(s) read</string>
<string>Mark &amp;selected feeds read</string>
</property>
<property name="toolTip">
<string>Marks all messages (without message filters) from selected feeds as read.</string>
@ -330,21 +312,18 @@
</action>
<action name="m_actionDeleteSelectedMessages">
<property name="text">
<string>&amp;Delete selected messages</string>
<string>&amp;Clear selected messages</string>
</property>
<property name="toolTip">
<string>Delete selected messages.</string>
</property>
<property name="shortcut">
<string notr="true"/>
</property>
</action>
<action name="m_actionDeleteAllMessages">
<action name="m_actionClearFeeds">
<property name="text">
<string>Dele&amp;te all messages</string>
<string>Clear selected feeds</string>
</property>
<property name="toolTip">
<string>Delete all messages from selected feeds. This does NOT take message filters into account.</string>
<string>Removes all messages from selected feeds.</string>
</property>
</action>
<action name="m_actionAddNewFeed">
@ -399,6 +378,14 @@
<string notr="true"/>
</property>
</action>
<action name="m_actionNoActions">
<property name="text">
<string>No actions available</string>
</property>
<property name="toolTip">
<string>No actions are available right now.</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>

View File

@ -123,7 +123,7 @@ void FormSettings::onSkinSelected(QTreeWidgetItem *current,
void FormSettings::changeBrowserProgressColor() {
QPointer<QColorDialog> color_dialog = new QColorDialog(m_initialSettings.m_webBrowserProgress,
this);
this);
color_dialog.data()->setWindowTitle(tr("Select color for web browser progress bar"));
color_dialog.data()->setOption(QColorDialog::ShowAlphaChannel);
@ -225,7 +225,7 @@ void FormSettings::promptForRestart() {
QStringList changed_data_texts = m_changedDataTexts;
changed_data_texts.replaceInStrings(QRegExp("^"),
QString::fromUtf8(""));
QString::fromUtf8(""));
QPointer<QMessageBox> msg_question = new QMessageBox(this);
msg_question.data()->setText(tr("Some critical settings were changed and will be applied after the application gets restarted."));
@ -368,9 +368,7 @@ void FormSettings::saveProxy() {
}
void FormSettings::loadLanguage() {
QList<Language> languages = Localization::getInstalledLanguages();
foreach (const Language &language, languages) {
foreach (const Language &language, Localization::getInstalledLanguages()) {
QTreeWidgetItem *item = new QTreeWidgetItem(m_ui->m_treeLanguages);
item->setText(0, language.m_name);
item->setText(1, language.m_code);
@ -504,10 +502,9 @@ void FormSettings::loadInterface() {
}
// Load skin.
QList<Skin> installed_skins = SkinFactory::getInstance()->getInstalledSkins();
QString selected_skin = SkinFactory::getInstance()->getSelectedSkinName();
foreach (const Skin &skin, installed_skins) {
foreach (const Skin &skin, SkinFactory::getInstance()->getInstalledSkins()) {
QTreeWidgetItem *new_item = new QTreeWidgetItem(QStringList() <<
skin.m_visibleName <<
skin.m_version <<