"Fossies" - the Fresh Open Source Software Archive

Member "cutter-1.8.2/src/common/TempConfig.cpp" (20 May 2019, 1275 Bytes) of package /linux/privat/cutter-1.8.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "TempConfig.cpp" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 1.8.0_vs_1.8.1.

    1 
    2 #include <cassert>
    3 
    4 #include "core/Cutter.h"
    5 #include "TempConfig.h"
    6 
    7 TempConfig::~TempConfig()
    8 {
    9     for (auto i = resetValues.constBegin(); i != resetValues.constEnd(); ++i) {
   10         switch (i.value().type()) {
   11         case QVariant::String:
   12             Core()->setConfig(i.key(), i.value().toString());
   13             break;
   14         case QVariant::Int:
   15             Core()->setConfig(i.key(), i.value().toInt());
   16             break;
   17         case QVariant::Bool:
   18             Core()->setConfig(i.key(), i.value().toBool());
   19             break;
   20         default:
   21             assert(false);
   22             break;
   23         }
   24     }
   25 }
   26 
   27 TempConfig &TempConfig::set(const QString &key, const QString &value)
   28 {
   29     if (!resetValues.contains(key)) {
   30         resetValues[key] = Core()->getConfig(key);
   31     }
   32 
   33     Core()->setConfig(key, value);
   34     return *this;
   35 }
   36 
   37 TempConfig &TempConfig::set(const QString &key, int value)
   38 {
   39     if (!resetValues.contains(key)) {
   40         resetValues[key] = Core()->getConfigi(key);
   41     }
   42 
   43     Core()->setConfig(key, value);
   44     return *this;
   45 }
   46 
   47 TempConfig &TempConfig::set(const QString &key, bool value)
   48 {
   49     if (!resetValues.contains(key)) {
   50         resetValues[key] = Core()->getConfigb(key);
   51     }
   52 
   53     Core()->setConfig(key, value);
   54     return *this;
   55 }