X-Git-Url: http://git.sourceforge.jp/view?p=neighbornote%2FNeighborNote.git;a=blobdiff_plain;f=src%2Fcx%2Ffbn%2Fnevernote%2FNeverNote.java;h=2c735485088aa4091017e89543d38d7ef1344e8a;hp=7b797901f71353bc10386e64b12a1d14109f847b;hb=a403cdb8ee3ac6e46725d576501998ede1cac6e0;hpb=b17875a437e3a1e817af6d033526aa70f65422c2 diff --git a/src/cx/fbn/nevernote/NeverNote.java b/src/cx/fbn/nevernote/NeverNote.java index 7b79790..2c73548 100644 --- a/src/cx/fbn/nevernote/NeverNote.java +++ b/src/cx/fbn/nevernote/NeverNote.java @@ -47,7 +47,6 @@ import java.util.Vector; import org.apache.log4j.Level; import org.apache.log4j.Logger; -import org.apache.thrift.TException; import org.h2.tools.ChangeFileEncryption; import com.evernote.edam.error.EDAMNotFoundException; @@ -66,6 +65,7 @@ import com.evernote.edam.type.Resource; import com.evernote.edam.type.SavedSearch; import com.evernote.edam.type.Tag; import com.evernote.edam.type.User; +import com.evernote.thrift.TException; import com.trolltech.qt.QThread; import com.trolltech.qt.core.QByteArray; import com.trolltech.qt.core.QDateTime; @@ -106,7 +106,6 @@ import com.trolltech.qt.gui.QComboBox; import com.trolltech.qt.gui.QCursor; import com.trolltech.qt.gui.QDesktopServices; import com.trolltech.qt.gui.QDialog; -import com.trolltech.qt.gui.QDockWidget; import com.trolltech.qt.gui.QFileDialog; import com.trolltech.qt.gui.QFileDialog.AcceptMode; import com.trolltech.qt.gui.QFileDialog.FileMode; @@ -181,6 +180,7 @@ import cx.fbn.nevernote.gui.ExternalBrowse; import cx.fbn.nevernote.gui.MainMenuBar; import cx.fbn.nevernote.gui.NotebookTreeWidget; import cx.fbn.nevernote.gui.RensoNoteList; +import cx.fbn.nevernote.gui.RensoNoteListDock; import cx.fbn.nevernote.gui.SavedSearchTreeWidget; import cx.fbn.nevernote.gui.SearchPanel; import cx.fbn.nevernote.gui.TabBrowse; @@ -208,6 +208,7 @@ import cx.fbn.nevernote.xml.ExportData; import cx.fbn.nevernote.xml.ImportData; import cx.fbn.nevernote.xml.ImportEnex; import cx.fbn.nevernote.xml.NoteFormatter; +//import org.apache.thrift.TException; public class NeverNote extends QMainWindow{ @@ -328,12 +329,14 @@ public class NeverNote extends QMainWindow{ int tagDeadCount=0; // number of consecutive dead times for the tag thread int trashDeadCount=0; // number of consecutive dead times for the trash thread int saveThreadDeadCount=0; // number of consecutive dead times for the save thread + int enRelatedNotesThreadDeadCount=0; // number of consecutive dead times for the EvernoteRelatedNotes Thread boolean disableTagThreadCheck=false; boolean disableNotebookThreadCheck=false; boolean disableTrashThreadCheck=false; boolean disableSaveThreadCheck=false; boolean disableSyncThreadCheck=false; boolean disableIndexThreadCheck=false; + boolean disableENRelatedNotesThreadCheck=false; HashMap noteCache; // Cash of note content HashMap readOnlyCache; // List of cashe notes that are read-only @@ -363,8 +366,7 @@ public class NeverNote extends QMainWindow{ // ICHANGED private final TabBrowserWidget tabBrowser; // ブラウザウィンドウをタブ化 private final HashMap tabWindows; // タブウィンドウ - private final RensoNoteList rensoNoteList; // 連想ノートリスト - private final QDockWidget rensoNoteListDock; // 連想ノートリストドックウィジェット + private final RensoNoteListDock rensoNoteListDock; // 連想ノートリストドックウィジェット ClipBoardObserver cbObserver; String rensoNotePressedItemGuid; @@ -453,9 +455,9 @@ public class NeverNote extends QMainWindow{ indexThread = new QThread(indexRunner, "Index Thread"); indexRunner.indexAttachmentsLocally = Global.indexAttachmentsLocally(); indexRunner.indexImageRecognition = Global.indexImageRecognition(); - indexRunner.indexNoteBody = Global.indexNoteBody(); - indexRunner.indexNoteTitle = Global.indexNoteTitle(); - indexRunner.specialIndexCharacters = Global.getSpecialIndexCharacters(); +// indexRunner.indexNoteBody = Global.indexNoteBody(); +// indexRunner.indexNoteTitle = Global.indexNoteTitle(); +// indexRunner.specialIndexCharacters = Global.getSpecialIndexCharacters(); indexThread.start(); synchronizeAnimationTimer = new QTimer(); @@ -600,11 +602,11 @@ public class NeverNote extends QMainWindow{ tabBrowser = new TabBrowserWidget(this); tabBrowser.setStyleSheet("QTabBar::tab{width:150px;}"); tabBrowser.setMovable(true); + tabBrowser.setTabsClosable(true); TabBrowse tab = new TabBrowse(conn, tabBrowser, cbObserver); browserWindow = tab.getBrowserWindow(); int index = tabBrowser.addNewTab(tab, ""); tabWindows.put(index, tab); - tabBrowser.setTabsClosable(true); tabBrowser.currentChanged.connect(this, "tabWindowChanged(int)"); tabBrowser.tabCloseRequested.connect(this, "tabWindowClosing(int)"); @@ -625,11 +627,7 @@ public class NeverNote extends QMainWindow{ // ICHANGED // 連想ノートリストをセットアップ - rensoNoteList = new RensoNoteList(conn, this); - rensoNoteList.itemPressed.connect(this, - "rensoNoteItemPressed(QListWidgetItem)"); - rensoNoteListDock = new QDockWidget(tr("Renso Note List"), this); - rensoNoteListDock.setWidget(rensoNoteList); + rensoNoteListDock = new RensoNoteListDock(conn, this, syncRunner, iconPath, tr("Renso Note List")); addDockWidget(DockWidgetArea.RightDockWidgetArea, rensoNoteListDock); if (Global.getListView() == Global.View_List_Wide) { @@ -916,8 +914,7 @@ public class NeverNote extends QMainWindow{ } if (Global.checkVersionUpgrade()) { - // ICHANGED TODO とりあえず封印 - // checkForUpdates(); + checkForUpdates(); } // ICHANGED @@ -1251,6 +1248,9 @@ public class NeverNote extends QMainWindow{ saveNote(); listManager.stop(); saveWindowState(); + + // 連想ノートリストのEvernote関連ノート取得スレッドを終了 + rensoNoteListDock.getRensoNoteList().stopThread(); if (tempFiles != null) tempFiles.clear(); @@ -1453,7 +1453,7 @@ public class NeverNote extends QMainWindow{ saveNoteColumnPositions(); saveNoteIndexWidth(); showColumns(); - ConfigDialog settings = new ConfigDialog(this); + ConfigDialog settings = new ConfigDialog(this, conn); String dateFormat = Global.getDateFormat(); String timeFormat = Global.getTimeFormat(); @@ -1462,9 +1462,9 @@ public class NeverNote extends QMainWindow{ settings.exec(); indexRunner.indexAttachmentsLocally = Global.indexAttachmentsLocally(); - indexRunner.indexNoteBody = Global.indexNoteBody(); - indexRunner.indexNoteTitle = Global.indexNoteTitle(); - indexRunner.specialIndexCharacters = Global.getSpecialIndexCharacters(); +// indexRunner.indexNoteBody = Global.indexNoteBody(); +// indexRunner.indexNoteTitle = Global.indexNoteTitle(); +// indexRunner.specialIndexCharacters = Global.getSpecialIndexCharacters(); indexRunner.indexImageRecognition = Global.indexImageRecognition(); if (Global.showTrayIcon() || Global.minimizeOnClose()) trayIcon.show(); @@ -2964,6 +2964,8 @@ public class NeverNote extends QMainWindow{ status.setTagCount(listManager.getTagIndex().size()); status.setResourceCount(conn.getNoteTable().noteResourceTable.getResourceCount()); status.setWordCount(conn.getWordsTable().getWordCount()); + status.setHistoryCount(conn.getHistoryTable().getHistoryCount()); + status.setRensoClickCount(conn.getHistoryTable().getRensoClickCount()); waitCursor(false); status.exec(); } @@ -3746,6 +3748,7 @@ public class NeverNote extends QMainWindow{ Global.isConnected = syncRunner.isConnected; + boolean autoLoginMessageFlag = false; if (!Global.isConnected) { OAuthWindow window = new OAuthWindow(logger); if (window.error) { @@ -3772,6 +3775,7 @@ public class NeverNote extends QMainWindow{ syncRunner.authToken = tokenizer.oauth_token; syncRunner.enConnect(); Global.isConnected = syncRunner.isConnected; + autoLoginMessageFlag = true; } // Global.username = syncRunner.username; @@ -3779,9 +3783,16 @@ public class NeverNote extends QMainWindow{ return; setupOnlineMenu(); setupConnectMenuOptions(); + + // 初回ログイン時に自動ログインが無効だったら、有効化するか確認する + if (autoLoginMessageFlag && !Global.automaticLogin()) { + if (QMessageBox.question(this, tr("Confirmation"), tr("Are you sure you want to enable the auto-login feature?"), + QMessageBox.StandardButton.Yes, QMessageBox.StandardButton.No) == StandardButton.Yes.value()) { + Global.setAutomaticLogin(true); + } + } + logger.log(logger.HIGH, "Leaving NeverNote.remoteConnect"); - - } private void setupConnectMenuOptions() { logger.log(logger.HIGH, "entering NeverNote.setupConnectMenuOptions"); @@ -4056,7 +4067,7 @@ public class NeverNote extends QMainWindow{ // ICHANGED // 連想ノートリストを更新 - rensoNoteList.refreshRensoNoteList(currentNoteGuid); + rensoNoteListDock.getRensoNoteList().refreshRensoNoteList(currentNoteGuid); waitCursor(false); logger.log(logger.HIGH, "Leaving NeverNote.noteTableSelection"); @@ -4905,6 +4916,11 @@ public class NeverNote extends QMainWindow{ fromHistory.remove(i + 1); } + // タブが残り1つになったら、閉じるボタンを消す + if (tabBrowser.count() == 1) { + tabBrowser.hideTabCloseButton(0); + } + // タブの閉じるボタンを押すと、tabWindowClosingより先にtabWindowChangedが呼ばれてしまうので、手動で呼びなおす tabWindowChanged(tabBrowser.currentIndex()); } @@ -5669,12 +5685,6 @@ public class NeverNote extends QMainWindow{ // 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("")) { @@ -5682,6 +5692,12 @@ public class NeverNote extends QMainWindow{ } } + 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(); @@ -6742,7 +6758,15 @@ public class NeverNote extends QMainWindow{ } else indexThreadDeadCount=0; - + if (!rensoNoteListDock.getRensoNoteList().getEnRelatedNotesThread().isAlive()) { + enRelatedNotesThreadDeadCount++; + if (enRelatedNotesThreadDeadCount > MAX && !disableENRelatedNotesThreadCheck) { + QMessageBox.information(this, tr("A thread has died."), tr("It appears as the Evernote Related Notes thread has died. I recommend "+ + "checking stopping NeighborNote, saving the logs for later viewing, and restarting. Sorry.")); + disableENRelatedNotesThreadCheck = true; + } + } else + enRelatedNotesThreadDeadCount=0; } private void thumbnailTimer() { @@ -7550,7 +7574,7 @@ public class NeverNote extends QMainWindow{ refreshEvernoteNote(true); // 連想ノートリストを更新 - rensoNoteList.refreshRensoNoteList(currentNoteGuid); + rensoNoteListDock.getRensoNoteList().refreshRensoNoteList(currentNoteGuid); } // ICHANGD @@ -7610,7 +7634,7 @@ public class NeverNote extends QMainWindow{ private void rensoNoteItemPressed(QListWidgetItem current) { logger.log(logger.HIGH, "Nevernote.rensoNoteSelectionChangeに入った"); - rensoNotePressedItemGuid = rensoNoteList.getNoteGuid(current); + rensoNotePressedItemGuid = rensoNoteListDock.getRensoNoteList().getNoteGuid(current); // 右クリックだったら終了 if (QApplication.mouseButtons().isSet(MouseButton.RightButton)) { @@ -7677,7 +7701,7 @@ public class NeverNote extends QMainWindow{ // 除外ノートテーブルに追加 conn.getExcludedTable().addExclusion(guid, currentNoteGuid); - rensoNoteList.refreshRensoNoteList(currentNoteGuid); + rensoNoteListDock.getRensoNoteList().refreshRensoNoteList(currentNoteGuid); } // ICHANGED @@ -7696,7 +7720,7 @@ public class NeverNote extends QMainWindow{ // スター付きノートテーブルに追加 conn.getStaredTable().addStaredItem(currentNoteGuid, guid); - rensoNoteList.refreshRensoNoteList(currentNoteGuid); + rensoNoteListDock.getRensoNoteList().refreshRensoNoteList(currentNoteGuid); } // ICHANGED @@ -7715,7 +7739,7 @@ public class NeverNote extends QMainWindow{ // スター付きノートテーブルから削除 conn.getStaredTable().removeStaredItem(currentNoteGuid, guid); - rensoNoteList.refreshRensoNoteList(currentNoteGuid); + rensoNoteListDock.getRensoNoteList().refreshRensoNoteList(currentNoteGuid); } // ICHANGED @@ -7756,4 +7780,9 @@ public class NeverNote extends QMainWindow{ fromHistory.put(from, fromHistory.get(to)); fromHistory.put(to, fromHist); } + + // 連想ノートリストのgetter + public RensoNoteList getRensoNoteList() { + return rensoNoteListDock.getRensoNoteList(); + } }