Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include "QmitkSearchLabelDialog.h"
18 
19 #include "mitkOrganTypeProperty.h"
20 
21 #include <itkRGBPixel.h>
22 
23 #include <QAbstractItemModel>
24 #include <QColorDialog>
25 #include <QStringListModel>
26 #include <qlabel.h>
27 #include <qlayout.h>
28 #include <qlineedit.h>
29 #include <qpushbutton.h>
30 
31 QmitkSearchLabelDialog::QmitkSearchLabelDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f)
32 {
33  m_Controls = new Ui::QmitkSearchLabelDialogGUI();
34  m_Controls->setupUi(this);
35 
36  m_LabelIndex = -1;
37 
38  QStringList completionList;
39  completionList << "";
40  m_Completer = new QCompleter(completionList);
41  m_Completer->setCaseSensitivity(Qt::CaseInsensitive);
42  m_Controls->m_LabelName->setCompleter(m_Completer);
43 
44  connect(m_Completer, SIGNAL(activated(const QString &)), this, SLOT(OnLabelCompleterChanged(const QString &)));
45  connect(m_Controls->m_pbCancel, SIGNAL(clicked()), this, SLOT(reject()));
46  connect(m_Controls->m_pbAccept, SIGNAL(clicked()), this, SLOT(accept()));
47 
48  m_Controls->m_LabelName->setFocus();
49 }
50 
52 {
53 }
54 
56 {
57  return m_LabelIndex;
58 }
59 
61 {
62  return m_CompleteWord;
63 }
64 
66 {
67  m_LabelList = stringList;
68  QStringListModel *completeModel = static_cast<QStringListModel *>(m_Completer->model());
69  completeModel->setStringList(m_LabelList);
70 }
71 
72 void QmitkSearchLabelDialog::OnLabelCompleterChanged(const QString &completedWord)
73 {
74  if (m_LabelList.contains(completedWord))
75  {
76  m_LabelIndex = m_LabelList.indexOf(completedWord);
77  m_CompleteWord = completedWord;
78  // emit(goToLabel(m_LabelIndex));
79  }
80 }
Ui::QmitkSearchLabelDialogGUI * m_Controls
QmitkSearchLabelDialog(QWidget *parent=0, Qt::WindowFlags f=0)
void SetLabelSuggestionList(QStringList stringList)
void OnLabelCompleterChanged(const QString &completedWord)