Exemplo n.º 1
0
void RevertBinaryTree(std::unique_ptr<TreeNode<T>>& root) {
    if (root != nullptr) {
        root->left.swap(root->right);
        revert(root->left);
        revert(root->right);
    }
}
Exemplo n.º 2
0
/*
	Basically the same code as minimax. It initiates the move making process. 
*/
void AI::make_move(int current_player, Board* game_board) {
	//Defines max and min possible scores.
	int alpha = -2000;
	int beta = 2000;
	//The depth is initially 0. This will be incremented after every recursive call to minimax. 
	int depth = 0;
	//Defines the best possible score so far and a default position. 
	int best_score;
	int position = 4;

	//If player is X. 
	if (current_player == 1) {
		//We try to get a better score than alpha, so we default to alpha in the beginning. 
		best_score = alpha;
		//We basically perform all 7 (at most) possible moves. 
		for (int i = 1; i < 8; ++i) {
			//Only if i is a valid move.
			if (valid_move(i)) {
				//It plays the move i in the vector and simply recursively calls minimax to maximize (or minimize) its score and revert all moves.
				play(current_player, i);
				int score = minimax(best_score, beta, -current_player, game_board, depth);
				if (score > best_score) {
					//Score and position are stored. 
					best_score = score;
					position = i;
				}
				//Move is reverted. 
				revert(current_player, i);

				//Here we perform alpha beta pruning, which enables us to discard large sections of the Search Tree. 
				if (beta <= best_score) {
					break;
				}
			}
		}
	}

	//Same process as with 1. 
	else if (current_player == -1) {
		best_score = beta;
		for (int i = 1; i < 8; ++i) {
			if (valid_move(i)) {
				play(current_player, i);
				int score = minimax(alpha, best_score, -current_player, game_board, depth);
				if (score < best_score) {
					best_score = score;
					position = i;
				}
				revert(current_player, i);
				if (best_score <= alpha) {
					break;
				}
			}
		}
	}

	//After determining the best position (from the best score), it makes that move. 
	play(current_player, position);
}
Exemplo n.º 3
0
static void
set_border_color(char *arg)
{
	int color;

	color = get_color_number(arg);
	if (color == -1) {
		revert();
		errx(1, "invalid color '%s'", arg);
	}
	if (ioctl(0, KDSBORDER, color) != 0) {
		revert();
		err(1, "ioctl(KD_SBORDER)");
	}
}
void IdleTimeDetector::informOverrun()
{
    if (!_overAllIdleDetect)
        return; // In the preferences the user has indicated that he do not
            // want idle detection.

    _timer->stop();
    start = QDateTime::currentDateTime();
    idlestart = start.addSecs(-60 * _maxIdle);
    QString backThen = KGlobal::locale()->formatTime(idlestart.time());
    // Create dialog
        KDialog *dialog=new KDialog( 0 );
        QWidget* wid=new QWidget(dialog);
        dialog->setMainWidget( wid );
        QVBoxLayout *lay1 = new QVBoxLayout(wid);
        QHBoxLayout *lay2 = new QHBoxLayout();
        lay1->addLayout(lay2);
        QString idlemsg=QString( "Desktop has been idle since %1. What do you want to do ?" ).arg(backThen);
        QLabel *label = new QLabel( idlemsg, wid );
        lay2->addWidget( label );
        connect( dialog , SIGNAL(cancelClicked()) , this , SLOT(revert()) );
        connect( wid , SIGNAL(changed(bool)) , wid , SLOT(enabledButtonApply(bool)) );
        QString explanation=i18n("Continue timing. Timing has started at %1", backThen);
        QString explanationrevert=i18n("Stop timing and revert back to the time at %1.", backThen);
        dialog->setButtonText(KDialog::Ok, i18n("Continue timing."));
        dialog->setButtonText(KDialog::Cancel, i18n("Revert timing"));
        dialog->setButtonWhatsThis(KDialog::Ok, explanation);
        dialog->setButtonWhatsThis(KDialog::Cancel, explanationrevert);
        // The user might be looking at another virtual desktop as where ktimetracker is running
        KWindowSystem::self()->setOnDesktop( dialog->winId(), KWindowSystem::self()->currentDesktop() );
        KWindowSystem::self()->demandAttention( dialog->winId() );
        kDebug(5970) << "Setting WinId " << dialog->winId() << " to deskTop " << KWindowSystem::self()->currentDesktop();
        dialog->show();
}
Exemplo n.º 5
0
View::View(Kate::MainWindow *mainWindow)
  : Kate::PluginView(mainWindow)
  , mw(mainWindow)
{
  toolView = mainWindow->createToolView("KatecodeinfoPlugin", Kate::MainWindow::Bottom, SmallIcon("msg_info"), i18n("Codeinfo"));
  QWidget* w = new QWidget(toolView);
  setupUi(w);
  config();
  w->show();

  btnConfig->setIcon(KIcon("configure"));

  m_nregex = NamedRegExp();
  updateCmbActions();
  updateGlobal();

  connect(btnFile, SIGNAL(clicked()), this, SLOT(loadFile()));
  connect(btnClipboard, SIGNAL(clicked()), this, SLOT(loadClipboard()));
  connect(btnRun, SIGNAL(clicked()), this, SLOT(run()));
  connect(btnConfig, SIGNAL(clicked()), this, SLOT(config()));
  connect(btnSave, SIGNAL(clicked()), this, SLOT(save()));
  connect(btnRevert, SIGNAL(clicked()), this, SLOT(revert()));

  connect(lstCodeinfo, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(infoSelected(QTreeWidgetItem*, int)));
  connect(cmbActions, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(actionSelected(const QString &)));
  connect(txtRegex, SIGNAL(textChanged(QString)), this, SLOT(regexChanged(QString)));
  connect(txtCommand, SIGNAL(textChanged(QString)), this, SLOT(commandChanged(QString)));
  actionSelected(cmbActions->currentText());
}
Exemplo n.º 6
0
int main(int argc, char* argv) {
    long long sum = 0;
    int digits[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
    long long num = is_qualified(digits);
    if (num > 0) {
        //printf("qualified number = %lld\n", num);
        sum = sum + num;
    }
    int n = 9;
    int i = n;
    while (i > 0) {
        int prev = i - 1;
        if (digits[prev] < digits[i]) {
            for (int j = n; j >= i; j--) {
                if (digits[j] > digits[prev]) {
                    swap(&digits[j], &digits[prev]);
                    if (i < n) revert(digits, i, n);
                    i = n;
                    break;
                }
            }
            num = is_qualified(digits);
            if (num > 0) {
                //printf("qualified number = %lld\n", num);
                sum = sum + num;
            }
        } else {
            i--;
        }
    }
    printf("sum = %lld\n", sum);
}
weighted_point eigen_feature_mapper::revert(
    const eigen_wsvec_t& src) const {
  weighted_point ret;
  ret.weight = src.weight;
  ret.data = revert(src.data);
  return ret;
}
Exemplo n.º 8
0
void MickeyApplyDialog::on_RevertButton_pressed()
{
  timer.stop();
  //std::cout<<"Reverting..."<<std::endl;
  emit revert();
  hide();
}
Exemplo n.º 9
0
  // return at most n nodes, if theres nodes less than n, return size is also less than n.
  // find(hash)    :: lock_service -> key -> [node] where hash(node0) <= hash(key) < hash(node1)
  bool cht::find(const std::string& key, std::vector<std::pair<std::string,int> >& out, size_t n){
    out.clear();
    std::vector<std::string> hlist;
    if(! get_hashlist_(key, hlist)){
      throw JUBATUS_EXCEPTION(not_found(key));
    }
    std::string hash = make_hash(key);
    std::string path = ACTOR_BASE_PATH + "/" + name_ + "/cht";

    std::vector<std::string>::iterator node0 = std::lower_bound(hlist.begin(), hlist.end(), hash);
    size_t idx = int(node0 - hlist.begin()) % hlist.size();
    std::string loc;
    for(size_t i=0; i<n; ++i){
      std::string ip;
      int port;
      if(lock_service_->read(path + "/" + hlist[idx], loc)){
        revert(loc, ip, port);
        out.push_back(make_pair(ip,port));
      }else{
        // TODO: output log
        throw JUBATUS_EXCEPTION(not_found(path));
      }
      idx++;
      idx %= hlist.size();
    }
    return !hlist.size();
  }
Exemplo n.º 10
0
void IgnoreListModel::clientConnected() {
  connect(Client::ignoreListManager(), SIGNAL(updated()), SLOT(revert()));
  if(Client::ignoreListManager()->isInitialized())
    initDone();
  else
    connect(Client::ignoreListManager(), SIGNAL(initDone()), SLOT(initDone()));
}
Exemplo n.º 11
0
void IgnoreListModel::commit() {
  if(!_configChanged)
    return;

  Client::ignoreListManager()->requestUpdate(_clonedIgnoreListManager.toVariantMap());
  revert();
}
Exemplo n.º 12
0
VideoProcessor::VideoProcessor(QObject *parent)
  : QObject(parent)
  , delay(-1)
  , rate(0)
  , fnumber(0)
  , length(0)
  , stop(true)
  , modify(false)
  , curPos(0)
  , curIndex(0)
  , curLevel(0)
  , digits(0)
  , extension(".avi")
  , levels(4)
  , alpha(10)
  , lambda_c(80)
  , fl(0.05)
  , fh(0.4)
  , chromAttenuation(0.1)
  , delta(0)
  , exaggeration_factor(2.0)
  , lambda(0)
{
    connect(this, SIGNAL(revert()), this, SLOT(revertVideo()));
}
Exemplo n.º 13
0
	void GraffitiTab::renameFiles ()
	{
		if (!FilesModel_->GetModified ().isEmpty ())
		{
			auto res = QMessageBox::question (this,
					"LMP Graffiti",
					tr ("You have unsaved files with changed tags. Do you want to save or discard those changes?"),
					QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
			if (res == QMessageBox::Save)
				save ();
			else if (res == QMessageBox::Discard)
				revert ();
			else
				return;
		}

		QList<MediaInfo> infos;
		for (const auto& index : Ui_.FilesList_->selectionModel ()->selectedRows ())
			infos << index.data (FilesModel::Roles::MediaInfoRole).value<MediaInfo> ();
		if (infos.isEmpty ())
			return;

		auto dia = new RenameDialog (LMPProxy_, this);
		dia->SetInfos (infos);

		dia->setAttribute (Qt::WA_DeleteOnClose);
		dia->show ();
	}
Exemplo n.º 14
0
	void GraffitiTab::SetupToolbar ()
	{
		Save_ = Toolbar_->addAction (tr ("Save"),
				this, SLOT (save ()));
		Save_->setProperty ("ActionIcon", "document-save");
		Save_->setShortcut (QString ("Ctrl+S"));

		Revert_ = Toolbar_->addAction (tr ("Revert"),
				this, SLOT (revert ()));
		Revert_->setProperty ("ActionIcon", "document-revert");

		Toolbar_->addSeparator ();

		RenameFiles_ = Toolbar_->addAction (tr ("Rename files"),
				this, SLOT (renameFiles ()));
		RenameFiles_->setProperty ("ActionIcon", "edit-rename");

		Toolbar_->addSeparator ();

		GetTags_ = Toolbar_->addAction (tr ("Fetch tags"),
				this, SLOT (fetchTags ()));
		GetTags_->setProperty ("ActionIcon", "download");

		SplitCue_ = Toolbar_->addAction (tr ("Split CUE..."),
				this, SLOT (splitCue ()));
		SplitCue_->setProperty ("ActionIcon", "split");
		SplitCue_->setEnabled (false);
	}
Exemplo n.º 15
0
  // find(hash)    :: lock_service -> key -> [node] where hash(node0) <= hash(key) < hash(node1)
  bool cht::find(const std::string& key, std::vector<std::pair<std::string,int> >& out){
    out.clear();
    std::string path = ACTOR_BASE_PATH + "/" + name_ + "/cht";
    std::string hash = make_hash(key);
    std::vector<std::pair<std::string, int> > ret;
    std::vector<std::string> hlist;
    lock_service_->list(path, hlist);

    if(hlist.empty()) return false;
    std::sort(hlist.begin(), hlist.end());

    std::vector<std::string>::iterator node0 = std::lower_bound(hlist.begin(), hlist.end(), hash);
    size_t idx = int(node0 - hlist.begin()) % hlist.size();
    std::string loc;
    for(int i=0; i<2; ++i){
      std::string ip;
      int port;
      if(lock_service_->read(path + "/" + hlist[idx], loc)){
        revert(loc, ip, port);
        out.push_back(make_pair(ip,port));
      }else{
        // TODO: output log
      }
      idx++;
      idx %= hlist.size();
    }
    return !hlist.size();
  }
Exemplo n.º 16
0
void dfaRightQuotient(DFA *a, unsigned var_index) 
{
  graph *G;
  int i;
  state_inf_fwd *R = mem_alloc(sizeof(*R)*(a->ns));
  int *f = mem_alloc(sizeof(*f)*(a->ns));
    
  for (i=0; i<a->ns; i++) {
    R[i].go_1 = read00(a->bddm, a->q[i], var_index, 0);
    R[i].go_2 = read00(a->bddm, a->q[i], var_index, 1);
    R[i].is_final = (a->f[i] == 1)? 1 : 0;
  };
  /* find states from which some string of 00..00X00..00
     letters can reach a +1 state; put result in f */
  G = revert(R, a->ns);
  make_finals(G, R, a->ns);
  color(G);
  for(i=0;i<a->ns;i++) 
    f[i] = (G->F[i]? 1 : 0);
  /* find states from which some string of 00..00X00..00
     letters can reach a -1 state */
  for (i=0; i<a->ns; i++) 
    R[i].is_final = (a->f[i] == -1)? 1 : 0;
  make_finals(G, R, a->ns);
  color(G);
  /* now a state is +1 if some path along 00..00x00..00 letters takes
     it to an original +1 state; otherwise, the state is -1 if some
     such path takes it to an original -1 state: */
  for(i=0;i<a->ns;i++) {
    a->f[i] = (f[i]? 1 : (G->F[i]? -1 : 0));
  }
  free_G(G, a->ns);
  mem_free(f);
  mem_free(R);
}
Exemplo n.º 17
0
int main()
{
	char  text[] = {"hello i am a student"};
	//text[5] = 'm';
	char*  start = text;
	char*  end = text;
	while (*start != '\0')
	{
		if (*end == ' ' || *end == '\0')
		{
			revert(start, end - 1);
			if (*end == '\0')
			{
				break;
			}
			start = ++end;
		}
		else
		{
			++end;
		}
	}
	printf("length = %d\n", strlen(text));
	printf("value = %s\n", text);
	return 0;
}
int QAbstractItemModel::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: dataChanged((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< const QModelIndex(*)>(_a[2]))); break;
        case 1: headerDataChanged((*reinterpret_cast< Qt::Orientation(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 2: layoutChanged(); break;
        case 3: layoutAboutToBeChanged(); break;
        case 4: rowsAboutToBeInserted((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 5: rowsInserted((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 6: rowsAboutToBeRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 7: rowsRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 8: columnsAboutToBeInserted((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 9: columnsInserted((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 10: columnsAboutToBeRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 11: columnsRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 12: modelAboutToBeReset(); break;
        case 13: modelReset(); break;
        case 14: rowsAboutToBeMoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3])),(*reinterpret_cast< const QModelIndex(*)>(_a[4])),(*reinterpret_cast< int(*)>(_a[5]))); break;
        case 15: rowsMoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3])),(*reinterpret_cast< const QModelIndex(*)>(_a[4])),(*reinterpret_cast< int(*)>(_a[5]))); break;
        case 16: columnsAboutToBeMoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3])),(*reinterpret_cast< const QModelIndex(*)>(_a[4])),(*reinterpret_cast< int(*)>(_a[5]))); break;
        case 17: columnsMoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3])),(*reinterpret_cast< const QModelIndex(*)>(_a[4])),(*reinterpret_cast< int(*)>(_a[5]))); break;
        case 18: { bool _r = submit();
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 19: revert(); break;
        default: ;
        }
        _id -= 20;
    }
    return _id;
}
Exemplo n.º 19
0
 bool isPalindrome(ListNode* head) {
     if (head == NULL)
     {
         return true;
     }
     ListNode *quick = head;
     ListNode *slow = head;
     while (quick->next && quick->next->next)
     {
         quick  = quick->next->next;
         slow = slow->next;
     }
     ListNode *left = head;
     ListNode *right = revert(slow);
     while (left != NULL)
     {
         if (left->val != right->val)
         {
             return false;
         }
         left = left->next;
         right = right->next;
     }
     return true;
 }
