}
// Edit an existing notebook
@SuppressWarnings("unused")
private void editNotebook() {
logger.log(logger.HIGH, "Entering NeverNote.editNotebook");
NotebookEdit edit = new NotebookEdit();
List<QTreeWidgetItem> selections = notebookTree.selectedItems();
QTreeWidgetItem currentSelection;
currentSelection = selections.get(0);
edit.setNotebook(currentSelection.text(0));
String guid = currentSelection.text(2);
if (!guid.equalsIgnoreCase("STACK")) {
edit.setTitle(tr("Edit Notebook"));
edit.setNotebooks(listManager.getNotebookIndex());
edit.setLocalCheckboxEnabled(false);
for (int i=0; i<listManager.getNotebookIndex().size(); i++) {
if (listManager.getNotebookIndex().get(i).getGuid().equals(guid)) {
edit.setDefaultNotebook(listManager.getNotebookIndex().get(i).isDefaultNotebook());
i=listManager.getNotebookIndex().size();
}
}
} else {
edit.setTitle(tr("Edit Stack"));
edit.setStacks(conn.getNotebookTable().getAllStackNames());
edit.hideLocalCheckbox();
edit.hideDefaultCheckbox();
}
edit.exec();
if (!edit.okPressed())
return;
if (guid.equalsIgnoreCase("STACK")) {
conn.getNotebookTable().renameStacks(currentSelection.text(0), edit.getNotebook());
for (int j=0; j<listManager.getNotebookIndex().size(); j++) {
if (listManager.getNotebookIndex().get(j).getStack() != null &&
listManager.getNotebookIndex().get(j).getStack().equalsIgnoreCase(currentSelection.text(0)))
listManager.getNotebookIndex().get(j).setStack(edit.getNotebook());
}
conn.getNotebookTable().renameStacks(currentSelection.text(0), edit.getNotebook());
currentSelection.setText(0, edit.getNotebook());
return;
}
updateListNotebookName(currentSelection.text(0), edit.getNotebook());
currentSelection.setText(0, edit.getNotebook());
for (int i=0; i<listManager.getNotebookIndex().size(); i++) {
if (listManager.getNotebookIndex().get(i).getGuid().equals(guid)) {
listManager.getNotebookIndex().get(i).setName(edit.getNotebook());
if (!listManager.getNotebookIndex().get(i).isDefaultNotebook() && edit.isDefaultNotebook()) {
for (int j=0; j<listManager.getNotebookIndex().size(); j++)
listManager.getNotebookIndex().get(j).setDefaultNotebook(false);
listManager.getNotebookIndex().get(i).setDefaultNotebook(true);
conn.getNotebookTable().setDefaultNotebook(listManager.getNotebookIndex().get(i).getGuid());
}
conn.getNotebookTable().updateNotebook(listManager.getNotebookIndex().get(i), true);
if (conn.getNotebookTable().isLinked(listManager.getNotebookIndex().get(i).getGuid())) {
LinkedNotebook linkedNotebook = conn.getLinkedNotebookTable().getByNotebookGuid(listManager.getNotebookIndex().get(i).getGuid());
linkedNotebook.setShareName(edit.getNotebook());
conn.getLinkedNotebookTable().updateNotebook(linkedNotebook, true);
}
i=listManager.getNotebookIndex().size();
}
}