From: yuki Date: Wed, 22 May 2013 02:26:15 +0000 (+0900) Subject: Merge branch 'checkUpdate' into develop X-Git-Tag: version0.1.2~2^2 X-Git-Url: http://git.sourceforge.jp/view?p=neighbornote%2FNeighborNote.git;a=commitdiff_plain;h=83b88db051d8e853d224547a16665ee7e0fb236c;hp=06470e86d4ad38a4f994ab4db0ad9e9d61dd9316 Merge branch 'checkUpdate' into develop --- diff --git a/README.md b/README.md index f790b26..8ed29ab 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ neighbornote.batを実行して下さい。 要件 ------------ -OpenSSLが必要です。Windowsを使っているのであれば、[Shining Light Productions - Win32 OpenSSL](http://slproweb.com/products/Win32OpenSSL.html)から"Win32 OpenSSL v0.9.8y Light"をダウンロードしてインストールする必要があるかもしれません。 +OpenSSLが必要です。Windowsを使っているのであれば、[Shining Light Productions - Win32 OpenSSL](http://slproweb.com/products/Win32OpenSSL.html)から"(Win32/Win64) OpenSSL v0.9.8y Light"をダウンロードしてインストールする必要があるかもしれません。 Download ------------ @@ -29,4 +29,4 @@ Please run the neighbornote.bat. Requirements ------------ -OpenSSL is needed. If you are using Windows, you may need to download and install "Win32 OpenSSL v0.9.8y Light" from [Shining Light Productions - Win32 OpenSSL](http://slproweb.com/products/Win32OpenSSL.html). +OpenSSL is needed. If you are using Windows, you may need to download and install "(Win32/Win64) OpenSSL v0.9.8y Light" from [Shining Light Productions - Win32 OpenSSL](http://slproweb.com/products/Win32OpenSSL.html). diff --git a/src/cx/fbn/nevernote/Global.java b/src/cx/fbn/nevernote/Global.java index b6bd5e5..4d3fb6e 100644 --- a/src/cx/fbn/nevernote/Global.java +++ b/src/cx/fbn/nevernote/Global.java @@ -65,8 +65,8 @@ import cx.fbn.nevernote.utilities.Pair; public class Global { // Set current version and the known versions. // ICHANGED 自分用に変更 - public static String version = "0.1"; - public static String[] validVersions = {"0.1"}; + public static String version = "0.1.1"; + public static String[] validVersions = {"0.1.1", "0.1"}; public static String username = ""; //public static String password = ""; @@ -2303,56 +2303,5 @@ public class Global { settings.endGroup(); return value; } - - // 最後に開いていたノート群を取得 - public static HashMap getLastViewedTabs() { - settings.beginGroup("General"); - - @SuppressWarnings("unchecked") - HashMap tabWindows = (HashMap) settings.value("lastViewedTabs", null); - - settings.endGroup(); - return tabWindows; - } - - // 最後に開いていたノート群を保存 - public static void saveLastViewedTabs(HashMap tabs) { - settings.beginGroup("General"); - if (tabs != null) { - settings.setValue("lastViewedTabs", tabs); - } else { - settings.setValue("lastViewedTabs", ""); - } - settings.endGroup(); - } - - // 最後に開いていたタブのインデックスを取得 - public static int getLastViewedTabIndex() { - settings.beginGroup("General"); - Integer index; - try { - String val = (String) settings.value("lastViewedTabIndex", 0); - index = new Integer(val.trim()); - } catch (Exception e) { - try { - index = (Integer) settings.value("lastViewedTabIndex", 0); - } catch (Exception e1) { - index = 0; - } - } - settings.endGroup(); - return index; - } - - // 最後に開いていたタブのインデックスを保存 - public static void saveLastViewedTabIndex(Integer index) { - settings.beginGroup("General"); - if (index != null) { - settings.setValue("lastViewedTabIndex", index); - } else { - settings.setValue("lastViewedTabIndex", 0); - } - settings.endGroup(); - } } diff --git a/src/cx/fbn/nevernote/NeverNote.java b/src/cx/fbn/nevernote/NeverNote.java index b2ac51e..c745cff 100644 --- a/src/cx/fbn/nevernote/NeverNote.java +++ b/src/cx/fbn/nevernote/NeverNote.java @@ -600,12 +600,25 @@ public class NeverNote extends QMainWindow{ 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, ""); + tabWindows.put(index, tab); tabBrowser.setTabsClosable(true); tabBrowser.currentChanged.connect(this, "tabWindowChanged(int)"); tabBrowser.tabCloseRequested.connect(this, "tabWindowClosing(int)"); + noteDirty = new HashMap(); + noteDirty.put(index, false); + inkNote = new HashMap(); readOnly = new HashMap(); + + // ICHANGED + // 履歴記録のハッシュマップを初期化 + historyGuids.put(index, new ArrayList()); + historyPosition.put(index, 0); + fromHistory.put(index, false); mainLeftRightSplitter.addWidget(leftSplitter1); mainLeftRightSplitter.addWidget(browserIndexSplitter); @@ -779,60 +792,21 @@ public class NeverNote extends QMainWindow{ trayIcon.setToolTip(tr("NeighborNote")); trayIcon.setContextMenu(trayMenu); trayIcon.activated.connect(this, "trayActivated(com.trolltech.qt.gui.QSystemTrayIcon$ActivationReason)"); - - // 前回のタブを復元 - noteTableView.load(true); - HashMap tabs = new HashMap(); - if (Global.getLastViewedTabs() != null) { - tabs.putAll(Global.getLastViewedTabs()); - } - - Collection guids = tabs.values(); - Iterator guidIterator = guids.iterator(); - Collection indexes = tabs.keySet(); - Iterator indexIterator = indexes.iterator(); - noteDirty = new HashMap(); - - while (guidIterator.hasNext()) { - String guid = guidIterator.next(); - int tabIndex = indexIterator.next(); - - currentNoteGuid = guid; - noteDirty.put(tabIndex, false); - if (!currentNoteGuid.trim().equals("")) { - currentNote = conn.getNoteTable().getNote(currentNoteGuid, true, true, false, false, true); - if (currentNote != null) { - openTabEditor(guid, tabIndex); - } - } - } - - // タブが0個だったら作る - if (tabBrowser.count() <= 0) { - TabBrowse tab = new TabBrowse(conn, tabBrowser, cbObserver); - browserWindow = tab.getBrowserWindow(); - tabBrowser.currentChanged.disconnect(); - int index = tabBrowser.addNewTab(tab, ""); - tabBrowser.currentChanged.connect(this, "tabWindowChanged(int)"); - tabWindows.put(index, tab); - noteDirty.put(index, false); - - // 履歴記録のハッシュマップを初期化 - historyGuids.put(index, new ArrayList()); - historyPosition.put(index, 0); - fromHistory.put(index, false); - } - + + currentNoteGuid=""; currentNoteGuid = Global.getLastViewedNoteGuid(); - if (currentNoteGuid.trim().equals("")) { + if (currentNoteGuid.equals("")) currentNote = new Note(); - } else { - currentNote = conn.getNoteTable().getNote(currentNoteGuid, true,true,false,false,true); - } - // タブのフォーカスをlastViewedTabIndexに移す - if (tabBrowser.count() >= 2) { - tabBrowser.setCurrentIndex(Global.getLastViewedTabIndex()); + // ICHANGED + /* 上に移動したので要らない + historyGuids = new ArrayList(); + historyPosition = 0; + fromHistory = false; + */ + + if (!currentNoteGuid.trim().equals("")) { + currentNote = conn.getNoteTable().getNote(currentNoteGuid, true,true,false,false,true); } noteIndexUpdated(true); @@ -1303,23 +1277,6 @@ public class NeverNote extends QMainWindow{ Global.saveWindowMaximized(isMaximized()); Global.saveCurrentNoteGuid(currentNoteGuid); - Global.saveLastViewedTabIndex(tabBrowser.currentIndex()); - - // 開いていたタブ群をsettingsに保存しておく - Collection tabBrowsers = tabWindows.values(); - Iterator tabIterator = tabBrowsers.iterator(); - Collection tabIndexes = tabWindows.keySet(); - Iterator indexIterator = tabIndexes.iterator(); - HashMap tabs = new HashMap(); - while (tabIterator.hasNext()) { - TabBrowse tab = tabIterator.next(); - int index = indexIterator.next(); - if (tab.getBrowserWindow() != null && tab.getBrowserWindow().getNote() != null) { - String guid = tab.getBrowserWindow().getNote().getGuid(); - tabs.put(index, guid); - } - } - Global.saveLastViewedTabs(tabs); int sortCol = noteTableView.proxyModel.sortColumn(); int sortOrder = noteTableView.proxyModel.sortOrder().value(); @@ -3006,6 +2963,7 @@ 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()); waitCursor(false); status.exec(); } @@ -4831,36 +4789,17 @@ public class NeverNote extends QMainWindow{ conn.getHistoryTable().addHistory("rensoItemClick", prevCurrentNoteGuid, rensoNotePressedItemGuid); } } - - private void openTabEditor(String guid) { - openTabEditor(guid, -1); - } - // オーバーロード insertIndex < 0 ならば普通に追加 - private void openTabEditor(String guid, int insertIndex) { + // ICHANGED + private void openTabEditor(String guid) { + Note note = conn.getNoteTable().getNote(guid, true, true, false, true, true); // 新しいタブエディタを作成 TabBrowse newBrowser = new TabBrowse(conn, tabBrowser, cbObserver); showEditorButtons(newBrowser.getBrowserWindow()); String noteTitle = note.getTitle(); - int index; - // 最初のタブだけ、追加後に自動的にフォーカスが移ってしまうので、一度切断する - if (tabBrowser.count() == 0) { - tabBrowser.currentChanged.disconnect(); - if (insertIndex < 0) { - index = tabBrowser.addNewTab(newBrowser, noteTitle); - } else { - index = tabBrowser.insertNewTab(insertIndex, newBrowser, noteTitle); - } - tabBrowser.currentChanged.connect(this, "tabWindowChanged(int)"); - } else { - if (insertIndex < 0) { - index = tabBrowser.addNewTab(newBrowser, noteTitle); - } else { - index = tabBrowser.insertNewTab(insertIndex, newBrowser, noteTitle); - } - } + int index = tabBrowser.addNewTab(newBrowser, noteTitle); tabWindows.put(index, newBrowser); noteDirty.put(index, false); @@ -4896,8 +4835,6 @@ public class NeverNote extends QMainWindow{ addBrowseHistory(); } } - - rensoNoteList.refreshRensoNoteList(currentNoteGuid); } // ICHANGED タブが閉じられた @@ -7693,7 +7630,7 @@ public class NeverNote extends QMainWindow{ String tableGuid = (String) ix.values().toArray()[0]; if (tableGuid.equals(rensoNotePressedItemGuid)) { noteTableView.selectRow(i); - return; + break; } } } diff --git a/src/cx/fbn/nevernote/dialog/DatabaseStatus.java b/src/cx/fbn/nevernote/dialog/DatabaseStatus.java index 44ce73c..c13b54e 100644 --- a/src/cx/fbn/nevernote/dialog/DatabaseStatus.java +++ b/src/cx/fbn/nevernote/dialog/DatabaseStatus.java @@ -43,6 +43,7 @@ public class DatabaseStatus extends QDialog { QLabel resourceCount; QLabel indexCount; QLabel resourceIndexNeeded; + QLabel historyCount; private final QPushButton ok; private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/"); @@ -61,6 +62,7 @@ public class DatabaseStatus extends QDialog { resourceCount = new QLabel(); resourceIndexNeeded = new QLabel(); indexCount = new QLabel(); + historyCount = new QLabel(); grid.addWidget(new QLabel(tr("Notebooks:")), 0,0); grid.addWidget(notebookCount, 0,1); @@ -88,12 +90,15 @@ public class DatabaseStatus extends QDialog { grid.addWidget(new QLabel(tr("Words In Index")), 8,0); grid.addWidget(indexCount, 8,1); - + + grid.addWidget(new QLabel(tr("Tobal Behavior History:")), 9, 0); + grid.addWidget(historyCount, 9,1); + QGridLayout buttonLayout = new QGridLayout(); ok = new QPushButton(tr("OK")); ok.clicked.connect(this, "okPushed()"); buttonLayout.addWidget(ok, 1, 1); - grid.addLayout(buttonLayout,9,1); + grid.addLayout(buttonLayout,10,1); } @SuppressWarnings("unused") @@ -127,6 +132,9 @@ public class DatabaseStatus extends QDialog { public void setWordCount(int d) { indexCount.setText(NumberFormat.getInstance().format(d)); } + public void setHistoryCount(int d) { + historyCount.setText(NumberFormat.getInstance().format(d)); + } public QPushButton getOkButton() { return ok; } diff --git a/src/cx/fbn/nevernote/gui/RensoNoteListItem.java b/src/cx/fbn/nevernote/gui/RensoNoteListItem.java index 7aa7ab0..294495b 100644 --- a/src/cx/fbn/nevernote/gui/RensoNoteListItem.java +++ b/src/cx/fbn/nevernote/gui/RensoNoteListItem.java @@ -34,6 +34,7 @@ import com.trolltech.qt.gui.QMouseEvent; import com.trolltech.qt.gui.QPaintEvent; import com.trolltech.qt.gui.QPainter; import com.trolltech.qt.gui.QPalette; +import com.trolltech.qt.gui.QPen; import com.trolltech.qt.gui.QTextOption; import com.trolltech.qt.gui.QWidget; @@ -51,6 +52,7 @@ public class RensoNoteListItem extends QWidget{ private final RensoNoteList parent; private final boolean isStared; private final int allPointSum; + private final QPalette palette; private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/"); @@ -85,9 +87,9 @@ public class RensoNoteListItem extends QWidget{ String kaigyo = System.getProperty("line.separator"); this.noteContent = this.noteContent.replaceAll(kaigyo, ""); - QPalette p = new QPalette(); - p.setColor(QPalette.ColorRole.Window, new QColor(255, 255, 255)); - this.setPalette(p); + palette = new QPalette(); + palette.setColor(QPalette.ColorRole.Window, new QColor(255, 255, 255)); + this.setPalette(palette); this.setAutoFillBackground(true); this.setBackgroundRole(QPalette.ColorRole.Window); } @@ -111,12 +113,6 @@ public class RensoNoteListItem extends QWidget{ QFont normalFont = new QFont(); normalFont.setPixelSize(12); - // 関連度 - double ratio = (double)relationPoints / allPointSum; - int green = (int) (255 * (1.0 - ratio)); - painter.setPen(new QColor(255, green, 0)); - painter.setFont(relationFont); - painter.drawText(70, size().height() - 30, size().width() - 70, 30, Qt.AlignmentFlag.AlignRight.value(), String.valueOf((int)(ratio * 100)) + "%"); // タイトル painter.setPen(QColor.black); painter.setFont(titleFont); @@ -129,11 +125,34 @@ public class RensoNoteListItem extends QWidget{ painter.setPen(QColor.black); painter.drawText(165, 23, size().width() - 165, 17, Qt.AlignmentFlag.AlignLeft.value(), tagNames); // ノート内容 + QPen tmpPen = painter.pen(); + painter.setPen(new QColor(100, 100, 100)); QTextOption option = new QTextOption(); option.setAlignment(Qt.AlignmentFlag.AlignLeft); option.setUseDesignMetrics(true); - painter.drawText(new QRectF(85, 40, width() - 85, 40), noteContent, option); + painter.drawText(new QRectF(85, 40, width() - 85, 45), noteContent, option); + painter.setPen(tmpPen); + // 関連度 + double ratio = (double)relationPoints / allPointSum; + QColor relationColor; + if (ratio >= 0.8) { + relationColor = new QColor(255, 0, 0); + } else if (ratio >= 0.5) { + relationColor = new QColor(255, 100, 0); + } else { + relationColor = new QColor(255, 200, 0); + } + painter.setFont(relationFont); + tmpPen = painter.pen(); + painter.setPen(this.palette().color(QPalette.ColorRole.Window)); + painter.drawText(size().width() - 70, size().height() - 33, 67, 33, Qt.AlignmentFlag.AlignRight.value(), String.valueOf((int)(ratio * 100)) + "%"); + painter.drawText(size().width() - 70, size().height() - 33, 73, 33, Qt.AlignmentFlag.AlignRight.value(), String.valueOf((int)(ratio * 100)) + "%"); + painter.drawText(70, size().height() - 36, size().width() - 70, 36, Qt.AlignmentFlag.AlignRight.value(), String.valueOf((int)(ratio * 100)) + "%"); + painter.drawText(70, size().height() - 30, size().width() - 70, 30, Qt.AlignmentFlag.AlignRight.value(), String.valueOf((int)(ratio * 100)) + "%"); + painter.setPen(relationColor); + painter.drawText(70, size().height() - 33, size().width() - 70, 33, Qt.AlignmentFlag.AlignRight.value(), String.valueOf((int)(ratio * 100)) + "%"); + painter.setPen(tmpPen); // サムネイル QImage img; String thumbnailName = Global.getFileManager().getResDirPath("thumbnail-" + noteGuid + ".png"); @@ -161,9 +180,8 @@ public class RensoNoteListItem extends QWidget{ @Override protected void enterEvent(QEvent e){ if (!parent.isContextMenuVisible()) { - QPalette p = new QPalette(); - p.setColor(QPalette.ColorRole.Window, new QColor(225, 235, 255)); - this.setPalette(p); + palette.setColor(QPalette.ColorRole.Window, new QColor(225, 235, 255)); + this.setPalette(palette); } } @@ -176,16 +194,15 @@ public class RensoNoteListItem extends QWidget{ @Override protected void mousePressEvent(QMouseEvent e) { - QPalette p = new QPalette(); - p.setColor(QPalette.ColorRole.Window, new QColor(165, 175, 255)); - this.setPalette(p); + + palette.setColor(QPalette.ColorRole.Window, new QColor(165, 175, 255)); + this.setPalette(palette); super.mousePressEvent(e); } public void setDefaultBackground() { - QPalette p = new QPalette(); - p.setColor(QPalette.ColorRole.Window, new QColor(255, 255, 255)); - this.setPalette(p); + palette.setColor(QPalette.ColorRole.Window, new QColor(255, 255, 255)); + this.setPalette(palette); } } diff --git a/src/cx/fbn/nevernote/gui/TabBrowserWidget.java b/src/cx/fbn/nevernote/gui/TabBrowserWidget.java index 3232e30..83debac 100644 --- a/src/cx/fbn/nevernote/gui/TabBrowserWidget.java +++ b/src/cx/fbn/nevernote/gui/TabBrowserWidget.java @@ -48,12 +48,5 @@ public class TabBrowserWidget extends QTabWidget { bar.setTabTitle(index, title); this.setTabToolTip(index, title); } - - public int insertNewTab(int index, QWidget widget, String title) { - int trueIndex = this.insertTab(index, widget, new String()); - bar.addNewTab(trueIndex, title); - this.setTabToolTip(trueIndex, title); - return trueIndex; - } } diff --git a/src/cx/fbn/nevernote/sql/DatabaseConnection.java b/src/cx/fbn/nevernote/sql/DatabaseConnection.java index ef314b5..72caf26 100644 --- a/src/cx/fbn/nevernote/sql/DatabaseConnection.java +++ b/src/cx/fbn/nevernote/sql/DatabaseConnection.java @@ -209,62 +209,6 @@ public class DatabaseConnection { } public void upgradeDb(String version) { - if (version.equals("0.85")) { - executeSql("alter table note add column titleColor integer"); - executeSql("alter table note add column thumbnail blob"); - executeSql("alter table note add column thumbnailneeded boolean"); - executeSql("Update note set thumbnailneeded = true;"); - executeSql("create index NOTE_NOTEBOOK_INDEX on note (notebookguid, guid);"); - executeSql("create index NOTETAGS_TAG_INDEX on notetags (tagguid, noteguid);"); - version = "0.86"; - Global.setDatabaseVersion(version); - } - if (version.equals("0.86")) { - - executeSql("alter table notebook add column publishingUri VarChar"); - executeSql("alter table notebook add column publishingOrder Integer"); - executeSql("alter table notebook add column publishingAscending Boolean"); - executeSql("alter table notebook add column publishingPublicDescription varchar"); - executeSql("alter table notebook add column stack varchar"); - executeSql("alter table notebook add column icon blob"); - executeSql("alter table notebook add column readOnly boolean"); - executeSql("alter table notebook add column linked boolean"); - - executeSql("alter table tag add column realname varchar"); - executeSql("alter table tag add column linked boolean"); - executeSql("alter table tag add column icon blob"); - executeSql("alter table tag add column notebookguid varchar"); - executeSql("alter table SavedSearch add column icon blob"); - - executeSql("create index NOTE_THUMBNAIL_INDEX on note (thumbnailneeded, guid);"); - executeSql("create index NOTE_EXPUNGED_INDEX on note (isExpunged, guid);"); - executeSql("create index NOTE_DUEDATE_INDEX on note (attributeSubjectDate, guid);"); - executeSql("create index TAG_NOTEBOOK_INDEX on tag (notebookGuid);"); - - executeSql("update note set thumbnailneeded=true, thumbnail=null;"); - executeSql("update notebook set publishingUri='', " + - "publishingAscending=false, stack='', readonly=false, publishingOrder=1, " + - "publishingPublicDescription='', linked=false"); - executeSql("update tag set linked=false, realname='', notebookguid=''"); - - sharedNotebookTable.createTable(); - linkedNotebookTable.createTable(); - systemIconTable.createTable(); - inkImagesTable.createTable(); - - version = "0.95"; - executeSql("Insert into Sync (key, value) values ('FullNotebookSync', 'true')"); - executeSql("Insert into Sync (key, value) values ('FullLinkedNotebookSync', 'true')"); - executeSql("Insert into Sync (key, value) values ('FullSharedNotebookSync', 'true')"); - executeSql("Insert into Sync (key, value) values ('FullInkNoteImageSync', 'true')"); - Global.setDatabaseVersion(version); - } - if (version.equals("0.95")) { - if (dbTableExists("words")) - executeSql("Drop table words;"); - if (dbTableExists("NoteResources")) - executeSql("Drop table NoteResources;"); - } if (!dbTableColumnExists("NOTE", "ORIGINAL_GUID")) { executeSql("alter table note add column ORIGINAL_GUID VarChar"); executeSql("create index NOTE_ORIGINAL_GUID_INDEX on note (original_guid, guid);"); diff --git a/src/cx/fbn/nevernote/sql/HistoryTable.java b/src/cx/fbn/nevernote/sql/HistoryTable.java index a89fca3..3ba31bf 100644 --- a/src/cx/fbn/nevernote/sql/HistoryTable.java +++ b/src/cx/fbn/nevernote/sql/HistoryTable.java @@ -300,4 +300,13 @@ public class HistoryTable { } } } + + // 操作履歴数の取得 + public int getHistoryCount() { + NSqlQuery query = new NSqlQuery(db.getBehaviorConnection()); + query.exec("Select count(*) from History"); + query.next(); + int returnValue = new Integer(query.valueString(0)); + return returnValue; + } }