Exemplo n.º 20
0
void BaseEditor::actionSaveAs()
{
	auto uiFramework = pImpl_->get<IUIFramework>();
	TF_ASSERT(uiFramework != nullptr);
	if (!uiFramework)
	{
		return;
	}

	auto path = uiFramework->showSaveAsFileDialog("Save As", lastSaveFolder(), fileSaveFilter(), IUIFramework::None);
	if (!path.empty())
	{
		clearCheckoutState();
		setLastSaveFolder(FilePath::getFolder(path));
		if(onSaveAs(path.c_str()))
		{
			auto editor = pImpl_->get<IEditor>();
			TF_ASSERT(editor != nullptr);
			if (editor)
			{
				editor->saveAs(path.c_str());
			}
			auto assetManager = pImpl_->get<IAssetManager>();
			if (assetManager)
			{
				auto assetModel = assetManager->assetModel();
				if (assetModel)
				{
					assetModel->revert();
				}
			}
		}
	}
}
Exemplo n.º 21
0
Mickey::Mickey() : updateTimer(this), btnThread(this), state(STANDBY), 
  calDlg(), aplDlg(), recenterFlag(true), dw(NULL) 
{
  trans = new MickeyTransform();
  //QObject::connect(onOffSwitch, SIGNAL(activated()), this, SLOT(onOffSwitch_activated()));
  //QObject::connect(&lbtnSwitch, SIGNAL(activated()), &btnThread, SLOT(on_key_pressed()));
  QObject::connect(this, SIGNAL(mouseHotKey_activated(int, bool)), 
		   &btnThread, SLOT(on_mouseHotKey_activated(int, bool)));
  QObject::connect(&updateTimer, SIGNAL(timeout()), this, SLOT(updateTimer_activated()));
  QObject::connect(&aplDlg, SIGNAL(keep()), this, SLOT(keepSettings()));
  QObject::connect(&aplDlg, SIGNAL(revert()), this, SLOT(revertSettings()));

  QObject::connect(&calDlg, SIGNAL(recenterNow(bool)), this, SLOT(recenterNow(bool)));
  QObject::connect(&calDlg, SIGNAL(startCalibration()), this, SLOT(startCalibration()));
  QObject::connect(&calDlg, SIGNAL(finishCalibration()), this, SLOT(finishCalibration()));
  QObject::connect(&calDlg, SIGNAL(cancelCalibration(bool)), this, SLOT(cancelCalibration(bool)));
  
  if(!mouse.init()){
    exit(1);
  }
  dw = QApplication::desktop();
//  screenBBox = dw->screenGeometry();
  screenBBox = QRect(0, 0, dw->width(), dw->height());
  screenCenter = screenBBox.center();
  updateTimer.setSingleShot(false);
  updateTimer.setInterval(8);
  btnThread.start();
  linuxtrack_init((char *)"Mickey");
  changeState(TRACKING);
}
Exemplo n.º 22
0
//Runs the genetic algorithm
void Solver::runAStar()
{
    for(int i=0;i<gateLimit;++i)
    {
        circuits.push_back(Circuit());
    }
    bool go = true;
    int loc = -1;
    unsigned long long int generation=0;
    do
    {
        //algorithm adds new random gate every generation, and reverts if the fitness value goes lower
        ++generation;
        addGatesAstar();
        calcFitness();
        revert();
        runSortFitness();
        cull();
        loc = checkSolution();
        if(generation%1000 == 0)
        {
            cout<<"Generation: "<<generation<<"\n";
            cout<<"Num Gates:  "<<circuits[0].getGateNum()<<"\n";
        }
        if(loc != -1)
        {
            solutionLoc = loc;
            cout<<"Generation: "<<generation<<"\n";
            go = false;
        }
    }while(go);
}
Exemplo n.º 23
0
void EffectEditor::onCancel()
{
	revert();

	// Call the inherited DialogWindow::destroy method
	destroy();
}
Exemplo n.º 24
0
/**
 * Genetically pairs the odd nodes
 */
