diff --git a/localization/rssguard_cs.ts b/localization/rssguard_cs.ts
index 0ee6d0abb..afb79cdf9 100644
--- a/localization/rssguard_cs.ts
+++ b/localization/rssguard_cs.ts
@@ -120,11 +120,11 @@
Title
- Nadpis
+ Název
Title of the category
-
+ Název kategorie
Description
@@ -359,11 +359,11 @@
Update &all items
-
+ Aktualizov&at všechny položky
Update &selected items
-
+ Aktualizovat v&ybrané položky
&Delete selected feeds/categories
@@ -371,31 +371,31 @@
Mark &selected items read
-
+ Označit vybrané položky jako přečte&né
Mark selected items unread
-
+ Označit vybrané položky jako nepřečtené
Clear selected items
-
+ Vyprázdnit vybrané položky
Mark all &items read
-
+ Označ&it všechny položky jako přečtené
Mark all messages in all feeds read. This does not take message filters into account.
-
+ Označí všechny zprávy ve všech kanálech jako přečtené. Toto nebere v potaz filtry zpráv.
View selected items in newspaper mode
-
+ Zobrazit vybrané položky v novinovém náhledu
Displays all messages from selected feeds/categories in a new "newspaper mode" tab. All selected feeds are marked as read.
-
+ Zobrazí všechny zprávy z vybraných kanálů v novinovém náhledu v novém panelu.
@@ -874,11 +874,11 @@
Meesage without URL
-
+ Zpráva bez URL
Message '%s' does not contain URL.
-
+ Zpráva '%s' neobsahuje URL.
diff --git a/src/core/basenetworkaccessmanager.cpp b/src/core/basenetworkaccessmanager.cpp
index e7166a3e5..13c6e6490 100644
--- a/src/core/basenetworkaccessmanager.cpp
+++ b/src/core/basenetworkaccessmanager.cpp
@@ -51,7 +51,8 @@ QNetworkReply *BaseNetworkAccessManager::createRequest(QNetworkAccessManager::Op
// This rapidly speeds up loading of web sites.
// NOTE: https://en.wikipedia.org/wiki/HTTP_pipelining
- new_request.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
+ new_request.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute,
+ true);
// Setup custom user-agent.
new_request.setRawHeader(USER_AGENT_HTTP_HEADER,
diff --git a/src/core/basenetworkaccessmanager.h b/src/core/basenetworkaccessmanager.h
index 1016c9aba..d058b4850 100644
--- a/src/core/basenetworkaccessmanager.h
+++ b/src/core/basenetworkaccessmanager.h
@@ -19,6 +19,7 @@ class BaseNetworkAccessManager : public QNetworkAccessManager {
virtual void loadSettings();
protected:
+ // Creates custom request.
QNetworkReply *createRequest(Operation op,
const QNetworkRequest &request,
QIODevice *outgoingData);
diff --git a/src/core/databasefactory.cpp b/src/core/databasefactory.cpp
index dbd2064ea..7f73b3a97 100644
--- a/src/core/databasefactory.cpp
+++ b/src/core/databasefactory.cpp
@@ -21,7 +21,7 @@ DatabaseFactory::~DatabaseFactory() {
qDebug("Destroying DatabaseFactory object.");
}
-DatabaseFactory *DatabaseFactory::getInstance() {
+DatabaseFactory *DatabaseFactory::instance() {
if (s_instance.isNull()) {
s_instance = new DatabaseFactory(qApp);
}
@@ -126,12 +126,14 @@ QSqlDatabase DatabaseFactory::initialize(const QString &connection_name) {
query_db.finish();
}
+ // Everything is initialized now.
+ m_initialized = true;
+
return database;
}
QSqlDatabase DatabaseFactory::connection(const QString &connection_name) {
if (!m_initialized) {
- m_initialized = true;
return initialize(connection_name);
}
else {
diff --git a/src/core/databasefactory.h b/src/core/databasefactory.h
index c00675f59..4815bea55 100644
--- a/src/core/databasefactory.h
+++ b/src/core/databasefactory.h
@@ -23,7 +23,7 @@ class DatabaseFactory : public QObject {
void removeConnection(const QString &connection_name);
// Singleton getter.
- static DatabaseFactory *getInstance();
+ static DatabaseFactory *instance();
private:
// Conctructor.
diff --git a/src/core/defs.h.in b/src/core/defs.h.in
index 13d821c72..6dad95f41 100755
--- a/src/core/defs.h.in
+++ b/src/core/defs.h.in
@@ -35,9 +35,7 @@
#define DOWNLOAD_TIMEOUT 5000
#define MESSAGES_VIEW_DEFAULT_COL 170
#define ELLIPSIS_LENGTH 3
-#define INTERNAL_URL_SCHEME APP_LOW_NAME
#define INTERNAL_URL_NEWSPAPER "@APP_LOW_NAME@:newspaper"
-#define INTERNAL_URL_NEWSPAPER_PATH "newspaper"
#define APP_DB_INIT_FILE "db_init.sql"
#define APP_DB_INIT_SPLIT "-- !\n"
diff --git a/src/core/feeddownloader.cpp b/src/core/feeddownloader.cpp
index 57d3d66fb..99e0d5ba2 100644
--- a/src/core/feeddownloader.cpp
+++ b/src/core/feeddownloader.cpp
@@ -18,6 +18,7 @@ void FeedDownloader::updateFeeds(const QList &feeds) {
qDebug().nospace() << "Performing feed updates in thread: \'" <<
QThread::currentThreadId() << "\'.";
+ // Job starts now.
emit started();
for (int i = 0, total = feeds.size(); i < total; i++) {
diff --git a/src/core/feedsmodel.cpp b/src/core/feedsmodel.cpp
index b026403ae..2628c16cd 100644
--- a/src/core/feedsmodel.cpp
+++ b/src/core/feedsmodel.cpp
@@ -23,7 +23,7 @@ FeedsModel::FeedsModel(QObject *parent) : QAbstractItemModel(parent) {
m_rootItem->setId(NO_PARENT_CATEGORY);
m_rootItem->setTitle(tr("root"));
m_rootItem->setIcon(IconThemeFactory::getInstance()->fromTheme("folder-red"));
- m_countsIcon = IconThemeFactory::getInstance()->fromTheme("mail-mark-unread");
+ m_countsIcon = IconThemeFactory::getInstance()->fromTheme("mail-mark-important");
m_headerData << tr("Title");
m_tooltipData << tr("Titles of feeds/categories.") <<
tr("Counts of unread/all meesages.");
@@ -34,8 +34,11 @@ FeedsModel::FeedsModel(QObject *parent) : QAbstractItemModel(parent) {
FeedsModel::~FeedsModel() {
qDebug("Destroying FeedsModel instance.");
+ // Delete all model items.
delete m_rootItem;
- DatabaseFactory::getInstance()->removeConnection(objectName());
+
+ // Remove connection.
+ DatabaseFactory::instance()->removeConnection(objectName());
}
QVariant FeedsModel::data(const QModelIndex &index, int role) const {
@@ -81,6 +84,8 @@ QModelIndex FeedsModel::index(int row, int column, const QModelIndex &parent) co
FeedsModelRootItem *parent_item;
+ // TODO: overit zda zde misto internalPointer nepouzit
+ // metodu itemFornIndex a overit vykonnostni dopady
if (!parent.isValid()) {
parent_item = m_rootItem;
}
@@ -103,6 +108,8 @@ QModelIndex FeedsModel::parent(const QModelIndex &child) const {
return QModelIndex();
}
+ // TODO: overit zda zde misto internalPointer nepouzit
+ // metodu itemFornIndex a overit vykonnostni dopady
FeedsModelRootItem *child_item = static_cast(child.internalPointer());
FeedsModelRootItem *parent_item = child_item->parent();
@@ -121,6 +128,8 @@ int FeedsModel::rowCount(const QModelIndex &parent) const {
return 0;
}
+ // TODO: overit zda zde misto internalPointer nepouzit
+ // metodu itemFornIndex a overit vykonnostni dopady
if (!parent.isValid()) {
parent_item = m_rootItem;
}
@@ -157,7 +166,9 @@ bool FeedsModel::removeItems(const QModelIndexList &indexes) {
FeedsModelRootItem *parent_item = itemForIndex(parent_index);
beginRemoveRows(parent_index, index.row(), index.row());
- items_for_deletion << parent_item->removeChild(index.row());
+ if (parent_item->removeChild(index.row())) {
+ items_for_deletion << item;
+ }
endRemoveRows();
}
}
@@ -167,14 +178,13 @@ bool FeedsModel::removeItems(const QModelIndexList &indexes) {
delete items_for_deletion.takeFirst();
}
-
return true;
}
-QList FeedsModel::messagesForFeeds(const QList &feeds) {
+QList FeedsModel::messagesForFeeds(const QList &feeds) {
QList messages;
- QSqlDatabase database = DatabaseFactory::getInstance()->connection(objectName());
+ QSqlDatabase database = DatabaseFactory::instance()->connection(objectName());
QSqlQuery query_read_msg(database);
query_read_msg.setForwardOnly(true);
query_read_msg.prepare("SELECT title, url, author, date_created, contents "
@@ -203,6 +213,8 @@ QList FeedsModel::messagesForFeeds(const QList &feeds
}
int FeedsModel::columnCount(const QModelIndex &parent) const {
+ // TODO: overit zda zde misto internalPointer nepouzit
+ // metodu itemFornIndex a overit vykonnostni dopady
if (parent.isValid()) {
return static_cast(parent.internalPointer())->columnCount();
}
@@ -314,7 +326,7 @@ void FeedsModel::loadFromDatabase() {
qDeleteAll(m_rootItem->childItems());
m_rootItem->clearChilds();
- QSqlDatabase database = DatabaseFactory::getInstance()->connection(objectName());
+ QSqlDatabase database = DatabaseFactory::instance()->connection(objectName());
CategoryAssignment categories;
FeedAssignment feeds;
@@ -416,7 +428,8 @@ QList FeedsModel::feedsForIndexes(const QModelIndexList &indexe
// example situation where feed and its parent category are both
// selected). So, remove duplicates from the list.
qSort(feeds.begin(), feeds.end(), FeedsModelRootItem::lessThan);
- feeds.erase(std::unique(feeds.begin(), feeds.end(), FeedsModelRootItem::isEqual),
+ feeds.erase(std::unique(feeds.begin(),
+ feeds.end(), FeedsModelRootItem::isEqual),
feeds.end());
}
@@ -425,7 +438,7 @@ QList FeedsModel::feedsForIndexes(const QModelIndexList &indexe
bool FeedsModel::markFeedsRead(const QList &feeds,
int read) {
- QSqlDatabase db_handle = DatabaseFactory::getInstance()->connection(objectName());
+ QSqlDatabase db_handle = DatabaseFactory::instance()->connection(objectName());
if (!db_handle.transaction()) {
qWarning("Starting transaction for feeds read change.");
@@ -461,7 +474,7 @@ bool FeedsModel::markFeedsRead(const QList &feeds,
bool FeedsModel::markFeedsDeleted(const QList &feeds,
int deleted) {
- QSqlDatabase db_handle = DatabaseFactory::getInstance()->connection(objectName());
+ QSqlDatabase db_handle = DatabaseFactory::instance()->connection(objectName());
if (!db_handle.transaction()) {
qWarning("Starting transaction for feeds clearing.");
diff --git a/src/core/feedsmodel.h b/src/core/feedsmodel.h
index dfd6b3fc9..5061ac769 100644
--- a/src/core/feedsmodel.h
+++ b/src/core/feedsmodel.h
@@ -36,7 +36,7 @@ class FeedsModel : public QAbstractItemModel {
// Feed/category manipulators.
bool removeItems(const QModelIndexList &indexes);
- // Returns all (undeleted) messages for given feeds.
+ // Returns (undeleted) messages for given feeds.
QList messagesForFeeds(const QList &feeds);
// Returns all categories, each pair
diff --git a/src/core/feedsmodelfeed.cpp b/src/core/feedsmodelfeed.cpp
index ebb36d12c..5d1f45049 100755
--- a/src/core/feedsmodelfeed.cpp
+++ b/src/core/feedsmodelfeed.cpp
@@ -58,7 +58,7 @@ QString FeedsModelFeed::typeToString(FeedsModelFeed::Type type) {
}
void FeedsModelFeed::updateCounts(bool including_total_count) {
- QSqlDatabase database = DatabaseFactory::getInstance()->connection("FeedsModelFeed");
+ QSqlDatabase database = DatabaseFactory::instance()->connection("FeedsModelFeed");
QSqlQuery query_all(database);
query_all.setForwardOnly(true);
diff --git a/src/core/feedsmodelrootitem.cpp b/src/core/feedsmodelrootitem.cpp
index 3b5dab491..a7102cb46 100755
--- a/src/core/feedsmodelrootitem.cpp
+++ b/src/core/feedsmodelrootitem.cpp
@@ -56,7 +56,7 @@ int FeedsModelRootItem::row() const {
}
int FeedsModelRootItem::childCount() const {
- return m_childItems.count();
+ return m_childItems.size();
}
QVariant FeedsModelRootItem::data(int column, int role) const {
@@ -103,12 +103,14 @@ void FeedsModelRootItem::clearChilds() {
m_childItems.clear();
}
-FeedsModelRootItem *FeedsModelRootItem::removeChild(int index) {
- FeedsModelRootItem *item_to_delete = m_childItems.at(index);
-
- m_childItems.removeAt(index);
-
- return item_to_delete;
+bool FeedsModelRootItem::removeChild(int index) {
+ if (index >= 0 && index < m_childItems.size()) {
+ m_childItems.removeAt(index);
+ return true;
+ }
+ else {
+ return false;
+ }
}
diff --git a/src/core/feedsmodelrootitem.h b/src/core/feedsmodelrootitem.h
index 6b6030c30..f50e682f1 100755
--- a/src/core/feedsmodelrootitem.h
+++ b/src/core/feedsmodelrootitem.h
@@ -66,7 +66,7 @@ class FeedsModelRootItem {
// Removes particular child at given index.
// NOTE: Child is NOT freed from the memory.
- FeedsModelRootItem *removeChild(int index);
+ bool removeChild(int index);
// Compares two model items.
static bool isEqual(FeedsModelRootItem *lhs, FeedsModelRootItem *rhs);
diff --git a/src/core/feedsmodelstandardfeed.cpp b/src/core/feedsmodelstandardfeed.cpp
index 295efb4bc..a3315a3f4 100755
--- a/src/core/feedsmodelstandardfeed.cpp
+++ b/src/core/feedsmodelstandardfeed.cpp
@@ -189,7 +189,7 @@ void FeedsModelStandardFeed::update() {
void FeedsModelStandardFeed::updateMessages(const QList &messages) {
int feed_id = id(), message_id;
qint64 message_creation_date;
- QSqlDatabase database = DatabaseFactory::getInstance()->connection("FeedsModelStandardFeed");
+ QSqlDatabase database = DatabaseFactory::instance()->connection("FeedsModelStandardFeed");
// Prepare queries.
QSqlQuery query_select(database);
diff --git a/src/core/feedsproxymodel.cpp b/src/core/feedsproxymodel.cpp
index 41838b529..5259cf69c 100755
--- a/src/core/feedsproxymodel.cpp
+++ b/src/core/feedsproxymodel.cpp
@@ -33,8 +33,8 @@ bool FeedsProxyModel::lessThan(const QModelIndex &left,
const QModelIndex &right) const {
if (left.isValid() && right.isValid()) {
// Make necessary castings.
- FeedsModelRootItem *left_item = static_cast(left.internalPointer());
- FeedsModelRootItem *right_item = static_cast(right.internalPointer());
+ FeedsModelRootItem *left_item = m_sourceModel->itemForIndex(left);
+ FeedsModelRootItem *right_item = m_sourceModel->itemForIndex(right);
// NOTE: Here we want to accomplish that ALL
// categories are queued one after another and all
@@ -59,7 +59,10 @@ bool FeedsProxyModel::lessThan(const QModelIndex &left,
return false;
}
else {
- // Left item is category, right item is feed.*/
+ // Left item is category, right item is feed.
+ // NOTE: Category is in fact "more" than feed but
+ // we consider it to be "less" because it should be "placed"
+ // above the "smalles" feed when ascending sort is used.
return true;
}
}
diff --git a/src/core/messagesmodel.cpp b/src/core/messagesmodel.cpp
index 7c81fdadb..9ee30d39e 100644
--- a/src/core/messagesmodel.cpp
+++ b/src/core/messagesmodel.cpp
@@ -13,7 +13,7 @@
MessagesModel::MessagesModel(QObject *parent)
: QSqlTableModel(parent,
- DatabaseFactory::getInstance()->connection("MessagesModel")) {
+ DatabaseFactory::instance()->connection("MessagesModel")) {
setObjectName("MessagesModel");
setupFonts();
diff --git a/src/gui/feedsview.cpp b/src/gui/feedsview.cpp
index 6aeb92592..5bed3ed40 100644
--- a/src/gui/feedsview.cpp
+++ b/src/gui/feedsview.cpp
@@ -111,7 +111,18 @@ void FeedsView::deleteSelectedItems() {
QModelIndexList selection = selectionModel()->selectedRows();
QModelIndexList mapped_selection = m_proxyModel->mapListToSource(selection);
+ FeedsModelRootItem *parent = m_sourceModel->itemForIndex(mapped_selection.at(0).parent());
+
m_sourceModel->removeItems(mapped_selection);
+
+ QModelIndex id = m_sourceModel->indexForItem(parent);
+
+ if (id.isValid()) {
+ selectionModel()->clearSelection();
+ selectionModel()->select(m_proxyModel->mapFromSource(id),
+ QItemSelectionModel::Rows |
+ QItemSelectionModel::Select);
+ }
}
void FeedsView::markSelectedFeedsReadStatus(int read) {