mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-22 16:37:28 +00:00
fix navigate
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5257 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
985ccb6218
commit
f560947a18
@ -1,3 +1,9 @@
|
||||
2002-09-10 John Levon <levon@movementarian.org>
|
||||
|
||||
* Menubar_pimpl.C:
|
||||
* QLPopupMenu.h:
|
||||
* QLPopupMenu.C: finally fix Navigate
|
||||
|
||||
2002-09-10 John Levon <levon@movementarian.org>
|
||||
|
||||
* ui/QIncludeDialog.ui:
|
||||
|
@ -44,7 +44,7 @@ Menubar::Pimpl::Pimpl(LyXView * view, MenuBackend const & mbe)
|
||||
Menu::const_iterator m = mbe.getMenubar().begin();
|
||||
Menu::const_iterator end = mbe.getMenubar().end();
|
||||
for (; m != end; ++m) {
|
||||
createMenu(owner_->menuBar(), &(*m), this);
|
||||
createMenu(owner_->menuBar(), &(*m), this, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,9 @@
|
||||
|
||||
#include "support/lstrings.h"
|
||||
|
||||
using std::pair;
|
||||
using std::make_pair;
|
||||
|
||||
namespace {
|
||||
|
||||
string const getLabel(MenuItem const & mi)
|
||||
@ -39,32 +42,31 @@ string const getLabel(MenuItem const & mi)
|
||||
}
|
||||
|
||||
|
||||
int createMenu(QMenuData * parent, MenuItem const * item, Menubar::Pimpl * owner)
|
||||
pair<int, QLPopupMenu *> createMenu(QMenuData * parent, MenuItem const * item, Menubar::Pimpl * owner, bool is_toplevel)
|
||||
{
|
||||
// FIXME: leaks ??
|
||||
QLPopupMenu * pm = new QLPopupMenu(owner, item->submenuname());
|
||||
return parent->insertItem(getLabel(*item).c_str(), pm);
|
||||
QLPopupMenu * pm = new QLPopupMenu(owner, item->submenuname(), is_toplevel);
|
||||
int id = parent->insertItem(getLabel(*item).c_str(), pm);
|
||||
return make_pair(id, pm);
|
||||
}
|
||||
|
||||
|
||||
QLPopupMenu::QLPopupMenu(Menubar::Pimpl * owner, string const & name)
|
||||
QLPopupMenu::QLPopupMenu(Menubar::Pimpl * owner, string const & name, bool toplevel)
|
||||
: owner_(owner), name_(name)
|
||||
{
|
||||
connect(this, SIGNAL(aboutToShow()), this, SLOT(showing()));
|
||||
if (toplevel)
|
||||
connect(this, SIGNAL(aboutToShow()), this, SLOT(showing()));
|
||||
}
|
||||
|
||||
|
||||
bool QLPopupMenu::disabled(string const & name)
|
||||
bool QLPopupMenu::disabled(Menu * menu)
|
||||
{
|
||||
bool disable = true;
|
||||
|
||||
Menu tomenu;
|
||||
Menu const frommenu = owner_->backend().getMenu(name);
|
||||
owner_->backend().expand(frommenu, tomenu, owner_->view()->buffer());
|
||||
Menu::const_iterator m = tomenu.begin();
|
||||
Menu::const_iterator end = tomenu.end();
|
||||
Menu::const_iterator m = menu->begin();
|
||||
Menu::const_iterator end = menu->end();
|
||||
for (; m != end; ++m) {
|
||||
if (m->kind() == MenuItem::Submenu && !disabled(m->submenuname())) {
|
||||
if (m->kind() == MenuItem::Submenu && !disabled(m->submenu())) {
|
||||
disable = false;
|
||||
} else {
|
||||
FuncStatus const status =
|
||||
@ -77,20 +79,17 @@ bool QLPopupMenu::disabled(string const & name)
|
||||
}
|
||||
|
||||
|
||||
void QLPopupMenu::showing()
|
||||
void QLPopupMenu::populate(Menu * menu)
|
||||
{
|
||||
clear();
|
||||
Menu tomenu;
|
||||
Menu const frommenu = owner_->backend().getMenu(name_);
|
||||
owner_->backend().expand(frommenu, tomenu, owner_->view()->buffer());
|
||||
Menu::const_iterator m = tomenu.begin();
|
||||
Menu::const_iterator end = tomenu.end();
|
||||
Menu::const_iterator m = menu->begin();
|
||||
Menu::const_iterator end = menu->end();
|
||||
for (; m != end; ++m) {
|
||||
if (m->kind() == MenuItem::Separator) {
|
||||
insertSeparator();
|
||||
} else if (m->kind() == MenuItem::Submenu) {
|
||||
int id(createMenu(this, m, owner_));
|
||||
setItemEnabled(id, !disabled(m->submenuname()));
|
||||
pair<int, QLPopupMenu *> res = createMenu(this, m, owner_);
|
||||
setItemEnabled(res.first, !disabled(m->submenu()));
|
||||
res.second->populate(m->submenu());
|
||||
} else {
|
||||
FuncStatus const status =
|
||||
owner_->view()->getLyXFunc().getStatus(m->action());
|
||||
@ -102,3 +101,13 @@ void QLPopupMenu::showing()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void QLPopupMenu::showing()
|
||||
{
|
||||
clear();
|
||||
Menu tomenu;
|
||||
Menu const frommenu = owner_->backend().getMenu(name_);
|
||||
owner_->backend().expand(frommenu, tomenu, owner_->view()->buffer());
|
||||
populate(&tomenu);
|
||||
}
|
||||
|
@ -16,26 +16,31 @@
|
||||
#include "LString.h"
|
||||
|
||||
class MenuBackend;
|
||||
class QtView;
|
||||
class MenuItem;
|
||||
class Menu;
|
||||
class QMenuData;
|
||||
class QLPopupMenu;
|
||||
|
||||
/// create a sub-menu
|
||||
int createMenu(QMenuData * parent, MenuItem const * item, Menubar::Pimpl * owner);
|
||||
std::pair<int, QLPopupMenu *>
|
||||
createMenu(QMenuData * parent, MenuItem const * item, Menubar::Pimpl * owner, bool is_toplevel = false);
|
||||
|
||||
/// a submenu
|
||||
class QLPopupMenu : public QPopupMenu {
|
||||
Q_OBJECT
|
||||
public:
|
||||
QLPopupMenu(Menubar::Pimpl * owner, string const & name);
|
||||
QLPopupMenu(Menubar::Pimpl * owner, string const & name, bool toplevel);
|
||||
|
||||
/// populate the menu
|
||||
void populate(Menu * menu);
|
||||
|
||||
public slots:
|
||||
/// populate the menu
|
||||
/// populate the toplevel menu and all children
|
||||
void showing();
|
||||
|
||||
private:
|
||||
/// return true if the given submenu is disabled
|
||||
bool disabled(string const & name);
|
||||
bool disabled(Menu * menu);
|
||||
|
||||
/// our owning menubar
|
||||
Menubar::Pimpl * owner_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user