From 05f2bc8392e8fa584ac05feed2287f6d5798702a Mon Sep 17 00:00:00 2001 From: Jeff Date: Thu, 20 Aug 2015 22:27:46 -0400 Subject: [PATCH] Fix Conflicts --- cockatrice/CMakeLists.txt | 5 +- cockatrice/src/tab_game.h | 8 +-- cockatrice/src/tab_room.cpp | 127 +----------------------------------- 3 files changed, 5 insertions(+), 135 deletions(-) diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index 2bb24f1c..8efc1e0e 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -94,13 +94,10 @@ SET(cockatrice_SOURCES src/qt-json/json.cpp src/soundengine.cpp src/pending_command.cpp -<<<<<<< HEAD - src/lineeditcompleter.cpp -======= src/shortcutssettings.cpp src/sequenceEdit/sequenceedit.cpp src/sequenceEdit/shortcutstab.cpp ->>>>>>> master + src/lineeditcompleter.cpp ${VERSION_STRING_CPP} ) diff --git a/cockatrice/src/tab_game.h b/cockatrice/src/tab_game.h index abda4b8a..5b13ffdd 100644 --- a/cockatrice/src/tab_game.h +++ b/cockatrice/src/tab_game.h @@ -204,12 +204,10 @@ private slots: void addMentionTag(QString value); void commandFinished(const Response &response); -<<<<<<< HEAD - - void actCompleterChanged(); -======= + void refreshShortcuts(); ->>>>>>> master + + void actCompleterChanged(); public: TabGame(TabSupervisor *_tabSupervisor, QList &_clients, const Event_GameJoined &event, const QMap &_roomGameTypes); TabGame(TabSupervisor *_tabSupervisor, GameReplay *replay); diff --git a/cockatrice/src/tab_room.cpp b/cockatrice/src/tab_room.cpp index f044b47f..bdf19192 100644 --- a/cockatrice/src/tab_room.cpp +++ b/cockatrice/src/tab_room.cpp @@ -296,129 +296,4 @@ PendingCommand *TabRoom::prepareRoomCommand(const ::google::protobuf::Message &c void TabRoom::sendRoomCommand(PendingCommand *pend) { client->sendCommand(pend); -<<<<<<< HEAD -} -======= -} - -CustomLineEdit::CustomLineEdit(QWidget *parent) - : QLineEdit(parent) -{ -} - -void CustomLineEdit::focusOutEvent(QFocusEvent * e){ - QLineEdit::focusOutEvent(e); - if (c->popup()->isVisible()){ - //Remove Popup - c->popup()->hide(); - //Truncate the line to last space or whole string - QString textValue = text(); - int lastIndex = textValue.length(); - int lastWordStartIndex = textValue.lastIndexOf(" ") + 1; - int leftShift = qMin(lastIndex, lastWordStartIndex); - setText(textValue.left(leftShift)); - //Insert highlighted line from popup - insert(c->completionModel()->index(c->popup()->currentIndex().row(), 0).data().toString() + " "); - //Set focus back to the textbox since tab was pressed - setFocus(); - } -} - -void CustomLineEdit::keyPressEvent(QKeyEvent * event) -{ - switch (event->key()){ - case Qt::Key_Return: - case Qt::Key_Enter: - case Qt::Key_Escape: - if (c->popup()->isVisible()){ - event->ignore(); - //Remove Popup - c->popup()->hide(); - //Truncate the line to last space or whole string - QString textValue = text(); - int lastIndexof = textValue.lastIndexOf(" "); - QString finalString = textValue.left(lastIndexof); - //Add a space if there's a word - if (finalString != "") - finalString += " "; - setText(finalString); - return; - } - break; - case Qt::Key_Space: - if (c->popup()->isVisible()){ - event->ignore(); - //Remove Popup - c->popup()->hide(); - //Truncate the line to last space or whole string - QString textValue = text(); - int lastIndex = textValue.length(); - int lastWordStartIndex = textValue.lastIndexOf(" ") + 1; - int leftShift = qMin(lastIndex, lastWordStartIndex); - setText(textValue.left(leftShift)); - //Insert highlighted line from popup - insert(c->completionModel()->index(c->popup()->currentIndex().row(), 0).data().toString() + " "); - return; - } - break; - default: - break; - } - - QLineEdit::keyPressEvent(event); - //Wait until the first character after @ - if (!c || text().right(1).contains("@")) - return; - - //Set new completion prefix - c->setCompletionPrefix(cursorWord(text())); - if (c->completionPrefix().length() < 1){ - c->popup()->hide(); - return; - } - - //Draw completion box - QRect cr = cursorRect(); - cr.setWidth(c->popup()->sizeHintForColumn(0) + c->popup()->verticalScrollBar()->sizeHint().width()); - c->complete(cr); - - //Select first item in the completion popup - QItemSelectionModel* sm = new QItemSelectionModel(c->completionModel()); - c->popup()->setSelectionModel(sm); - sm->select(c->completionModel()->index(0, 0), QItemSelectionModel::ClearAndSelect); - sm->setCurrentIndex(c->completionModel()->index(0, 0), QItemSelectionModel::NoUpdate); -} - -QString CustomLineEdit::cursorWord(const QString &line) const -{ - return line.mid(line.left(cursorPosition()).lastIndexOf(" ") + 1, - cursorPosition() - line.left(cursorPosition()).lastIndexOf(" ") - 1); -} - -void CustomLineEdit::insertCompletion(QString arg) -{ - QString s_arg = arg + " "; - setText(text().replace(text().left(cursorPosition()).lastIndexOf(" ") + 1, - cursorPosition() - text().left(cursorPosition()).lastIndexOf(" ") - 1, s_arg)); -} - -void CustomLineEdit::setCompleter(QCompleter* completer) -{ - c = completer; - c->setWidget(this); - connect(c, SIGNAL(activated(QString)),this, SLOT(insertCompletion(QString))); -} - -void CustomLineEdit::updateCompleterModel(QStringList completionList) -{ - if (!c || c->popup()->isVisible()) - return; - - QStringListModel *model; - model = (QStringListModel*)(c->model()); - if (model == NULL) - model = new QStringListModel(); - QStringList updatedList = completionList; - model->setStringList(updatedList); -} ->>>>>>> master +} \ No newline at end of file