Refactorings...
This commit is contained in:
parent
7aa22a5fd5
commit
7da1338552
@ -18,7 +18,6 @@
|
|||||||
#include "application.h"
|
#include "application.h"
|
||||||
|
|
||||||
#include "miscellaneous/systemfactory.h"
|
#include "miscellaneous/systemfactory.h"
|
||||||
#include "gui/formmain.h"
|
|
||||||
#include "gui/feedsview.h"
|
#include "gui/feedsview.h"
|
||||||
#include "gui/feedmessageviewer.h"
|
#include "gui/feedmessageviewer.h"
|
||||||
#include "gui/messagebox.h"
|
#include "gui/messagebox.h"
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "definitions/definitions.h"
|
#include "definitions/definitions.h"
|
||||||
#include "miscellaneous/settings.h"
|
#include "miscellaneous/settings.h"
|
||||||
#include "gui/systemtrayicon.h"
|
#include "gui/systemtrayicon.h"
|
||||||
|
#include "gui/formmain.h"
|
||||||
|
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
|
|
||||||
@ -33,7 +34,6 @@
|
|||||||
// Define new qApp macro. Yeaaaaah.
|
// Define new qApp macro. Yeaaaaah.
|
||||||
#define qApp (Application::instance())
|
#define qApp (Application::instance())
|
||||||
|
|
||||||
class FormMain;
|
|
||||||
|
|
||||||
// TODO: presunout nektery veci sem, settings atp
|
// TODO: presunout nektery veci sem, settings atp
|
||||||
class Application : public QtSingleApplication {
|
class Application : public QtSingleApplication {
|
||||||
|
@ -382,46 +382,28 @@ void FeedMessageViewer::initializeViews() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FeedMessageViewer::vacuumDatabase() {
|
void FeedMessageViewer::vacuumDatabase() {
|
||||||
bool is_tray_activated = SystemTrayIcon::isSystemTrayActivated();
|
|
||||||
|
|
||||||
if (!qApp->closeLock()->tryLock()) {
|
if (!qApp->closeLock()->tryLock()) {
|
||||||
// Lock was not obtained because
|
// Lock was not obtained because
|
||||||
// it is used probably by feed updater or application
|
// it is used probably by feed updater or application
|
||||||
// is quitting.
|
// is quitting.
|
||||||
if (is_tray_activated) {
|
qApp->showGuiMessage(tr("Cannot defragment database"),
|
||||||
qApp->trayIcon()->showMessage(tr("Cannot defragment database"),
|
tr("Database cannot be defragmented because feed update is ongoing."),
|
||||||
tr("Database cannot be defragmented because feed update is ongoing."),
|
QSystemTrayIcon::Warning,
|
||||||
QSystemTrayIcon::Warning);
|
this);
|
||||||
}
|
|
||||||
else {
|
|
||||||
MessageBox::show(this,
|
|
||||||
QMessageBox::Warning,
|
|
||||||
tr("Cannot defragment database"),
|
|
||||||
tr("Database cannot be defragmented because feed update is ongoing."));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Thus, cannot delete and quit the method.
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DatabaseFactory::instance()->vacuumDatabase()) {
|
if (DatabaseFactory::instance()->vacuumDatabase()) {
|
||||||
qApp->showGuiMessage(tr("Database defragmented"),
|
qApp->showGuiMessage(tr("Database defragmented"),
|
||||||
tr("Database was successfully defragmented."),
|
tr("Database was successfully defragmented."),
|
||||||
QSystemTrayIcon::Information);
|
QSystemTrayIcon::Information,
|
||||||
|
this);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (is_tray_activated) {
|
qApp->showGuiMessage(tr("Database was not defragmented"),
|
||||||
qApp->trayIcon()->showMessage(tr("Database was not defragmented"),
|
tr("Database was not defragmented. This database backend does not support it or it cannot be defragmented now."),
|
||||||
tr("Database was not defragmented. This database backend does not support it or it cannot be defragmented now."),
|
QSystemTrayIcon::Warning,
|
||||||
QSystemTrayIcon::Warning,
|
this);
|
||||||
TRAY_ICON_BUBBLE_TIMEOUT);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
MessageBox::show(this,
|
|
||||||
QMessageBox::Warning,
|
|
||||||
tr("Database was not defragmented"),
|
|
||||||
tr("Database was not defragmented. This database backend does not support it or it cannot be defragmented now."));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qApp->closeLock()->unlock();
|
qApp->closeLock()->unlock();
|
||||||
|
@ -144,17 +144,9 @@ void FeedsView::updateAllFeeds() {
|
|||||||
emit feedsUpdateRequested(allFeeds());
|
emit feedsUpdateRequested(allFeeds());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (SystemTrayIcon::isSystemTrayActivated()) {
|
qApp->showGuiMessage(tr("Cannot update all items"),
|
||||||
qApp->trayIcon()->showMessage(tr("Cannot update all items"),
|
tr("You cannot update all items because another feed update is ongoing."),
|
||||||
tr("You cannot update all items because another feed update is ongoing."),
|
QSystemTrayIcon::Warning, qApp->mainForm());
|
||||||
QSystemTrayIcon::Warning);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
MessageBox::show(this,
|
|
||||||
QMessageBox::Warning,
|
|
||||||
tr("Cannot update all items"),
|
|
||||||
tr("You cannot update all items because another feed update is ongoing."));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,17 +162,9 @@ void FeedsView::updateSelectedFeeds() {
|
|||||||
emit feedsUpdateRequested(selectedFeeds());
|
emit feedsUpdateRequested(selectedFeeds());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (SystemTrayIcon::isSystemTrayActivated()) {
|
qApp->showGuiMessage(tr("Cannot update selected items"),
|
||||||
qApp->trayIcon()->showMessage(tr("Cannot update selected items"),
|
tr("You cannot update selected items because another feed update is ongoing."),
|
||||||
tr("You cannot update selected items because another feed update is ongoing."),
|
QSystemTrayIcon::Warning, qApp->mainForm());
|
||||||
QSystemTrayIcon::Warning);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
MessageBox::show(this,
|
|
||||||
QMessageBox::Warning,
|
|
||||||
tr("Cannot update selected items"),
|
|
||||||
tr("You cannot update selected items because another feed update is ongoing."));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,8 +180,7 @@ void FeedsView::executeNextAutoUpdate() {
|
|||||||
// If global auto-update is enabled
|
// If global auto-update is enabled
|
||||||
// and its interval counter reached zero,
|
// and its interval counter reached zero,
|
||||||
// then we need to restore it.
|
// then we need to restore it.
|
||||||
if (m_globalAutoUpdateEnabled &&
|
if (m_globalAutoUpdateEnabled && --m_globalAutoUpdateRemainingInterval < 0) {
|
||||||
--m_globalAutoUpdateRemainingInterval < 0) {
|
|
||||||
// We should start next auto-update interval.
|
// We should start next auto-update interval.
|
||||||
m_globalAutoUpdateRemainingInterval = m_globalAutoUpdateInitialInterval;
|
m_globalAutoUpdateRemainingInterval = m_globalAutoUpdateInitialInterval;
|
||||||
}
|
}
|
||||||
@ -218,12 +201,8 @@ void FeedsView::executeNextAutoUpdate() {
|
|||||||
// Request update for given feeds.
|
// Request update for given feeds.
|
||||||
emit feedsUpdateRequested(feeds_for_update);
|
emit feedsUpdateRequested(feeds_for_update);
|
||||||
|
|
||||||
if (SystemTrayIcon::isSystemTrayActivated()) {
|
// NOTE: OSD/bubble informing about performing
|
||||||
qApp->trayIcon()->showMessage(tr("Scheduled update started"),
|
// of scheduled update can be shown now.
|
||||||
//: RSS Guard is performing updates right now.
|
|
||||||
tr("%1 is performing scheduled update of some feeds.").arg(APP_NAME),
|
|
||||||
QSystemTrayIcon::Information);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,19 +233,9 @@ void FeedsView::addNewCategory() {
|
|||||||
// Lock was not obtained because
|
// Lock was not obtained because
|
||||||
// it is used probably by feed updater or application
|
// it is used probably by feed updater or application
|
||||||
// is quitting.
|
// is quitting.
|
||||||
if (SystemTrayIcon::isSystemTrayActivated()) {
|
qApp->showGuiMessage(tr("Cannot add standard category"),
|
||||||
qApp->trayIcon()->showMessage(tr("Cannot add standard category"),
|
tr("You cannot add new standard category now because feed update is ongoing."),
|
||||||
tr("You cannot add new standard category now because feed update is ongoing."),
|
QSystemTrayIcon::Warning, qApp->mainForm());
|
||||||
QSystemTrayIcon::Warning);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
MessageBox::show(this,
|
|
||||||
QMessageBox::Warning,
|
|
||||||
tr("Cannot add standard category"),
|
|
||||||
tr("You cannot add new standard category now because feed update is ongoing."));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Thus, cannot delete and quit the method.
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,19 +262,9 @@ void FeedsView::addNewFeed() {
|
|||||||
// Lock was not obtained because
|
// Lock was not obtained because
|
||||||
// it is used probably by feed updater or application
|
// it is used probably by feed updater or application
|
||||||
// is quitting.
|
// is quitting.
|
||||||
if (SystemTrayIcon::isSystemTrayActivated()) {
|
qApp->showGuiMessage(tr("Cannot add standard feed"),
|
||||||
qApp->trayIcon()->showMessage(tr("Cannot add standard feed"),
|
tr("You cannot add new standard feed now because feed update is ongoing."),
|
||||||
tr("You cannot add new standard feed now because feed update is ongoing."),
|
QSystemTrayIcon::Warning, qApp->mainForm());
|
||||||
QSystemTrayIcon::Warning);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
MessageBox::show(this,
|
|
||||||
QMessageBox::Warning,
|
|
||||||
tr("Cannot add standard feed"),
|
|
||||||
tr("You cannot add new standard feed now because feed update is ongoing."));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Thus, cannot delete and quit the method.
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,19 +291,9 @@ void FeedsView::editSelectedItem() {
|
|||||||
// Lock was not obtained because
|
// Lock was not obtained because
|
||||||
// it is used probably by feed updater or application
|
// it is used probably by feed updater or application
|
||||||
// is quitting.
|
// is quitting.
|
||||||
if (SystemTrayIcon::isSystemTrayActivated()) {
|
qApp->showGuiMessage(tr("Cannot edit item"),
|
||||||
//: Warning messagebox title when selected item cannot be edited.
|
tr("Selected item cannot be edited because feed update is ongoing."),
|
||||||
qApp->trayIcon()->showMessage(tr("Cannot edit item"),
|
QSystemTrayIcon::Warning, qApp->mainForm());
|
||||||
tr("Selected item cannot be edited because feed update is ongoing."),
|
|
||||||
QSystemTrayIcon::Warning);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
MessageBox::show(this,
|
|
||||||
QMessageBox::Warning,
|
|
||||||
//: Warning messagebox title when selected item cannot be edited.
|
|
||||||
tr("Cannot edit item"),
|
|
||||||
tr("Selected item cannot be edited because feed update is ongoing."));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Thus, cannot delete and quit the method.
|
// Thus, cannot delete and quit the method.
|
||||||
return;
|
return;
|
||||||
@ -382,17 +331,9 @@ void FeedsView::deleteSelectedItem() {
|
|||||||
// Lock was not obtained because
|
// Lock was not obtained because
|
||||||
// it is used probably by feed updater or application
|
// it is used probably by feed updater or application
|
||||||
// is quitting.
|
// is quitting.
|
||||||
if (SystemTrayIcon::isSystemTrayActivated()) {
|
qApp->showGuiMessage(tr("Cannot delete item"),
|
||||||
qApp->trayIcon()->showMessage(tr("Cannot delete item"),
|
tr("Selected item cannot be deleted because feed update is ongoing."),
|
||||||
tr("Selected item cannot be deleted because feed update is ongoing."),
|
QSystemTrayIcon::Warning, qApp->mainForm());
|
||||||
QSystemTrayIcon::Warning);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
MessageBox::show(this,
|
|
||||||
QMessageBox::Warning,
|
|
||||||
tr("Cannot delete item"),
|
|
||||||
tr("Selected item cannot be deleted because feed update is ongoing."));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Thus, cannot delete and quit the method.
|
// Thus, cannot delete and quit the method.
|
||||||
return;
|
return;
|
||||||
@ -411,11 +352,9 @@ void FeedsView::deleteSelectedItem() {
|
|||||||
selection_model->clearSelection();
|
selection_model->clearSelection();
|
||||||
selection_model->select(current_index, QItemSelectionModel::Rows | QItemSelectionModel::SelectCurrent);
|
selection_model->select(current_index, QItemSelectionModel::Rows | QItemSelectionModel::SelectCurrent);
|
||||||
|
|
||||||
if (SystemTrayIcon::isSystemTrayActivated()) {
|
qApp->showGuiMessage(tr("Cannot delete item"),
|
||||||
qApp->trayIcon()->showMessage(tr("Cannot delete item"),
|
tr("Selected item cannot be deleted because feed update is ongoing."),
|
||||||
tr("Selected item cannot be deleted because feed update is ongoing."),
|
QSystemTrayIcon::Warning, qApp->mainForm());
|
||||||
QSystemTrayIcon::Warning);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_sourceModel->removeItem(m_proxyModel->mapToSource(current_index))) {
|
if (m_sourceModel->removeItem(m_proxyModel->mapToSource(current_index))) {
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
|
|
||||||
FormCategoryDetails::FormCategoryDetails(FeedsModel *model,
|
FormCategoryDetails::FormCategoryDetails(FeedsModel *model,
|
||||||
QWidget *parent)
|
QWidget *parent)
|
||||||
: QDialog(parent),
|
: QDialog(parent),
|
||||||
m_editableCategory(NULL),
|
m_editableCategory(NULL),
|
||||||
m_feedsModel(model) {
|
m_feedsModel(model) {
|
||||||
@ -118,17 +118,10 @@ void FormCategoryDetails::apply() {
|
|||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (SystemTrayIcon::isSystemTrayActivated()) {
|
qApp->showGuiMessage(tr("Cannot add category"),
|
||||||
qApp->trayIcon()->showMessage(tr("Cannot add category"),
|
tr("Category was not added due to error."),
|
||||||
tr("Category was not added due to error."),
|
QSystemTrayIcon::Critical,
|
||||||
QSystemTrayIcon::Critical);
|
qApp->mainForm());
|
||||||
}
|
|
||||||
else {
|
|
||||||
MessageBox::show(this,
|
|
||||||
QMessageBox::Critical,
|
|
||||||
tr("Cannot add category"),
|
|
||||||
tr("Category was not added due to error."));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -136,17 +129,10 @@ void FormCategoryDetails::apply() {
|
|||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (SystemTrayIcon::isSystemTrayActivated()) {
|
qApp->showGuiMessage(tr("Cannot edit category"),
|
||||||
qApp->trayIcon()->showMessage(tr("Cannot edit category"),
|
tr("Category was not edited due to error."),
|
||||||
tr("Category was not edited due to error."),
|
QSystemTrayIcon::Critical,
|
||||||
QSystemTrayIcon::Critical);
|
qApp->mainForm());
|
||||||
}
|
|
||||||
else {
|
|
||||||
MessageBox::show(this,
|
|
||||||
QMessageBox::Critical,
|
|
||||||
tr("Cannot edit category"),
|
|
||||||
tr("Category was not edited due to error."));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -154,11 +140,11 @@ void FormCategoryDetails::apply() {
|
|||||||
void FormCategoryDetails::onTitleChanged(const QString &new_title){
|
void FormCategoryDetails::onTitleChanged(const QString &new_title){
|
||||||
if (new_title.simplified().size() >= MIN_CATEGORY_NAME_LENGTH) {
|
if (new_title.simplified().size() >= MIN_CATEGORY_NAME_LENGTH) {
|
||||||
m_ui->m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
m_ui->m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||||
m_ui->m_txtTitle->setStatus(LineEditWithStatus::Ok, tr("Category name is ok."));
|
m_ui->m_txtTitle->setStatus(WidgetWithStatus::Ok, tr("Category name is ok."));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_ui->m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
m_ui->m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||||
m_ui->m_txtTitle->setStatus(LineEditWithStatus::Error, tr("Category name is too short."));
|
m_ui->m_txtTitle->setStatus(WidgetWithStatus::Error, tr("Category name is too short."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,8 +232,8 @@ void FormCategoryDetails::initialize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FormCategoryDetails::loadCategories(const QList<FeedsModelCategory*> categories,
|
void FormCategoryDetails::loadCategories(const QList<FeedsModelCategory*> categories,
|
||||||
FeedsModelRootItem *root_item,
|
FeedsModelRootItem *root_item,
|
||||||
FeedsModelCategory *input_category) {
|
FeedsModelCategory *input_category) {
|
||||||
m_ui->m_cmbParentCategory->addItem(root_item->icon(),
|
m_ui->m_cmbParentCategory->addItem(root_item->icon(),
|
||||||
root_item->title(),
|
root_item->title(),
|
||||||
QVariant::fromValue((void*) root_item));
|
QVariant::fromValue((void*) root_item));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user