Some simplifications in construcotrs of std. category.
This commit is contained in:
parent
cd62c222e9
commit
e0790bb6a2
@ -34,6 +34,8 @@ Category::Category(RootItem* parent) : RootItem(parent) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Category::Category(const Category& other) : RootItem(other) {}
|
||||||
|
|
||||||
Category::Category(const QSqlRecord& record) : Category(nullptr) {
|
Category::Category(const QSqlRecord& record) : Category(nullptr) {
|
||||||
setId(record.value(CAT_DB_ID_INDEX).toInt());
|
setId(record.value(CAT_DB_ID_INDEX).toInt());
|
||||||
setCustomId(record.value(CAT_DB_CUSTOM_ID_INDEX).toString());
|
setCustomId(record.value(CAT_DB_CUSTOM_ID_INDEX).toString());
|
||||||
|
@ -26,6 +26,7 @@ class Category : public RootItem {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Category(RootItem* parent = nullptr);
|
explicit Category(RootItem* parent = nullptr);
|
||||||
|
explicit Category(const Category& other);
|
||||||
explicit Category(const QSqlRecord& record);
|
explicit Category(const QSqlRecord& record);
|
||||||
virtual ~Category();
|
virtual ~Category();
|
||||||
|
|
||||||
|
@ -146,7 +146,13 @@ QVariant RootItem::data(int column, int role) const {
|
|||||||
switch (role) {
|
switch (role) {
|
||||||
case Qt::ToolTipRole:
|
case Qt::ToolTipRole:
|
||||||
if (column == FDS_MODEL_TITLE_INDEX) {
|
if (column == FDS_MODEL_TITLE_INDEX) {
|
||||||
return m_title;
|
QString tool_tip = m_title;
|
||||||
|
|
||||||
|
if (!m_description.isEmpty()) {
|
||||||
|
tool_tip += QL1S("\n\n") + m_description;
|
||||||
|
}
|
||||||
|
|
||||||
|
return tool_tip;
|
||||||
}
|
}
|
||||||
else if (column == FDS_MODEL_COUNTS_INDEX) {
|
else if (column == FDS_MODEL_COUNTS_INDEX) {
|
||||||
//: Tooltip for "unread" column of feed list.
|
//: Tooltip for "unread" column of feed list.
|
||||||
|
@ -35,16 +35,7 @@
|
|||||||
StandardCategory::StandardCategory(RootItem* parent_item) : Category(parent_item) {}
|
StandardCategory::StandardCategory(RootItem* parent_item) : Category(parent_item) {}
|
||||||
|
|
||||||
StandardCategory::StandardCategory(const StandardCategory& other)
|
StandardCategory::StandardCategory(const StandardCategory& other)
|
||||||
: StandardCategory(nullptr) {
|
: Category(other) {}
|
||||||
setId(other.id());
|
|
||||||
setCustomId(other.customId());
|
|
||||||
setTitle(other.title());
|
|
||||||
setDescription(other.description());
|
|
||||||
setIcon(other.icon());
|
|
||||||
setCreationDate(other.creationDate());
|
|
||||||
setChildItems(other.childItems());
|
|
||||||
setParent(other.parent());
|
|
||||||
}
|
|
||||||
|
|
||||||
StandardCategory::~StandardCategory() {
|
StandardCategory::~StandardCategory() {
|
||||||
qDebug("Destroying Category instance.");
|
qDebug("Destroying Category instance.");
|
||||||
@ -54,27 +45,6 @@ StandardServiceRoot* StandardCategory::serviceRoot() const {
|
|||||||
return qobject_cast<StandardServiceRoot*>(getParentServiceRoot());
|
return qobject_cast<StandardServiceRoot*>(getParentServiceRoot());
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant StandardCategory::data(int column, int role) const {
|
|
||||||
switch (role) {
|
|
||||||
case Qt::ToolTipRole:
|
|
||||||
if (column == FDS_MODEL_TITLE_INDEX) {
|
|
||||||
//: Tooltip for standard feed.
|
|
||||||
return tr("%1 (category)"
|
|
||||||
"%2%3").arg(title(),
|
|
||||||
description().isEmpty() ? QString() : QSL("\n") + description(),
|
|
||||||
childCount() == 0 ?
|
|
||||||
tr("\nThis category does not contain any nested items.") :
|
|
||||||
QString());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return Category::data(column, role);
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
return Category::data(column, role);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Qt::ItemFlags StandardCategory::additionalFlags() const {
|
Qt::ItemFlags StandardCategory::additionalFlags() const {
|
||||||
return Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
|
return Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
|
||||||
}
|
}
|
||||||
@ -96,6 +66,14 @@ bool StandardCategory::performDragDropChange(RootItem* target_item) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool StandardCategory::canBeEdited() const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool StandardCategory::canBeDeleted() const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool StandardCategory::editViaGui() {
|
bool StandardCategory::editViaGui() {
|
||||||
QScopedPointer<FormStandardCategoryDetails> form_pointer(new FormStandardCategoryDetails(serviceRoot(), qApp->mainFormWidget()));
|
QScopedPointer<FormStandardCategoryDetails> form_pointer(new FormStandardCategoryDetails(serviceRoot(), qApp->mainFormWidget()));
|
||||||
form_pointer.data()->addEditCategory(this, nullptr);
|
form_pointer.data()->addEditCategory(this, nullptr);
|
||||||
|
@ -34,8 +34,6 @@ class StandardCategory : public Category {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Constructors and destructors
|
|
||||||
explicit StandardCategory(RootItem* parent_item = nullptr);
|
explicit StandardCategory(RootItem* parent_item = nullptr);
|
||||||
explicit StandardCategory(const StandardCategory& other);
|
explicit StandardCategory(const StandardCategory& other);
|
||||||
explicit StandardCategory(const QSqlRecord& record);
|
explicit StandardCategory(const QSqlRecord& record);
|
||||||
@ -44,27 +42,18 @@ class StandardCategory : public Category {
|
|||||||
StandardServiceRoot* serviceRoot() const;
|
StandardServiceRoot* serviceRoot() const;
|
||||||
|
|
||||||
// Returns the actual data representation of standard category.
|
// Returns the actual data representation of standard category.
|
||||||
QVariant data(int column, int role) const;
|
|
||||||
Qt::ItemFlags additionalFlags() const;
|
Qt::ItemFlags additionalFlags() const;
|
||||||
bool performDragDropChange(RootItem* target_item);
|
bool performDragDropChange(RootItem* target_item);
|
||||||
|
|
||||||
bool canBeEdited() const {
|
bool canBeEdited() const;
|
||||||
return true;
|
bool canBeDeleted() const;
|
||||||
}
|
|
||||||
|
|
||||||
bool canBeDeleted() const {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool editViaGui();
|
bool editViaGui();
|
||||||
bool deleteViaGui();
|
bool deleteViaGui();
|
||||||
|
|
||||||
// Removes category and all its children from persistent
|
|
||||||
// database.
|
|
||||||
bool removeItself();
|
|
||||||
|
|
||||||
bool addItself(RootItem* parent);
|
bool addItself(RootItem* parent);
|
||||||
bool editItself(StandardCategory* new_category_data);
|
bool editItself(StandardCategory* new_category_data);
|
||||||
|
bool removeItself();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FEEDSMODELCLASSICCATEGORY_H
|
#endif // FEEDSMODELCLASSICCATEGORY_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user