}
+GuiWorkArea * GuiView::workArea(int index)
+{
+ if (TabWorkArea * twa = d.currentTabWorkArea())
+ if (index < twa->count())
+ return dynamic_cast<GuiWorkArea *>(twa->widget(index));
+ return 0;
+}
+
+
GuiWorkArea * GuiView::workArea(Buffer & buffer)
{
if (currentWorkArea()
void GuiView::gotoNextOrPreviousBuffer(NextOrPrevious np)
{
- Buffer * const curbuf = documentBufferView()
- ? &documentBufferView()->buffer() : 0;
- Buffer * nextbuf = curbuf;
- while (true) {
- if (np == NEXTBUFFER)
- nextbuf = theBufferList().next(nextbuf);
- else
- nextbuf = theBufferList().previous(nextbuf);
- if (nextbuf == curbuf)
- break;
- if (nextbuf == 0) {
- nextbuf = curbuf;
- break;
+ if (!documentBufferView())
+ return;
+
+ if (TabWorkArea * twa = d.currentTabWorkArea()) {
+ Buffer * const curbuf = &documentBufferView()->buffer();
+ int nwa = twa->count();
+ for (int i = 0; i < nwa; ++i) {
+ if (&workArea(i)->bufferView().buffer() == curbuf) {
+ int next_index;
+ if (np == NEXTBUFFER)
+ next_index = (i == nwa - 1 ? 0 : i + 1);
+ else
+ next_index = (i == 0 ? nwa - 1 : i - 1);
+ setBuffer(&workArea(next_index)->bufferView().buffer());
+ break;
+ }
}
- if (workArea(*nextbuf))
- break;
}
- setBuffer(nextbuf);
}
#include "Action.h"
#include "GuiApplication.h"
#include "GuiView.h"
+#include "GuiWorkArea.h"
#include "qt_helpers.h"
#include "BiblioInfo.h"
item.setSubmenu(MenuDefinition(qt_("Hidden|H")));
Buffer * first = theBufferList().first();
- if (first) {
- Buffer * b = first;
- int vis = 1;
- int invis = 1;
-
- // We cannot use a for loop as the buffer list cycles.
- do {
+ if (!first) {
+ add(MenuItem(MenuItem::Info, qt_("<No Documents Open>")));
+ return;
+ }
+
+ int i = 0;
+ while (true) {
+ GuiWorkArea * wa = guiApp->currentView()->workArea(i);
+ if (!wa)
+ break;
+ Buffer const & b = wa->bufferView().buffer();
+ QString label = toqstr(b.fileName().displayName(20));
+ if (!b.isClean())
+ label += "*";
+ if (i < 10)
+ label = QString::number(i) + ". " + label + '|' + QString::number(i);
+ add(MenuItem(MenuItem::Command, label,
+ FuncRequest(LFUN_BUFFER_SWITCH, b.absFileName())));
+ ++i;
+ }
+
+
+ i = 0;
+ Buffer * b = first;
+ // We cannot use a for loop as the buffer list cycles.
+ do {
+ bool const shown = guiApp->currentView()
+ ? guiApp->currentView()->workArea(*b) : false;
+ if (!shown) {
QString label = toqstr(b->fileName().displayName(20));
if (!b->isClean())
label += "*";
- bool const shown = guiApp->currentView()
- ? guiApp->currentView()->workArea(*b) : false;
- int ii = shown ? vis : invis;
- if (ii < 10)
- label = QString::number(ii) + ". " + label + '|' + QString::number(ii);
- if (shown) {
- add(MenuItem(MenuItem::Command, label,
- FuncRequest(LFUN_BUFFER_SWITCH, b->absFileName())));
- ++vis;
- } else {
- item.submenu().add(MenuItem(MenuItem::Command, label,
- FuncRequest(LFUN_BUFFER_SWITCH, b->absFileName())));
- ++invis;
- }
- b = theBufferList().next(b);
- } while (b != first);
- if (!item.submenu().empty())
- add(item);
- } else
- add(MenuItem(MenuItem::Info, qt_("<No Documents Open>")));
+ if (i < 10)
+ label = QString::number(i) + ". " + label + '|' + QString::number(i);
+ item.submenu().add(MenuItem(MenuItem::Command, label,
+ FuncRequest(LFUN_BUFFER_SWITCH, b->absFileName())));
+ ++i;
+ }
+ b = theBufferList().next(b);
+ } while (b != first);
+
+ if (!item.submenu().empty())
+ add(item);
}