import java.text.SimpleDateFormat;\r
import java.util.ArrayList;\r
import java.util.Calendar;\r
+import java.util.Collections;\r
import java.util.Date;\r
import java.util.GregorianCalendar;\r
import java.util.HashMap;\r
private final QComboBox geoBox;\r
public final TagLineEdit tagEdit;\r
public final QLabel tagLabel;\r
- private final QLabel urlLabel;\r
+ private final QPushButton urlLabel;\r
private final QLabel alteredLabel;\r
private final QDateEdit alteredDate;\r
private final QTimeEdit alteredTime;\r
urlText = new QLineEdit();\r
authorText = new QLineEdit();\r
geoBox = new QComboBox();\r
- urlLabel = new QLabel();\r
+ urlLabel = new QPushButton();\r
+ urlLabel.clicked.connect(this, "sourceUrlClicked()");\r
authorLabel = new QLabel();\r
conn = c;\r
\r
urlText.setText(t);\r
}\r
\r
+ // The user want's to launch a web browser on the source of the URL\r
+ public void sourceUrlClicked() {\r
+ // Make sure we have a valid URL\r
+ if (urlText.text().trim().equals(""))\r
+ return;\r
+ \r
+ String url = urlText.text();\r
+ if (!url.toLowerCase().startsWith(tr("http://")))\r
+ url = tr("http://") +url;\r
+ \r
+ if (!QDesktopServices.openUrl(new QUrl(url))) {\r
+ logger.log(logger.LOW, "Error opening file :" +url);\r
+ }\r
+ }\r
+ \r
public void setAuthor(String t) {\r
authorLabel.setText(tr("Author:\t"));\r
authorText.setText(t);\r
// Tag line has been modified by typing text\r
@SuppressWarnings("unused")\r
private void modifyTagsTyping() {\r
+ String completionText = "";\r
if (tagEdit.currentCompleterSelection != null && !tagEdit.currentCompleterSelection.equals("")) {\r
- tagEdit.completeText(tagEdit.currentCompleterSelection);\r
+ completionText = tagEdit.currentCompleterSelection;\r
+ tagEdit.currentCompleterSelection = "";\r
}\r
\r
- \r
- String newTags = tagEdit.text();\r
- List<String> test = tagEdit.tagCompleter.getTagList();\r
- if (newTags.equalsIgnoreCase(saveTagList))\r
+ if (tagEdit.text().equalsIgnoreCase(saveTagList))\r
return;\r
\r
// We know something has changed...\r
String oldTagArray[] = saveTagList.split(Global.tagDelimeter);\r
- String newTagArray[] = newTags.split(Global.tagDelimeter);\r
+ String newTagArray[] = tagEdit.text().split(Global.tagDelimeter);\r
+ \r
+ if (!completionText.equals("") && newTagArray.length > 0) {\r
+ newTagArray[newTagArray.length-1] = completionText;\r
+ }\r
+ // Remove any potential duplicates from the new list\r
+ for (int i=0; i<newTagArray.length; i++) {\r
+ boolean foundOnce = false;\r
+ for (int j=0; j<newTagArray.length; j++) {\r
+ if (newTagArray[j].equalsIgnoreCase(newTagArray[i])) {\r
+ if (!foundOnce) {\r
+ foundOnce = true;\r
+ } else\r
+ newTagArray[j] = "";\r
+ }\r
+ }\r
+ }\r
\r
List<String> newTagList = new ArrayList<String>();\r
List<String> oldTagList = new ArrayList<String>();\r
if (!newTagArray[i].trim().equals(""))\r
newTagList.add(newTagArray[i]);\r
\r
+ // Let's cleanup the appearance of the tag list\r
+ Collections.sort(newTagList);\r
+ String newDisplay = "";\r
+ for (int i=0; i<newTagList.size(); i++) {\r
+ newDisplay = newDisplay+newTagList.get(i);\r
+ if (i<newTagList.size()-1)\r
+ newDisplay = newDisplay+", ";\r
+ }\r
+ tagEdit.blockSignals(true);\r
+ tagEdit.setText(newDisplay);\r
+ tagEdit.blockSignals(false);\r
+ \r
// We now have lists of the new & old. Remove duplicates. If all\r
// are removed from both then nothing has really changed\r
for (int i = newTagList.size() - 1; i >= 0; i--) {\r
\r
if (oldTagList.size() != 0 || newTagList.size() != 0) {\r
currentTags.clear();\r
+ newTagArray = tagEdit.text().split(Global.tagDelimeter);\r
for (int i = 0; i < newTagArray.length; i++)\r
if (!newTagArray[i].trim().equals(""))\r
currentTags.add(newTagArray[i].trim());\r
\r
noteSignal.tagsChanged.emit(currentNote.getGuid(), currentTags);\r
}\r
-\r
+ \r
}\r
\r
// Tab button was pressed\r
buffer.append("\" en-tag=en-media type=\"image/jpeg\""\r
+" hash=\""+Global.byteArrayToHexString(newRes.getData().getBodyHash()) +"\""\r
+" guid=\"" +newRes.getGuid() +"\""\r
- +" onContextMenu=\"window.jambi.imageContextMenu('" +tfile.fileName() +"');\""\r
+// +" onContextMenu=\"window.jambi.imageContextMenu('" +tfile.fileName() +"');\""\r
+ +" onContextMenu=\"window.jambi.imageContextMenu(&." +tfile.fileName() +"&.);\""\r
+ " />");\r
+ \r
browser.page().mainFrame().evaluateJavaScript(\r
script_start + buffer + script_end);\r
\r
icon = findIcon(type[0]);\r
if (icon.equals("attachment.png"))\r
icon = findIcon(url.substring(url.lastIndexOf(".")+1));\r
- StringBuffer imageBuffer = new StringBuffer();\r
String imageURL = FileUtils.toFileURLString(Global.getFileManager().getImageDirFile(icon));\r
\r
logger.log(logger.EXTREME, "Creating resource ");\r
noteSignal.authorChanged.emit(currentNote.getGuid(), authorText.text());\r
}\r
\r
+ @SuppressWarnings("unused")\r
private void geoBoxChanged() {\r
int index = geoBox.currentIndex();\r
geoBox.setCurrentIndex(0);\r