indexRunner.indexNoteBody = Global.indexNoteBody();
indexRunner.indexNoteTitle = Global.indexNoteTitle();
indexRunner.specialIndexCharacters = Global.getSpecialIndexCharacters();
indexThread.start();
synchronizeAnimationTimer = new QTimer();
synchronizeAnimationTimer.timeout.connect(this, "updateSyncButton()");
indexTimer = new QTimer();
indexTime = 1000*Global.getIndexThreadSleepInterval();
indexTimer.start(indexTime); // Start indexing timer
indexTimer.timeout.connect(this, "indexTimer()");
indexDisabled = false;
indexRunning = false;
logger.log(logger.EXTREME, "Setting sync thread & timers");
syncThreadsReady=1;
syncRunner = new SyncRunner("syncRunner.log",
Global.getDatabaseUrl(), Global.getIndexDatabaseUrl(), Global.getResourceDatabaseUrl(),
Global.getDatabaseUserid(), Global.getDatabaseUserPassword(), Global.cipherPassword);
syncTime = new SyncTimes().timeValue(Global.getSyncInterval());
syncTimer = new QTimer();
syncTimer.timeout.connect(this, "syncTimer()");
syncRunner.status.message.connect(this, "setMessage(String)");
syncRunner.syncSignal.finished.connect(this, "syncThreadComplete(Boolean)");
syncRunner.syncSignal.errorDisconnect.connect(this, "remoteErrorDisconnect()");
syncRunning = false;
if (syncTime > 0) {
automaticSync = true;
syncTimer.start(syncTime*60*1000);
} else {
automaticSync = false;
syncTimer.stop();
}
syncRunner.setEvernoteUpdateCount(Global.getEvernoteUpdateCount());
syncThread = new QThread(syncRunner, "Synchronization Thread");
syncThread.start();
logger.log(logger.EXTREME, "Starting thumnail thread");
pdfReadyQueue = new ArrayList<String>();
thumbnailRunner = new ThumbnailRunner("thumbnailRunner.log",
Global.getDatabaseUrl(), Global.getIndexDatabaseUrl(), Global.getResourceDatabaseUrl(),
Global.getDatabaseUserid(), Global.getDatabaseUserPassword(), Global.cipherPassword);
thumbnailThread = new QThread(thumbnailRunner, "Thumbnail Thread");
thumbnailRunner.noteSignal.thumbnailPageReady.connect(this, "thumbnailHTMLReady(String,QByteArray,Integer)");
thumbnailThread.start();
thumbGenerators = new ArrayList<Thumbnailer>();
thumbnailTimer = new QTimer();
thumbnailTimer.timeout.connect(this, "thumbnailTimer()");
thumbnailTimer();
thumbnailTimer.setInterval(500*1000); // Thumbnail every minute
thumbnailTimer.start();
// debugTimer = new QTimer();
// debugTimer.timeout.connect(this, "debugDirty()");
// debugTimer.start(1000*60);
logger.log(logger.EXTREME, "Starting authentication timer");
authTimer = new QTimer();
authTimer.timeout.connect(this, "authTimer()");
authTimer.start(1000*60*15);
syncRunner.syncSignal.authRefreshComplete.connect(this, "authRefreshComplete(boolean)");
logger.log(logger.EXTREME, "Setting save note timer");
saveTimer = new QTimer();
saveTimer.timeout.connect(this, "saveNote()");
if (Global.getAutoSaveInterval() > 0) {
saveTimer.setInterval(1000*60*Global.getAutoSaveInterval());
saveTimer.start();
}
listManager.saveRunner.noteSignals.noteSaveRunnerError.connect(this, "saveRunnerError(String, String)");
logger.log(logger.EXTREME, "Starting external file monitor timer");
externalFileSaveTimer = new QTimer();
externalFileSaveTimer.timeout.connect(this, "externalFileEditedSaver()");
externalFileSaveTimer.setInterval(1000*5); // save every 5 seconds;
externalFiles = new ArrayList<String>();
importFilesDelete = new ArrayList<String>();
importFilesKeep = new ArrayList<String>();
externalFileSaveTimer.start();
notebookTree = new NotebookTreeWidget(conn);
attributeTree = new AttributeTreeWidget();
tagTree = new TagTreeWidget(conn);
savedSearchTree = new SavedSearchTreeWidget();
trashTree = new TrashTreeWidget();
noteTableView = new TableView(logger, listManager);
searchField = new QComboBox();
searchField.setObjectName("searchField");
//setStyleSheet("QComboBox#searchField { background-color: yellow }");
searchField.setEditable(true);
searchField.activatedIndex.connect(this, "searchFieldChanged()");
searchField.setDuplicatesEnabled(false);
searchField.editTextChanged.connect(this,"searchFieldTextChanged(String)");
searchShortcut = new QShortcut(this);
setupShortcut(searchShortcut, "Focus_Search");
searchShortcut.activated.connect(this, "focusSearch()");
quotaBar = new QuotaProgressBar();
// Setup the zoom
zoomSpinner = new QSpinBox();
zoomSpinner.setMinimum(10);
zoomSpinner.setMaximum(1000);
zoomSpinner.setAccelerated(true);
zoomSpinner.setSingleStep(10);
zoomSpinner.setValue(100);
zoomSpinner.valueChanged.connect(this, "zoomChanged()");
searchLayout = new SearchPanel(searchField, quotaBar, notebookTree, zoomSpinner);
QGridLayout leftGrid = new QGridLayout();
leftSplitter1.setContentsMargins(5, 0, 0, 7);
leftSplitter1.setLayout(leftGrid);
leftGrid.addWidget(searchLayout,1,1);
leftGrid.addWidget(tagTree,2,1);
leftGrid.addWidget(attributeTree,3,1);
leftGrid.addWidget(savedSearchTree,4,1);
leftGrid.addWidget(trashTree,5, 1);
// Setup the browser window
noteCache = new HashMap<String,String>();
readOnlyCache = new HashMap<String, Boolean>();
inkNoteCache = new HashMap<String, Boolean>();
browserWindow = new BrowserWindow(conn);
mainLeftRightSplitter.addWidget(leftSplitter1);
mainLeftRightSplitter.addWidget(browserIndexSplitter);
if (Global.getListView() == Global.View_List_Wide) {
browserIndexSplitter.addWidget(noteTableView);
browserIndexSplitter.addWidget(browserWindow);
} else {
mainLeftRightSplitter.addWidget(noteTableView);
mainLeftRightSplitter.addWidget(browserWindow);
}
// Setup the thumbnail viewer
thumbnailViewer = new ThumbnailViewer();
thumbnailViewer.upArrow.connect(this, "upAction()");
thumbnailViewer.downArrow.connect(this, "downAction()");
thumbnailViewer.leftArrow.connect(this, "nextViewedAction()");
thumbnailViewer.rightArrow.connect(this, "previousViewedAction()");
//Setup external browser manager
externalWindows = new HashMap<String, ExternalBrowse>();
listManager.loadNotesIndex();
initializeNotebookTree();
initializeTagTree();
initializeSavedSearchTree();
attributeTree.itemClicked.connect(this, "attributeTreeClicked(QTreeWidgetItem, Integer)");
attributeTreeSelected = null;
initializeNoteTable();
selectedNoteGUIDs = new ArrayList<String>();
statusBar = new QStatusBar();
setStatusBar(statusBar);
menuBar = new MainMenuBar(this);
emitLog = new ArrayList<String>();
tagTree.setDeleteAction(menuBar.tagDeleteAction);
tagTree.setMergeAction(menuBar.tagMergeAction);
tagTree.setEditAction(menuBar.tagEditAction);
tagTree.setAddAction(menuBar.tagAddAction);
tagTree.setIconAction(menuBar.tagIconAction);
tagTree.setVisible(Global.isWindowVisible("tagTree"));
leftSplitter1.setVisible(Global.isWindowVisible("leftPanel"));
tagTree.noteSignal.tagsAdded.connect(this, "tagsAdded(String, String)");
menuBar.hideTags.setChecked(Global.isWindowVisible("tagTree"));
listManager.tagSignal.listChanged.connect(this, "reloadTagTree()");
if (!Global.isWindowVisible("zoom")) {
searchLayout.hideZoom();
menuBar.hideZoom.setChecked(false);
}
notebookTree.setDeleteAction(menuBar.notebookDeleteAction);
notebookTree.setEditAction(menuBar.notebookEditAction);
notebookTree.setAddAction(menuBar.notebookAddAction);
notebookTree.setIconAction(menuBar.notebookIconAction);
notebookTree.setStackAction(menuBar.notebookStackAction);
notebookTree.setPublishAction(menuBar.notebookPublishAction);
notebookTree.setShareAction(menuBar.notebookShareAction);
notebookTree.setVisible(Global.isWindowVisible("notebookTree"));
notebookTree.noteSignal.notebookChanged.connect(this, "updateNoteNotebook(String, String)");
notebookTree.noteSignal.tagsChanged.connect(this, "updateNoteTags(String, List)");
notebookTree.noteSignal.tagsChanged.connect(this, "updateListTags(String, List)");
menuBar.hideNotebooks.setChecked(Global.isWindowVisible("notebookTree"));
savedSearchTree.setAddAction(menuBar.savedSearchAddAction);
savedSearchTree.setEditAction(menuBar.savedSearchEditAction);
savedSearchTree.setDeleteAction(menuBar.savedSearchDeleteAction);
savedSearchTree.setIconAction(menuBar.savedSearchIconAction);
savedSearchTree.itemSelectionChanged.connect(this, "updateSavedSearchSelection()");
savedSearchTree.setVisible(Global.isWindowVisible("savedSearchTree"));
menuBar.hideSavedSearches.setChecked(Global.isWindowVisible("savedSearchTree"));
noteTableView.setAddAction(menuBar.noteAdd);
noteTableView.setDeleteAction(menuBar.noteDelete);
noteTableView.setRestoreAction(menuBar.noteRestoreAction);
noteTableView.setNoteDuplicateAction(menuBar.noteDuplicateAction);
noteTableView.setNoteHistoryAction(menuBar.noteOnlineHistoryAction);
noteTableView.noteSignal.titleColorChanged.connect(this, "titleColorChanged(Integer)");
noteTableView.noteSignal.notePinned.connect(this, "notePinned()");
noteTableView.setMergeNotesAction(menuBar.noteMergeAction);
noteTableView.setCopyAsUrlAction(menuBar.noteCopyAsUrlAction);
noteTableView.doubleClicked.connect(this, "listDoubleClick()");
listManager.trashSignal.countChanged.connect(trashTree, "updateCounts(Integer)");
quotaBar.setMouseClickAction(menuBar.accountAction);
trashTree.load();
trashTree.itemSelectionChanged.connect(this, "trashTreeSelection()");
trashTree.setEmptyAction(menuBar.emptyTrashAction);
trashTree.setVisible(Global.isWindowVisible("trashTree"));
menuBar.hideTrash.setChecked(Global.isWindowVisible("trashTree"));
trashTree.updateCounts(listManager.getTrashCount());
attributeTree.setVisible(Global.isWindowVisible("attributeTree"));
menuBar.hideAttributes.setChecked(Global.isWindowVisible("attributeTree"));
noteTableView.setVisible(Global.isWindowVisible("noteList"));
menuBar.hideNoteList.setChecked(Global.isWindowVisible("noteList"));
if (!Global.isWindowVisible("editorButtonBar"))
toggleEditorButtonBar();
if (!Global.isWindowVisible("leftPanel"))
menuBar.hideLeftSide.setChecked(true);
if (Global.isWindowVisible("noteInformation"))
toggleNoteInformation();
quotaBar.setVisible(Global.isWindowVisible("quota"));
if (!quotaBar.isVisible())
menuBar.hideQuota.setChecked(false);
searchField.setVisible(Global.isWindowVisible("searchField"));
if (!searchField.isVisible())
menuBar.hideSearch.setChecked(false);
if (searchField.isHidden() && quotaBar.isHidden() && zoomSpinner.isHidden() && notebookTree.isHidden())
searchLayout.hide();
setMenuBar(menuBar);
setupToolBar();
find = new FindDialog();
find.getOkButton().clicked.connect(this, "doFindText()");
// Setup the tray icon menu bar
trayShowAction = new QAction(tr("Show/Hide"), this);
trayExitAction = new QAction(tr("Exit"), this);
trayAddNoteAction = new QAction(tr("Add Note"), this);
trayExitAction.triggered.connect(this, "closeNeverNote()");
trayAddNoteAction.triggered.connect(this, "addNote()");
trayShowAction.triggered.connect(this, "trayToggleVisible()");
trayMenu = new QMenu(this);
trayMenu.addAction(trayAddNoteAction);
trayMenu.addAction(trayShowAction);
trayMenu.addAction(trayExitAction);
trayIcon = new QSystemTrayIcon(this);
trayIcon.setToolTip(tr("NixNote"));
trayIcon.setContextMenu(trayMenu);
trayIcon.activated.connect(this, "trayActivated(com.trolltech.qt.gui.QSystemTrayIcon$ActivationReason)");
currentNoteGuid="";
currentNoteGuid = Global.getLastViewedNoteGuid();
if (currentNoteGuid.equals(""))
currentNote = new Note();
historyGuids = new ArrayList<String>();
historyPosition = 0;
fromHistory = false;
noteDirty = false;
if (!currentNoteGuid.trim().equals("")) {
currentNote = conn.getNoteTable().getNote(currentNoteGuid, true,true,false,false,true);
}
noteIndexUpdated(true);
showColumns();
menuBar.showEditorBar.setChecked(Global.isWindowVisible("editorButtonBar"));
if (menuBar.showEditorBar.isChecked())
showEditorButtons(browserWindow);
tagIndexUpdated(true);
savedSearchIndexUpdated();
notebookIndexUpdated();
updateQuotaBar();
setupSyncSignalListeners();
setupBrowserSignalListeners();
setupIndexListeners();
tagTree.tagSignal.listChanged.connect(this, "tagIndexUpdated()");
tagTree.showAllTags(true);
QIcon appIcon = new QIcon(iconPath+"nevernote.png");
if (QSystemTrayIcon.isSystemTrayAvailable()) {
setWindowIcon(appIcon);
trayIcon.setIcon(appIcon);
if (Global.showTrayIcon() || Global.minimizeOnClose())
trayIcon.show();
else
trayIcon.hide();
}
scrollToGuid(currentNoteGuid);
if (Global.automaticLogin()) {
remoteConnect();
if (Global.isConnected)
syncTimer();
}
setupFolderImports();
loadStyleSheet();
restoreWindowState(true);
if (Global.mimicEvernoteInterface) {
notebookTree.selectGuid("");
}
threadMonitorTimer = new QTimer();
threadMonitorTimer.timeout.connect(this, "threadMonitorCheck()");
threadMonitorTimer.start(1000*10); // Check for threads every 10 seconds;
historyGuids.add(currentNoteGuid);
historyPosition = 1;
menuBar.blockSignals(true);
menuBar.narrowListView.blockSignals(true);
menuBar.wideListView.blockSignals(true);
if (Global.getListView() == Global.View_List_Narrow) {
menuBar.narrowListView.setChecked(true);
}
else{
menuBar.wideListView.setChecked(true);
}
menuBar.blockSignals(false);
menuBar.narrowListView.blockSignals(false);
menuBar.wideListView.blockSignals(false);
if (Global.getListView() == Global.View_List_Wide) {
browserIndexSplitter.addWidget(noteTableView);
browserIndexSplitter.addWidget(browserWindow);
} else {
mainLeftRightSplitter.addWidget(noteTableView);
mainLeftRightSplitter.addWidget(browserWindow);
}
messageTimer = new QTimer();
messageTimer.timeout.connect(this, "clearMessage()");
messageTimer.setInterval(1000*15);
clearMessage();
int sortCol = Global.getSortColumn();