You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
(2) |
Apr
(3) |
May
|
Jun
(45) |
Jul
(4) |
Aug
|
Sep
(7) |
Oct
(1) |
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
(4) |
Feb
(4) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
(1) |
Nov
|
Dec
(7) |
2010 |
Jan
(9) |
Feb
(5) |
Mar
(22) |
Apr
(1) |
May
(5) |
Jun
|
Jul
(2) |
Aug
|
Sep
(22) |
Oct
(6) |
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(17) |
Jul
(5) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Cerion Armour-B. <ce...@ke...> - 2010-07-28 21:24:58
|
Hi Hendrik, Great to hear you're interested in helping out! Indeed, Valkyrie is being ported to Qt4. It's fairly far along already, but is still in need of some serious testing. I'm currently working on organising the issue list, and I'll get that to you asap. It needs to go online (e.g. bugzilla, as Valgrind uses), but no time to organise that right now. Best thing you could help with currently is testing and bug fixing for the first release. After that's done, it needs extending for better support of the Valgrind tools that output xml. The current Qt4 port is available for download via svn: svn co svn://svn.valgrind.org/valkyrie/branches/valkyrie_qt4port I suggest you take a look first, see whether you're still interested and whether you think you can usefully contribute. Let me know what you think. Regards, Cerion Henrik null wrote: > Hi! > > My name is Henrik. I have almost two years of experience of > object-oriented programming and feel comfortable with Java, C#/C++, > Python, MATLAB, GTK and Java Swing. Next month I will start my > education to Master of Science in Engeneering at the Royal Institute > of Technology in Sweden. I would like to contribute as a > developer/programmer by writing code for an open source project. I > could do anything from building a GUI to writing a class for a > specific problem. I am hoping joining an open source project as a > developer will improve my programming skills. > > I subscribed to the Debian Mentor's mailing list to get tips about > projects to join. Zaar Hai (ha...@ha...) told me valkyrie is > currently rewritten using QT4 and I would like to contribute to this > work. > > Best regards, > Henrik > sp...@ho... > > ------------------------------------------------------------------------ > Hotmail: Powerful Free email with security by Microsoft. Get it now. > <https://signup.live.com/signup.aspx?id=60969> > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > The Palm PDK Hot Apps Program offers developers who use the > Plug-In Development Kit to bring their C/C++ apps to Palm for a share > of $1 Million in cash or HP Products. Visit us here for more details: > http://ad.doubleclick.net/clk;226879339;13503038;l? > http://clk.atdmt.com/CRS/go/247765532/direct/01/ > > ------------------------------------------------------------------------ > > _______________________________________________ > Valgrind-Valkyrie-dev mailing list > Val...@li... > https://lists.sourceforge.net/lists/listinfo/valgrind-valkyrie-dev |
From: Henrik n. <sp...@ho...> - 2010-07-27 13:41:05
|
Hi! My name is Henrik. I have almost two years of experience of object-oriented programming and feel comfortable with Java, C#/C++, Python, MATLAB, GTK and Java Swing. Next month I will start my education to Master of Science in Engeneering at the Royal Institute of Technology in Sweden. I would like to contribute as a developer/programmer by writing code for an open source project. I could do anything from building a GUI to writing a class for a specific problem. I am hoping joining an open source project as a developer will improve my programming skills. I subscribed to the Debian Mentor's mailing list to get tips about projects to join. Zaar Hai (ha...@ha...) told me valkyrie is currently rewritten using QT4 and I would like to contribute to this work. Best regards, Henrik sp...@ho... _________________________________________________________________ Hotmail: Powerful Free email with security by Microsoft. https://signup.live.com/signup.aspx?id=60969 |
From: Zaar H. <ha...@ha...> - 2010-05-16 06:11:55
|
On Fri, May 14, 2010 at 2:37 PM, Cerion Armour-Brown <ce...@ke...> wrote: > Nope - the trunk supports Vg 3.4 only. > But the qt4 branch supports (as yet unreleased) Vg 3.6 already. Got it. I'll start right away with qt4. Thank you. -- Zaar |
From: Cerion Armour-B. <ce...@ke...> - 2010-05-14 11:37:23
|
Nope - the trunk supports Vg 3.4 only. But the qt4 branch supports (as yet unreleased) Vg 3.6 already. Regards, Cerion Zaar Hai wrote: > Hello, Cerion! > > On Thu, May 13, 2010 at 1:31 PM, Cerion Armour-Brown <ce...@ke...> wrote: > >> Hi there Zaar, >> >> The latest under the qt4port branch will become the next release: >> branches/valkyrie_qt4port. >> It's in a fairly good state, but I really need some testing feedback. >> If that's too beta for you, then by all means take a trunk snapshot - that's >> stable, but still uses Qt3. >> > Just to get it clear: does trunk Qt3 version supports latest valgrind 3.5? > > Best, > |
From: Zaar H. <ha...@ha...> - 2010-05-13 11:20:57
|
Hello, Cerion! On Thu, May 13, 2010 at 1:31 PM, Cerion Armour-Brown <ce...@ke...> wrote: > Hi there Zaar, > > The latest under the qt4port branch will become the next release: > branches/valkyrie_qt4port. > It's in a fairly good state, but I really need some testing feedback. > If that's too beta for you, then by all means take a trunk snapshot - that's > stable, but still uses Qt3. Just to get it clear: does trunk Qt3 version supports latest valgrind 3.5? Best, -- Zaar |
From: Cerion Armour-B. <ce...@ke...> - 2010-05-13 10:46:30
|
Hi there Zaar, The latest under the qt4port branch will become the next release: branches/valkyrie_qt4port. It's in a fairly good state, but I really need some testing feedback. If that's too beta for you, then by all means take a trunk snapshot - that's stable, but still uses Qt3. Great that you want this in the Debian release, and I'd love to help push for that, but I'm afraid it's unlikely I'll be able to find time to work on this until june. Regards, Cerion Zaar Hai wrote: > Hi, guys! > > Debian squeeze is going to freeze soon, but so far I do not see any > valkyrie release to push there. I do want valkyrie to go to Debian > software repository. > So I shall ask: > 1. Is there going to be any, at least beta, release until end of May? > 2. If not, I suggest I'll start with current trunk snapshot. > > Thank you, > |
From: Zaar H. <ha...@ha...> - 2010-05-11 06:25:51
|
Hi, guys! Debian squeeze is going to freeze soon, but so far I do not see any valkyrie release to push there. I do want valkyrie to go to Debian software repository. So I shall ask: 1. Is there going to be any, at least beta, release until end of May? 2. If not, I suggest I'll start with current trunk snapshot. Thank you, -- Zaar |
From: <sv...@va...> - 2010-04-07 23:20:22
|
Author: sewardj Date: 2010-04-08 00:20:12 +0100 (Thu, 08 Apr 2010) New Revision: 499 Log: Don't decline to show me the source text just because the source file happens to be reachable through a symlink -- that's actually very] common. Hmm, what if the symlink is dangling? Need a better check here. Modified: branches/valkyrie_qt4port/toolview/vglogview.cpp Modified: branches/valkyrie_qt4port/toolview/vglogview.cpp =================================================================== --- branches/valkyrie_qt4port/toolview/vglogview.cpp 2010-03-27 21:29:52 UTC (rev 498) +++ branches/valkyrie_qt4port/toolview/vglogview.cpp 2010-04-07 23:20:12 UTC (rev 499) @@ -723,7 +723,7 @@ QFileInfo fi( path ); - if ( fi.exists() && fi.isFile() && !fi.isSymLink() ) { + if ( fi.exists() && fi.isFile() /* && !fi.isSymLink() */) { isReadable = fi.isReadable(); isWriteable = fi.isWritable(); } |
From: <sv...@va...> - 2010-03-27 21:30:01
|
Author: cerion Date: 2010-03-27 21:29:52 +0000 (Sat, 27 Mar 2010) New Revision: 498 Log: Helgrind now supported. - Replaced all occurences of hthreadid #id with #HG_id, to clearly distinguish from real thread-id's. - Almost all of memcheck_object has moved to tool_object base-class - HelgrindView is simply a copy of MemcheckView, but am waiting until the next tool before moving this lot to the toolview base-class. And some misc cleaning up: - Error message from failed XML parsing now shown to user e.g because memcheck Vk tool used for opening a helgrind xml log file. - Removed tool process enum extension - unlikely to ever be used. - Refactored some VkOptionPage code: used Template Method to reduce duplicate code. Added: branches/valkyrie_qt4port/toolview/helgrind_logview.cpp branches/valkyrie_qt4port/toolview/helgrind_logview.h Modified: branches/valkyrie_qt4port/mainwindow.cpp branches/valkyrie_qt4port/objects/helgrind_object.cpp branches/valkyrie_qt4port/objects/helgrind_object.h branches/valkyrie_qt4port/objects/memcheck_object.cpp branches/valkyrie_qt4port/objects/memcheck_object.h branches/valkyrie_qt4port/objects/tool_object.cpp branches/valkyrie_qt4port/objects/tool_object.h branches/valkyrie_qt4port/objects/valkyrie_object.cpp branches/valkyrie_qt4port/objects/vk_objects.h branches/valkyrie_qt4port/options/helgrind_options_page.cpp branches/valkyrie_qt4port/options/memcheck_options_page.cpp branches/valkyrie_qt4port/options/valgrind_options_page.cpp branches/valkyrie_qt4port/options/valkyrie_options_page.cpp branches/valkyrie_qt4port/options/vk_options_dialog.cpp branches/valkyrie_qt4port/options/vk_options_page.cpp branches/valkyrie_qt4port/options/vk_options_page.h branches/valkyrie_qt4port/toolview/helgrindview.cpp branches/valkyrie_qt4port/toolview/helgrindview.h branches/valkyrie_qt4port/toolview/memcheck_logview.cpp branches/valkyrie_qt4port/toolview/memcheck_logview.h branches/valkyrie_qt4port/toolview/memcheckview.cpp branches/valkyrie_qt4port/toolview/memcheckview.h branches/valkyrie_qt4port/toolview/toolview.cpp branches/valkyrie_qt4port/toolview/toolview.h branches/valkyrie_qt4port/toolview/vglogview.cpp branches/valkyrie_qt4port/toolview/vglogview.h branches/valkyrie_qt4port/utils/vglogreader.cpp branches/valkyrie_qt4port/utils/vk_logpoller.cpp branches/valkyrie_qt4port/utils/vk_logpoller.h branches/valkyrie_qt4port/valkyrie.pro [... diff too large to include ...] |
From: <sv...@va...> - 2010-03-26 21:30:16
|
Author: cerion Date: 2010-03-26 21:30:07 +0000 (Fri, 26 Mar 2010) New Revision: 497 Log: Cleaned up the xml parsing - Removed all remainders of merge support this allowed removal of vglog (wrapper for qdomdoc) - Now just have vglogview, which the parser (vglogreader) populates with top-level nodes incrementally. vglogview holds the model (qdomdoc), and updates the both the model and the view. - Separated the tool-specific parsing and displaying to <tool>logview classes (currently only memcheck still, but adding helgrind should be real easy now.) - Support for Vg XML protocol 4 (Vg3.6). Older protocols no longer supported. Oh for some Qt XML binding support... Added: branches/valkyrie_qt4port/toolview/memcheck_logview.cpp branches/valkyrie_qt4port/toolview/memcheck_logview.h Removed: branches/valkyrie_qt4port/utils/vglog.cpp branches/valkyrie_qt4port/utils/vglog.h Modified: branches/valkyrie_qt4port/objects/memcheck_object.cpp branches/valkyrie_qt4port/objects/valgrind_object.cpp branches/valkyrie_qt4port/toolview/memcheckview.cpp branches/valkyrie_qt4port/toolview/memcheckview.h branches/valkyrie_qt4port/toolview/vglogview.cpp branches/valkyrie_qt4port/toolview/vglogview.h branches/valkyrie_qt4port/utils/vglogreader.cpp branches/valkyrie_qt4port/utils/vglogreader.h branches/valkyrie_qt4port/valkyrie.pro [... diff too large to include ...] |
From: Cerion Armour-B. <ce...@ke...> - 2010-03-22 22:01:22
|
Hi Adu, I just fell across your email from a while back, and am not sure if you ever got a response... We're working hard on the next release of Valkyrie, for Qt4, and supporting the latest version of Valgrind. Thanks for your feedback. - those links are confusing, I agree, I'll add it to the todo list. - time to Vk release: hard to estimate, but right now I need Testers! I'll send a separate mail soon about that. To finish off memcheck support, add helgrind, test, make packagable, etc... probably at least another month, given my current resources. Feature Requests: 1) Error -> context_menu -> text representation - If that's something that more people would like to see, that should be no problem. I'll put it on the (bottom of the) todo list - if other people let me know they want this, it'll move up in priority. 2) Filtering error log. - Hmm. The proper answer to this is: you do not want to do this. Errors further down the log are very often related to errors further up. The errors should thus be fixed in order, from top to bottom, else its wasted work. If you can convince me that there's a practical reason why filtering like this is still necessary, and that others want this too, then no problem, but I don't think this is the right direction to go. As for .supp resources, I'm afraid I can't help you there - best to try the valgrind-users list for that. Regards, Cerion adu wrote: > > Hi! First of all I want to thanks for such amazing program)) > > But there are still some problem/misunderstandings and etc )) > > First of all we have 3 links > > http://valgrind.org/downloads/guis.html > > http://www.open-works.net/projects/valkyrie.html > > http://valgrind.org/downloads/current.html > > The first 2 of ‘em – are talking about 1.3.0 version even there is > already 1.4.0! > > And (I hope very) soon there will be 1.5.0 version))) > > Maybe someone has to change all those places in one manner? > > Whereupon - here it is very difficult question – well, how much time > (approximately of course) it is necessary > > to wait till the moment of release of the new version? > > I understand what all is relative - but nevertheless is here quite > certain milestone? > > In the second: I suggest adding not only support for 3.5 version of > valgrind but also introduce new feature in valkyrie itself: > > 1. Selecting of node of errors tree and to call context-menu. > > Which will contain (for now) only 1 item - «Copy error in clipboard»? > > And hereby we will have error as a 'plain formatted text' – we will > have representation of current selected error > > from the global errors tree for a future using. For ex. I (as a > Tester) can send to developers only small (but useful) piece of > valgrind log. > > Because right now I HAVE TO create and to send ALL log. Of course such > trick should work only with first-level nodes. > > 2. Filters for valgrind output in main window. > > Right now we can see (in situation with a real huge amount of errors) > very loooooong error’s listing in main window – and sometimes > > to open each kind of found error from this list and make something > useful in source code for removing this error – is quit difficult > because this list is very looong. > > BUT – If we had an opportunity to use Filter-system then we would > reduce quantity of errors on the screen and the correction of mistakes > would be more comfortable. > > I suggest making filters based on the basic fields of the xml > structures describing one error: > > TAG <obj> - filters:[“equal”,”contains”, “starts with”, “ends with”] > > TAG <fn> - filters:[“equal”,”contains”, “starts with”, “ends with”] > > TAG <dir> - filters:[“equal”,”contains”, “starts with”, “ends with”] > > TAG <file> - filters:[“equal”,”contains”, “starts with”, “ends with”] > > And also – for more gobal tags like: > > TAG <kind> - filters:[“equal”] {here should be only predefined list of > error types} > > TAG <leakedbytes> - filters:[“equal”,”more that”, “less than”, “from > .. till ..”] > > And final question: > > How I can suppress annoying STL errors?problems? > > Ex.: > > <frame> > > <ip>0x5AF17F4</ip> > > <obj>/usr/local/tools/gcc/gcc-3.2.3/lib/libstdc++.so.5.0.3</obj> > > <fn>std::string::append(char const*)</fn> > > <dir>/usr/local/samba/download/Redhat9/addons/gcc/gcc-3.2.3/gcc-build2/i686-pc-linux-gnu/libstdc++-v3/src</dir> > > <file>/usr/local/samba/download/Redhat9/addons/gcc/gcc-3.2.3/gcc-build2/i686-pc-linux-gnu/libstdc++-v3/include/bits/char_traits.h</file> > > <line>135</line> > > </frame> > > Yes, I've read about .supp files but > > I don't have it on my comp. Only in valgrind dir I have few of 'em - > but they not covering gcc and STL > > functions... > > Where I can find rather big && useful .supp files?? > > Regards, Anton > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry® Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9-12, 2009. Register now! > http://p.sf.net/sfu/devconf > ------------------------------------------------------------------------ > > _______________________________________________ > Valgrind-Valkyrie-dev mailing list > Val...@li... > https://lists.sourceforge.net/lists/listinfo/valgrind-valkyrie-dev > |
From: <sv...@va...> - 2010-03-13 12:18:18
|
Author: cerion Date: 2010-03-13 12:17:07 +0000 (Sat, 13 Mar 2010) New Revision: 496 Log: More option page stuff: If any edits in last page, ask user what to do: - Accept edits and move on - Reject edits and move on - Cancel (i.e. cancel move to new page), and remain where we were. oh, and changing option category now works with up/down keys. Modified: branches/valkyrie_qt4port/options/vk_options_dialog.cpp branches/valkyrie_qt4port/options/vk_options_dialog.h branches/valkyrie_qt4port/options/vk_options_page.cpp branches/valkyrie_qt4port/options/vk_options_page.h Modified: branches/valkyrie_qt4port/options/vk_options_dialog.cpp =================================================================== --- branches/valkyrie_qt4port/options/vk_options_dialog.cpp 2010-03-12 20:40:12 UTC (rev 495) +++ branches/valkyrie_qt4port/options/vk_options_dialog.cpp 2010-03-13 12:17:07 UTC (rev 496) @@ -50,7 +50,10 @@ setupLayout(); // ------------------------------------------------------------ - // Add categories, and the default page (other pages loaded on demand) + // Add categories, and the pages + // Note: both the pages and categories list use the same 'index', + // which is how we keep them in sync. + // TODO: if any complaints re speed, load the pages on demand. VkObjectList objList = (( MainWindow* )parent )->getValkyrie()->vkObjList(); for ( int i = 0; i < objList.size(); ++i ) { @@ -83,8 +86,9 @@ contentsListWidget->setFocus(); optionPages->setCurrentIndex( 0 ); - // Give a max to our contentsList, based on the hints from the list-items. - //TODO: surely this can be done automatically? QSizePolicy::* don't seem to do the job :-( + // Give a max to our contentsList, based on hints from the list-items. + // TODO: surely this can be done automatically? + // - QSizePolicy::* don't seem to do the job :-( contentsListWidget->setMaximumWidth( 40 + contentsListWidget->sizeHintForColumn( 0 ) ); ContextHelp::addHelp( this, urlValkyrie::optsDlg ); @@ -190,9 +194,9 @@ // ------------------------------------------------------------ // signals / slots - connect( contentsListWidget, SIGNAL( itemClicked( QListWidgetItem* ) ), - this, SLOT( showPage( QListWidgetItem* ) ) ); - + connect( contentsListWidget, SIGNAL( itemSelectionChanged() ), + this, SLOT( showPage() ) ); + QPushButton* applyButton = optionsButtonBox->button( QDialogButtonBox::Apply ); QPushButton* cancelButton = optionsButtonBox->button( QDialogButtonBox::Cancel ); QPushButton* okButton = optionsButtonBox->button( QDialogButtonBox::Ok ); @@ -210,24 +214,71 @@ /*! - Show the chosen options page + Show the chosen options page. + + If any edits in last page, ask user what to do: + - Accept edits and move on + - Reject edits and move on + - Cancel (i.e. cancel move to new page), and remain where we were. + + Note: have to use listwidget signal itemSelectionChanged(), to make + sure the item has already been updated - else our update of + current-item would get overridden. */ -void VkOptionsDialog::showPage( QListWidgetItem* nextItem ) +void VkOptionsDialog::showPage() { - int nextIdx = contentsListWidget->row( nextItem ); - - // std::cerr << "showPage( " << nextIdx << " )" << std::endl; - - // TODO: check no uncommited edits in last page - // proper way to do this is subclass contentsListWidget to catch click events... - - //TODO? setWindowTitle( capt + item->text() ); - optionPages->setCurrentIndex( nextIdx ); + int nextIdx = contentsListWidget->currentRow(); + int prevIdx = optionPages->currentIndex(); + //cerr << "itemSelectionChanged: old->new: " << prevIdx << "->" << nextIdx << endl; + + if ( nextIdx == prevIdx ) { + // get here on startup, and whenever we revert to last list item + // - easier than disconnecting signals etc. + return; + } + + // check no outstanding edits in prevItem. + bool continueToNext = true; + VkOptionsPage* prevPage = (VkOptionsPage*)optionPages->currentWidget(); + vk_assert( prevPage ); + + if ( prevPage->isModified() ) { + // choose to apply/reset edits + QString pageName = contentsListWidget->item( prevIdx )->text(); + + int ret_qry = + vkQuery( this, "Apply/Reset Edits", + "&Apply;&Reset;&Cancel", + "<p>The <b><i>%s</i></b> option page has non-committed edits.<br/>" + "Would you like to <b>Apply</b> or <b>Reset</b> these edits?<br/>" + "Choose <b>Cancel</b> to stay on the edited page.</p>", + qPrintable( pageName ) ); + + switch ( ret_qry ) { + case MsgBox::vkYes: apply(); break; // apply & move on + case MsgBox::vkNo: prevPage->rejectEdits(); break; // reject & move on + case MsgBox::vkCancel: continueToNext = false; break; // remain in prevPage + default: + vk_assert_never_reached(); + } + } + + if ( continueToNext ) { + // All done with last page: open next page + optionPages->setCurrentIndex( nextIdx ); + } + else { + // Revert current item in contents list. + // This will trigger this function to be called again, but with + // nextidx == previdx, so easy to ignore. + contentsListWidget->setCurrentRow( prevIdx ); + } } -/* reject edits - - only current page can be in an edited state. +/*! + reject edits + - showPage() ensures only current page can be in an edited state. */ void VkOptionsDialog::reject() { @@ -235,11 +286,10 @@ VkOptionsPage* page = ( VkOptionsPage* )optionPages->currentWidget(); vk_assert( page ); - - if ( !page->rejectEdits() ) { - VK_DEBUG( "Failed to reject edits" ); - } - + + page->rejectEdits(); + + // close up shop. QDialog::reject(); } @@ -270,7 +320,7 @@ /*! - apply edits and quit if no problems + Accept: apply edits and quit if no problems. - save the settings to the Project cfg file if specified */ void VkOptionsDialog::accept() @@ -278,6 +328,7 @@ // std::cerr << "VkOptionsDialog::apply()" << std::endl; if ( apply() ) { + // close up shop. QDialog::accept(); } @@ -292,11 +343,12 @@ */ void VkOptionsDialog::saveToGlobalConfig() { - int ok = vkQuery( this, 2, "Overwrite Global Config", - "<p>Are you <b>sure</b> you want to overwrite the global config ?</p>" - "<p><i>Note: Valkyrie will regenerate factory global settings<br>" - "if the global config file is removed:<br>" - "%s</i></p>", qPrintable( vkConfig->vkCfgGlblFilename() ) ); + int ok = + vkQuery( this, 2, "Overwrite Global Config", + "<p>Are you <b>sure</b> you want to overwrite the global config ?</p>" + "<p><i>Note: Valkyrie will regenerate factory global settings<br>" + "if the global config file is removed:<br>" + "%s</i></p>", qPrintable( vkConfig->vkCfgGlblFilename() ) ); if ( ok == MsgBox::vkYes ) { vkConfig->saveToGlblConfigFile(); @@ -304,8 +356,6 @@ } - - /*! Enable/disable buttons. This slot is called by page->modified() signal @@ -321,7 +371,7 @@ QPushButton* cancelButton = optionsButtonBox->button( QDialogButtonBox::Cancel ); applyButton->setEnabled( modified ); cancelButton->setEnabled( modified ); - // enable save only when no edits + // enable save-to-global only when no edits saveGlblButton->setEnabled( !modified ); // updates the window title to indicate modified. Modified: branches/valkyrie_qt4port/options/vk_options_dialog.h =================================================================== --- branches/valkyrie_qt4port/options/vk_options_dialog.h 2010-03-12 20:40:12 UTC (rev 495) +++ branches/valkyrie_qt4port/options/vk_options_dialog.h 2010-03-13 12:17:07 UTC (rev 496) @@ -45,11 +45,10 @@ bool apply(); void accept(); // overloaded void reject(); // overloaded - - void showPage( QListWidgetItem* ); + void showPage(); void pageModified(); void saveToGlobalConfig(); - + signals: void flagsChanged(); Modified: branches/valkyrie_qt4port/options/vk_options_page.cpp =================================================================== --- branches/valkyrie_qt4port/options/vk_options_page.cpp 2010-03-12 20:40:12 UTC (rev 495) +++ branches/valkyrie_qt4port/options/vk_options_page.cpp 2010-03-13 12:17:07 UTC (rev 496) @@ -103,8 +103,10 @@ } -/* reset button clicked */ -bool VkOptionsPage::rejectEdits() +/*! + Reset action activated +*/ +void VkOptionsPage::rejectEdits() { if ( m_editList.count() != 0 ) { // first copy the list: the list is managed by this->updateEditList(). @@ -112,21 +114,19 @@ // now remove all the items from m_editList: // signal is emitted for by each optw, calls this->updateEditList() - for ( int i = 0; i < tmpList.size(); ++i ) { - tmpList.at( i )->cancelEdit(); + foreach ( OptionWidget* opt, tmpList ) { + opt->cancelEdit(); } } vk_assert( m_mod == false ); vk_assert( m_editList.isEmpty() == true ); - - return ( !m_mod && m_editList.isEmpty() ); } /*! applyEdits() - user clicked Ok/Apply after editing some items + user chose Ok/Apply after editing some items */ bool VkOptionsPage::applyEdits() { Modified: branches/valkyrie_qt4port/options/vk_options_page.h =================================================================== --- branches/valkyrie_qt4port/options/vk_options_page.h 2010-03-12 20:40:12 UTC (rev 495) +++ branches/valkyrie_qt4port/options/vk_options_page.h 2010-03-13 12:17:07 UTC (rev 496) @@ -62,7 +62,7 @@ VkOptionsPage( VkObject* obj ); ~VkOptionsPage(); - bool rejectEdits(); + void rejectEdits(); bool applyEdits(); bool isModified() { return m_mod; |
From: <sv...@va...> - 2010-03-12 20:40:37
|
Author: cerion Date: 2010-03-12 20:40:12 +0000 (Fri, 12 Mar 2010) New Revision: 495 Log: Much refactoring of the option widgets (how did they ever work before!): if they don't work now, at least they all don't work in the same way ;-) - all conform to a more general abstract interface - removed knowledge of valgrind/valkyrie from these internals - two standard signals: * valueChanged(): emitted on all edit changes - triggers updates of dialog: apply/cancel button state etc. etc. * editDone(): emitted once editing finished for that widget - triggers immediate validation of input via vkObject::checkOptArg() plus: - fixed VkConfig::strToBool() to tell us if parsing string->bool actually failed, - pulled out some input checks from the option widgets/pages, and put them in their appropriate vkObject::checkOptArg() functions, where they belong (and added the necessary new PERROR_ types). Modified: branches/valkyrie_qt4port/objects/valgrind_object.cpp branches/valkyrie_qt4port/objects/valkyrie_object.cpp branches/valkyrie_qt4port/options/valgrind_options_page.cpp branches/valkyrie_qt4port/options/valkyrie_options_page.cpp branches/valkyrie_qt4port/options/vk_option.cpp branches/valkyrie_qt4port/options/vk_option.h branches/valkyrie_qt4port/options/vk_options_page.cpp branches/valkyrie_qt4port/options/vk_options_page.h branches/valkyrie_qt4port/options/widgets/opt_base_widget.cpp branches/valkyrie_qt4port/options/widgets/opt_base_widget.h branches/valkyrie_qt4port/options/widgets/opt_cb_widget.cpp branches/valkyrie_qt4port/options/widgets/opt_cb_widget.h branches/valkyrie_qt4port/options/widgets/opt_ck_widget.cpp branches/valkyrie_qt4port/options/widgets/opt_ck_widget.h branches/valkyrie_qt4port/options/widgets/opt_lb_widget.cpp branches/valkyrie_qt4port/options/widgets/opt_lb_widget.h branches/valkyrie_qt4port/options/widgets/opt_le_widget.cpp branches/valkyrie_qt4port/options/widgets/opt_le_widget.h branches/valkyrie_qt4port/options/widgets/opt_sp_widget.cpp branches/valkyrie_qt4port/options/widgets/opt_sp_widget.h branches/valkyrie_qt4port/utils/vk_config.cpp branches/valkyrie_qt4port/utils/vk_config.h Modified: branches/valkyrie_qt4port/objects/valgrind_object.cpp =================================================================== --- branches/valkyrie_qt4port/objects/valgrind_object.cpp 2010-03-12 13:32:28 UTC (rev 494) +++ branches/valkyrie_qt4port/objects/valgrind_object.cpp 2010-03-12 20:40:12 UTC (rev 495) @@ -542,14 +542,17 @@ for ( ; it != files.end(); ++it ) { // check file ok and has at least R permissions *it = fileCheck( &errval, *it, true ); - if ( errval != PARSED_OK ) { - break; + return errval; } - // TODO: ? check valid suppression files } - + + // check for duplicates + if ( files.removeDuplicates() > 0 ) { + return PERROR_DUPLICATE; + } + argval = files.join( sep ); } break; Modified: branches/valkyrie_qt4port/objects/valkyrie_object.cpp =================================================================== --- branches/valkyrie_qt4port/objects/valkyrie_object.cpp 2010-03-12 13:32:28 UTC (rev 494) +++ branches/valkyrie_qt4port/objects/valkyrie_object.cpp 2010-03-12 20:40:12 UTC (rev 495) @@ -26,6 +26,7 @@ #include "utils/vk_utils.h" #include <QFile> +#include <QFileInfo> #include <QPoint> #include <QStringList> @@ -554,8 +555,20 @@ ( void ) dirCheck( &errval, argval, true, true, true ); } break; - // helper executables - case VALKYRIE::BROWSER: + // browser executable + case VALKYRIE::BROWSER: { + if ( argval.isEmpty() ) { + // empty is fine. + } else { + // check for at least X permissions. + QString path = argval.split( " " ).first(); + QString file = fileCheck( &errval, path, false, false, true ); + argval.replace( path, file ); + argval = argval.simplified(); + } + } break; + + // editor executable case VALKYRIE::SRC_EDITOR: { if ( argval.isEmpty() ) { // empty is fine. @@ -565,9 +578,19 @@ QString file = fileCheck( &errval, path, false, false, true ); argval.replace( path, file ); argval = argval.simplified(); + + if ( !argval.contains( "%n" ) ) { + // for a few well-known editors, add the go-to-line + // editor flag, plus our replacement string (%n) + QFileInfo fi( argval ); + QString fname = fi.fileName(); + if ( fname.contains( QRegExp( "^(emacs|gedit|gvim|nano|nedit)[\\W]*" ) ) ) { + argval += " +%n"; + } + } } } break; - + // valkyrie project file case VALKYRIE::PROJ_FILE: { // check file exists and has RW perms Modified: branches/valkyrie_qt4port/options/valgrind_options_page.cpp =================================================================== --- branches/valkyrie_qt4port/options/valgrind_options_page.cpp 2010-03-12 13:32:28 UTC (rev 494) +++ branches/valkyrie_qt4port/options/valgrind_options_page.cpp 2010-03-12 20:40:12 UTC (rev 495) @@ -175,7 +175,6 @@ insertOptionWidget( VALGRIND::DB_COMMAND, egroup1, false ); // ledit+button LeWidget* dbLedit = (( LeWidget* )m_itemList[VALGRIND::DB_COMMAND] ); dbLedit->addButton( egroup1, this, SLOT( getDbBin() ) ); - connect( dbLedit, SIGNAL( returnPressed() ), this, SIGNAL( apply() ) ); insertOptionWidget( VALGRIND::INPUT_FD, egroup1, true ); // spinbox insertOptionWidget( VALGRIND::LOG_FD, egroup1, true ); // spinbox Modified: branches/valkyrie_qt4port/options/valkyrie_options_page.cpp =================================================================== --- branches/valkyrie_qt4port/options/valkyrie_options_page.cpp 2010-03-12 13:32:28 UTC (rev 494) +++ branches/valkyrie_qt4port/options/valkyrie_options_page.cpp 2010-03-12 20:40:12 UTC (rev 495) @@ -88,16 +88,13 @@ insertOptionWidget( VALKYRIE::BINARY, group1, false ); // ledit + button LeWidget* binLedit = (( LeWidget* )m_itemList[VALKYRIE::BINARY] ); binLedit->addButton( group1, this, SLOT( getBinary() ) ); - connect( binLedit, SIGNAL( returnPressed() ), this, SIGNAL( apply() ) ); insertOptionWidget( VALKYRIE::BIN_FLAGS, group1, true ); // ledit LeWidget* binFlgsLedit = (( LeWidget* )m_itemList[VALKYRIE::BIN_FLAGS] ); - connect( binFlgsLedit, SIGNAL( returnPressed() ), this, SIGNAL( apply() ) ); insertOptionWidget( VALKYRIE::WORKING_DIR, group1, false ); // line edit + button LeWidget* dirWorking = (( LeWidget* )m_itemList[VALKYRIE::WORKING_DIR] ); dirWorking->addButton( group1, this, SLOT( getWorkingDir() ) ); - connect( dirWorking, SIGNAL( returnPressed() ), this, SIGNAL( apply() ) ); // target setup - layout grid->addWidget( binLedit->button(), i, 0 ); @@ -115,24 +112,20 @@ insertOptionWidget( VALKYRIE::SRC_EDITOR, group1, false ); // ledit + button LeWidget* editLedit = (( LeWidget* )m_itemList[VALKYRIE::SRC_EDITOR] ); editLedit->addButton( group1, this, SLOT( getEditor() ) ); - connect( editLedit, SIGNAL( returnPressed() ), this, SIGNAL( apply() ) ); insertOptionWidget( VALKYRIE::SRC_LINES, group1, true ); // intspin insertOptionWidget( VALKYRIE::BROWSER, group1, false ); // line edit LeWidget* brwsrLedit = (( LeWidget* )m_itemList[VALKYRIE::BROWSER] ); brwsrLedit->addButton( group1, this, SLOT( getBrowser() ) ); - connect( brwsrLedit, SIGNAL( returnPressed() ), this, SIGNAL( apply() ) ); insertOptionWidget( VALKYRIE::DFLT_LOGDIR, group1, false ); // line edit + button LeWidget* dirLogSave = (( LeWidget* )m_itemList[VALKYRIE::DFLT_LOGDIR] ); dirLogSave->addButton( group1, this, SLOT( getDfltLogDir() ) ); - connect( dirLogSave, SIGNAL( returnPressed() ), this, SIGNAL( apply() ) ); insertOptionWidget( VALKYRIE::VG_EXEC, group1, false ); // ledit + button LeWidget* vgbinLedit = (( LeWidget* )m_itemList[VALKYRIE::VG_EXEC] ); vgbinLedit->addButton( group1, this, SLOT( getVgExec() ) ); - connect( vgbinLedit, SIGNAL( returnPressed() ), this, SIGNAL( apply() ) ); // general prefs - layout grid->addWidget( editLedit->button(), i, 0 ); @@ -210,7 +203,7 @@ QFont font = QFontDialog::getFont( &ok, afont, this, "Select General Font" ); if ( ok ) { - fontLedit->setCurrValue( font.toString() ); + fontLedit->setValue( font.toString() ); } } @@ -228,7 +221,7 @@ QFont font = QFontDialog::getFont( &ok, afont, this, "Select Tool Font" ); if ( ok ) { - fontLedit->setCurrValue( font.toString() ); + fontLedit->setValue( font.toString() ); } } @@ -258,20 +251,8 @@ start_dir, tr("All Files (*)")); if ( !editor.isEmpty() ) { // user might have clicked Cancel - - // for a few well known editors, add the - // go-to-line editor flag, plus our replacement string (%n) - QFileInfo fi( editor ); - if ( fi.fileName().startsWith( "emacs " ) || - fi.fileName().startsWith( "gedit " ) || - fi.fileName().startsWith( "gvim " ) || - fi.fileName().startsWith( "nano " ) || - fi.fileName().startsWith( "nedit " ) ) { - editor += " +%n"; - } - - editLedit->setCurrValue( editor ); - checkOption( VALKYRIE::SRC_EDITOR ); + editLedit->setValue( editor ); + // update triggers checkOption() } } @@ -286,8 +267,8 @@ "./", tr("All Files (*)")); if ( !binfile.isEmpty() ) { // user might have clicked Cancel - (( LeWidget* )m_itemList[VALKYRIE::BINARY] )->setCurrValue( binfile ); - checkOption( VALKYRIE::BINARY ); + (( LeWidget* )m_itemList[VALKYRIE::BINARY] )->setValue( binfile ); + // update triggers checkOption() } } @@ -302,8 +283,8 @@ "./", tr("All Files (*)")); if ( !brwsr.isEmpty() ) { // user might have clicked Cancel - (( LeWidget* )m_itemList[VALKYRIE::BROWSER] )->setCurrValue( brwsr ); - checkOption( VALKYRIE::BROWSER ); + (( LeWidget* )m_itemList[VALKYRIE::BROWSER] )->setValue( brwsr ); + // update triggers checkOption() } } @@ -318,8 +299,8 @@ "./", tr("All Files (*)")); if ( !vg_exec.isEmpty() ) { // user might have clicked Cancel - (( LeWidget* )m_itemList[VALKYRIE::VG_EXEC] )->setCurrValue( vg_exec ); - checkOption( VALKYRIE::VG_EXEC ); + (( LeWidget* )m_itemList[VALKYRIE::VG_EXEC] )->setValue( vg_exec ); + // update triggers checkOption() } } @@ -338,8 +319,8 @@ QFileDialog::ShowDirsOnly ); if ( !dir_logsave.isEmpty() ) { // user might have clicked Cancel - (( LeWidget* )m_itemList[VALKYRIE::DFLT_LOGDIR] )->setCurrValue( dir_logsave ); - checkOption( VALKYRIE::DFLT_LOGDIR ); + (( LeWidget* )m_itemList[VALKYRIE::DFLT_LOGDIR] )->setValue( dir_logsave ); + // update triggers checkOption() } } @@ -357,7 +338,7 @@ QFileDialog::ShowDirsOnly ); if ( !dir_working.isEmpty() ) { // user might have clicked Cancel - (( LeWidget* )m_itemList[VALKYRIE::WORKING_DIR] )->setCurrValue( dir_working ); - checkOption( VALKYRIE::WORKING_DIR ); + (( LeWidget* )m_itemList[VALKYRIE::WORKING_DIR] )->setValue( dir_working ); + // update triggers checkOption() } } Modified: branches/valkyrie_qt4port/options/vk_option.cpp =================================================================== --- branches/valkyrie_qt4port/options/vk_option.cpp 2010-03-12 13:32:28 UTC (rev 494) +++ branches/valkyrie_qt4port/options/vk_option.cpp 2010-03-12 20:40:12 UTC (rev 495) @@ -93,6 +93,8 @@ return "number is not a power of two"; case PERROR_BADVERSION: return "Bad program version"; + case PERROR_DUPLICATE: + return "Duplicate entries"; default: return "unknown error"; } Modified: branches/valkyrie_qt4port/options/vk_option.h =================================================================== --- branches/valkyrie_qt4port/options/vk_option.h 2010-03-12 13:32:28 UTC (rev 494) +++ branches/valkyrie_qt4port/options/vk_option.h 2010-03-12 20:40:12 UTC (rev 495) @@ -93,6 +93,7 @@ #define PERROR_DB_OUTPUT -31 // using db-attach, but not sending output to stderr #define PERROR_POWER_OF_TWO -32 // number not a power of two #define PERROR_BADVERSION -33 // bad program version +#define PERROR_DUPLICATE -34 // duplicate entries const char* parseErrString( const int error ); Modified: branches/valkyrie_qt4port/options/vk_options_page.cpp =================================================================== --- branches/valkyrie_qt4port/options/vk_options_page.cpp 2010-03-12 13:32:28 UTC (rev 494) +++ branches/valkyrie_qt4port/options/vk_options_page.cpp 2010-03-12 20:40:12 UTC (rev 495) @@ -126,41 +126,34 @@ /*! applyEdits() - Called from OptionsDialog::apply(), accept() + user clicked Ok/Apply after editing some items */ bool VkOptionsPage::applyEdits() { if ( m_editList.isEmpty() && m_mod == false ) { return true; } - - // user clicked Ok/Apply after editing some items - - // verify all entries before committing any - OptionWidget* optw; - - for ( int i = 0; i < m_editList.size(); ++i ) { - optw = m_editList.at( i ); - if ( !checkOption( optw->id() ) ) { + // verify all edited entries before committing any. + // TODO: shouldn't need to do this anymore, as we now verify upon + // edit completion. But keeping it in for now. + foreach( OptionWidget* optw, m_editList ) { + if ( !checkOption( optw ) ) { return false; } } - // all entries ok: commit them + // all edited entries ok: commit them all QList<OptionWidget*> tmpList; - - for ( int i = 0; i < m_editList.size(); ++i ) { - optw = m_editList.at( i ); - + foreach( OptionWidget* optw, m_editList ) { // optw->option emits valueChanged() on save: optw->saveEdit(); tmpList.append( optw ); } // now remove all the saved items from m_editList - for ( int i = 0; i < tmpList.size(); ++i ) { - updateEditList( false, tmpList.at( i ) ); + foreach( OptionWidget* optw, tmpList ) { + updateEditList( false, optw ); } vk_assert( m_mod == false ); @@ -173,30 +166,26 @@ checkOption() Check valid option via VkObject */ -bool VkOptionsPage::checkOption( unsigned int optId ) +bool VkOptionsPage::checkOption( OptionWidget* opt ) { - vk_assert( optId < m_vkObj->maxOptId() ); + vk_assert( opt ); + vk_assert( opt->id() < (int)m_vkObj->maxOptId() ); + + QString argval = opt->currValue(); + int errval = m_vkObj->checkOptArg( opt->id(), argval ); - QString argval = m_itemList[optId]->currValue(); - // Note: argval may be altered by checkOptArg() - int errval = m_vkObj->checkOptArg( optId, argval ); - if ( errval != PARSED_OK ) { - - vkError( this, "Invalid Entry", "%s:\n\"%s\"", + vkError( this, "Invalid Entry", "%s:<br><i>%s</i>", parseErrString( errval ), - qPrintable( m_itemList[optId]->currValue() ) ); - - m_itemList[optId]->cancelEdit(); + qPrintable( opt->printCurrValue() ) ); + + opt->cancelEdit(); return false; } // argval may have been altered by checkOptArg(), e.g. a file path - // - only applies to line-edit widgets. - if ( argval != m_itemList[optId]->currValue() ) { - if ( m_itemList[optId]->inherits( "LeWidget" ) ) { - (( LeWidget* )m_itemList[optId] )->setCurrValue( argval ); - } + if ( argval != opt->currValue() ) { + opt->setValue( argval ); } return true; @@ -243,7 +232,7 @@ if ( !ok ) { cerr << "Error in VkOptionsPage::insertOptionWidget( " << optid << " ): " << "VkOPT::WDG_SPINBOX: bad int conversion from: '" - << val.toLatin1().data() << "'" << endl; + << qPrintable( val ) << "'" << endl; // soldier on... ival = 0; } @@ -261,7 +250,11 @@ optWidget = 0; break; } - + + // check validity of option values immediately upon finishing edit + connect( optWidget, SIGNAL( editDone( OptionWidget* ) ), + this, SLOT( checkOption( OptionWidget* ) ) ); + // ------------------------------------------------------------ // Insert into the itemlist m_itemList.insert( optid, optWidget ); Modified: branches/valkyrie_qt4port/options/vk_options_page.h =================================================================== --- branches/valkyrie_qt4port/options/vk_options_page.h 2010-03-12 13:32:28 UTC (rev 494) +++ branches/valkyrie_qt4port/options/vk_options_page.h 2010-03-12 20:40:12 UTC (rev 495) @@ -74,15 +74,14 @@ protected slots: void updateEditList( bool, OptionWidget* ); - + bool checkOption( OptionWidget* opt ); + protected: virtual void setupOptions() = 0; OptionWidget* insertOptionWidget( int optid, QWidget* parent, bool mklabel ); QFrame* sep( QWidget* parent ); - - bool checkOption( unsigned int optId ); - + protected: bool m_mod; int lineHeight; Modified: branches/valkyrie_qt4port/options/widgets/opt_base_widget.cpp =================================================================== --- branches/valkyrie_qt4port/options/widgets/opt_base_widget.cpp 2010-03-12 13:32:28 UTC (rev 494) +++ branches/valkyrie_qt4port/options/widgets/opt_base_widget.cpp 2010-03-12 20:40:12 UTC (rev 495) @@ -53,6 +53,21 @@ { } +void OptionWidget::setCurrValue( const QString& txt ) +{ + if ( m_currentValue != txt ) { + m_currentValue = txt; + bool edited = (m_currentValue != m_initialValue); + emit valueChanged( edited, this ); + + // default behaviour is that any change is a complete change + // - can then e.g. test new value. + if ( edited ) { + emit editDone( this ); + } + } +} + int OptionWidget::id() { return m_opt->optid; @@ -78,6 +93,33 @@ return m_initialValue; } + + +void OptionWidget::setValue( const QString& txt ) +{ + update( txt ); +} + +void OptionWidget::reset() +{ + update( m_initialValue ); +} + +void OptionWidget::resetDefault() +{ + update( m_opt->dfltValue.toString() ); +} + + +/*! + virtual function to print current value prettily + - some widgets (e.g. listbox) need to overload this. +*/ +QString OptionWidget::printCurrValue() +{ + return currValue(); +} + void OptionWidget::saveEdit() { m_initialValue = m_currentValue; @@ -86,8 +128,6 @@ void OptionWidget::cancelEdit() { - m_currentValue = m_initialValue; - emit valueChanged( false, this ); reset(); } Modified: branches/valkyrie_qt4port/options/widgets/opt_base_widget.h =================================================================== --- branches/valkyrie_qt4port/options/widgets/opt_base_widget.h 2010-03-12 13:32:28 UTC (rev 494) +++ branches/valkyrie_qt4port/options/widgets/opt_base_widget.h 2010-03-12 20:40:12 UTC (rev 495) @@ -26,7 +26,10 @@ #include <QWidget> #include <QVBoxLayout> +#include <iostream> +using namespace std; + // ============================================================ class VkOption; @@ -42,20 +45,32 @@ int id(); QLabel* label(); QWidget* widget(); + QString currValue(); QString initValue(); + QString changedValue(); void setEnabled( bool enable ); - - virtual void reset() = 0; - virtual void resetDefault() = 0; //TODO: not used: wanted? + + void setValue( const QString& txt ); + void reset(); + void resetDefault(); //TODO: not used: wanted? + + virtual QString printCurrValue(); + virtual void saveEdit(); virtual void cancelEdit(); + virtual QHBoxLayout* hlayout(); virtual QVBoxLayout* vlayout(); signals: void valueChanged( bool, OptionWidget* ); + void editDone( OptionWidget* ); +protected slots: + virtual void setCurrValue( const QString& txt ); + virtual void update( const QString& txt ) = 0; + protected: QWidget* m_widg; QLabel* m_wLabel; Modified: branches/valkyrie_qt4port/options/widgets/opt_cb_widget.cpp =================================================================== --- branches/valkyrie_qt4port/options/widgets/opt_cb_widget.cpp 2010-03-12 13:32:28 UTC (rev 494) +++ branches/valkyrie_qt4port/options/widgets/opt_cb_widget.cpp 2010-03-12 20:40:12 UTC (rev 495) @@ -57,7 +57,7 @@ m_combo->setCurrentIndex( m_currIdx ); connect( m_combo, SIGNAL( activated( const QString& ) ), - this, SLOT( cbChanged( const QString& ) ) ); + this, SLOT( update( const QString& ) ) ); // not added if the url is empty ContextHelp::addHelp( m_widg, m_opt->urlAddress ); @@ -77,10 +77,10 @@ -void CbWidget::cbChanged( const QString& txt ) +void CbWidget::update( const QString& txt ) { bool found = false; - + for ( int i = 0; i < m_combo->count(); ++i ) { if ( txt == m_combo->itemText( i ) ) { found = true; @@ -95,22 +95,11 @@ } else { m_currIdx = m_combo->currentIndex(); - m_currentValue = m_combo->currentText(); - bool edited = m_currentValue != m_initialValue; - emit valueChanged( edited, this ); + setCurrValue( m_combo->currentText() ); } } -void CbWidget::reset() -{ - cbChanged( m_initialValue ); -} -void CbWidget::resetDefault() -{ - cbChanged( m_opt->dfltValue.toString() ); -} - QHBoxLayout* CbWidget::hlayout() { vk_assert( m_wLabel != 0 ); Modified: branches/valkyrie_qt4port/options/widgets/opt_cb_widget.h =================================================================== --- branches/valkyrie_qt4port/options/widgets/opt_cb_widget.h 2010-03-12 13:32:28 UTC (rev 494) +++ branches/valkyrie_qt4port/options/widgets/opt_cb_widget.h 2010-03-12 20:40:12 UTC (rev 495) @@ -37,13 +37,11 @@ CbWidget( QWidget* parent, VkOption* vkopt, bool mklabel ); ~CbWidget(); - void reset(); - void resetDefault(); QHBoxLayout* hlayout(); private slots: - void cbChanged( const QString& txt ); - + void update( const QString& txt ); + private: int m_currIdx; QComboBox* m_combo; Modified: branches/valkyrie_qt4port/options/widgets/opt_ck_widget.cpp =================================================================== --- branches/valkyrie_qt4port/options/widgets/opt_ck_widget.cpp 2010-03-12 13:32:28 UTC (rev 494) +++ branches/valkyrie_qt4port/options/widgets/opt_ck_widget.cpp 2010-03-12 20:40:12 UTC (rev 495) @@ -61,31 +61,22 @@ void CkWidget::ckChanged( bool on ) { - m_currentValue = ( on ) ? m_opt->possValues[0] : m_opt->possValues[1]; - bool edited = m_currentValue != m_initialValue; - emit valueChanged( edited, this ); + setCurrValue( m_opt->possValues[ (on ? 0 : 1) ] ); + // for dis/enabling associated widgets emit changed( on ); - emit clicked( m_opt->optid ); } -void CkWidget::reset() +/*! + txt value translated to boolean to check box. + only updates if value valid 'boolean' string +*/ +void CkWidget::update( const QString& txt ) { - bool cfgChecked = VkConfig::strToBool( m_initialValue ); - m_cbox->setChecked( cfgChecked ); + bool ok; + bool checked = VkConfig::strToBool( txt, &ok ); + if ( ok ) { + m_cbox->setChecked( checked ); + // toggled signal sent -> calls ckChanged() + } } - -void CkWidget::resetDefault() -{ - setOn( VkConfig::strToBool( m_opt->dfltValue.toString() ) ); -} - -bool CkWidget::isOn() -{ - return m_cbox->isChecked(); -} - -void CkWidget::setOn( bool on ) -{ - m_cbox->setChecked( on ); -} Modified: branches/valkyrie_qt4port/options/widgets/opt_ck_widget.h =================================================================== --- branches/valkyrie_qt4port/options/widgets/opt_ck_widget.h 2010-03-12 13:32:28 UTC (rev 494) +++ branches/valkyrie_qt4port/options/widgets/opt_ck_widget.h 2010-03-12 20:40:12 UTC (rev 495) @@ -37,18 +37,13 @@ CkWidget( QWidget* parent, VkOption* vkopt, bool mklabel ); ~CkWidget(); - bool isOn(); - void reset(); - void resetDefault(); - void setOn( bool on ); - signals: - void clicked( int ); void changed( bool ); private slots: void ckChanged( bool ); - + void update( const QString& txt ); + private: QCheckBox* m_cbox; }; Modified: branches/valkyrie_qt4port/options/widgets/opt_lb_widget.cpp =================================================================== --- branches/valkyrie_qt4port/options/widgets/opt_lb_widget.cpp 2010-03-12 13:32:28 UTC (rev 494) +++ branches/valkyrie_qt4port/options/widgets/opt_lb_widget.cpp 2010-03-12 20:40:12 UTC (rev 495) @@ -75,7 +75,7 @@ m_sep = vkConfig->vkSepChar; - reset(); + update( m_currentValue ); m_lbox->setContextMenuPolicy( Qt::CustomContextMenu ); connect( m_lbox, SIGNAL( customContextMenuRequested( const QPoint& ) ), this, SLOT( popupMenu( const QPoint& ) ) ); @@ -95,11 +95,12 @@ /*! - reset lbox to m_currentValue - called from OptionWidget::cancelEdit(), after m_currentValue reset. + reload lbox from m_currentValue */ -void LbWidget::reset() +void LbWidget::update( const QString& txt ) { + setCurrValue( txt ); + m_lbox->clear(); QStringList sfiles = m_currentValue.split( m_sep, QString::SkipEmptyParts ); @@ -110,24 +111,14 @@ /*! - called from OptionsPage::resetDefaults() - reset to installation defaults - */ -void LbWidget::resetDefault() + Pretty print current value +*/ +QString LbWidget::printCurrValue() { - m_currentValue = m_opt->dfltValue.toString(); - reset(); - lbChanged(); + return "For one (or more) of:<br>" + currValue().replace( m_sep, "<br>" ); } -void LbWidget::setCurrValue( const QString& txt ) -{ - m_currentValue = txt; - reset(); - lbChanged(); -} - /*! return all contents concat'd with m_sep */ @@ -136,7 +127,6 @@ QStringList items; for ( int i = 0; i < m_lbox->count(); i++ ) { - m_lbox->removeItemWidget( m_lbox->item( i ) ); items += m_lbox->item( i )->text(); } @@ -145,15 +135,6 @@ /*! - emit signals to indicate widget content has changed -*/ -void LbWidget::lbChanged() -{ - emit valueChanged( (m_currentValue != m_initialValue), this ); -} - - -/*! different menus and stuff for the different modes */ void LbWidget::popupMenu( const QPoint& pos ) @@ -175,9 +156,7 @@ if ( act == &actRemove ) { vk_assert( lb_item ); m_lbox->takeItem( m_lbox->row( lb_item ) ); - // update currentvalue, and emit signal - m_currentValue = lbText(); - lbChanged(); + setCurrValue( lbText() ); } else if ( act == &actAdd ) { QString supp_file = @@ -186,19 +165,8 @@ "./", tr("Suppression Files (*.supp)") ); if ( ! supp_file.isEmpty() ) { // user clicked Cancel ? - // check not a duplicate entry - if ( ! m_lbox->findItems( supp_file, Qt::MatchExactly ).isEmpty() ) { - - vkInfo( m_lbox, "Duplicate Entry", - "The entry '%s' is already in the list.", - qPrintable( supp_file ) ); - } - else { - m_lbox->addItem( supp_file ); - // update currentvalue, and emit signal - m_currentValue = lbText(); - lbChanged(); - } + m_lbox->addItem( supp_file ); + setCurrValue( lbText() ); } } } Modified: branches/valkyrie_qt4port/options/widgets/opt_lb_widget.h =================================================================== --- branches/valkyrie_qt4port/options/widgets/opt_lb_widget.h 2010-03-12 13:32:28 UTC (rev 494) +++ branches/valkyrie_qt4port/options/widgets/opt_lb_widget.h 2010-03-12 20:40:12 UTC (rev 495) @@ -33,13 +33,13 @@ public: LbWidget( QWidget* parent, VkOption* vkopt, bool mklabel ); ~LbWidget(); - void reset(); - void resetDefault(); - void setCurrValue( const QString& ); - + + QString printCurrValue(); // overloads base class + private slots: void popupMenu( const QPoint& ); - + void update( const QString& txt ); + private: QString lbText(); void lbChanged(); Modified: branches/valkyrie_qt4port/options/widgets/opt_le_widget.cpp =================================================================== --- branches/valkyrie_qt4port/options/widgets/opt_le_widget.cpp 2010-03-12 13:32:28 UTC (rev 494) +++ branches/valkyrie_qt4port/options/widgets/opt_le_widget.cpp 2010-03-12 20:40:12 UTC (rev 495) @@ -38,10 +38,10 @@ m_ledit->setText( m_initialValue ); connect( m_ledit, SIGNAL( textChanged( const QString& ) ), - this, SLOT( leChanged( const QString& ) ) ); - connect( m_ledit, SIGNAL( returnPressed() ), - this, SIGNAL( returnPressed() ) ); - + this, SLOT( setCurrValue( const QString& ) ) ); + connect( m_ledit, SIGNAL( editingFinished() ), + this, SLOT( editingFinished() ) ); + // not added if the url is empty ContextHelp::addHelp( m_widg, m_opt->urlAddress ); } @@ -64,51 +64,43 @@ } -void LeWidget::setCurrValue( const QString& txt ) +void LeWidget::editingFinished() { - m_ledit->setText( txt ); /* calls leChanged(txt) */ - - if ( txt.length() > 0 ) { - m_ledit->setCursorPosition( 0 ); - } + emit editDone( this ); } -void LeWidget::addCurrValue( const QString& txt ) +/*! + overloaded from base class + just emit valueChanged, _not_ editDone() + - we do that on signal m_ledit->editingFinished() +*/ +void LeWidget::setCurrValue( const QString& value ) { - if ( m_currentValue.isEmpty() ) { - setCurrValue( txt ); + m_currentValue = value; + emit valueChanged( (m_currentValue != m_initialValue), this ); +} + + +void LeWidget::update( const QString& txt ) +{ + m_ledit->setText( txt ); + // m_ledit signal -> calls setCurrValue() + + if ( txt.length() > 0 ) { + m_ledit->setCursorPosition( 0 ); } - else { - setCurrValue( m_ledit->text() + "," + txt ); - } } + void LeWidget::setDisabled( bool disable ) { m_ledit->setDisabled( disable ); - + if ( m_pb != 0 ) { m_pb->setDisabled( disable ); } } -void LeWidget::leChanged( const QString& txt ) -{ - m_currentValue = txt; - bool edited = m_currentValue != m_initialValue; - emit valueChanged( edited, this ); -} - -void LeWidget::reset() -{ - m_ledit->setText( m_initialValue ); -} - -void LeWidget::resetDefault() -{ - setCurrValue( m_opt->dfltValue.toString() ); -} - QPushButton* LeWidget::button() { return m_pb; Modified: branches/valkyrie_qt4port/options/widgets/opt_le_widget.h =================================================================== --- branches/valkyrie_qt4port/options/widgets/opt_le_widget.h 2010-03-12 13:32:28 UTC (rev 494) +++ branches/valkyrie_qt4port/options/widgets/opt_le_widget.h 2010-03-12 20:40:12 UTC (rev 495) @@ -39,10 +39,6 @@ LeWidget( QWidget* parent, VkOption* vkopt, bool mklabel ); ~LeWidget(); - void reset(); - void resetDefault(); - void setCurrValue( const QString& ); - void addCurrValue( const QString& ); void addButton( QWidget* parent, const QObject* receiver, const char* slot, QString txt = QString::null, bool icon = false ); @@ -50,16 +46,17 @@ QPushButton* button(); QHBoxLayout* hlayout(); -signals: - void returnPressed(); - public slots: void setDisabled( bool disable ); - + private slots: - void leChanged( const QString& txt ); - + void editingFinished(); + void update( const QString& txt ); + private: + void setCurrValue( const QString& value ); // overloaded + +private: QLineEdit* m_ledit; QPushButton* m_pb; }; Modified: branches/valkyrie_qt4port/options/widgets/opt_sp_widget.cpp =================================================================== --- branches/valkyrie_qt4port/options/widgets/opt_sp_widget.cpp 2010-03-12 13:32:28 UTC (rev 494) +++ branches/valkyrie_qt4port/options/widgets/opt_sp_widget.cpp 2010-03-12 20:40:12 UTC (rev 495) @@ -41,8 +41,8 @@ m_numSections = num_sections; connect( m_intspin, SIGNAL( valueChanged( const QString& ) ), - this, SLOT( spChanged( const QString& ) ) ); - + this, SLOT( setCurrValue( const QString& ) ) ); + // not added if the url is empty ContextHelp::addHelp( m_widg, m_opt->urlAddress ); } @@ -119,44 +119,17 @@ m_intspin->addSection( min, max, defval, step, sep_char ); } -void SpWidget::spChanged( const QString& val ) -{ - m_currentValue = val; - bool edited = m_currentValue != m_initialValue; - emit valueChanged( edited, this ); -} -void SpWidget::reset() +void SpWidget::update( const QString& txt ) { if ( m_numSections == 1 ) { //TODO: multisections // m_intspin->setValue( m_initialValue.toInt(), 0 ); - m_intspin->setValue( m_initialValue.toInt() ); + m_intspin->setValue( txt.toInt() ); } else { - QStringList values = m_initialValue.split( ",", QString::SkipEmptyParts ); - - for ( int i = 0; i < values.count(); i++ ) { - //TODO: multisections - // m_intspin->setValue( values[i].toInt(), i ); - m_intspin->setValue( values[i].toInt() ); - } - } -} + QStringList values = txt.split( ",", QString::SkipEmptyParts ); -void SpWidget::resetDefault() -{ - QString dflt = m_opt->dfltValue.toString(); - spChanged( dflt ); - - if ( m_numSections == 1 ) { - //TODO: multisections - // m_intspin->setValue( dflt.toInt(), 0 ); - m_intspin->setValue( dflt.toInt() ); - } - else { - QStringList values = dflt.split( ",", QString::SkipEmptyParts ); - for ( int i = 0; i < values.count(); i++ ) { //TODO: multisections // m_intspin->setValue( values[i].toInt(), i ); @@ -165,6 +138,7 @@ } } + QHBoxLayout* SpWidget::hlayout() { vk_assert( m_wLabel != 0 ); Modified: branches/valkyrie_qt4port/options/widgets/opt_sp_widget.h =================================================================== --- branches/valkyrie_qt4port/options/widgets/opt_sp_widget.h 2010-03-12 13:32:28 UTC (rev 494) +++ branches/valkyrie_qt4port/options/widgets/opt_sp_widget.h 2010-03-12 20:40:12 UTC (rev 495) @@ -36,16 +36,14 @@ SpWidget( QWidget* parent, VkOption* vkopt, bool mklabel, int num_sections ); ~SpWidget(); - void reset(); - void resetDefault(); void addSection( int min, int max, int defval = 0, int step = 1, QString sep_char = " : " ); QHBoxLayout* hlayout(); - -private slots: - void spChanged( const QString& val ); - + private: + void update( const QString& txt ); + +private: IntSpin* m_intspin; int m_numSections; }; Modified: branches/valkyrie_qt4port/utils/vk_config.cpp =================================================================== --- branches/valkyrie_qt4port/utils/vk_config.cpp 2010-03-12 13:32:28 UTC (rev 494) +++ branches/valkyrie_qt4port/utils/vk_config.cpp 2010-03-12 20:40:12 UTC (rev 495) @@ -288,16 +288,28 @@ -/*! Translate valgrind's booleans +/*! + Translate boolean strings into booleans + returns true if successfully parsed a 'true' string. + returns false otherwise + Use argment 'ok' to detect failed 'false' parsing. */ -bool VkConfig::strToBool( QString str ) +bool VkConfig::strToBool( QString str, bool* ok ) { + if ( ok ) *ok = true; + if ( str == "true" || str == "on" || str == "yes" || str == "1" || str == "T" ) { return true; } + if ( str == "false" || str == "off" || + str == "no" || str == "0" || + str == "F" ) { + return false; + } + if ( ok ) *ok = false; return false; } Modified: branches/valkyrie_qt4port/utils/vk_config.h =================================================================== --- branches/valkyrie_qt4port/utils/vk_config.h 2010-03-12 13:32:28 UTC (rev 494) +++ branches/valkyrie_qt4port/utils/vk_config.h 2010-03-12 20:40:12 UTC (rev 495) @@ -98,7 +98,7 @@ public: // util functions - static bool strToBool( QString str ); + static bool strToBool( QString str, bool* ok=0 ); static QString vkCfgGlblFilename(); static QString vkTmpDir(); |
From: <sv...@va...> - 2010-03-12 13:33:02
|
Author: cerion Date: 2010-03-12 13:32:28 +0000 (Fri, 12 Mar 2010) New Revision: 494 Log: Eat return/enter keypresses in OptionDialog::eventFilter(), so we don't end up closing the dialog when an edit fails. Modified: branches/valkyrie_qt4port/objects/valgrind_object.cpp branches/valkyrie_qt4port/options/valkyrie_options_page.cpp branches/valkyrie_qt4port/options/vk_options_dialog.cpp branches/valkyrie_qt4port/options/vk_options_dialog.h branches/valkyrie_qt4port/options/widgets/opt_base_widget.cpp branches/valkyrie_qt4port/options/widgets/opt_base_widget.h branches/valkyrie_qt4port/options/widgets/opt_ck_widget.cpp Modified: branches/valkyrie_qt4port/objects/valgrind_object.cpp =================================================================== --- branches/valkyrie_qt4port/objects/valgrind_object.cpp 2010-03-12 02:33:11 UTC (rev 493) +++ branches/valkyrie_qt4port/objects/valgrind_object.cpp 2010-03-12 13:32:28 UTC (rev 494) @@ -547,9 +547,6 @@ break; } - // TODO: do we care if it doesn't end in .supp? - // - breaks the suppression widgets a little, as only lists those ending in .supp ... - // TODO: ? check valid suppression files } Modified: branches/valkyrie_qt4port/options/valkyrie_options_page.cpp =================================================================== --- branches/valkyrie_qt4port/options/valkyrie_options_page.cpp 2010-03-12 02:33:11 UTC (rev 493) +++ branches/valkyrie_qt4port/options/valkyrie_options_page.cpp 2010-03-12 13:32:28 UTC (rev 494) @@ -116,6 +116,7 @@ LeWidget* editLedit = (( LeWidget* )m_itemList[VALKYRIE::SRC_EDITOR] ); editLedit->addButton( group1, this, SLOT( getEditor() ) ); connect( editLedit, SIGNAL( returnPressed() ), this, SIGNAL( apply() ) ); + insertOptionWidget( VALKYRIE::SRC_LINES, group1, true ); // intspin insertOptionWidget( VALKYRIE::BROWSER, group1, false ); // line edit Modified: branches/valkyrie_qt4port/options/vk_options_dialog.cpp =================================================================== --- branches/valkyrie_qt4port/options/vk_options_dialog.cpp 2010-03-12 02:33:11 UTC (rev 493) +++ branches/valkyrie_qt4port/options/vk_options_dialog.cpp 2010-03-12 13:32:28 UTC (rev 494) @@ -50,13 +50,6 @@ setupLayout(); // ------------------------------------------------------------ - // setup default state - QPushButton* applyButton = optionsButtonBox->button( QDialogButtonBox::Apply ); - QPushButton* cancelButton = optionsButtonBox->button( QDialogButtonBox::Cancel ); - applyButton->setEnabled( false ); - cancelButton->setEnabled( false ); - - // ------------------------------------------------------------ // Add categories, and the default page (other pages loaded on demand) VkObjectList objList = (( MainWindow* )parent )->getValkyrie()->vkObjList(); @@ -98,12 +91,41 @@ } +/*! + Nothing to cleanup: Qt's object-parenting does it all for us. +*/ VkOptionsDialog::~VkOptionsDialog() { - // optPages.clear(); } +/*! + A return/enter keypress in an option widget isn't eaten up by that + widgets' event handler - it's propogated to the QDialog parent. + Enter/Return keypresses will then call the QDialog default-button, + which is the 'Ok' button. + + We don't know for sure if changes have been applied already, and + if the edits failed, we don't want to leave. + + Until this is worked out better, we're just going to ignore these + events: shortcuts & mouse are then the only way to accept(). + TODO: better way of doing this? +*/ +void VkOptionsDialog::keyPressEvent( QKeyEvent* event ) +{ + if ( event->key() == Qt::Key_Return || + event->key() == Qt::Key_Enter ) { + // eat keypress return/enter event, so dialog doesn't close + return; + } + QDialog::keyPressEvent( event ); +} + + +/*! + Setup our basic widget layout, ready for the pages +*/ void VkOptionsDialog::setupLayout() { // ------------------------------------------------------------ @@ -162,21 +184,28 @@ optionsButtonBox->setObjectName( QString::fromUtf8( "optionsButtonBox" ) ); optionsButtonBox->setOrientation( Qt::Horizontal ); optionsButtonBox->setStandardButtons( QDialogButtonBox::Apply | - QDialogButtonBox::Cancel | QDialogButtonBox::Ok ); + QDialogButtonBox::Cancel | + QDialogButtonBox::Ok ); hLayoutButtons->addWidget( optionsButtonBox ); - - // ------------------------------------------------------------ // signals / slots connect( contentsListWidget, SIGNAL( itemClicked( QListWidgetItem* ) ), this, SLOT( showPage( QListWidgetItem* ) ) ); - QPushButton* applyButton = optionsButtonBox->button( QDialogButtonBox::Apply ); - connect( applyButton, SIGNAL( released() ), this, SLOT( apply() ) ); // Apply + QPushButton* applyButton = optionsButtonBox->button( QDialogButtonBox::Apply ); + QPushButton* cancelButton = optionsButtonBox->button( QDialogButtonBox::Cancel ); + QPushButton* okButton = optionsButtonBox->button( QDialogButtonBox::Ok ); + connect( applyButton, SIGNAL( released() ), this, SLOT( apply() ) ); // Apply connect( optionsButtonBox, SIGNAL( rejected() ), this, SLOT( reject() ) ); // Cancel connect( optionsButtonBox, SIGNAL( accepted() ), this, SLOT( accept() ) ); // Ok connect( saveGlblButton, SIGNAL( released() ), this, SLOT( saveToGlobalConfig() ) ); + + // ------------------------------------------------------------ + // setup default state + applyButton->setEnabled( false ); + cancelButton->setEnabled( false ); + okButton->setDefault( true ); } Modified: branches/valkyrie_qt4port/options/vk_options_dialog.h =================================================================== --- branches/valkyrie_qt4port/options/vk_options_dialog.h 2010-03-12 02:33:11 UTC (rev 493) +++ branches/valkyrie_qt4port/options/vk_options_dialog.h 2010-03-12 13:32:28 UTC (rev 494) @@ -39,11 +39,13 @@ private: void setupLayout(); - + void keyPressEvent( QKeyEvent* event ); // overloaded + private slots: bool apply(); - void accept(); - void reject(); + void accept(); // overloaded + void reject(); // overloaded + void showPage( QListWidgetItem* ); void pageModified(); void saveToGlobalConfig(); Modified: branches/valkyrie_qt4port/options/widgets/opt_base_widget.cpp =================================================================== --- branches/valkyrie_qt4port/options/widgets/opt_base_widget.cpp 2010-03-12 02:33:11 UTC (rev 493) +++ branches/valkyrie_qt4port/options/widgets/opt_base_widget.cpp 2010-03-12 13:32:28 UTC (rev 494) @@ -23,9 +23,6 @@ #include "utils/vk_config.h" #include "utils/vk_utils.h" -#if 0 -#include "vk_messages.h" -#endif /* class OptionWidget -------------------------------------------------- */ Modified: branches/valkyrie_qt4port/options/widgets/opt_base_widget.h =================================================================== --- branches/valkyrie_qt4port/options/widgets/opt_base_widget.h 2010-03-12 02:33:11 UTC (rev 493) +++ branches/valkyrie_qt4port/options/widgets/opt_base_widget.h 2010-03-12 13:32:28 UTC (rev 494) @@ -47,7 +47,7 @@ void setEnabled( bool enable ); virtual void reset() = 0; - virtual void resetDefault() = 0; + virtual void resetDefault() = 0; //TODO: not used: wanted? virtual void saveEdit(); virtual void cancelEdit(); virtual QHBoxLayout* hlayout(); @@ -55,7 +55,7 @@ signals: void valueChanged( bool, OptionWidget* ); - + protected: QWidget* m_widg; QLabel* m_wLabel; Modified: branches/valkyrie_qt4port/options/widgets/opt_ck_widget.cpp =================================================================== --- branches/valkyrie_qt4port/options/widgets/opt_ck_widget.cpp 2010-03-12 02:33:11 UTC (rev 493) +++ branches/valkyrie_qt4port/options/widgets/opt_ck_widget.cpp 2010-03-12 13:32:28 UTC (rev 494) @@ -77,10 +77,7 @@ void CkWidget::resetDefault() { - QString val = m_opt->dfltValue.toString(); - bool on = ( val == "1" || val == "on" || - val == "yes" || val == "true" ); - setOn( on ); + setOn( VkConfig::strToBool( m_opt->dfltValue.toString() ) ); } bool CkWidget::isOn() |
From: <sv...@va...> - 2010-03-12 02:33:31
|
Author: cerion Date: 2010-03-12 02:33:11 +0000 (Fri, 12 Mar 2010) New Revision: 493 Log: cleaned up the valgrind::suppressions options stuff - no more 'dirs' + auto-scanning dirs to provide 'available', etc. crap. - just a simple multiple-file listbox is just fine, and there's much less to go wrong. Modified: branches/valkyrie_qt4port/objects/valgrind_object.cpp branches/valkyrie_qt4port/objects/valgrind_object.h branches/valkyrie_qt4port/objects/valkyrie_object.cpp branches/valkyrie_qt4port/options/valgrind_options_page.cpp branches/valkyrie_qt4port/options/valgrind_options_page.h branches/valkyrie_qt4port/options/widgets/opt_base_widget.cpp branches/valkyrie_qt4port/options/widgets/opt_cb_widget.cpp branches/valkyrie_qt4port/options/widgets/opt_ck_widget.cpp branches/valkyrie_qt4port/options/widgets/opt_lb_widget.cpp branches/valkyrie_qt4port/options/widgets/opt_lb_widget.h branches/valkyrie_qt4port/options/widgets/opt_le_widget.cpp branches/valkyrie_qt4port/options/widgets/opt_sp_widget.cpp branches/valkyrie_qt4port/toolview/helgrindview.cpp branches/valkyrie_qt4port/utils/vk_config.cpp branches/valkyrie_qt4port/utils/vk_config.h Modified: branches/valkyrie_qt4port/objects/valgrind_object.cpp =================================================================== --- branches/valkyrie_qt4port/objects/valgrind_object.cpp 2010-03-12 00:30:43 UTC (rev 492) +++ branches/valkyrie_qt4port/objects/valgrind_object.cpp 2010-03-12 02:33:11 UTC (rev 493) @@ -385,38 +385,6 @@ // ------------------------------------------------------------ - /* list of dirs holding suppression files */ - options.addOpt( - VALGRIND::SUPPS_DIRS, - this->objectName(), - "supps-dirs", - '\0', - "", - "", - VkConfig::vkSuppsDir(), - "Suppression Dirs:", - "", - urlValkyrie::suppsTab, - VkOPT::NOT_POPT, - VkOPT::WDG_LISTBOX - ); - - /* list of all suppression files found in option SUPP_DIRS */ - options.addOpt( - VALGRIND::SUPPS_AVAIL, - this->objectName(), - "supps-avail", - '\0', - "", - "", - "", - "Available error-suppression file(s):", - "", - urlValkyrie::suppsTab, - VkOPT::NOT_POPT, - VkOPT::WDG_LISTBOX - ); - /* list of selected suppression files */ options.addOpt( VALGRIND::SUPPS_SEL, @@ -426,7 +394,7 @@ "<file1,...>", "", "", - "Selected error-suppression file(s):", + "Error-suppression file(s):", "suppress errors described in suppressions file(s)", urlValkyrie::suppsTab, VkOPT::ARG_STRING, @@ -515,27 +483,7 @@ - - - /*! - Update config - special cases -*/ -void Valgrind::updateConfig( int optid, QString& argval ) -{ - // exception: multiple suppressions are allowed - if ( optid == VALGRIND::SUPPS_SEL ) { - //TODO: concat supps, don't overwrite - // vkConfig->value( vk_opt->configKey() ); - // argval = cfg_argval + argval - } - - VkObject::updateConfig( optid, argval ); -} - - - -/*! Check \a argval for the option given by \a optid, updating if necessary. */ int Valgrind::checkOptArg( int optid, QString& argval ) @@ -587,32 +535,6 @@ argval = escapeEntities( argval ); break; - case VALGRIND::SUPPS_DIRS: { - // not popt: only reaches here from gui - vk_assert( opt->argType == VkOPT::NOT_POPT ); - - // check all entries are valid dirs, - // and update dirs to absolute paths - QStringList dirs = argval.split( sep, QString::SkipEmptyParts ); - - QStringList::iterator it = dirs.begin(); - for ( ; it != dirs.end(); ++it ) { - // check dir ok and has at least RX permissions - *it = dirCheck( &errval, *it, true, false, true ); - - if ( errval != PARSED_OK ) { - break; - } - } - - argval = dirs.join( sep ); - } - break; - - case VALGRIND::SUPPS_AVAIL: { - // not popt: only reaches here from gui - vk_assert( opt->argType == VkOPT::NOT_POPT ); - } // fall through to next case. case VALGRIND::SUPPS_SEL: { QStringList files = argval.split( sep, QString::SkipEmptyParts ); @@ -746,8 +668,6 @@ // we never want these included case VALGRIND::TOOL: /* tool set by valkyrie */ - case VALGRIND::SUPPS_DIRS: /* false option */ - case VALGRIND::SUPPS_AVAIL: /* false option */ // ignore these opts break; Modified: branches/valkyrie_qt4port/objects/valgrind_object.h =================================================================== --- branches/valkyrie_qt4port/objects/valgrind_object.h 2010-03-12 00:30:43 UTC (rev 492) +++ branches/valkyrie_qt4port/objects/valgrind_object.h 2010-03-12 02:33:11 UTC (rev 493) @@ -59,9 +59,7 @@ SHOW_BELOW, // --show-below-main // suppressions hackery - SUPPS_DIRS, // list of suppfile dirs - feeds SUPPS_AVAIL list - SUPPS_AVAIL, // fake opt: dyname list of available supp files - SUPPS_SEL, // the currently selected suppression(s) + SUPPS_SEL, // selected suppression files // misc GEN_SUPP, // --gen-suppressions @@ -89,8 +87,6 @@ int checkOptArg( int optid, QString& argval ); - void updateConfig( int optid, QString& argval ); - VkOptionsPage* createVkOptionsPage(); public: Modified: branches/valkyrie_qt4port/objects/valkyrie_object.cpp =================================================================== --- branches/valkyrie_qt4port/objects/valkyrie_object.cpp 2010-03-12 00:30:43 UTC (rev 492) +++ branches/valkyrie_qt4port/objects/valkyrie_object.cpp 2010-03-12 02:33:11 UTC (rev 493) @@ -505,7 +505,7 @@ void Valkyrie::updateConfig( int optid, QString& argval ) { // Load config settings from project file - // - load these first before + // - load these first before updating the rest if ( optid == VALKYRIE::PROJ_FILE ) { QString proj_filename = argval; Modified: branches/valkyrie_qt4port/options/valgrind_options_page.cpp =================================================================== --- branches/valkyrie_qt4port/options/valgrind_options_page.cpp 2010-03-12 00:30:43 UTC (rev 492) +++ branches/valkyrie_qt4port/options/valgrind_options_page.cpp 2010-03-12 02:33:11 UTC (rev 493) @@ -221,32 +221,13 @@ supp_vbox->setObjectName( QString::fromUtf8( "supp_vbox" ) ); // tabErep - options - insertOptionWidget( VALGRIND::SUPPS_DIRS, tabSupps, true ); // listbox - insertOptionWidget( VALGRIND::SUPPS_AVAIL, tabSupps, true ); // listbox - insertOptionWidget( VALGRIND::SUPPS_SEL, tabSupps, true ); // listbox + insertOptionWidget( VALGRIND::SUPPS_SEL, tabSupps, true ); // listbox - /* FIXME: suppression listbox widgets have far too much knowledge - about what they're used for. */ - LbWidget* lbDirs = ( LbWidget* )m_itemList[VALGRIND::SUPPS_DIRS]; - LbWidget* lbAvail = ( LbWidget* )m_itemList[VALGRIND::SUPPS_AVAIL]; - LbWidget* lbSel = ( LbWidget* )m_itemList[VALGRIND::SUPPS_SEL]; + LbWidget* lbSel = ( LbWidget* )m_itemList[VALGRIND::SUPPS_SEL]; + supp_vbox->addLayout( lbSel->vlayout() ); - // lbDirs updates lbAvail - connect( lbDirs, SIGNAL( listChanged() ), - this, SLOT( suppDirsChanged() ) ); - - // lbSel and lbAvail update each other - connect( lbAvail, SIGNAL( itemSelected( const QString& ) ), - this, SLOT( updateSuppsSel( const QString& ) ) ); - connect( lbSel, SIGNAL( listChanged() ), - this, SLOT( updateSuppsAvail() ) ); - - supp_vbox->addLayout( m_itemList[VALGRIND::SUPPS_DIRS ]->vlayout(), 1 ); - supp_vbox->addLayout( m_itemList[VALGRIND::SUPPS_AVAIL]->vlayout(), 2 ); - supp_vbox->addLayout( m_itemList[VALGRIND::SUPPS_SEL ]->vlayout(), 1 ); - // ============================================================ // Disabled Widgets /* These widgets are disabled because Valkyrie uses @@ -289,109 +270,14 @@ } - - -#if 1 -/* Called from OptionsDialog::categoryClicked() */ -void ValgrindOptionsPage::init() -{ - /* if usr gave suppfile on cmdline (updating lbSel) - - update suppDirs, suppsAvail from each path in lbSel */ - QChar sep = vkConfig->vkSepChar; - LbWidget* lbSel = ( LbWidget* )m_itemList[Valgrind::SUPPS_SEL ]; - QStringList currSupps = QStringList::split( sep, lbSel->currValue() ); //, QString::SkipEmptyParts - LbWidget* lbDirs = ( LbWidget* )m_itemList[Valgrind::SUPPS_DIRS]; - QStringList suppDirs = QStringList::split( sep, lbDirs->currValue() ); //, QString::SkipEmptyParts - - for ( unsigned int i = 0; i < currSupps.count(); i++ ) { - QFileInfo fi( currSupps[i] ); - QString path = fi.dirPath(); - - if ( suppDirs.find( path ) == suppDirs.end() ) { - suppDirs << path; - } - } - - lbDirs->setCurrValue( suppDirs.join( sep ) ); - - /* apply changes to lbDirs */ - applyEdits(); - - /* init suppsAvail */ - suppDirsChanged(); -} -#endif - - void ValgrindOptionsPage::getDbBin() { vkPrintErr( "TODO: ValgrindOptionsPage::getDbBin()\n" ); } -/*! - Scan dirs set in option "valgrind::supps-dirs" for available - suppression files. - Update other widgets with result. -*/ -void ValgrindOptionsPage::suppDirsChanged() +#if 0 //TODO { - m_allAvailSuppFiles = QStringList(); - LbWidget* lbDirs = ( LbWidget* )m_itemList[VALGRIND::SUPPS_DIRS]; - QChar sep = vkConfig->vkSepChar; - - // Get list of dirs from "valgrind::supps-dirs" - QStringList suppDirs = lbDirs->currValue().split( sep, QString::SkipEmptyParts ); - - for ( int i = 0; i < suppDirs.count(); i++ ) { - - // for each suppDir, find all supp files - QDir suppDir( suppDirs[i] ); - QString path = suppDir.absolutePath() + '/'; - QStringList entries = suppDir.entryList( QStringList( "*.supp" ), QDir::Files ); - - for ( int i = 0; i < entries.count(); i++ ) { - m_allAvailSuppFiles += ( path + entries[i] ); - } - } - - updateSuppsAvail(); -} - - -/*! - Given available suppfiles from dirscan, - remove those already selected in option "valgrind::supps-sel" - Set suppsAvail list with result. -*/ -void ValgrindOptionsPage::updateSuppsAvail() -{ - QChar sep = vkConfig->vkSepChar; - LbWidget* lbAvail = ( LbWidget* )m_itemList[VALGRIND::SUPPS_AVAIL]; - LbWidget* lbSel = ( LbWidget* )m_itemList[VALGRIND::SUPPS_SEL ]; - QStringList suppsAvail = m_allAvailSuppFiles; - QStringList currSupps = lbSel->currValue().split( sep, QString::SkipEmptyParts ); - - for ( int i = 0; i < currSupps.count(); i++ ) { - int idx = suppsAvail.indexOf( currSupps[i] ); - - if ( idx != -1 ) { - suppsAvail.removeAt( idx ); - } - } - - lbAvail->setCurrValue( suppsAvail.join( sep ) ); -} - - -/*! - Called by selecting an item in suppsAvail listbox. - Adds item to selected supps listbox (up to limit) -*/ -void ValgrindOptionsPage::updateSuppsSel( const QString& suppr ) -{ - LbWidget* lbSel = ( LbWidget* )m_itemList[VALGRIND::SUPPS_SEL]; - if ((( QListWidget* )lbSel->widget() )->count() < VG_CLO_MAX_SFILES ) { lbSel->insertItem( suppr ); } @@ -402,3 +288,4 @@ VG_CLO_MAX_SFILES ); } } +#endif Modified: branches/valkyrie_qt4port/options/valgrind_options_page.h =================================================================== --- branches/valkyrie_qt4port/options/valgrind_options_page.h 2010-03-12 00:30:43 UTC (rev 492) +++ branches/valkyrie_qt4port/options/valgrind_options_page.h 2010-03-12 02:33:11 UTC (rev 493) @@ -34,22 +34,10 @@ public: ValgrindOptionsPage( VkObject* obj ); -#if 0 - - void init(); -#endif - private slots: void getDbBin(); - void suppDirsChanged(); - void updateSuppsAvail(); - void updateSuppsSel( const QString& ); private: - // hold on to these, so don't have to rescan dirs all the time - QStringList m_allAvailSuppFiles; - -private: void setupOptions(); private: Modified: branches/valkyrie_qt4port/options/widgets/opt_base_widget.cpp =================================================================== --- branches/valkyrie_qt4port/options/widgets/opt_base_widget.cpp 2010-03-12 00:30:43 UTC (rev 492) +++ branches/valkyrie_qt4port/options/widgets/opt_base_widget.cpp 2010-03-12 02:33:11 UTC (rev 493) @@ -32,6 +32,8 @@ OptionWidget::OptionWidget( QWidget* parent, VkOption* vkopt, bool mklabel ) : QObject( parent ) { + this->setObjectName( "option_widget" ); + m_opt = vkopt; m_widg = 0; m_wLabel = 0; Modified: branches/valkyrie_qt4port/options/widgets/opt_cb_widget.cpp =================================================================== --- branches/valkyrie_qt4port/options/widgets/opt_cb_widget.cpp 2010-03-12 00:30:43 UTC (rev 492) +++ branches/valkyrie_qt4port/options/widgets/opt_cb_widget.cpp 2010-03-12 02:33:11 UTC (rev 493) @@ -37,6 +37,8 @@ CbWidget::CbWidget( QWidget* parent, VkOption* vkopt, bool mklabel ) : OptionWidget( parent, vkopt, mklabel ) { + this->setObjectName( "cb_widget" ); + m_currIdx = 0; m_combo = new QComboBox( parent ); // true m_widg = m_combo; Modified: branches/valkyrie_qt4port/options/widgets/opt_ck_widget.cpp =================================================================== --- branches/valkyrie_qt4port/options/widgets/opt_ck_widget.cpp 2010-03-12 00:30:43 UTC (rev 492) +++ branches/valkyrie_qt4port/options/widgets/opt_ck_widget.cpp 2010-03-12 02:33:11 UTC (rev 493) @@ -32,6 +32,8 @@ CkWidget::CkWidget( QWidget* parent, VkOption* vkopt, bool mklabel ) : OptionWidget( parent, vkopt, mklabel ) { + this->setObjectName( "ck_widget" ); + m_cbox = new QCheckBox( m_opt->shortHelp, parent ); m_widg = m_cbox; Modified: branches/valkyrie_qt4port/options/widgets/opt_lb_widget.cpp =================================================================== --- branches/valkyrie_qt4port/options/widgets/opt_lb_widget.cpp 2010-03-12 00:30:43 UTC (rev 492) +++ branches/valkyrie_qt4port/options/widgets/opt_lb_widget.cpp 2010-03-12 02:33:11 UTC (rev 493) @@ -66,7 +66,7 @@ LbWidget::LbWidget( QWidget* parent, VkOption* vkopt, bool mklabel ) : OptionWidget( parent, vkopt, mklabel ) { - // "lb_widget" + this->setObjectName( "lb_widget" ); m_lbox = new QListWidget( parent ); m_lbox->setObjectName( QString::fromUtf8( "list_box" ) ); @@ -75,28 +75,10 @@ m_sep = vkConfig->vkSepChar; - // horrible hack alert! - vk_assert( m_opt->configGrp == "valgrind" ); - - if ( m_opt->longFlag == "supps-dirs" ) { - m_mode = LbWidget::LB_SUPPDIRS; - } - else if ( m_opt->longFlag == "supps-avail" ) { - m_mode = LbWidget::LB_SUPPAVAIL; - } - else if ( m_opt->longFlag == "suppressions" ) { - m_mode = LbWidget::LB_SUPPSEL; - } - else { - vk_assert_never_reached(); - } - - lbLoad(); + reset(); m_lbox->setContextMenuPolicy( Qt::CustomContextMenu ); connect( m_lbox, SIGNAL( customContextMenuRequested( const QPoint& ) ), this, SLOT( popupMenu( const QPoint& ) ) ); - connect( m_lbox, SIGNAL( itemDoubleClicked( QListWidgetItem* ) ), - this, SLOT( selectItem( QListWidgetItem* ) ) ); // not added if the url is empty ContextHelp::addHelp( m_widg, m_opt->urlAddress ); @@ -112,35 +94,29 @@ } - -/* load items from m_currentValue to listbox */ -void LbWidget::lbLoad() +/*! + reset lbox to m_currentValue + called from OptionWidget::cancelEdit(), after m_currentValue reset. + */ +void LbWidget::reset() { m_lbox->clear(); QStringList sfiles = m_currentValue.split( m_sep, QString::SkipEmptyParts ); - + for ( int i = 0; i < sfiles.count(); i++ ) { m_lbox->addItem( sfiles[i] ); } } -/* reset lbox to m_currentValue - called from OptionWidget::cancelEdit(), after m_currentValue reset. +/*! + called from OptionsPage::resetDefaults() + reset to installation defaults */ -void LbWidget::reset() -{ - lbLoad(); - emit listChanged(); -} - -/* called from OptionsPage::resetDefaults() - reset to installation defaults - */ void LbWidget::resetDefault() { m_currentValue = m_opt->dfltValue.toString(); - lbLoad(); + reset(); lbChanged(); } @@ -148,16 +124,19 @@ void LbWidget::setCurrValue( const QString& txt ) { m_currentValue = txt; - lbLoad(); + reset(); lbChanged(); } -/* return all contents concat'd with m_sep */ +/*! + return all contents concat'd with m_sep +*/ QString LbWidget::lbText() { QStringList items; - + for ( int i = 0; i < m_lbox->count(); i++ ) { + m_lbox->removeItemWidget( m_lbox->item( i ) ); items += m_lbox->item( i )->text(); } @@ -165,201 +144,61 @@ } -/* emit signals to indicate widget content has changed */ +/*! + emit signals to indicate widget content has changed +*/ void LbWidget::lbChanged() { - switch ( m_mode ) { - case LbWidget::LB_SUPPAVAIL: - // Never test this widget's editedness - holds a dynamic list - break; - - case LbWidget::LB_SUPPDIRS: - case LbWidget::LB_SUPPSEL: { - bool edited = m_currentValue != m_initialValue; - emit valueChanged( edited, this ); - emit listChanged(); - } - break; - - default: - vk_assert_never_reached(); - break; - } + emit valueChanged( (m_currentValue != m_initialValue), this ); } -/* insert new list item. - only valid mode is LB_SUPPSEL +/*! + different menus and stuff for the different modes */ -void LbWidget::insertItem( const QString& entry ) -{ - switch ( m_mode ) { - case LbWidget::LB_SUPPSEL: - m_lbox->addItem( entry ); - m_currentValue = lbText(); - lbChanged(); - break; - - case LbWidget::LB_SUPPDIRS: - case LbWidget::LB_SUPPAVAIL: - default: - vk_assert_never_reached(); - break; - } -} - - -/* double clicked item, or via right-click menu - for a single-entry menu, do the only thing possible - else do nothing -*/ -void LbWidget::selectItem( QListWidgetItem* lb_item ) -{ - if ( !lb_item ) { - return; - } - - switch ( m_mode ) { - case LbWidget::LB_SUPPDIRS: - break; - - case LbWidget::LB_SUPPSEL: - emit itemSelected( lb_item->text() ); - m_lbox->removeItemWidget( lb_item ); - m_currentValue = lbText(); - lbChanged(); - break; - - case LbWidget::LB_SUPPAVAIL: - emit itemSelected( lb_item->text() ); - // Not removing item - list recalculated in valgrind opts page - break; - - default: - vk_assert_never_reached(); - break; - } -} - - -/* different menus and stuff for the different modes */ void LbWidget::popupMenu( const QPoint& pos ) { QListWidgetItem* lb_item = m_lbox->itemAt( pos ); - switch ( m_mode ) { - case LbWidget::LB_SUPPDIRS: - popupSuppDirs( lb_item, pos ); - break; - case LbWidget::LB_SUPPAVAIL: - popupSuppAvail( lb_item, pos ); - break; - case LbWidget::LB_SUPPSEL: - popupSuppSel( lb_item, pos ); - break; - default: - vk_assert_never_reached(); - break; - } -} + QAction actRemove( QPixmap( sel_supp_xpm ), "Remove File", this ); + QAction actAdd( QPixmap( sel_supp_xpm ), "Add File", this ); - -void LbWidget::popupSuppSel( QListWidgetItem* lb_item, const QPoint& pos ) -{ - vk_assert( m_mode == LbWidget::LB_SUPPSEL ); - - if ( !lb_item ) { // m_lbox is empty, so nothing to do - return; + if ( !lb_item ) { + actRemove.setEnabled( false ); } - QAction deselectAct( "Deselect File", this ); - -//TODO: check this - if ( !( lb_item->isSelected() ) ) { // || lb_item->isCurrent()) ) { - deselectAct.setEnabled( false ); - } - QMenu menu( m_lbox ); - menu.addAction( &deselectAct ); + menu.addAction( &actRemove ); + menu.addAction( &actAdd ); QAction* act = menu.exec( m_lbox->mapToGlobal( pos ) ); - if ( act == &deselectAct ) { - selectItem( lb_item ); + if ( act == &actRemove ) { + vk_assert( lb_item ); + m_lbox->takeItem( m_lbox->row( lb_item ) ); + // update currentvalue, and emit signal + m_currentValue = lbText(); + lbChanged(); } -} - - -void LbWidget::popupSuppAvail( QListWidgetItem* lb_item, const QPoint& pos ) -{ - vk_assert( m_mode == LbWidget::LB_SUPPAVAIL ); - - QAction selectAct( QPixmap( sel_supp_xpm ), "Select File", this ); - - if ( !lb_item || !( lb_item->isSelected() || - ( m_lbox->currentItem() == lb_item ) ) ) { - selectAct.setEnabled( false ); - } - - QMenu menu( m_lbox ); - menu.addAction( &selectAct ); - QAction* act = menu.exec( m_lbox->mapToGlobal( pos ) ); - - if ( act == &selectAct ) { - selectItem( lb_item ); - } -} - - -void LbWidget::popupSuppDirs( QListWidgetItem* lb_item, const QPoint& pos ) -{ - vk_assert( m_mode == LbWidget::LB_SUPPDIRS ); - - QAction rmDirAct( QPixmap( sel_supp_xpm ), "Remove Dir", this ); - QAction addDirAct( QPixmap( sel_supp_xpm ), "Add Dir", this ); - - if ( !lb_item/* empty */ ) { - rmDirAct.setEnabled( false ); - } - - QMenu menu( m_lbox ); - menu.addAction( &rmDirAct ); - menu.addAction( &addDirAct ); - QAction* act = menu.exec( m_lbox->mapToGlobal( pos ) ); - - bool changed = false; - - if ( act == &rmDirAct ) { - m_lbox->removeItemWidget( lb_item ); - changed = true; - } - else if ( act == &addDirAct ) { - QString startdir = m_currentValue.isEmpty() ? - QDir::currentPath() : - m_currentValue.split( m_sep, QString::SkipEmptyParts ).first(); - - QString supp_dir = QFileDialog::getExistingDirectory( - m_lbox, - tr( "Choose Suppressions Directory" ), - startdir, - QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks ); + else if ( act == &actAdd ) { + QString supp_file = + QFileDialog::getOpenFileName( m_lbox, + tr( "Choose Suppression File" ), + "./", tr("Suppression Files (*.supp)") ); - if ( ! supp_dir.isEmpty() ) { // user clicked Cancel ? + if ( ! supp_file.isEmpty() ) { // user clicked Cancel ? // check not a duplicate entry - if ( ! m_lbox->findItems( supp_dir, Qt::MatchExactly ).isEmpty() ) { - + if ( ! m_lbox->findItems( supp_file, Qt::MatchExactly ).isEmpty() ) { + vkInfo( m_lbox, "Duplicate Entry", "The entry '%s' is already in the list.", - qPrintable( supp_dir ) ); + qPrintable( supp_file ) ); } else { - m_lbox->addItem( supp_dir ); - changed = true; + m_lbox->addItem( supp_file ); + // update currentvalue, and emit signal + m_currentValue = lbText(); + lbChanged(); } } } - - if ( changed ) { - m_currentValue = lbText(); - lbChanged(); - } } Modified: branches/valkyrie_qt4port/options/widgets/opt_lb_widget.h =================================================================== --- branches/valkyrie_qt4port/options/widgets/opt_lb_widget.h 2010-03-12 00:30:43 UTC (rev 492) +++ branches/valkyrie_qt4port/options/widgets/opt_lb_widget.h 2010-03-12 02:33:11 UTC (rev 493) @@ -26,7 +26,7 @@ // ============================================================ -// listbox widget - specificly for suppression files +// listbox widget - for lists of files class LbWidget : public OptionWidget { Q_OBJECT @@ -37,35 +37,16 @@ void resetDefault(); void setCurrValue( const QString& ); -public slots: - void insertItem( const QString& ); -signals: - void itemSelected( const QString& ); - void listChanged(); - private slots: void popupMenu( const QPoint& ); - void selectItem( QListWidgetItem* lb_item ); - void popupSuppDirs( QListWidgetItem*, const QPoint& pos ); - void popupSuppAvail( QListWidgetItem*, const QPoint& pos ); - void popupSuppSel( QListWidgetItem*, const QPoint& pos ); private: QString lbText(); void lbChanged(); - void lbLoad(); private: QListWidget* m_lbox; - QChar m_sep; // so we don't have to keep asking vkConfig - - /* Note: - LB_SUPPDIRS = valgrind::supps-dirs = dirs to scan for supps - LB_SUPPAVAIL = valgrind::supps-avail = available supps to use - LB_SUPPSEL = valgrind::suppressions = selected supps - */ - enum LBMode { LB_SUPPDIRS, LB_SUPPAVAIL, LB_SUPPSEL }; - LBMode m_mode; + QChar m_sep; }; #endif // __VK_OPTION_LB_WIDGET_H Modified: branches/valkyrie_qt4port/options/widgets/opt_le_widget.cpp =================================================================== --- branches/valkyrie_qt4port/options/widgets/opt_le_widget.cpp 2010-03-12 00:30:43 UTC (rev 492) +++ branches/valkyrie_qt4port/options/widgets/opt_le_widget.cpp 2010-03-12 02:33:11 UTC (rev 493) @@ -30,6 +30,8 @@ LeWidget::LeWidget( QWidget* parent, VkOption* vkopt, bool mklabel ) : OptionWidget( parent, vkopt, mklabel ) { + this->setObjectName( "le_widget" ); + m_pb = 0; m_ledit = new QLineEdit( parent ); m_widg = m_ledit; Modified: branches/valkyrie_qt4port/options/widgets/opt_sp_widget.cpp =================================================================== --- branches/valkyrie_qt4port/options/widgets/opt_sp_widget.cpp 2010-03-12 00:30:43 UTC (rev 492) +++ branches/valkyrie_qt4port/options/widgets/opt_sp_widget.cpp 2010-03-12 02:33:11 UTC (rev 493) @@ -34,6 +34,8 @@ bool mklabel, int num_sections ) : OptionWidget( parent, vkopt, mklabel ) { + this->setObjectName( "sp_widget" ); + m_intspin = new IntSpin( parent ); m_widg = m_intspin; Modified: branches/valkyrie_qt4port/toolview/helgrindview.cpp =================================================================== --- branches/valkyrie_qt4port/toolview/helgrindview.cpp 2010-03-12 00:30:43 UTC (rev 492) +++ branches/valkyrie_qt4port/toolview/helgrindview.cpp 2010-03-12 02:33:11 UTC (rev 493) @@ -69,7 +69,7 @@ } -void HelgrindView::setState( bool run ) +void HelgrindView::setState( bool /*run*/ ) { } Modified: branches/valkyrie_qt4port/utils/vk_config.cpp =================================================================== --- branches/valkyrie_qt4port/utils/vk_config.cpp 2010-03-12 00:30:43 UTC (rev 492) +++ branches/valkyrie_qt4port/utils/vk_config.cpp 2010-03-12 02:33:11 UTC (rev 493) @@ -609,10 +609,3 @@ return QDir::homePath() + "/" + VK_CFG_GLBL_DIR + "/" + QString( VK_CFG_GLBL ) + "." + QString( VK_CFG_EXT ); } - -QString VkConfig::vkSuppsDir() -{ - return QDir::homePath() + "/" + VK_CFG_GLBL_DIR - + "/" + QString( VK_SUPPS_DIR ); -} - Modified: branches/valkyrie_qt4port/utils/vk_config.h =================================================================== --- branches/valkyrie_qt4port/utils/vk_config.h 2010-03-12 00:30:43 UTC (rev 492) +++ branches/valkyrie_qt4port/utils/vk_config.h 2010-03-12 02:33:11 UTC (rev 493) @@ -60,7 +60,6 @@ #define VK_INSTALL_PREFIX "./" //"$VK_INSTALL_PREFIX" #define VK_DOC_PATH "/doc/" #define VK_DBASE_DIR "dbase/" -#define VK_SUPPS_DIR "suppressions/" #define VK_BIN_VALGRIND "valgrind" #define VK_BIN_EDITOR "vi" #define VK_COPYRIGHT "(c) 2003-2010" @@ -101,7 +100,6 @@ // util functions static bool strToBool( QString str ); static QString vkCfgGlblFilename(); - static QString vkSuppsDir(); static QString vkTmpDir(); #if 0 |
From: <sv...@va...> - 2010-03-12 00:30:57
|
Author: cerion Date: 2010-03-12 00:30:43 +0000 (Fri, 12 Mar 2010) New Revision: 492 Log: options pages: - before saving to global config, query if user certain - brought back in functionality to help choose options: fonts, dirs, files, etc. - bigger font for option-page choice list Modified: branches/valkyrie_qt4port/objects/valkyrie_object.cpp branches/valkyrie_qt4port/options/valgrind_options_page.cpp branches/valkyrie_qt4port/options/valkyrie_options_page.cpp branches/valkyrie_qt4port/options/vk_options_dialog.cpp branches/valkyrie_qt4port/options/vk_options_page.cpp branches/valkyrie_qt4port/utils/vk_config.cpp Modified: branches/valkyrie_qt4port/objects/valkyrie_object.cpp =================================================================== --- branches/valkyrie_qt4port/objects/valkyrie_object.cpp 2010-03-11 21:54:47 UTC (rev 491) +++ branches/valkyrie_qt4port/objects/valkyrie_object.cpp 2010-03-12 00:30:43 UTC (rev 492) @@ -543,26 +543,32 @@ case VALKYRIE::FNT_GEN_SYS: case VALKYRIE::FNT_GEN_USR: case VALKYRIE::FNT_TOOL_USR: - case VALKYRIE::SRC_LINES: - case VALKYRIE::BROWSER: { + case VALKYRIE::SRC_LINES: { vk_assert( opt->argType == VkOPT::NOT_POPT ); return errval; } break; - // dir options: check for rwx permissions + // dir options: check for RWX permissions case VALKYRIE::DFLT_LOGDIR: case VALKYRIE::WORKING_DIR: { ( void ) dirCheck( &errval, argval, true, true, true ); } break; + // helper executables + case VALKYRIE::BROWSER: case VALKYRIE::SRC_EDITOR: { - // source editor executable: check for at least X permissions - QString ed_file = argval.split( " " ).first(); - QString ed = fileCheck( &errval, ed_file, false, false, true ); - argval.replace( ed_file, ed ); - argval = argval.simplified(); + if ( argval.isEmpty() ) { + // empty is fine. + } else { + // check for at least X permissions. + QString path = argval.split( " " ).first(); + QString file = fileCheck( &errval, path, false, false, true ); + argval.replace( path, file ); + argval = argval.simplified(); + } } break; + // valkyrie project file case VALKYRIE::PROJ_FILE: { // check file exists and has RW perms argval = fileCheck( &errval, argval, true, true ); Modified: branches/valkyrie_qt4port/options/valgrind_options_page.cpp =================================================================== --- branches/valkyrie_qt4port/options/valgrind_options_page.cpp 2010-03-11 21:54:47 UTC (rev 491) +++ branches/valkyrie_qt4port/options/valgrind_options_page.cpp 2010-03-12 00:30:43 UTC (rev 492) @@ -291,8 +291,8 @@ -#if 0 -/* Called from OptionsWindow::categoryClicked() */ +#if 1 +/* Called from OptionsDialog::categoryClicked() */ void ValgrindOptionsPage::init() { /* if usr gave suppfile on cmdline (updating lbSel) @@ -329,9 +329,10 @@ } -/* Scan dirs set in option "valgrind::supps-dirs" for available - suppression files. - Update other widgets with result. +/*! + Scan dirs set in option "valgrind::supps-dirs" for available + suppression files. + Update other widgets with result. */ void ValgrindOptionsPage::suppDirsChanged() { @@ -339,12 +340,12 @@ LbWidget* lbDirs = ( LbWidget* )m_itemList[VALGRIND::SUPPS_DIRS]; QChar sep = vkConfig->vkSepChar; - /* Get list of dirs from "valgrind::supps-dirs" */ + // Get list of dirs from "valgrind::supps-dirs" QStringList suppDirs = lbDirs->currValue().split( sep, QString::SkipEmptyParts ); for ( int i = 0; i < suppDirs.count(); i++ ) { - /* for each suppDir, find all supp files */ + // for each suppDir, find all supp files QDir suppDir( suppDirs[i] ); QString path = suppDir.absolutePath() + '/'; QStringList entries = suppDir.entryList( QStringList( "*.supp" ), QDir::Files ); @@ -358,9 +359,10 @@ } -/* Given available suppfiles from dirscan, - remove those already selected in option "valgrind::supps-sel" - Set suppsAvail list with result. +/*! + Given available suppfiles from dirscan, + remove those already selected in option "valgrind::supps-sel" + Set suppsAvail list with result. */ void ValgrindOptionsPage::updateSuppsAvail() { @@ -382,8 +384,9 @@ } -/* Called by selecting an item in suppsAvail listbox. - Adds item to selected supps listbox (up to limit) +/*! + Called by selecting an item in suppsAvail listbox. + Adds item to selected supps listbox (up to limit) */ void ValgrindOptionsPage::updateSuppsSel( const QString& suppr ) { @@ -393,7 +396,7 @@ lbSel->insertItem( suppr ); } else { - /* valgrind doesn't accept any more suppression files */ + // valgrind doesn't accept any more suppression files vkError( this, "Error", "Valgrind won't accept more than %d suppression files", VG_CLO_MAX_SFILES ); Modified: branches/valkyrie_qt4port/options/valkyrie_options_page.cpp =================================================================== --- branches/valkyrie_qt4port/options/valkyrie_options_page.cpp 2010-03-11 21:54:47 UTC (rev 491) +++ branches/valkyrie_qt4port/options/valkyrie_options_page.cpp 2010-03-12 00:30:43 UTC (rev 492) @@ -19,8 +19,10 @@ ****************************************************************************/ #include <QApplication> -#include <QVBoxLayout> +#include <QFileDialog> +#include <QFontDialog> #include <QLabel> +#include <QVBoxLayout> #include "help/help_context.h" #include "help/help_urls.h" @@ -194,171 +196,167 @@ } -/* called by pbFont: conjures up a QFontDialog */ +/*! + Allows user to select a general font +*/ void ValkyrieOptionsPage::chooseGenFont() { - cerr << "TODO: ValkyrieOptionsPage::chooseGenFont()" << endl; -#if 0 // TODO LeWidget* fontLedit = (( LeWidget* )m_itemList[VALKYRIE::FNT_GEN_USR] ); QFont afont; - afont.fromString( fontLedit->initValue() ); + afont.fromString( fontLedit->currValue() ); bool ok; - QFont font = QFontDialog::getFont( &ok, afont, this ); + QFont font = QFontDialog::getFont( &ok, afont, this, "Select General Font" ); if ( ok ) { fontLedit->setCurrValue( font.toString() ); } - else { /* user clicked cancel */ - m_itemList[VALKYRIE::FNT_GEN_SYS]->reset(); - } - -#endif } -/* called by pbFont: conjures up a QFontDialog */ +/*! + Allows user to select a tool font +*/ void ValkyrieOptionsPage::chooseToolFont() { - cerr << "TODO: ValkyrieOptionsPage::chooseToolFont()" << endl; -#if 0 // TODO LeWidget* fontLedit = (( LeWidget* )m_itemList[VALKYRIE::FNT_TOOL_USR] ); QFont afont; - afont.fromString( fontLedit->initValue() ); + afont.fromString( fontLedit->currValue() ); bool ok; - QFont font = QFontDialog::getFont( &ok, afont, this ); + QFont font = QFontDialog::getFont( &ok, afont, this, "Select Tool Font" ); if ( ok ) { fontLedit->setCurrValue( font.toString() ); } - -#endif } +/*! + Allows user to select the source editor +*/ void ValkyrieOptionsPage::getEditor() { - cerr << "TODO: ValkyrieOptionsPage::getEditor()" << endl; -#if 0 // TODO - /* try and start up somewhere sensible */ - QString ed = m_itemList[VALKYRIE::SRC_EDITOR]->currValue(); - QString ed_file = QStringList::split( " ", ed ).first(); //, QString::SkipEmptyParts - QFileInfo fi( ed_file ); + // try and start up somewhere sensible + QString start_dir = "/"; + + // get current dir of current editor + LeWidget* editLedit = (( LeWidget* )m_itemList[VALKYRIE::SRC_EDITOR] ); + QString ed = editLedit->currValue(); + if ( !ed.isEmpty() ) { + QString ed_file = ed.split( " ", QString::SkipEmptyParts ).first(); + int err_val; + ed_file = fileCheck( &err_val, ed_file, false, false, true ); + + QFileInfo fi( ed_file ); + start_dir = fi.absolutePath(); + } - QString ed_path = - QFileDialog::getOpenFileName( fi.dirPath(), "All Files (*)", - this, "fdlg", "Select Source Editor" ); + QString editor = + QFileDialog::getOpenFileName( this, tr("Select Source Editor"), + start_dir, tr("All Files (*)")); - if ( ed_path.isEmpty() ) { /* user might have clicked Cancel */ - return; + if ( !editor.isEmpty() ) { // user might have clicked Cancel + + // for a few well known editors, add the + // go-to-line editor flag, plus our replacement string (%n) + QFileInfo fi( editor ); + if ( fi.fileName().startsWith( "emacs " ) || + fi.fileName().startsWith( "gedit " ) || + fi.fileName().startsWith( "gvim " ) || + fi.fileName().startsWith( "nano " ) || + fi.fileName().startsWith( "nedit " ) ) { + editor += " +%n"; + } + + editLedit->setCurrValue( editor ); + checkOption( VALKYRIE::SRC_EDITOR ); } - - fi.setFile( ed_path ); - - ed = ed_path; - - if ( fi.fileName().startsWith( "emacs" ) || - fi.fileName().startsWith( "nedit" ) ) { - /* add go-to-line flag + replacement string (%n) */ - ed += " +%n"; - } - - (( LeWidget* )m_itemList[VALKYRIE::SRC_EDITOR] )->setCurrValue( ed ); - checkOption( VALKYRIE::SRC_EDITOR ); -#endif } -/* allows user to select executable-to-debug */ +/*! + Allows user to select executable-to-debug +*/ void ValkyrieOptionsPage::getBinary() { - cerr << "TODO: ValkyrieOptionsPage::getBinary()" << endl; -#if 0 // TODO QString binfile = - QFileDialog::getOpenFileName( QString::null, "All Files (*)", - this, "fdlg", "Select Executable" ); - - if ( !binfile.isEmpty() ) { /* user might have clicked Cancel */ + QFileDialog::getOpenFileName( this, tr("Select Executable To Debug"), + "./", tr("All Files (*)")); + + if ( !binfile.isEmpty() ) { // user might have clicked Cancel (( LeWidget* )m_itemList[VALKYRIE::BINARY] )->setCurrValue( binfile ); checkOption( VALKYRIE::BINARY ); } - -#endif } -/* allows user to select default browser */ +/*! + Allows user to select the default browser +*/ void ValkyrieOptionsPage::getBrowser() { - cerr << "TODO: ValkyrieOptionsPage::getBrowser()" << endl; -#if 0 // TODO QString brwsr = - QFileDialog::getOpenFileName( QString::null, "All Files (*)", - this, "fdlg", "Select Browser" ); - - if ( !brwsr.isEmpty() ) { /* user might have clicked Cancel */ + QFileDialog::getOpenFileName( this, tr("Select Browser"), + "./", tr("All Files (*)")); + + if ( !brwsr.isEmpty() ) { // user might have clicked Cancel (( LeWidget* )m_itemList[VALKYRIE::BROWSER] )->setCurrValue( brwsr ); checkOption( VALKYRIE::BROWSER ); } - -#endif } -/* RM: allows user to specify which valgrind version to use. the guts - of this fn are essentially the same as the one in config.tests/valgrind.test */ +/*! + Allows user to specify which valgrind version to use. +*/ void ValkyrieOptionsPage::getVgExec() { - cerr << "TODO: ValkyrieOptionsPage::getVgExec()" << endl; -#if 0 // TODO - QString vg_exec_path = - QFileDialog::getOpenFileName( QString::null, "All Files (*)", - this, "fdlg", "Select Valgrind" ); + QString vg_exec = + QFileDialog::getOpenFileName( this, tr("Select Valgrind"), + "./", tr("All Files (*)")); - if ( !vg_exec_path.isEmpty() ) { /* user might have clicked Cancel */ - (( LeWidget* )m_itemList[VALKYRIE::VG_EXEC] )->setCurrValue( vg_exec_path ); + if ( !vg_exec.isEmpty() ) { // user might have clicked Cancel + (( LeWidget* )m_itemList[VALKYRIE::VG_EXEC] )->setCurrValue( vg_exec ); checkOption( VALKYRIE::VG_EXEC ); } - -#endif } -/* RM: allows user to specify which default log dir to use */ +/*! + Allows user to specify which default log dir to use +*/ void ValkyrieOptionsPage::getDfltLogDir() { - cerr << "TODO: ValkyrieOptionsPage::getDfltLogDir()" << endl; -#if 0 // TODO QString currdir = m_itemList[VALKYRIE::DFLT_LOGDIR]->currValue(); + QString dir_logsave = - QFileDialog::getExistingDirectory( currdir, this, - "get default log-save dir", - "Choose a directory", TRUE ); + QFileDialog::getExistingDirectory( this, + tr("Choose Directory"), + currdir, + QFileDialog::ShowDirsOnly ); - if ( !dir_logsave.isEmpty() ) { /* user might have clicked Cancel */ + if ( !dir_logsave.isEmpty() ) { // user might have clicked Cancel (( LeWidget* )m_itemList[VALKYRIE::DFLT_LOGDIR] )->setCurrValue( dir_logsave ); checkOption( VALKYRIE::DFLT_LOGDIR ); } - -#endif } -/* RM: allows user to specify which default log dir to use */ +/*! + Allows user to specify which dir to run valgrind under +*/ void ValkyrieOptionsPage::getWorkingDir() { - cerr << "TODO: ValkyrieOptionsPage::getWorkingDir()" << endl; -#if 0 // TODO QString currdir = m_itemList[VALKYRIE::WORKING_DIR]->currValue(); + QString dir_working = - QFileDialog::getExistingDirectory( currdir, this, - "get default working dir", - "Choose a directory", TRUE ); - - if ( !dir_working.isEmpty() ) { /* user might have clicked Cancel */ + QFileDialog::getExistingDirectory( this, + tr("Choose Directory"), + currdir, + QFileDialog::ShowDirsOnly ); + + if ( !dir_working.isEmpty() ) { // user might have clicked Cancel (( LeWidget* )m_itemList[VALKYRIE::WORKING_DIR] )->setCurrValue( dir_working ); checkOption( VALKYRIE::WORKING_DIR ); } - -#endif } Modified: branches/valkyrie_qt4port/options/vk_options_dialog.cpp =================================================================== --- branches/valkyrie_qt4port/options/vk_options_dialog.cpp 2010-03-11 21:54:47 UTC (rev 491) +++ branches/valkyrie_qt4port/options/vk_options_dialog.cpp 2010-03-12 00:30:43 UTC (rev 492) @@ -25,27 +25,17 @@ #include "help/help_context.h" #include "help/help_urls.h" +#include "mainwindow.h" +#include "objects/vk_objects.h" +#include "options/vk_options_dialog.h" +#include "options/vk_options_page.h" #include "utils/vk_config.h" +#include "utils/vk_messages.h" #include "utils/vk_utils.h" -#if 0 -#include "vk_utils.h" -#include "vk_objects.h" -#include "vk_messages.h" -#endif -#include "objects/vk_objects.h" -#include "options/vk_options_dialog.h" -//#include "options/vk_options_page.h" -#include "options/valkyrie_options_page.h" -#include "mainwindow.h" - -#include <iostream> - - - /***************************************************************************/ /*! Constructs a VkOptionsDialog @@ -86,7 +76,12 @@ QString itemName = obj->objectName(); itemName[0] = itemName[0].toUpper(); item->setText( itemName ); - + + QFont font = item->font(); + font.setBold( true ); + font.setPointSize( font.pointSize() * 1.2 ); + item->setFont( font ); + // insert into stack (takes ownership) optionPages->addWidget( page ); } @@ -268,7 +263,15 @@ */ void VkOptionsDialog::saveToGlobalConfig() { - vkConfig->saveToGlblConfigFile(); + int ok = vkQuery( this, 2, "Overwrite Global Config", + "<p>Are you <b>sure</b> you want to overwrite the global config ?</p>" + "<p><i>Note: Valkyrie will regenerate factory global settings<br>" + "if the global config file is removed:<br>" + "%s</i></p>", qPrintable( vkConfig->vkCfgGlblFilename() ) ); + + if ( ok == MsgBox::vkYes ) { + vkConfig->saveToGlblConfigFile(); + } } Modified: branches/valkyrie_qt4port/options/vk_options_page.cpp =================================================================== --- branches/valkyrie_qt4port/options/vk_options_page.cpp 2010-03-11 21:54:47 UTC (rev 491) +++ branches/valkyrie_qt4port/options/vk_options_page.cpp 2010-03-12 00:30:43 UTC (rev 492) @@ -126,7 +126,7 @@ /*! applyEdits() - Called from OptionsWindow::apply(), accept() + Called from OptionsDialog::apply(), accept() */ bool VkOptionsPage::applyEdits() { Modified: branches/valkyrie_qt4port/utils/vk_config.cpp =================================================================== --- branches/valkyrie_qt4port/utils/vk_config.cpp 2010-03-11 21:54:47 UTC (rev 491) +++ branches/valkyrie_qt4port/utils/vk_config.cpp 2010-03-12 00:30:43 UTC (rev 492) @@ -214,7 +214,7 @@ // save to vkCfgProjectName, if exists if ( !vkCfgProjectFilename.isEmpty() && !vkCfgProjectFilename.isNull() ) { std::cerr << "VkConfig::sync(): in proj => save cfg to proj cfg file (" - << this->vkCfgProjectFilename.toLatin1().constData() << ")" << std::endl; + << qPrintable( vkCfgProjectFilename ) << ")" << std::endl; saveToProjConfigFile(); } } |
From: <sv...@va...> - 2010-03-11 21:55:04
|
Author: cerion Date: 2010-03-11 21:54:47 +0000 (Thu, 11 Mar 2010) New Revision: 491 Log: valgrind & valkyrie option checks + cleanup & comments Modified: branches/valkyrie_qt4port/doc/options_dialog.html branches/valkyrie_qt4port/help/help_handbook.cpp branches/valkyrie_qt4port/help/help_urls.cpp branches/valkyrie_qt4port/help/help_urls.h branches/valkyrie_qt4port/mainwindow.cpp branches/valkyrie_qt4port/objects/helgrind_object.cpp branches/valkyrie_qt4port/objects/helgrind_object.h branches/valkyrie_qt4port/objects/memcheck_object.cpp branches/valkyrie_qt4port/objects/memcheck_object.h branches/valkyrie_qt4port/objects/tool_object.h branches/valkyrie_qt4port/objects/valgrind_object.cpp branches/valkyrie_qt4port/objects/valgrind_object.h branches/valkyrie_qt4port/objects/valkyrie_object.cpp branches/valkyrie_qt4port/objects/valkyrie_object.h branches/valkyrie_qt4port/objects/vk_objects.cpp branches/valkyrie_qt4port/objects/vk_objects.h branches/valkyrie_qt4port/options/memcheck_options_page.cpp branches/valkyrie_qt4port/options/valkyrie_options_page.cpp branches/valkyrie_qt4port/options/vk_option.cpp branches/valkyrie_qt4port/options/vk_option.h branches/valkyrie_qt4port/options/vk_options_page.cpp branches/valkyrie_qt4port/options/vk_options_page.h branches/valkyrie_qt4port/options/vk_parse_cmdline.cpp branches/valkyrie_qt4port/options/widgets/opt_base_widget.cpp branches/valkyrie_qt4port/options/widgets/opt_ck_widget.cpp branches/valkyrie_qt4port/options/widgets/opt_lb_widget.cpp branches/valkyrie_qt4port/toolview/memcheckview.cpp branches/valkyrie_qt4port/utils/vglog.cpp branches/valkyrie_qt4port/utils/vglog.h branches/valkyrie_qt4port/utils/vk_messages.cpp Modified: branches/valkyrie_qt4port/doc/options_dialog.html =================================================================== --- branches/valkyrie_qt4port/doc/options_dialog.html 2010-03-11 19:42:35 UTC (rev 490) +++ branches/valkyrie_qt4port/doc/options_dialog.html 2010-03-11 21:54:47 UTC (rev 491) @@ -127,6 +127,14 @@ Example: "./".<br> Example: "/home/myself/valkyrie_working_dir".</p></dd> <dt> +<a name="project_file"></a><span><b class="command">Project File:</b></span> +</dt> +<dd><p>This option specifies a project file for Valkyrie to use. + All settings needed by Valkyrie will be read from this file, + and all settings that the user changes will be saved to this file. + The file must have the extension ".conf".<br> + Example: "myVkProject.conf".</p></dd> +<dt> <a name="user_font_general"></a><span><b class="command">General Font:</b></span> </dt> <dd><p>This is the general application font. Modified: branches/valkyrie_qt4port/help/help_handbook.cpp =================================================================== --- branches/valkyrie_qt4port/help/help_handbook.cpp 2010-03-11 19:42:35 UTC (rev 490) +++ branches/valkyrie_qt4port/help/help_handbook.cpp 2010-03-11 21:54:47 UTC (rev 491) @@ -19,7 +19,6 @@ ****************************************************************************/ #include "help/help_handbook.h" -//#include "tb_handbook_icons.h" #include "utils/vk_config.h" //#include "vk_messages.h" #include "utils/vk_utils.h" Modified: branches/valkyrie_qt4port/help/help_urls.cpp =================================================================== --- branches/valkyrie_qt4port/help/help_urls.cpp 2010-03-11 19:42:35 UTC (rev 490) +++ branches/valkyrie_qt4port/help/help_urls.cpp 2010-03-11 21:54:47 UTC (rev 491) @@ -52,6 +52,7 @@ const char* browser = "options_dialog.html#browser"; const char* logDir = "options_dialog.html#log_dir"; const char* workingDir = "options_dialog.html#working_dir"; +const char* projectFile = "options_dialog.html#project_file"; const char* userFontGen = "options_dialog.html#user_font_general"; const char* userFontTool = "options_dialog.html#user_font_tool"; const char* palette = "options_dialog.html#palette"; Modified: branches/valkyrie_qt4port/help/help_urls.h =================================================================== --- branches/valkyrie_qt4port/help/help_urls.h 2010-03-11 19:42:35 UTC (rev 490) +++ branches/valkyrie_qt4port/help/help_urls.h 2010-03-11 21:54:47 UTC (rev 491) @@ -52,6 +52,7 @@ extern const char* browser; extern const char* logDir; extern const char* workingDir; +extern const char* projectFile; extern const char* userFontGen; extern const char* userFontTool; extern const char* palette; Modified: branches/valkyrie_qt4port/mainwindow.cpp =================================================================== --- branches/valkyrie_qt4port/mainwindow.cpp 2010-03-11 19:42:35 UTC (rev 490) +++ branches/valkyrie_qt4port/mainwindow.cpp 2010-03-11 21:54:47 UTC (rev 491) @@ -865,7 +865,9 @@ */ void MainWindow::runTool( int procId ) { - cerr << "MainWindow::runTool( " << procId << " )" << endl; + VGTOOL::ToolID tId = toolViewStack->currentToolId(); + cerr << "MainWindow::runTool( tool: " << tId + << ", proc: " << procId << " )" << endl; vk_assert( procId >= 0 ); @@ -876,35 +878,17 @@ return; } - //TODO: checks -#if 0 - // last process might not be done ... - if ( !valkyrie->queryToolDone( m_viewStack->visibleId() ) ) { + if ( !valkyrie->queryToolDone( tId ) ) { cerr << "Warning: Last process not finished" << endl; return; } - /* if running valgrind, make sure there's a valid binary - just 'cos it made it into the config doesn't mean it's valid */ - if ( runState == VkRunState::VALGRIND ) { - int errval = PARSED_OK; - QString bin = vkConfig->rdEntry( "binary", "valkyrie" ); - fileCheck( &errval, bin, false, false, true ); - - if ( errval != PARSED_OK ) { - vkError( this, "Run Tool", "Invalid Binary: Please set a valid binary in Options::Valkyrie." ); - return; - } - } - -#endif - - if ( !valkyrie->runTool( toolViewStack->currentToolId(), procId ) ) { + if ( !valkyrie->runTool( tId, procId ) ) { //TODO: make sure all fail cases have given a message to the user already VK_DEBUG( "Failed to complete execution for toolId (%d), procId (%d)", - toolViewStack->currentToolId(), procId ); + tId, procId ); } } Modified: branches/valkyrie_qt4port/objects/helgrind_object.cpp =================================================================== --- branches/valkyrie_qt4port/objects/helgrind_object.cpp 2010-03-11 19:42:35 UTC (rev 490) +++ branches/valkyrie_qt4port/objects/helgrind_object.cpp 2010-03-11 21:54:47 UTC (rev 491) @@ -77,6 +77,12 @@ } +bool Helgrind::queryDone() +{ + return true; +} + + VkOptionsPage* Helgrind::createVkOptionsPage() { return ( VkOptionsPage* )new HelgrindOptionsPage( this ); Modified: branches/valkyrie_qt4port/objects/helgrind_object.h =================================================================== --- branches/valkyrie_qt4port/objects/helgrind_object.h 2010-03-11 19:42:35 UTC (rev 490) +++ branches/valkyrie_qt4port/objects/helgrind_object.h 2010-03-11 21:54:47 UTC (rev 491) @@ -52,6 +52,8 @@ void setupOptions(); ToolView* createView( QWidget* parent ); + bool queryDone(); + unsigned int maxOptId() { return HELGRIND::NUM_OPTS; } Modified: branches/valkyrie_qt4port/objects/memcheck_object.cpp =================================================================== --- branches/valkyrie_qt4port/objects/memcheck_object.cpp 2010-03-11 19:42:35 UTC (rev 490) +++ branches/valkyrie_qt4port/objects/memcheck_object.cpp 2010-03-11 21:54:47 UTC (rev 491) @@ -305,22 +305,20 @@ bool Memcheck::queryDone() { vk_assert( getToolView() != 0 ); -#if 0 - /* if current process is not yet finished, ask user if they really - want to close */ + // if current process busy, ask user if they really want to close if ( isRunning() ) { int ok = vkQuery( getToolView(), "Process Running", "&Abort;&Cancel", "<p>The current process is not yet finished.</p>" "<p>Do you want to abort it ?</p>" ); - /* Note: process may have finished while waiting for user */ + // Note: process may have finished while waiting for user if ( ok == MsgBox::vkYes ) { - stopProcess(); /* abort */ + stopProcess(); // abort vk_assert( !isRunning() ); } else if ( ok == MsgBox::vkNo ) { - return false; /* continue */ + return false; // continue } } @@ -328,7 +326,6 @@ return false; // not saved: procrastinate. } -#endif return true; } Modified: branches/valkyrie_qt4port/objects/memcheck_object.h =================================================================== --- branches/valkyrie_qt4port/objects/memcheck_object.h 2010-03-11 19:42:35 UTC (rev 490) +++ branches/valkyrie_qt4port/objects/memcheck_object.h 2010-03-11 21:54:47 UTC (rev 491) @@ -69,7 +69,6 @@ // returns the ToolView window (memcheckView) for this tool ToolView* createView( QWidget* parent ); - // called by MainWin::closeToolView() bool queryDone(); bool start( int procId, QStringList vgflags ); Modified: branches/valkyrie_qt4port/objects/tool_object.h =================================================================== --- branches/valkyrie_qt4port/objects/tool_object.h 2010-03-11 19:42:35 UTC (rev 490) +++ branches/valkyrie_qt4port/objects/tool_object.h 2010-03-11 21:54:47 UTC (rev 491) @@ -56,10 +56,9 @@ // creates and init's this tool's ToolView window virtual ToolView* createView( QWidget* parent ) = 0; + virtual bool queryDone() = 0; /* - // called by MainWin::closeToolView() - virtual bool queryDone() = 0; - virtual void deleteView(); + virtual void deleteView(); */ ToolView* view(); Modified: branches/valkyrie_qt4port/objects/valgrind_object.cpp =================================================================== --- branches/valkyrie_qt4port/objects/valgrind_object.cpp 2010-03-11 19:42:35 UTC (rev 490) +++ branches/valkyrie_qt4port/objects/valgrind_object.cpp 2010-03-11 21:54:47 UTC (rev 491) @@ -525,7 +525,7 @@ { // exception: multiple suppressions are allowed if ( optid == VALGRIND::SUPPS_SEL ) { - //TODO: concat, don't overwrite + //TODO: concat supps, don't overwrite // vkConfig->value( vk_opt->configKey() ); // argval = cfg_argval + argval } @@ -540,22 +540,19 @@ */ int Valgrind::checkOptArg( int optid, QString& argval ) { - optid = optid; - argval = argval; - // vk_assert( optid >= 0 && optid < NUM_OPTS ); + vk_assert( optid >= 0 && optid < VALGRIND::NUM_OPTS ); + VkOption* opt = getOption( optid ); int errval = PARSED_OK; + + QChar sep = vkConfig->vkSepChar; -#if 0 - Option* opt = findOption( optid ); - QString sep = vkConfig->sepChar(); + switch ( (VALGRIND::vgOptId)optid ) { - switch (( Valgrind::vgOpts )optid ) { - case VALGRIND::TOOL: - /* Note: gui option disabled, so only reaches here from cmdline */ + // Note: gui option disabled, so only reaches here from cmdline errval = PERROR_BADOPT; - vkPrintErr( "Option disabled '--%s'", opt->m_longFlag.latin1() ); + vkPrintErr( "Option disabled '--%s'", qPrintable( opt->longFlag ) ); vkPrintErr( " - Valkyrie currently only supports Memcheck." ); break; @@ -578,27 +575,31 @@ case VALGRIND::ERROR_LIMIT: case VALGRIND::DB_COMMAND: case VALGRIND::DB_ATTACH: - /* Note: gui option disabled, so only reaches here from cmdline */ + // Note: gui option disabled, so only reaches here from cmdline errval = PERROR_BADOPT; - vkPrintErr( "Option disabled '--%s'", opt->m_longFlag.latin1() ); + vkPrintErr( "Option disabled '--%s'", qPrintable( opt->longFlag ) ); vkPrintErr( " - Valgrind presets these options for XML output." ); vkPrintErr( " - See valgrind/docs/internals/xml_output.txt." ); break; case VALGRIND::XML_COMMENT: - /* don't wan't xml in comment: escape '<','&',etc */ + // don't wan't xml in comment: escape '<','&',etc argval = escapeEntities( argval ); break; - case VALGRIND::SUPPS_DIRS: { /* not popt: only reaches here from gui */ - /* check all entries are valid dirs */ - QStringList dirs = QStringList::split( sep, argval ); //, QString::SkipEmptyParts + case VALGRIND::SUPPS_DIRS: { + // not popt: only reaches here from gui + vk_assert( opt->argType == VkOPT::NOT_POPT ); + + // check all entries are valid dirs, + // and update dirs to absolute paths + QStringList dirs = argval.split( sep, QString::SkipEmptyParts ); + QStringList::iterator it = dirs.begin(); - for ( ; it != dirs.end(); ++it ) { - /* check dirs ok */ - *it = dirCheck( &errval, *it, true, false ); - + // check dir ok and has at least RX permissions + *it = dirCheck( &errval, *it, true, false, true ); + if ( errval != PARSED_OK ) { break; } @@ -608,23 +609,26 @@ } break; - case VALGRIND::SUPPS_AVAIL: /* not popt: only reaches here from gui */ - case VALGRIND::SUPPS_SEL: { /* is popt: --suppressions */ - QStringList files = QStringList::split( sep, argval ); //, QString::SkipEmptyParts + case VALGRIND::SUPPS_AVAIL: { + // not popt: only reaches here from gui + vk_assert( opt->argType == VkOPT::NOT_POPT ); + } // fall through to next case. + case VALGRIND::SUPPS_SEL: { + QStringList files = argval.split( sep, QString::SkipEmptyParts ); + QStringList::iterator it = files.begin(); - for ( ; it != files.end(); ++it ) { - /* check files ok & readable */ - *it = fileCheck( &errval, *it, true, false ); + // check file ok and has at least R permissions + *it = fileCheck( &errval, *it, true ); if ( errval != PARSED_OK ) { break; } - /* TODO: do we care if it doesn't end in .supp? - - breaks the suppression widgets a little, as only lists those ending in .supp ... */ + // TODO: do we care if it doesn't end in .supp? + // - breaks the suppression widgets a little, as only lists those ending in .supp ... - /* TODO: ? check valid suppression files */ + // TODO: ? check valid suppression files } argval = files.join( sep ); @@ -696,34 +700,30 @@ case VALGRIND::KERN_VAR: break; - /* logging options */ - /* all tools use an internal logging option, - all logging options are therefore ignored */ + // Logging options: + // All tool objects use a logging option to generate/read Vg output. + // All logging options are therefore ignored. case VALGRIND::LOG_FILE: case VALGRIND::LOG_FD: case VALGRIND::LOG_SOCKET: - /* Note: gui options disabled, so only reaches here from cmdline */ + // Note: gui options disabled, so only reaches here from cmdline errval = PERROR_BADOPT; - vkPrintErr( "Option disabled '--%s'", opt->m_longFlag.latin1() ); + vkPrintErr( "Option disabled '--%s'", qPrintable( opt->longFlag ) ); vkPrintErr( " - Valkyrie sets its own logging options to gather data from Valgrind." ); break; - - /* Not yet implemented */ + // Not yet implemented case VALGRIND::INPUT_FD: - /* Note: gui option disabled, so only reaches here from cmdline */ + // Note: gui option disabled, so only reaches here from cmdline errval = PERROR_BADOPT; // vkPrintErr("Option disabled '--%s'", opt->m_longFlag.latin1()); // vkPrintErr(" - Not yet implemented."); break; default: - assert( true ); - // vk_assert_never_reached(); + vk_assert_never_reached(); } -#endif - return errval; } Modified: branches/valkyrie_qt4port/objects/valgrind_object.h =================================================================== --- branches/valkyrie_qt4port/objects/valgrind_object.h 2010-03-11 19:42:35 UTC (rev 490) +++ branches/valkyrie_qt4port/objects/valgrind_object.h 2010-03-11 21:54:47 UTC (rev 491) @@ -33,7 +33,7 @@ */ enum vgOptId { TOOL, // --tool - /* common options relevant to all tools */ + // common options relevant to all tools VERBOSITY, // --verbosity TRACE_CH, // --trace-children SILENT_CH, // --child-silent-after-fork @@ -43,27 +43,27 @@ LOG_FILE, // --log-file LOG_SOCKET, // --log-socket - /* uncommon options relevant to all tools */ + // uncommon options relevant to all tools RUN_LIBC, // --run-libc-freeres SIM_HINTS, // --sim-hints KERN_VAR, // --kernel-variant EM_WARNS, // --show-emwarns SMC_CHECK, // --smc-check - /* options relevant to error-reporting tools */ + // options relevant to error-reporting tools XML_OUTPUT, // --xml - XML_COMMENT, // -- xml-user-comment + XML_COMMENT, // --xml-user-comment DEMANGLE, // --demangle NUM_CALLERS, // --num-callers ERROR_LIMIT, // --error-limit SHOW_BELOW, // --show-below-main - /* suppressions hackery */ + // suppressions hackery SUPPS_DIRS, // list of suppfile dirs - feeds SUPPS_AVAIL list SUPPS_AVAIL, // fake opt: dyname list of available supp files SUPPS_SEL, // the currently selected suppression(s) - /* misc */ + // misc GEN_SUPP, // --gen-suppressions DB_ATTACH, // --db-attach DB_COMMAND, // --db-command @@ -96,8 +96,9 @@ public: // ToolObject access ToolObjList getToolObjList(); + ToolObject* getToolObj( VGTOOL::ToolID tid ); +//TODO: needed? // int getToolObjId( const QString& name ); - ToolObject* getToolObj( VGTOOL::ToolID tid ); // ToolObject* getToolObj( const QString& name ); private: Modified: branches/valkyrie_qt4port/objects/valkyrie_object.cpp =================================================================== --- branches/valkyrie_qt4port/objects/valkyrie_object.cpp 2010-03-11 19:42:35 UTC (rev 490) +++ branches/valkyrie_qt4port/objects/valkyrie_object.cpp 2010-03-11 21:54:47 UTC (rev 491) @@ -77,42 +77,42 @@ "", "", "", - "show this help message and exit", + "show this message", urlNone, VkOPT::ARG_NONE, VkOPT::WDG_NONE ); options.addOpt( - VALKYRIE::OPT_VERSION, + VALKYRIE::VGHELP, this->objectName(), - "version", - 'v', + "valgrind-opts", + 'V', "", "", - PACKAGE_VERSION, "", - "display version information and exit", + "", + "show this message, plus valgrind options", urlNone, VkOPT::ARG_NONE, VkOPT::WDG_NONE ); options.addOpt( - VALKYRIE::VGHELP, + VALKYRIE::OPT_VERSION, this->objectName(), - "valgrind-opts", - 'V', + "version", + 'v', "", "", "", "", - "show valgrind options too, and exit", + "show version", urlNone, VkOPT::ARG_NONE, VkOPT::WDG_NONE ); - + options.addOpt( VALKYRIE::TOOLTIP, this->objectName(), @@ -248,21 +248,23 @@ VkOPT::WDG_LEDIT ); + QString projfile = QString("<project.") + VK_CFG_EXT + ">"; options.addOpt( - VALKYRIE::DFLT_LOGDIR, + VALKYRIE::PROJ_FILE, this->objectName(), - "default-logdir", - '\0', + "project-file", + 'f', + projfile, "", "", - VkConfig::vkTmpDir(), - "Tmp Log Dir:", "", - urlValkyrie::logDir, - VkOPT::NOT_POPT, + "use " + projfile + " for project settings", + urlValkyrie::projectFile, + VkOPT::ARG_STRING, VkOPT::WDG_LEDIT ); + options.addOpt( VALKYRIE::WORKING_DIR, this->objectName(), @@ -277,25 +279,9 @@ VkOPT::ARG_STRING, VkOPT::WDG_LEDIT ); - + + // path to valgrind executable (maybe found by configure) options.addOpt( - VALKYRIE::PROJ_FILE, - this->objectName(), - "proj-file", - 'f', - "<project.vk>", - "", - "", - "", - "use settings from project file", - urlValkyrie::workingDir, - VkOPT::ARG_STRING, - VkOPT::WDG_LEDIT - ); - - - /* path to valgrind executable (maybe found by configure) */ - options.addOpt( VALKYRIE::VG_EXEC, this->objectName(), "vg-exec", @@ -355,8 +341,23 @@ VkOPT::WDG_NONE ); + options.addOpt( + VALKYRIE::DFLT_LOGDIR, + this->objectName(), + "default-logdir", + '\0', + "", + "", + VkConfig::vkTmpDir(), + "Tmp Log Dir:", + "", + urlValkyrie::logDir, + VkOPT::NOT_POPT, + VkOPT::WDG_LEDIT + ); + + - // Internal configuration options.addOpt( VALKYRIE::MW_SIZE, this->objectName(), "mainwindow_size", @@ -524,21 +525,18 @@ /*! Check \a argval for the option given by \a optid, updating if necessary. */ -int Valkyrie::checkOptArg( int optid, QString& /*argval*/ ) +int Valkyrie::checkOptArg( int optid, QString& argval ) { vk_assert( optid >= 0 && optid < VALKYRIE::NUM_OPTS ); -#if 0 // TODO VkOption* opt = getOption( optid ); - int errval = PARSED_OK; - // Option* opt = findOption( optid ); switch ( optid ) { - - /* these options are _only_ set via the gui, and are either (a) - limited to a set of available values, or (b) have already been - checked, so no need to re-check them. */ + + // the following options are _only_ set via the gui, and are either + // a) limited to a set of available values, or + // b) have already been checked, so no need to re-check them. case VALKYRIE::TOOLTIP: case VALKYRIE::PALETTE: case VALKYRIE::ICONTXT: @@ -546,134 +544,100 @@ case VALKYRIE::FNT_GEN_USR: case VALKYRIE::FNT_TOOL_USR: case VALKYRIE::SRC_LINES: - case VALKYRIE::BROWSER: - return errval; - break; + case VALKYRIE::BROWSER: { + vk_assert( opt->argType == VkOPT::NOT_POPT ); + return errval; + } break; + // dir options: check for rwx permissions case VALKYRIE::DFLT_LOGDIR: case VALKYRIE::WORKING_DIR: { - // see if we have an dir with rx permissions - ( void ) dirCheck( &errval, argval, true, true ); - } - break; + ( void ) dirCheck( &errval, argval, true, true, true ); + } break; case VALKYRIE::SRC_EDITOR: { - QString ed_file = QStringList::split( " ", argval ).first(); //, QString::SkipEmptyParts - QString ed = binaryCheck( &errval, ed_file ); - argval.replace( ed_file, ed ); - } - break; - -#if 0 //TODO: return ok, but give warning. - - // if no "%n", give warning - if ( argval.indexOf( "%n" ) == -1 ) { - QFileInfo fi( argval.split( " ", QString::SkipEmptyParts ).first() ); + // source editor executable: check for at least X permissions + QString ed_file = argval.split( " " ).first(); + QString ed = fileCheck( &errval, ed_file, false, false, true ); + argval.replace( ed_file, ed ); + argval = argval.simplified(); + } break; - if ( !fi.fileName().startsWith( "emacs" ) && !fi.fileName().startsWith( "nedit" ) ) { - vkInfo( this, "Unknown Source Editor", - "If possible, set an editor flag to allow the " - "editor to be opened at a target line-number, " - "where %%n will be replaced with the line-number." ); - } - } - -#endif - case VALKYRIE::PROJ_FILE: { -#if 0 // TODO: review this + // check file exists and has RW perms + argval = fileCheck( &errval, argval, true, true ); + if ( errval != PARSED_OK ) { + return errval; + } - // TODO: check filname format: ( dir + "/" + proj_name + "." + VK_CFG_EXT ) - - // TODO: check dir exists & perms ok - - // check owner read/write perms ok - if ( QFile::exists( proj_filename ) ) { - QFile::Permissions perms = QFile::permissions( proj_filename ); - - if (( perms & QFile::WriteOwner ) != QFile::WriteOwner || - ( perms & QFile::ReadOwner ) != QFile::ReadOwner ) { - // TODO: vkError perms + // check filename format: ".*\.VK_CFG_EXT$" + if ( !argval.contains( QRegExp( QString(".*\\.") + VK_CFG_EXT + "$" ) ) ) { + return PERROR_BADFILENAME; } - } - -#endif - } - break; + + } break; case VALKYRIE::VG_EXEC: { - // see if we have an executable with rx permissions - argval = binaryCheck( &errval, argval ); - - if ( errval != PARSED_OK ) { - return errval; - } - - // check the version - QString cmd = argval + " --version 2>&1"; - FILE* fp; - char line[50]; - fp = popen(( const char* )cmd, "r" ); - - if ( !fp ) { - pclose( fp ); - return PERROR_BADFILE; - } - - fgets( line, sizeof( line ), fp ); - - int result = pclose( fp ); - - if ( !WIFEXITED( result ) ) { // cmd exit error? - return PERROR_BADFILE; - } - - QString vg_version = QString( line ).simplifyWhiteSpace(); - - if ( !vg_version.startsWith( "valgrind" ) ) { - return PERROR_BADFILE; - } - - // compare with minimum req'd version - int versionVg = strVersion2hex( vg_version ); - int versionVgReqd = strVersion2hex( pchVersionVgMin ); - - if ( versionVg == -1 || versionVgReqd == -1 ) { - return PERROR_BADFILE; - } - - if ( versionVg < versionVgReqd ) { - return PERROR_BADVERSION; - } - - // if we get here, we're fine. - } - break; - + // see if we have a valgrind exec with at least X permissions: + argval = fileCheck( &errval, argval, false, false, true ); + if ( errval != PARSED_OK ) { + return errval; + } + + // check the version + QString cmd_qstr = argval + " --version 2>&1"; + const char* cmd = cmd_qstr.toLatin1().constData(); + FILE* fp = popen( cmd, "r" ); + if ( !fp ) { + pclose( fp ); + return PERROR_BADFILE; + } + + char line[50]; + if ( fgets( line, sizeof( line ), fp ) == NULL ) { + return PERROR_BADFILE; + } + + if ( pclose( fp ) == -1 ) { + return PERROR_BADFILE; + } + + // we have a string from the executable: is it what we hope? + QString vg_version = QString( line ).simplified(); + + if ( !vg_version.startsWith( "valgrind" ) ) { + return PERROR_BADFILE; + } + + // compare with minimum req'd version + int versionVg = strVersion2hex( vg_version ); + int versionVgReqd = strVersion2hex( pchVersionVgMin ); + + if ( versionVg == -1 || versionVgReqd == -1 ) { + return PERROR_BADFILE; + } + + if ( versionVg < versionVgReqd ) { + return PERROR_BADVERSION; + } + + // if we get here, we're fine. + } break; + case VALKYRIE::VIEW_LOG: - argval = fileCheck( &errval, argval, true, false ); - - if ( errval == PARSED_OK ) { - m_startRunState = VkRunState::TOOL1; - } - - break; - + if ( !argval.isEmpty() ) { + // see if we have a logfile with at least R permissions: + argval = fileCheck( &errval, argval, true ); + } break; + case VALKYRIE::BINARY: - if ( !argval.isEmpty() ) { - argval = binaryCheck( &errval, argval ); - } - - if ( errval == PARSED_OK ) { - m_startRunState = VkRunState::VALGRIND; - } - - break; - - + // see if we have a binary with at least X permissions: + argval = fileCheck( &errval, argval, false, false, true ); + } break; + case VALKYRIE::BIN_FLAGS: - // Can't test this. + // Can't (easily) test this. break; // ignore these opts @@ -687,8 +651,6 @@ } return errval; -#endif - return 0; } @@ -781,6 +743,19 @@ /*! + find out if tool is running or not. +*/ +bool Valkyrie::queryToolDone( VGTOOL::ToolID tId ) +{ + vk_assert( tId != VGTOOL::ID_NULL ); + ToolObject* tool = valgrind()->getToolObj( tId ); + vk_assert( tool != 0 ); + + return tool->queryDone(); +} + + +/*! Run the tool with given process id. */ bool Valkyrie::runTool( VGTOOL::ToolID tId, int procId ) Modified: branches/valkyrie_qt4port/objects/valkyrie_object.h =================================================================== --- branches/valkyrie_qt4port/objects/valkyrie_object.h 2010-03-11 19:42:35 UTC (rev 490) +++ branches/valkyrie_qt4port/objects/valkyrie_object.h 2010-03-11 21:54:47 UTC (rev 491) @@ -30,33 +30,48 @@ { /*! enum identification of all options for this object + Note: command-line output order depends on this order */ enum vkOptId { - HELP, - OPT_VERSION, - VGHELP, - TOOLTIP, - PALETTE, - ICONTXT, - FNT_GEN_SYS, - FNT_GEN_USR, - FNT_TOOL_USR, - SRC_EDITOR, - SRC_LINES, - BROWSER, - DFLT_LOGDIR, - WORKING_DIR, - PROJ_FILE, - VG_EXEC, // path to valgrind executable - BINARY, // user-binary to be valgrindised - BIN_FLAGS, // flags for user-binary - VIEW_LOG, - MW_SIZE, - MW_POS, - HB_HIST, - HB_BKMK, - HB_MXHIST, - HB_MXBKMK, + + // basic command-line options + HELP, // show cmdline help + VGHELP, // show extended cmdline help + OPT_VERSION, // show version + + // look 'n feel options + TOOLTIP, // show tooltips + PALETTE, // use valkyrie's palette + ICONTXT, // show toolbar text labels + FNT_GEN_SYS, // use system default or user-specific general-font + FNT_GEN_USR, // choose user-specific general-font + FNT_TOOL_USR, // choose font for tools + + // general options + SRC_EDITOR, // editor to use to edit source + SRC_LINES, // extra lines shown above/below target + BROWSER, // browser for external links + PROJ_FILE, // project file for valkyrie settings + + // valgrind related flags + WORKING_DIR, // where to run valgrind + VG_EXEC, // path to valgrind executable + BINARY, // user-binary to be valgrindised + BIN_FLAGS, // flags for user-binary + VIEW_LOG, // parse and view a valgrind logfile + DFLT_LOGDIR, // where to put our temporary logs + + // internal-config: mainwindow + MW_SIZE, // mainwindow size + MW_POS, // mainwindow position + + // internal-config: handbook + HB_HIST, // handbook history (urls) + HB_BKMK, // handbook bookmarks (urls) + HB_MXHIST, // handbook max num history items + HB_MXBKMK, // handbook max num bookmarks + + // internal-config: colours COL_BKGD, COL_BASE, COL_DKGR, @@ -64,6 +79,7 @@ COL_HILT, COL_NULL, COL_TEXT, + NUM_OPTS }; @@ -83,9 +99,7 @@ bool runTool( VGTOOL::ToolID tId, int procId ); void stopTool( VGTOOL::ToolID tId ); -#if 0 // TODO - bool queryToolDone( int tId ); -#endif + bool queryToolDone( VGTOOL::ToolID tId ); unsigned int maxOptId() { return VALKYRIE::NUM_OPTS; @@ -107,10 +121,12 @@ virtual void setConfigDefaults(); VkOption* findOption( QString& optKey ); +//TODO: needed? // VkOption* findOption( QString& optGrp, int optid ); // list of all objects const VkObjectList vkObjList(); +//TODO: needed? // VkObject* vkObject( int objId ); private: Modified: branches/valkyrie_qt4port/objects/vk_objects.cpp =================================================================== --- branches/valkyrie_qt4port/objects/vk_objects.cpp 2010-03-11 19:42:35 UTC (rev 490) +++ branches/valkyrie_qt4port/objects/vk_objects.cpp 2010-03-11 21:54:47 UTC (rev 491) @@ -78,7 +78,7 @@ /*! - Setup factory defaults + Setup factory defaults for this object */ void VkObject::setConfigDefaults() { Modified: branches/valkyrie_qt4port/objects/vk_objects.h =================================================================== --- branches/valkyrie_qt4port/objects/vk_objects.h 2010-03-11 19:42:35 UTC (rev 490) +++ branches/valkyrie_qt4port/objects/vk_objects.h 2010-03-11 21:54:47 UTC (rev 491) @@ -53,7 +53,6 @@ virtual void updateConfig( int optid, QString& argval ); - /*! Set default config entries for thies object */ virtual void setConfigDefaults(); virtual VkOptionsPage* createVkOptionsPage() = 0; @@ -67,13 +66,6 @@ }; - -//TODO: cleanup -// VkOption* opt = options.getOption( "include" ); -// cerr << "url: " << opt->urlAddress.toLatin1().data() << endl; - - - #endif // __VK_OBJECT_H Modified: branches/valkyrie_qt4port/options/memcheck_options_page.cpp =================================================================== --- branches/valkyrie_qt4port/options/memcheck_options_page.cpp 2010-03-11 19:42:35 UTC (rev 490) +++ branches/valkyrie_qt4port/options/memcheck_options_page.cpp 2010-03-11 21:54:47 UTC (rev 491) @@ -23,17 +23,10 @@ #include "help/help_context.h" #include "help/help_urls.h" #include "objects/memcheck_object.h" -//#include "utils/vk_messages.h" -//#include "utils/vk_utils.h" - - -#include "help/help_context.h" -#include "help/help_urls.h" //#include "utils/vk_config.h" //#include "utils/vk_messages.h" #include "utils/vk_utils.h" -//#include "objects/memcheck_object.h" #include "options/widgets/opt_base_widget.h" //#include "options/widgets/opt_le_widget.h" //#include "options/widgets/opt_lb_widget.h" Modified: branches/valkyrie_qt4port/options/valkyrie_options_page.cpp =================================================================== --- branches/valkyrie_qt4port/options/valkyrie_options_page.cpp 2010-03-11 19:42:35 UTC (rev 490) +++ branches/valkyrie_qt4port/options/valkyrie_options_page.cpp 2010-03-11 21:54:47 UTC (rev 491) @@ -181,6 +181,16 @@ grid->addWidget( fontToolLedit->widget(), i++, 1, 1, 3 ); vk_assert( m_itemList.count() <= VALKYRIE::NUM_OPTS ); + + + // ------------------------------------------------------------ + // tooltips + QString tip_editor = tr( "Tip: \"%n\" will be replaced with " + "the source code line number.<br>" + "Set the appropriate editor flag to support " + "opening the source at this line." ); + editLedit->button()->setToolTip( tip_editor ); + editLedit->widget()->setToolTip( tip_editor ); } Modified: branches/valkyrie_qt4port/options/vk_option.cpp =================================================================== --- branches/valkyrie_qt4port/options/vk_option.cpp 2010-03-11 19:42:35 UTC (rev 490) +++ branches/valkyrie_qt4port/options/vk_option.cpp 2010-03-11 21:54:47 UTC (rev 491) @@ -72,6 +72,8 @@ return "Invalid directory"; case PERROR_BADFILE: return "Invalid file"; + case PERROR_BADFILENAME: + return "Invalid filename"; case PERROR_BADNUMFILES: return "Invalid number of files ( max == 10 )"; case PERROR_BADFILERD: @@ -162,8 +164,10 @@ */ VkOption* VkOptionHash::getOption( int optid ) { - // TODO: check for non-existent options - + if ( !optionHash.contains( optid ) ) { + VK_DEBUG( "Warning: optid (%d) not found in options.", optid ); + return NULL; + } return optionHash.value( optid ); } Modified: branches/valkyrie_qt4port/options/vk_option.h =================================================================== --- branches/valkyrie_qt4port/options/vk_option.h 2010-03-11 19:42:35 UTC (rev 490) +++ branches/valkyrie_qt4port/options/vk_option.h 2010-03-11 21:54:47 UTC (rev 491) @@ -39,8 +39,8 @@ { /*! Argument type: tells us how to parse and test the argument value. - NO_CMDLINE: ignore this option in cmdline option parsing - ARG_* : arg type for this option (ARG_NONE = no args) + NOT_POPT: ignore this option in cmdline option parsing + ARG_* : arg type for this option (ARG_NONE = no args) */ enum ArgType { NOT_POPT = -1, @@ -69,29 +69,30 @@ // ============================================================ // Error return values -#define PARSED_OK 0 /* value passed the parsing checks */ -#define PERROR_DEFAULT - 1 /* don't print parseError() */ -#define PERROR_NODASH - 2 /* don't use '=' for short opts */ -#define PERROR_NOARG -10 /* missing argument */ -#define PERROR_BADOPT -11 /* unknown option */ -#define PERROR_BADARG -12 /* bad argument given */ -#define PERROR_BADQUOTE -15 /* error in paramter quoting */ -#define PERROR_BADNUMBER -17 /* invalid numeric value */ -#define PERROR_OUTOFRANGE -18 /* outside min|max values */ -#define PERROR_OVERFLOW -19 /* number too large or too small */ -#define PERROR_BADOPERATION -20 /* mutually exclusive logical operations requested */ -#define PERROR_NULLARG -21 /* opt->arg should not be NULL */ -#define PERROR_MALLOC -22 /* memory allocation failed */ -#define PERROR_BADDIR -23 /* dir does not exist */ -#define PERROR_BADFILE -24 /* file does not exist */ -#define PERROR_BADNUMFILES -25 /* invalid no. of files */ -#define PERROR_BADFILERD -26 /* user hasn't got rd permission */ -#define PERROR_BADFILEWR -27 /* user hasn't got wr permission */ -#define PERROR_BADEXEC -28 /* user hasn't got exec permission */ -#define PERROR_DB_CONFLICT -29 /* db-attach -v- trace-children */ -#define PERROR_DB_OUTPUT -30 /* using db-attach, but not sending output to stderr */ -#define PERROR_POWER_OF_TWO -31 /* number not a power of two */ -#define PERROR_BADVERSION -32 /* bad program version */ +#define PARSED_OK 0 // value passed the parsing checks +#define PERROR_DEFAULT - 1 // don't print parseError() +#define PERROR_NODASH - 2 // don't use '=' for short opts +#define PERROR_NOARG -10 // missing argument +#define PERROR_BADOPT -11 // unknown option +#define PERROR_BADARG -12 // bad argument given +#define PERROR_BADQUOTE -15 // error in paramter quoting +#define PERROR_BADNUMBER -17 // invalid numeric value +#define PERROR_OUTOFRANGE -18 // outside min|max values +#define PERROR_OVERFLOW -19 // number too large or too small +#define PERROR_BADOPERATION -20 // mutually exclusive logical operations requested +#define PERROR_NULLARG -21 // opt->arg should not be NULL +#define PERROR_MALLOC -22 // memory allocation failed +#define PERROR_BADDIR -23 // dir does not exist +#define PERROR_BADFILE -24 // file does not exist +#define PERROR_BADFILENAME -25 // filename un-good +#define PERROR_BADNUMFILES -26 // invalid no. of files +#define PERROR_BADFILERD -27 // user hasn't got rd permission +#define PERROR_BADFILEWR -28 // user hasn't got wr permission +#define PERROR_BADEXEC -29 // user hasn't got exec permission +#define PERROR_DB_CONFLICT -30 // db-attach -v- trace-children +#define PERROR_DB_OUTPUT -31 // using db-attach, but not sending output to stderr +#define PERROR_POWER_OF_TWO -32 // number not a power of two +#define PERROR_BADVERSION -33 // bad program version const char* parseErrString( const int error ); Modified: branches/valkyrie_qt4port/options/vk_options_page.cpp =================================================================== --- branches/valkyrie_qt4port/options/vk_options_page.cpp 2010-03-11 19:42:35 UTC (rev 490) +++ branches/valkyrie_qt4port/options/vk_options_page.cpp 2010-03-11 21:54:47 UTC (rev 491) @@ -20,14 +20,6 @@ ** ****************************************************************************/ -#include "utils/vk_utils.h" - -#if 0 -#include "vk_utils.h" -#include "vk_config.h" -#include "vk_messages.h" -#endif - #include "options/vk_options_page.h" #include "options/widgets/opt_base_widget.h" #include "options/widgets/opt_cb_widget.h" @@ -37,6 +29,7 @@ #include "options/widgets/opt_sp_widget.h" #include "utils/vk_config.h" #include "utils/vk_messages.h" +#include "utils/vk_utils.h" #include <QList> @@ -75,15 +68,9 @@ } -#if 0// TODO -int VkOptionsPage::optId() -{ - vk_assert( m_vkObj != 0 ); - return m_vkObj->objId(); -} -#endif - - +/*! + Provides a default seperator UI element +*/ QFrame* VkOptionsPage::sep( QWidget* parent ) { QFrame* line = new QFrame( parent ); @@ -190,8 +177,6 @@ { vk_assert( optId < m_vkObj->maxOptId() ); - //TODO: allow for warnings: vkobj should give string back for message - QString argval = m_itemList[optId]->currValue(); // Note: argval may be altered by checkOptArg() int errval = m_vkObj->checkOptArg( optId, argval ); Modified: branches/valkyrie_qt4port/options/vk_options_page.h =================================================================== --- branches/valkyrie_qt4port/options/vk_options_page.h 2010-03-11 19:42:35 UTC (rev 490) +++ branches/valkyrie_qt4port/options/vk_options_page.h 2010-03-11 21:54:47 UTC (rev 491) @@ -68,15 +68,6 @@ return m_mod; } -#if 0 // TODO - // init page on open - virtual void init() { - /*do nothing*/ - } - - int optId(); -#endif - signals: void modified(); void apply(); Modified: branches/valkyrie_qt4port/options/vk_parse_cmdline.cpp =================================================================== --- branches/valkyrie_qt4port/options/vk_parse_cmdline.cpp 2010-03-11 19:42:35 UTC (rev 490) +++ branches/valkyrie_qt4port/options/vk_parse_cmdline.cpp 2010-03-11 21:54:47 UTC (rev 491) @@ -55,8 +55,6 @@ VkName.toLatin1().constData(), vkConfig->vkCopyright.toLatin1().constData(), vkConfig->vkAuthor.toLatin1().constData() ); - //TODO - // printf("Valgrind is copyright %s\n\n", vkConfig->vgCopyright.toLatin1().constData() ); break; default: @@ -195,24 +193,6 @@ vkPoptOption allOpts[num_objs+1/*null end*/]; getAllOptions( objList, allOpts ); -#if 0 // TODO: rm when done debugging - cerr << "PRINTOUT" << endl; - - for ( int i = 0; i < num_objs; i++ ) { - vkPoptOption* opt = &allOpts[i]; - cerr << "TABLE: " << opt->optGrp << endl; - - opt = opt->arg; - - while ( opt && opt->optId != -1 ) { - cerr << opt->optGrp << ", " << opt->optId << ", " << opt->longFlag << endl; - opt++; - } - } - -#endif - - // -------------------------------------------------- // context for parsing cmd-line opts vkPoptContext optCon = Modified: branches/valkyrie_qt4port/options/widgets/opt_base_widget.cpp =================================================================== --- branches/valkyrie_qt4port/options/widgets/opt_base_widget.cpp 2010-03-11 19:42:35 UTC (rev 490) +++ branches/valkyrie_qt4port/options/widgets/opt_base_widget.cpp 2010-03-11 21:54:47 UTC (rev 491) @@ -21,9 +21,9 @@ #include "options/widgets/opt_base_widget.h" #include "options/vk_option.h" // for listbox fileCheck() #include "utils/vk_config.h" +#include "utils/vk_utils.h" #if 0 -#include "vk_utils.h" #include "vk_messages.h" #endif @@ -108,7 +108,7 @@ combos, spinboxes and lineedits have their own way of doings things */ QHBoxLayout* OptionWidget::hlayout() { - //vk_assert( m_wLabel != 0 ); + vk_assert( m_wLabel != 0 ); m_hBox = new QHBoxLayout(); m_hBox->addWidget( m_wLabel ); @@ -120,7 +120,7 @@ QVBoxLayout* OptionWidget::vlayout() { - // vk_assert( m_wLabel != 0 ); + vk_assert( m_wLabel != 0 ); m_vBox = new QVBoxLayout(); m_vBox->addWidget( m_wLabel ); Modified: branches/valkyrie_qt4port/options/widgets/opt_ck_widget.cpp =================================================================== --- branches/valkyrie_qt4port/options/widgets/opt_ck_widget.cpp 2010-03-11 19:42:35 UTC (rev 490) +++ branches/valkyrie_qt4port/options/widgets/opt_ck_widget.cpp 2010-03-11 21:54:47 UTC (rev 491) @@ -62,7 +62,7 @@ m_currentValue = ( on ) ? m_opt->possValues[0] : m_opt->possValues[1]; bool edited = m_currentValue != m_initialValue; emit valueChanged( edited, this ); - /* for dis/enabling associated widgets */ + // for dis/enabling associated widgets emit changed( on ); emit clicked( m_opt->optid ); } Modified: branches/valkyrie_qt4port/options/widgets/opt_lb_widget.cpp =================================================================== --- branches/valkyrie_qt4port/options/widgets/opt_lb_widget.cpp 2010-03-11 19:42:35 UTC (rev 490) +++ branches/valkyrie_qt4port/options/widgets/opt_lb_widget.cpp 2010-03-11 21:54:47 UTC (rev 491) @@ -170,7 +170,7 @@ { switch ( m_mode ) { case LbWidget::LB_SUPPAVAIL: - /* Never test this widget's editedness - holds a dynamic list */ + // Never test this widget's editedness - holds a dynamic list break; case LbWidget::LB_SUPPDIRS: @@ -232,7 +232,7 @@ case LbWidget::LB_SUPPAVAIL: emit itemSelected( lb_item->text() ); - /* Not removing item - list recalculated in valgrind opts page */ + // Not removing item - list recalculated in valgrind opts page break; default: @@ -268,12 +268,13 @@ { vk_assert( m_mode == LbWidget::LB_SUPPSEL ); - if ( !lb_item ) { /* m_lbox is empty, so nothing to do */ + if ( !lb_item ) { // m_lbox is empty, so nothing to do return; } QAction deselectAct( "Deselect File", this ); - + +//TODO: check this if ( !( lb_item->isSelected() ) ) { // || lb_item->isCurrent()) ) { deselectAct.setEnabled( false ); } Modified: branches/valkyrie_qt4port/toolview/memcheckview.cpp =================================================================== --- branches/valkyrie_qt4port/toolview/memcheckview.cpp 2010-03-11 19:42:35 UTC (rev 490) +++ branches/valkyrie_qt4port/toolview/memcheckview.cpp 2010-03-11 21:54:47 UTC (rev 491) @@ -556,7 +556,5 @@ // item ok: contract / expand it VgOutputItem* vgItem = (VgOutputItem*)item; actMC_OpenClose_item->setEnabled( vgItem->getIsExpandable() ); - - //TODO: for leaves, default to closing parent item? } } Modified: branches/valkyrie_qt4port/utils/vglog.cpp =================================================================== --- branches/valkyrie_qt4port/utils/vglog.cpp 2010-03-11 19:42:35 UTC (rev 490) +++ branches/valkyrie_qt4port/utils/vglog.cpp 2010-03-11 21:54:47 UTC (rev 491) @@ -1279,6 +1279,11 @@ } +/*! + merge given log into this log. + + TODO: handle merge of incomplete logs: - errors with no errorcount, ... +*/ bool VgLog::merge( VgLog& slave ) { /* clean master of leaks before status_end */ Modified: branches/valkyrie_qt4port/utils/vglog.h =================================================================== --- branches/valkyrie_qt4port/utils/vglog.h 2010-03-11 19:42:35 UTC (rev 490) +++ branches/valkyrie_qt4port/utils/vglog.h 2010-03-11 21:54:47 UTC (rev 491) @@ -193,8 +193,6 @@ QString toString( int indent = 2 ); /* xml output */ QString toPlainTxt(); /* plain text output */ - /* TODO: handle merge of incomplete logs: - - errors with no errorcount, ... */ bool merge( VgLog& slave ); VgStatus::StateType state(); Modified: branches/valkyrie_qt4port/utils/vk_messages.cpp =================================================================== --- branches/valkyrie_qt4port/utils/vk_messages.cpp 2010-03-11 19:42:35 UTC (rev 490) +++ branches/valkyrie_qt4port/utils/vk_messages.cpp 2010-03-11 21:54:47 UTC (rev 491) @@ -20,8 +20,6 @@ #include "utils/vk_messages.h" #include "utils/vk_config.h" -//#include "valkyrie_xpm.h" -//#include "msgbox_icons.h" #include <stdarg.h> /* va_start, va_end */ #include <stdlib.h> /* exit errno */ @@ -33,9 +31,7 @@ #include <QPixmap> #include <QStyle> -#include <iostream> - /***************************************************************************/ /*! message dialogs |
From: <sv...@va...> - 2010-03-11 19:42:53
|
Author: cerion Date: 2010-03-11 19:42:35 +0000 (Thu, 11 Mar 2010) New Revision: 490 Log: fix bug in fileCheck(): init QFileInfo _after_ we've found the exec via $PATH. Modified: branches/valkyrie_qt4port/utils/vk_utils.cpp Modified: branches/valkyrie_qt4port/utils/vk_utils.cpp =================================================================== --- branches/valkyrie_qt4port/utils/vk_utils.cpp 2010-03-11 13:52:33 UTC (rev 489) +++ branches/valkyrie_qt4port/utils/vk_utils.cpp 2010-03-11 19:42:35 UTC (rev 490) @@ -364,7 +364,7 @@ { *err_val = PARSED_OK; QString absPath = QString::null; - QFileInfo fi( fpath ); + QFileInfo fi; // check exists: if so, return absolute path if ( fpath.isEmpty() ) { @@ -379,7 +379,9 @@ *err_val = PERROR_BADFILE; goto bye; } - + + fi.setFile( absPath ); + // check this is really a file if ( !fi.isFile() ) { *err_val = PERROR_BADFILE; |
From: <sv...@va...> - 2010-03-11 13:52:49
|
Author: cerion Date: 2010-03-11 13:52:33 +0000 (Thu, 11 Mar 2010) New Revision: 489 Log: reimplemented a bunch of internal tests: - option tests - file/dir tests Modified: branches/valkyrie_qt4port/mainwindow.cpp branches/valkyrie_qt4port/objects/memcheck_object.cpp branches/valkyrie_qt4port/options/vk_option.cpp branches/valkyrie_qt4port/options/vk_option.h branches/valkyrie_qt4port/toolview/memcheckview.cpp branches/valkyrie_qt4port/toolview/memcheckview.h branches/valkyrie_qt4port/utils/vk_utils.cpp branches/valkyrie_qt4port/utils/vk_utils.h Modified: branches/valkyrie_qt4port/mainwindow.cpp =================================================================== --- branches/valkyrie_qt4port/mainwindow.cpp 2010-03-10 00:44:20 UTC (rev 488) +++ branches/valkyrie_qt4port/mainwindow.cpp 2010-03-11 13:52:33 UTC (rev 489) @@ -890,7 +890,7 @@ if ( runState == VkRunState::VALGRIND ) { int errval = PARSED_OK; QString bin = vkConfig->rdEntry( "binary", "valkyrie" ); - binaryCheck( &errval, bin ); + fileCheck( &errval, bin, false, false, true ); if ( errval != PARSED_OK ) { vkError( this, "Run Tool", "Invalid Binary: Please set a valid binary in Options::Valkyrie." ); Modified: branches/valkyrie_qt4port/objects/memcheck_object.cpp =================================================================== --- branches/valkyrie_qt4port/objects/memcheck_object.cpp 2010-03-10 00:44:20 UTC (rev 488) +++ branches/valkyrie_qt4port/objects/memcheck_object.cpp 2010-03-11 13:52:33 UTC (rev 489) @@ -236,32 +236,32 @@ /* check argval for this option, updating if necessary. called by parseCmdArgs() and gui option pages -------------------- */ -int Memcheck::checkOptArg( int optid, QString& )//argval ) +int Memcheck::checkOptArg( int optid, QString& argval ) { vk_assert( optid >= 0 && optid < MEMCHECK::NUM_OPTS ); int errval = PARSED_OK; -#if 0 - Option* opt = findOption( optid ); + + VkOption* opt = getOption( optid ); - switch (( Memcheck::mcOpts )optid ) { - case PARTIAL: - case FREELIST: - case LEAK_RES: - case SHOW_REACH: - //case UNDEF_VAL: - case TRACK_ORI: - case GCC_296: - case ALIGNMENT: + switch ( (MEMCHECK::mcOptId)optid ) { + case MEMCHECK::PARTIAL: + case MEMCHECK::FREELIST: + case MEMCHECK::LEAK_RES: + case MEMCHECK::SHOW_REACH: + //case MEMCHECK::UNDEF_VAL: + case MEMCHECK::TRACK_ORI: + case MEMCHECK::GCC_296: + case MEMCHECK::ALIGNMENT: opt->isValidArg( &errval, argval ); break; - /* when using xml output from valgrind, this option is preset to - 'full' by valgrind, so this option should not be used. */ - case LEAK_CHECK: - /* Note: gui options disabled, so only reaches here from cmdline */ + // when using xml output from valgrind, this option is preset to + // 'full' by valgrind, so this option should not be used. + case MEMCHECK::LEAK_CHECK: + // Note: gui options disabled, so only reaches here from cmdline errval = PERROR_BADOPT; - vkPrintErr( "Option disabled '--%s'", opt->m_longFlag.latin1() ); + vkPrintErr( "Option disabled '--%s'", qPrintable( opt->longFlag ) ); vkPrintErr( " - Memcheck presets this option to 'full' when generating the required xml output." ); vkPrintErr( " - See valgrind/docs/internals/xml_output.txt." ); break; @@ -270,8 +270,6 @@ vk_assert_never_reached(); } -#endif - return errval; } @@ -474,21 +472,18 @@ QString log_file = vkConfig->value( "valkyrie/view-log" ).toString(); statusMsg( "Parsing '" + log_file + "'" ); - //TODO: file checks -#if 0 - // check this is a valid file, and has the right perms + // check this is a valid file, and has at least read perms int errval = PARSED_OK; - QString ret_file = fileCheck( &errval, log_file, true, false ); - + QString ret_file = fileCheck( &errval, log_file, true ); + if ( errval != PARSED_OK ) { vkError( getToolView(), "File Error", "%s: \n\"%s\"", parseErrString( errval ), - escapeEntities( log_file ).latin1() ); + qPrintable( escapeEntities( log_file ) ) ); return false; } log_file = ret_file; -#endif // fileSaved true, 'cos we're just parsing an existing file fileSaved = true; @@ -498,7 +493,7 @@ qApp->processEvents( QEventLoop::AllEvents, 1000/*max msecs*/ ); // Parse the log - VgLogReader vgLogFileReader( getToolView()->vgLogPtr() ); + VgLogReader vgLogFileReader( getToolView()->createVgLog() ); bool success = vgLogFileReader.parse( log_file ); if ( success ) { @@ -540,7 +535,7 @@ // new vgreader - view may have been recreated, so need up-to-date ptr vk_assert( vgreader == 0 ); - vgreader = new VgLogReader( getToolView()->vgLogPtr() ); + vgreader = new VgLogReader( getToolView()->createVgLog() ); // start a new process, listening on exit signal to call processDone(). // - once Vg is done, we can read the remainder of the log in one last go. Modified: branches/valkyrie_qt4port/options/vk_option.cpp =================================================================== --- branches/valkyrie_qt4port/options/vk_option.cpp 2010-03-10 00:44:20 UTC (rev 488) +++ branches/valkyrie_qt4port/options/vk_option.cpp 2010-03-11 13:52:33 UTC (rev 489) @@ -19,6 +19,7 @@ #include "options/vk_option.h" #include "utils/vk_config.h" +#include "utils/vk_utils.h" /***************************************************************************/ @@ -175,156 +176,292 @@ class VkOption */ VkOption::VkOption( - int optid, - QString configGrp, QString longFlag, QChar shortFlag, - QString flagDesc, QString possVals, QVariant dfltValue, - QString shortHelp, QString longHelp, QString urlAddress, - VkOPT::ArgType argType, VkOPT::WidgType widgType ) + int _optid, + QString _configGrp, QString _longFlag, QChar _shortFlag, + QString _flagDescr, QString _possVals, QVariant _dfltValue, + QString _shortHelp, QString _longHelp, QString _urlAddress, + VkOPT::ArgType _argType, VkOPT::WidgType _widgType ) { - this->optid = optid; - this->configGrp = configGrp; - this->longFlag = longFlag; - this->shortFlag = shortFlag; - this->flagDescr = flagDesc; - this->possValues = possVals.split( '|', QString::SkipEmptyParts ); - this->dfltValue = dfltValue; - this->shortHelp = shortHelp; - this->longHelp = longHelp; - this->urlAddress = urlAddress; - this->argType = argType; - this->widgType = widgType; + optid = _optid; + configGrp = _configGrp; + longFlag = _longFlag; + shortFlag = _shortFlag; + flagDescr = _flagDescr; + possValues = _possVals.split( '|', QString::SkipEmptyParts ); + dfltValue = _dfltValue; + shortHelp = _shortHelp; + longHelp = _longHelp; + urlAddress = _urlAddress; + argType = _argType; + widgType = _widgType; - - // TODO -#ifdef VK_DEBUG - - /* augment m_longHelp if m_defaultValue not empty */ - if ( m_argType != VkOPTION::NOT_POPT && - !m_defaultValue.isEmpty() ) { - m_longHelp += " [" + m_defaultValue + "]"; + // augment longHelp if dfltValue not empty + if ( argType != VkOPT::NOT_POPT && + !dfltValue.toString().isEmpty() ) { + longHelp += " [" + dfltValue.toString() + "]"; } - /* Assert is valid option ---------------------------------------- */ + // Assert is valid option ---------------------------------------- if ( 0 ) { print(); } - /* we always expect the following fields */ - vk_assert( !m_configGroup.isEmpty() ); - vk_assert( !m_longFlag.isEmpty() ); - vk_assert( !m_longHelp.isEmpty() || !m_shortHelp.isEmpty() ); + // we always expect the following fields + vk_assert( !configGrp.isEmpty() ); + vk_assert( !longFlag.isEmpty() ); + + // no help for internal-config options: short|long help for others + if ( argType == VkOPT::NOT_POPT && + widgType == VkOPT::WDG_NONE ) { + vk_assert( longHelp.isEmpty() && shortHelp.isEmpty() ); + } else { + vk_assert( !longHelp.isEmpty() || !shortHelp.isEmpty() ); + } - /* if ARG_NONE, we don't expect any argument related stuff */ - if ( m_argType == VkOPTION::ARG_NONE ) { - vk_assert( m_flagDescrip.isEmpty() ); - vk_assert( m_possValues.isEmpty() ); + // if ARG_NONE, we don't expect any argument related stuff + if ( argType == VkOPT::ARG_NONE ) { + vk_assert( flagDescr.isEmpty() ); + vk_assert( possValues.isEmpty() ); } - /* NOT_POPT options: not for command-line processing */ - if ( m_argType == VkOPTION::NOT_POPT ) { - /* vk_popt option parsing relies on at least these being non-empty: */ - vk_assert( !m_shortFlag.isNull() || !m_longFlag.isEmpty() ); - /* only short help wanted: used for gui widget text */ - vk_assert( !m_shortHelp.isEmpty() ); - vk_assert( m_longHelp.isEmpty() ); + // NOT_POPT options: not for command-line processing + if ( argType == VkOPT::NOT_POPT ) { + + // vk_popt option parsing relies on at least these being non-empty: + vk_assert( !shortFlag.isNull() || !longFlag.isEmpty() ); + + // gui-only options + if ( widgType != VkOPT::WDG_NONE ) { + // only short help wanted: used for gui widget text + vk_assert( !shortHelp.isEmpty() ); + vk_assert( longHelp.isEmpty() ); + } + // else NOT_POPT && WDG_NONE => internal configure options only. } - /* ARG_PWR2 options */ - if ( m_argType == VkOPTION::ARG_PWR2 ) { - /* min|max */ - vk_assert( m_possValues.count() == 2 ); - /* m_defaultValue, m_possValues must all be powers of 2 */ - vk_assert( isPowerOfTwo( m_defaultValue ) ); - vk_assert( isPowerOfTwo( m_possValues[0] ) ); - vk_assert( isPowerOfTwo( m_possValues[1] ) ); - /* min <= default <= max */ + // ARG_PWR2 options + if ( argType == VkOPT::ARG_PWR2 ) { + // min|max + vk_assert( possValues.count() == 2 ); + // dfltValue, possValues must all be powers of 2 + vk_assert( isPowerOfTwo( dfltValue.toString() ) ); + vk_assert( isPowerOfTwo( possValues[0] ) ); + vk_assert( isPowerOfTwo( possValues[1] ) ); + // min <= default <= max bool ok; - unsigned long dflt = m_defaultValue.toULong( &ok ); + unsigned long dflt = dfltValue.toString().toULong( &ok ); vk_assert( ok ); - unsigned long min = m_possValues[0].toULong( &ok ); + unsigned long min = possValues[0].toULong( &ok ); vk_assert( ok ); - unsigned long max = m_possValues[1].toULong( &ok ); + unsigned long max = possValues[1].toULong( &ok ); vk_assert( ok ); vk_assert( min <= dflt ); vk_assert( dflt <= max ); } - /* ARG_UINT options */ - if ( m_argType == VkOPTION::ARG_UINT ) { - /* except don't test cachegrind's horrible cache options */ - bool dontTest = ( m_configGroup == "cachegrind" && - ( m_longFlag == "I1" || - m_longFlag == "D1" || - m_longFlag == "L2" ) ); + // ARG_UINT options + if ( argType == VkOPT::ARG_UINT ) { + // except don't test cachegrind's horrible cache options + bool dontTest = ( configGrp == "cachegrind" && + ( longFlag == "I1" || + longFlag == "D1" || + longFlag == "L2" ) ); - if ( !dontTest ) { - /* min|max */ - vk_assert( m_possValues.count() == 2 ); - /* min <= default <= max */ + if ( dontTest ) { + VK_DEBUG( "Warning: Not performing UInt value test for option: %s", + qPrintable( longFlag ) ); + } else { + // min|max + vk_assert( possValues.count() == 2 ); + // min <= default <= max bool ok; - unsigned long dflt = m_defaultValue.toULong( &ok ); + unsigned long dflt = dfltValue.toString().toULong( &ok ); vk_assert( ok ); - unsigned long min = m_possValues[0].toULong( &ok ); + unsigned long min = possValues[0].toULong( &ok ); vk_assert( ok ); - unsigned long max = m_possValues[1].toULong( &ok ); + unsigned long max = possValues[1].toULong( &ok ); vk_assert( ok ); vk_assert( min <= dflt ); vk_assert( dflt <= max ); } } - /* ARG_BOOL options */ - if ( m_argType == VkOPTION::ARG_BOOL ) { - /* true|false (in various guises) */ - vk_assert( m_possValues.count() == 2 ); - /* accepted bool forms: */ - QString t = m_possValues[0]; - QString f = m_possValues[1]; + // ARG_BOOL options + if ( argType == VkOPT::ARG_BOOL ) { + // true|false (in various guises) + vk_assert( possValues.count() == 2 ); + // accepted bool forms: + QString t = possValues[0]; + QString f = possValues[1]; vk_assert( t == "true" || t == "on" || t == "yes" || t == "1" || t == "T" ); vk_assert( f == "false" || f == "off" || f == "no" || f == "0" || f == "F" ); } - /* OptWidget relies on bool values being in order <true|false> */ - if ( m_widgType == VkOPTION::WDG_CHECK || - m_widgType == VkOPTION::WDG_RADIO ) { + // OptWidget relies on bool values being in order <true|false> + if ( widgType == VkOPT::WDG_CHECK || + widgType == VkOPT::WDG_RADIO ) { - vk_assert( m_possValues.count() == 2 ); + vk_assert( possValues.count() == 2 ); - QString yes = m_possValues[0]; - QString no = m_possValues[1]; + QString yes = possValues[0]; + QString no = possValues[1]; vk_assert( yes == "1" || yes == "on" || yes == "yes" || yes == "true" ); - vk_assert( no == "0" || no == "off" || no == "no" || no == "false" ); + vk_assert( no == "0" || no == "off" || no == "no" || no == "false" ); } - -#endif } - -#if 0 // TODO -/* for debugging */ -void Option::print() -{ - vkPrint( "m_key = %d", m_key ); - vkPrint( "m_widgType = %d", m_widgType ); - vkPrint( "m_argType = %d", m_argType ); - vkPrint( "m_shortFlag = %c", m_shortFlag.latin1() ); - vkPrint( "m_longFlag = %s", m_longFlag.latin1() ); - vkPrint( "m_flagDescrip = %s", m_flagDescrip.latin1() ); - vkPrint( "m_shortHelp = %s", m_shortHelp.latin1() ); - vkPrint( "m_longHelp = %s", m_longHelp.latin1() ); - vkPrint( "m_urlHelp = %s", m_urlHelp.latin1() ); - vkPrint( "m_defaultValue = %s", m_defaultValue.latin1() ); - vkPrint( "m_configGroup = %s", m_configGroup.latin1() ); - vkPrint( "m_possValues = |%s|", m_possValues.join( "|" ).latin1() ); - vkPrint( " " ); +/*! + configuration settings (QSettings) key for persistent storage: +*/ +QString VkOption::configKey() { + return configGrp + "/" + longFlag; } -#endif +/*! + update +*/ void VkOption::updateConfig( QVariant argVal ) { vkConfig->setValue( configKey(), argVal ); emit valueChanged(); } + + +/*! + tests for potential argument update +*/ +bool VkOption::isValidArg( int* err_val, QString argval ) +{ + *err_val = PARSED_OK; + switch ( argType ) { + + // eg. possValues == { 0, 4 }, ie. min=0, max=4 + case VkOPT::ARG_UINT: { + vk_assert( possValues.count() == 2 ); + // is this a number? + bool ok; + unsigned int val = argval.toUInt(&ok); + if (!ok) + *err_val = PERROR_BADNUMBER; + else { // looking good ... + unsigned int min = possValues[0].toUInt(&ok); + vk_assert(ok); + unsigned int max = possValues[1].toUInt(&ok); + vk_assert(ok); + if ( val < min || val > max ) { + *err_val = PERROR_OUTOFRANGE; + } + } + } + break; + + // eg. possValues == { 2, 16 }, ie. min=2, max=16 + case VkOPT::ARG_PWR2: { + vk_assert( possValues.count() == 2 ); + // is this a number? + bool ok; + unsigned long val = argval.toULong(&ok); + if (!ok) + *err_val = PERROR_BADNUMBER; + else { // looking good ... + // is this a power of 2? + if ( isPowerOfTwo( argval, err_val ) ) { // looking better ... + unsigned long min = possValues[0].toULong(); + unsigned long max = possValues[1].toULong(); + if ( val < min || val > max ) { + *err_val = PERROR_OUTOFRANGE; + } + } + } + } break; + + // possValues == { memcheck, addrcheck, ... } + case VkOPT::ARG_STRING: { + if ( ! possValues.contains( argval ) ) { + *err_val = PERROR_BADARG; + } + } break; + + // possValues == { yes|true, no|false } or whatever + case VkOPT::ARG_BOOL: { + vk_assert( possValues.count() == 2 ); + if ( argval != possValues[0] && + argval != possValues[1] ) { + *err_val = PERROR_BADARG; + } + } break; + + // this option is only ever called from within an options page via + // radio buttons etc., so the values can never be typed in. ergo, + // don't bother to check. + case VkOPT::NOT_POPT: + break; + + // this should never happen: only relevant to popt short help options. + case VkOPT::ARG_NONE: + vk_assert_never_reached(); + break; + + default: + vk_assert_never_reached(); + break; + } + + return ( *err_val == PARSED_OK ); +} + + +// static fn +bool VkOption::isPowerOfTwo( QString argval, int *err_val/*=0*/ ) +{ + bool ok; + unsigned long val = argval.toULong(&ok); + + if ( !ok ) { + if (err_val) + *err_val = PERROR_BADNUMBER; + return false; + } + + switch ( val ) { + case 1: case 2: case 4: case 8: + case 16: case 32: case 64: case 128: + case 256: case 512: case 1024: case 2048: + case 4096: case 8192: case 16384: case 32768: + case 65536: case 131072: case 262144: case 524288: + case 1048576: case 2097152: case 4194304: case 8388608: + break; + default: + if (err_val) + *err_val = PERROR_POWER_OF_TWO; + return false; + } + + if (err_val) + *err_val = PARSED_OK; + return true; +} + + +/*! + for debugging +*/ +void VkOption::print() +{ + vkPrint( "optid = %d", optid ); + vkPrint( "widgType = %d", widgType ); + vkPrint( "argType = %d", argType ); + vkPrint( "shortFlag = %c", shortFlag.toLatin1() ); + vkPrint( "longFlag = %s", qPrintable( longFlag ) ); + vkPrint( "flagDescr = %s", qPrintable( flagDescr ) ); + vkPrint( "shortHelp = %s", qPrintable( shortHelp ) ); + vkPrint( "longHelp = %s", qPrintable( longHelp ) ); + vkPrint( "urlAddress = %s", qPrintable( urlAddress ) ); + vkPrint( "dfltValue = %s", qPrintable( dfltValue.toString() ) ); + vkPrint( "configGrp = %s", qPrintable( configGrp ) ); + vkPrint( "possValues = |%s|", qPrintable( possValues.join( "|" ) ) ); + vkPrint( " " ); +} Modified: branches/valkyrie_qt4port/options/vk_option.h =================================================================== --- branches/valkyrie_qt4port/options/vk_option.h 2010-03-10 00:44:20 UTC (rev 488) +++ branches/valkyrie_qt4port/options/vk_option.h 2010-03-11 13:52:33 UTC (rev 489) @@ -93,21 +93,9 @@ #define PERROR_POWER_OF_TWO -31 /* number not a power of two */ #define PERROR_BADVERSION -32 /* bad program version */ - -#if 0 -// ============================================================ -// helper functions -QString fileCheck( int* err_val, const QString fpath, - bool rd_perms, bool wr_perms ); -QString binaryCheck( int* err_val, const QString exe_name ); -QString dirCheck( int* err_val, const QString fpath, - bool rd_perms, bool wr_perms ); -#endif - const char* parseErrString( const int error ); - // ============================================================ class VkOptionHash { @@ -160,7 +148,10 @@ VkOPT::ArgType arg_type, VkOPT::WidgType w_type ); - + + bool isValidArg( int* err_val, QString argval ); + static bool isPowerOfTwo( QString argval, int* err_val=0 ); + signals: void valueChanged(); @@ -173,18 +164,20 @@ QString flagDescr; // eg. <file> QStringList possValues; // eg. low | med | high QVariant dfltValue; // eg. [low] + // - QVariant to support QSettings::setValue() + // See this->updateConfig() QString shortHelp; // txt for OptionsWindow QString longHelp; // txt for help --> stdout QString urlAddress; // context help url VkOPT::ArgType argType; // eg. ARG_UINT VkOPT::WidgType widgType; // eg. VkOPTION::WDG_LEDIT - // configuration settings key: - QString configKey() { - return configGrp + "/" + longFlag; - } + QString configKey(); void updateConfig( QVariant argVal ); + +private: + void print(); }; #endif // __VK_OPTION_H Modified: branches/valkyrie_qt4port/toolview/memcheckview.cpp =================================================================== --- branches/valkyrie_qt4port/toolview/memcheckview.cpp 2010-03-10 00:44:20 UTC (rev 488) +++ branches/valkyrie_qt4port/toolview/memcheckview.cpp 2010-03-11 13:52:33 UTC (rev 489) @@ -55,7 +55,7 @@ Constructs a MemcheckView with the given \a parent. */ MemcheckView::MemcheckView( QWidget* parent ) - : ToolView( parent, VGTOOL::ID_MEMCHECK ) + : ToolView( parent, VGTOOL::ID_MEMCHECK ), logview(0) { setObjectName( QString::fromUtf8( "MemcheckView" ) ); @@ -78,9 +78,6 @@ // launch editor with src file loaded connect( treeView, SIGNAL( itemDoubleClicked( QTreeWidgetItem*, int ) ), this, SLOT( launchEditor( QTreeWidgetItem* ) ) ); - - - logview = new VgLogView( treeView ); } @@ -104,12 +101,12 @@ This should be called by the tool-object just before it intends to fill the log. */ -VgLog* MemcheckView::vgLogPtr() +VgLog* MemcheckView::createVgLog() { if ( logview != 0 ) { delete logview; - logview = new VgLogView( treeView ); } + logview = new VgLogView( treeView ); return ( VgLog* )logview; } Modified: branches/valkyrie_qt4port/toolview/memcheckview.h =================================================================== --- branches/valkyrie_qt4port/toolview/memcheckview.h 2010-03-10 00:44:20 UTC (rev 488) +++ branches/valkyrie_qt4port/toolview/memcheckview.h 2010-03-11 13:52:33 UTC (rev 489) @@ -52,7 +52,7 @@ MemcheckView( QWidget* parent ); ~MemcheckView(); - VgLog* vgLogPtr(); + VgLog* createVgLog(); public slots: virtual void setState( bool run ); Modified: branches/valkyrie_qt4port/utils/vk_utils.cpp =================================================================== --- branches/valkyrie_qt4port/utils/vk_utils.cpp 2010-03-10 00:44:20 UTC (rev 488) +++ branches/valkyrie_qt4port/utils/vk_utils.cpp 2010-03-11 13:52:33 UTC (rev 489) @@ -18,12 +18,14 @@ ****************************************************************************/ #include "vk_utils.h" +#include "options/vk_option.h" #include "utils/vk_config.h" // vkname() #include <cstdlib> // exit, mkstemp, free/malloc, etc #include <QDateTime> #include <QFile> +#include <QFileInfo> #include <QRegExp> #include <QString> @@ -80,7 +82,7 @@ /* prints debug msg -------------------------------------------------- */ void vkDebug( const char* msg, ... ) { -#ifdef DEBUG +#ifdef DEBUG_ON QByteArray ba = vkConfig->vkName.toLatin1(); const char* vkname = vkConfig ? ba.constData() : ""; va_list ap; @@ -312,3 +314,141 @@ } + + + + +//*************************************************************************** +// helper functions +//*************************************************************************** + +/*! + Local helper function to find file_name: either directly or via $PATH + Returns absolute path to file_name. +*/ +static QString getFileAbsPath( const QString file_name ) +{ + QString absPath = QString::null; + + if ( QFile::exists( file_name ) ) { + // file_name exists: get its absolute path. + absPath = QFileInfo( file_name ).absoluteFilePath(); + } + else if ( !file_name.contains('/') ) { + // no '/' in file_name -> try $PATH env variable + QString env = getenv( "PATH" ); + QStringList paths = env.split( ':' ); + + foreach ( QString candidate, paths ) { + candidate += "/" + file_name; + if ( QFile::exists( candidate ) ) { + // found it! set its absolute path. + absPath = QFileInfo( candidate ).absoluteFilePath(); + break; + } + } + } + + return absPath; +} + + +/*! + Checks file exists and has correct permissions. + Returns absolute path to file, if it exists: else QString::null +*/ +QString fileCheck( int* err_val, const QString fpath, + bool check_read/*=false*/, + bool check_write/*=false*/, + bool check_exe/*=false*/ ) +{ + *err_val = PARSED_OK; + QString absPath = QString::null; + QFileInfo fi( fpath ); + + // check exists: if so, return absolute path + if ( fpath.isEmpty() ) { + *err_val = PERROR_BADFILE; + goto bye; + } + + // try to find fpath: directly or via $PATH + absPath = getFileAbsPath( fpath ); + if ( absPath.isNull() ) { + // couldn't find fpath :-( + *err_val = PERROR_BADFILE; + goto bye; + } + + // check this is really a file + if ( !fi.isFile() ) { + *err_val = PERROR_BADFILE; + goto bye; + } + + // check for read permissions + if ( check_read && !fi.isReadable() ) { + *err_val = PERROR_BADFILERD; + goto bye; + } + + // check for write permissions + if ( check_write && !fi.isWritable() ) { + *err_val = PERROR_BADFILEWR; + goto bye; + } + + // check for executable permissions + if ( check_exe && !fi.isExecutable() ) { + *err_val = PERROR_BADEXEC; + goto bye; + } + +bye: + return absPath; +} + + +/*! + Checks dir exists and has correct permissions. + Returns absolute path to dir, if it exists: else QString::null +*/ +QString dirCheck( int* err_val, const QString dir, + bool check_read/*=false*/, + bool check_write/*=false*/, + bool check_exe/*=false*/ ) +{ + *err_val = PARSED_OK; + QString absPath = QString::null; + QFileInfo fi( dir ); + + // check exists: if so, return absolute path + if ( dir.isEmpty() || !fi.exists() || !fi.isDir() ) { + *err_val = PERROR_BADDIR; + goto bye; + } + + // dir exists: set its absolute path + absPath = fi.absolutePath(); + + // check for read permissions + if ( check_read && !fi.isReadable() ) { + *err_val = PERROR_BADFILERD; + goto bye; + } + + // check for write permissions + if ( check_write && !fi.isWritable() ) { + *err_val = PERROR_BADFILEWR; + goto bye; + } + + // check for executable permissions + if ( check_exe && !fi.isExecutable() ) { + *err_val = PERROR_BADEXEC; + goto bye; + } + +bye: + return absPath; +} Modified: branches/valkyrie_qt4port/utils/vk_utils.h =================================================================== --- branches/valkyrie_qt4port/utils/vk_utils.h 2010-03-10 00:44:20 UTC (rev 488) +++ branches/valkyrie_qt4port/utils/vk_utils.h 2010-03-11 13:52:33 UTC (rev 489) @@ -129,4 +129,18 @@ char* vk_strdup( const char* str ); + + + +// ============================================================ +// helper functions +QString fileCheck( int* err_val, const QString fpath, + bool check_read=false, bool check_write=false, + bool check_exe=false ); + +QString dirCheck( int* err_val, const QString fpath, + bool check_read=false, bool check_write=false, + bool check_exe=false ); + + #endif |
From: <sv...@va...> - 2010-03-10 00:44:44
|
Author: cerion Date: 2010-03-10 00:44:20 +0000 (Wed, 10 Mar 2010) New Revision: 488 Log: provide nice shiny new model for tool-object to fill when asked to do so. - else would crash on every 2nd run. plus more comments on how the model/view stuff works. Modified: branches/valkyrie_qt4port/toolview/memcheckview.cpp branches/valkyrie_qt4port/toolview/memcheckview.h branches/valkyrie_qt4port/toolview/vglogview.h Modified: branches/valkyrie_qt4port/toolview/memcheckview.cpp =================================================================== --- branches/valkyrie_qt4port/toolview/memcheckview.cpp 2010-03-09 22:31:15 UTC (rev 487) +++ branches/valkyrie_qt4port/toolview/memcheckview.cpp 2010-03-10 00:44:20 UTC (rev 488) @@ -97,6 +97,24 @@ /*! + Provide the tool-object access to our model, to fill it, + but keep ownership ourselves: we know when we're done with it. + + Creates a clean log on each call. + This should be called by the tool-object just before it intends + to fill the log. +*/ +VgLog* MemcheckView::vgLogPtr() +{ + if ( logview != 0 ) { + delete logview; + logview = new VgLogView( treeView ); + } + return ( VgLog* )logview; +} + + +/*! Parse and load a memcheck xml logfile. */ void MemcheckView::openLogFile() Modified: branches/valkyrie_qt4port/toolview/memcheckview.h =================================================================== --- branches/valkyrie_qt4port/toolview/memcheckview.h 2010-03-09 22:31:15 UTC (rev 487) +++ branches/valkyrie_qt4port/toolview/memcheckview.h 2010-03-10 00:44:20 UTC (rev 488) @@ -52,9 +52,7 @@ MemcheckView( QWidget* parent ); ~MemcheckView(); - VgLog* vgLogPtr() { - return ( VgLog* )logview; - } + VgLog* vgLogPtr(); public slots: virtual void setState( bool run ); Modified: branches/valkyrie_qt4port/toolview/vglogview.h =================================================================== --- branches/valkyrie_qt4port/toolview/vglogview.h 2010-03-09 22:31:15 UTC (rev 487) +++ branches/valkyrie_qt4port/toolview/vglogview.h 2010-03-10 00:44:20 UTC (rev 488) @@ -219,12 +219,22 @@ // ============================================================ /*! VgLogView: inherits VgLog + - this is our model, which incrementally updates our view + - takes qlistview in constructor, and populates it at the same time the underlying vglog is populated - - associates each listview item with a VgLog element, + + - each listview item gets a ref to its appropriate VgLog element, which is used to set the text of the item, and is intended for - future use of accessing/editing the underlying log + future use of accessing/editing the underlying model data. (e.g. generating a suppression by clicking on an error item) + + - this is fast, but not very pretty: we end up with two models, + holding refs to the same model nodes: + - one via vgLog itself (currently not used after helping populate view), + - one via the view-items, which hold dom-elements. + + - TODO: refactor this for less maintenance. */ class VgLogView : public VgLog { |
From: <sv...@va...> - 2010-03-09 22:31:43
|
Author: cerion Date: 2010-03-09 22:31:15 +0000 (Tue, 09 Mar 2010) New Revision: 487 Log: finished off vglogview & memcheckview - src items now shown, along with colours & icons - editor launched on double-click oh, and ErrorItem::count is now updated by <errorcount>'s, when they come along. Added: branches/valkyrie_qt4port/icons/vglogview_readonly.xpm branches/valkyrie_qt4port/icons/vglogview_readwrite.xpm Removed: branches/valkyrie_qt4port/icons/vglogview_read.xpm branches/valkyrie_qt4port/icons/vglogview_write.xpm Modified: branches/valkyrie_qt4port/icons.qrc branches/valkyrie_qt4port/objects/helgrind_object.cpp branches/valkyrie_qt4port/objects/helgrind_object.h branches/valkyrie_qt4port/objects/valkyrie_object.cpp branches/valkyrie_qt4port/toolview/memcheckview.cpp branches/valkyrie_qt4port/toolview/vglogview.cpp branches/valkyrie_qt4port/toolview/vglogview.h Deleted: branches/valkyrie_qt4port/icons/vglogview_read.xpm =================================================================== --- branches/valkyrie_qt4port/icons/vglogview_read.xpm 2010-03-08 22:24:33 UTC (rev 486) +++ branches/valkyrie_qt4port/icons/vglogview_read.xpm 2010-03-09 22:31:15 UTC (rev 487) @@ -1,69 +0,0 @@ -/* XPM */ -static const char* read_xpm[] = { -"16 16 50 1", -" c None", -". c #D0D0DF", -"+ c #9C9CB6", -"@ c #FFFFFF", -"# c #F9F9FE", -"$ c #F5F5FC", -"% c #E9E9F2", -"& c #EBEBF4", -"* c #FCFCFF", -"= c #F8F8FE", -"- c #ECECF4", -"; c #D3D3E1", -"> c #EFEFF6", -", c #FDFDFF", -"' c #F1F1F8", -") c #E6E6F0", -"! c #D7D7E5", -"~ c #C9C9DA", -"{ c #6A6A7B", -"] c #FEFEFF", -"^ c #F2F2F9", -"/ c #EEEEF5", -"( c #DADAE7", -"_ c #CECEDD", -": c #CCCCDB", -"< c #F3F3F9", -"[ c #D5D5E4", -"} c #D2D2E0", -"| c #E7E7F0", -"1 c #E0E0EC", -"2 c #DCDCE9", -"3 c #DBDBE8", -"4 c #D8D8E6", -"5 c #D57A00", -"6 c #F6F6FD", -"7 c #E5E5EF", -"8 c #DEDEEB", -"9 c #FEFEFE", -"0 c #FEFED5", -"a c #FEFE7A", -"b c #FED500", -"c c #A94600", -"d c #EAEAF3", -"e c #E8E8F1", -"f c #E1E1ED", -"g c #FEFE00", -"h c #7A0000", -"i c #E4E4EE", -"j c #D5A900", -"k c #F0F0F7", -" ........+ ", -" .@@@#$%&.+ ", -" .@@@*=-&.;+ ", -" .@@@*#>&++++", -" ++++@,#'&)!~+", -" +@@@@{]*^/(_:+", -" +@{+@{@*<&[}.+", -" +@{+@{#$|1234+", -" 5555556/)7182+", -" 590aaabc/de7f1+", -" 5agagb5h>&d)i1+", -" 5agagb5h>&d|7f+", -" 5bjbj55hk/d|7f+", -" chhhhhk>-d)7f+", -" .*<<'>&d|7f+", -" ++++++++++++"}; Copied: branches/valkyrie_qt4port/icons/vglogview_readonly.xpm (from rev 482, branches/valkyrie_qt4port/icons/vglogview_read.xpm) =================================================================== --- branches/valkyrie_qt4port/icons/vglogview_readonly.xpm (rev 0) +++ branches/valkyrie_qt4port/icons/vglogview_readonly.xpm 2010-03-09 22:31:15 UTC (rev 487) @@ -0,0 +1,69 @@ +/* XPM */ +static const char* read_xpm[] = { +"16 16 50 1", +" c None", +". c #D0D0DF", +"+ c #9C9CB6", +"@ c #FFFFFF", +"# c #F9F9FE", +"$ c #F5F5FC", +"% c #E9E9F2", +"& c #EBEBF4", +"* c #FCFCFF", +"= c #F8F8FE", +"- c #ECECF4", +"; c #D3D3E1", +"> c #EFEFF6", +", c #FDFDFF", +"' c #F1F1F8", +") c #E6E6F0", +"! c #D7D7E5", +"~ c #C9C9DA", +"{ c #6A6A7B", +"] c #FEFEFF", +"^ c #F2F2F9", +"/ c #EEEEF5", +"( c #DADAE7", +"_ c #CECEDD", +": c #CCCCDB", +"< c #F3F3F9", +"[ c #D5D5E4", +"} c #D2D2E0", +"| c #E7E7F0", +"1 c #E0E0EC", +"2 c #DCDCE9", +"3 c #DBDBE8", +"4 c #D8D8E6", +"5 c #D57A00", +"6 c #F6F6FD", +"7 c #E5E5EF", +"8 c #DEDEEB", +"9 c #FEFEFE", +"0 c #FEFED5", +"a c #FEFE7A", +"b c #FED500", +"c c #A94600", +"d c #EAEAF3", +"e c #E8E8F1", +"f c #E1E1ED", +"g c #FEFE00", +"h c #7A0000", +"i c #E4E4EE", +"j c #D5A900", +"k c #F0F0F7", +" ........+ ", +" .@@@#$%&.+ ", +" .@@@*=-&.;+ ", +" .@@@*#>&++++", +" ++++@,#'&)!~+", +" +@@@@{]*^/(_:+", +" +@{+@{@*<&[}.+", +" +@{+@{#$|1234+", +" 5555556/)7182+", +" 590aaabc/de7f1+", +" 5agagb5h>&d)i1+", +" 5agagb5h>&d|7f+", +" 5bjbj55hk/d|7f+", +" chhhhhk>-d)7f+", +" .*<<'>&d|7f+", +" ++++++++++++"}; Property changes on: branches/valkyrie_qt4port/icons/vglogview_readonly.xpm ___________________________________________________________________ Name: svn:mergeinfo + Copied: branches/valkyrie_qt4port/icons/vglogview_readwrite.xpm (from rev 482, branches/valkyrie_qt4port/icons/vglogview_write.xpm) =================================================================== --- branches/valkyrie_qt4port/icons/vglogview_readwrite.xpm (rev 0) +++ branches/valkyrie_qt4port/icons/vglogview_readwrite.xpm 2010-03-09 22:31:15 UTC (rev 487) @@ -0,0 +1,146 @@ +/* XPM */ +static const char* write_xpm[] = { +"16 16 127 2", +" c None", +". c #9AB2DB", +"+ c #5373A8", +"@ c #AB8668", +"# c #E3CFB0", +"$ c #F9FAFC", +"% c #F3F5FA", +"& c #EEF2F9", +"* c #E1E8F4", +"= c #DBE3F2", +"- c #C5D2EA", +"; c #C9D6EC", +"> c #AA8567", +", c #E3CDB0", +"' c #BF8D4C", +") c #FAFBFD", +"! c #F4F6FB", +"~ c #F0F3F9", +"{ c #E4EAF5", +"] c #DEE5F3", +"^ c #CCD9ED", +"/ c #AABDDD", +"( c #A3836C", +"_ c #E2CBAD", +": c #C0894D", +"< c #BC8543", +"[ c #E6EBF5", +"} c #CFDAEE", +"| c #6C86B1", +"1 c #A2826D", +"2 c #E3CFB2", +"3 c #C08A4F", +"4 c #BD8544", +"5 c #BA7E43", +"6 c #F1F4FA", +"7 c #E9EEF6", +"8 c #E3EAF4", +"9 c #D4DDEF", +"0 c #CDD8EA", +"a c #AC8D77", +"b c #BF884C", +"c c #B37A42", +"d c #815430", +"e c #F9F9FC", +"f c #EAEEF7", +"g c #D8E0EF", +"h c #C1A594", +"i c #E3CCB0", +"j c #BD8446", +"k c #80532F", +"l c #150D08", +"m c #F6F8FB", +"n c #EAEFF7", +"o c #E6ECF5", +"p c #E8E2E1", +"q c #F4EDE3", +"r c #D3A58C", +"s c #BF844A", +"t c #B37940", +"u c #7E522F", +"v c #1A1009", +"w c #FFFFFF", +"x c #E9EDF6", +"y c #E3E9F4", +"z c #DEDEE5", +"A c #F4EEE1", +"B c #E4C6B5", +"C c #B7846E", +"D c #AC7655", +"E c #805433", +"F c #1D1510", +"G c #E7DDD6", +"H c #EDDCCC", +"I c #B48F7F", +"J c #745A47", +"K c #564B41", +"L c #261D1B", +"M c #4B638C", +"N c #EDF1F8", +"O c #D7D0D4", +"P c #ECD8C9", +"Q c #B48E7D", +"R c #735B4C", +"S c #302E29", +"T c #545557", +"U c #B8C4D9", +"V c #DAE2EF", +"W c #8A8279", +"X c #967C6D", +"Y c #483E37", +"Z c #676767", +"` c #BCC4D1", +" . c #BDCBE4", +".. c #B9CAE6", +"+. c #4E6DA1", +"@. c #B6B6B7", +"#. c #191714", +"$. c #606060", +"%. c #B8BEC9", +"&. c #B7C3D6", +"*. c #A4B0C5", +"=. c #95A0B4", +"-. c #8592A6", +";. c #395076", +">. c #DBE1EC", +",. c #878684", +"'. c #A6A9AF", +"). c #9CA4B1", +"!. c #8E97A5", +"~. c #8B95A4", +"{. c #8791A2", +"]. c #848FA1", +"^. c #838EA0", +"/. c #EBF0F8", +"(. c #D8E1F1", +"_. c #D7E0F0", +":. c #D2DDEF", +"<. c #CFDBEE", +"[. c #CBD7EC", +"}. c #C6D4EB", +"|. c #C1D0E8", +"1. c #BECDE7", +"2. c #BBCBE6", +"3. c #D2DCEF", +"4. c #C6D3EB", +"5. c #C1CFE8", +"6. c #BECCE7", +" . . . . . . . . + @ # ", +" . $ % & * = - ; . + > , ' ", +" . ) ! ~ { ] ^ ; . / ( _ : < ", +" . ) % ~ [ * } ; | 1 2 3 4 5 ", +" . ) 6 ~ 7 8 9 0 a 2 b 4 c d ", +" . e 6 ~ f [ g h i j 4 c k l ", +" . m 6 ~ n o p q r s t u v w ", +" . ! & x y z A B C D E F w ", +" . & 7 7 ] G H I J K L M ", +" . & N y O P Q R S T U + ", +" . ~ 7 V W X Y Z ` ...+. ", +" . ~ y @.#.$.%.&.*.=.-.;. ", +" . N >.,.'.).!.~.{.].^.;. ", +" . /.(._.:.<.[.}.|.1.2.+ ", +" . o (._.3.} [.4.5.6...+ ", +" + + + + + + + + + + + + "}; Property changes on: branches/valkyrie_qt4port/icons/vglogview_readwrite.xpm ___________________________________________________________________ Name: svn:mergeinfo + Deleted: branches/valkyrie_qt4port/icons/vglogview_write.xpm =================================================================== --- branches/valkyrie_qt4port/icons/vglogview_write.xpm 2010-03-08 22:24:33 UTC (rev 486) +++ branches/valkyrie_qt4port/icons/vglogview_write.xpm 2010-03-09 22:31:15 UTC (rev 487) @@ -1,146 +0,0 @@ -/* XPM */ -static const char* write_xpm[] = { -"16 16 127 2", -" c None", -". c #9AB2DB", -"+ c #5373A8", -"@ c #AB8668", -"# c #E3CFB0", -"$ c #F9FAFC", -"% c #F3F5FA", -"& c #EEF2F9", -"* c #E1E8F4", -"= c #DBE3F2", -"- c #C5D2EA", -"; c #C9D6EC", -"> c #AA8567", -", c #E3CDB0", -"' c #BF8D4C", -") c #FAFBFD", -"! c #F4F6FB", -"~ c #F0F3F9", -"{ c #E4EAF5", -"] c #DEE5F3", -"^ c #CCD9ED", -"/ c #AABDDD", -"( c #A3836C", -"_ c #E2CBAD", -": c #C0894D", -"< c #BC8543", -"[ c #E6EBF5", -"} c #CFDAEE", -"| c #6C86B1", -"1 c #A2826D", -"2 c #E3CFB2", -"3 c #C08A4F", -"4 c #BD8544", -"5 c #BA7E43", -"6 c #F1F4FA", -"7 c #E9EEF6", -"8 c #E3EAF4", -"9 c #D4DDEF", -"0 c #CDD8EA", -"a c #AC8D77", -"b c #BF884C", -"c c #B37A42", -"d c #815430", -"e c #F9F9FC", -"f c #EAEEF7", -"g c #D8E0EF", -"h c #C1A594", -"i c #E3CCB0", -"j c #BD8446", -"k c #80532F", -"l c #150D08", -"m c #F6F8FB", -"n c #EAEFF7", -"o c #E6ECF5", -"p c #E8E2E1", -"q c #F4EDE3", -"r c #D3A58C", -"s c #BF844A", -"t c #B37940", -"u c #7E522F", -"v c #1A1009", -"w c #FFFFFF", -"x c #E9EDF6", -"y c #E3E9F4", -"z c #DEDEE5", -"A c #F4EEE1", -"B c #E4C6B5", -"C c #B7846E", -"D c #AC7655", -"E c #805433", -"F c #1D1510", -"G c #E7DDD6", -"H c #EDDCCC", -"I c #B48F7F", -"J c #745A47", -"K c #564B41", -"L c #261D1B", -"M c #4B638C", -"N c #EDF1F8", -"O c #D7D0D4", -"P c #ECD8C9", -"Q c #B48E7D", -"R c #735B4C", -"S c #302E29", -"T c #545557", -"U c #B8C4D9", -"V c #DAE2EF", -"W c #8A8279", -"X c #967C6D", -"Y c #483E37", -"Z c #676767", -"` c #BCC4D1", -" . c #BDCBE4", -".. c #B9CAE6", -"+. c #4E6DA1", -"@. c #B6B6B7", -"#. c #191714", -"$. c #606060", -"%. c #B8BEC9", -"&. c #B7C3D6", -"*. c #A4B0C5", -"=. c #95A0B4", -"-. c #8592A6", -";. c #395076", -">. c #DBE1EC", -",. c #878684", -"'. c #A6A9AF", -"). c #9CA4B1", -"!. c #8E97A5", -"~. c #8B95A4", -"{. c #8791A2", -"]. c #848FA1", -"^. c #838EA0", -"/. c #EBF0F8", -"(. c #D8E1F1", -"_. c #D7E0F0", -":. c #D2DDEF", -"<. c #CFDBEE", -"[. c #CBD7EC", -"}. c #C6D4EB", -"|. c #C1D0E8", -"1. c #BECDE7", -"2. c #BBCBE6", -"3. c #D2DCEF", -"4. c #C6D3EB", -"5. c #C1CFE8", -"6. c #BECCE7", -" . . . . . . . . + @ # ", -" . $ % & * = - ; . + > , ' ", -" . ) ! ~ { ] ^ ; . / ( _ : < ", -" . ) % ~ [ * } ; | 1 2 3 4 5 ", -" . ) 6 ~ 7 8 9 0 a 2 b 4 c d ", -" . e 6 ~ f [ g h i j 4 c k l ", -" . m 6 ~ n o p q r s t u v w ", -" . ! & x y z A B C D E F w ", -" . & 7 7 ] G H I J K L M ", -" . & N y O P Q R S T U + ", -" . ~ 7 V W X Y Z ` ...+. ", -" . ~ y @.#.$.%.&.*.=.-.;. ", -" . N >.,.'.).!.~.{.].^.;. ", -" . /.(._.:.<.[.}.|.1.2.+ ", -" . o (._.3.} [.4.5.6...+ ", -" + + + + + + + + + + + + "}; Modified: branches/valkyrie_qt4port/icons.qrc =================================================================== --- branches/valkyrie_qt4port/icons.qrc 2010-03-08 22:24:33 UTC (rev 486) +++ branches/valkyrie_qt4port/icons.qrc 2010-03-09 22:31:15 UTC (rev 487) @@ -12,8 +12,8 @@ <file>icons/tb_mainwin_viewflags.xpm</file> <file>icons/tb_mainwin_viewflags2.xpm</file> <file>icons/valkyrie.xpm</file> - <file>icons/vglogview_read.xpm</file> - <file>icons/vglogview_write.xpm</file> + <file>icons/vglogview_readonly.xpm</file> + <file>icons/vglogview_readwrite.xpm</file> <file>icons/context_help.xpm</file> <file>icons/valgrind_run.png</file> <file>icons/filesave.png</file> Modified: branches/valkyrie_qt4port/objects/helgrind_object.cpp =================================================================== --- branches/valkyrie_qt4port/objects/helgrind_object.cpp 2010-03-08 22:24:33 UTC (rev 486) +++ branches/valkyrie_qt4port/objects/helgrind_object.cpp 2010-03-09 22:31:15 UTC (rev 487) @@ -62,7 +62,7 @@ /* check argval for this option, updating if necessary. called by parseCmdArgs() and gui option pages -------------------- */ -int Helgrind::checkOptArg( int optid, QString& argval ) +int Helgrind::checkOptArg( int /*optid*/, QString& /*argval*/ ) { return PARSED_OK; } Modified: branches/valkyrie_qt4port/objects/helgrind_object.h =================================================================== --- branches/valkyrie_qt4port/objects/helgrind_object.h 2010-03-08 22:24:33 UTC (rev 486) +++ branches/valkyrie_qt4port/objects/helgrind_object.h 2010-03-09 22:31:15 UTC (rev 487) @@ -59,12 +59,12 @@ VkOptionsPage* createVkOptionsPage(); - bool start( int procId, QStringList vgflags ) { + bool start( int /*procId*/, QStringList /*vgflags*/ ) { return false; } void stop() {} - bool runValgrind( QStringList vgflags ) { + bool runValgrind( QStringList /*vgflags*/ ) { return false; } }; Modified: branches/valkyrie_qt4port/objects/valkyrie_object.cpp =================================================================== --- branches/valkyrie_qt4port/objects/valkyrie_object.cpp 2010-03-08 22:24:33 UTC (rev 486) +++ branches/valkyrie_qt4port/objects/valkyrie_object.cpp 2010-03-09 22:31:15 UTC (rev 487) @@ -524,13 +524,13 @@ /*! Check \a argval for the option given by \a optid, updating if necessary. */ -int Valkyrie::checkOptArg( int optid, QString& argval ) +int Valkyrie::checkOptArg( int optid, QString& /*argval*/ ) { vk_assert( optid >= 0 && optid < VALKYRIE::NUM_OPTS ); +#if 0 // TODO VkOption* opt = getOption( optid ); -#if 0 // TODO int errval = PARSED_OK; // Option* opt = findOption( optid ); Modified: branches/valkyrie_qt4port/toolview/memcheckview.cpp =================================================================== --- branches/valkyrie_qt4port/toolview/memcheckview.cpp 2010-03-08 22:24:33 UTC (rev 486) +++ branches/valkyrie_qt4port/toolview/memcheckview.cpp 2010-03-09 22:31:15 UTC (rev 487) @@ -20,6 +20,7 @@ #include "toolview/memcheckview.h" #include "utils/vk_config.h" +#include "utils/vk_messages.h" #include "utils/vk_utils.h" #include <QAction> @@ -27,6 +28,7 @@ #include <QFileDialog> #include <QLabel> #include <QMenuBar> +#include <QProcess> #include <QToolBar> #include <QVBoxLayout> @@ -263,8 +265,8 @@ /*! - Launches an editor for the given \a code_item tree-item. - Checks if the itemType() is indeed of type SRC_CODE, + Launches an editor for the given \a item. + Checks if the itemType() is of type SRC_CODE, and if the referenced file isReadable|isWriteable. If these checks are passed, the (option-configurable) editor is launched to open the source code file at the correct @@ -272,12 +274,84 @@ TODO: what if fails tests: user message? */ -void MemcheckView::launchEditor( QTreeWidgetItem* code_item ) +void MemcheckView::launchEditor( QTreeWidgetItem* item ) { - cerr << "MemcheckView::launchEditor( QTreeWidgetItem* ): " - << code_item->text( 0 ).toLatin1().data() << endl; - cerr << "TODO" << endl; - //TODO +// cerr << "MemcheckView::launchEditor(): " << qPrintable( item->text( 0 ) ) << endl; + + VgOutputItem* vgItemCurr = (VgOutputItem*)item; + if ( !vgItemCurr || + !vgItemCurr->parent() ) { + return; + } + + // only interested in SrcItem items (== LINE type) + if ( vgItemCurr->elemType() != VgElement::LINE || + vgItemCurr->parent()->elemType() != VgElement::FRAME ) { + return; + } + + // nothing to do if not even readable :-( + // in principle, if a src item is visible, it should be readable, + // but you never know... + if ( !vgItemCurr->isReadable ) { + vkError( this, "Editor Launch", "<p>Source file not readable.</p>" ); + return; + } + + // check editor is set + QString editor = vkConfig->value( "valkyrie/src-editor" ).toString(); + if ( editor.isEmpty() ) { + vkError( this, "Editor Launch", + "<p>Source editor not set.<br>" + "This can be set via Edit->Options->Valkyrie.</p>" ); + return; + } + + // get path,line for this frame + FrameItem* frame = (FrameItem*)vgItemCurr->parent(); + + QDomNodeList frame_details = frame->elem.childNodes(); + vk_assert( frame_details.count() >= 1 ); // only ip guaranteed + QDomElement dir = frame_details.item( 3 ).toElement(); + QDomElement srcloc = frame_details.item( 4 ).toElement(); + QDomElement line = frame_details.item( 5 ).toElement(); + + if ( dir.isNull() || srcloc.isNull() ) { + VK_DEBUG( "MemcheckView::launchEditor(): Not enough path information." ); + vkError( this, "Editor Launch", "<p>Not enough path information.</p>" ); + return; + } + + QString path( dir.text() + '/' + srcloc.text() ); + vk_assert( !path.isEmpty() ); + + // setup args to editor + QStringList args = editor.split( " " ); + QString program = args.at( 0 ); + args = args.mid( 1 ); + + if ( line.isNull() ) { + // remove any arg with "%n" in it + QStringList lineargs = args.filter(".*%n.*"); + QStringList::iterator it = lineargs.begin(); + for (; it != lineargs.end(); ++it ) { + args.removeAll( *it ); + } + } else { + args.replaceInStrings( "%n", line.text() ); + } + args << path; + + // launch editor in a new process, and detach from it. + // process will continue to live, even if Valkrie exits. + if ( ! QProcess::startDetached( program, args ) ) { + VK_DEBUG("MemcheckView::launchEditor(): Failed to launch editor: %s", + qPrintable( args.join(" ") ) ); + vkError( this, "Editor Launch", + "<p>Failed to launch editor:<br>%s %s</p>", + qPrintable( program ), + qPrintable( args.join("<br>") ) ); + } } Modified: branches/valkyrie_qt4port/toolview/vglogview.cpp =================================================================== --- branches/valkyrie_qt4port/toolview/vglogview.cpp 2010-03-08 22:24:33 UTC (rev 486) +++ branches/valkyrie_qt4port/toolview/vglogview.cpp 2010-03-09 22:31:15 UTC (rev 487) @@ -94,33 +94,12 @@ { return ( VgOutputItem* )QTreeWidgetItem::child( 0 ); } -//TODO: was :firstChild(); } -//TODO -//VgOutputItem* VgOutputItem::nextSibling() -//{ return (VgOutputItem*)QTreeWidgetItem::nextSibling(); } - VgOutputItem* VgOutputItem::parent() { return ( VgOutputItem* )QTreeWidgetItem::parent(); } -void VgOutputItem::paintCell( QPainter* p, const QColorGroup& cg, - int col, int width, int align ) -{ - //TODO -#if 0 - if ( !( isReadable || isWriteable ) ) { - QTreeWidgetItem::paintCell( p, cg, col, width, align ); - } - else { - QColorGroup cgrp( cg ); - cgrp.setColor( QColorGroup::Text, Qt::blue ); - QTreeWidgetItem::paintCell( p, cgrp, col, width, align ); - } - -#endif -} /*! Setup children of this item. @@ -133,8 +112,6 @@ */ void VgOutputItem::setupChildren() { -// cerr << "VgOutputItem::setupChildren()" << endl; - // Top-level item: no init needed. if ( parent() == 0 ) { return; @@ -740,10 +717,7 @@ for ( ; !e.isNull(); e = e.nextSibling().toElement() ) { VgFrame frame = ( VgFrame& )e; after = new FrameItem( this, after, frame ); - -// TODO: false?! -// after->setupChildren( false ); -// after->setupChildren(); + after->setupChildren(); } VgOutputItem::setupChildren(); @@ -782,16 +756,23 @@ setText( frm.describe_IP() ); - isExpandable = ( isReadable || isWriteable ); + isExpandable = isReadable; + + if ( isExpandable ) { + QColor col( "blue" ); + QBrush brush( col ); + setForeground( 0, brush ); + } else { + QColor col( "darkred" ); + QBrush brush( col ); + setForeground( 0, brush ); + } } void FrameItem::setupChildren() { -// TODO: isReadable correct here? -// isExpandable ? - - if ( childCount() == 0 && isReadable ) { + if ( childCount() == 0 && isExpandable ) { QDomElement srcdir = elem.getFirstElem( "dir" ); QDomElement srcfile = elem.getFirstElem( "file" ); QDomElement line = elem.getFirstElem( "line" ); @@ -843,27 +824,23 @@ // num lines to show above / below the target line bool ok = false; int n_lines = vkConfig->value( "valkyrie/src-lines" ).toInt( &ok ); - //TODO: check ok + //TODO: check ok is ok + // figure out where to start showing src lines int top_line = 1; - if ( target_line > n_lines + 1 ) { top_line = target_line - n_lines; } - int bot_line = target_line + n_lines; int current_line = 1; QFile file( path ); - if ( !file.open( QIODevice::ReadOnly ) ) { return; - } + } - // TODO: faster to set file pos using QFile::at(offset) - QString src_lines; QTextStream stream( &file ); @@ -885,63 +862,27 @@ isReadable = parent->isReadable; isWriteable = parent->isWriteable; - pix = 0; - - if ( isWriteable ) { - // QIcon icon_vk; - // icon_vk.addPixmap( QPixmap( QString::fromUtf8(":/vk_icons/icons/vglogview_write.xpm") ), QIcon::Normal, QIcon::Off ); - - //TODO: check ok - setIcon( 0, QPixmap( QString::fromUtf8( ":/vk_icons/icons/vglogview_write.xpm" ) ) ); - // setPixmap( write_xpm ); + // if we got this far, the source is at least readable. + vk_assert( isReadable == true ); + + if ( isWriteable ) { // read & write + setIcon( 0, QPixmap( QString::fromUtf8( ":/vk_icons/icons/vglogview_readwrite.xpm" ) ) ); } - else if ( isReadable ) { - setIcon( 0, QPixmap( QString::fromUtf8( ":/vk_icons/icons/vglogview_read.xpm" ) ) ); - // setPixmap( read_xpm ); + else { // readonly + setIcon( 0, QPixmap( QString::fromUtf8( ":/vk_icons/icons/vglogview_readonly.xpm" ) ) ); } setText( src_lines ); -} -SrcItem::~SrcItem() -{ - if ( pix ) { - delete pix; - pix = 0; - } + // pale gray background colour. + QColor col( "lightgrey" ); + QBrush brush( col ); + setBackground( 0, brush ); } -void SrcItem::paintCell( QPainter* p, const QColorGroup& cg, - int col, int width, int align ) -{ - //TODO -#if 0 - QColor bg( 240, 240, 240 ); // very pale gray - QColorGroup cgrp( cg ); // copy the original - cgrp.setColor( QColorGroup::Base, bg ); - QTreeWidgetItem::paintCell( p, cgrp, col, width, align ); -#endif -} -void SrcItem::setPixmap( const char* pix_xpm[] ) -{ - //TODO -#if 0 - pix = new QPixmap( pix_xpm ); - setup(); - widthChanged( 0 ); - invalidateHeight(); - repaint(); -#endif -} -const QPixmap* SrcItem::pixmap( int i ) const -{ - return ( i ) ? 0 : pix; -} - - // ============================================================ /*! SuppCountsItem @@ -1081,26 +1022,17 @@ */ void VgLogView::updateErrorItems( VgErrCounts ec ) { - //TODO -#if 0 - //TODO - // VgOutputItem* item = (VgOutputItem*)topStatus->firstChild(); - - while ( item ) { - if ( item->elem.elemType() == VgElement::ERROR ) { - ErrorItem* err_item = ( ErrorItem* )item; - VgError err = *(( VgError* )&err_item->elem ); + for ( int i=0; i<topStatus->childCount(); ++i ) { + VgOutputItem* vgItem = (VgOutputItem*)topStatus->child( i ); + + if ( vgItem->elem.elemType() == VgElement::ERROR ) { + ErrorItem* vgItemError = ( ErrorItem* )vgItem; + VgError vgError = *(( VgError* )&vgItemError->elem ); - if ( ! err.isLeak() ) { - QString count = ec.getCount( err ).text(); - err_item->updateCount( count ); + if ( ! vgError.isLeak() ) { + QString count = ec.getCount( vgError ).text(); + vgItemError->updateCount( count ); } } - - //TODO - // item = item->nextSibling(); } - -#endif } - Modified: branches/valkyrie_qt4port/toolview/vglogview.h =================================================================== --- branches/valkyrie_qt4port/toolview/vglogview.h 2010-03-08 22:24:33 UTC (rev 486) +++ branches/valkyrie_qt4port/toolview/vglogview.h 2010-03-09 22:31:15 UTC (rev 487) @@ -50,12 +50,10 @@ void initialise(); void setText( QString str ); - // some make-life-simpler stuff VgOutputItem* firstChild(); - VgOutputItem* nextSibling(); VgOutputItem* parent(); - void paintCell( QPainter* p, const QColorGroup& cg, - int col, int width, int align ); + + // all branch items must reimplement this: virtual void setupChildren(); // since we add children on demand, we can't use childCount() @@ -195,22 +193,14 @@ /*! class SrcItem (error::stack::frame::dir/file/line) - pale gray background colour. - - 'read'/'write' pixmap to denote user perms for src file. + - shows read/write pixmap to denote user perms for src file. - click item => source file opened in an editor, at lineno. */ class SrcItem : public VgOutputItem { public: SrcItem( VgOutputItem* parent, VgElement line, QString path ); - ~SrcItem(); - - void setPixmap( const char* pix_xpm[] ); - const QPixmap* pixmap( int i ) const; - void paintCell( QPainter* p, const QColorGroup& cg, - int col, int width, int align ); - -private: - QPixmap* pix; + // leaf item: no children to setup. }; |
From: <sv...@va...> - 2010-03-08 22:24:49
|
Author: cerion Date: 2010-03-08 22:24:33 +0000 (Mon, 08 Mar 2010) New Revision: 486 Log: Added show-src-path functionality back in to memcheckview. Modified: branches/valkyrie_qt4port/toolview/memcheckview.cpp branches/valkyrie_qt4port/toolview/memcheckview.h branches/valkyrie_qt4port/toolview/vglogview.cpp branches/valkyrie_qt4port/toolview/vglogview.h Modified: branches/valkyrie_qt4port/toolview/memcheckview.cpp =================================================================== --- branches/valkyrie_qt4port/toolview/memcheckview.cpp 2010-03-07 21:54:57 UTC (rev 485) +++ branches/valkyrie_qt4port/toolview/memcheckview.cpp 2010-03-08 22:24:33 UTC (rev 486) @@ -160,14 +160,11 @@ actMC_ShowSrcPaths = new QAction( this ); actMC_ShowSrcPaths->setObjectName( QString::fromUtf8( "actMC_ShowSrcPaths" ) ); - actMC_ShowSrcPaths->setCheckable( true ); QIcon icon_showsrcpaths; icon_showsrcpaths.addPixmap( QPixmap( QString::fromUtf8( ":/vk_icons/icons/text_more.png" ) ), QIcon::Normal, QIcon::Off ); - icon_showsrcpaths.addPixmap( QPixmap( QString::fromUtf8( ":/vk_icons/icons/text_less.png" ) ), - QIcon::Normal, QIcon::On ); actMC_ShowSrcPaths->setIcon( icon_showsrcpaths ); - connect( actMC_ShowSrcPaths, SIGNAL( triggered( bool ) ), this, SLOT( showSrcPath( bool ) ) ); + connect( actMC_ShowSrcPaths, SIGNAL( triggered() ), this, SLOT( showSrcPath() ) ); actFile_OpenLog = new QAction( this ); actFile_OpenLog->setObjectName( QString::fromUtf8( "actFile_OpenLog" ) ); @@ -260,7 +257,6 @@ actMC_OpenClose_item->setEnabled( false ); // can't enable before item clicked actMC_OpenClose_all->setEnabled( !tree_empty ); // enable only if sthng in tree actMC_ShowSrcPaths->setEnabled( !tree_empty ); // enable only if sthng in tree - actMC_ShowSrcPaths->setChecked( false ); // - and default to 'show src' actFile_SaveLog->setEnabled( !tree_empty ); } } @@ -288,14 +284,50 @@ /*! Shows/Hides the file paths for all frames under current item. */ -void MemcheckView::showSrcPath( bool show_src ) +void MemcheckView::showSrcPath() { - cerr << "MemcheckView::showSrcPath(): " << show_src << endl; - cerr << "TODO" << endl; - //TODO - - - actMC_ShowSrcPaths->setChecked( show_src ); +// cerr << "MemcheckView::showSrcPath()" << endl; + + if ( treeView->topLevelItemCount() == 0 ) { + return; + } + VgOutputItem* vgItemTop = (VgOutputItem*)treeView->topLevelItem( 0 ); + + VgOutputItem* vgItem = (VgOutputItem*)treeView->currentItem(); + if ( !vgItem ) { + vgItem = vgItemTop; + } + + // if we're top dog, show full src path for all _open_ error items. + // Note: not supporting UNshow for all. Don't think worth the effort. + if ( vgItem == vgItemTop ) { + for ( int i=0; i<vgItem->childCount(); ++i ) { + VgOutputItem* child = (VgOutputItem*)vgItem->child( i ); + if ( child->isExpanded() && + child->elemType() == VgElement::ERROR ) { + ErrorItem* error = (ErrorItem*)vgItem->child( i ); + error->showFullSrcPath( true ); + } + } + return; + } + + // else, we're not top level item... + // in case we're hanging out on a branch somewhere, + // crawl up the branch until we're a first-child item + vk_assert( vgItem->parent() != 0 ); + vk_assert( vgItem != vgItemTop ); + while ( vgItem->parent() != vgItemTop ) { + vgItem = vgItem->parent(); + } + + // if we're an _open_ ERROR-item, then show src path for this item only. + // Toggling of show full src paths suppored for this case. + if ( vgItem->isExpanded() && + vgItem->elemType() == VgElement::ERROR ) { + ErrorItem* error = (ErrorItem*)vgItem; + error->showFullSrcPath( !error->isFullSrcPathShown() ); + } } Modified: branches/valkyrie_qt4port/toolview/memcheckview.h =================================================================== --- branches/valkyrie_qt4port/toolview/memcheckview.h 2010-03-07 21:54:57 UTC (rev 485) +++ branches/valkyrie_qt4port/toolview/memcheckview.h 2010-03-08 22:24:33 UTC (rev 486) @@ -68,7 +68,7 @@ void openLogFile(); void opencloseAllItems(); void opencloseOneItem(); - void showSrcPath( bool show_src ); + void showSrcPath(); void launchEditor( QTreeWidgetItem* item ); void itemExpanded( QTreeWidgetItem* item ); void itemCollapsed( QTreeWidgetItem* item ); Modified: branches/valkyrie_qt4port/toolview/vglogview.cpp =================================================================== --- branches/valkyrie_qt4port/toolview/vglogview.cpp 2010-03-07 21:54:57 UTC (rev 485) +++ branches/valkyrie_qt4port/toolview/vglogview.cpp 2010-03-08 22:24:33 UTC (rev 486) @@ -600,7 +600,8 @@ : VgOutputItem( parent, after, err ) { err_tmplt = "%1 [%2]: %3"; - + fullSrcPathShown = false; + QString what = err.getFirstElem( "what" ).text(); QString kind = err.getFirstElem( "kind" ).text(); QString acnym = errorAcronym( kind ); @@ -692,8 +693,31 @@ return it.value(); } +/*! + Shows src paths for all frames under this error +*/ +void ErrorItem::showFullSrcPath( bool show ) +{ + // (maybe) multiple stacks + for ( int i=0; i<childCount(); ++i ) { + StackItem* stack = (StackItem*)child( i ); + if ( stack->elemType() == VgElement::STACK ) { + // multiple frames + for ( int i=0; i<stack->childCount(); ++i ) { + FrameItem* frame = (FrameItem*)stack->child( i ); + if ( frame->elemType() == VgElement::FRAME ) { + QString text = ((VgFrame*)&frame->elem)->describe_IP( show ); + frame->setText( text ); + } + } + } + } + fullSrcPathShown = show; +} + + // ============================================================ /*! StackItem @@ -727,7 +751,6 @@ } - // ============================================================ /*! FrameItem Modified: branches/valkyrie_qt4port/toolview/vglogview.h =================================================================== --- branches/valkyrie_qt4port/toolview/vglogview.h 2010-03-07 21:54:57 UTC (rev 485) +++ branches/valkyrie_qt4port/toolview/vglogview.h 2010-03-08 22:24:33 UTC (rev 486) @@ -152,14 +152,22 @@ bool isLeak() { return (( VgError* )&elem )->isLeak(); } - + + void showFullSrcPath( bool show ); + bool isFullSrcPathShown() { + return fullSrcPathShown; + } + // mapping of error::kind to 3-letter acronyms typedef QMap<QString, QString> AcronymMap; static AcronymMap acronymMap; private: QString errorAcronym( QString kind ); + +private: QString err_tmplt; + bool fullSrcPathShown; }; |
From: <sv...@va...> - 2010-03-07 21:55:06
|
Author: cerion Date: 2010-03-07 21:54:57 +0000 (Sun, 07 Mar 2010) New Revision: 485 Log: Implemented openclose_all_items for memcheckview. Both open/close one & all now just triggering actions, not toggling: much simpler, and adequate. Modified: branches/valkyrie_qt4port/toolview/memcheckview.cpp branches/valkyrie_qt4port/toolview/memcheckview.h Modified: branches/valkyrie_qt4port/toolview/memcheckview.cpp =================================================================== --- branches/valkyrie_qt4port/toolview/memcheckview.cpp 2010-03-07 16:52:32 UTC (rev 484) +++ branches/valkyrie_qt4port/toolview/memcheckview.cpp 2010-03-07 21:54:57 UTC (rev 485) @@ -64,10 +64,10 @@ // enable | disable show*Item buttons connect( treeView, SIGNAL( itemSelectionChanged() ), this, SLOT( updateItemActions() ) ); + + // on collapsing a branch, reset currentItem to branch head. connect( treeView, SIGNAL( itemCollapsed( QTreeWidgetItem* ) ), this, SLOT( itemCollapsed( QTreeWidgetItem* ) ) ); - connect( treeView, SIGNAL( itemExpanded( QTreeWidgetItem* ) ), - this, SLOT( updateItemActions() ) ); // load items on-demand connect( treeView, SIGNAL( itemExpanded( QTreeWidgetItem* ) ), @@ -142,26 +142,21 @@ // Define actions actMC_OpenClose_item = new QAction( this ); actMC_OpenClose_item->setObjectName( QString::fromUtf8( "actMC_OpenClose_item" ) ); - actMC_OpenClose_item->setCheckable( true ); QIcon icon_opencloseitem; icon_opencloseitem.addPixmap( QPixmap( QString::fromUtf8( ":/vk_icons/icons/item_open.png" ) ), QIcon::Normal, QIcon::Off ); - icon_opencloseitem.addPixmap( QPixmap( QString::fromUtf8( ":/vk_icons/icons/item_close.png" ) ), - QIcon::Normal, QIcon::On ); actMC_OpenClose_item->setIcon( icon_opencloseitem ); - connect( actMC_OpenClose_item, SIGNAL( triggered( bool ) ), - this, SLOT( openOneItem( bool ) ) ); + connect( actMC_OpenClose_item, SIGNAL( triggered() ), + this, SLOT( opencloseOneItem() ) ); actMC_OpenClose_all = new QAction( this ); actMC_OpenClose_all->setObjectName( QString::fromUtf8( "actMC_OpenClose_all" ) ); - actMC_OpenClose_all->setCheckable( true ); QIcon icon_opencloseall; icon_opencloseall.addPixmap( QPixmap( QString::fromUtf8( ":/vk_icons/icons/tree_open.png" ) ), QIcon::Normal, QIcon::Off ); - icon_opencloseall.addPixmap( QPixmap( QString::fromUtf8( ":/vk_icons/icons/tree_close.png" ) ), - QIcon::Normal, QIcon::On ); actMC_OpenClose_all->setIcon( icon_opencloseall ); - connect( actMC_OpenClose_all, SIGNAL( triggered( bool ) ), this, SLOT( openAllItems( bool ) ) ); + connect( actMC_OpenClose_all, SIGNAL( triggered() ), + this, SLOT( opencloseAllItems() ) ); actMC_ShowSrcPaths = new QAction( this ); actMC_ShowSrcPaths->setObjectName( QString::fromUtf8( "actMC_ShowSrcPaths" ) ); @@ -196,10 +191,10 @@ // ------------------------------------------------------------ // Text - actMC_OpenClose_item->setText( tr( "Open/Close" ) ); + actMC_OpenClose_item->setText( tr( "Open/Close item" ) ); actMC_OpenClose_item->setToolTip( tr( "Open/Close currently selected item" ) ); actMC_OpenClose_all->setText( tr( "Open/Close all" ) ); - actMC_OpenClose_all->setToolTip( tr( "Open/Close all items" ) ); + actMC_OpenClose_all->setToolTip( tr( "Open/Close all Valgrind::ERROR items" ) ); actMC_ShowSrcPaths->setText( tr( "Display simple" ) ); actMC_ShowSrcPaths->setToolTip( tr( "Display complex / simplified view" ) ); @@ -263,9 +258,7 @@ // ... turn on again only if they can be used bool tree_empty = ( treeView->topLevelItemCount() == 0 ); actMC_OpenClose_item->setEnabled( false ); // can't enable before item clicked - actMC_OpenClose_item->setChecked( false ); // - and default to 'open' actMC_OpenClose_all->setEnabled( !tree_empty ); // enable only if sthng in tree - actMC_OpenClose_all->setChecked( false ); // - and default to 'open' actMC_ShowSrcPaths->setEnabled( !tree_empty ); // enable only if sthng in tree actMC_ShowSrcPaths->setChecked( false ); // - and default to 'show src' actFile_SaveLog->setEnabled( !tree_empty ); @@ -310,13 +303,73 @@ Opens all error items, including their children. Ignores non-error items (status, preample, etc). */ -void MemcheckView::openAllItems( bool open_all ) +void MemcheckView::opencloseAllItems() { - cerr << "MemcheckView::openAllItems(): " << open_all << endl; - cerr << "TODO" << endl; - //TODO +// cerr << "MemcheckView::opencloseAllItems()" << endl; - actMC_OpenClose_all->setChecked( open_all ); + if ( treeView->topLevelItemCount() == 0 ) { + // empty tree. + return; + } + + VgOutputItem* vgItemTop = (VgOutputItem*)treeView->topLevelItem( 0 ); + if ( !vgItemTop || vgItemTop->childCount() == 0 ) { + cerr << "Error: listview not populated as expected" << endl; + return; + } + + // iterate over the first-child items + // check item->isOpen, start from first error, ignore suppcounts + bool anItemIsOpen = false; + int idxItemERR = -1; + for ( int i=0; i<vgItemTop->childCount(); ++i ) { + VgOutputItem* child = (VgOutputItem*)vgItemTop->child( i ); + + // find the first ERROR element + if ( (idxItemERR == -1) && + child->elemType() == VgElement::ERROR ) { + idxItemERR = i; + } + + // and check all elements from then on for isExpanded() + if ( idxItemERR != -1 ) { + // skip suppressions + if ( child->elemType() == VgElement::SUPPCOUNTS ) { + continue; + } + if ( child->isExpanded() ) { + anItemIsOpen = true; + break; + } + } + } + if ( idxItemERR == -1 ) { + // first ERROR element not found :-( + cerr << "Error: listview not populated as expected " + << "(no VgElement::ERROR found)" << endl; + return; + } + + // iterate over the same items, opening or collapsing all. + // note: only opening/collapsing first-child level, not all levels. + for ( int i=idxItemERR; i<vgItemTop->childCount(); ++i ) { + VgOutputItem* child = (VgOutputItem*)vgItemTop->child( i ); + // skip suppressions + if ( child->elemType() == VgElement::SUPPCOUNTS ) { + continue; + } + child->setExpanded( !anItemIsOpen ); + } + + + if ( anItemIsOpen ) { + // We've collapsed all ERROR branches. + // Collapsing a branch sets currentItem to branch head + // - giving currentItem == last branch to be collapsed. + // Too much work to figure out if we were previously + // inside a now collapsed branch. Just reset to top. + treeView->setCurrentItem( vgItemTop ); + } } @@ -326,16 +379,12 @@ When opening, all the children of the item are also opened. When closing, only the selected item is closed. */ -void MemcheckView::openOneItem( bool open_item ) +void MemcheckView::opencloseOneItem() { QTreeWidgetItem* item = treeView->currentItem(); if ( item == 0 ) return; - // action and item state should be in sync. - vk_assert( open_item != item->isExpanded() ); - - // this should be a slot. grr! item->setExpanded( !item->isExpanded() ); } @@ -358,8 +407,7 @@ /*! - if we collapse a branch, set current item to branch head, - and update actions for selected item + if we collapse a branch, set current item to branch head */ void MemcheckView::itemCollapsed( QTreeWidgetItem* item ) { @@ -368,10 +416,6 @@ if ( item != treeView->currentItem() ) { // this should be a slot. grr! treeView->setCurrentItem( item ); - // item now changed: updateItemActions() will be called by signal - } else { - // item remained the same: updateItemActions() by hand. - updateItemActions(); } } @@ -389,23 +433,9 @@ } else { // item ok: contract / expand it - actMC_OpenClose_item->setEnabled( true ); + VgOutputItem* vgItem = (VgOutputItem*)item; + actMC_OpenClose_item->setEnabled( vgItem->getIsExpandable() ); - if ( item->isExpanded() ) { - // set action to 'collapse' - actMC_OpenClose_item->setChecked( true ); - } - else { - // not expanded: is it expandable? - if ( ((VgOutputItem*)item)->getIsExpandable() ) { - // set action to 'expand' - actMC_OpenClose_item->setChecked( false ); - } else { - // not expanded, and not expandable -> disable action - actMC_OpenClose_item->setEnabled( false ); - - //TODO: for leaves, default to closing parent item? - } - } + //TODO: for leaves, default to closing parent item? } } Modified: branches/valkyrie_qt4port/toolview/memcheckview.h =================================================================== --- branches/valkyrie_qt4port/toolview/memcheckview.h 2010-03-07 16:52:32 UTC (rev 484) +++ branches/valkyrie_qt4port/toolview/memcheckview.h 2010-03-07 21:54:57 UTC (rev 485) @@ -66,8 +66,8 @@ private slots: void openLogFile(); - void openAllItems( bool open_all ); - void openOneItem( bool open_item ); + void opencloseAllItems(); + void opencloseOneItem(); void showSrcPath( bool show_src ); void launchEditor( QTreeWidgetItem* item ); void itemExpanded( QTreeWidgetItem* item ); |
From: <sv...@va...> - 2010-03-07 16:52:40
|
Author: cerion Date: 2010-03-07 16:52:32 +0000 (Sun, 07 Mar 2010) New Revision: 484 Log: Implemented support for on-demand loading of the logview items (VgOutputItems) from the underlying model (VgElements) Had to catch the treeView::itemExpanded() signal and pass it on to our implementation of QTreeWidgetItem (VgOutputItem). This code should be in VgOutputItem class, but QTreeWidgetItem no longer provides a virtual setExpanded() method :-( Still to do in memcheckview: openAll, showSrc, launchEditor. Modified: branches/valkyrie_qt4port/mainwindow.cpp branches/valkyrie_qt4port/toolview/memcheckview.cpp branches/valkyrie_qt4port/toolview/memcheckview.h branches/valkyrie_qt4port/toolview/vglogview.cpp branches/valkyrie_qt4port/toolview/vglogview.h branches/valkyrie_qt4port/utils/vglog.cpp Modified: branches/valkyrie_qt4port/mainwindow.cpp =================================================================== --- branches/valkyrie_qt4port/mainwindow.cpp 2010-03-07 14:52:00 UTC (rev 483) +++ branches/valkyrie_qt4port/mainwindow.cpp 2010-03-07 16:52:32 UTC (rev 484) @@ -926,8 +926,9 @@ if ( vkConfig->value( "valkyrie/binary" ).toString().isEmpty() ) { vkInfo( this, "Run Valgrind: No program specified", - "Please specify (via Options->Valkyrie->Binary) the path to the program<br>" - "you wish to run, along with any arguments required" ); + "Please specify (via Options->Valkyrie->Binary)<br>" + "the path to the program you wish to run, along<br>" + "with any arguments required" ); openOptions(); return; Modified: branches/valkyrie_qt4port/toolview/memcheckview.cpp =================================================================== --- branches/valkyrie_qt4port/toolview/memcheckview.cpp 2010-03-07 14:52:00 UTC (rev 483) +++ branches/valkyrie_qt4port/toolview/memcheckview.cpp 2010-03-07 16:52:32 UTC (rev 484) @@ -20,6 +20,7 @@ #include "toolview/memcheckview.h" #include "utils/vk_config.h" +#include "utils/vk_utils.h" #include <QAction> #include <QApplication> @@ -60,13 +61,23 @@ setupActions(); setupToolBar(); - /* enable | disable show*Item buttons */ + // enable | disable show*Item buttons connect( treeView, SIGNAL( itemSelectionChanged() ), - this, SLOT( itemSelected() ) ); - /* launch editor with src file loaded */ + this, SLOT( updateItemActions() ) ); + connect( treeView, SIGNAL( itemCollapsed( QTreeWidgetItem* ) ), + this, SLOT( itemCollapsed( QTreeWidgetItem* ) ) ); + connect( treeView, SIGNAL( itemExpanded( QTreeWidgetItem* ) ), + this, SLOT( updateItemActions() ) ); + + // load items on-demand + connect( treeView, SIGNAL( itemExpanded( QTreeWidgetItem* ) ), + this, SLOT( itemExpanded( QTreeWidgetItem* ) ) ); + + // launch editor with src file loaded connect( treeView, SIGNAL( itemDoubleClicked( QTreeWidgetItem*, int ) ), this, SLOT( launchEditor( QTreeWidgetItem* ) ) ); - + + logview = new VgLogView( treeView ); } @@ -88,7 +99,7 @@ */ void MemcheckView::openLogFile() { - cerr << "MemcheckView::openLogFile()" << endl; +// cerr << "MemcheckView::openLogFile()" << endl; QString captn = "Select Log File"; QString filt = "XML Files (*.xml);;Log Files (*.log.*);;All Files (*)"; @@ -117,23 +128,8 @@ treeView = new QTreeWidget( this ); treeView->setObjectName( QString::fromUtf8( "treeMemcheck" ) ); treeView->setHeaderHidden( true ); + treeView->setRootIsDecorated( false ); vLayout->addWidget( treeView ); - - - // TODO: remove -#if 0 - // --- <test_setup> --- - treeView->setColumnCount( 1 ); - treeView->setRootIsDecorated( true ); - QTreeWidgetItem* item; - - for ( int i = 0; i < 10; ++i ) { - item = new QTreeWidgetItem( treeView, QStringList( QString( "memcheck: %1" ).arg( i ) ) ); - new QTreeWidgetItem( item, QStringList( QString( "boo! %1-1" ).arg( i ) ) ); - } - - // --- </test_setup> --- -#endif } @@ -153,7 +149,8 @@ icon_opencloseitem.addPixmap( QPixmap( QString::fromUtf8( ":/vk_icons/icons/item_close.png" ) ), QIcon::Normal, QIcon::On ); actMC_OpenClose_item->setIcon( icon_opencloseitem ); - connect( actMC_OpenClose_item, SIGNAL( triggered( bool ) ), this, SLOT( openOneItem( bool ) ) ); + connect( actMC_OpenClose_item, SIGNAL( triggered( bool ) ), + this, SLOT( openOneItem( bool ) ) ); actMC_OpenClose_all = new QAction( this ); actMC_OpenClose_all->setObjectName( QString::fromUtf8( "actMC_OpenClose_all" ) ); @@ -264,7 +261,7 @@ unsetCursor(); // ... turn on again only if they can be used - bool tree_empty = ( treeView->children().count() == 0 ); + bool tree_empty = ( treeView->topLevelItemCount() == 0 ); actMC_OpenClose_item->setEnabled( false ); // can't enable before item clicked actMC_OpenClose_item->setChecked( false ); // - and default to 'open' actMC_OpenClose_all->setEnabled( !tree_empty ); // enable only if sthng in tree @@ -290,20 +287,35 @@ { cerr << "MemcheckView::launchEditor( QTreeWidgetItem* ): " << code_item->text( 0 ).toLatin1().data() << endl; + cerr << "TODO" << endl; //TODO } /*! + Shows/Hides the file paths for all frames under current item. +*/ +void MemcheckView::showSrcPath( bool show_src ) +{ + cerr << "MemcheckView::showSrcPath(): " << show_src << endl; + cerr << "TODO" << endl; + //TODO + + + actMC_ShowSrcPaths->setChecked( show_src ); +} + + +/*! Opens all error items, including their children. Ignores non-error items (status, preample, etc). */ void MemcheckView::openAllItems( bool open_all ) { cerr << "MemcheckView::openAllItems(): " << open_all << endl; + cerr << "TODO" << endl; //TODO - - + actMC_OpenClose_all->setChecked( open_all ); } @@ -316,32 +328,84 @@ */ void MemcheckView::openOneItem( bool open_item ) { - cerr << "MemcheckView::openOneItem(): " << open_item << endl; - //TODO - - - actMC_OpenClose_item->setChecked( open_item ); + QTreeWidgetItem* item = treeView->currentItem(); + if ( item == 0 ) + return; + + // action and item state should be in sync. + vk_assert( open_item != item->isExpanded() ); + + // this should be a slot. grr! + item->setExpanded( !item->isExpanded() ); } /*! - Shows/Hides the file paths for all frames under current item. + void MemcheckView::itemExpanded( QTreeWidgetItem* item ) + + Supports on-demand loading our VgOutputItems from our underlying model (VgElements) + Have to catch the treeView::itemExpanded() signal and pass it on to our + implementation of QTreeWidgetItem (VgOutputItem). + + This should be in VgOutputItem class, but QTreeWidgetItem no longer + provides a virtual setExpanded() method :-( */ -void MemcheckView::showSrcPath( bool show_src ) +void MemcheckView::itemExpanded( QTreeWidgetItem* item ) { - cerr << "MemcheckView::showSrcPath(): " << show_src << endl; - //TODO - - - actMC_ShowSrcPaths->setChecked( show_src ); +// cerr << "MemcheckView::itemExpanded(): " << endl; + ((VgOutputItem*)item)->setupChildren(); } /*! - Updates actions (e.g. show-source) dependent on current selected item. + if we collapse a branch, set current item to branch head, + and update actions for selected item */ -void MemcheckView::itemSelected() +void MemcheckView::itemCollapsed( QTreeWidgetItem* item ) { - cerr << "MemcheckView::itemSelected()" << endl; - //TODO +// cerr << "MemcheckView::itemCollapsed(): " << endl; + + if ( item != treeView->currentItem() ) { + // this should be a slot. grr! + treeView->setCurrentItem( item ); + // item now changed: updateItemActions() will be called by signal + } else { + // item remained the same: updateItemActions() by hand. + updateItemActions(); + } } + + +/*! + Updates actions dependent on currently selected item. +*/ +void MemcheckView::updateItemActions() +{ +// cerr << "MemcheckView::updateItemActions(): " << endl; + + QTreeWidgetItem* item = treeView->currentItem(); + if ( !item ) { + actMC_OpenClose_item->setEnabled( false ); + } + else { + // item ok: contract / expand it + actMC_OpenClose_item->setEnabled( true ); + + if ( item->isExpanded() ) { + // set action to 'collapse' + actMC_OpenClose_item->setChecked( true ); + } + else { + // not expanded: is it expandable? + if ( ((VgOutputItem*)item)->getIsExpandable() ) { + // set action to 'expand' + actMC_OpenClose_item->setChecked( false ); + } else { + // not expanded, and not expandable -> disable action + actMC_OpenClose_item->setEnabled( false ); + + //TODO: for leaves, default to closing parent item? + } + } + } +} Modified: branches/valkyrie_qt4port/toolview/memcheckview.h =================================================================== --- branches/valkyrie_qt4port/toolview/memcheckview.h 2010-03-07 14:52:00 UTC (rev 483) +++ branches/valkyrie_qt4port/toolview/memcheckview.h 2010-03-07 16:52:32 UTC (rev 484) @@ -70,8 +70,10 @@ void openOneItem( bool open_item ); void showSrcPath( bool show_src ); void launchEditor( QTreeWidgetItem* item ); - void itemSelected(); - + void itemExpanded( QTreeWidgetItem* item ); + void itemCollapsed( QTreeWidgetItem* item ); + void updateItemActions(); + signals: void saveLogFile(); Modified: branches/valkyrie_qt4port/toolview/vglogview.cpp =================================================================== --- branches/valkyrie_qt4port/toolview/vglogview.cpp 2010-03-07 14:52:00 UTC (rev 483) +++ branches/valkyrie_qt4port/toolview/vglogview.cpp 2010-03-07 16:52:32 UTC (rev 484) @@ -82,6 +82,7 @@ void VgOutputItem::initialise() { isReadable = isWriteable = false; + isExpandable = false; } void VgOutputItem::setText( QString str ) @@ -121,9 +122,32 @@ #endif } -void VgOutputItem::setOpen( bool open ) +/*! + Setup children of this item. + Derived items use this to load children from the model on demand. + Rem to call this base class version at the end of derived methods, + in order to finish initialisation of children. + + Ideally, we'd have overloaded QWidgetTreeItem::setExpanded(), + but it's no longer virtual in Qt4 :-( +*/ +void VgOutputItem::setupChildren() { - QTreeWidgetItem::setExpanded( open ); +// cerr << "VgOutputItem::setupChildren()" << endl; + + // Top-level item: no init needed. + if ( parent() == 0 ) { + return; + } + + // now we've loaded any child items from the model, + // we can open up any child items that themselves have children + for ( int i=0; i<this->childCount(); ++i ) { + QTreeWidgetItem* chld = this->child( i ); + if ( chld->childCount() > 0 ) { + chld->setExpanded( true ); + } + } } @@ -158,9 +182,8 @@ .arg( num_blocks ); setText( status_str + "\n" + err_str ); - - //TODO: - // setMultiLinesEnabled( true ); + + isExpandable = true; } // finished @@ -400,39 +423,36 @@ setText( content ); - //TODO - // setExpandable( true ); + isExpandable = true; } -void InfoItem::setOpen( bool open ) +void InfoItem::setupChildren() { - if ( open && childCount() == 0 ) { + if ( childCount() == 0 ) { VgOutputItem* after = 0; // handle any number of log-file-qualifiers VgElement logqual = elem.getFirstElem( "logfilequalifier" ); - while ( !logqual.isNull() && logqual.tagName() == "logfilequalifier" ) { after = new LogQualItem( this, logqual ); - after->setOpen( true ); + after->setupChildren(); logqual = logqual.getNextSibling(); } + // may / may not have a user comment VgElement comment = elem.getFirstElem( "usercomment" ); - - // may / may not have a user comment if ( ! comment.isNull() ) { after = new CommentItem( this, after, comment ); - after->setOpen( true ); + after->setupChildren(); } + // args VgElement args = elem.getFirstElem( "args" ); - // args after = new ArgsItem( this, after, args ); - after->setOpen( true ); + after->setupChildren(); + + VgOutputItem::setupChildren(); } - - VgOutputItem::setOpen( open ); } @@ -445,11 +465,13 @@ : VgOutputItem( parent, logqual ) { setText( "logfilequalifier" ); + + isExpandable = true; } -void LogQualItem::setOpen( bool open ) +void LogQualItem::setupChildren() { - if ( open && childCount() == 0 ) { + if ( childCount() == 0 ) { VgOutputItem* last_item = 0; QDomElement e = elem.firstChild().toElement(); @@ -458,11 +480,9 @@ last_item = new VgOutputItem( this, last_item, elem ); last_item->setText( elem.text() ); } + + VgOutputItem::setupChildren(); } - - VgOutputItem::setOpen( open ); - //TODO - // setExpandable( true ); } @@ -478,16 +498,14 @@ setText( "usercomment" ); } -void CommentItem::setOpen( bool open ) +void CommentItem::setupChildren() { - if ( open && childCount() == 0 ) { + if ( childCount() == 0 ) { VgOutputItem* item = new VgOutputItem( this, elem ); item->setText( elem.text() ); } - - VgOutputItem::setOpen( open ); - //TODO - // setExpandable( true ); + + VgOutputItem::setupChildren(); } @@ -501,13 +519,12 @@ : VgOutputItem( parent, after, args ) { setText( "args" ); - //TODO - // setExpandable( true ); + isExpandable = true; } -void ArgsItem::setOpen( bool open ) +void ArgsItem::setupChildren() { - if ( open && childCount() == 0 ) { + if ( childCount() == 0 ) { VgElement vgInfo = elem.getFirstElem( "vargv" ); VgElement exInfo = elem.getFirstElem( "argv" ); @@ -527,9 +544,9 @@ last_item = new VgOutputItem( this, last_item, elem ); last_item->setText( e.text() ); } + + VgOutputItem::setupChildren(); } - - VgOutputItem::setOpen( open ); } @@ -545,13 +562,13 @@ VgPreamble preamble ) : VgOutputItem( parent, after, preamble ) { - //TODO - // setExpandable( true ); setText( "Preamble" ); + isExpandable = true; } -void PreambleItem::setOpen( bool open ) + +void PreambleItem::setupChildren() { - if ( open && childCount() == 0 ) { + if ( childCount() == 0 ) { VgOutputItem* last_item = 0; QDomElement e = elem.firstChild().toElement(); @@ -560,9 +577,9 @@ last_item = new VgOutputItem( this, last_item, elem ); last_item->setText( e.text() ); } + + VgOutputItem::setupChildren(); } - - VgOutputItem::setOpen( open ); } @@ -594,9 +611,8 @@ else { setText( err_tmplt.arg( acnym ).arg( 1 ).arg( what ) ); } - - //TODO - // setExpandable( true ); + + isExpandable = true; } void ErrorItem::updateCount( QString count ) @@ -609,15 +625,15 @@ } } -void ErrorItem::setOpen( bool open ) +void ErrorItem::setupChildren() { - if ( open && childCount() == 0 ) { + if ( childCount() == 0 ) { VgOutputItem* after = this; // main stack VgElement main_stack = elem.getFirstElem( "stack" ); VgOutputItem* stack_item1 = new StackItem( this, after, main_stack ); - stack_item1->setOpen( true ); + stack_item1->setupChildren(); after = stack_item1; // aux what & stack @@ -633,7 +649,7 @@ VgElement auxstack = ( VgElement& )aux_stack; StackItem* si = new StackItem( this, after, auxstack ); after = si; - si->setOpen( true ); + si->setupChildren(); } } @@ -649,17 +665,17 @@ after = ori_item; StackItem* si = new StackItem( this, after, ori_stack ); - si->setOpen( true ); + si->setupChildren(); } + VgOutputItem::setupChildren(); + /* We should really check that we've used up all the children at this level. But that's difficult since we don't scan through them from one end to another using any 'cursor' kind of arrangement, so we can't easily check that the 'cursor' is at the last sibling. */ } - - VgOutputItem::setOpen( open ); } /*! @@ -687,24 +703,27 @@ : VgOutputItem( parent, after, stck ) { setText( "stack" ); - //TODO - // setExpandable( true ); + + isExpandable = true; } -void StackItem::setOpen( bool open ) +void StackItem::setupChildren() { - if ( open && childCount() == 0 ) { + if ( childCount() == 0 ) { VgOutputItem* after = this; QDomElement e = elem.firstChild().toElement(); for ( ; !e.isNull(); e = e.nextSibling().toElement() ) { VgFrame frame = ( VgFrame& )e; after = new FrameItem( this, after, frame ); - after->setOpen( false ); + +// TODO: false?! +// after->setupChildren( false ); +// after->setupChildren(); } + + VgOutputItem::setupChildren(); } - - VgOutputItem::setOpen( open ); } @@ -739,13 +758,17 @@ } setText( frm.describe_IP() ); - //TODO - // setExpandable( isReadable || isWriteable ); + + isExpandable = ( isReadable || isWriteable ); } -void FrameItem::setOpen( bool open ) + +void FrameItem::setupChildren() { - if ( open && childCount() == 0 && isReadable ) { +// TODO: isReadable correct here? +// isExpandable ? + + if ( childCount() == 0 && isReadable ) { QDomElement srcdir = elem.getFirstElem( "dir" ); QDomElement srcfile = elem.getFirstElem( "file" ); QDomElement line = elem.getFirstElem( "line" ); @@ -770,10 +793,11 @@ // create the item for the src lines SrcItem* src_item = new SrcItem( this, srcline, path ); - src_item->setOpen( true ); + src_item->setupChildren(); + + + VgOutputItem::setupChildren(); } - - VgOutputItem::setOpen( open ); } @@ -854,8 +878,6 @@ } setText( src_lines ); - //TODO - // setMultiLinesEnabled( true ); } SrcItem::~SrcItem() @@ -909,13 +931,13 @@ : VgOutputItem( parent, after, sc ) { setText( "Suppressed errors" ); - //TODO: - // setExpandable( true ); + + isExpandable = true; } -void SuppCountsItem::setOpen( bool open ) +void SuppCountsItem::setupChildren() { - if ( open && childCount() == 0 ) { + if ( childCount() == 0 ) { VgOutputItem* child_item = 0; QDomNodeList pairs = elem.childNodes(); QDomElement e = pairs.item( 0 ).toElement(); @@ -929,9 +951,9 @@ child_item = new VgOutputItem( this, child_item, pair ); child_item->setText( supp_str ); } + + VgOutputItem::setupChildren(); } - - VgOutputItem::setOpen( open ); } @@ -960,9 +982,10 @@ QDomElement e = node.toElement(); VgElement elem = ( VgElement& )e; - - // populate listview - + + // populate listview with top-level items, from our model (VgElements) + // children of these items are only populated on-demand + switch ( elem.elemType() ) { case VgElement::STATUS: { VgStatus status = ( VgStatus& )elem; @@ -972,8 +995,11 @@ VgElement exe = args().getFirstElem( "argv" ).getFirstElem( "exe" ); topStatus = new TopStatusItem( view, status, exe, protocol().text() ); - topStatus->setOpen( true ); + topStatus->setExpanded( true ); + lastChild = new InfoItem( topStatus, docroot() ); + lastChild->setChildIndicatorPolicy( QTreeWidgetItem::ShowIndicator ); + lastChild = new PreambleItem( topStatus, lastChild, preamble() ); } else { @@ -986,7 +1012,7 @@ case VgElement::ERROR: { VgError err = ( VgError& )elem; lastChild = new ErrorItem( topStatus, lastChild, err ); - + if ( err.isLeak() ) { // update topStatus topStatus->updateLeakCounts( err ); @@ -1016,7 +1042,11 @@ default: break; } - + + if ( lastChild ) { + lastChild->setChildIndicatorPolicy( QTreeWidgetItem::ShowIndicator ); + } + return true; } Modified: branches/valkyrie_qt4port/toolview/vglogview.h =================================================================== --- branches/valkyrie_qt4port/toolview/vglogview.h 2010-03-07 14:52:00 UTC (rev 483) +++ branches/valkyrie_qt4port/toolview/vglogview.h 2010-03-07 16:52:32 UTC (rev 484) @@ -33,8 +33,8 @@ // ============================================================ /* VgOutputItem: base class - item classes set up their own state and text in their construtors, - and item->setOpen() sets up item's children. + item classes set up their own state and text in their constructors, + and item->setupChildren() sets up item's children. - only spends time populating an item when made visible - no item opened before setup (inc. children's) finished. only a couple of sub-classes currently implement different @@ -56,13 +56,19 @@ VgOutputItem* parent(); void paintCell( QPainter* p, const QColorGroup& cg, int col, int width, int align ); - void setOpen( bool open ); + virtual void setupChildren(); + + // since we add children on demand, we can't use childCount() + virtual bool getIsExpandable() { + return isExpandable; + } VgElement::ElemType elemType() { return elem.elemType(); } public: + bool isExpandable; bool isReadable, isWriteable; VgElement elem; // associated element }; @@ -92,7 +98,7 @@ { public: InfoItem( VgOutputItem* parent, VgElement root ); - void setOpen( bool open ); + void setupChildren(); }; @@ -101,7 +107,7 @@ { public: LogQualItem( VgOutputItem* parent, VgElement logqual ); - void setOpen( bool open ); + void setupChildren(); }; @@ -111,7 +117,7 @@ public: CommentItem( VgOutputItem* parent, QTreeWidgetItem* after, VgElement cmnt ); - void setOpen( bool open ); + void setupChildren(); }; @@ -121,7 +127,7 @@ public: ArgsItem( VgOutputItem* parent, QTreeWidgetItem* after, VgElement vgargs ); - void setOpen( bool open ); + void setupChildren(); }; @@ -131,7 +137,7 @@ public: PreambleItem( VgOutputItem* parent, QTreeWidgetItem* after, VgPreamble preamble ); - void setOpen( bool open ); + void setupChildren(); }; @@ -141,7 +147,7 @@ public: ErrorItem( VgOutputItem* parent, QTreeWidgetItem* after, VgError err ); - void setOpen( bool open ); + void setupChildren(); void updateCount( QString count ); bool isLeak() { return (( VgError* )&elem )->isLeak(); @@ -163,7 +169,7 @@ public: StackItem( VgOutputItem* parent, QTreeWidgetItem* after, VgElement stck ); - void setOpen( bool open ); + void setupChildren(); }; @@ -173,7 +179,7 @@ public: FrameItem( VgOutputItem* parent, QTreeWidgetItem* after, VgFrame frm ); - void setOpen( bool open ); + void setupChildren(); }; @@ -206,7 +212,7 @@ public: SuppCountsItem( VgOutputItem* parent, QTreeWidgetItem* after, VgSuppCounts sc ); - void setOpen( bool open ); + void setupChildren(); }; Modified: branches/valkyrie_qt4port/utils/vglog.cpp =================================================================== --- branches/valkyrie_qt4port/utils/vglog.cpp 2010-03-07 14:52:00 UTC (rev 483) +++ branches/valkyrie_qt4port/utils/vglog.cpp 2010-03-07 16:52:32 UTC (rev 484) @@ -697,8 +697,8 @@ vkPrintErr( "VgLog::appendNode(): bad xml protocol version" ); return false; } - break; + case VgElement::PREAMBLE: case VgElement::PID: case VgElement::PPID: @@ -711,6 +711,7 @@ case VgElement::ERRORCOUNTS: case VgElement::SUPPCOUNTS: break; + default: vkPrintErr( "VgLog::appendNode(): not a top-level tagname: %s", qPrintable( elem.tagName() ) ); |
From: <sv...@va...> - 2010-03-07 14:52:09
|
Author: cerion Date: 2010-03-07 14:52:00 +0000 (Sun, 07 Mar 2010) New Revision: 483 Log: unbreak memcheck::openLogFile - no direct access to valkyrie's options. needs a better options/config solution. Modified: branches/valkyrie_qt4port/objects/memcheck_object.cpp Modified: branches/valkyrie_qt4port/objects/memcheck_object.cpp =================================================================== --- branches/valkyrie_qt4port/objects/memcheck_object.cpp 2010-03-05 01:17:52 UTC (rev 482) +++ branches/valkyrie_qt4port/objects/memcheck_object.cpp 2010-03-07 14:52:00 UTC (rev 483) @@ -471,8 +471,7 @@ vk_assert( getToolView() != 0 ); //TODO: pass this via flags from the toolview, or something. - VkOption* opt = options.getOption( VALKYRIE::VIEW_LOG ); - QString log_file = vkConfig->value( opt->configKey() ).toString(); + QString log_file = vkConfig->value( "valkyrie/view-log" ).toString(); statusMsg( "Parsing '" + log_file + "'" ); //TODO: file checks |