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) {
|
||||
setId(record.value(CAT_DB_ID_INDEX).toInt());
|
||||
setCustomId(record.value(CAT_DB_CUSTOM_ID_INDEX).toString());
|
||||
|
@ -26,6 +26,7 @@ class Category : public RootItem {
|
||||
|
||||
public:
|
||||
explicit Category(RootItem* parent = nullptr);
|
||||
explicit Category(const Category& other);
|
||||
explicit Category(const QSqlRecord& record);
|
||||
virtual ~Category();
|
||||
|
||||
|
@ -146,7 +146,13 @@ QVariant RootItem::data(int column, int role) const {
|
||||
switch (role) {
|
||||
case Qt::ToolTipRole:
|
||||
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) {
|
||||
//: Tooltip for "unread" column of feed list.
|
||||
|
@ -35,16 +35,7 @@
|
||||
StandardCategory::StandardCategory(RootItem* parent_item) : Category(parent_item) {}
|
||||
|
||||
StandardCategory::StandardCategory(const StandardCategory& other)
|
||||
: StandardCategory(nullptr) {
|
||||
setId(other.id());
|
||||
setCustomId(other.customId());
|
||||
setTitle(other.title());
|
||||
setDescription(other.description());
|
||||
setIcon(other.icon());
|
||||
setCreationDate(other.creationDate());
|
||||
setChildItems(other.childItems());
|
||||
setParent(other.parent());
|
||||
}
|
||||
: Category(other) {}
|
||||
|
||||
StandardCategory::~StandardCategory() {
|
||||
qDebug("Destroying Category instance.");
|
||||
@ -54,27 +45,6 @@ StandardServiceRoot* StandardCategory::serviceRoot() const {
|
||||
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 {
|
||||
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() {
|
||||
QScopedPointer<FormStandardCategoryDetails> form_pointer(new FormStandardCategoryDetails(serviceRoot(), qApp->mainFormWidget()));
|
||||
form_pointer.data()->addEditCategory(this, nullptr);
|
||||
|
@ -34,8 +34,6 @@ class StandardCategory : public Category {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
// Constructors and destructors
|
||||
explicit StandardCategory(RootItem* parent_item = nullptr);
|
||||
explicit StandardCategory(const StandardCategory& other);
|
||||
explicit StandardCategory(const QSqlRecord& record);
|
||||
@ -44,27 +42,18 @@ class StandardCategory : public Category {
|
||||
StandardServiceRoot* serviceRoot() const;
|
||||
|
||||
// Returns the actual data representation of standard category.
|
||||
QVariant data(int column, int role) const;
|
||||
Qt::ItemFlags additionalFlags() const;
|
||||
bool performDragDropChange(RootItem* target_item);
|
||||
|
||||
bool canBeEdited() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool canBeDeleted() const {
|
||||
return true;
|
||||
}
|
||||
bool canBeEdited() const;
|
||||
bool canBeDeleted() const;
|
||||
|
||||
bool editViaGui();
|
||||
bool deleteViaGui();
|
||||
|
||||
// Removes category and all its children from persistent
|
||||
// database.
|
||||
bool removeItself();
|
||||
|
||||
bool addItself(RootItem* parent);
|
||||
bool editItself(StandardCategory* new_category_data);
|
||||
bool removeItself();
|
||||
};
|
||||
|
||||
#endif // FEEDSMODELCLASSICCATEGORY_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user