void improveGenetically() {
	int i, j, k;

	if (oddNodesSize == 0) return;


	/**
	 * MUTATION: SWITCH
	 */

	for (i = 0; i < oddNodesSize / 2; i++) {
		for (j = 0; j < oddNodesSize / 2; j++) {
			if (i != j) {
				for (k = 0; k < 2; k++) {
					int scorebefore = rateCombs();
					save();

					int temp = oddNodes[j * 2 + k];
					oddNodes[j * 2 + k] = oddNodes[i * 2];
					oddNodes[i * 2] = temp;


					int scoreafter = rateCombs();

					if (scoreafter > scorebefore) { // No improvement, revert
						revert();
					} else {
//						printf("Mutation: switch\n");
					}
					//					}
				}
			}
		}
	}
}
PreferencesAppearanceConfigPage::PreferencesAppearanceConfigPage( Knipptasch::Preferences *pref, ConfigWidget *parent )
    : AbstractConfigPage( tr( "Appearance" ), DesktopIcon( "preferences-desktop-theme" ), parent ),
      ui( new Ui::PreferencesAppearanceConfigPage ),
      m_preferences( pref )
{
    ui->setupUi( this );

    connect( ui->positiveAmountForegroundEnabled, SIGNAL( toggled( bool ) ),
             ui->fgPositiveAmountWidget, SLOT( setEditable( bool ) ) );
    connect( ui->negativeAmountForegroundEnabled, SIGNAL( toggled( bool ) ),
             ui->fgNegativeAmountWidget, SLOT( setEditable( bool ) ) );
    connect( ui->availableWarrantyForegroundEnabled, SIGNAL( toggled( bool ) ),
             ui->fgAvailableWarrantyWidget, SLOT( setEditable( bool ) ) );
    connect( ui->expiredWarrantyForegroundEnabled, SIGNAL( toggled( bool ) ),
             ui->fgExpiredWarrantyWidget, SLOT( setEditable( bool ) ) );
    connect( ui->currentPostingBackgroundEnabled, SIGNAL( toggled( bool ) ),
             ui->bgCurrentPostingWidget, SLOT( setEditable( bool ) ) );
    connect( ui->futurePostingBackgroundEnabled, SIGNAL( toggled( bool ) ),
             ui->bgFuturePostingWidget, SLOT( setEditable( bool ) ) );
    connect( ui->defaultPostingBackgroundEnabled, SIGNAL( toggled( bool ) ),
             ui->bgNormalPostingWidget, SLOT( setEditable( bool ) ) );
    connect( ui->incompletePostingBackgroundEnabled, SIGNAL( toggled( bool ) ),
             ui->bgIncompletePostingWidget, SLOT( setEditable( bool ) ) );

    connect( ui->positiveAmountForegroundEnabled, SIGNAL( stateChanged( int ) ),
             this, SIGNAL( pageModified() ) );
    connect( ui->negativeAmountForegroundEnabled, SIGNAL( stateChanged( int ) ),
             this, SIGNAL( pageModified() ) );
    connect( ui->availableWarrantyForegroundEnabled, SIGNAL( stateChanged( int ) ),
             this, SIGNAL( pageModified() ) );
    connect( ui->expiredWarrantyForegroundEnabled, SIGNAL( stateChanged( int ) ),
             this, SIGNAL( pageModified() ) );
    connect( ui->currentPostingBackgroundEnabled, SIGNAL( stateChanged( int ) ),
             this, SIGNAL( pageModified() ) );
    connect( ui->futurePostingBackgroundEnabled, SIGNAL( stateChanged( int ) ),
             this, SIGNAL( pageModified() ) );
    connect( ui->defaultPostingBackgroundEnabled, SIGNAL( stateChanged( int ) ),
             this, SIGNAL( pageModified() ) );
    connect( ui->incompletePostingBackgroundEnabled, SIGNAL( stateChanged( int ) ),
             this, SIGNAL( pageModified() ) );

    connect( ui->fgPositiveAmountWidget, SIGNAL( colorChanged( QColor ) ),
             this, SIGNAL( pageModified() ) );
    connect( ui->fgNegativeAmountWidget, SIGNAL( colorChanged( QColor ) ),
             this, SIGNAL( pageModified() ) );
    connect( ui->fgAvailableWarrantyWidget, SIGNAL( colorChanged( QColor ) ),
             this, SIGNAL( pageModified() ) );
    connect( ui->fgExpiredWarrantyWidget, SIGNAL( colorChanged( QColor ) ),
             this, SIGNAL( pageModified() ) );
    connect( ui->bgCurrentPostingWidget, SIGNAL( colorChanged( QColor ) ),
             this, SIGNAL( pageModified() ) );
    connect( ui->bgFuturePostingWidget, SIGNAL( colorChanged( QColor ) ),
             this, SIGNAL( pageModified() ) );
    connect( ui->bgNormalPostingWidget, SIGNAL( colorChanged( QColor ) ),
             this, SIGNAL( pageModified() ) );
    connect( ui->bgIncompletePostingWidget, SIGNAL( colorChanged( QColor ) ),
             this, SIGNAL( pageModified() ) );

    revert();
}
Exemplo n.º 26
0
void DBBrowserDB::close () {
    if (_db)
    {
        if (getDirty())
        {
            QString msg = "Do you want to save the changes made to the database file ";
            msg.append(curDBFilename);
            msg.append(" ?");
            if (QMessageBox::question( 0, applicationName ,msg, QMessageBox::Yes, QMessageBox::No)==QMessageBox::Yes)
            {
                save();
            } else {
                //not really necessary, I think... but will not hurt.
                revert();
            }
        }
        sqlite3_close(_db);
    }
    _db = 0;
    idxmap.clear();
    tbmap.clear();
    idmap.clear();
    browseRecs.clear();
    browseFields.clear();
    hasValidBrowseSet = false;
}
Exemplo n.º 27
0
std::pair<std::string, int> cht::find_predecessor(const std::string& key) {
  std::vector<std::string> hlist;
  get_hashlist_(key, hlist);

  std::string hash = make_hash(key);
  std::string path;
  build_actor_path(path, type_, name_);
  path += "/cht";

  std::vector<std::string>::iterator node0 = std::lower_bound(hlist.begin(),
                                                              hlist.end(),
                                                              hash);

  size_t idx = (static_cast<int>(node0 - hlist.begin()) + hlist.size() - 1)
    % hlist.size();

  std::string ip;
  int port;
  std::string loc;
  if (lock_service_->read(path + "/" + hlist[idx], loc)) {
    revert(loc, ip, port);
    return make_pair(ip, port);
  } else {
    throw JUBATUS_EXCEPTION(core::common::not_found(path));
    // TODO(kuenishi): output log and throw exception
  }
}
Exemplo n.º 28
0
static void
show_adapter_info(void)
{
    struct video_adapter_info ad;

    ad.va_index = 0;

    if (ioctl(0, CONS_ADPINFO, &ad) == -1) {
        revert();
        errc(1, errno, "obtaining adapter information");
    }

    printf("fb%d:\n", ad.va_index);
    printf("    %.*s%d, type:%s%s (%d), flags:0x%x\n",
           (int)sizeof(ad.va_name), ad.va_name, ad.va_unit,
           (ad.va_flags & V_ADP_VESA) ? "VESA " : "",
           adapter_name(ad.va_type), ad.va_type, ad.va_flags);
    printf("    initial mode:%d, current mode:%d, BIOS mode:%d\n",
           ad.va_initial_mode, ad.va_mode, ad.va_initial_bios_mode);
    printf("    frame buffer window:0x%x, buffer size:0x%zx\n",
           ad.va_window, ad.va_buffer_size);
    printf("    window size:0x%zx, origin:0x%x\n",
           ad.va_window_size, ad.va_window_orig);
    printf("    display start address (%d, %d), scan line width:%d\n",
           ad.va_disp_start.x, ad.va_disp_start.y, ad.va_line_width);
    printf("    reserved:0x%x\n", ad.va_unused0);
}
Exemplo n.º 29
0
// return at most n nodes, if theres nodes less than n, return size is also less
// than n.
// find(hash) :: lock_service -> key -> [node]
//   where hash(node0) <= hash(key) < hash(node1)
bool cht::find(
    const std::string& key,
    std::vector<std::pair<std::string, int> >& out,
    size_t n) {
  out.clear();
  std::vector<std::string> hlist;
  if (!get_hashlist_(key, hlist)) {
    throw JUBATUS_EXCEPTION(core::common::not_found(key));
  }
  std::string hash = make_hash(key);
  std::string path;
  build_actor_path(path, type_, name_);
  path += "/cht";

  std::vector<std::string>::iterator node0 = std::lower_bound(hlist.begin(),
                                                              hlist.end(),
                                                              hash);

  size_t idx = static_cast<int>(node0 - hlist.begin()) % hlist.size();
  std::string loc;
  for (size_t i = 0; i < n; ++i) {
    std::string ip;
    int port;
    if (lock_service_->read(path + "/" + hlist[idx], loc)) {
      revert(loc, ip, port);
      out.push_back(make_pair(ip, port));
    } else {
      // TODO(kuenishi): output log
      throw JUBATUS_EXCEPTION(core::common::not_found(path));
    }
    idx++;
    idx %= hlist.size();
  }
  return !hlist.size();
}
Exemplo n.º 30
0
static void
clear_history(void)
{
    if (ioctl(0, CONS_CLRHIST) == -1) {
        revert();
        errc(1, errno, "clearing history buffer");
    }
}