grouped list view in gtk - gtk

Is there a way to achieve a view in following screenshot by Gtk?
I have tried treeview, but it doesn't automatically filtered out the group.
KDELibs equivalent is KCategorizedView.
Edit:
My use case it like:
for example like the screen shot, if I type Mythology, AOE and AOE III will not be shown, since there is no match under that group.
If I try to use treeview, the parent node not cannot be easily filtered, since the filtermodel cannot easily depends on the filtered result.

you can use a GtkTreeView with a GtkTreeStore, but there is no stock widget that has the appearance of the KDE widget.
alternatively, you can have different GtkTreeView instances, each inside a GtkFrame and each using a GtkTreeModelFilter to apply a filter to the same GtkListStore or GtkTreeStore, so that you can keep that data inside a single storage.
the layout would look like:
GtkBox
+---- GtkFrame
| +---- GtkTreeView
|
+---- GtkFrame
| +---- GtkTreeView
|
+---- GtkFrame
| +---- GtkTreeView
|
...
the GtkTreeModelFilter can be set to filter all rows inside the source GtkListStore or GtkTreeStore that match the "category" you want.

Related

Selecting multiple rows on CheckboxTreeViewer without using the 'ctrl' button

I have created a checkboxtreeviewer using the JFace library. I have created the tree viewer as below
Tree tree = new Tree(parent,SWT.CHECK | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
CheckboxTreeViewer checkboxTreeViewer = new CheckboxTreeViewer(tree);
The SWT.MULTI allows me to select(highlight) multiple rows of the tree using the 'CTRL key.
Is there a way we can select multiple rows without using the ctrl key. One way i know of is using the setSelection() method, which cannot be used since that causes a flickering effect when the user goes from one row to another , the Tree.java would deselect all the existing rows and then highlight the rows that are called in the setSelection method.
I feel the code here is causing a deselect to all rows and then a select on the row selected by the user.
You can turn off redrawing of the tree until you have finished setting the selection, this should reduce flickering:
checkboxTreeViewer.getControl().setRedraw(false);
checkboxTreeViewer.setSelection(....);
checkboxTreeViewer.getControl().setRedraw(true);

How to achieve an advanced table view header

I have a grouped UITableView. Now unlike the default table view header my header should be next to the individual cells:
Standard:
[Header Cell]
[Item 1]
[Item 2]
What I need
+-------+----------------+
| | Item 1a |
| h1 +----------------+
| | Item 1b |
+ - - - +----------------+
| Item 1c |
+------------------------+
| | Item 2a |
| h2 +----------------+
| | Item 2b |
+------------------------+
| | Item 3a |
| h3 +----------------+
| | -placeholder- |
+-------+----------------+
Some remarks:
Group H1 has three items
Group H2 has two items
Group H3 has just one item (I have to insert a placeholder cell so that the header cell can have the full height of two item-cells
When the user scrolls the list then the header should be pushed upwards that the two header-cells don't overlap.
The challenge here is the height of the header cell:
If I set the height to 0 and uncheck clip subviews then that header cell is shown but does not get pushed away at the correct position.
If I set the height of the header cell to the visual height then there is an empty space of that height across the whole width of the table which I don't want...
Update 1: I just realized that apple uses such a list for the search (grouped by messages, mails, contacts, calenders etc.). So my question basically is how can I tweak UITableView in order to behave like the grouped search results... :-)
(source: mshcdn.com)
Update: I created a project on github, which does exactly this. I have extracted all the relevant code for the behaviour into two classes (BBFloatingHeaderViewController & BBFloatingHeaderCell). There is also an example project. I hope this is useful for others :-)
Here's the project: besi/FloatingTableViewHeader
This is an excerpt from the readme:
Floating UITableView headers
These classes aim to copy the behaviour found in iOS built-in Spotlight search, where the search results are grouped by category and the icon of the respective category floats on the left side of the search results.
Setup
Check out the example project so see how to setup the classes.
Add the .m + .h files of BBFloatingHeaderViewController and BBFloatingHeaderCell to your project.
Create a TableView and set the Class of the ViewController to your subclass of BBFloatingHeaderViewController
Create the header cell in IB and set its class to your subclass of BBFloatingHeaderCell
Make sure that your floating header view is the topmost view in the BBFloatingHeaderCell's view hierarchy.
The result
Floating Headers http://i.minus.com/jyea3I5qbUdoQ.png

Android UI requirement

I have UI requirement shown below:
|------------------------|
|Header-1 |
| Checkbox1[] |
| Checkbox2[] |
| Checkbox3[] |
|------------------------|
|Header-2 |
| Checkbox1 [] |
| Checkbox2 [] |
| Checkbox3 [] |
and so on clicking below button.
BUTTON -> clicking on this button on bottom will create header and 3 checkbox everytime. How can i achieve this? This is very urgent. I can not take these in XML laypout as these need to be added dynamically on runtime.
If possible, Please provide any sample code and guide me.
Thanks,
Rachana
You should create a listView containing rows defined by a layout having :
a linear layout containing a textView with Header-1 (and so on) as text
another linearLayout containing three checkboxes.
You will create an arrayAdapter with a list of strings representing different values for Header-1 (I guess checkboxes will have same values all the time).
Adding a click listener (onClickListener) on your button. This listener will add an item to the arrayList used by the adapter to add new items in /remove items from your listview when your arrayList is modified (calling notifyDataSetChanged()) to refresh the listView.

How can i have more than one cell in a table view row?

I have seen apps that have table views that have rows that contain 2 or 3 cells. Something like the following:
| 3 cells in one row |
/-------\ /-------\ /-------\
|do this| | do | |do smth| <--- table view row that contains 3 cells
| | | that | | else |
\-------/ \-------/ \-------/
When you click on a cell they behave exactly like a cell and have different events. Is there a simple way to do this or do I have to use some trick.
Those aren't actually separate cells. A UITableView can only contain rows, not columns. But each cell can be laid out with its content in three equal-sized areas, thereby mimicking a real grid of content.
If they don't have to look like cells, I would use 3 Buttons in a custom UITableViewCell. They also get blue if you tap on them.
Adding buttons and then using the code from here seems to be the easiest way. Although the initWithFrame:CGRectZero looks hacky, it works.

Embedding a long UIWebView within a table view cell with various heights

I want to be able to embed a UIWebView into a tableview's cell (grouped style).
The web view is long (longer than the screen), and I want it to display it's full length. So there is no scrolling within the web view itself, just on the table.
------------------------
| a normal table cell |
------------------------
| a normal table cell 2|
------------------------
| a long webview |
| which doesn't scroll|
| within itself |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
------------------------
The web view will have various heights so how can I discover the the height of the webview in order to adjust the height in heightForRowAtIndexPath?
Here's how you could do it, but see my caution below:
You could load the web view, then use a javascript function to determine the height of the content. You could then use [myWebView stringByEvaluatingJavaScriptFromString: ..] to get the height.
Here's the problem. UIWebViews are fairly slow. The table can't present itself until it knows the heights of the rows, because that's how it determines which table cells to fetch. So scrolling your table view will be jerky, because every time you scroll down to a new cell, the height will need to be computed.
There are two approaches you can take:
1) Don't use a UIWebView embedded in a UITableCell. Instead use a UILabel and determine its height using some of the NSString convenience methods for doing this.
2) Use a UIWebView for the entire table. You can very closely simulate a tableview by doing this, and you will get the UI you need. To handle things like clicks, use the URL loading hooks provided by UIWebViewDelegate.