summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRalf Habacker <[email protected]>2015-03-11 01:03:20 +0100
committerRalf Habacker <[email protected]>2015-03-11 20:25:26 +0100
commit7d65472ba174f0e67088e2e56837805a312fceed (patch)
treeacb9d13bd198dcd5c310f67a069e47192c764ce6
parent627fedbd54c87a39686ad39741b013365ba14980 (diff)
Add categories to 'find' function.
CCBUG:345060
-rw-r--r--umbrello/dialogs/finddialog.cpp60
-rw-r--r--umbrello/dialogs/finddialog.h7
-rw-r--r--umbrello/dialogs/finddialog.ui166
-rw-r--r--umbrello/finder/findresults.cpp14
-rw-r--r--umbrello/finder/findresults.h6
-rw-r--r--umbrello/finder/umldocfinder.h2
-rw-r--r--umbrello/finder/umlfinder.cpp16
-rw-r--r--umbrello/finder/umlfinder.h9
-rw-r--r--umbrello/finder/umllistviewfinder.cpp17
-rw-r--r--umbrello/finder/umllistviewfinder.h2
-rw-r--r--umbrello/finder/umlscenefinder.cpp4
-rw-r--r--umbrello/finder/umlscenefinder.h1
-rw-r--r--umbrello/uml.cpp8
13 files changed, 220 insertions, 92 deletions
diff --git a/umbrello/dialogs/finddialog.cpp b/umbrello/dialogs/finddialog.cpp
index 8884150..e690671 100644
--- a/umbrello/dialogs/finddialog.cpp
+++ b/umbrello/dialogs/finddialog.cpp
@@ -15,32 +15,68 @@ FindDialog::FindDialog(QWidget *parent) :
{
setCaption(i18n("Find"));
setupUi(mainWidget());
+ connect(ui_buttonGroup, SIGNAL(buttonClicked(int)), this, SLOT(slotFilterButtonClicked(int)));
setButtons(User1 | Cancel);
setDefaultButton(User1);
setButtonText(User1, i18n("Search"));
ui_treeView->setChecked(true);
+ ui_categoryAll->setChecked(true);
}
FindDialog::~FindDialog()
{
}
+/**
+ * return entered text.
+ * @return text
+ */
QString FindDialog::text()
{
return ui_searchTerm->text();
}
-FindDialog::Filter FindDialog::filter()
+/**
+ * Return user selected filter.
+ * @return filter enum
+ */
+UMLFinder::Filter FindDialog::filter()
{
if (ui_treeView->isChecked())
- return TreeView;
+ return UMLFinder::TreeView;
else if (ui_CurrentDiagram->isChecked())
- return CurrentDiagram;
+ return UMLFinder::CurrentDiagram;
else
- return AllDiagrams;
+ return UMLFinder::AllDiagrams;
}
+/**
+ * Return user selected category.
+ * @return category enum
+ */
+UMLFinder::Category FindDialog::category()
+{
+ if (ui_categoryAll->isChecked())
+ return UMLFinder::All;
+ else if (ui_categoryClass->isChecked())
+ return UMLFinder::Classes;
+ else if (ui_categoryPackage->isChecked())
+ return UMLFinder::Packages;
+ else if (ui_categoryInterface->isChecked())
+ return UMLFinder::Interfaces;
+ else if (ui_categoryOperation->isChecked())
+ return UMLFinder::Operations;
+ else if (ui_categoryAttribute->isChecked())
+ return UMLFinder::Attributes;
+ else
+ return UMLFinder::All;
+}
+
+/**
+ * Handles dialog button click.
+ * @param button
+ */
void FindDialog::slotButtonClicked(int button)
{
if (button == KDialog::User1)
@@ -49,6 +85,22 @@ void FindDialog::slotButtonClicked(int button)
KDialog::slotButtonClicked(button);
}
+/**
+ * Handles filter radio button group click.
+ * @param button (-2=Treeview,-3,-4)
+ */
+void FindDialog::slotFilterButtonClicked(int button)
+{
+ ui_categoryOperation->setEnabled(button == -2);
+ ui_categoryAttribute->setEnabled(button == -2);
+ if (button != -2)
+ ui_categoryAll->setChecked(true);
+}
+
+/**
+ * Override default event handler for show event.
+ * @param event
+ */
void FindDialog::showEvent(QShowEvent *event)
{
ui_searchTerm->setFocus();
diff --git a/umbrello/dialogs/finddialog.h b/umbrello/dialogs/finddialog.h
index 7c6dbfe..e2d8ed7 100644
--- a/umbrello/dialogs/finddialog.h
+++ b/umbrello/dialogs/finddialog.h
@@ -14,6 +14,7 @@
#include "ui_finddialog.h"
#include "singlepagedialogbase.h"
+#include "umlfinder.h"
/**
* Class FindDialog provides the ui part for selecting find attributes.
@@ -25,17 +26,17 @@ class FindDialog : public SinglePageDialogBase, private Ui::FindDialog
Q_OBJECT
public:
- typedef enum { TreeView, CurrentDiagram, AllDiagrams } Filter;
explicit FindDialog(QWidget *parent = 0);
~FindDialog();
QString text();
- Filter filter();
-
+ UMLFinder::Filter filter();
+ UMLFinder::Category category();
protected:
void showEvent(QShowEvent *event);
private slots:
virtual void slotButtonClicked(int button);
+ void slotFilterButtonClicked(int button);
};
#endif // FINDDIALOG_H
diff --git a/umbrello/dialogs/finddialog.ui b/umbrello/dialogs/finddialog.ui
index d4a47ce..3120828 100644
--- a/umbrello/dialogs/finddialog.ui
+++ b/umbrello/dialogs/finddialog.ui
@@ -6,60 +6,122 @@
<rect>
<x>0</x>
<y>0</y>
- <width>293</width>
- <height>118</height>
+ <width>520</width>
+ <height>268</height>
</rect>
</property>
- <layout class="QFormLayout" name="formLayout">
- <item row="0" column="0">
- <layout class="QVBoxLayout" name="verticalLayout_2">
+ <property name="minimumSize">
+ <size>
+ <width>441</width>
+ <height>268</height>
+ </size>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
<item>
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Filter:</string>
- </property>
- <property name="buddy">
- <cstring>ui_CurrentDiagram</cstring>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QRadioButton" name="ui_treeView">
- <property name="text">
- <string>Tree View</string>
- </property>
- <attribute name="buttonGroup">
- <string notr="true">buttonGroup</string>
- </attribute>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="ui_CurrentDiagram">
- <property name="text">
- <string>&amp;Current diagram</string>
- </property>
- <attribute name="buttonGroup">
- <string notr="true">buttonGroup</string>
- </attribute>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="ui_Diagrams">
- <property name="text">
- <string>&amp;All diagrams</string>
- </property>
- <attribute name="buttonGroup">
- <string notr="true">buttonGroup</string>
- </attribute>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
+ <widget class="QGroupBox" name="groupBox_2">
+ <property name="title">
+ <string>Filter</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QRadioButton" name="ui_treeView">
+ <property name="text">
+ <string>Tree View</string>
+ </property>
+ <attribute name="buttonGroup">
+ <string notr="true">ui_buttonGroup</string>
+ </attribute>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="ui_CurrentDiagram">
+ <property name="text">
+ <string>&amp;Current diagram</string>
+ </property>
+ <attribute name="buttonGroup">
+ <string notr="true">ui_buttonGroup</string>
+ </attribute>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="ui_Diagrams">
+ <property name="text">
+ <string>&amp;All diagrams</string>
+ </property>
+ <attribute name="buttonGroup">
+ <string notr="true">ui_buttonGroup</string>
+ </attribute>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ <zorder>ui_Diagrams</zorder>
+ <zorder>ui_CurrentDiagram</zorder>
+ <zorder>ui_treeView</zorder>
+ <zorder>ui_Diagrams</zorder>
+ <zorder>ui_CurrentDiagram</zorder>
+ <zorder>ui_treeView</zorder>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string>Category</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_5">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
+ <item>
+ <widget class="QRadioButton" name="ui_categoryAll">
+ <property name="text">
+ <string>All</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="ui_categoryClass">
+ <property name="text">
+ <string>Class</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="ui_categoryPackage">
+ <property name="text">
+ <string>Package</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="ui_categoryInterface">
+ <property name="text">
+ <string>Interface</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="ui_categoryOperation">
+ <property name="text">
+ <string>Operation</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="ui_categoryAttribute">
+ <property name="text">
+ <string>Attribute</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
@@ -98,6 +160,6 @@
<resources/>
<connections/>
<buttongroups>
- <buttongroup name="buttonGroup"/>
+ <buttongroup name="ui_buttonGroup"/>
</buttongroups>
</ui>
diff --git a/umbrello/finder/findresults.cpp b/umbrello/finder/findresults.cpp
index 3141a3b..139538e 100644
--- a/umbrello/finder/findresults.cpp
+++ b/umbrello/finder/findresults.cpp
@@ -33,21 +33,21 @@ FindResults::~FindResults()
* @param text
* @return Number of items found
*/
-int FindResults::collect(FindResults::Filter filter, Category category, const QString &text)
+int FindResults::collect(UMLFinder::Filter filter, UMLFinder::Category category, const QString &text)
{
Q_UNUSED(category);
clear();
- if (filter == TreeView) {
+ if (filter == UMLFinder::TreeView) {
m_listViewFinder.append(UMLListViewFinder());
- return m_listViewFinder.last().collect(UMLFinder::All, text);
+ return m_listViewFinder.last().collect(category, text);
}
- else if (filter == CurrentDiagram) {
+ else if (filter == UMLFinder::CurrentDiagram) {
m_sceneFinder.append(UMLSceneFinder(UMLApp::app()->currentView()));
- return m_sceneFinder.last().collect(UMLFinder::All, text);
+ return m_sceneFinder.last().collect(category, text);
}
- else if (filter == AllDiagrams) {
+ else if (filter == UMLFinder::AllDiagrams) {
m_docFinder.append(UMLDocFinder());
- return m_docFinder.last().collect(UMLFinder::All, text);
+ return m_docFinder.last().collect(category, text);
}
return 0;
}
diff --git a/umbrello/finder/findresults.h b/umbrello/finder/findresults.h
index e5840af..ed72803 100644
--- a/umbrello/finder/findresults.h
+++ b/umbrello/finder/findresults.h
@@ -11,6 +11,8 @@
#ifndef FINDRESULTS_H
#define FINDRESULTS_H
+#include "umlfinder.h"
+
#include <QList>
#include <QObject>
@@ -28,14 +30,12 @@ class FindResults : QObject
{
Q_OBJECT
public:
- typedef enum { TreeView, CurrentDiagram, AllDiagrams } Filter;
- typedef enum { Class } Category;
FindResults();
virtual ~FindResults ();
void clear();
- int collect(Filter filter, Category category, const QString & text);
+ int collect(UMLFinder::Filter filter, UMLFinder::Category category, const QString & text);
public slots:
bool displayNext();
diff --git a/umbrello/finder/umldocfinder.h b/umbrello/finder/umldocfinder.h
index e6844d8..f317e9c 100644
--- a/umbrello/finder/umldocfinder.h
+++ b/umbrello/finder/umldocfinder.h
@@ -14,6 +14,8 @@
#include "umlfinder.h"
#include "umlscene.h"
+class UMLSceneFinder;
+
#include <QList>
/**
diff --git a/umbrello/finder/umlfinder.cpp b/umbrello/finder/umlfinder.cpp
index 489759a..8008777 100644
--- a/umbrello/finder/umlfinder.cpp
+++ b/umbrello/finder/umlfinder.cpp
@@ -10,6 +10,8 @@
#include "umlfinder.h"
+#include "umlobject.h"
+
UMLFinder::UMLFinder() : m_index(-1)
{
}
@@ -17,3 +19,17 @@ UMLFinder::UMLFinder() : m_index(-1)
UMLFinder::~UMLFinder()
{
}
+
+bool UMLFinder::includeObject(UMLFinder::Category category, UMLObject *o)
+{
+ if (!o)
+ return false;
+ UMLObject::ObjectType type = o ? o->baseType() : UMLObject::ot_Unknown;
+ return category == All
+ || (category == Classes && type == UMLObject::ot_Class)
+ || (category == Interfaces && type == UMLObject::ot_Interface)
+ || (category == Packages && type == UMLObject::ot_Package)
+ || (category == Operations && type == UMLObject::ot_Operation)
+ || (category == Attributes && type == UMLObject::ot_Attribute)
+ ;
+}
diff --git a/umbrello/finder/umlfinder.h b/umbrello/finder/umlfinder.h
index 5d83b11..1955be6 100644
--- a/umbrello/finder/umlfinder.h
+++ b/umbrello/finder/umlfinder.h
@@ -11,14 +11,14 @@
#ifndef UMLFINDER_H
#define UMLFINDER_H
-#include "findresults.h"
-
// app include
#include "basictypes.h"
// qt include
#include <QList>
+class UMLObject;
+
/**
* The UMLFinder class provides the interface for find related classes.
*
@@ -27,7 +27,8 @@
class UMLFinder
{
public:
- typedef enum { All } Category;
+ typedef enum { All, Classes, Packages, Interfaces, Operations, Attributes } Category;
+ typedef enum { TreeView, CurrentDiagram, AllDiagrams } Filter;
typedef enum { Empty, End, Found, NotFound } Result;
UMLFinder();
virtual ~UMLFinder();
@@ -57,6 +58,8 @@ public:
protected:
int m_index;
QList<Uml::ID::Type> m_items;
+
+ bool includeObject(Category category, UMLObject *o);
};
#endif // UMLFINDER_H
diff --git a/umbrello/finder/umllistviewfinder.cpp b/umbrello/finder/umllistviewfinder.cpp
index 07d8abe..81757b1 100644
--- a/umbrello/finder/umllistviewfinder.cpp
+++ b/umbrello/finder/umllistviewfinder.cpp
@@ -30,16 +30,13 @@ int UMLListViewFinder::collect(Category category, const QString &text)
QList<QTreeWidgetItem*> items = UMLApp::app()->listView()->findItems(text, Qt::MatchContains | Qt::MatchRecursive);
m_items.clear();
foreach(QTreeWidgetItem *item, items) {
- UMLListViewItem *ui = static_cast<UMLListViewItem*>(item);
- // TODO check category
-#if 0
- UMLObject::ObjectType type = ui->umlObject() ? ui->umlObject()->baseType() : UMLObject::ot_Unknown;
- if (type == UMLObject::ot_Class
- || type == UMLObject::ot_Interface
- || type == UMLObject::ot_Package)
-#endif
- if (ui->umlObject())
- m_items.append(ui->umlObject()->id());
+ UMLListViewItem *ui = dynamic_cast<UMLListViewItem*>(item);
+ if (!ui)
+ continue;
+ UMLObject *o = ui->umlObject();
+ if (!includeObject(category, o))
+ continue;
+ m_items.append(o->id());
}
m_index = -1;
diff --git a/umbrello/finder/umllistviewfinder.h b/umbrello/finder/umllistviewfinder.h
index 1657522..8aff13d 100644
--- a/umbrello/finder/umllistviewfinder.h
+++ b/umbrello/finder/umllistviewfinder.h
@@ -24,7 +24,7 @@ public:
UMLListViewFinder();
virtual ~UMLListViewFinder();
virtual int collect(Category category, const QString &text);
-public slots:
+
virtual Result displayNext();
virtual Result displayPrevious();
protected:
diff --git a/umbrello/finder/umlscenefinder.cpp b/umbrello/finder/umlscenefinder.cpp
index 8f0039c..1544299 100644
--- a/umbrello/finder/umlscenefinder.cpp
+++ b/umbrello/finder/umlscenefinder.cpp
@@ -26,7 +26,7 @@ UMLSceneFinder::~UMLSceneFinder()
{
}
-int UMLSceneFinder::collect(UMLFinder::Category category, const QString &text)
+int UMLSceneFinder::collect(Category category, const QString &text)
{
Q_UNUSED(category);
m_items.clear();
@@ -38,6 +38,8 @@ int UMLSceneFinder::collect(UMLFinder::Category category, const QString &text)
UMLScene *scene = view->umlScene();
foreach(UMLWidget* w, scene->widgetList()) {
+ if (!includeObject(category, w->umlObject()))
+ continue;
if (w->name().contains(text, Qt::CaseInsensitive))
m_items.append(w->id());
}
diff --git a/umbrello/finder/umlscenefinder.h b/umbrello/finder/umlscenefinder.h
index 01022a4..6512d9c 100644
--- a/umbrello/finder/umlscenefinder.h
+++ b/umbrello/finder/umlscenefinder.h
@@ -27,7 +27,6 @@ public:
virtual ~UMLSceneFinder();
virtual int collect(Category category, const QString &text);
-public slots:
virtual Result displayNext();
virtual Result displayPrevious();
diff --git a/umbrello/uml.cpp b/umbrello/uml.cpp
index 438c038..da8aa95 100644
--- a/umbrello/uml.cpp
+++ b/umbrello/uml.cpp
@@ -1353,13 +1353,7 @@ void UMLApp::slotFind()
return;
}
- int count = 0;
- if (m_d->findDialog.filter() == FindDialog::TreeView)
- count = m_d->findResults.collect(FindResults::TreeView, FindResults::Class, m_d->findDialog.text());
- else if (m_d->findDialog.filter() == FindDialog::CurrentDiagram)
- count = m_d->findResults.collect(FindResults::CurrentDiagram, FindResults::Class, m_d->findDialog.text());
- else if (m_d->findDialog.filter() == FindDialog::AllDiagrams)
- count = m_d->findResults.collect(FindResults::AllDiagrams, FindResults::Class, m_d->findDialog.text());
+ int count = m_d->findResults.collect(m_d->findDialog.filter(), m_d->findDialog.category(), m_d->findDialog.text());
UMLApp::app()->document()->writeToStatusBar(i18n("'%1': %2 found", m_d->findDialog.text(), count));
slotFindNext();