Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
QmitkSearchLabelDialog.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include "QmitkSearchLabelDialog.h"
14 
15 #include <itkRGBPixel.h>
16 
17 #include <QAbstractItemModel>
18 #include <QColorDialog>
19 #include <QStringListModel>
20 #include <qlabel.h>
21 #include <qlayout.h>
22 #include <qlineedit.h>
23 #include <qpushbutton.h>
24 
25 QmitkSearchLabelDialog::QmitkSearchLabelDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f)
26 {
27  m_Controls = new Ui::QmitkSearchLabelDialogGUI();
28  m_Controls->setupUi(this);
29 
30  m_LabelIndex = -1;
31 
32  QStringList completionList;
33  completionList << "";
34  m_Completer = new QCompleter(completionList);
35  m_Completer->setCaseSensitivity(Qt::CaseInsensitive);
36  m_Controls->m_LabelName->setCompleter(m_Completer);
37 
38  connect(m_Completer, SIGNAL(activated(const QString &)), this, SLOT(OnLabelCompleterChanged(const QString &)));
39  connect(m_Controls->m_pbCancel, SIGNAL(clicked()), this, SLOT(reject()));
40  connect(m_Controls->m_pbAccept, SIGNAL(clicked()), this, SLOT(accept()));
41 
42  m_Controls->m_LabelName->setFocus();
43 }
44 
46 {
47 }
48 
50 {
51  return m_LabelIndex;
52 }
53 
55 {
56  return m_CompleteWord;
57 }
58 
60 {
61  m_LabelList = stringList;
62  QStringListModel *completeModel = static_cast<QStringListModel *>(m_Completer->model());
63  completeModel->setStringList(m_LabelList);
64 }
65 
66 void QmitkSearchLabelDialog::OnLabelCompleterChanged(const QString &completedWord)
67 {
68  if (m_LabelList.contains(completedWord))
69  {
70  m_LabelIndex = m_LabelList.indexOf(completedWord);
71  m_CompleteWord = completedWord;
72  // emit(goToLabel(m_LabelIndex));
73  }
74 }
QmitkSearchLabelDialog(QWidget *parent=nullptr, Qt::WindowFlags f=nullptr)
Ui::QmitkSearchLabelDialogGUI * m_Controls
void SetLabelSuggestionList(QStringList stringList)
void OnLabelCompleterChanged(const QString &completedWord)