From 57498fc64322a90469c465959366056491b0c23e Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Sun, 4 Feb 2007 21:19:20 +0000 Subject: [PATCH] * GuiView.C (setGeometry): whitespace and warning. (updateTab,currentTabChanged): simplify code further. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17044 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiView.C | 60 ++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 34 deletions(-) diff --git a/src/frontends/qt4/GuiView.C b/src/frontends/qt4/GuiView.C index 2b96abdf0e..732cf483a0 100644 --- a/src/frontends/qt4/GuiView.C +++ b/src/frontends/qt4/GuiView.C @@ -107,8 +107,7 @@ public: struct GuiView::GuiViewPrivate { - typedef std::map FuncMap; - FuncMap funcmap; + std::vector tabnames; TabWidget* tabWidget; @@ -308,11 +307,11 @@ void GuiView::saveGeometry() void GuiView::setGeometry(unsigned int width, - unsigned int height, - int posx, int posy, - bool maximize, - unsigned int iconSizeXY, - const std::string & geometryArg) + unsigned int height, + int posx, int posy, + bool maximize, + unsigned int iconSizeXY, + const string & geometryArg) { // use last value (not at startup) if (d.lastIconSize != 0) @@ -353,12 +352,15 @@ void GuiView::setGeometry(unsigned int width, int x, y; int w, h; QRegExp re( "[=]*(?:([0-9]+)[xX]([0-9]+)){0,1}[ ]*(?:([+-][0-9]*)([+-][0-9]*)){0,1}" ); - re.indexIn( toqstr(geometryArg.c_str())); - w = re.cap( 1 ).toInt(); - h = re.cap( 2 ).toInt(); - x = re.cap( 3 ).toInt(); - y = re.cap( 4 ).toInt(); + re.indexIn(toqstr(geometryArg.c_str())); + w = re.cap(1).toInt(); + h = re.cap(2).toInt(); + x = re.cap(3).toInt(); + y = re.cap(4).toInt(); QWidget::setGeometry( x, y, w, h ); +#else + // silence warning + (void)geometryArg; #endif } @@ -479,24 +481,21 @@ void GuiView::initTab(QWidget* workarea) void GuiView::updateTab() { - static std::vector oldnames; - std::vector const& names = theBufferList().getFileNames(); + std::vector const & names = theBufferList().getFileNames(); // avoid unnecessary tabbar rebuild: // check if something has changed - if (oldnames == names) + if (d.tabnames == names) return; - else - oldnames = names; + d.tabnames = names; - QTabBar& tabbar = *d.tabWidget->tabbar; + QTabBar & tabbar = *d.tabWidget->tabbar; - // update when all is done + // update when all is done tabbar.blockSignals(true); - // remove all tab bars and clear the function map + // remove all tab bars d.tabWidget->clearTabbar(); - d.funcmap.clear(); string cur_title; if (view()->buffer()) { @@ -504,29 +503,22 @@ void GuiView::updateTab() } // rebuild tabbar and function map from scratch - if (names.size() == 1) { - d.funcmap.insert(std::pair - (0, FuncRequest(LFUN_BUFFER_SWITCH, names[0]))); - } else { + if (names.size() > 1) { for(size_t i = 0; i < names.size(); i++) { - tabbar.addTab(lyx::toqstr(onlyFilename(names[i]))); - d.funcmap.insert(std::pair - (i, FuncRequest(LFUN_BUFFER_SWITCH, names[i]))); + tabbar.addTab(toqstr(onlyFilename(names[i]))); // set current tab - if (names[i] == cur_title) { + if (names[i] == cur_title) tabbar.setCurrentIndex(i); - } } } tabbar.blockSignals(false); } -void GuiView::currentTabChanged (int index) +void GuiView::currentTabChanged(int i) { - std::map::const_iterator it = d.funcmap.find(index); - if (it != d.funcmap.end()) - activated(it->second); + BOOST_ASSERT(i >= 0 && size_type(i) < d.tabnames.size()); + dispatch(FuncRequest(LFUN_BUFFER_SWITCH, d.tabnames[i])); } -- 2.39.2