}
// This is really dead code. it is the beginning of logic to create stacks by
// dragging.
if (data.hasFormat("application/x-nevernote-notebook")) {
QByteArray d = data.data("application/x-nevernote-notebook");
String current = d.toString();
// If dropping to the top level, then remove the stack
if (parent == null) {
db.getNotebookTable().clearStack(current);
return true;
}
// If trying to drop under the "All notebooks" then ignore
if (parent.text(2).equals(""))
return false;
// If we are NOT droping directly onto the stack icon
// we need to find the stack widget
String stackName;
QTreeWidgetItem stackItem;
List<QTreeWidgetItem> currentItems = selectedItems();
if (!parent.text(2).equalsIgnoreCase("STACK")) {
// If a parent stack exists, then use it.
if (parent.parent() != null) {
stackName = parent.parent().text(0);
stackItem = parent.parent();
} else {
currentItems.add(parent);
// If a stack doesn't exist, then we need to create one
stackName = "New Stack";
// Find a new stack name that isn't in use
for (int i=1; i<101; i++) {
if (stacks.containsKey(stackName))
stackName = "New Stack(" +new Integer(i).toString() + ")";
else
break;
}
db.getNotebookTable().setStack(parent.text(2), stackName);
Qt.Alignment ra = new Qt.Alignment(Qt.AlignmentFlag.AlignRight);
stackItem = createStackIcon(stackName, ra);
addTopLevelItem(stackItem);
}
} else {
stackName = parent.text(0);
stackItem = parent;
}
List<QTreeWidgetItem> newItems = new ArrayList<QTreeWidgetItem>();
for (int i=0; i<currentItems.size(); i++) {
newItems.add(copyTreeItem(currentItems.get(i)));
currentItems.get(i).setHidden(true);
}
db.getNotebookTable().setStack(current, stackName);
stackItem.addChildren(newItems);
return true;
}
// If we are dropping a note onto a notebook
if (data.hasFormat("application/x-nevernote-note")) {
// If we are dropping onto a read-only notebook, we are done.
if (db.getNotebookTable().isReadOnly(parent.text(2)))
return false;
QByteArray d = data.data("application/x-nevernote-note");
String s = d.toString();
String noteGuidArray[] = s.split(" ");
for (String element : noteGuidArray) {
Note n = db.getNoteTable().getNote(element.trim(), false, false, false, false, true);
// We need to be sure that...