mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-01-31 09:34:52 +01:00
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/formwelcome.ui
|
||||
src/gui/formabout.ui
|
||||
src/gui/formcategorydetails.ui
|
||||
)
|
||||
|
||||
# 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");
|
||||
|
||||
m_rootItem = new FeedsModelRootItem();
|
||||
m_rootItem->setId(NO_PARENT_CATEGORY);
|
||||
m_rootItem->setTitle(tr("root"));
|
||||
m_rootItem->setIcon(IconThemeFactory::getInstance()->fromTheme("folder-red"));
|
||||
|
||||
m_countsIcon = IconThemeFactory::getInstance()->fromTheme("mail-mark-unread");
|
||||
|
||||
@ -29,32 +31,6 @@ FeedsModel::FeedsModel(QObject *parent) : QAbstractItemModel(parent) {
|
||||
tr("Counts of unread/all meesages.");
|
||||
|
||||
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() {
|
||||
@ -463,6 +439,10 @@ void FeedsModel::assembleFeeds(FeedAssignment feeds) {
|
||||
}
|
||||
}
|
||||
|
||||
FeedsModelRootItem *FeedsModel::rootItem() const {
|
||||
return m_rootItem;
|
||||
}
|
||||
|
||||
void FeedsModel::assembleCategories(CategoryAssignment categories) {
|
||||
QHash<int, FeedsModelRootItem*> assignments;
|
||||
assignments.insert(NO_PARENT_CATEGORY, m_rootItem);
|
||||
|
@ -54,6 +54,9 @@ class FeedsModel : public QAbstractItemModel {
|
||||
// Returns feeds contained within single index.
|
||||
QList<FeedsModelFeed*> feedsForIndex(const QModelIndex &index);
|
||||
|
||||
// Access to root item.
|
||||
FeedsModelRootItem *rootItem() const;
|
||||
|
||||
public slots:
|
||||
bool markFeedsRead(const QList<FeedsModelFeed*> &feeds, int read);
|
||||
bool markFeedsDeleted(const QList<FeedsModelFeed*> &feeds, int deleted);
|
||||
|
@ -27,6 +27,10 @@ FeedsModelRootItem::Kind FeedsModelRootItem::kind() const {
|
||||
return m_kind;
|
||||
}
|
||||
|
||||
QIcon FeedsModelRootItem::icon() const {
|
||||
return m_icon;
|
||||
}
|
||||
|
||||
FeedsModelRootItem *FeedsModelRootItem::child(int row) {
|
||||
return m_childItems.value(row);
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ class FeedsModelRootItem {
|
||||
virtual Kind kind() const;
|
||||
|
||||
// Each item has icon.
|
||||
QIcon icon() const;
|
||||
void setIcon(const QIcon &icon);
|
||||
|
||||
// Each item has some kind of id.
|
||||
|
@ -26,6 +26,14 @@ FeedsView::~FeedsView() {
|
||||
qDebug("Destroying FeedsView instance.");
|
||||
}
|
||||
|
||||
FeedsProxyModel *FeedsView::model() {
|
||||
return m_proxyModel;
|
||||
}
|
||||
|
||||
FeedsModel *FeedsView::sourceModel() {
|
||||
return m_sourceModel;
|
||||
}
|
||||
|
||||
void FeedsView::setSortingEnabled(bool enable) {
|
||||
QTreeView::setSortingEnabled(enable);
|
||||
header()->setSortIndicatorShown(false);
|
||||
|
@ -16,6 +16,9 @@ class FeedsView : public QTreeView {
|
||||
explicit FeedsView(QWidget *parent = 0);
|
||||
virtual ~FeedsView();
|
||||
|
||||
FeedsProxyModel *model();
|
||||
FeedsModel *sourceModel();
|
||||
|
||||
// Enables or disables sorting.
|
||||
void setSortingEnabled(bool enable);
|
||||
|
||||
|
@ -1,25 +1,63 @@
|
||||
#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/feedsview.h"
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
|
||||
FormCategoryDetails::FormCategoryDetails(FeedsView *parent)
|
||||
: QDialog(parent) {
|
||||
// Set flags and attributes.
|
||||
setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog);
|
||||
setWindowIcon(IconThemeFactory::getInstance()->fromTheme("document-new"));
|
||||
initialize(parent);
|
||||
loadCategories(parent->sourceModel()->getAllCategories().values(),
|
||||
parent->sourceModel()->rootItem());
|
||||
|
||||
setWindowTitle(tr("Add new category"));
|
||||
}
|
||||
|
||||
FormCategoryDetails::FormCategoryDetails(FeedsModelCategory *category,
|
||||
FeedsView *parent)
|
||||
:QDialog(parent) {
|
||||
// Set flags and attributes.
|
||||
setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog);
|
||||
setWindowIcon(IconThemeFactory::getInstance()->fromTheme("document-new"));
|
||||
: QDialog(parent) {
|
||||
initialize(parent);
|
||||
loadCategories(parent->sourceModel()->getAllCategories().values(),
|
||||
parent->sourceModel()->rootItem());
|
||||
|
||||
setWindowTitle(tr("Edit existing category"));
|
||||
}
|
||||
|
||||
FormCategoryDetails::~FormCategoryDetails() {
|
||||
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
|
||||
#define FORMCATEGORYDETAILS_H
|
||||
|
||||
#include "ui_formcategorydetails.h"
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class FormSettings;
|
||||
}
|
||||
|
||||
class FeedsModelCategory;
|
||||
class FeedsModelRootItem;
|
||||
class FeedsView;
|
||||
|
||||
class FormCategoryDetails : public QDialog {
|
||||
@ -22,9 +29,16 @@ class FormCategoryDetails : public QDialog {
|
||||
// Destructor.
|
||||
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">
|
||||
<widget class="QStackedWidget" name="m_stackedSettings">
|
||||
<property name="currentIndex">
|
||||
<number>4</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="m_pageGeneral">
|
||||
<layout class="QFormLayout" name="formLayout_5">
|
||||
@ -583,7 +583,7 @@
|
||||
<item>
|
||||
<widget class="QTabWidget" name="m_tabFeedsMessages">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="m_tabFeeds">
|
||||
<attribute name="title">
|
||||
@ -714,7 +714,7 @@
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="currentRow">
|
||||
<number>-1</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
|
Loading…
x
Reference in New Issue
Block a user