Work on category manipulation, some refactoring.

This commit is contained in:
Martin Rotter 2014-01-27 14:54:27 +01:00
parent 5ab7ea370d
commit 8d070db0ed
12 changed files with 99 additions and 80 deletions

View file

@ -287,7 +287,7 @@ set(APP_SOURCES
src/gui/messagesview.cpp src/gui/messagesview.cpp
src/gui/statusbar.cpp src/gui/statusbar.cpp
src/gui/iconfactory.cpp src/gui/iconfactory.cpp
src/gui/formcategorydetails.cpp src/gui/formstandardcategorydetails.cpp
src/gui/plaintoolbutton.cpp src/gui/plaintoolbutton.cpp
src/gui/lineeditwithstatus.cpp src/gui/lineeditwithstatus.cpp
src/gui/messagebox.cpp src/gui/messagebox.cpp
@ -352,7 +352,7 @@ set(APP_HEADERS
src/gui/feedsview.h src/gui/feedsview.h
src/gui/messagesview.h src/gui/messagesview.h
src/gui/statusbar.h src/gui/statusbar.h
src/gui/formcategorydetails.h src/gui/formstandardcategorydetails.h
src/gui/plaintoolbutton.h src/gui/plaintoolbutton.h
src/gui/lineeditwithstatus.h src/gui/lineeditwithstatus.h
src/gui/messagebox.h src/gui/messagebox.h
@ -378,7 +378,7 @@ set(APP_FORMS
src/gui/formsettings.ui src/gui/formsettings.ui
src/gui/formwelcome.ui src/gui/formwelcome.ui
src/gui/formabout.ui src/gui/formabout.ui
src/gui/formcategorydetails.ui src/gui/formstandardcategorydetails.ui
) )
# Add translations. # Add translations.

File diff suppressed because one or more lines are too long

View file

@ -6,7 +6,7 @@
<email>rotter.martinos@gmail.com</email> <email>rotter.martinos@gmail.com</email>
</author> </author>
<style/> <style/>
<markup_wrapper>PGh0bWw+DQogIDxoZWFkPg0KICAgIDxzdHlsZT4NCiAgICAgIGJvZHkgew0KICAgICAgICBtYXJnaW46IDBweDsNCiAgICAgICAgcGFkZGluZzogMHB4Ow0KICAgICAgfQ0KICAgIA0KICAgICAgcHJlIHsNCiAgICAgICAgd2hpdGUtc3BhY2U6IHByZS13cmFwOw0KICAgICAgfQ0KDQogICAgICAuaGVhZGVydGV4dCB7DQogICAgICAgIGZvbnQtc2l6ZTogMjBweDsNCiAgICAgICAgbWFyZ2luLWJvdHRvbTogMTBweDsNCiAgICAgIH0NCg0KICAgICAgLmhlYWRlciB7DQogICAgICAgIGZvbnQtc2l6ZTogMTdweDsNCiAgICAgICAgYmFja2dyb3VuZDogLXdlYmtpdC1ncmFkaWVudChsaW5lYXIsIGxlZnQgdG9wLCBsZWZ0IGJvdHRvbSwgY29sb3Itc3RvcCgwJSxyZ2JhKDk5LDEzNSwyMjksMSkpLCBjb2xvci1zdG9wKDEwMCUscmdiYSg2NCwxMDksMjM2LDEpKSk7DQogICAgICAgIHBhZGRpbmc6IDZweDsNCiAgICAgICAgbWFyZ2luOiAwcHggYXV0bzsNCiAgICAgICAgY29sb3I6IHdoaXRlOw0KICAgICAgICBib3JkZXI6IDAuNXB4IHNvbGlkIGJsYWNrOw0KICAgICAgfQ0KDQogICAgICAuaGVhZGVyIGEgew0KICAgICAgICBjb2xvcjogd2hpdGU7DQogICAgICB9DQoNCiAgICAgIC5jb250ZW50IHsNCiAgICAgICAgYm9yZGVyLXRvcDogMXB4IHNvbGlkIGdyYXk7DQogICAgICAgIGZvbnQtc2l6ZTogMTZweDsNCiAgICAgICAgbWFyZ2luOiAwcHggYXV0bzsNCiAgICAgICAgcGFkZGluZzogNnB4Ow0KICAgICAgICBwYWRkaW5nLXRvcDogMTJweDsNCiAgICAgIH0NCiAgICAgIA0KICAgICAgLmNvbnRhaW5lciB7DQogICAgICAgIGJvcmRlcjogMXB4IHNvbGlkIGdyYXk7DQogICAgICAgIC13ZWJraXQtYm9yZGVyLXJhZGl1czogMnB4Ow0KICAgICAgICBtYXJnaW46IDEwcHg7DQogICAgICAgIC13ZWJraXQtYm94LXNoYWRvdzogMnB4IDJweCAxNnB4IDBweCByZ2JhKDUwLCA1MCwgNTAsIDAuNjIpOw0KICAgICAgfQ0KICAgIDwvc3R5bGU+DQogICAgPHRpdGxlPg0KICAgICAgJTENCiAgICA8L3RpdGxlPg0KICA8L2hlYWQ+DQogIDxib2R5Pg0KICAgICUyDQogIDwvYm9keT4NCjwvaHRtbD4=</markup_wrapper> <markup_wrapper>PGh0bWw+DQogIDxoZWFkPg0KICAgIDxzdHlsZT4NCiAgICAgIGJvZHkgew0KICAgICAgICBtYXJnaW46IDBweDsNCiAgICAgICAgcGFkZGluZzogMHB4Ow0KICAgICAgfQ0KICAgIA0KICAgICAgcHJlIHsNCiAgICAgICAgd2hpdGUtc3BhY2U6IHByZS13cmFwOw0KCQlmb250LWZhbWlseTogIkNvdXJpZXIgTmV3IiwgQ291cmllciwgbW9ub3NwYWNlOw0KICAgICAgfQ0KDQogICAgICAuaGVhZGVydGV4dCB7DQogICAgICAgIGZvbnQtc2l6ZTogMjBweDsNCiAgICAgICAgbWFyZ2luLWJvdHRvbTogMTBweDsNCiAgICAgIH0NCg0KICAgICAgLmhlYWRlciB7DQogICAgICAgIGZvbnQtc2l6ZTogMTdweDsNCiAgICAgICAgYmFja2dyb3VuZDogLXdlYmtpdC1ncmFkaWVudChsaW5lYXIsIGxlZnQgdG9wLCBsZWZ0IGJvdHRvbSwgY29sb3Itc3RvcCgwJSxyZ2JhKDk5LDEzNSwyMjksMSkpLCBjb2xvci1zdG9wKDEwMCUscmdiYSg2NCwxMDksMjM2LDEpKSk7DQogICAgICAgIHBhZGRpbmc6IDZweDsNCiAgICAgICAgbWFyZ2luOiAwcHggYXV0bzsNCiAgICAgICAgY29sb3I6IHdoaXRlOw0KICAgICAgICBib3JkZXI6IDAuNXB4IHNvbGlkIGJsYWNrOw0KICAgICAgfQ0KDQogICAgICAuaGVhZGVyIGEgew0KICAgICAgICBjb2xvcjogd2hpdGU7DQogICAgICB9DQoNCiAgICAgIC5jb250ZW50IHsNCiAgICAgICAgYm9yZGVyLXRvcDogMXB4IHNvbGlkIGdyYXk7DQogICAgICAgIGZvbnQtc2l6ZTogMTZweDsNCiAgICAgICAgbWFyZ2luOiAwcHggYXV0bzsNCiAgICAgICAgcGFkZGluZzogNnB4Ow0KICA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HggMXB4IDFweCAxcHg7DQp9IA0KDQpRVHJlZVZpZXdbaGlkZVRyZWU9InRydWUiXTo6YnJhbmNoOiFoYXMtY2hsaWRyZW46aGFzU2libGluZ3Mgew0KICBib3JkZXItaW1hZ2U6IG5vbmU7DQogIGltYWdlOiBub25lOw0KfQ0K</data>
</skin> </skin>

View file

@ -137,21 +137,18 @@ bool FeedsModel::removeItem(const QModelIndex &index) {
if (index.isValid()) { if (index.isValid()) {
QModelIndex parent_index = index.parent(); QModelIndex parent_index = index.parent();
FeedsModelRootItem *deleting_item = itemForIndex(index); FeedsModelRootItem *deleting_item = itemForIndex(index);
FeedsModelRootItem *parent_item = itemForIndex(parent_index); FeedsModelRootItem *parent_item = deleting_item->parent();
// Try to persistently remove the item. // Try to persistently remove the item.
if (deleting_item->removeItself()) { if (deleting_item->removeItself()) {
// Item was persistently removed. // Item was persistently removed.
// Remove it from the model. // Remove it from the model.
beginRemoveRows(parent_index, index.row(), index.row()); beginRemoveRows(parent_index, index.row(), index.row());
parent_item->removeChild(deleting_item);
if (parent_item->removeChild(deleting_item)) {
// Free deleted item (and its children) from the memory.
delete deleting_item;
}
endRemoveRows(); endRemoveRows();
delete deleting_item;
return true; return true;
} }
} }
@ -204,11 +201,7 @@ bool FeedsModel::addStandardCategory(FeedsModelStandardCategory *category,
// Category was added to the persistent storage, // Category was added to the persistent storage,
// so add it to the model. // so add it to the model.
beginInsertRows(parent_index, parent->childCount(), parent->childCount()); beginInsertRows(parent_index, parent->childCount(), parent->childCount());
// Add category to parent's children list.
parent->appendChild(category); parent->appendChild(category);
// Everything is completed now.
endInsertRows(); endInsertRows();
return true; return true;
@ -219,6 +212,8 @@ bool FeedsModel::editStandardCategory(FeedsModelStandardCategory *original_categ
QSqlDatabase database = DatabaseFactory::instance()->connection(objectName(), QSqlDatabase database = DatabaseFactory::instance()->connection(objectName(),
DatabaseFactory::FromSettings); DatabaseFactory::FromSettings);
QSqlQuery query_update_category(database); QSqlQuery query_update_category(database);
FeedsModelRootItem *original_parent = original_category->parent();
FeedsModelRootItem *new_parent = new_category->parent();
query_update_category.setForwardOnly(true); query_update_category.setForwardOnly(true);
query_update_category.prepare("UPDATE Categories " query_update_category.prepare("UPDATE Categories "
@ -227,38 +222,44 @@ bool FeedsModel::editStandardCategory(FeedsModelStandardCategory *original_categ
query_update_category.bindValue(":title", new_category->title()); query_update_category.bindValue(":title", new_category->title());
query_update_category.bindValue(":description", new_category->description()); query_update_category.bindValue(":description", new_category->description());
query_update_category.bindValue(":icon", IconFactory::toByteArray(new_category->icon())); query_update_category.bindValue(":icon", IconFactory::toByteArray(new_category->icon()));
query_update_category.bindValue(":parent_id", new_category->parent()->id()); query_update_category.bindValue(":parent_id", new_parent->id());
query_update_category.bindValue(":id", original_category->id()); query_update_category.bindValue(":id", original_category->id());
if (!query_update_category.exec()) { if (!query_update_category.exec()) {
// Persistent storage update failed, no way to continue now.
return false; return false;
} }
// TODO: nastavit originalni kategorii podle nove; doimplementovat // Setup new model data for the original item.
// celkove dodelat original_category->setDescription(new_category->description());
original_category->setIcon(new_category->icon());
original_category->setTitle(new_category->title());
if (original_category->parent() != new_category->parent()) { if (original_parent != new_parent) {
// User edited category but left its parent intact. // User edited category and set it new parent item,
beginRemoveRows(indexForItem(original_category->parent()), // se we need to move the item in the model too.
original_category->parent()->childItems().indexOf(original_category), int original_index_of_category = original_parent->childItems().indexOf(original_category);
original_category->parent()->childItems().indexOf(original_category)); int new_index_of_category = new_parent->childCount();
original_category->parent()->removeChild(original_category);
// Remove the original item from the model...
beginRemoveRows(indexForItem(original_parent),
original_index_of_category,
original_index_of_category);
original_parent->removeChild(original_category);
endRemoveRows(); endRemoveRows();
beginInsertRows(indexForItem(new_category->parent()), // ... and insert it under the new parent.
new_category->parent()->childCount(), beginInsertRows(indexForItem(new_parent),
new_category->parent()->childCount()); new_index_of_category,
new_index_of_category);
new_category->parent()->appendChild(original_category); new_parent->appendChild(original_category);
endInsertRows(); endInsertRows();
} }
// Free temporary category from memory. // Free temporary category from memory.
delete new_category; delete new_category;
// Editing is done.
return true; return true;
} }

View file

@ -217,8 +217,8 @@ void FeedMessageViewer::createConnections() {
SIGNAL(triggered()), this, SLOT(updateSelectedFeeds())); SIGNAL(triggered()), this, SLOT(updateSelectedFeeds()));
connect(FormMain::instance()->m_ui->m_actionUpdateAllFeeds, connect(FormMain::instance()->m_ui->m_actionUpdateAllFeeds,
SIGNAL(triggered()), this, SLOT(updateAllFeeds())); SIGNAL(triggered()), this, SLOT(updateAllFeeds()));
connect(FormMain::instance()->m_ui->m_actionAddNewCategory, connect(FormMain::instance()->m_ui->m_actionAddStandardCategory,
SIGNAL(triggered()), m_feedsView, SLOT(addNewCategory())); SIGNAL(triggered()), m_feedsView, SLOT(addNewStandardCategory()));
connect(FormMain::instance()->m_ui->m_actionEditSelectedFeedCategory, connect(FormMain::instance()->m_ui->m_actionEditSelectedFeedCategory,
SIGNAL(triggered()), m_feedsView, SLOT(editSelectedItem())); SIGNAL(triggered()), m_feedsView, SLOT(editSelectedItem()));
connect(FormMain::instance()->m_ui->m_actionViewSelectedItemsNewspaperMode, connect(FormMain::instance()->m_ui->m_actionViewSelectedItemsNewspaperMode,

View file

@ -8,7 +8,7 @@
#include "core/feedsmodelcategory.h" #include "core/feedsmodelcategory.h"
#include "core/feedsmodelstandardcategory.h" #include "core/feedsmodelstandardcategory.h"
#include "gui/formmain.h" #include "gui/formmain.h"
#include "gui/formcategorydetails.h" #include "gui/formstandardcategorydetails.h"
#include <QMenu> #include <QMenu>
#include <QHeaderView> #include <QHeaderView>
@ -69,8 +69,8 @@ void FeedsView::clearSelectedFeeds() {
setSelectedFeedsClearStatus(1); setSelectedFeedsClearStatus(1);
} }
void FeedsView::addNewCategory() { void FeedsView::addNewStandardCategory() {
QPointer<FormCategoryDetails> form_pointer = new FormCategoryDetails(m_sourceModel, this); QPointer<FormStandardCategoryDetails> form_pointer = new FormStandardCategoryDetails(m_sourceModel, this);
if (form_pointer.data()->exec(NULL) == QDialog::Accepted) { if (form_pointer.data()->exec(NULL) == QDialog::Accepted) {
// TODO: nova kategorie pridana // TODO: nova kategorie pridana
@ -82,8 +82,25 @@ void FeedsView::addNewCategory() {
delete form_pointer.data(); delete form_pointer.data();
} }
void FeedsView::editStandardCategory(FeedsModelStandardCategory *category) {
FeedsModelStandardCategory *std_category = static_cast<FeedsModelStandardCategory*>(category);
QPointer<FormStandardCategoryDetails> form_pointer = new FormStandardCategoryDetails(m_sourceModel, this);
if (form_pointer.data()->exec(std_category) == QDialog::Accepted) {
// TODO: kategorie upravena
}
else {
// TODO: kategorie neupravena (uživatel zrušil dialog)
}
delete form_pointer.data();
}
void FeedsView::editSelectedItem() { void FeedsView::editSelectedItem() {
// TODO: Implement this. // TODO: preda pridavanim/upravou/mazanim kanalu/kategorii
// ziskat ZAPISOVACI zamek pres systemfactory::applicationCloseLock
// a po dokonceni cinnosti jej odevzdavat
FeedsModelCategory *category; FeedsModelCategory *category;
FeedsModelFeed *feed; FeedsModelFeed *feed;
@ -92,18 +109,7 @@ void FeedsView::editSelectedItem() {
switch (category->type()) { switch (category->type()) {
case FeedsModelCategory::Standard: { case FeedsModelCategory::Standard: {
// User wants to edit standard category. // User wants to edit standard category.
FeedsModelStandardCategory *std_category = static_cast<FeedsModelStandardCategory*>(category); editStandardCategory(static_cast<FeedsModelStandardCategory*>(category));
QPointer<FormCategoryDetails> form_pointer = new FormCategoryDetails(m_sourceModel, this);
if (form_pointer.data()->exec(std_category) == QDialog::Accepted) {
// TODO: kategorie upravena
}
else {
// TODO: kategorie neupravena
}
delete form_pointer.data();
break; break;
} }

View file

@ -68,11 +68,14 @@ class FeedsView : public QTreeView {
void setSelectedFeedsClearStatus(int clear); void setSelectedFeedsClearStatus(int clear);
void clearSelectedFeeds(); void clearSelectedFeeds();
// Category operators. // Base manipulators.
void addNewCategory();
void editSelectedItem(); void editSelectedItem();
void deleteSelectedItem(); void deleteSelectedItem();
// Standard category manipulators.
void addNewStandardCategory();
void editStandardCategory(FeedsModelStandardCategory *category);
// Reloads counts for selected feeds. // Reloads counts for selected feeds.
void updateCountsOfSelectedFeeds(bool update_total_too = true); void updateCountsOfSelectedFeeds(bool update_total_too = true);

View file

@ -223,7 +223,7 @@ void FormMain::setupIcons() {
m_ui->m_actionClearFeeds->setIcon(IconThemeFactory::instance()->fromTheme("mail-mark-junk")); m_ui->m_actionClearFeeds->setIcon(IconThemeFactory::instance()->fromTheme("mail-mark-junk"));
m_ui->m_actionDeleteSelectedFeedCategory->setIcon(IconThemeFactory::instance()->fromTheme("edit-delete")); m_ui->m_actionDeleteSelectedFeedCategory->setIcon(IconThemeFactory::instance()->fromTheme("edit-delete"));
m_ui->m_actionDeleteSelectedMessages->setIcon(IconThemeFactory::instance()->fromTheme("mail-mark-junk")); m_ui->m_actionDeleteSelectedMessages->setIcon(IconThemeFactory::instance()->fromTheme("mail-mark-junk"));
m_ui->m_actionAddNewCategory->setIcon(IconThemeFactory::instance()->fromTheme("document-new")); m_ui->m_actionAddStandardCategory->setIcon(IconThemeFactory::instance()->fromTheme("document-new"));
m_ui->m_actionAddNewFeed->setIcon(IconThemeFactory::instance()->fromTheme("document-new")); m_ui->m_actionAddNewFeed->setIcon(IconThemeFactory::instance()->fromTheme("document-new"));
m_ui->m_actionEditSelectedFeedCategory->setIcon(IconThemeFactory::instance()->fromTheme("gnome-other")); m_ui->m_actionEditSelectedFeedCategory->setIcon(IconThemeFactory::instance()->fromTheme("gnome-other"));
m_ui->m_actionMarkAllFeedsRead->setIcon(IconThemeFactory::instance()->fromTheme("mail-mark-not-junk")); m_ui->m_actionMarkAllFeedsRead->setIcon(IconThemeFactory::instance()->fromTheme("mail-mark-not-junk"));

View file

@ -15,7 +15,16 @@
</property> </property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@ -39,7 +48,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>979</width> <width>979</width>
<height>20</height> <height>21</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="m_menuFile"> <widget class="QMenu" name="m_menuFile">
@ -89,7 +98,7 @@
<addaction name="m_actionUpdateSelectedFeedsCategories"/> <addaction name="m_actionUpdateSelectedFeedsCategories"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="m_actionAddNewFeed"/> <addaction name="m_actionAddNewFeed"/>
<addaction name="m_actionAddNewCategory"/> <addaction name="m_actionAddStandardCategory"/>
<addaction name="m_actionEditSelectedFeedCategory"/> <addaction name="m_actionEditSelectedFeedCategory"/>
<addaction name="m_actionDeleteSelectedFeedCategory"/> <addaction name="m_actionDeleteSelectedFeedCategory"/>
<addaction name="separator"/> <addaction name="separator"/>
@ -359,12 +368,12 @@
<string notr="true"/> <string notr="true"/>
</property> </property>
</action> </action>
<action name="m_actionAddNewCategory"> <action name="m_actionAddStandardCategory">
<property name="text"> <property name="text">
<string>Add new &amp;category</string> <string>Add new standard &amp;category</string>
</property> </property>
<property name="shortcut"> <property name="toolTip">
<string notr="true"/> <string>Add new standard category.</string>
</property> </property>
</action> </action>
<action name="m_actionNoActions"> <action name="m_actionNoActions">

View file

@ -1,4 +1,4 @@
#include "gui/formcategorydetails.h" #include "gui/formstandardcategorydetails.h"
#include "core/defs.h" #include "core/defs.h"
#include "core/feedsmodelrootitem.h" #include "core/feedsmodelrootitem.h"
@ -16,7 +16,7 @@
#include <QPushButton> #include <QPushButton>
FormCategoryDetails::FormCategoryDetails(FeedsModel *model, QWidget *parent) FormStandardCategoryDetails::FormStandardCategoryDetails(FeedsModel *model, QWidget *parent)
: QDialog(parent), : QDialog(parent),
m_editableCategory(NULL), m_editableCategory(NULL),
m_feedsModel(model) { m_feedsModel(model) {
@ -30,18 +30,18 @@ FormCategoryDetails::FormCategoryDetails(FeedsModel *model, QWidget *parent)
onTitleChanged(QString()); onTitleChanged(QString());
} }
FormCategoryDetails::~FormCategoryDetails() { FormStandardCategoryDetails::~FormStandardCategoryDetails() {
qDebug("Destroying FormCategoryDetails instance."); qDebug("Destroying FormCategoryDetails instance.");
} }
void FormCategoryDetails::createConnections() { void FormStandardCategoryDetails::createConnections() {
connect(m_ui->m_buttonBox, SIGNAL(accepted()), connect(m_ui->m_buttonBox, SIGNAL(accepted()),
this, SLOT(apply())); this, SLOT(apply()));
connect(m_ui->m_txtTitle->lineEdit(), SIGNAL(textChanged(QString)), connect(m_ui->m_txtTitle->lineEdit(), SIGNAL(textChanged(QString)),
this, SLOT(onTitleChanged(QString))); this, SLOT(onTitleChanged(QString)));
} }
void FormCategoryDetails::setEditableCategory(FeedsModelStandardCategory *editable_category) { void FormStandardCategoryDetails::setEditableCategory(FeedsModelStandardCategory *editable_category) {
m_editableCategory = editable_category; m_editableCategory = editable_category;
m_ui->m_cmbParentCategory->setCurrentIndex(m_ui->m_cmbParentCategory->findData(QVariant::fromValue((void*) editable_category->parent()))); m_ui->m_cmbParentCategory->setCurrentIndex(m_ui->m_cmbParentCategory->findData(QVariant::fromValue((void*) editable_category->parent())));
@ -50,7 +50,7 @@ void FormCategoryDetails::setEditableCategory(FeedsModelStandardCategory *editab
m_ui->m_btnIcon->setIcon(editable_category->icon()); m_ui->m_btnIcon->setIcon(editable_category->icon());
} }
int FormCategoryDetails::exec(FeedsModelStandardCategory *input_category) { int FormStandardCategoryDetails::exec(FeedsModelStandardCategory *input_category) {
if (input_category == NULL) { if (input_category == NULL) {
// User is adding new category. // User is adding new category.
setWindowTitle(tr("Add new category")); setWindowTitle(tr("Add new category"));
@ -67,7 +67,7 @@ int FormCategoryDetails::exec(FeedsModelStandardCategory *input_category) {
return QDialog::exec(); return QDialog::exec();
} }
void FormCategoryDetails::apply() { void FormStandardCategoryDetails::apply() {
FeedsModelRootItem *parent = static_cast<FeedsModelRootItem*>(m_ui->m_cmbParentCategory->itemData(m_ui->m_cmbParentCategory->currentIndex()).value<void*>()); FeedsModelRootItem *parent = static_cast<FeedsModelRootItem*>(m_ui->m_cmbParentCategory->itemData(m_ui->m_cmbParentCategory->currentIndex()).value<void*>());
FeedsModelStandardCategory *new_category = new FeedsModelStandardCategory(); FeedsModelStandardCategory *new_category = new FeedsModelStandardCategory();
@ -97,7 +97,7 @@ void FormCategoryDetails::apply() {
} }
} }
void FormCategoryDetails::onTitleChanged(const QString &new_title){ void FormStandardCategoryDetails::onTitleChanged(const QString &new_title){
if (new_title.size() >= MIN_CATEGORY_NAME_LENGTH) { if (new_title.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("This category name is ok.")); m_ui->m_txtTitle->setStatus(LineEditWithStatus::Ok, tr("This category name is ok."));
@ -108,8 +108,8 @@ void FormCategoryDetails::onTitleChanged(const QString &new_title){
} }
} }
void FormCategoryDetails::initialize() { void FormStandardCategoryDetails::initialize() {
m_ui = new Ui::FormCategoryDetails(); m_ui = new Ui::FormStandardCategoryDetails();
m_ui->setupUi(this); m_ui->setupUi(this);
// Set flags and attributes. // Set flags and attributes.
@ -119,7 +119,7 @@ void FormCategoryDetails::initialize() {
m_ui->m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); m_ui->m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
} }
void FormCategoryDetails::loadCategories(const QList<FeedsModelCategory *> categories, void FormStandardCategoryDetails::loadCategories(const QList<FeedsModelCategory *> categories,
FeedsModelRootItem *root_item) { FeedsModelRootItem *root_item) {
m_ui->m_cmbParentCategory->addItem(root_item->icon(), m_ui->m_cmbParentCategory->addItem(root_item->icon(),
root_item->title(), root_item->title(),

View file

@ -1,13 +1,13 @@
#ifndef FORMCATEGORYDETAILS_H #ifndef FORMCATEGORYDETAILS_H
#define FORMCATEGORYDETAILS_H #define FORMCATEGORYDETAILS_H
#include "ui_formcategorydetails.h" #include "ui_formstandardcategorydetails.h"
#include <QDialog> #include <QDialog>
namespace Ui { namespace Ui {
class FormSettings; class FormStandardCategoryDetails;
} }
class FeedsModelCategory; class FeedsModelCategory;
@ -16,16 +16,16 @@ class FeedsModel;
class FeedsModelRootItem; class FeedsModelRootItem;
class FormCategoryDetails : public QDialog { class FormStandardCategoryDetails : public QDialog {
Q_OBJECT Q_OBJECT
public: public:
// Constructors and destructors. // Constructors and destructors.
// This constructor is supposed to create new categories. // This constructor is supposed to create new categories.
explicit FormCategoryDetails(FeedsModel *model, QWidget *parent = 0); explicit FormStandardCategoryDetails(FeedsModel *model, QWidget *parent = 0);
// Destructor. // Destructor.
virtual ~FormCategoryDetails(); virtual ~FormStandardCategoryDetails();
// Creates needed connections. // Creates needed connections.
void createConnections(); void createConnections();
@ -60,7 +60,7 @@ class FormCategoryDetails : public QDialog {
FeedsModelRootItem *root_item); FeedsModelRootItem *root_item);
private: private:
Ui::FormCategoryDetails *m_ui; Ui::FormStandardCategoryDetails *m_ui;
FeedsModelStandardCategory *m_editableCategory; FeedsModelStandardCategory *m_editableCategory;
FeedsModel *m_feedsModel; FeedsModel *m_feedsModel;
}; };

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>FormCategoryDetails</class> <class>FormStandardCategoryDetails</class>
<widget class="QDialog" name="FormCategoryDetails"> <widget class="QDialog" name="FormStandardCategoryDetails">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
@ -108,7 +108,7 @@
<connection> <connection>
<sender>m_buttonBox</sender> <sender>m_buttonBox</sender>
<signal>rejected()</signal> <signal>rejected()</signal>
<receiver>FormCategoryDetails</receiver> <receiver>FormStandardCategoryDetails</receiver>
<slot>reject()</slot> <slot>reject()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">