/*
- * This file is part of NixNote
+ * This file is part of NixNote/NeighborNote
* Copyright 2009 Randy Baumgarte
+ * Copyright 2013 Yuki Takahashi
*
* This file may be licensed under the terms of of the
* GNU General Public License Version 2 (the ``GPL'').
import com.trolltech.qt.core.QSize;
import com.trolltech.qt.core.QTemporaryFile;
import com.trolltech.qt.core.QTextCodec;
+import com.trolltech.qt.core.QTextStream;
import com.trolltech.qt.core.QThreadPool;
import com.trolltech.qt.core.QTimer;
import com.trolltech.qt.core.QTranslator;
NoteFilter filter; // Note filter
String currentNoteGuid; // GUID of the current note
Note currentNote; // The currently viewed note
- boolean noteDirty; // Has the note been changed?
- boolean inkNote; // if this is an ink note, it is read only
- boolean readOnly; // Is this note read-only?
+ // ICHANGED
+ HashMap<Integer, Boolean> noteDirty; // Has the note been changed?
+ HashMap<Integer, Boolean> inkNote; // if this is an ink note, it is read only
+ HashMap<Integer, Boolean> readOnly; // Is this note read-only?
ListManager listManager; // DB runnable task
logger.log(logger.EXTREME, "Starting GUI build");
QTranslator nevernoteTranslator = new QTranslator();
- nevernoteTranslator.load(Global.getFileManager().getTranslateFilePath("nevernote_" + QLocale.system().name() + ".qm"));
+ nevernoteTranslator.load(Global.getFileManager().getTranslateFilePath("neighbornote_" + QLocale.system().name() + ".qm"));
QApplication.instance().installTranslator(nevernoteTranslator);
Global.originalPalette = QApplication.palette();
indexThread = new QThread(indexRunner, "Index Thread");
indexRunner.indexAttachmentsLocally = Global.indexAttachmentsLocally();
indexRunner.indexImageRecognition = Global.indexImageRecognition();
- indexRunner.indexNoteBody = Global.indexNoteBody();
- indexRunner.indexNoteTitle = Global.indexNoteTitle();
+// indexRunner.indexNoteBody = Global.indexNoteBody();
+// indexRunner.indexNoteTitle = Global.indexNoteTitle();
indexRunner.specialIndexCharacters = Global.getSpecialIndexCharacters();
indexThread.start();
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, "");
tabBrowser.setTabsClosable(true);
tabBrowser.currentChanged.connect(this, "tabWindowChanged(int)");
tabBrowser.tabCloseRequested.connect(this, "tabWindowClosing(int)");
+
+ noteDirty = new HashMap<Integer, Boolean>();
+ noteDirty.put(index, false);
+
+ inkNote = new HashMap<Integer, Boolean>();
+ readOnly = new HashMap<Integer, Boolean>();
// ICHANGED
// 履歴記録のハッシュマップを初期化
noteTableView.setVisible(Global.isWindowVisible("noteList"));
menuBar.hideNoteList.setChecked(Global.isWindowVisible("noteList"));
- if (!Global.isWindowVisible("editorButtonBar"))
+ // ICHANGED
+ if (!Global.isWindowVisible("editorButtonBar")) {
+ menuBar.showEditorBar.setChecked(false);
toggleEditorButtonBar();
+ }
if (!Global.isWindowVisible("leftPanel"))
menuBar.hideLeftSide.setChecked(true);
- if (Global.isWindowVisible("noteInformation"))
+
+ // ICHANGED
+ if (Global.isWindowVisible("noteInformation")) {
+ menuBar.noteAttributes.setChecked(true);
toggleNoteInformation();
+ }
+
quotaBar.setVisible(Global.isWindowVisible("quota"));
// IFIXED quotaBar.isVisible() → Global.isWindowVisible("quota")
// なぜかquotaBar.isVisible()が常にfalseを返すようなので修正
fromHistory = false;
*/
- noteDirty = false;
if (!currentNoteGuid.trim().equals("")) {
currentNote = conn.getNoteTable().getNote(currentNoteGuid, true,true,false,false,true);
}
}
if (Global.checkVersionUpgrade()) {
- // ICHANGED TODO とりあえず封印
- // checkForUpdates();
+ checkForUpdates();
+ }
+
+ // ICHANGED
+ if (currentNoteGuid == null || currentNoteGuid.equals("")) {
+ menuBar.noteAddNewTab.setEnabled(false);
}
}
saveNoteColumnPositions();
saveNoteIndexWidth();
showColumns();
- ConfigDialog settings = new ConfigDialog(this);
+ ConfigDialog settings = new ConfigDialog(this, conn);
String dateFormat = Global.getDateFormat();
String timeFormat = Global.getTimeFormat();
settings.exec();
indexRunner.indexAttachmentsLocally = Global.indexAttachmentsLocally();
- indexRunner.indexNoteBody = Global.indexNoteBody();
- indexRunner.indexNoteTitle = Global.indexNoteTitle();
+// indexRunner.indexNoteBody = Global.indexNoteBody();
+// indexRunner.indexNoteTitle = Global.indexNoteTitle();
indexRunner.specialIndexCharacters = Global.getSpecialIndexCharacters();
indexRunner.indexImageRecognition = Global.indexImageRecognition();
if (Global.showTrayIcon() || Global.minimizeOnClose())
}
}
browserWindow.setTag(names.toString());
- noteDirty = true;
+
+ // ICHANGED
+ for (TabBrowse tab: tabWindows.values()) {
+ if (tab.getBrowserWindow().getNote().getGuid().equals(guid)) {
+ int index = tabBrowser.indexOf(tab);
+ noteDirty.put(index, true);
+ break;
+ }
+ }
// Now, we need to add any new tags to the tag tree
for (int i=0; i<newTags.size(); i++)
status.setTagCount(listManager.getTagIndex().size());
status.setResourceCount(conn.getNoteTable().noteResourceTable.getResourceCount());
status.setWordCount(conn.getWordsTable().getWordCount());
+ status.setHistoryCount(conn.getHistoryTable().getHistoryCount());
waitCursor(false);
status.exec();
}
if (!file.open(new QIODevice.OpenMode(QIODevice.OpenModeFlag.ReadOnly,
QIODevice.OpenModeFlag.Text)))
return;
- textBox.setText(file.readAll().toString());
+ // ICHANGED 日本語文字化け対策
+ QTextCodec codec = QTextCodec.codecForName("UTF-8");
+ QTextStream textStream = new QTextStream(file);
+ textStream.setCodec(codec);
+ textBox.setText(textStream.readAll().toString());
+
file.close();
dialog.setWindowTitle(tr("Release Notes"));
dialog.setLayout(layout);
Global.showDeleted = true;
}
+
+ menuBar.noteAddNewTab.setEnabled(newButton.isEnabled());
+ if (currentNoteGuid == null || currentNoteGuid.equals("")) {
+ menuBar.noteAddNewTab.setEnabled(false);
+ }
+
listManager.loadNotesIndex();
noteIndexUpdated(false);
//// browserWindow.setEnabled(newButton.isEnabled());
listManager.setSelectedSavedSearch("");
newButton.setEnabled(!newButton.isEnabled());
menuBar.noteAdd.setEnabled(newButton.isEnabled());
+ menuBar.noteAddNewTab.setEnabled(newButton.isEnabled());
+ if (currentNoteGuid == null || currentNoteGuid.equals("")) {
+ menuBar.noteAddNewTab.setEnabled(false);
+ }
menuBar.noteAdd.setVisible(true);
browserWindow.clear();
Global.showDeleted = false;
newButton.setEnabled(true);
menuBar.noteAdd.setEnabled(true);
+ if (currentNoteGuid == null || currentNoteGuid.equals("")) {
+ menuBar.noteAddNewTab.setEnabled(false);
+ } else {
+ menuBar.noteAddNewTab.setEnabled(true);
+ }
menuBar.noteAdd.setVisible(true);
trashTree.blockSignals(true);
trashTree.clearSelection();
menuBar.noteOnlineHistoryAction.setEnabled(true);
menuBar.noteMergeAction.setEnabled(true);
selectedNoteGUIDs.clear();
+ if (currentNoteGuid != null && !currentNoteGuid.equals("") && !Global.showDeleted) {
+ menuBar.noteAddNewTab.setEnabled(true);
+ }
if (selections.size() != 1 || Global.showDeleted) {
menuBar.noteDuplicateAction.setEnabled(false);
}
TabBrowse newBrowser = new TabBrowse(conn, tabBrowser, cbObserver);
showEditorButtons(newBrowser.getBrowserWindow());
+ String noteTitle = note.getTitle();
+ int index = tabBrowser.addNewTab(newBrowser, noteTitle);
+ tabWindows.put(index, newBrowser);
+ noteDirty.put(index, false);
+
// noteTableViewの選択を変更するとselectionChangedが発生してしまうので一度切断
noteTableView.selectionModel().selectionChanged.disconnect(this, "noteTableSelection()");
loadNoteBrowserInformation(newBrowser.getBrowserWindow(), guid, note);
setupBrowserWindowListeners(newBrowser.getBrowserWindow(), false);
- String noteTitle = note.getTitle();
- int index = tabBrowser.addNewTab(newBrowser, noteTitle);
- tabWindows.put(index, newBrowser);
-
// ExtendedInformationを必要があれば表示する
toggleNoteInformation();
// Sourceを必要があれば表示する
// ノートを削除
tabWindows.remove(index);
tabBrowser.removeTab(index);
+ noteDirty.remove(index);
+ inkNote.remove(index);
+ readOnly.remove(index);
// 履歴記録のハッシュマップを削除
historyGuids.remove(index);
TabBrowse tab = tabWindows.get(i + 1);
tabWindows.put(i, tab);
tabWindows.remove(i + 1);
+ // noteDirty
+ boolean isNoteDirty = noteDirty.get(i + 1);
+ noteDirty.put(i, isNoteDirty);
+ noteDirty.remove(i + 1);
+ // inkNote
+ boolean isInkNote = inkNote.get(i + 1);
+ inkNote.put(i, isInkNote);
+ inkNote.remove(i + 1);
+ // readOnly
+ boolean isReadOnly = readOnly.get(i + 1);
+ readOnly.put(i, isReadOnly);
+ readOnly.remove(i + 1);
// historyGuids
ArrayList<String> histGuids = historyGuids.get(i + 1);
historyGuids.put(i, histGuids);
// ノート追加前に開いていたノートとの関連性を記録するためにguidをとっておく
TabBrowse prevTab = (TabBrowse)tabBrowser.currentWidget();
- String prevTabGuid = prevTab.getBrowserWindow().getNote().getGuid();
+ String prevTabGuid = null;
+ if (prevTab.getBrowserWindow() != null && prevTab.getBrowserWindow().getNote() != null) {
+ prevTabGuid = prevTab.getBrowserWindow().getNote().getGuid();
+ }
openEmptyTabEditor();
addNote();
// 追加されたノートのguidを取得し、ノート追加操作履歴としてデータベースに登録
- TabBrowse addedTab = (TabBrowse)tabBrowser.currentWidget();
- String addedTabGuid = addedTab.getBrowserWindow().getNote().getGuid();
if (prevTabGuid != null && !prevTabGuid.equals("")) {
+ TabBrowse addedTab = (TabBrowse)tabBrowser.currentWidget();
+ String addedTabGuid = addedTab.getBrowserWindow().getNote().getGuid();
if (addedTabGuid != null && !addedTabGuid.equals("")) {
if (!prevTabGuid.equals(addedTabGuid)) {
conn.getHistoryTable().addHistory("addNewNote", prevTabGuid, addedTabGuid);
int index = tabBrowser.addNewTab(newBrowser, "");
tabWindows.put(index, newBrowser);
+ noteDirty.put(index, false);
// ExtendedInformationを必要があれば表示する
toggleNoteInformation();
//** These functions deal with Note specific things
//***************************************************************
//***************************************************************
+ // ICHANGED
private void setNoteDirty() {
+ for (String guid: selectedNoteGUIDs) {
+ setNoteDirty(guid);
+ }
+ }
+
+ // ICHANGED
+ private void setNoteDirty(String targetGuid) {
logger.log(logger.EXTREME, "Entering NeverNote.setNoteDirty()");
// Find if the note is being edited externally. If it is, update it.
- if (externalWindows.containsKey(currentNoteGuid)) {
+ if (externalWindows.containsKey(targetGuid)) {
QTextCodec codec = QTextCodec.codecForName("UTF-8");
QByteArray unicode = codec.fromUnicode(browserWindow.getContent());
- ExternalBrowse window = externalWindows.get(currentNoteGuid);
+ ExternalBrowse window = externalWindows.get(targetGuid);
window.getBrowserWindow().setContent(unicode);
}
- // ICHANGED ↓↓↓ここから↓↓↓
// 他のタブで同じノートを開いていないか探す。もしあったら、内容を更新する。
- Collection<TabBrowse> tabBrowsers = tabWindows.values();
- Iterator<TabBrowse> tabIterator = tabBrowsers.iterator();
Collection<Integer> tabIndexes = tabWindows.keySet();
Iterator<Integer> indexIterator = tabIndexes.iterator();
- while (tabIterator.hasNext()) {
- TabBrowse tab = tabIterator.next();
+ for (TabBrowse tab: tabWindows.values()) {
int index = indexIterator.next();
String guid = tab.getBrowserWindow().getNote().getGuid();
QTextCodec codec = QTextCodec.codecForName("UTF-8");
QByteArray unicode = codec.fromUnicode(browserWindow.getContent());
- if (guid.equals(currentNoteGuid)) {
+ if (guid.equals(guid)) {
if (index != tabBrowser.currentIndex()) {
TabBrowse window = tabWindows.get(index);
window.getBrowserWindow().setContent(unicode);
}
}
}
- // ICHANGED ↑↑↑ここまで↑↑↑
+ // ターゲットノートがタブで開かれていて、かつDirty = trueかどうかを取得する
// If the note is dirty, then it is unsynchronized by default.
- if (noteDirty)
+ int index = -1;
+ boolean isNoteDirty = false;
+ for (TabBrowse tab: tabWindows.values()) {
+ if (tab.getBrowserWindow().getNote().getGuid().equals(targetGuid)) {
+ index = tabBrowser.indexOf(tab);
+ isNoteDirty = noteDirty.get(index);
+ break;
+ }
+ }
+ if (isNoteDirty) {
return;
+ }
// Set the note as dirty and check if its status is synchronized in the display table
- noteDirty = true;
- if (listManager.getNoteMetadata().containsKey(currentNoteGuid) &&
- listManager.getNoteMetadata().get(currentNoteGuid).isDirty()) {
+ // まだダーティでなく、かつタブで開かれている場合にnoteDirty = trueにする
+ if (index >= 0) {
+ noteDirty.put(index, true);
+ }
+
+ if (listManager.getNoteMetadata().containsKey(targetGuid) &&
+ listManager.getNoteMetadata().get(targetGuid).isDirty()) {
return;
}
// If this wasn't already marked as unsynchronized, then we need to update the table
- listManager.getNoteTableModel().updateNoteSyncStatus(currentNoteGuid, false);
-// listManager.getUnsynchronizedNotes().add(currentNoteGuid);
+ listManager.getNoteTableModel().updateNoteSyncStatus(targetGuid, false);
+// listManager.getUnsynchronizedNotes().add(targetGuid);
for (int i=0; i<listManager.getNoteTableModel().rowCount(); i++) {
QModelIndex modelIndex = listManager.getNoteTableModel().index(i, Global.noteTableGuidPosition);
if (modelIndex != null) {
SortedMap<Integer, Object> ix = listManager.getNoteTableModel().itemData(modelIndex);
String tableGuid = (String)ix.values().toArray()[0];
- if (tableGuid.equals(currentNoteGuid)) {
+ if (tableGuid.equals(targetGuid)) {
listManager.getNoteTableModel().proxyModel.setData(i, Global.noteTableSynchronizedPosition, "false");
return;
}
noteCache.remove(guid);
noteCache.put(guid, unicode.toString());
if (guid.equals(currentNoteGuid)) {
- noteDirty = true;
+ // ICHANGED
+ int index = tabBrowser.currentIndex();
+ noteDirty.put(index, true);
browserWindow.setContent(unicode);
}
if (save) {
}
private void saveNote() {
- if (noteDirty) {
- saveNote(currentNoteGuid, browserWindow);
- thumbnailRunner.addWork("GENERATE "+ currentNoteGuid);
- noteDirty = false;
- }
+ // ICHANGED
+ // すべてのタブに対して、Dirtyを確認し、trueならセーブする
+ Collection<Integer> dirtyIndex = noteDirty.keySet();
+ Iterator<Integer> indexIterator = dirtyIndex.iterator();
+ for (boolean isNoteDirty: noteDirty.values()) {
+ int index = indexIterator.next();
+ if (isNoteDirty) {
+ if (index < 0) {
+ return;
+ }
+ BrowserWindow b = tabWindows.get(index).getBrowserWindow();
+ String guid = b.getNote().getGuid();
+ saveNote(guid, b);
+ thumbnailRunner.addWork("GENERATE "+ guid);
+ noteDirty.put(index, false);
+ }
+ }
}
private void saveNote(String guid, BrowserWindow window) {
logger.log(logger.EXTREME, "Inside NeverNote.saveNote()");
browserWindow.setEnabled(false);
return;
}
- inkNote = false;
- readOnly = false;
- if (Global.showDeleted || currentNoteGuid == null || currentNoteGuid.equals(""))
- readOnly = true;
+ // ICHANGED
+ inkNote.put(tabBrowser.currentIndex(), false);
+ readOnly.put(tabBrowser.currentIndex(), false);
+
+ if (Global.showDeleted || currentNoteGuid == null || currentNoteGuid.equals("")) {
+ readOnly.put(tabBrowser.currentIndex(), true);
+ }
Global.cryptCounter =0;
- if (readOnly) {
+ if (readOnly.get(tabBrowser.currentIndex())) {
browserWindow.setReadOnly(true);
}
loadNoteBrowserInformation(browserWindow, currentNoteGuid, currentNote);
}
+ // ICHANGED
private void loadNoteBrowserInformation(BrowserWindow browser, String guid, Note note) {
NoteFormatter formatter = new NoteFormatter(logger, conn, tempFiles);
formatter.setNote(note, Global.pdfPreview());
formatter.setHighlight(listManager.getEnSearch());
QByteArray js;
+ int tabIndex = -1;
+
+ // 対象のタブインデックスを取得
+ for (TabBrowse tab: tabWindows.values()) {
+ if (tab.getBrowserWindow() == browser) {
+ tabIndex = tabBrowser.indexOf(tab);
+ break;
+ }
+ }
+
if (!noteCache.containsKey(guid)) {
js = new QByteArray();
// We need to prepend the note with <HEAD></HEAD> or encoded characters are ugly
noteCache.put(guid, js.toString());
if (formatter.resourceError)
- resourceErrorMessage();
+ resourceErrorMessage(tabIndex);
if (formatter.formatError) {
waitCursor(false);
QMessageBox.information(this, tr("Error"),
" To protect your data this note is being marked as read-only."));
waitCursor(true);
}
- readOnly = formatter.readOnly;
- inkNote = formatter.inkNote;
- if (readOnly)
+
+ if (tabIndex >= 0) {
+ readOnly.put(tabIndex, formatter.readOnly);
+ inkNote.put(tabIndex, formatter.inkNote);
+ }
+
+ if (tabIndex >= 0 && readOnly.get(tabIndex)) {
readOnlyCache.put(guid, true);
- if (inkNote)
+ }
+ if (tabIndex >= 0 && inkNote.get(tabIndex)) {
inkNoteCache.put(guid, true);
+ }
+
} else {
logger.log(logger.HIGH, "Note content is being pulled from the cache");
String cachedContent = formatter.modifyCachedTodoTags(noteCache.get(guid));
js = new QByteArray(cachedContent);
browser.setContent(js);
- if (readOnlyCache.containsKey(guid))
- readOnly = true;
- if (inkNoteCache.containsKey(guid))
- inkNote = true;
+ if (readOnlyCache.containsKey(guid) && tabIndex >= 0) {
+ readOnly.put(tabIndex, true);
+ } else {
+ readOnly.put(tabIndex, false);
+ }
+ if (inkNoteCache.containsKey(guid) && tabIndex >= 0) {
+ inkNote.put(tabIndex, true);
+ } else {
+ inkNote.put(tabIndex, false);
+ }
}
if (conn.getNoteTable().isThumbnailNeeded(guid)) {
thumbnailHTMLReady(guid, js, Global.calculateThumbnailZoom(js.toString()));
}
- if (readOnly || inkNote ||
- (note.getAttributes() != null && note.getAttributes().getContentClass() != null && note.getAttributes().getContentClass() != ""))
+ if (tabIndex >= 0 && (readOnly.get(tabIndex) || inkNote.get(tabIndex) ||
+ (note.getAttributes() != null && note.getAttributes().getContentClass() != null && note.getAttributes().getContentClass() != "")))
browser.getBrowser().page().setContentEditable(false); // We don't allow editing of ink notes
else
browser.getBrowser().page().setContentEditable(true);
- browser.setReadOnly(readOnly);
- deleteButton.setEnabled(!readOnly);
- tagButton.setEnabled(!readOnly);
- menuBar.noteDelete.setEnabled(!readOnly);
- menuBar.noteTags.setEnabled(!readOnly);
+ if (tabIndex >= 0) {
+ browser.setReadOnly(readOnly.get(tabIndex));
+ deleteButton.setEnabled(!readOnly.get(tabIndex));
+ tagButton.setEnabled(!readOnly.get(tabIndex));
+ menuBar.noteDelete.setEnabled(!readOnly.get(tabIndex));
+ menuBar.noteTags.setEnabled(!readOnly.get(tabIndex));
+ }
browser.setNote(note);
if (note != null && note.getNotebookGuid() != null &&
browser.setAllTags(tagList);
browser.setCurrentTags(note.getTagNames());
- noteDirty = false;
+ // ICHANGED
+ for (TabBrowse tab: tabWindows.values()) {
+ if (tab.getBrowserWindow().getNote().getGuid().equals(guid)) {
+ int index = tabBrowser.indexOf(tab);
+ noteDirty.put(index, false);
+ break;
+ }
+ }
+
scrollToGuid(guid);
browser.loadingData(false);
}
if (selectedNoteGUIDs.size() == 0 && !currentNoteGuid.equals(""))
selectedNoteGUIDs.add(currentNoteGuid);
+ closeTabs(selectedNoteGUIDs);
for (int i=0; i<selectedNoteGUIDs.size(); i++) {
listManager.deleteNote(selectedNoteGUIDs.get(i));
}
}
}
}
+ closeTabs(selectedNoteGUIDs);
listManager.expungeNote(selectedNoteGUIDs.get(i));
// ICHANGED
}
}
currentNoteGuid = "";
-
- // ICHANGED ↓↓↓ここから↓↓↓
- // 削除したノートを外部ウィンドウで開いていたら、閉じる
- Collection<ExternalBrowse> windows = externalWindows.values();
- Iterator<ExternalBrowse> windowIterator = windows.iterator();
- Collection<String> guids = externalWindows.keySet();
- Iterator<String> guidIterator = guids.iterator();
- List<ExternalBrowse> closeWindows = new ArrayList<ExternalBrowse>(); // イテレータ操作中に中身をいじっちゃダメなので
-
- while (windowIterator.hasNext()) {
- ExternalBrowse browser = windowIterator.next();
- String guid = guidIterator.next();
-
- for (int i = 0; i < selectedNoteGUIDs.size(); i++) {
- if (guid.equals(selectedNoteGUIDs.get(i))) {
- closeWindows.add(browser);
- }
- }
- }
-
- for (int i = closeWindows.size() - 1; i >= 0; i--) {
- closeWindows.get(i).close();
+ closeExternalWindows(selectedNoteGUIDs);
+ if (currentNoteGuid == null || currentNoteGuid.equals("")) {
+ menuBar.noteAddNewTab.setEnabled(false);
}
- // ICHANGED ↑↑↑ここまで↑↑↑
- // ICHANGED ↓↓↓ここから↓↓↓
- // 削除したノートをタブで開いていたら、閉じる
+ listManager.loadNotesIndex();
+ noteIndexUpdated(false);
+ refreshEvernoteNote(true);
+ scrollToGuid(currentNoteGuid);
+ logger.log(logger.HIGH, "Leaving NeverNote.deleteNote");
+ }
+
+ // 対象ノートをタブで開いていたら閉じる
+ private void closeTabs(List<String> noteGUIDs) {
Collection<TabBrowse> tabBrowsers = tabWindows.values();
Iterator<TabBrowse> tabIterator = tabBrowsers.iterator();
Collection<Integer> tabIndexes = tabWindows.keySet();
int index = indexIterator.next();
String guid = tab.getBrowserWindow().getNote().getGuid();
- for(int i = 0; i < selectedNoteGUIDs.size(); i++){
- if(guid.equals(selectedNoteGUIDs.get(i))){
+ for(int i = 0; i < noteGUIDs.size(); i++){
+ if(guid.equals(noteGUIDs.get(i))){
closeIndexes.add(index);
}
}
for(int i = closeIndexes.size() - 1; i >= 0; i--){
tabWindowClosing(closeIndexes.get(i));
}
- // ICHANGED ↑↑↑ここまで↑↑↑
-
- listManager.loadNotesIndex();
- noteIndexUpdated(false);
- refreshEvernoteNote(true);
- scrollToGuid(currentNoteGuid);
- logger.log(logger.HIGH, "Leaving NeverNote.deleteNote");
}
+
+ // 対象ノートを外部ウィンドウで開いていたら閉じる
+ private void closeExternalWindows(List<String> noteGUIDs) {
+ Collection<ExternalBrowse> windows = externalWindows.values();
+ Iterator<ExternalBrowse> windowIterator = windows.iterator();
+ Collection<String> guids = externalWindows.keySet();
+ Iterator<String> guidIterator = guids.iterator();
+ List<ExternalBrowse> closeWindows = new ArrayList<ExternalBrowse>(); // イテレータ操作中に中身をいじっちゃダメなので
+
+ while (windowIterator.hasNext()) {
+ ExternalBrowse browser = windowIterator.next();
+ String guid = guidIterator.next();
+
+ for (int i = 0; i < noteGUIDs.size(); i++) {
+ if (guid.equals(noteGUIDs.get(i))) {
+ closeWindows.add(browser);
+ }
+ }
+ }
+
+ for (int i = closeWindows.size() - 1; i >= 0; i--) {
+ closeWindows.get(i).close();
+ }
+ }
+
// Add a new note
- // ICHANGED @SuppressWarnings("unused") を削除
private void addNote() {
logger.log(logger.HIGH, "Inside NeverNote.addNote");
// browserWindow.setEnabled(true);
// IFIXED こいつのせいで、ノート追加時にcurrentNoteGuidが更新されないので消す
// noteTableView.clearSelection();
- refreshEvernoteNote(true);
- listManager.countNotebookResults(listManager.getNoteIndex());
- browserWindow.titleLabel.setFocus();
- browserWindow.titleLabel.selectAll();
-// notebookTree.updateCounts(listManager.getNotebookIndex(), listManager.getNotebookCounter());
-
// ICHANGED 新規に作成したノートとそれまで開いていたノートの関連性を追加
if (prevCurrentNoteGuid != null && !prevCurrentNoteGuid.equals("")) {
if (currentNoteGuid != null && !currentNoteGuid.equals("")) {
}
}
+ refreshEvernoteNote(true);
+ listManager.countNotebookResults(listManager.getNoteIndex());
+ browserWindow.titleLabel.setFocus();
+ browserWindow.titleLabel.selectAll();
+// notebookTree.updateCounts(listManager.getNotebookIndex(), listManager.getNotebookCounter());
+
// If the window is hidden, then we want to popup this in an external window &
if (!isVisible())
listDoubleClick();
// ICHANGED
for(int i = 0; i < tabBrowser.count(); i++){
TabBrowse b = (TabBrowse)tabBrowser.widget(i);
- b.getBrowserWindow().getNote().setGuid(newGuid);
+ if (b.getBrowserWindow().getNote().getGuid().equals(oldGuid)) {
+ b.getBrowserWindow().getNote().setGuid(newGuid);
+ }
}
for (int i=0; i<listManager.getNoteIndex().size(); i++) {
//**********************************************************
//**********************************************************
// An error has happended fetching a resource. let the user know
- private void resourceErrorMessage() {
- if (inkNote)
+ // ICHANGED
+ private void resourceErrorMessage(int tabIndex) {
+ if (tabIndex < 0) {
+ return;
+ }
+ if (inkNote.get(tabIndex))
return;
waitCursor(false);
QMessageBox.information(this, tr("DOUGH!!!"), tr("Well, this is embarrassing."+
"Don't get angry. I'm doing it to prevent you from messing up\n"+
"this note on the Evernote servers. Sorry."+
"\n\nP.S. You might want to re-synchronize to see if it corrects this problem.\nWho knows, you might get lucky."));
- inkNote = true;
+ inkNote.put(tabIndex, true);
browserWindow.setReadOnly(true);
waitCursor(true);
}
public void refreshLists() {
logger.log(logger.EXTREME, "Entering NeverNote.refreshLists");
updateQuotaBar();
- listManager.refreshLists(currentNote, noteDirty, browserWindow.getContent());
+ // ICHANGED
+ // すべてのタブのノートを調べて、Dirtyならばセーブする。その後refreshListsする。
+ Collection<Integer> tabIndex = noteDirty.keySet();
+ Iterator<Integer> indexIterator = tabIndex.iterator();
+ HashMap<Integer, Note> saveNotes = new HashMap<Integer, Note>();
+ HashMap<Integer, String> saveContents = new HashMap<Integer, String>();
+ for (boolean isNoteDirty: noteDirty.values()) {
+ int index = indexIterator.next();
+ if (isNoteDirty) {
+ saveNotes.put(index, tabWindows.get(index).getBrowserWindow().getNote());
+ saveContents.put(index, tabWindows.get(index).getBrowserWindow().getContent());
+ }
+ }
+
+ listManager.saveUpdatedNotes(saveNotes, saveContents);
+ listManager.refreshLists();
+
tagIndexUpdated(true);
notebookIndexUpdated();
savedSearchIndexUpdated();
// toggle the add buttons
newButton.setEnabled(!newButton.isEnabled());
menuBar.noteAdd.setEnabled(newButton.isEnabled());
+ menuBar.noteAddNewTab.setEnabled(newButton.isEnabled());
+ if (currentNoteGuid == null || currentNoteGuid.equals("")) {
+ menuBar.noteAddNewTab.setEnabled(false);
+ }
menuBar.noteAdd.setVisible(true);
if (!toDeleted) { // 生存ノートテーブルへ
String tableGuid = (String) ix.values().toArray()[0];
if (tableGuid.equals(rensoNotePressedItemGuid)) {
noteTableView.selectRow(i);
- return;
+ break;
}
}
}
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);
+ }
}