Search Results

Search found 6420 results on 257 pages for 'mathieu parent'.

Page 56/257 | < Previous Page | 52 53 54 55 56 57 58 59 60 61 62 63  | Next Page >

  • Finding parents where child collection does not contain an item with a specific property value

    - by Colin Bowern
    I am trying to get a list of parents where the child collection does not contain an item of a specific type. The LINQ equivalent would be something like: dataset.Where(x => x.Items.FirstOrDefault(y => y.Type.Code == "ABC") == null) The object model is Parent Child (Items) Type Code If Parent is my aggregate root, how would I model this in NHibernate criteria/query? Here's my first attempt: var results = session.CreateCriteria<Parent>() .CreateCriteria("Items") .CreateCriteria("Type") .Add(Restrictions.Not(Restrictions.Eq("Code", "ABC"))) .SetResultTransformer(Transformers.DistinctRootEntity) .List<Parent>(); This doesn't seem to return the right entities - it just returns them all.

    Read the article

  • Scala 2.8: _ behaviour changed?

    - by Alexey Romanov
    Using XScalaWT, this compiled under Scala 2.7: class NodeView(parent: Composite) extends Composite(parent) { var nodeName: Label = null this.contains( label( nodeName = _ ) ) } With 2.8.0 RC1, I get this error: type mismatch; found : main.scala.NodeView required: org.eclipse.swt.widgets.Label The types are: label(setups: (Label => Unit)*)(parent: Composite) : Label contains(setups: (W => Unit)*) : W So it looks like _ now binds to the outer function instead of inner. Is this change intentional?

    Read the article

  • jquery mouseout problem

    - by From.ME.to.YOU
    hello my html <div id="parent"> <div id="child">cx</div> </div> when i use jquery $('#parent').mouseout(function(){ //something here }); i wonder why when my mouse enter the child div the function fires. i'm still inside parent div. i want that mouseout function to fire only when i leave the parent div not when i'm on any child div http://jsbin.com/esiju/ << example Cheers

    Read the article

  • My listview is not gaining the keyboard focus in Qt

    - by Solitaire
    Hi, i am trying to operate the listview itesm through keyboard focus, its not moving.. can you folks suggest where i am wrong. if i click on the listview from mouse, listview is gaining the focus. i dont no what is wrong. #include <QtGui> #include <QApplication> class Newlist : public QListView { public: Newlist(QWidget *parent = 0); ~Newlist(){}; public: QListView *list; QStringListModel *model; }; Newlist::Newlist(QWidget *parent) : QListView(parent) { list = new QListView(this); list->setViewMode(QListView::ListMode); list->setSelectionMode(QAbstractItemView::SingleSelection); list->setMinimumSize(300,500); model = new QStringListModel(this); QStringList strlist; strlist<<"Test"<<"fest"<<"mest"; list->setModel(model); model->setStringList(strlist); QModelIndex index = model->index(1,0); list->setCurrentIndex(index); QVBoxLayout *layout = new QVBoxLayout(this); layout->addWidget(list); setLayout(layout); list->setFocus(); } class Test : public QMainWindow { public: Test(QWidget *parent = 0); ~Test(){}; private: Mylistview *newlist; QVBoxLayout *layout; }; Test::Test(QWidget *parent) : QMainWindow(parent) { layout = new QVBoxLayout(); newlist = new Mylistview(); this->setCentralWidget(newlist); } int main(int argc, char *argv[]) { QApplication a(argc, argv); Test test; test.showMaximized(); return a.exec(); } Thanks in advance

    Read the article

  • problem with treeview

    - by Xaver
    I want to configure a treeview so that when all checkboxes of a parent are checked, then the parent checkbox is checked. And when all checkboxes are unchecked, the parent checkbox is unchecked. Does the treeview class have a standard property for that?

    Read the article

  • c - fork() and wait()

    - by Joe
    Hi there, I need to use the fork() and wait() functions to complete an assignment. We are modelling non-deterministic behaviour and need the program to fork() if there is more than one possible transition. In order to try and work out how fork and wait work, I have just made a simple program. I think I understand now how the calls work and would be fine if the program only branched once because the parent process could use the exit status from the single child process to determine whether the child process reached the accept state or not. As you can see from the code that follows though, I want to be able to handle situations where there must be more than one child processes. My problem is that you seem to only be able to set the status using an _exit function once. So, as in my example the exit status that the parent process tests for shows that the first child process issued 0 as it's exit status, but has no information on the second child process. I tried simply not _exit()-ing on a reject, but then that child process would carry on, and in effect there would seem to be two parent processes. Sorry for the waffle, but I would be grateful if someone could tell me how my parent process could obtain the status information on more than one child process, or I would be happy for the parent process to only notice accept status's from the child processes, but in that case I would successfully need to exit from the child processes which have a reject status. My test code is as follows: #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <errno.h> #include <sys/wait.h> int main(void) { pid_t child_pid, wpid, pid; int status = 0; int i; int a[3] = {1, 2, 1}; for(i = 1; i < 3; i++) { printf("i = %d\n", i); pid = getpid(); printf("pid after i = %d\n", pid); if((child_pid = fork()) == 0) { printf("In child process\n"); pid = getpid(); printf("pid in child process is %d\n", pid); /* Is a child process */ if(a[i] < 2) { printf("Should be accept\n"); _exit(1); } else { printf("Should be reject\n"); _exit(0); } } } if(child_pid > 0) { /* Is the parent process */ pid = getpid(); printf("parent_pid = %d\n", pid); wpid = wait(&status); if(wpid != -1) { printf("Child's exit status was %d\n", status); if(status > 0) { printf("Accept\n"); } else { printf("Complete parent process\n"); if(a[0] < 2) { printf("Accept\n"); } else { printf("Reject\n"); } } } } return 0; } Many thanks Joe

    Read the article

  • Mismatched coordinate systems in LWJGL with Mouse and Textures

    - by Braains
    I'm not really sure how to expand on this other than to say that it appears that my LWJGL seems to have different coordinate systems for the Mouse and for painting Textures. It seems that Textures have the usual Java2D way of putting (0, 0) in the upper-left corner, while the Mouse goes by the more sensible way of having the origin in the lower-left corner. I've checked my code a bunch but I don't see anything modifying the values between where I read them and where I use them. It's thrown me for a loop and I can't quite figure it out. I'll post all the code that involves the Mouse input and Texture painting for you guys to look at. private static void pollHelpers() { while(Mouse.next()) { InputHelper.acceptMouseInput(Mouse.getEventButton(), Mouse.getEventX(), Mouse.getEventY()); } while (Keyboard.next()) { if (Keyboard.getEventKeyState()) { InputHelper.acceptKeyboardInput(Keyboard.getEventKey(), true); } else { InputHelper.acceptKeyboardInput(Keyboard.getEventKey(), false); } } } public static void acceptMouseInput(int mouseButton, int x, int y) { for(InputHelper ie: InputHelper.instances) { if(ie.checkRectangle(x, y)) { ie.sendMouseInputToParent(mouseButton); } } } private void sendMouseInputToParent(int mouseButton) { parent.onClick(mouseButton); } public boolean checkRectangle(int x, int y) { //y = InputManager.HEIGHT - y; See below for explanation return x > parent.getX() && x < parent.getX() + parent.getWidth() && y > parent.getY() && y < parent.getY() + parent.getHeight(); } I put this line of code in because it temporarily fixed the coordinate system problem. However, I want to have my code to be as independent as possible so I want to remove as much reliance on other classes as possible. These are the only methods that touch the Mouse input, and as far as I can tell none of them change anything so all is good here. Now for the Texture methods: public void draw() { if(!clicked || deactivatedImage == null) { activatedImage.bind(); glBegin(GL_QUADS); { DrawHelper.drawGLQuad(activatedImage, x, y, width, height); } glEnd(); } else { deactivatedImage.bind(); glBegin(GL_QUADS); { DrawHelper.drawGLQuad(deactivatedImage, x, y, width, height); } glEnd(); } } public static void drawGLQuad(Texture texture, float x, float y, float width, float height) { glTexCoord2f(x, y); glVertex2f(x, y); glTexCoord2f(x, y + texture.getHeight()); glVertex2f(x, y + height); glTexCoord2f(x + texture.getWidth(), y + texture.getHeight()); glVertex2f(x + width, y +height); glTexCoord2f(x + texture.getWidth(), y); glVertex2f(x + width, y); } I'll be honest, I do not have the faintest clue as to what is really happening in this method but I was able to put it together on my own and get it to work. my guess is that this is where the problem is. Thanks for any help!

    Read the article

  • Passing List (Of ChildClass) as parameter to method expecting List (Of ParentClass)?

    - by Nicholas
    Hi, I have implemented inheritance for two parent classes called Table and Field. Each parent class has several child classes. In the Table parent class, I created a method that expects parameter List(Of Field). I get an error when trying to pass in parameter List(Of ChildField) to the method that expects a parameter of List(Of Field). The error message is as below: Value of type 'System.Collections.Generic.List(Of com.hlb.icisbatch.data.ChildField)' cannot be converted to 'System.Collections.Generic.List(Of com.hlb.icisbatch.data.Field)' My question, is it possible to pass in list of child class as parameter? If it is not a list then it works fine. But somehow it is not possible with lists? Below is sample class structure: Table Field | | ChildTable ChildField I have a method in the parent class: Public Class Table Public Sub New() End Sub Public Overridable Sub setFields(ByVal list As List(Of Field) 'Do work here' End Sub End Class and method in child class: Public Class ChildTable Public Sub New(ByVal list As List(Of ChildField) setFields(ChildField) End Sub End Class

    Read the article

  • Classloading order in JBoss

    - by Spiderman
    I'd like to know if the default behavior of JBoss server (4.2.3.GA in my case) is loading the classes in parent-first or parent-last mode. And in case it work as I suspect in parent-last mode (i.e. first trying to load classes from the application's WEB-INF/lib and only if they are not found go to server\lib), how can I configure it to work in the opposite- first trying to load classes from outside and only looking inside the application afterwards.

    Read the article

  • Core data, sorting one-to-many child objects

    - by Shizam
    So if I have a store of parents children and the parent has a one to many relationship to children (parent.children) and they all have first names. Now, on the initial fetch for parents I can specify a sort descriptor to get them back in order of first name but how can I request the children in order? If I do a [parent.children allObjects] it just gives them back in a jumble and I'd have to sort after the fact, every time. Thanks, Sam

    Read the article

  • Me As Child Type

    - by Steven
    I have a MustInherit Parent class with two Child classes which Inherit from the Parent. How can I use (or Cast) Me in a Parent function as the the child type of that instance? EDIT: My actual goal is to be able to serialize (BinaryFormatter.Serialize(Stream, Object)) either of my child classes. However, "repeating the code" in each child "seems" wrong.

    Read the article

  • Python Threading

    - by anteater7171
    I'm trying to make a simple program that continually displays and updates a label that displays the CPU usage, while having other unrelated things going on. I've done enough research to know that threading is likely going to be involved. However, I'm having trouble applying what I've seen in simple examples of threading to what I'm trying to do. What I currently have going: import Tkinter import psutil,time from PIL import Image, ImageTk class simpleapp_tk(Tkinter.Tk): def __init__(self,parent): Tkinter.Tk.__init__(self,parent) self.parent = parent self.initialize() def initialize(self): self.labelVariable = Tkinter.StringVar() self.label = Tkinter.Label(self,textvariable=self.labelVariable) self.label.pack() self.button = Tkinter.Button(self,text='button',command=self.A) self.button.pack() def A (self): G = str(round(psutil.cpu_percent(), 1)) + '%' print G self.labelVariable.set(G) def B (self): print "hello" if __name__ == "__main__": app = simpleapp_tk(None) app.mainloop() In the above code I'm basically trying to get command A continually running, while allowing command B to be done when the users presses the button.

    Read the article

  • Problem in Rich : menubar

    - by Ramesh G
    Hi, I'm using rich:toolbar with backing bean menuAction method.I'm facing one problem in menu link icons.Suppose if i ve child menu in my parent menu it is displaying "hand symbol" for that.else if i dont ve any child menu in my parent menu it is showing "I" this icon.While clicking parent menu(without having child menu) i want hand symbol icon instead of "I" this icon. please help me....... Regards, Ramesh G

    Read the article

  • How to call notifyDataSetChanged() from a generic Adapter

    - by Matty F
    An OnItemClickListener for a ListView has the following method: @Override public void onItemClick(AdapterView<?> parent, View v, int position, long id) I'd like to have the adapter behind the ListView refresh, and I believe this is done through the use of: BaseAdapter.notifyDataSetChanged() How do I use the parent parameter in the onItemClick method to do this? So far I've tried: parent.getAdapter().notifyDataSetChanged(); This throws an error because the object returned is of class HeaderViewListAdapter, which for reasons unknown isn't a subclass of BaseAdapter.

    Read the article

  • Entities groups in transactions

    - by Joel
    In the context of "Keys and Entity Groups" article by google: http://code.google.com/appengine/docs/python/datastore/transactions.html 1) "Only use entity groups when they are needed for transactions" 2) "Every entity belongs to an entity group, a set of one or more entities that can be manipulated in a single transaction." It seems like entity groups exist only for the use of transactions, i.e. making one transaction possible between all entities in a group. My question is then why are there parent-child relations between entities and not just a simple declaration of entities to be in a single group (that is defining A,B,C to be in the same group as opposed to defining relations between them "A (parent of) B, B (parent of C)"). What is the benefit from using parent-child relation model when the only purpose is for entities to be in the same group to make transaction possible? Thanks Joel

    Read the article

  • Why isn't this simple PHP/MySQL code working?

    - by Sammy
    I am very new to php/mysql and this is causing me to loose hairs, I am trying to build a multi level site navigation. In this part of my script I am readying the sub and parent categories coming from a form for insertion into the database: // get child categories $catFields = $_POST['categories']; if (is_array($catFields)) { $categories = $categories; for ($i=0; $i<count($catFields); $i++) { $categories = $categories . $catFields[$i]"; } } // get parent category $select = mysql_query ("SELECT parent FROM categories WHERE id = $categories"); while ($return = mysql_fetch_assoc($select)) { $parentId = $return['parent']; } The first part of my script works fine, it grabs all the categories that the user has chosen to assign a post by checking the checkboxes in a form and readies it for insertion into the database. But the second part does not work and I can't understand why. I am trying to match a category with a parent that is stored in it's own table, but it returns nothing even though the categories all have parents. Can anyone tell me why this is? p.s. The $categories variable contains the sub category id.

    Read the article

  • Python - Polymorphism in wxPython, What's wrong?

    - by Wallter
    I am trying to wright a simple custom button in wx.Python. My code is as follows, an error is thrown on line 19 of my "Custom_Button.py" - What is going on? I can find no help online for this error and have a suspicion that it has to do with the Polymorphism. (As a side note: I am relatively new to python having come from C++ and C# any help on syntax and function of the code would be great! - knowing that, it could be a simple error. thanks!) Error def __init__(self, parent, id=-1, NORM_BMP, PUSH_BMP, MOUSE_OVER_BMP, **kwargs): SyntaxError: non-default argument follows default argument Main.py class MyFrame(wx.Frame): def __init__(self, parent, ID, title): wxFrame.__init__(self, parent, ID, title, wxDefaultPosition, wxSize(400, 400)) self.CreateStatusBar() self.SetStatusText("Program testing custom button overlays") menu = wxMenu() menu.Append(ID_ABOUT, "&About", "More information about this program") menu.AppendSeparator() menu.Append(ID_EXIT, "E&xit", "Terminate the program") menuBar = wxMenuBar() menuBar.Append(menu, "&File"); self.SetMenuBar(menuBar) self.Button1 = Custom_Button(self, parent, -1, "D:/Documents/Python/Normal.bmp", "D:/Documents/Python/Clicked.bmp", "D:/Documents/Python/Over.bmp", "None", wx.Point(200,200), wx.Size(300,100)) EVT_MENU(self, ID_ABOUT, self.OnAbout) EVT_MENU(self, ID_EXIT, self.TimeToQuit) def OnAbout(self, event): dlg = wxMessageDialog(self, "Testing the functions of custom " "buttons using pyDev and wxPython", "About", wxOK | wxICON_INFORMATION) dlg.ShowModal() dlg.Destroy() def TimeToQuit(self, event): self.Close(true) class MyApp(wx.App): def OnInit(self): frame = MyFrame(NULL, -1, "wxPython | Buttons") frame.Show(true) self.SetTopWindow(frame) return true app = MyApp(0) app.MainLoop() Custom Button import wx from wxPython.wx import * class Custom_Button(wx.PyControl): ############################################ ##THE ERROR IS BEING THROWN SOME WHERE IN HERE ## ############################################ # The BMP's Mouse_over_bmp = wx.Bitmap(0) # When the mouse is over Norm_bmp = wx.Bitmap(0) # The normal BMP Push_bmp = wx.Bitmap(0) # The down BMP Pos_bmp = wx.Point(0,0) # The posisition of the button def __init__(self, parent, id=-1, NORM_BMP, PUSH_BMP, MOUSE_OVER_BMP, text="", pos, size, **kwargs): wx.PyControl.__init__(self,parent, id, **kwargs) # Set the BMP's to the ones given in the constructor self.Mouse_over_bmp = wx.Bitmap(MOUSE_OVER_BMP) self.Norm_bmp = wx.Bitmap(NORM_BMP) self.Push_bmp = wx.Bitmap(PUSH_BMP) self.Pos_bmp = pos ############################################ ##THE ERROR IS BEING THROWN SOME WHERE IN HERE ## ############################################ self.Bind(wx.EVT_LEFT_DOWN, self._onMouseDown) self.Bind(wx.EVT_LEFT_UP, self._onMouseUp) self.Bind(wx.EVT_LEAVE_WINDOW, self._onMouseLeave) self.Bind(wx.EVT_ENTER_WINDOW, self._onMouseEnter) self.Bind(wx.EVT_ERASE_BACKGROUND,self._onEraseBackground) self.Bind(wx.EVT_PAINT,self._onPaint) self._mouseIn = self._mouseDown = False def _onMouseEnter(self, event): self._mouseIn = True def _onMouseLeave(self, event): self._mouseIn = False def _onMouseDown(self, event): self._mouseDown = True def _onMouseUp(self, event): self._mouseDown = False self.sendButtonEvent() def sendButtonEvent(self): event = wx.CommandEvent(wx.wxEVT_COMMAND_BUTTON_CLICKED, self.GetId()) event.SetInt(0) event.SetEventObject(self) self.GetEventHandler().ProcessEvent(event) def _onEraseBackground(self,event): # reduce flicker pass def _onPaint(self, event): dc = wx.BufferedPaintDC(self) dc.SetFont(self.GetFont()) dc.SetBackground(wx.Brush(self.GetBackgroundColour())) dc.Clear() dc.DrawBitmap(self.Norm_bmp) # draw whatever you want to draw # draw glossy bitmaps e.g. dc.DrawBitmap if self._mouseIn: # If the Mouse is over the button dc.DrawBitmap(self, self.Mouse_over_bmp, self.Pos_bmp, useMask=False) if self._mouseDown: # If the Mouse clicks the button dc.DrawBitmap(self, self.Push_bmp, self.Pos_bmp, useMask=False)

    Read the article

  • Post request with body_stream and parameters

    - by Damien MATHIEU
    Hello, I'm building some kind of proxy. When I call some url in a rack application, I forward that request to an other url. The request I forward is a POST with a file and some parameters. I want to add more parameters. But the file can be quite big. So I send it with Net::HTTP#body_stream instead of Net::HTTP#body. I get my request as a Rack::Request object and I create my Net::HTTP object with that. req = Net::HTTP::Post.new(request.path_info) req.body_stream = request.body req.content_type = request.content_type req.content_length = request.content_length http = Net::HTTP.new(@host, @port) res = http.request(req) I've tried several ways to add the proxy's parameters. But it seems nothing in Net::HTTP allows to add parameters to a body_stream request, only to a body one. Is there a simpler way to proxy a rack request like that ? Or a clean way to add my parameters to my request ?

    Read the article

  • Reliable way to get the "ancestor" of an object with a specific classname, using jQuery

    - by Matt Dawdy
    I've got a javascript function that gets called on change event of a select form element. So, the "this" variable in js refers to the select element. This select element is in a td tag, in a tr tag. The tr tag has a classname of "FilterDetailsRow". Now, I've tested, and if I use this syntax: var filterRow = $(this).parent().parent(); it gets me what I want. However, is there a better way to tell jQuery, "starting with "this" can you please go up my tree of parents until you find one with a classname of "FilterDetailsRow"? Here's what I came up with, but I want to make sure I"m not reinventing the wheel. function GetFilterDetailsRowOfObject(o) { if (o) { if (o.parent()[0].className.indexOf("FilterDetailsRow") != -1) return o; else return GetFilterDetailsRowOfObject(o.parent()); } else { return null; } } Thanks for any advice.

    Read the article

  • A general question about inheritence in the .NET framework

    - by Grant
    I have a general question about inheritance in the .NET framework, lets say you have 2 classes, the first is called Parent and the second is called Child. Child inherits from Parent. Parent wants to ensure that each instance of child executes a specific piece of code when it loads irrespective of whether the child has their own onLoad code explicitly specified. From my experience, if i handle onLoad in the parent and not in the child, the parents onLoad code will fire but if its handled in both classes only the child's code will fire. Is this correct? and if so how can i ensure the parents code will always fire for the child...

    Read the article

  • Python - wxPython custom button -> unbound method __init__()? what?

    - by Wallter
    After looking at questions like this it doesn't make sense that my __init__(self, parrent, id) would be throwing a unbound error? help? main.py import wx from customButton import customButton from wxPython.wx import * class MyFrame(wx.Frame): def __init__(self, parent, ID, title): wxFrame.__init__(self, parent, ID, title, wxDefaultPosition, wxSize(400, 400)) # Non-important code here... # This is the first declaration of the Button1 # This is also where the ERROR is thrown. # Omitting this line causes the window to execute # flawlessly. self.Button1 = customButton.__init__(self, parent, -1) # ... finishes in a basic wx.program style... customButton.py # I've included all of the code in the file # because have no idea where the bug/error happens import wx from wxPython.wx import * class Custom_Button(wx.PyControl): # The BMP's Over_bmp = None #wxEmptyBitmap(1,1,1) # When the mouse is over Norm_bmp = None #wxEmptyBitmap(1,1,1) # The normal BMP Push_bmp = None #wxEmptyBitmap(1,1,1) # The down BMP def __init__(self, parent, id, **kwargs): wx.PyControl.__init__(self,parent, id, **kwargs) # Set the BMP's to the ones given in the constructor #self.Over_bmp = wx.Bitmap(wx.Image(MOUSE_OVER_BMP, wx.BITMAP_TYPE_ANY).ConvertToBitmap()) #self.Norm_bmp = wx.Bitmap(wx.Image(NORM_BMP, wx.BITMAP_TYPE_ANY).ConvertToBitmap()) #self.Push_bmp = wx.Bitmap(wx.Image(PUSH_BMP, wx.BITMAP_TYPE_ANY).ConvertToBitmap()) #self.Pos_bmp = self.pos self.Bind(wx.EVT_LEFT_DOWN, self._onMouseDown) self.Bind(wx.EVT_LEFT_UP, self._onMouseUp) self.Bind(wx.EVT_LEAVE_WINDOW, self._onMouseLeave) self.Bind(wx.EVT_ENTER_WINDOW, self._onMouseEnter) self.Bind(wx.EVT_ERASE_BACKGROUND,self._onEraseBackground) self.Bind(wx.EVT_PAINT,self._onPaint) self._mouseIn = self._mouseDown = False def _onMouseEnter(self, event): self._mouseIn = True def _onMouseLeave(self, event): self._mouseIn = False def _onMouseDown(self, event): self._mouseDown = True def _onMouseUp(self, event): self._mouseDown = False self.sendButtonEvent() def sendButtonEvent(self): event = wx.CommandEvent(wx.wxEVT_COMMAND_BUTTON_CLICKED, self.GetId()) event.SetInt(0) event.SetEventObject(self) self.GetEventHandler().ProcessEvent(event) def _onEraseBackground(self,event): # reduce flicker pass def _onPaint(self, event): dc = wx.BufferedPaintDC(self) dc.SetFont(self.GetFont()) dc.SetBackground(wx.Brush(self.GetBackgroundColour())) dc.Clear() dc.DrawBitmap(self.Norm_bmp) # draw whatever you want to draw # draw glossy bitmaps e.g. dc.DrawBitmap if self._mouseIn: # If the Mouse is over the button dc.DrawBitmap(self, self.Mouse_over_bmp, self.Pos_bmp, useMask=False) if self._mouseDown: # If the Mouse clicks the button dc.DrawBitmap(self, self.Push_bmp, self.Pos_bmp, useMask=False)

    Read the article

  • ListAdapters and WrapperListAdapter algorithm

    - by Matty F
    This logic is written in a function with signature private void showDialog(final AdapterView<? extends Adapter> parent, String title, String message, final Tag subject) Is there a better way of doing this? // refresh adapter SimpleCursorAdapter adapter; if (parent.getAdapter() instanceof WrapperListAdapter) { adapter = (SimpleCursorAdapter) ((WrapperListAdapter) parent.getAdapter()).getWrappedAdapter(); } else { adapter = (SimpleCursorAdapter) parent.getAdapter(); } adapter.getCursor().requery(); adapter.notifyDataSetChanged(); Also, is there any point in having AdapterView<? extends Adapter> in the signature and not just AdapterView<?>?

    Read the article

  • Why is my slot not being called?

    - by Jen
    I have this class: class CustomEdit : public QTextEdit { Q_GADGET public: CustomEdit(QWidget* parent); public slots: void onTextChanged (); }; CustomEdit::CustomEdit(QWidget* parent) : QTextEdit(parent) { connect( this, SIGNAL(textChanged()), this, SLOT(onTextChanged())); } void CustomEdit::onTextChanged () { // ... do stuff } The onTextChanged method is never called when I type text into the edit control. What am I missing?

    Read the article

  • Counting leaf nodes in hierarchical tree

    - by timn
    This code fills a tree with values based their depths. But when traversing the tree, I cannot manage to determine the actual number of children. node-cnt is always 0. I've already tried node-parent-cnt but that gives me lots of warnings in Valgrind. Anyway, is the tree type I've chosen even appropriate for my purpose? #include <string.h> #include <stdio.h> #include <stdlib.h> #ifndef NULL #define NULL ((void *) 0) #endif // ---- typedef struct _Tree_Node { // data ptr void *p; // number of nodes int cnt; struct _Tree_Node *nodes; // parent nodes struct _Tree_Node *parent; } Tree_Node; typedef struct { Tree_Node root; } Tree; void Tree_Init(Tree *this) { this->root.p = NULL; this->root.cnt = 0; this->root.nodes = NULL; this->root.parent = NULL; } Tree_Node* Tree_AddNode(Tree_Node *node) { if (node->cnt == 0) { node->nodes = malloc(sizeof(Tree_Node)); } else { node->nodes = realloc( node->nodes, (node->cnt + 1) * sizeof(Tree_Node) ); } Tree_Node *res = &node->nodes[node->cnt]; res->p = NULL; res->cnt = 0; res->nodes = NULL; res->parent = node; node->cnt++; return res; } // ---- void handleNode(Tree_Node *node, int depth) { int j = depth; printf("\n"); while (j--) { printf(" "); } printf("depth=%d ", depth); if (node->p == NULL) { goto out; } printf("value=%s cnt=%d", node->p, node->cnt); out: for (int i = 0; i < node->cnt; i++) { handleNode(&node->nodes[i], depth + 1); } } Tree tree; int curdepth; Tree_Node *curnode; void add(int depth, char *s) { printf("%s: depth (%d) > curdepth (%d): %d\n", s, depth, curdepth, depth > curdepth); if (depth > curdepth) { curnode = Tree_AddNode(curnode); Tree_Node *node = Tree_AddNode(curnode); node->p = malloc(strlen(s)); memcpy(node->p, s, strlen(s)); curdepth++; } else { while (curdepth - depth > 0) { if (curnode->parent == NULL) { printf("Illegal nesting\n"); return; } curnode = curnode->parent; curdepth--; } Tree_Node *node = Tree_AddNode(curnode); node->p = malloc(strlen(s)); memcpy(node->p, s, strlen(s)); } } void main(void) { Tree_Init(&tree); curnode = &tree.root; curdepth = 0; add(0, "1"); add(1, "1.1"); add(2, "1.1.1"); add(3, "1.1.1.1"); add(4, "1.1.1.1.1"); add(2, "1.1.2"); add(0, "2"); handleNode(&tree.root, 0); }

    Read the article

< Previous Page | 52 53 54 55 56 57 58 59 60 61 62 63  | Next Page >