'operator=' is deprecated: Use QDir::setPath() instead - c++

Simple program that opens a GUI, you click one button to set curDir, click another button to set savDir, and a third button does some C++ code similar to
ls -l curDir > savDir.txt
One of my Qt functions:
void dirList::on_savBut_clicked(){
savDir = QFileDialog::getExistingDirectory(
this,"Save Location",QDir::homePath());
savPath = savDir.absolutePath();
ui->savText->setText(savPath);
}
On the savDir = QFileDialog::getExistingDirectory(... line I get a warning:
'operator=' is depreciated: Use QDir::setPath() instead
Could anyone give an example how I might incorporate setPath()?

You can simply write
savPath = QFileDialog::getExistingDirectory(
this,"Save Location",QDir::homePath());
Without using savDir.

I believe setPath is just a drop in replacement instead of using assignment for when updating a QDir with a QString path.
savDir = QFileDialog::getExistingDirectory(
this,"Save Location",QDir::homePath());
simply becomes
savDir.setPath(QFileDialog::getExistingDirectory(
this,"Save Location",QDir::homePath()));

Related

QFileDialog in c++: "no matching function for call"

I want to let the user choose a folder so I can display and sort its contents somewhere else. The best way to do this seems to be using QFileDialog. Here's a snippet of the code I'm using:
> #include <QFileDialog>
.....
void someEvent(){
QString path = QFileDialog::getExistingDirectoryUrl(this, tr("Choose a Folder"), QDir::home());
}
When I try to compile this I get the error:
no matching function for call to QFileDialog::getExistingDirectoryUrl(MainWindow*, QString, QDir) path = QFileDialog::getExistingDirectoryUrl(this, tr("Choose a Folder"), QDir::home());
Note: I'm running Fedora 25 on this PC and I'm wondering whether that might be the issue?
You have 2 choices depending on your needs, the first one being the best :
getExistingDirectory :
QString path = QFileDialog::getExistingDirectory(this,tr("Choose a Folder"),QDir::homePath());
getExistingDirectoryUrl :
QUrl url = QFileDialog::getExistingDirectoryUrl(this,tr("Choose a Folder"),QUrl(QDir::homePath()));
QString path = url.toString();

Does webstorm have some shortcut for console.log or console.info?

Just tired of typing console.log again and again, and do not find a way like Sysout + Control + Space in Eclipse will create System.out.println().
There's a predefined Postfix template that allows you to type .log after a JavaScript expression or string and hit Tab to transform it to console.log().
You can also create a Live template (see Preferences | Editor | Live templates) that would expand into a code snippet once you type the selected abbreviation and hit Tab.
Update: there's now also a plugin that allows you to add console.log with a shortcut: https://plugins.jetbrains.com/plugin/10986-console-log
Yes it does,
<anything>.log and press Tab key. This will result in console.log(<anything>);
ie,
<anything>.log + Tab => console.log(<anything>);
eg1: variable
let my_var = 'Hello, World!';
my_var.log + Tab => console.log(my_var);
eg2: string
'hello'.log + Tab => console.log('hello');
eg3: string and variable
'hello', my_var.log + Tab => console.log('hello', my_var);
[UPDATE 2020]
Typing log + Enter autocompletes to console.log()
I made my own template that seems to work.
It may be useful for somebody.
Abbreviation: ll
Template text:
console.log('$NAME$ ', $VALUE$);
$END$
Variables: (just select the given field values by clicking drop down box)
NAME - jsDefineParameter()
VALUE - jsSuggestVariableName
I'm including what I find to be the most efficient, which I added via live templates -> javascript -> applicable to "Everything". Hopefully someone finds it useful.
console.log('L$LINE$ $MYSTRING$ ===', $MYVAR$);$END$
What it does:
When I type cl and press tab, it creates the log and the first thing you type fills both MYSTRING and MYVAR variables. If you tab again, it selects MYVAR where you can rewrite/delete as desired. The third time you hit tab will take you to the end of the line at $END.
This snippet also prints the line number like L123 but you can easily remove that if it isn't helpful because obviously most browsers show line number anyway.
You also have to set the variables' behaviour as seen in the image below:
Edit variables setup
use Macros!
https://www.jetbrains.com/help/webstorm/using-macros-in-the-editor.html
I recorded a macro that takes the name my cursor is on and create
console.log("#### name = ", name);
on the next line.
and assigned a keyboard shortcut to it :)
super easy, and couldn't get Live Template to get the same result with 1 action.
to create a new macro: Edit -> Macros -> Start Macro Recording. then record your next moves and create the desired result.
this is mine:
This is my solution, it somewhat mimics a turbo-console approach and gives you certain freedoms to build on it.
Step 1: Go to Editor > General > Postfix Completion;
Step 2: Click on JavaScript, click the + button, select JavaScript and TypeScript;
Step 3: In the Key input, type a alias for your command, I choose 'cl' for mine;
Step 4: In the 'Minimum language level' select your desired preference, I choose ECMAScript 6+;
Step 5: In the bellow text area, add your logic, for me it is console.log('$EXPR$', $EXPR$, '$END$');
Step 6: Customize however you like.
So what does all of this do?
Lets consider the following:
const willNeedToBeLogged = 'some value you want to check';
All you need to do for a console long is type
willNeedToBeLogged.cl + press (Tab, Enter or Spance)
And you will get this
console.log('willNeedToBeLogged', willNeedToBeLogged, '');
With your cursor being on the $END$ variable, where you could write, a line, or anything you like.
Have fun!
I made a custom template. This can help you.
Abbreviation: clog
Template code:
console.log("\n\n--------------------------------");
console.log($END$);
console.log("--------------------------------\n\n");
Simplest live template text:
console.log($END$);
Maybe it is a recent addition but you can write log and hit tab and console.log() will appear with the caret in between the braces.
The answer from Ekaterina Prigara (https://stackoverflow.com/a/32975087/5653914) was very useful to me but if you want to log a string like "Test" this method is quicker.
Try a logit plugin. It provides the next logging pattern by default:
const data = 'data';
console.log('-> data', data);
You can configure it.
Try Dot Log (vscode extension), It can automatically transfer aaa.log to console.log('aaa', aaa )

Navigation using path parameter on Pretty Faces 2.0.8.Final

Consider the configuration below:
#URLMapping(id = "programaManter", parentId = "homeTreinamento", pattern = "/programa/#{id : programaManter.id}", viewId = "/pages/treinamento/ProgramaManter.xhtml")
Lets say that I need to navigate to /programa/1. I've tried the following:
return "/pages/treinamento/ProgramaManter.xhtml?faces-redirect=true&id=" + id;
But instead of navigating to /programa/1 it's navigating to /programa/?id=1, how can I force it to build the url using path parameter instead of query parameter?
Solution posted here on the OCPsoft support forums: http://ocpsoft.org/support/topic/navigation-using-path-parameter-on-pretty-faces-2-0-8-final/#post-25822

How can I change the Print Spooler filename/document name associated with wxPrintout in wxwidgets

I have managed to attach my filename to my print out by overloading the wxPrintout constructor with my chosen name.
wxPrintout(const wxString& title = wxT("Printout"));
In my code:
VRPrintout::VRPrintout(blababala):wxPrintout(_("Heartrate")),
But on printing to save as a PDF, in the filename dialog, it reads "Printing Heartrate".
How can I get rid of "Printing" added before the name or even change it?
#Credits to Xaviou from wxDev.fr.
You can try overriding the "OnBeginDocument" method in your wxPrintout derived class.
The default code is the following (the "OnBeginDocument" is virtual) in wx-src/common/prntbase.cpp:584 :
bool wxPrintout::OnBeginDocument(int WXUNUSED(startPage), int WXUNUSED(endPage))
{
return GetDC()->StartDoc(_("Printing ") + m_printoutTitle);
}
I think that if you provide yours with the correct text, it should be ok.
Regards
Xav'
Edit : Tested on an app of mine that do printing stuff, and it works...
Worked for me too

SugarCRM customization of Basic template

I need to add a field in basic template. Can anyone help me how can i add another field in include/SugarObjects/templates/basic/vardefs.php in upgrade safe manner.
In VardefManager's function addTemplate not like general standards of Sugar it is not requiring the custom paths
include/SugarObjects/VardefManager.php near line 107 SugarCE6.5.5:
if(empty($templates[$template])){
$path = 'include/SugarObjects/templates/' . $template . '/vardefs.php';
if(file_exists($path)){
require($path);
$templates[$template] = $vardefs;
}else{
$path = 'include/SugarObjects/implements/' . $template . '/vardefs.php';
if(file_exists($path)){
require($path);
$templates[$template] = $vardefs;
}
}
}
Really waiting for awesome responses.
Create a file at the path custom/include/SugarObjects/VardefManager.php with the name VardefManager.php and in that file include your mail file it is include/SugarObjects/VardefManager.php.
Here you will create a class with same and and create a function with the name
static function addTemplate
with same the arguments pass in the main file. and override the method here with your custom code (as you want to add some lines of code in that).
This will be upgrade safe and will be workable to you.