return success;
}
+
+ // 操作ログを取らないモードのボタン状態
+ public static boolean isHaltLogButton() {
+ settings.beginGroup("RensoNoteList");
+ try {
+ String text = (String)settings.value("haltOperationLog", "false");
+ settings.endGroup();
+ if (text.equalsIgnoreCase("true"))
+ return true;
+ else
+ return false;
+ } catch (java.lang.ClassCastException e) {
+ Boolean value = (Boolean) settings.value("haltOperationLog", true);
+ settings.endGroup();
+ return value;
+ }
+ }
+ public static void saveHaltLogButton(boolean val) {
+ settings.beginGroup("RensoNoteList");
+ if (val)
+ settings.setValue("haltOperationLog", "true");
+ else
+ settings.setValue("haltOperationLog", "false");
+ settings.endGroup();
+ }
}
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;
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;
// ICHANGED
private final TabBrowserWidget tabBrowser; // ブラウザウィンドウをタブ化
private final HashMap<Integer, TabBrowse> tabWindows; // タブウィンドウ
- private final RensoNoteList rensoNoteList; // 連想ノートリスト
- private final QDockWidget rensoNoteListDock; // 連想ノートリストドックウィジェット
+ private final RensoNoteListDock rensoNoteListDock; // 連想ノートリストドックウィジェット
ClipBoardObserver cbObserver;
String rensoNotePressedItemGuid;
// ICHANGED
// 連想ノートリストをセットアップ
- rensoNoteList = new RensoNoteList(conn, this, syncRunner);
- 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) {
saveWindowState();
// 連想ノートリストのEvernote関連ノート取得スレッドを終了
- rensoNoteList.stopThread();
+ rensoNoteListDock.getRensoNoteList().stopThread();
if (tempFiles != null)
tempFiles.clear();
// ICHANGED
// 連想ノートリストを更新
- rensoNoteList.refreshRensoNoteList(currentNoteGuid);
+ rensoNoteListDock.getRensoNoteList().refreshRensoNoteList(currentNoteGuid);
waitCursor(false);
logger.log(logger.HIGH, "Leaving NeverNote.noteTableSelection");
} else
indexThreadDeadCount=0;
- if (!rensoNoteList.getEnRelatedNotesThread().isAlive()) {
+ 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 "+
refreshEvernoteNote(true);
// 連想ノートリストを更新
- rensoNoteList.refreshRensoNoteList(currentNoteGuid);
+ rensoNoteListDock.getRensoNoteList().refreshRensoNoteList(currentNoteGuid);
}
// ICHANGD
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)) {
// 除外ノートテーブルに追加
conn.getExcludedTable().addExclusion(guid, currentNoteGuid);
- rensoNoteList.refreshRensoNoteList(currentNoteGuid);
+ rensoNoteListDock.getRensoNoteList().refreshRensoNoteList(currentNoteGuid);
}
// ICHANGED
// スター付きノートテーブルに追加
conn.getStaredTable().addStaredItem(currentNoteGuid, guid);
- rensoNoteList.refreshRensoNoteList(currentNoteGuid);
+ rensoNoteListDock.getRensoNoteList().refreshRensoNoteList(currentNoteGuid);
}
// ICHANGED
// スター付きノートテーブルから削除
conn.getStaredTable().removeStaredItem(currentNoteGuid, guid);
- rensoNoteList.refreshRensoNoteList(currentNoteGuid);
+ rensoNoteListDock.getRensoNoteList().refreshRensoNoteList(currentNoteGuid);
}
// ICHANGED
// 連想ノートリストのgetter
public RensoNoteList getRensoNoteList() {
- return rensoNoteList;
+ return rensoNoteListDock.getRensoNoteList();
}
}
private String guid;
private int allPointSum;
- public RensoNoteList(DatabaseConnection c, NeverNote p, SyncRunner syncRunner) {
- logger = new ApplicationLogger("rensoNoteList.log");
- logger.log(logger.HIGH, "Setting up rensoNoteList");
+ public RensoNoteList(DatabaseConnection c, NeverNote p, SyncRunner syncRunner, ApplicationLogger logger) {
+ this.logger = logger;
+ this.logger.log(this.logger.HIGH, "Setting up rensoNoteList");
allPointSum = 0;
this.conn = c;
this.guid = new String();
mergedHistory = new HashMap<String, Integer>();
enRelatedNotesCache = new HashMap<String, List<String>>();
- this.enRelatedNotesRunner = new ENRelatedNotesRunner(this.syncRunner, logger);
+ this.enRelatedNotesRunner = new ENRelatedNotesRunner(this.syncRunner, this.logger);
this.enRelatedNotesRunner.enRelatedNotesSignal.getENRelatedNotesFinished.connect(this, "enRelatedNotesComplete()");
this.enRelatedNotesThread = new QThread(enRelatedNotesRunner, "ENRelatedNotes Thread");
this.getEnRelatedNotesThread().start();
menu.addAction(excludeNoteAction);
menu.aboutToHide.connect(this, "contextMenuHidden()");
- logger.log(logger.HIGH, "rensoNoteList setup complete");
+ this.logger.log(this.logger.HIGH, "rensoNoteList setup complete");
+ }
+
+ // オーバーロード
+ // 現在開いているノートの連想ノートリストをリフレッシュ
+ public void refreshRensoNoteList() {
+ refreshRensoNoteList(guid);
}
// 連想ノートリストをリフレッシュ
public void refreshRensoNoteList(String guid) {
- logger.log(logger.HIGH, "Entering RensoNoteList.refreshRensoNoteList");
+ logger.log(logger.HIGH, "Entering RensoNoteList.refreshRensoNoteList guid = " + guid);
this.clear();
rensoNoteListItems.clear();
// 操作履歴をデータベースから取得してノートごとの関連度を算出、その後mergedHistoryに追加
private void calculateHistory(String guid) {
+ logger.log(logger.EXTREME, "Entering RensoNoteList.calculateHistory guid = " + guid);
+
// browseHistory<guid, 回数(ポイント)>
HashMap<String, Integer> browseHistory = conn.getHistoryTable().getBehaviorHistory("browse", guid);
addWeight(browseHistory, Global.getBrowseWeight());
HashMap<String, Integer> sameNotebookHistory = conn.getHistoryTable().getBehaviorHistory("sameNotebook", guid);
addWeight(sameNotebookHistory, Global.getSameNotebookWeight());
mergedHistory = mergeHistory(sameNotebookHistory, mergedHistory);
+ logger.log(logger.EXTREME, "Leaving RensoNoteList.calculateHistory");
}
// 操作回数に重み付けする
private void addWeight(HashMap<String, Integer> history, int weight){
+ logger.log(logger.EXTREME, "Entering RensoNoteList.addWeight");
+
Set<String> keySet = history.keySet();
Iterator<String> hist_iterator = keySet.iterator();
while(hist_iterator.hasNext()){
String key = hist_iterator.next();
history.put(key, history.get(key) * weight);
}
+
+ logger.log(logger.EXTREME, "Leaving RensoNoteList.addWeight");
}
// 連想ノートリストを再描画
private void repaintRensoNoteList(boolean needClear) {
+ logger.log(logger.EXTREME, "Entering RensoNoteList.repaintRensoNoteList");
+
if (needClear) {
this.clear();
rensoNoteListItems.clear();
}
addRensoNoteList(mergedHistory);
+
+ logger.log(logger.EXTREME, "Leaving RensoNoteList.repaintRensoNoteList");
}
// 引数1と引数2をマージしたハッシュマップを返す
private HashMap<String, Integer> mergeHistory(HashMap<String, Integer> History1, HashMap<String, Integer> History2){
+ logger.log(logger.EXTREME, "Entering RensoNoteList.mergeHistory");
+
HashMap<String, Integer> mergedHistory = new HashMap<String, Integer>();
mergedHistory.putAll(History1);
mergedHistory.put(key, History2.get(key));
}
}
-
+
+ logger.log(logger.EXTREME, "Leaving RensoNoteList.mergeHistory");
return mergedHistory;
}
// 連想ノートリストにハッシュマップのデータを追加
private void addRensoNoteList(HashMap<String, Integer> History){
+ logger.log(logger.EXTREME, "Entering RensoNoteList.addRensoNoteList");
+
String currentNoteGuid = new String(parent.getCurrentNoteGuid());
// スター付きノートとスター無しノートを分ける
}
}
}
+ logger.log(logger.EXTREME, "Leaving RensoNoteList.addRensoNoteList");
}
// リストのアイテムから対象ノートのguidを取得
// 関連ノートリストの右クリックメニュー
@Override
public void contextMenuEvent(QContextMenuEvent event){
+ logger.log(logger.EXTREME, "Entering RensoNoteList.contextMenuEvent");
+
if (rensoNotePressedItemGuid == null || rensoNotePressedItemGuid.equals("")) {
return;
}
menu.exec(event.globalPos());
rensoNotePressedItemGuid = null;
+
+ logger.log(logger.EXTREME, "Leaving RensoNoteList.contextMenuEvent");
}
// コンテキストメニューが表示されているかどうか
// ユーザが連想ノートリストのアイテムを選択した時の処理
@SuppressWarnings("unused")
private void rensoNoteItemPressed(QListWidgetItem current) {
+ logger.log(logger.HIGH, "Entering RensoNoteList.rensoNoteItemPressed");
+
rensoNotePressedItemGuid = null;
// 右クリックだったときの処理
if (QApplication.mouseButtons().isSet(MouseButton.RightButton)) {
rensoNotePressedItemGuid = getNoteGuid(current);
}
+
+ logger.log(logger.HIGH, "Leaving RensoNoteList.rensoNoteItemPressed");
}
// Evernoteの関連ノートの取得が完了
@SuppressWarnings("unused")
private void enRelatedNotesComplete() {
+ logger.log(logger.HIGH, "Entering RensoNoteList.enRelatedNotesComplete");
+
Pair<String, List<String>> enRelatedNoteGuidPair = enRelatedNotesRunner.getENRelatedNoteGuids(); // <元ノートguid, 関連ノートguidリスト>
if (enRelatedNoteGuidPair == null) {
}
}
}
+
+ logger.log(logger.HIGH, "Leaving RensoNoteList.enRelatedNotesComplete");
}
// Evernote関連ノートの関連度情報をmergedHistoryに追加
private void addENRelatedNotes(List<String> relatedNoteGuids) {
+ logger.log(logger.EXTREME, "Entering RensoNoteList.addENRelatedNotes");
+
// Evernote関連ノート<guid, 関連ポイント>
HashMap<String, Integer> enRelatedNotes = new HashMap<String, Integer>();
}
mergedHistory = mergeHistory(enRelatedNotes, mergedHistory);
+
+ logger.log(logger.EXTREME, "Leaving RensoNoteList.addENRelatedNotes");
}
// Evernoteの関連ノート取得スレッドを終了させる
public boolean stopThread() {
+ logger.log(logger.HIGH, "Entering RensoNoteList.stopThread");
+
if (enRelatedNotesRunner.addStop()) {
+ logger.log(logger.HIGH, "RensoNoteList.stopThread succeeded");
return true;
}
+ logger.log(logger.HIGH, "RensoNoteList.stopThread failed");
return false;
}
--- /dev/null
+/*
+ * This file is part of NeighborNote
+ * Copyright 2013 Yuki Takahashi
+ *
+ * This file may be licensed under the terms of of the
+ * GNU General Public License Version 2 (the ``GPL'').
+ *
+ * Software distributed under the License is distributed
+ * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
+ * express or implied. See the GPL for the specific language
+ * governing rights and limitations.
+ *
+ * You should have received a copy of the GPL along with this
+ * program. If not, go to http://www.gnu.org/licenses/gpl.html
+ * or write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+*/
+
+package cx.fbn.nevernote.gui;
+
+import com.trolltech.qt.core.QSize;
+import com.trolltech.qt.gui.QDockWidget;
+import com.trolltech.qt.gui.QIcon;
+import com.trolltech.qt.gui.QMessageBox;
+import com.trolltech.qt.gui.QPushButton;
+import com.trolltech.qt.gui.QSizePolicy;
+import com.trolltech.qt.gui.QToolBar;
+import com.trolltech.qt.gui.QVBoxLayout;
+import com.trolltech.qt.gui.QWidget;
+
+import cx.fbn.nevernote.Global;
+import cx.fbn.nevernote.NeverNote;
+import cx.fbn.nevernote.sql.DatabaseConnection;
+import cx.fbn.nevernote.threads.SyncRunner;
+import cx.fbn.nevernote.utilities.ApplicationLogger;
+
+public class RensoNoteListDock extends QDockWidget {
+ private final DatabaseConnection conn;
+ private final NeverNote parent;
+ private final SyncRunner syncRunner;
+ private final ApplicationLogger logger;
+ private final QPushButton haltLogButton; // 操作ログの取得を停止ボタン
+ private final RensoNoteList rensoNoteList; // 連想ノートリスト
+ private final QToolBar rensoToolBar; // 連想ノートリストドックのツールバー
+
+ private final String iconPath;
+
+ public RensoNoteListDock(DatabaseConnection conn, NeverNote parent, SyncRunner syncRunner, String iconPath, String title) {
+ super(title);
+
+ this.logger = new ApplicationLogger("rensoNoteList.log");
+ this.logger.log(this.logger.HIGH, "Setting up rensoNoteListDock");
+
+ this.conn = conn;
+ this.parent = parent;
+ this.iconPath = iconPath;
+ this.syncRunner = syncRunner;
+
+ QVBoxLayout vLayout = new QVBoxLayout();
+ rensoToolBar = new QToolBar();
+ vLayout.addWidget(rensoToolBar);
+
+ haltLogButton = new QPushButton();
+ QIcon haltLogIcon = new QIcon(this.iconPath + "haltLog.png");
+ haltLogButton.setIcon(haltLogIcon);
+ haltLogButton.setIconSize(new QSize(24, 24));
+ haltLogButton.setToolTip(tr("Halt Collectiong Operation Log"));
+ haltLogButton.setCheckable(true);
+ haltLogButton.setChecked(Global.isHaltLogButton());
+ haltLogButton.toggled.connect(this, "haltLogToggled(boolean)");
+
+ // ログ取得停止ボタンを右寄せするためのスペーサ
+ QWidget spacer = new QWidget();
+ spacer.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding);
+ rensoToolBar.addWidget(spacer);
+ rensoToolBar.addWidget(haltLogButton);
+
+ rensoNoteList = new RensoNoteList(this.conn, this.parent, this.syncRunner, this.logger);
+ getRensoNoteList().itemPressed.connect(this.parent, "rensoNoteItemPressed(QListWidgetItem)");
+ vLayout.addWidget(getRensoNoteList());
+
+ QWidget w = new QWidget();
+ w.setLayout(vLayout);
+ this.setWidget(w);
+ }
+
+ @SuppressWarnings("unused")
+ private void haltLogToggled(boolean checked) {
+ logger.log(logger.EXTREME, "RensoNoteListDock.haltLogToggled");
+
+ if (checked) {
+ QMessageBox.information(this, tr("Halt Collectiong Operation Log"), tr("Collecting operation log halted.\nYou can resume, if you press this button again."));
+ }
+ Global.saveHaltLogButton(checked);
+ }
+
+ public RensoNoteList getRensoNoteList() {
+ return rensoNoteList;
+ }
+}
import java.util.HashMap;
import java.util.List;
+import cx.fbn.nevernote.Global;
import cx.fbn.nevernote.sql.driver.NSqlQuery;
import cx.fbn.nevernote.utilities.ApplicationLogger;
NSqlQuery query = new NSqlQuery(db.getBehaviorConnection());
boolean excludedCheck = false;
+ // 操作ログの取得を停止中
+ if (Global.isHaltLogButton()) {
+ return;
+ }
+
if (behaviorType == null) {
return;
}