OSDN Git Service

タブの順番入れ替え機能を追加。
authoryuki <kimaira7@gmail.com>
Wed, 27 Mar 2013 07:08:51 +0000 (16:08 +0900)
committeryuki <kimaira7@gmail.com>
Wed, 27 Mar 2013 07:08:51 +0000 (16:08 +0900)
src/cx/fbn/nevernote/NeverNote.java
src/cx/fbn/nevernote/gui/TabBrowserWidget.java

index 5dcc60b..87004c4 100644 (file)
@@ -597,6 +597,7 @@ public class NeverNote extends QMainWindow{
                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, "");
@@ -7671,4 +7672,37 @@ public class NeverNote extends QMainWindow{
        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);
+       }
 }
index bc920bb..ff635f3 100644 (file)
@@ -4,13 +4,18 @@ package cx.fbn.nevernote.gui;
 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){