flags

WPF ComboBox/ListBox with MultiSelect based on Enum with Flags

安稳与你 提交于 2019-11-28 04:17:26
问题 So I may be pushing the boundaries just a bit... Basically I have the following enum, declared in C# code: [Flags] public enum FlaggedEnum : int { Option1 = 1, Option2 = 2, Option3 = 4, Option4 = 8, ... Option16 = 32768, None = 0 } This enum is a member of an object which I have successfully bound to a DataGrid object. Successfully meaning that I have bound all the other fields successfully. :) What I want to achieve here is a control where all the appropriate options above are checked, that

object editing and isDirty() flag

霸气de小男生 提交于 2019-11-28 03:38:44
问题 I'm working on a system were a user can edit existing objects ("Filter" domain objects to be exact) through a GUI. As a UI hint, we only want to enable the save button if the user really modified something to the object. I was wondering if anyone had any experience with this problem and what the best way would be to approach this. I was thinking about adding an isDirty() flag to the domain object. When a user starts editing a Filter, I would then make a copy, pass it to the GUI and let the

Conditional compilation in gfortran

浪子不回头ぞ 提交于 2019-11-28 01:50:29
问题 I want to know if it is possible to select different parts of my Fortran 95 routine to compile. For example, if I pass certain flag to gfortran, then the compiler chooses which section to use for a certain function. I know I can do it using if inside the routine, but the drawback is that I don't want the program to run the if all the time due to speed concerns. I suppose solution should be similar to this one I am working specifically with a program that calculates energies in a many-body

How to get imap flags?

倖福魔咒の 提交于 2019-11-28 01:21:58
问题 I used the imap4flag plugin for Dovecot sieve: http://wiki.dovecot.org/LDA/Sieve#Flagging_or_Highlighting_your_mail The flag is correctly show in thunderbird but I search how get the flags for show them in roundcube. Thank's in advance. 回答1: This is a missing feature, see the PHP bug #53043 : http://bugs.php.net/bug.php?id=53043 A example code using directly the IMAP protocol: <?php declare(strict_types=1); class ImapSocket { private $socket; public function __construct($options, $mailbox = '

Making only one column of a QTreeWidgetItem editable

自古美人都是妖i 提交于 2019-11-27 22:44:32
I have a QTreeWidgetItem with two columns of data, is there any way to make only the second column editable? When I do the following: QTreeWidgetItem* item = new QTreeWidgetItem(); item->setFlags(item->flags() | Qt::ItemIsEditable); all columns become editable. Looks like you will have to forgo using QTreeWidget and QTreeWidgetItem and go with QTreeView and QAbstractItemModel . The "Widget" classes are convenience classes that are concrete implementations of the more abstract but more flexible versions. QAbstractItemModel has a call flags(QModelIndex index) where you would return the

What Does the [Flags] Attribute Really Do?

我与影子孤独终老i 提交于 2019-11-27 22:43:04
What does applying [Flags] really do? I know it modifies the behavior of Enum.ToString , but does it do anything else? (e.g. Different compiler or runtime behavior, etc.) Edit : Yeah, I'm aware that it documents the fact that the enum is intended to be used as bitwise flags, and that it's more logical to apply it to bit flags. I was asking more about concrete behavior changes though, not general programming practices. From an MSDN article : It is interesting to note that when Flags is specified, Parse and Format methods feature advanced capabilities. Likewise, the Parse method can successfully

Removing Strikethrough from TextView

让人想犯罪 __ 提交于 2019-11-27 21:06:25
问题 I'm using this line below in order to set a strikethrough on my TextView: tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); However later on in the Fragment, if they click the TextView again, I would like the strikethrough to be removed. What line of code can I use to simply make the TextView display the text in the normal format again? Thanks in advance! 回答1: I ended up finding this online: tv.setPaintFlags(tv.getPaintFlags() & (~ Paint.STRIKE_THRU_TEXT_FLAG)); This

Start new Activity and finish current one in Android? [duplicate]

冷暖自知 提交于 2019-11-27 18:15:53
This question already has an answer here: How to finish current activity in Android 7 answers Currently I'm starting a new Activity and calling finish on a current one. Is there any flag that can be passed to Intent that enables finishing current Activity without a need to call finish manually from code? You can use finish() method or you can use: android:noHistory="true" And then there is no need to call finish() anymore. <activity android:name=".ClassName" android:noHistory="true" ... /> Avi Kumar Manku Use finish like this: Intent i = new Intent(Main_Menu.this, NextActivity.class); finish()

GCC: how is march different from mtune?

允我心安 提交于 2019-11-27 17:39:44
I tried to scrub the GCC man page for this, but still don't get it, really. What's the difference between -march and -mtune ? When does one use just -march , vs. both? Is it ever possible to just -mtune ? If you use -march then GCC will be free to generate instructions that work on the specified CPU, but not on (typically) earlier CPUs in the architecture family. If you use -mtune , then the compiler will generate code that works on any of them, but will favour instruction sequences that run fastest on the specific CPU you indicated. This is what i've googled up: The -march=X option takes a

Why do enum permissions often have 0, 1, 2, 4 values?

血红的双手。 提交于 2019-11-27 16:47:34
Why are people always using enum values like 0, 1, 2, 4, 8 and not 0, 1, 2, 3, 4 ? Has this something to do with bit operations, etc.? I would really appreciate a small sample snippet on how this is used correctly :) [Flags] public enum Permissions { None = 0, Read = 1, Write = 2, Delete = 4 } Because they are powers of two and I can do this: var permissions = Permissions.Read | Permissions.Write; And perhaps later... if( (permissions & Permissions.Write) == Permissions.Write ) { // we have write access } It is a bit field, where each set bit corresponds to some permission (or whatever the