Work on adding categories.
This commit is contained in:
parent
a19ba25137
commit
d6ee69df0d
@ -340,6 +340,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
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add resources.
|
# Add resources.
|
||||||
|
BIN
resources/graphics/icons/mini-kfaenza/folder-red.png
Normal file
BIN
resources/graphics/icons/mini-kfaenza/folder-red.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
@ -20,7 +20,9 @@ FeedsModel::FeedsModel(QObject *parent) : QAbstractItemModel(parent) {
|
|||||||
setObjectName("FeedsModel");
|
setObjectName("FeedsModel");
|
||||||
|
|
||||||
m_rootItem = new FeedsModelRootItem();
|
m_rootItem = new FeedsModelRootItem();
|
||||||
|
m_rootItem->setId(NO_PARENT_CATEGORY);
|
||||||
m_rootItem->setTitle(tr("root"));
|
m_rootItem->setTitle(tr("root"));
|
||||||
|
m_rootItem->setIcon(IconThemeFactory::getInstance()->fromTheme("folder-red"));
|
||||||
|
|
||||||
m_countsIcon = IconThemeFactory::getInstance()->fromTheme("mail-mark-unread");
|
m_countsIcon = IconThemeFactory::getInstance()->fromTheme("mail-mark-unread");
|
||||||
|
|
||||||
@ -29,32 +31,6 @@ FeedsModel::FeedsModel(QObject *parent) : QAbstractItemModel(parent) {
|
|||||||
tr("Counts of unread/all meesages.");
|
tr("Counts of unread/all meesages.");
|
||||||
|
|
||||||
loadFromDatabase();
|
loadFromDatabase();
|
||||||
|
|
||||||
/*
|
|
||||||
FeedsModelStandardCategory *cat1 = new FeedsModelStandardCategory();
|
|
||||||
FeedsModelStandardCategory *cat2 = new FeedsModelStandardCategory();
|
|
||||||
FeedsModelStandardFeed *feed1 = new FeedsModelStandardFeed();
|
|
||||||
FeedsModelStandardFeed *feed2 = new FeedsModelStandardFeed();
|
|
||||||
FeedsModelStandardFeed *feed3 = new FeedsModelStandardFeed();
|
|
||||||
FeedsModelStandardFeed *feed4 = new FeedsModelStandardFeed();
|
|
||||||
FeedsModelStandardFeed *feed5 = new FeedsModelStandardFeed();
|
|
||||||
|
|
||||||
feed1->setTitle("aaa");
|
|
||||||
feed2->setTitle("aaa");
|
|
||||||
feed3->setTitle("aaa");
|
|
||||||
feed4->setTitle("aaa");
|
|
||||||
feed5->setTitle("aaa");
|
|
||||||
|
|
||||||
cat1->appendChild(feed1);
|
|
||||||
cat1->appendChild(feed2);
|
|
||||||
cat1->appendChild(cat2);
|
|
||||||
|
|
||||||
cat2->appendChild(feed4);
|
|
||||||
cat2->appendChild(feed5);
|
|
||||||
|
|
||||||
m_rootItem->appendChild(cat1);
|
|
||||||
m_rootItem->appendChild(feed3);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FeedsModel::~FeedsModel() {
|
FeedsModel::~FeedsModel() {
|
||||||
@ -463,6 +439,10 @@ void FeedsModel::assembleFeeds(FeedAssignment feeds) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FeedsModelRootItem *FeedsModel::rootItem() const {
|
||||||
|
return m_rootItem;
|
||||||
|
}
|
||||||
|
|
||||||
void FeedsModel::assembleCategories(CategoryAssignment categories) {
|
void FeedsModel::assembleCategories(CategoryAssignment categories) {
|
||||||
QHash<int, FeedsModelRootItem*> assignments;
|
QHash<int, FeedsModelRootItem*> assignments;
|
||||||
assignments.insert(NO_PARENT_CATEGORY, m_rootItem);
|
assignments.insert(NO_PARENT_CATEGORY, m_rootItem);
|
||||||
|
@ -54,6 +54,9 @@ class FeedsModel : public QAbstractItemModel {
|
|||||||
// Returns feeds contained within single index.
|
// Returns feeds contained within single index.
|
||||||
QList<FeedsModelFeed*> feedsForIndex(const QModelIndex &index);
|
QList<FeedsModelFeed*> feedsForIndex(const QModelIndex &index);
|
||||||
|
|
||||||
|
// Access to root item.
|
||||||
|
FeedsModelRootItem *rootItem() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
bool markFeedsRead(const QList<FeedsModelFeed*> &feeds, int read);
|
bool markFeedsRead(const QList<FeedsModelFeed*> &feeds, int read);
|
||||||
bool markFeedsDeleted(const QList<FeedsModelFeed*> &feeds, int deleted);
|
bool markFeedsDeleted(const QList<FeedsModelFeed*> &feeds, int deleted);
|
||||||
|
@ -27,6 +27,10 @@ FeedsModelRootItem::Kind FeedsModelRootItem::kind() const {
|
|||||||
return m_kind;
|
return m_kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QIcon FeedsModelRootItem::icon() const {
|
||||||
|
return m_icon;
|
||||||
|
}
|
||||||
|
|
||||||
FeedsModelRootItem *FeedsModelRootItem::child(int row) {
|
FeedsModelRootItem *FeedsModelRootItem::child(int row) {
|
||||||
return m_childItems.value(row);
|
return m_childItems.value(row);
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ class FeedsModelRootItem {
|
|||||||
virtual Kind kind() const;
|
virtual Kind kind() const;
|
||||||
|
|
||||||
// Each item has icon.
|
// Each item has icon.
|
||||||
|
QIcon icon() const;
|
||||||
void setIcon(const QIcon &icon);
|
void setIcon(const QIcon &icon);
|
||||||
|
|
||||||
// Each item has some kind of id.
|
// Each item has some kind of id.
|
||||||
|
@ -26,6 +26,14 @@ FeedsView::~FeedsView() {
|
|||||||
qDebug("Destroying FeedsView instance.");
|
qDebug("Destroying FeedsView instance.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FeedsProxyModel *FeedsView::model() {
|
||||||
|
return m_proxyModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
FeedsModel *FeedsView::sourceModel() {
|
||||||
|
return m_sourceModel;
|
||||||
|
}
|
||||||
|
|
||||||
void FeedsView::setSortingEnabled(bool enable) {
|
void FeedsView::setSortingEnabled(bool enable) {
|
||||||
QTreeView::setSortingEnabled(enable);
|
QTreeView::setSortingEnabled(enable);
|
||||||
header()->setSortIndicatorShown(false);
|
header()->setSortIndicatorShown(false);
|
||||||
|
@ -16,6 +16,9 @@ class FeedsView : public QTreeView {
|
|||||||
explicit FeedsView(QWidget *parent = 0);
|
explicit FeedsView(QWidget *parent = 0);
|
||||||
virtual ~FeedsView();
|
virtual ~FeedsView();
|
||||||
|
|
||||||
|
FeedsProxyModel *model();
|
||||||
|
FeedsModel *sourceModel();
|
||||||
|
|
||||||
// Enables or disables sorting.
|
// Enables or disables sorting.
|
||||||
void setSortingEnabled(bool enable);
|
void setSortingEnabled(bool enable);
|
||||||
|
|
||||||
|
@ -1,25 +1,63 @@
|
|||||||
#include "gui/formcategorydetails.h"
|
#include "gui/formcategorydetails.h"
|
||||||
|
|
||||||
|
#include "core/defs.h"
|
||||||
|
#include "core/feedsmodelrootitem.h"
|
||||||
|
#include "core/feedsmodelcategory.h"
|
||||||
|
#include "core/feedsmodel.h"
|
||||||
#include "gui/iconthemefactory.h"
|
#include "gui/iconthemefactory.h"
|
||||||
#include "gui/feedsview.h"
|
#include "gui/feedsview.h"
|
||||||
|
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
|
|
||||||
FormCategoryDetails::FormCategoryDetails(FeedsView *parent)
|
FormCategoryDetails::FormCategoryDetails(FeedsView *parent)
|
||||||
: QDialog(parent) {
|
: QDialog(parent) {
|
||||||
// Set flags and attributes.
|
initialize(parent);
|
||||||
setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog);
|
loadCategories(parent->sourceModel()->getAllCategories().values(),
|
||||||
setWindowIcon(IconThemeFactory::getInstance()->fromTheme("document-new"));
|
parent->sourceModel()->rootItem());
|
||||||
|
|
||||||
|
setWindowTitle(tr("Add new category"));
|
||||||
}
|
}
|
||||||
|
|
||||||
FormCategoryDetails::FormCategoryDetails(FeedsModelCategory *category,
|
FormCategoryDetails::FormCategoryDetails(FeedsModelCategory *category,
|
||||||
FeedsView *parent)
|
FeedsView *parent)
|
||||||
:QDialog(parent) {
|
: QDialog(parent) {
|
||||||
// Set flags and attributes.
|
initialize(parent);
|
||||||
setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog);
|
loadCategories(parent->sourceModel()->getAllCategories().values(),
|
||||||
setWindowIcon(IconThemeFactory::getInstance()->fromTheme("document-new"));
|
parent->sourceModel()->rootItem());
|
||||||
|
|
||||||
|
setWindowTitle(tr("Edit existing category"));
|
||||||
}
|
}
|
||||||
|
|
||||||
FormCategoryDetails::~FormCategoryDetails() {
|
FormCategoryDetails::~FormCategoryDetails() {
|
||||||
qDebug("Destroying FormCategoryDetails instance.");
|
qDebug("Destroying FormCategoryDetails instance.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FormCategoryDetails::initialize(FeedsView *view) {
|
||||||
|
m_ui = new Ui::FormCategoryDetails();
|
||||||
|
m_ui->setupUi(this);
|
||||||
|
|
||||||
|
// Set flags and attributes.
|
||||||
|
setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog);
|
||||||
|
setWindowIcon(IconThemeFactory::getInstance()->fromTheme("document-new"));
|
||||||
|
|
||||||
|
// Add button for obtaining data about feed from internet.
|
||||||
|
m_btnObtainDetails = m_ui->m_buttonBox->addButton(tr("Get details via internet"),
|
||||||
|
QDialogButtonBox::ActionRole);
|
||||||
|
m_btnObtainDetails->setIcon(IconThemeFactory::getInstance()->fromTheme("document-save"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void FormCategoryDetails::loadCategories(const QList<FeedsModelCategory *> categories,
|
||||||
|
FeedsModelRootItem *root_item) {
|
||||||
|
m_ui->m_cmbParentCategory->addItem(root_item->icon(),
|
||||||
|
root_item->title(),
|
||||||
|
root_item->id());
|
||||||
|
|
||||||
|
foreach (FeedsModelCategory *category, categories) {
|
||||||
|
m_ui->m_cmbParentCategory->addItem(category->data(FDS_MODEL_TITLE_INDEX,
|
||||||
|
Qt::DecorationRole).value<QIcon>(),
|
||||||
|
category->title(),
|
||||||
|
category->id());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -1,10 +1,17 @@
|
|||||||
#ifndef FORMCATEGORYDETAILS_H
|
#ifndef FORMCATEGORYDETAILS_H
|
||||||
#define FORMCATEGORYDETAILS_H
|
#define FORMCATEGORYDETAILS_H
|
||||||
|
|
||||||
|
#include "ui_formcategorydetails.h"
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class FormSettings;
|
||||||
|
}
|
||||||
|
|
||||||
class FeedsModelCategory;
|
class FeedsModelCategory;
|
||||||
|
class FeedsModelRootItem;
|
||||||
class FeedsView;
|
class FeedsView;
|
||||||
|
|
||||||
class FormCategoryDetails : public QDialog {
|
class FormCategoryDetails : public QDialog {
|
||||||
@ -22,9 +29,16 @@ class FormCategoryDetails : public QDialog {
|
|||||||
// Destructor.
|
// Destructor.
|
||||||
virtual ~FormCategoryDetails();
|
virtual ~FormCategoryDetails();
|
||||||
|
|
||||||
signals:
|
protected:
|
||||||
|
void initialize(FeedsView *view);
|
||||||
|
|
||||||
public slots:
|
// Loads categories into the dialog.
|
||||||
|
void loadCategories(const QList<FeedsModelCategory*> categories,
|
||||||
|
FeedsModelRootItem *root_item);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::FormCategoryDetails *m_ui;
|
||||||
|
QPushButton *m_btnObtainDetails;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
126
src/gui/formcategorydetails.ui
Normal file
126
src/gui/formcategorydetails.ui
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>FormCategoryDetails</class>
|
||||||
|
<widget class="QDialog" name="FormCategoryDetails">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>362</width>
|
||||||
|
<height>183</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Dialog</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<layout class="QFormLayout" name="formLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="m_lblParentCategory">
|
||||||
|
<property name="text">
|
||||||
|
<string>Parent category</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QComboBox" name="m_cmbParentCategory"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="m_lblParentCategory_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Title</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLineEdit" name="lineEdit">
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Title of the category</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="m_lblParentCategory_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Description</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QLineEdit" name="lineEdit_2">
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Description of the category</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="m_lblParentCategory_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>Icon</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QToolButton" name="toolButton">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="m_buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>m_buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>FormCategoryDetails</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>m_buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>FormCategoryDetails</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
@ -17,7 +17,7 @@
|
|||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QStackedWidget" name="m_stackedSettings">
|
<widget class="QStackedWidget" name="m_stackedSettings">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>4</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="m_pageGeneral">
|
<widget class="QWidget" name="m_pageGeneral">
|
||||||
<layout class="QFormLayout" name="formLayout_5">
|
<layout class="QFormLayout" name="formLayout_5">
|
||||||
@ -583,7 +583,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="m_tabFeedsMessages">
|
<widget class="QTabWidget" name="m_tabFeedsMessages">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="m_tabFeeds">
|
<widget class="QWidget" name="m_tabFeeds">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@ -714,7 +714,7 @@
|
|||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentRow">
|
<property name="currentRow">
|
||||||
<number>-1</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user