QTfrontend/ui/widget/hatprompt.cpp
author sheepluva
Thu, 23 Jan 2014 13:56:53 +0100
changeset 10061 b7161f00a6ca
parent 9998 736015b847e3
child 10108 c68cf030eded
permissions -rw-r--r--
hide complete IP of other users, when non-admin requests player info. showing the first two parts of the IP was kinda pointless to begin with (what for?) and has recently lead to increased abuse and lobby flooding due to bots collecting/posting IP tracking information
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8374
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
     1
/*
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
     2
 * Hedgewars, a free turn based strategy game
9998
736015b847e3 update copyright to 2014
sheepluva
parents: 9080
diff changeset
     3
 * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
8374
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
     4
 *
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
     8
 *
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    12
 * GNU General Public License for more details.
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    13
 *
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    17
 */
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    18
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    19
#include <QDialog>
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    20
#include <QGridLayout>
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    21
#include <QHBoxLayout>
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    22
#include <QScrollArea>
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    23
#include <QPushButton>
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    24
#include <QToolButton>
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    25
#include <QWidgetItem>
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    26
#include <QModelIndex>
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    27
#include <QListView>
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    28
#include <QLineEdit>
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    29
#include <QLabel>
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    30
#include <QSortFilterProxyModel>
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    31
#include <QDebug>
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    32
8375
af2d2f56bc45 Fix build
unc0rr
parents: 8374
diff changeset
    33
#include "DataManager.h"
8374
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    34
#include "lineeditcursor.h"
8375
af2d2f56bc45 Fix build
unc0rr
parents: 8374
diff changeset
    35
#include "HatModel.h"
8374
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    36
#include "hatprompt.h"
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    37
8731
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8488
diff changeset
    38
void HatListView::moveUp()
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8488
diff changeset
    39
{
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8488
diff changeset
    40
    setCurrentIndex(moveCursor(QAbstractItemView::MoveUp, Qt::NoModifier));
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8488
diff changeset
    41
}
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8488
diff changeset
    42
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8488
diff changeset
    43
void HatListView::moveDown()
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8488
diff changeset
    44
{
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8488
diff changeset
    45
    setCurrentIndex(moveCursor(QAbstractItemView::MoveDown, Qt::NoModifier));
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8488
diff changeset
    46
}
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8488
diff changeset
    47
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8488
diff changeset
    48
void HatListView::moveLeft()
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8488
diff changeset
    49
{
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8488
diff changeset
    50
    setCurrentIndex(moveCursor(QAbstractItemView::MoveLeft, Qt::NoModifier));
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8488
diff changeset
    51
}
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8488
diff changeset
    52
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8488
diff changeset
    53
void HatListView::moveRight()
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8488
diff changeset
    54
{
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8488
diff changeset
    55
    setCurrentIndex(moveCursor(QAbstractItemView::MoveRight, Qt::NoModifier));
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8488
diff changeset
    56
}
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8488
diff changeset
    57
