Here’s the Vigenere crypto algorithm as suggested by Allan:
function Vigenere(Src, Key : string; Encrypt : boolean) : string;
const
OrdMinChar : integer = Ord('A');
OrdMaxChar : integer = Ord('Z');
IncludeChars : set of char = ['A'..'Z'];
var
CharRangeCount, i, j, KeyLen, KeyInc, SrcOrd, CryptOrd : integer;
SrcA : string;
begin
CharRangeCount := OrdMaxChar - OrdMinChar + 1;
KeyLen := Length(Key);
SetLength(SrcA, Length(Src));
If Encrypt then
begin
// transfer only included characters to SrcA for encryption
j := 1;
for i := 1 to Length(Src) do
begin
if (Src[i] in IncludeChars) then
begin
SrcA[j] := Src[i];
inc(j);
end;
end;
SetLength(SrcA, j - 1);
end;
SetLength(Result, Length(SrcA));
if Encrypt then
begin
// Encrypt to Result
for i := 1 to Length(SrcA) do
begin
SrcOrd := Ord(Src[i]) - OrdMinChar;
KeyInc := Ord(Key[((i - 1 ) mod KeyLen)+ 1]) - OrdMinChar;
CryptOrd := ((SrcOrd + KeyInc) mod CharRangeCount) + OrdMinChar;
Result[i] := Char(CryptOrd);
end;
end;
else
begin
// Decrypt to Result
for i := 1 to Length(SrcA) do
begin
SrcOrd := Ord(Src[i]) - OrdMinChar;
KeyInc := Ord(Key[((i - 1 ) mod KeyLen)+ 1]) - OrdMinChar;
CryptOrd := ((SrcOrd - KeyInc + CharRangeCount)
mod CharRangeCount) + OrdMinChar;
// KeyInc may be larger than SrcOrd
Result[i] := Char(CryptOrd);
end;
end;
end;
class MainWindow : public QMainWindow
{
Q_OBJECT;
public:
MainWindow(QWidget *parent = 0) : QMainWindow(parent)
{
QSettings settings;
restoreGeometry(settings.value("mainWindowGeometry").toByteArray());
// create docs, toolbars, etc...
restoreState(settings.value("mainWindowState").toByteArray());
}
void closeEvent(QCloseEvent *event)
{
QSettings settings;
settings.setValue("mainWindowGeometry", saveGeometry());
settings.setValue("mainWindowState", saveState());
}
};
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QCoreApplication::setOrganizationDomain("OrgDomain");
QCoreApplication::setOrganizationName("OrgName");
QCoreApplication::setApplicationName("AppName");
QCoreApplication::setApplicationVersion("1.0.0");
MainWindow w;
w.show();
return a.exec();
}
The above code will save and restore window position, size, toolbar visibility, toolbar docking area, dock states, locations and sizes. It saves using QSettings which will store your settings in a platform correct way.
Source
This add-in for StarUML exports modeled state machine(s) to Qt C++ code.
The add-in can speed up developing state machines when you need to only model a state machine with StarUML and then export it to source code, instead of maintaining the model and code separately.
Get 97 short and extremely useful tips from some of the most experienced and respected practitioners in the industry, including Uncle Bob Martin, Scott Meyers, Dan North, Linda Rising, Udi Dahan, Neal Ford, and many more. They encourage you to stretch yourself by learning new languages, looking at problems in new ways, following specific practices, taking responsibility for your work, and becoming as good at the entire craft of programming as you possibly can.
O’Relly homepage
There is the 97 Things Every Programmer Should Know project, pearls of wisdom for programmers collected from leading practitioners. You can read through the Contributions Appearing in the Book.
Russian translation of these tips.