tabWindows = new HashMap<Integer, TabBrowse>();
tabBrowser = new TabBrowserWidget(this);
tabBrowser.setStyleSheet("QTabBar::tab{width:150px;}");
+ tabBrowser.setMovable(true);
TabBrowse tab = new TabBrowse(conn, tabBrowser, cbObserver);
browserWindow = tab.getBrowserWindow();
int index = tabBrowser.addNewTab(tab, "");
public String getCurrentNoteGuid() {
return currentNoteGuid;
}
+
+ @SuppressWarnings("unused")
+ // タブ入れ替えによってタブインデックスが変わったので、インデックスで管理しているハッシュマップ達も入れ替える
+ private void tabIndexChanged(int from, int to) {
+ // tabWindows
+ TabBrowse tab = tabWindows.get(from);
+ tabWindows.put(from, tabWindows.get(to));
+ tabWindows.put(to, tab);
+ // noteDirty
+ boolean isNoteDirty = noteDirty.get(from);
+ noteDirty.put(from, noteDirty.get(to));
+ noteDirty.put(to, isNoteDirty);
+ // inkNote
+ boolean isInkNote = inkNote.get(from);
+ inkNote.put(from, inkNote.get(to));
+ inkNote.put(to, isInkNote);
+ // readOnly
+ boolean isReadOnly = readOnly.get(from);
+ readOnly.put(from, readOnly.get(to));
+ readOnly.put(to, isReadOnly);
+ // historyGuids
+ ArrayList<String> histGuids = historyGuids.get(from);
+ historyGuids.put(from, historyGuids.get(to));
+ historyGuids.put(to, histGuids);
+ // historyPosition
+ int histPosition = historyPosition.get(from);
+ historyPosition.put(from, historyPosition.get(to));
+ historyPosition.put(to, histPosition);
+ // fromHistory
+ boolean fromHist = fromHistory.get(from);
+ fromHistory.put(from, fromHistory.get(to));
+ fromHistory.put(to, fromHist);
+ }
}
import com.trolltech.qt.gui.QTabWidget;
import com.trolltech.qt.gui.QWidget;
+import cx.fbn.nevernote.NeverNote;
+
public class TabBrowserWidget extends QTabWidget {
- TabBrowserBar bar;
+ private final TabBrowserBar bar;
+ private final NeverNote parent;
- public TabBrowserWidget(QWidget parent) {
+ public TabBrowserWidget(NeverNote parent) {
super(parent);
+ this.parent = parent;
bar = new TabBrowserBar();
this.setTabBar(bar);
+ bar.tabMoved.connect(parent, "tabIndexChanged(int, int)");
}
public int addNewTab(QWidget widget, String title){