+
+ if(lineSep.isEmpty())
+ return;
+
+ QStringList lines = newText.split(lineSep, QString::SkipEmptyParts);
+
+ if(lines.count() >= 4) {
+ QString msg = tr("Do you really want to paste %n lines?", "", lines.count());
+ msg += "<p>";
+ for(int i = 0; i < 3; i++) {
+ msg += lines[i].left(40);
+ if(lines[i].count() > 40)
+ msg += "...";
+ msg += "<br />";
+ }
+ msg += "...</p>";
+ QMessageBox question(QMessageBox::NoIcon, tr("Paste Protection"), msg, QMessageBox::Yes|QMessageBox::No);
+ question.setDefaultButton(QMessageBox::No);
+#ifdef Q_WS_MAC
+ question.setWindowFlags(question.windowFlags() | Qt::Sheet); // Qt::Sheet is not ignored on other platforms as it should :/
+#endif
+ if(question.exec() == QMessageBox::No) {
+ clear();
+ return;
+ }
+ }
+
+ foreach(QString line, lines) {
+ if(!line.isEmpty()) {
+ resetLine();
+ insert(line);
+ emit returnPressed();
+ }
+ }
+
+// if(newText.contains(lineSep)) {
+// clear();
+// QString line = newText.section(lineSep, 0, 0);
+// QString remainder = newText.section(lineSep, 1);
+// insert(line);
+// emit returnPressed();
+// insert(remainder);
+// }
+}
+
+void InputLine::resetLine() {
+ // every time the InputLine is cleared we also reset history index
+ idx = history.count();
+ clear();
+ QTextBlockFormat format = textCursor().blockFormat();
+ format.setLeftMargin(leftMargin); // we want a little space between the frame and the contents
+ textCursor().setBlockFormat(format);
+}
+
+void InputLine::showHistoryEntry() {
+ // if the user changed the history, display the changed line
+ setPlainText(tempHistory.contains(idx) ? tempHistory[idx] : history[idx]);
+ QTextCursor cursor = textCursor();
+ QTextBlockFormat format = cursor.blockFormat();
+ format.setLeftMargin(leftMargin); // we want a little space between the frame and the contents
+ cursor.setBlockFormat(format);
+ cursor.movePosition(QTextCursor::End);
+ setTextCursor(cursor);