aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/modeldelegates.cpp
AgeCommit message (Collapse)Author
2014-08-29Revert hacks now that we use Qt5 on MacGravatar Dirk Hohndel
Commits a24eb8ac120bf and 0b0860d24a81b introduced a nasty hack that was needed back then to make tank and weight selection work on the Mac. But it caused other unpleasant issues (as mentioned in the commit messages). I re-tested this with the current Qt5.3 based builds on Mac and this hack is no longer needed. Fixes #638 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-23Whitespace fixes.Gravatar Tomaz Canabrava
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-18Do not plot text twice for information.Gravatar Tomaz Canabrava
Well, the information was bad, it was being printed twice if the text is HTML, print only once. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-18Add the HTML Delegate to printing.Gravatar Tomaz Canabrava
This patch just adds the HTML Delegate to print the text. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-18Save / Restore the QPainter before operations.Gravatar Tomaz Canabrava
I don't know if this fixes anything, but it is asked of us to do that by the Qt docs. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-18Added a HTML Displayable DelegateGravatar Tomaz Canabrava
Added a HTML delegate to show rendered HTML on print. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-16Fixed creating recursion on the connectionsGravatar Tomaz Canabrava
Ugh. Each time you wanted to change a cylinder, a new connection was being created on this object, delaying the correctly setup of the item. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-16Complete the name of the first Cylinder on editGravatar Tomaz Canabrava
When you entered part of the name of a cylinder this was being treated as a new cylinder, and not selecting the first one. Fixes #628 Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-15Selects the delegate text on Cylinder editionGravatar Tomaz Canabrava
The text selection was not being set, bummer. See #628 Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-12Add step size in our SpinBox delegatesGravatar Anton Lundin
For the Set point spinbox, it was kinda hard just stepping by the default 1.0, so setting it to step by 0.1 makes much more sense. The int SpinBox got a step size parameter for consistency. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-12Use doubles in DoubleSpinBoxDelegateGravatar Anton Lundin
The previous code used qreals, but it feels clearer to use doubles when the name of the class contains the word double. The performance loss of using doubles instead of floats on arm is non-existent in this case. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-11Fixed input in the DivePlanner tableGravatar Tomaz Canabrava
Based on Glance's idea on rewritting the Delegates, but we don't need to redo the wheel as Qt already gives us the correct Delegate, we just need to set some boundaries on it before returning. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-20Change the Star Widget to use QImage instead of QPixmapGravatar Tomaz Canabrava
Also, clean a few calls, this should make the widget a tiny bit faster. This patch also moves the grayImage function from the star widget to the global scope, so I can use it on the Calendar widget. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-22Gratuitous whitespace changesGravatar Dirk Hohndel
I keep trying to get to consistenct. Completely hopeless. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-25Better handling of mouse on the delegates ( Equipment Edition )Gravatar Tomaz Canabrava
This adds more handling of missing actions for the mouse on the equipment edition. It complements the stuff talked about on bug 359, but it's a different issue. 359 seems already fixed. See #359 Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-20Better handling of keyboard on the inline edition on equipmentGravatar Tomaz Canabrava
The handling of keyboard is broken on Qt inside QComboBoxes. I'm trying ( and losing ) to make it less broken. This patch makes the code work reasonably well if you press Key_down or Key_up after having displayed the filter popup, which is different from the combobox popup for some reason. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-27Massive automated whitespace cleanupGravatar Dirk Hohndel
I know everyone will hate it. Go ahead. Complain. Call me names. At least now things are consistent and reproducible. If you want changes, have your complaint come with a patch to scripts/whitespace.pl so that we can automate it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11Update #include statement for QStringListModelGravatar Boris Barbulovski
Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16Whitespace and coding style updatesGravatar Dirk Hohndel
Another futile attempt to cleanup the code and make coding style and whitespace consistent. I tried to add a file that describes the key points of our coding style. I have no illusions that this will help the least bit... This commit should ONLY change whitespace Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-12Copyed the code from Dirk that solved the mac issue on cylinders.Gravatar Tomaz Canabrava
This is the same code that Dirk used on the Mac to fix the bad-behavior of Cylinder Selection, this time applyed to Weigthsystem selection. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-12Fix TableWidget ( equipment ones ) on dark scheme.Gravatar Tomaz Canabrava
This patch uses the class created by the previous patch to get rid of the CSS and be really desktop native. it fixes a lot of stuff in non-blue-styles and throws a lot of code away. <3 Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-12Kill the use of CSS - Fixes a Lot of issues on dark color schemes.Gravatar Tomaz Canabrava
The css was done by me in the first days of subsurface for Qt, and it was a code that I was never proud of. Mostly because I tougth at the time that it was better to write it into CSS than to create a new class just to take care of the size of the default cell height on a tree view. Now I see that it was a biased approach since it created issues on dark color schemes and it also didn't make a 'native' experience on Gnome or OSX, only on KDE. This fixes that. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-30Print: fix missing vertical line at the last columnGravatar Lubomir I. Ivanov
There was a line missing in the right-most column wrapping the table for the profile print. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-11-30Print: update drawing of the profile table gridGravatar Lubomir I. Ivanov
The new table layout requires that we draw the vertical and horizontal lines differently. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-11-21Hack to make tank selection work on MacGravatar Dirk Hohndel
This is an ugly hack as it partially breaks the ability to abort a selection (so if you click outside of the combobox, the last value you hovered over is selected). But this seems much better than not being able to select a different tank at all. Fixes #275 (and by 'Fixes' I mean "hacks to sort of make work"... but the trac automation is rather inflexible in which words it understands...) Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15Correctly handle changes on the CylinderModel to update the AirModel.Gravatar Tomaz Canabrava
What happened before was that the AirTypes model was only being updated when the user requested to change the air by clicking directly on the Air, in the planner ( but not on the Air Table. ). This fixes it by calling 'repopulate' whenever the cylinder model changes ( by adding, removing and changing something.) Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-11Connect cylinders entered in planner with the gases availableGravatar Dirk Hohndel
Now the gases for which we have cylinders are offered in the gas selection list and correctly recognized and added for the plan. Still tons of work to be done to make this work the way it is designed, but we are getting closer. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-15Fixed the Tab behavior on the QCombobox DelegateGravatar Tomaz Canabrava
This Patch fixes the tab behavior on the QComboBox delegate. For a QComboBox, tab was being treated as 'cancel' action on edit, but since it will send a editingFinished() signal, and the Qt::Key_Return will also send a editingFinished() signal, I couldn't use that method and had to do a little hack around it. The code is mostly clean and works. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-11Good deal of whitespace fixes and code cleanup.Gravatar Tomaz Canabrava
I just went thru all of subsurface code removing some whitespaces issues and trying to make the code prettyer, I also removed a few QString issues.d Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-10-04Correct spelling of "weight" throughout the code.Gravatar Benjamin
"Weight" was misspelled "weigth" in several places in the code and comments. Signed-off-by: Benjamin Fogel <nystire@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-03Print: provide means to print profile tablesGravatar Lubomir I. Ivanov
This patch adds a couple of classes and some other modifications in PrintLayout that handle the printing of tables under a profile. models.h : ProfilePrintModel The class uses a 'struct *dive' to output all required data for a certain dive at specific rows and columns. It also handles font formatting and text alignment. modeldelagatates.h : ProfilePrintDelegate The class is used only for drawing a custom grid for profile tables. PrintLayout::createProfileTable() The function is used to create and setup the profile table object PrintLayout::printProfileDives() The function now has correct padding of dive profiles on a page and also the printing of actual tables below them. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-27Hack to make the subsurface work on Gnome3 shellGravatar Tomaz Canabrava
The Gtk+ style on the Gnome shell is somewhat broken on Qt for some reason. This hack pokes the system, checks if it's running gnome-shell, and if the current style is gtk+ ( I couldn't just check for gtk+ since it worked on XFCE and other Gtk based enviro ments. so a double check is needed. ) then I changed the Pallete of the affected widgets by hand. not a pretty hack but worked. [Dirk Hohndel: redid the patch to be simpler and more consistent] Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-26Fix the edition of cylinders and weigths by keypressGravatar Tomaz Canabrava
This patch fixes the cylinders and weigth edition by keypress. I don`t know when I broke this and linus found, most probably when I added the code for showing the cylinder size and working press while moving the mouse around the list - sorry guys. So, now this *seems* fixed, tested for a fairly good amount of time and everything seemed ok. I was unable to reproduce the behavior that linus got on two value overlapped on each other, tougth. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-09-26Set the Cylinder/Weigth even if it's the same old value.Gravatar Tomaz Canabrava
Since the cylinders and weigths have other data attached to it, like size and working pressure, one could mess the other data and want it to revert to the cylinder / weigth defaults, but for that the user had to choose another item, then go back to the previous one, so the cache would be clean. This patch fixes that by reverting the values to the it fixes linus bug n2, where he had invalid data on the other fields and had to go back and forth for it to be fixed. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-09-25Make the Qt ComboBox behave in a Better WayGravatar Tomaz Canabrava
So, the ComboBox is a beast, and when used on a Delegate it's very hard to get things right, wich is a pitty, because I overly like qt. So: 1 - Combobox needs to show the popup when user press ↓ and ↑ keys 2 - Combobox needs to select when user press enter, not twice. 3 - Combobox neesds to select when user selects from the mouse, not pressing enter after. 4 - Combobox needs to not mess with stuff when moving around. Everything that I listed there works on a non-delegate combobox, but for some reason, a delegate missed those, so I reimplemented all. not nice, but now we have a code that will work, I hope. *fingers crossed* Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-09-10Fill ws_info structure and use it when entering weight systemsGravatar Dirk Hohndel
The code to initialize the weight systems from the last datafile loaded had not been brought over from the Gtk version. We now correctly update the data structure when loading file (but not yet when editing values). Most likely the same needs to be done for the tanks as well. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-09Enable the CC SetPoint on the planner, also input bug fix.Gravatar Tomaz Canabrava
Enabled the CC SetPoint settings on the table, changing it will automatically reflect the canvas. Also fixed a bug that prevented the 'Air' handling on the diveplanner table to show the list of options using arrow up and down. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-30Corrected spelling of "weight" in the preferences dialog and codeGravatar Benjamin
"weight" was spelled as "weigth" in a few places in the code, but more importantly, it was misspelled in the preferences dialog. A minor nit-pick, maybe, but it still drew the eye in the dialog and looked weird. Signed-off-by: Benjamin Fogel <benjaminfogel@yahoo.co.uk> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-08-30Gas choices working, both directions ( Planner and Table )Gravatar Tomaz Canabrava
The gas choice now works and correctly ( I hope ) calculates the gas choosen to show on the planner. User can choose the gas from the list on the visual planner, and also on the table. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-30Started the work of Editable Model for the PlannerGravatar Tomaz Canabrava
This commit is the start of the Editable Model work for the planner, it creates a new delegate and shares the code for the model that creates the gas types, so we only need to change in one place to add new gases. The table is already edition-enabled, but the outcome is still undone, next commit - put all together. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-18Added the code to revert Weigths when user cancels editionGravatar Tomaz Canabrava
This is a follow up commit to the previous one that enabled cancel for cylinders, everything in the commit log for the cylinders also applyes here. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-18'Cancel' action Cancels editing Cylinders.Gravatar Tomaz Canabrava
Made the default 'Cancel' action correctly cancel the cylinder edition. This is needed only because we bypassed the default behavior on Qt that took care of this, because we wanted to have more control on how the view would update the items accordingly with wich one of the cylinders were selected on the edition pane - the pressure and size of the cylinders needed to have it's data set, but the Qt Model/View system *thinks* that cancel-edition is simply 'do not commit the edition data, then.' wich would not work with us, because we passed the strange data already. So, I created a backup data that serves us very well. When the user cancels, this backup data is added back on the cylinder, making everything as it was before. [Dirk Hohndel: removed the inadvertendly added boost header] Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-18Don't set if equal, on edit cylinders and weigth types.Gravatar Tomaz Canabrava
Don't set the cylinders and weight types if they are the same than before, this fixes a bad thing that happened when playing with the values. it could blank out the values carefully chosen by you. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-17Added EnterKey to finish edition on Cyl/Weigths with the popup openGravatar Tomaz Canabrava
So, I used the Qt Event Filter strategy to bypass the normal role of user interaction, the Qt ComboBox needed 2 keypresses to close and edit. so I grabbed the first one and send together a second one. Há. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-16Fixes the Combobox behavior on the inline-editGravatar Tomaz Canabrava
This patch fixes the combobox behavior on the inline edit to what it was ( well, similar to ) the GTK version, up and arrow keys will walk you to the list of choices, and it will update the other data as soon as you walks over it one drawback is that you cant ( for now, since I do have a very big headache at the moment ) cancel, since the cancel will just forgets the item and do not call 'setData' on the model, but we already called it while walking on the list. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-16Support for key_up and down in the combobox delegate.Gravatar Tomaz Canabrava
Adds spport for key_up and key_down in the combobox delegates, now when you press key_up or down, it will show the list of choices instead of going one-by-one in the lineedit. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-17Changed a lot of code to reduce boilerplate on models in the future.Gravatar Tomaz Canabrava
So, I changed a lot of code to reduce boilerplate on models in the future. Currently we do not have a lot of models, but this can increase quite rapdly. There's a second TreeModel in the works, the Yearly Statistics, this patch will save around 250 LOC for this new model, and more and more models will give us a greater saving. Iwll do that for the table models in the future too - I did the tree models now because they are the most complex case and I didn't wanted to create a second tree model without this. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-16Better handling of default sizes on the Cylinder and Weight widgetsGravatar Tomaz Canabrava
Better handling of default sizes on the Cylinder and weight widgets, the weigth widget didn't had a CSS applied so it looked odd compared to the cylinder one, also the default behavior for the combobox delegate didn't worked very well with the css applied, being too small. this patch fixes that. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-16Create a 'ComboBoxDelegate' to concentrate the comboboxness of delegates.Gravatar Tomaz Canabrava
This patch creates a ComboBoxDelegate where the other specific delegates should inherit from. this adds a little code cleanup for the current version, and will help as soon as more delegates got added to the code. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-23Correctly add new weight / cylinder types, even when hitting 'tab'Gravatar Dirk Hohndel
We now detect if a weight / cylinder with this description exists and if not add it on the fly. We also remember the additional values (weight and size / workingpressure) for new entries and take the values for these fields into account when autocompleting. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>