Done refactoring.

This commit is contained in:
Martin Rotter 2016-01-15 10:04:58 +01:00
parent ef33988ca6
commit 01d8b218b1
9 changed files with 16 additions and 20 deletions

View File

@ -47,7 +47,7 @@ int RecycleBin::countOfAllMessages() const {
void RecycleBin::updateCounts(bool update_total_count) { void RecycleBin::updateCounts(bool update_total_count) {
QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings); QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
QSqlQuery query_all(database); QSqlQuery query_all(database);
ServiceRoot *parent_root = getParentServiceRoot(); const ServiceRoot *parent_root = getParentServiceRoot();
query_all.setForwardOnly(true); query_all.setForwardOnly(true);
query_all.prepare("SELECT count(*) FROM Messages " query_all.prepare("SELECT count(*) FROM Messages "
@ -88,7 +88,7 @@ QVariant RecycleBin::data(int column, int role) const {
QList<Message> RecycleBin::undeletedMessages() const { QList<Message> RecycleBin::undeletedMessages() const {
QList<Message> messages; QList<Message> messages;
int account_id = const_cast<RecycleBin*>(this)->getParentServiceRoot()->accountId(); const int account_id = getParentServiceRoot()->accountId();
QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings); QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
QSqlQuery query_read_msg(database); QSqlQuery query_read_msg(database);

View File

@ -201,7 +201,7 @@ void FormStandardCategoryDetails::onUseDefaultIcon() {
} }
void FormStandardCategoryDetails::initialize() { void FormStandardCategoryDetails::initialize() {
m_ui = new Ui::FormStandardCategoryDetails(); m_ui.reset(new Ui::FormStandardCategoryDetails());
m_ui->setupUi(this); m_ui->setupUi(this);
// Set text boxes. // Set text boxes.

View File

@ -76,7 +76,7 @@ class FormStandardCategoryDetails : public QDialog {
void loadCategories(const QList<Category *> categories, RootItem *root_item, StandardCategory *input_category); void loadCategories(const QList<Category *> categories, RootItem *root_item, StandardCategory *input_category);
private: private:
Ui::FormStandardCategoryDetails *m_ui; QScopedPointer<Ui::FormStandardCategoryDetails> m_ui;
StandardCategory *m_editableCategory; StandardCategory *m_editableCategory;
StandardServiceRoot *m_serviceRoot; StandardServiceRoot *m_serviceRoot;

View File

@ -56,7 +56,6 @@ FormStandardFeedDetails::FormStandardFeedDetails(StandardServiceRoot *service_ro
} }
FormStandardFeedDetails::~FormStandardFeedDetails() { FormStandardFeedDetails::~FormStandardFeedDetails() {
delete m_ui;
} }
int FormStandardFeedDetails::exec(StandardFeed *input_feed, RootItem *parent_to_select, const QString &url) { int FormStandardFeedDetails::exec(StandardFeed *input_feed, RootItem *parent_to_select, const QString &url) {
@ -386,7 +385,7 @@ void FormStandardFeedDetails::setEditableFeed(StandardFeed *editable_feed) {
} }
void FormStandardFeedDetails::initialize() { void FormStandardFeedDetails::initialize() {
m_ui = new Ui::FormStandardFeedDetails(); m_ui.reset(new Ui::FormStandardFeedDetails());
m_ui->setupUi(this); m_ui->setupUi(this);
// Set flags and attributes. // Set flags and attributes.
@ -419,7 +418,7 @@ void FormStandardFeedDetails::initialize() {
m_ui->m_cmbType->addItem(StandardFeed::typeToString(StandardFeed::Rss2X), QVariant::fromValue((int) StandardFeed::Rss2X)); m_ui->m_cmbType->addItem(StandardFeed::typeToString(StandardFeed::Rss2X), QVariant::fromValue((int) StandardFeed::Rss2X));
// Load available encodings. // Load available encodings.
QList<QByteArray> encodings = QTextCodec::availableCodecs(); const QList<QByteArray> encodings = QTextCodec::availableCodecs();
QStringList encoded_encodings; QStringList encoded_encodings;
foreach (const QByteArray &encoding, encodings) { foreach (const QByteArray &encoding, encodings) {

View File

@ -81,7 +81,7 @@ class FormStandardFeedDetails : public QDialog {
void loadCategories(const QList<Category*> categories, RootItem *root_item); void loadCategories(const QList<Category*> categories, RootItem *root_item);
private: private:
Ui::FormStandardFeedDetails *m_ui; QScopedPointer<Ui::FormStandardFeedDetails> m_ui;
StandardFeed *m_editableFeed; StandardFeed *m_editableFeed;
StandardServiceRoot *m_serviceRoot; StandardServiceRoot *m_serviceRoot;

View File

@ -53,7 +53,6 @@ FormStandardImportExport::FormStandardImportExport(StandardServiceRoot *service_
} }
FormStandardImportExport::~FormStandardImportExport() { FormStandardImportExport::~FormStandardImportExport() {
delete m_ui;
} }
void FormStandardImportExport::setMode(const FeedsImportExportModel::Mode &mode) { void FormStandardImportExport::setMode(const FeedsImportExportModel::Mode &mode) {
@ -141,8 +140,8 @@ void FormStandardImportExport::onParsingProgress(int completed, int total) {
} }
void FormStandardImportExport::selectExportFile() { void FormStandardImportExport::selectExportFile() {
QString filter_opml20 = tr("OPML 2.0 files (*.opml)"); const QString filter_opml20 = tr("OPML 2.0 files (*.opml)");
QString filter_txt_url_per_line = tr("TXT files (one URL per line) (*.txt)"); const QString filter_txt_url_per_line = tr("TXT files (one URL per line) (*.txt)");
QString filter; QString filter;
QString selected_filter; QString selected_filter;
@ -178,8 +177,8 @@ void FormStandardImportExport::selectExportFile() {
} }
void FormStandardImportExport::selectImportFile() { void FormStandardImportExport::selectImportFile() {
QString filter_opml20 = tr("OPML 2.0 files (*.opml)"); const QString filter_opml20 = tr("OPML 2.0 files (*.opml)");
QString filter_txt_url_per_line = tr("TXT files (one URL per line) (*.txt)"); const QString filter_txt_url_per_line = tr("TXT files (one URL per line) (*.txt)");
QString filter; QString filter;
QString selected_filter; QString selected_filter;
@ -189,8 +188,8 @@ void FormStandardImportExport::selectImportFile() {
filter += ";;"; filter += ";;";
filter += filter_txt_url_per_line; filter += filter_txt_url_per_line;
QString selected_file = QFileDialog::getOpenFileName(this, tr("Select file for feeds import"), qApp->homeFolderPath(), const QString selected_file = QFileDialog::getOpenFileName(this, tr("Select file for feeds import"), qApp->homeFolderPath(),
filter, &selected_filter); filter, &selected_filter);
if (!selected_file.isEmpty()) { if (!selected_file.isEmpty()) {
if (selected_filter == filter_opml20) { if (selected_filter == filter_opml20) {

View File

@ -60,7 +60,7 @@ class FormStandardImportExport : public QDialog {
void exportFeeds(); void exportFeeds();
void importFeeds(); void importFeeds();
Ui::FormStandardImportExport *m_ui; QScopedPointer<Ui::FormStandardImportExport> m_ui;
ConversionType m_conversionType; ConversionType m_conversionType;
FeedsImportExportModel *m_model; FeedsImportExportModel *m_model;
StandardServiceRoot *m_serviceRoot; StandardServiceRoot *m_serviceRoot;

View File

@ -100,10 +100,9 @@ bool StandardCategory::performDragDropChange(RootItem *target_item) {
} }
bool StandardCategory::editViaGui() { bool StandardCategory::editViaGui() {
QPointer<FormStandardCategoryDetails> form_pointer = new FormStandardCategoryDetails(serviceRoot(), qApp->mainForm()); QScopedPointer<FormStandardCategoryDetails> form_pointer(new FormStandardCategoryDetails(serviceRoot(), qApp->mainForm()));
form_pointer.data()->exec(this, NULL); form_pointer.data()->exec(this, NULL);
delete form_pointer.data();
return false; return false;
} }

View File

@ -103,10 +103,9 @@ StandardServiceRoot *StandardFeed::serviceRoot() {
} }
bool StandardFeed::editViaGui() { bool StandardFeed::editViaGui() {
QPointer<FormStandardFeedDetails> form_pointer = new FormStandardFeedDetails(serviceRoot(), qApp->mainForm()); QScopedPointer<FormStandardFeedDetails> form_pointer(new FormStandardFeedDetails(serviceRoot(), qApp->mainForm()));
form_pointer.data()->exec(this, NULL); form_pointer.data()->exec(this, NULL);
delete form_pointer.data();
return false; return false;
} }