Work on menus.
This commit is contained in:
parent
c3384af89e
commit
fa976120b8
5 changed files with 34 additions and 27 deletions
|
@ -173,31 +173,23 @@ void FormMain::switchMainMenu() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormMain::updateAddItemMenu() {
|
void FormMain::updateAddItemMenu() {
|
||||||
// TODO: clear nevymaže z paměti. - edit, stačí nastavit parent na to menu
|
// NOTE: Clear here deletes items from memory but only those OWNED by the menu.
|
||||||
// a při clear to i vymaže z paměti.
|
|
||||||
m_ui->m_menuAddItem->clear();
|
m_ui->m_menuAddItem->clear();
|
||||||
|
|
||||||
foreach (ServiceRoot *activated_root, tabWidget()->feedMessageViewer()->feedsView()->sourceModel()->serviceRoots()) {
|
foreach (ServiceRoot *activated_root, tabWidget()->feedMessageViewer()->feedsView()->sourceModel()->serviceRoots()) {
|
||||||
QMenu *root_menu = new QMenu(activated_root->title(), m_ui->m_menuAddItem);
|
QMenu *root_menu = activated_root->addItemMenu();
|
||||||
QList<QAction*> root_actions = activated_root->specificAddItemActions();
|
|
||||||
|
|
||||||
root_menu->setIcon(activated_root->icon());
|
if (root_menu == NULL) {
|
||||||
root_menu->setToolTip(activated_root->description());
|
root_menu = new QMenu(activated_root->title(), m_ui->m_menuAddItem);
|
||||||
|
root_menu->setIcon(activated_root->icon());
|
||||||
|
root_menu->setToolTip(activated_root->description());
|
||||||
|
|
||||||
if (root_actions.isEmpty()) {
|
|
||||||
QAction *no_action = new QAction(qApp->icons()->fromTheme(QSL("dialog-error")),
|
QAction *no_action = new QAction(qApp->icons()->fromTheme(QSL("dialog-error")),
|
||||||
tr("No possible actions"),
|
tr("No possible actions"),
|
||||||
m_ui->m_menuAddItem);
|
m_ui->m_menuAddItem);
|
||||||
no_action->setEnabled(false);
|
no_action->setEnabled(false);
|
||||||
root_menu->addAction(no_action);
|
root_menu->addAction(no_action);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
foreach (QAction *action, root_actions) {
|
|
||||||
action->setParent(root_menu);
|
|
||||||
}
|
|
||||||
|
|
||||||
root_menu->addActions(root_actions);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_ui->m_menuAddItem->addMenu(root_menu);
|
m_ui->m_menuAddItem->addMenu(root_menu);
|
||||||
}
|
}
|
||||||
|
|
|
@ -622,7 +622,8 @@ void FeedsView::contextMenuEvent(QContextMenuEvent *event) {
|
||||||
m_contextMenuFeeds->exec(event->globalPos());
|
m_contextMenuFeeds->exec(event->globalPos());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// TODO: volaz specificke menu polozky? zobrazovat menu pro dalsi typy
|
||||||
|
// polozek jako odpadkovy kos atp.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
class FeedsModel;
|
class FeedsModel;
|
||||||
|
class QMenu;
|
||||||
|
|
||||||
// THIS IS the root node of the service.
|
// THIS IS the root node of the service.
|
||||||
// NOTE: The root usually contains some core functionality of the
|
// NOTE: The root usually contains some core functionality of the
|
||||||
|
@ -38,10 +39,10 @@ class ServiceRoot : public RootItem {
|
||||||
// a) Add new feed
|
// a) Add new feed
|
||||||
// b) Add new category
|
// b) Add new category
|
||||||
// c) ...
|
// c) ...
|
||||||
// NOTE: This method should always create new actions in memory
|
// NOTE: Caller does NOT take ownership of created menu!
|
||||||
// before returning them because caller takes ownership of any
|
virtual QMenu* addItemMenu() = 0;
|
||||||
// actions returned from here.
|
|
||||||
virtual QList<QAction*> specificAddItemActions() = 0;
|
// TODO: dodělat menu, které se zobrazi v menubaru "Services -> tato služba".
|
||||||
|
|
||||||
inline FeedsModel *feedsModel() const {
|
inline FeedsModel *feedsModel() const {
|
||||||
return m_feedsModel;
|
return m_feedsModel;
|
||||||
|
|
|
@ -32,10 +32,11 @@
|
||||||
#include <QSqlError>
|
#include <QSqlError>
|
||||||
#include <QStack>
|
#include <QStack>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
|
|
||||||
StandardServiceRoot::StandardServiceRoot(bool load_from_db, FeedsModel *feeds_model, RootItem *parent)
|
StandardServiceRoot::StandardServiceRoot(bool load_from_db, FeedsModel *feeds_model, RootItem *parent)
|
||||||
: ServiceRoot(feeds_model, parent), m_recycleBin(new StandardRecycleBin(this)) {
|
: ServiceRoot(feeds_model, parent), m_recycleBin(new StandardRecycleBin(this)), m_addItemMenu(NULL) {
|
||||||
m_title = qApp->system()->getUsername() + QL1S("@") + QL1S(APP_LOW_NAME);
|
m_title = qApp->system()->getUsername() + QL1S("@") + QL1S(APP_LOW_NAME);
|
||||||
m_icon = StandardServiceEntryPoint().icon();
|
m_icon = StandardServiceEntryPoint().icon();
|
||||||
m_description = tr("This is obligatory service account for standard RSS/RDF/ATOM feeds.");
|
m_description = tr("This is obligatory service account for standard RSS/RDF/ATOM feeds.");
|
||||||
|
@ -47,6 +48,9 @@ StandardServiceRoot::StandardServiceRoot(bool load_from_db, FeedsModel *feeds_mo
|
||||||
}
|
}
|
||||||
|
|
||||||
StandardServiceRoot::~StandardServiceRoot() {
|
StandardServiceRoot::~StandardServiceRoot() {
|
||||||
|
if (m_addItemMenu != NULL) {
|
||||||
|
delete m_addItemMenu;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StandardServiceRoot::canBeEdited() {
|
bool StandardServiceRoot::canBeEdited() {
|
||||||
|
@ -324,12 +328,17 @@ bool StandardServiceRoot::mergeImportExportModel(FeedsImportExportModel *model,
|
||||||
return !some_feed_category_error;
|
return !some_feed_category_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QAction*> StandardServiceRoot::specificAddItemActions() {
|
QMenu *StandardServiceRoot::addItemMenu() {
|
||||||
QList<QAction*> actions;
|
if (m_addItemMenu == NULL) {
|
||||||
|
m_addItemMenu = new QMenu(title(), NULL);
|
||||||
|
m_addItemMenu->setIcon(icon());
|
||||||
|
m_addItemMenu->setToolTip(description());
|
||||||
|
|
||||||
// TODO: vracet add feed, add category
|
// TODO: Add items.
|
||||||
actions.append(new QAction("abc", NULL));
|
m_addItemMenu->addAction(new QAction("abc", m_addItemMenu));
|
||||||
return actions;
|
}
|
||||||
|
|
||||||
|
return m_addItemMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StandardServiceRoot::assembleCategories(CategoryAssignment categories) {
|
void StandardServiceRoot::assembleCategories(CategoryAssignment categories) {
|
||||||
|
|
|
@ -27,6 +27,7 @@ class StandardRecycleBin;
|
||||||
class StandardCategory;
|
class StandardCategory;
|
||||||
class StandardFeed;
|
class StandardFeed;
|
||||||
class FeedsImportExportModel;
|
class FeedsImportExportModel;
|
||||||
|
class QMenu;
|
||||||
|
|
||||||
typedef QList<QPair<int, StandardCategory*> > CategoryAssignment;
|
typedef QList<QPair<int, StandardCategory*> > CategoryAssignment;
|
||||||
typedef QPair<int, StandardCategory*> CategoryAssignmentItem;
|
typedef QPair<int, StandardCategory*> CategoryAssignmentItem;
|
||||||
|
@ -65,7 +66,7 @@ class StandardServiceRoot : public ServiceRoot {
|
||||||
bool mergeImportExportModel(FeedsImportExportModel *model, QString &output_message);
|
bool mergeImportExportModel(FeedsImportExportModel *model, QString &output_message);
|
||||||
|
|
||||||
// Return "add feed" and "add category" items.
|
// Return "add feed" and "add category" items.
|
||||||
QList<QAction*> specificAddItemActions();
|
QMenu *addItemMenu();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void loadFromDatabase();
|
void loadFromDatabase();
|
||||||
|
@ -76,6 +77,9 @@ class StandardServiceRoot : public ServiceRoot {
|
||||||
void assembleFeeds(FeedAssignment feeds);
|
void assembleFeeds(FeedAssignment feeds);
|
||||||
|
|
||||||
StandardRecycleBin *m_recycleBin;
|
StandardRecycleBin *m_recycleBin;
|
||||||
|
|
||||||
|
// Menus.
|
||||||
|
QMenu *m_addItemMenu;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // STANDARDSERVICEROOT_H
|
#endif // STANDARDSERVICEROOT_H
|
||||||
|
|
Loading…
Add table
Reference in a new issue