8374
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    58
HatPrompt::HatPrompt(int currentIndex, QWidget* parent) : QDialog(parent)
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    59
{
8434
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
    60
    setModal(true);
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
    61
    setWindowFlags(Qt::Sheet);
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
    62
    setWindowModality(Qt::WindowModal);
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
    63
    setMinimumSize(550, 430);
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
    64
    resize(550, 430);
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
    65
    setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
8374
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    66
8434
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
    67
    setStyleSheet("QPushButton { padding: 5px; margin-top: 10px; }");
8374
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    68
8434
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
    69
    // Hat model, and a model for setting a filter
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
    70
    HatModel * hatModel = DataManager::instance().hatModel();
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
    71
    filterModel = new QSortFilterProxyModel();
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
    72
    filterModel->setSourceModel(hatModel);
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
    73
    filterModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
8374
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    74
8434
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
    75
    // Grid
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
    76
    QGridLayout * dialogLayout = new QGridLayout(this);
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
    77
    dialogLayout->setSpacing(0);
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
    78
    dialogLayout->setColumnStretch(1, 1);
8374
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    79
8434
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
    80
    QHBoxLayout * topLayout = new QHBoxLayout();
8374
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    81
8434
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
    82
    // Help/prompt message at top
8488
e72f3398a28b Removed in-lineedit labels such as "search:" and "room name:" due to size issues with localization and platform differences.
dag10
parents: 8453
diff changeset
    83
    QLabel * lblDesc = new QLabel(tr("Search for a hat:"));
8434
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
    84
    lblDesc->setObjectName("lblDesc");
8374
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    85
    lblDesc->setStyleSheet("#lblDesc { color: #130F2A; background: #F6CB1C; border: solid 4px #F6CB1C; border-top-left-radius: 10px; padding: 4px 10px;}");
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    86
    lblDesc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    87
    lblDesc->setFixedHeight(24);
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    88
    lblDesc->setMinimumWidth(0);
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    89
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    90
    // Filter text box
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    91
    QWidget * filterContainer = new QWidget();
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    92
    filterContainer->setFixedHeight(24);
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    93
    filterContainer->setObjectName("filterContainer");
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    94
    filterContainer->setStyleSheet("#filterContainer { background: #F6CB1C; border-top-right-radius: 10px; padding: 3px; }");
8488
e72f3398a28b Removed in-lineedit labels such as "search:" and "room name:" due to size issues with localization and platform differences.
dag10
parents: 8453
diff changeset
    95
    filterContainer->setFixedWidth(150);
8374
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    96
    txtFilter = new LineEditCursor(filterContainer);
8488
e72f3398a28b Removed in-lineedit labels such as "search:" and "room name:" due to size issues with localization and platform differences.
dag10
parents: 8453
diff changeset
    97
    txtFilter->setFixedWidth(150);
8374
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    98
    txtFilter->setFocus();
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
    99
    txtFilter->setFixedHeight(22);
8488
e72f3398a28b Removed in-lineedit labels such as "search:" and "room name:" due to size issues with localization and platform differences.
dag10
parents: 8453
diff changeset
   100
    txtFilter->setStyleSheet("LineEditCursor { border-width: 0px; border-radius: 6px; margin-top: 3px; margin-right: 3px; padding-left: 4px; padding-bottom: 2px; background-color: rgb(23, 11, 54); } LineEditCursor:hover, LineEditCursor:focus { background-color: rgb(13, 5, 68); }");
8374
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   101
    connect(txtFilter, SIGNAL(textChanged(const QString &)), this, SLOT(filterChanged(const QString &)));
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   102
    connect(txtFilter, SIGNAL(moveUp()), this, SLOT(moveUp()));
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   103
    connect(txtFilter, SIGNAL(moveDown()), this, SLOT(moveDown()));
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   104
    connect(txtFilter, SIGNAL(moveLeft()), this, SLOT(moveLeft()));
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   105
    connect(txtFilter, SIGNAL(moveRight()), this, SLOT(moveRight()));
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   106
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   107
    // Corner widget
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   108
    QLabel * corner = new QLabel();
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   109
    corner->setPixmap(QPixmap(QString::fromUtf8(":/res/inverse-corner-bl.png")));
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   110
    corner->setFixedSize(10, 10);
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   111
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   112
    // Add widgets to top layout
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   113
    topLayout->addWidget(lblDesc);
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   114
    topLayout->addWidget(filterContainer);
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   115
    topLayout->addWidget(corner, 0, Qt::AlignBottom);
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   116
    topLayout->addStretch(1);
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   117
8434
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
   118
    // Cancel button (closes dialog)
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
   119
    QPushButton * btnCancel = new QPushButton(tr("Cancel"));
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
   120
    connect(btnCancel, SIGNAL(clicked()), this, SLOT(reject()));
8374
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   121
8434
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
   122
    // Select button
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
   123
    QPushButton * btnSelect = new QPushButton(tr("Use selected hat"));
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
   124
    btnSelect->setDefault(true);
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
   125
    connect(btnSelect, SIGNAL(clicked()), this, SLOT(onAccepted()));
8374
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   126
8434
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
   127
    // Add hats
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
   128
    list = new HatListView();
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
   129
    list->setModel(filterModel);
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
   130
    list->setViewMode(QListView::IconMode);
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
   131
    list->setResizeMode(QListView::Adjust);
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
   132
    list->setMovement(QListView::Static);
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
   133
    list->setEditTriggers(QAbstractItemView::NoEditTriggers);
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
   134
    list->setSpacing(8);
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
   135
    list->setWordWrap(true);
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
   136
    list->setSelectionMode(QAbstractItemView::SingleSelection);
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
   137
    list->setObjectName("hatList");
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
   138
    list->setCurrentIndex(filterModel->index(currentIndex, 0));
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
   139
    connect(list, SIGNAL(activated(const QModelIndex &)), this, SLOT(hatChosen(const QModelIndex &)));
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
   140
    connect(list, SIGNAL(clicked(const QModelIndex &)), this, SLOT(hatChosen(const QModelIndex &)));
8374
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   141
8434
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
   142
    // Add elements to layouts
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
   143
    dialogLayout->addLayout(topLayout, 0, 0, 1, 3);
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
   144
    dialogLayout->addWidget(list, 1, 0, 1, 3);
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
   145
    dialogLayout->addWidget(btnCancel, 2, 0, 1, 1, Qt::AlignLeft);
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
   146
    dialogLayout->addWidget(btnSelect, 2, 2, 1, 1, Qt::AlignRight);
8374
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   147
}
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   148
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   149
void HatPrompt::moveUp()
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   150
{
8731
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8488
diff changeset
   151
    list->moveUp();
8374
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   152
}
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   153
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   154
void HatPrompt::moveDown()
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   155
{
8731
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8488
diff changeset
   156
    list->moveDown();
8374
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   157
}
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   158
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   159
void HatPrompt::moveLeft()
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   160
{
8731
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8488
diff changeset
   161
    list->moveLeft();
8374
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   162
}
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   163
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   164
void HatPrompt::moveRight()
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   165
{
8731
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8488
diff changeset
   166
    list->moveRight();
8374
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   167
}
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   168
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   169
void HatPrompt::onAccepted()
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   170
{
8434
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
   171
    hatChosen(list->currentIndex());
8374
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   172
}
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   173
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   174
// When a hat is selected
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   175
void HatPrompt::hatChosen(const QModelIndex & index)
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   176
{
8434
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
   177
    done(filterModel->mapToSource(index).row() + 1); // Since returning 0 means canceled
8374
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   178
}
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   179
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   180
// When the text in the filter text box is changed
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   181
void HatPrompt::filterChanged(const QString & text)
3a1708759c4f Hat selection reworked
dag10
parents:
diff changeset
   182
{
8434
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
   183
    filterModel->setFilterFixedString(text);
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8375
diff changeset
   184
    list->setCurrentIndex(filterModel->index(0, 0));
8375
af2d2f56bc45 Fix build
unc0rr
parents: 8374
diff changeset
   185
}