示例#1
0
/*{{{  main*/
int main(int argc, char *argv[])
{
  /*{{{  variables*/
  int x, login_y, password_y;
  char loginstr[9], passwordstr[9], ret;
  char ttystr[_POSIX_PATH_MAX];
  char *background = NULL;
  char *fontname = NULL;
  /*}}}  */

  /*{{{  parse arguments*/
  {
    int c;

    while ((c = getopt(argc, argv, "b:f:")) != EOF)
      switch (c) {
      case 'b':
        background = optarg;
        break;
      case 'f':
        fontname = optarg;
        break;
      }
    /*{{{  parse tty*/
    {
      int tty;

      if (optind + 1 > argc) {
        fprintf(stderr, "Usage: %s tty\n", argv[0]);
        exit(1);
      } else {
        strcpy(ttystr, "/dev/");
        strcat(ttystr, argv[optind++]);
      }
      close(0);
      close(1);
      close(2);
      setsid();
      if ((tty = open(ttystr, O_RDWR)) != 0) {
        fprintf(stderr, "%s: Can't open controlling terminal on fd 0.\n", argv[0]);
        exit(1);
      }
      fchmod(tty, 0600);
      fchown(tty, getuid(), getgid());
      open(argv[optind], O_RDWR);
      open(argv[optind], O_RDWR);
    }
    /*}}}  */
  }
  /*}}}  */
  /*{{{  get into grafics mode*/
  signal(SIGTERM, quit);
  signal(SIGHUP, quit);
  set_tty(0);
  if ((screen = bit_open(SCREEN_DEV)) == NULL) {
    reset_tty(0);
    exit(EX_NOPERM);
  }
  bit_grafscreen();
  /*}}}  */
  /*{{{  load font*/
  if (fontname) {
    char fontpath[_POSIX_PATH_MAX];

    if (*fontname == '/' || *fontname == '.')
      strcpy(fontpath, fontname);
    else {
      strcpy(fontpath, ICONDIR);
      strcat(fontpath, "/");
      strcat(fontpath, fontname);
    }

    if ((font = open_font(fontname)) == NULL)
      font = open_font(NULL);
  } else
    font = open_font(NULL);
  /*}}}  */
  /*{{{  draw background*/
  bit_blit(screen, 0, 0, screen->wide, screen->high, BIT_CLR, NULL, 0, 0);
  if (background) {
    BITMAP *bp;
    FILE *fp;
    char backgroundpath[_POSIX_PATH_MAX];

    if (*background == '/' || *background == '.')
      strcpy(backgroundpath, background);
    else {
      strcpy(backgroundpath, ICONDIR);
      strcat(backgroundpath, "/");
      strcat(backgroundpath, background);
    }

    if ((fp = fopen(backgroundpath, "r")) != NULL && (bp = bitmapread(fp)) != NULL) {
      int x, y;

      for (x = 0; x < screen->wide; x += bp->wide)
        bit_blit(
            screen,
            x, 0,
            screen->wide - x < bp->wide ? screen->wide - x : bp->wide,
            bp->high,
            BIT_SRC, bp, 0, 0);

      for (y = 0; y < screen->high; y += bp->high)
        bit_blit(
            screen,
            0, y,
            screen->wide,
            screen->high - y < bp->high ? screen->high - y : bp->high,
            BIT_SRC, screen, 0, 0);
    }
  }
  /*}}}  */
  /*{{{  draw hostname*/
  {
    int bx, bw, by, bh;
    char hostname[_POSIX_PATH_MAX];
    struct hostent *h;

    gethostname(hostname, sizeof(hostname));
    if ((h = gethostbyname(hostname)) != NULL)
      strcpy(hostname, h->h_name);
    bw = font->head.wide * (strlen(hostname) + 2);
    bh = 2 * font->head.high;
    bx = (screen->wide - bw) / 2;
    by = screen->high / 6 - bh / 2;
    cutebox(bx, by, bw, bh);
    printstr(bx + font->head.wide, by + bh - font->head.high / 2, hostname);
  }
  /*}}}  */
  /*{{{  draw login box*/
  {
    int bx, bw, by, bh;

    bx = (screen->wide - font->head.wide * 40) / 2;
    by = (screen->high - font->head.high * 8) / 2;
    bw = font->head.wide * 40;
    bh = font->head.high * 8;
    cutebox(bx, by, bw, bh);
  }
  /*}}}  */
  /*{{{  draw login box contents*/
  x = (screen->wide - font->head.wide * 18) / 2;
  login_y = screen->high / 2 - font->head.wide / 6;
  password_y = screen->high / 2 + font->head.high / 6 + font->head.high;
  printstr(x, password_y, "Password:         "******"Press ESC for terminal login");
  /*}}}  */
  while (1) {
    /*{{{  get login and password or escape*/
    printstr(x, login_y, "Login:            "******"mgr", NULL };
        int i;

        sprintf(env_user, "USER=%s", pw->pw_name);
        sprintf(env_logname, "LOGNAME=%s", pw->pw_name);
        sprintf(env_home, "HOME=%s", pw->pw_dir);
        sprintf(env_shell, "SHELL=%s", pw->pw_shell == NULL || pw->pw_shell[0] == '\0' ? "/bin/sh" : pw->pw_shell);
        sprintf(env_path, "PATH=%s", PATH);
        sprintf(env_mail, "MAIL=%s/%s", MAILDIR, pw->pw_name);
        if (chdir(pw->pw_dir) != 0)
          chdir("/");
        if (ttyname(0)) {
          chown(ttyname(0), pw->pw_uid, pw->pw_gid);
          chmod(ttyname(0), 0600);
        }
        for (i = 1; i <= _NSIG; i++)
          signal(i, SIG_DFL);
        bit_destroy(screen);
        reset_tty(0);
        initgroups(pw->pw_name, pw->pw_gid);
        setgid(pw->pw_gid);
        setuid(pw->pw_uid);
        sprintf(mgrlogin, "%s/.mgrlogin", pw->pw_dir);
        execve(mgrlogin, login_argv, login_env);
        execve(MGR_BINARY, login_argv, login_env);
        exit(EX_OSFILE);
      }
      /*}}}  */
      else
      /*{{{  incorrect login*/
      {
        printstr((screen->wide - font->head.wide * 16) / 2, login_y + 3 * font->head.high,
            "Login incorrect");
      }
      /*}}}  */
    }
    /*}}}  */
  }
}
示例#2
0
char *EditConverter::get_str()
{
 return (char*)edit()->get_text();  // *hack
}
 void main()
 {
	clrscr();
	int i,ch,n,res;
	char a,an,pass[6];
	cout<<"\t********** T H E   H Y A T T   R E S I D E N C Y **********\n";
	cout<<"\t----------------------------------------------------------------------------------\n";
	gotoxy(30,13);
	cout<<"Enter password\t";
	for(i=0;i<5;i++)
	{

		pass[i]=getch();
		cout<<'*';
	}
	pass[5]='\0';
	getch();

	if(strcmp(pass,"hyatt")==0)
	{
		gotoxy(32,15);
		cout<<"PASSWORD ACCEPTED";
		getch();
		do
		{
			clrscr();
			cout<<"\t********** T H E   H Y A T T   R E S I D E N C Y **********\n";
			cout<<"\t----------------------------------------------------------------------------------\n";

			cout<<"\n1.Get Information ";
			cout<<"\n2.Get Details about Rooms";
			cout<<"\n3.Get details for a particular room";
			cout<<"\n4.Book a Room";
			cout<<"\n5.Edit information for a particular room";
			cout<<"\n6.Check out And Print Bill";
			cout<<"\n7.Count the present Number of rooms booked";
			cout<<"\n8.Exit the program";
			cout<<"\nPls. Enter the Choice\t";
			cin>>ch;

			switch(ch)
			{
				case 1 : details();
					break;

				case 2 : readf();
					break;

				case 3: cout<<"search details according to-\na.name \nb.roomno ";
					a=getch();
					switch(a)
					{
						case 'a':namesearch();
							break;
						case 'b':roomnosearch();
							break;
					 }
					break;

				case 4 : create();
					 break;


				case 5 : cout<<"\nenter the value of room number to edit the info..\t";
						cin>>n;
					 edit(n);
					 break;

				case 6 : cout<<"\nEnter the room number you want to check out\t";
						cin>>n;
					 chkout(n);
					 break;

				case 7 : res=count();
					 cout<<res;
					 break;

				case 8 : exit(0);
					 break;

	}
	cout<<"\nDo You Want to go to main menu..\t";
	an=getch();

	}while(an=='y'||an=='Y');
	}
示例#4
0
void GraphicUI::createActions()
{
	CreateAct = new QAction(QIcon("images/create.png"), tr("&Create a mind map"), this);
	connect(CreateAct, SIGNAL(triggered()), this, SLOT(create()));

	OpenAct = new QAction(QIcon("images/open.png"), tr("&Open a mind map"), this);
	OpenAct->setStatusTip(tr("Open an existing file"));
	connect(OpenAct, SIGNAL(triggered()), this, SLOT(open()));

	SaveAct = new QAction(QIcon("images/save.png"), tr("&Save a mind map"), this);
	connect(SaveAct, SIGNAL(triggered()), this, SLOT(save()));

	ExitAct = new QAction(QIcon("images/exit.png"), tr("&Exit"), this);
	ExitAct->setStatusTip(tr("Exit the application"));
	connect(ExitAct, SIGNAL(triggered()), this, SLOT(close()));

	EditAct = new QAction(QIcon("images/edit.png"), tr("&Edit"), this);
	connect(EditAct, SIGNAL(triggered()), this, SLOT(edit()));

	DeleteAct = new QAction(QIcon("images/delete.png"), tr("&Delete"), this);
	connect(DeleteAct, SIGNAL(triggered()), this, SLOT(deleteNode()));

	InsertAChildAct = new QAction(QIcon("images/child.png"), tr("&Insert a child"), this);
	connect(InsertAChildAct, SIGNAL(triggered()), this, SLOT(insertChild()));

	InsertASiblingAct = new QAction(QIcon("images/silbing.png"), tr("&Insert a silbing"), this);
	connect(InsertASiblingAct, SIGNAL(triggered()), this, SLOT(insertSilbing()));

	InsertAParentAct = new QAction(QIcon("images/parent.png"), tr("&Insert a parent"), this);
	connect(InsertAParentAct, SIGNAL(triggered()), this, SLOT(insertParent()));

	AboutAct = new QAction(QIcon("images/about.png"), tr("&About"), this);
	connect(AboutAct, SIGNAL(triggered()), this, SLOT(about()));

	CutAct = new QAction(QIcon("images/cut.png"), tr("&Cut"), this);
	connect(CutAct, SIGNAL(triggered()), this, SLOT(cut()));
	
	CopyAct = new QAction(QIcon("images/copy.png"), tr("&Copy"), this);
	connect(CopyAct, SIGNAL(triggered()), this, SLOT(copy()));

	PasteAct = new QAction(QIcon("images/paste.png"), tr("&Paste"), this);
	connect(PasteAct, SIGNAL(triggered()), this, SLOT(paste()));

	RedoAct = new QAction(QIcon("images/redo.png"), tr("&Redo"), this);
	connect(RedoAct, SIGNAL(triggered()), this, SLOT(redo()));

	UndoAct = new QAction(QIcon("images/undo.png"), tr("&Undo"), this);
	connect(UndoAct, SIGNAL(triggered()), this, SLOT(undo()));

	InsertARectangleAct = new QAction(QIcon("images/rectangle.png"), tr("&Insert a rectangle"), this);
	connect(InsertARectangleAct, SIGNAL(triggered()), this, SLOT(insertRectangle()));

	InsertACircleAct = new QAction(QIcon("images/circle.png"), tr("&Insert a circle"), this);
	connect(InsertACircleAct, SIGNAL(triggered()), this, SLOT(insertCircle()));

	InsertATriangleAct = new QAction(QIcon("images/triangle.png"), tr("&Insert a triangle"), this);
	connect(InsertATriangleAct, SIGNAL(triggered()), this, SLOT(insertTriangle()));

	UpAct = new QAction(QIcon("images/up.png"), tr("&Up"), this);
	connect(UpAct, SIGNAL(triggered()), this, SLOT(up()));

	DownAct = new QAction(QIcon("images/down.png"), tr("&Down"), this);
	connect(DownAct, SIGNAL(triggered()), this, SLOT(down()));

	ExpandAct = new QAction(QIcon("images/expand.png"), tr("&Expand"), this);
	connect(ExpandAct, SIGNAL(triggered()), this, SLOT(expand()));

	CollapseAct = new QAction(QIcon("images/collapse.png"), tr("&Collapse"), this);
	connect(CollapseAct, SIGNAL(triggered()), this, SLOT(collapse()));

	ExpandOneAct = new QAction(QIcon("images/expand2.png"), tr("&Expand"), this);
	connect(ExpandOneAct, SIGNAL(triggered()), this, SLOT(expandOne()));

	CollapseOneAct = new QAction(QIcon("images/collapse2.png"), tr("&Collapse"), this);
	connect(CollapseOneAct, SIGNAL(triggered()), this, SLOT(collapseOne()));

	ClearAct = new QAction(QIcon("images/clear.png"), tr("&Clear"), this);
	connect(ClearAct, SIGNAL(triggered()), this, SLOT(clear()));

	initialAction();
	GraphicAction.push_back(DeleteAct);
	GraphicAction.push_back(InsertAChildAct);
	GraphicAction.push_back(InsertASiblingAct);
	GraphicAction.push_back(InsertAParentAct);
	GraphicAction.push_back(EditAct);
	GraphicAction.push_back(CutAct);
	GraphicAction.push_back(CopyAct);
	GraphicAction.push_back(PasteAct);
	GraphicAction.push_back(RedoAct);
	GraphicAction.push_back(UndoAct);
	GraphicAction.push_back(InsertARectangleAct);
	GraphicAction.push_back(InsertACircleAct);
	GraphicAction.push_back(InsertATriangleAct);
	GraphicAction.push_back(UpAct);
	GraphicAction.push_back(DownAct);
	GraphicAction.push_back(ExpandAct);
	GraphicAction.push_back(CollapseAct);
	GraphicAction.push_back(ExpandOneAct);
	GraphicAction.push_back(CollapseOneAct);
	GraphicAction.push_back(ClearAct);

	Gui_presentation->setGraphicAction(GraphicAction);
}
示例#5
0
void FileListView::keyPressEvent( QKeyEvent *event )
{
    int overridden_key = 0;
    QModelIndex wasCurrent = currentIndex();

    bool isControlEnter = (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) && (event->modifiers() & Qt::ControlModifier);
    switch (event->key())
    {
    case Qt::Key_Shift:
        currentSelectionAction = selectionModel()->isSelected(currentIndex()) ? QItemSelectionModel::Deselect : QItemSelectionModel::Select;
        break;

    case Qt::Key_Plus:
    case Qt::Key_Minus:
    case Qt::Key_Asterisk:
        SelectAll(event->key() == Qt::Key_Plus ? QItemSelectionModel::Select :
                  event->key() == Qt::Key_Minus ? QItemSelectionModel::Deselect :
                  QItemSelectionModel::Toggle);
        break;

    case Qt::Key_Left:
        overridden_key = Qt::Key_PageUp;
        break;
    case Qt::Key_Right:
        overridden_key = Qt::Key_PageDown;
        break;

    case Qt::Key_Insert:
        overridden_key = Qt::Key_Down;
        selectionModel()->select(currentIndex(), QItemSelectionModel::Toggle);
        break;

    case Qt::Key_Enter:
    case Qt::Key_Return:
        if (!isControlEnter)
        {
            if (event->modifiers() & Qt::ShiftModifier)
                emit OpenSelected();
            else
                emit EnterSelected();
        }
        break;
    }

    if (isSearchMode && !isControlEnter)
        switch (event->key())
        {
        case Qt::Key_Return:
        case Qt::Key_Enter:
        case Qt::Key_Escape:
        case Qt::Key_Left:
        case Qt::Key_Right:
        case Qt::Key_Up:
        case Qt::Key_Down:
        case Qt::Key_PageUp:
        case Qt::Key_PageDown:
        case Qt::Key_Home:
        case Qt::Key_End:
            Action_CloseQuickFind();
            break;
        }

    if ((isControlEnter && isSearchMode) ||
            (!event->text().isEmpty() && event->text() != "\x0d" &&
             !(event->modifiers() & (Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier)) &&
             !edit(currentIndex(), AnyKeyPressed, event)))
    {
        Action_OpenQuickFind();
        if (!isControlEnter)
            Action_QuickFindProcessKeyPressEvent(event);

        bool isFound = (event->modifiers() & Qt::ShiftModifier) ? Action_QuickFindPrev() : Action_QuickFindNext(!isControlEnter);
        if (!isControlEnter)
        {
            static bool wasFound = true;
            if (wasFound != isFound)
            {
                wasFound = isFound;

                QPalette pal = searchEdit->palette();
                pal.setColor(QPalette::Base, QColor(255, 200, 200));
                if (isFound)
                    pal = palette();
                searchEdit->setPalette(pal);
            }
        }

        setDirtyRegion(QRegion(0, 0, width(), height()));
        //keyboardSearch(event->text());
        event->accept();
    }
    else
    {
        event->ignore();

        if (overridden_key)
        {
            QKeyEvent newEvent(event->type(), overridden_key, event->modifiers(), event->text(), event->isAutoRepeat(), event->count());
            QTreeView::keyPressEvent(&newEvent);
        }
        else
            QTreeView::keyPressEvent(event);
    }

    if (event->modifiers() & Qt::ShiftModifier)
    {
        QModelIndex current = currentIndex();
        switch (event->key())
        {
        case Qt::Key_Up:
        case Qt::Key_Down:
            selectionModel()->select(wasCurrent, currentSelectionAction);
            break;

        case Qt::Key_Left:
        case Qt::Key_PageUp:
        case Qt::Key_Right:
        case Qt::Key_PageDown:
        case Qt::Key_Home:
        case Qt::Key_End:
            if (current.row() < wasCurrent.row())
                qSwap(wasCurrent, current);

            QItemSelection toSelect;
            toSelect << QItemSelectionRange(model()->index(wasCurrent.row(), 0), model()->index(current.row(), 1));
            selectionModel()->select(toSelect, currentSelectionAction);
            break;
        }
    }
}
示例#6
0
文件: gameui.cpp 项目: saffari/mythtv
void GameUI::customEvent(QEvent *event)
{
    if (event->type() == DialogCompletionEvent::kEventType)
    {
        DialogCompletionEvent *dce = (DialogCompletionEvent*)(event);

        QString resultid   = dce->GetId();
        QString resulttext = dce->GetResultText();

        if (resultid == "showMenuPopup")
        {
            if (resulttext == tr("Edit Details"))
            {
                edit();
            }
            if (resulttext == tr("Scan For Changes"))
            {
                doScan();
            }
            else if (resulttext == tr("Show Information"))
            {
                showInfo();
            }
            else if (resulttext == tr("Make Favorite") ||
                     resulttext == tr("Remove Favorite"))
            {
                toggleFavorite();
            }
            else if (resulttext == tr("Retrieve Details"))
            {
                gameSearch();
            }
        }
        else if (resultid == "chooseSystemPopup")
        {
            if (!resulttext.isEmpty() && resulttext != tr("Cancel"))
            {
                MythGenericTree *node = m_gameUITree->GetCurrentNode();
                RomInfo *romInfo = qVariantValue<RomInfo *>(node->GetData());
                GameHandler::Launchgame(romInfo, resulttext);
            }
        }
        else if (resultid == "editMetadata")
        {
            MythGenericTree *node = m_gameUITree->GetCurrentNode();
            RomInfo *oldRomInfo = qVariantValue<RomInfo *>(node->GetData());
            delete oldRomInfo;

            RomInfo *romInfo = qVariantValue<RomInfo *>(dce->GetData());
            node->SetData(qVariantFromValue(romInfo));
            node->setString(romInfo->Gamename());

            romInfo->SaveToDatabase();
            updateChangedNode(node, romInfo);
        }
        else if (resultid == "detailsPopup")
        {
            // Play button pushed
            itemClicked(0);
        }
    }
    if (event->type() == MetadataLookupEvent::kEventType)
    {
        MetadataLookupEvent *lue = (MetadataLookupEvent *)event;

        MetadataLookupList lul = lue->lookupList;

        if (m_busyPopup)
        {
            m_busyPopup->Close();
            m_busyPopup = NULL;
        }

        if (lul.isEmpty())
            return;

        if (lul.count() == 1)
        {
            OnGameSearchDone(lul.takeFirst());
        }
        else
        {
            MetadataResultsDialog *resultsdialog =
                new MetadataResultsDialog(m_popupStack, lul);

            connect(resultsdialog, SIGNAL(haveResult(MetadataLookup*)),
                    SLOT(OnGameSearchListSelection(MetadataLookup*)),
                    Qt::QueuedConnection);

            if (resultsdialog->Create())
                m_popupStack->AddScreen(resultsdialog);
        }
    }
    else if (event->type() == MetadataLookupFailure::kEventType)
    {
        MetadataLookupFailure *luf = (MetadataLookupFailure *)event;

        MetadataLookupList lul = luf->lookupList;

        if (m_busyPopup)
        {
            m_busyPopup->Close();
            m_busyPopup = NULL;
        }

        if (lul.size())
        {
            MetadataLookup *lookup = lul.takeFirst();
            MythGenericTree *node = qVariantValue<MythGenericTree *>(lookup->GetData());
            if (node)
            {
                RomInfo *metadata = qVariantValue<RomInfo *>(node->GetData());
                if (metadata)
                {
                }
            }
            LOG(VB_GENERAL, LOG_ERR,
                QString("No results found for %1").arg(lookup->GetTitle()));
        }
    }
    else if (event->type() == ImageDLEvent::kEventType)
    {
        ImageDLEvent *ide = (ImageDLEvent *)event;

        MetadataLookup *lookup = ide->item;

        if (!lookup)
            return;

        handleDownloadedImages(lookup);
    }
}
示例#7
0
LRESULT iMapValidateDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{	
	CEdit edit(GetDlgItem(IDC_REPORT));
	edit.AppendText(m_text.CStr());
	return 0;
}
示例#8
0
DynamicPage::DynamicPage(QWidget *p)
    : SinglePageWidget(p)
{
    addAction = new Action(Icons::self()->addNewItemIcon, i18n("Add"), this);
    editAction = new Action(Icons::self()->editIcon, i18n("Edit"), this);
    removeAction = new Action(Icons::self()->removeDynamicIcon, i18n("Remove"), this);
    toggleAction = new Action(this);

    ToolButton *addBtn=new ToolButton(this);
    ToolButton *editBtn=new ToolButton(this);
    ToolButton *removeBtn=new ToolButton(this);
    ToolButton *startBtn=new ToolButton(this);

    addBtn->setDefaultAction(addAction);
    editBtn->setDefaultAction(editAction);
    removeBtn->setDefaultAction(removeAction);
    startBtn->setDefaultAction(Dynamic::self()->startAct());

    view->addAction(editAction);
    view->addAction(removeAction);
    view->addAction(Dynamic::self()->startAct());
    view->alwaysShowHeader();

    connect(view, SIGNAL(itemsSelected(bool)), this, SLOT(controlActions()));
    connect(view, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(toggle()));
    connect(view, SIGNAL(headerClicked(int)), SLOT(headerClicked(int)));
    connect(MPDConnection::self(), SIGNAL(dynamicSupport(bool)), this, SLOT(remoteDynamicSupport(bool)));
    connect(addAction, SIGNAL(triggered()), SLOT(add()));
    connect(editAction, SIGNAL(triggered()), SLOT(edit()));
    connect(removeAction, SIGNAL(triggered()), SLOT(remove()));
    connect(Dynamic::self()->startAct(), SIGNAL(triggered()), SLOT(start()));
    connect(Dynamic::self()->stopAct(), SIGNAL(triggered()), SLOT(stop()));
    connect(toggleAction, SIGNAL(triggered()), SLOT(toggle()));
    connect(Dynamic::self(), SIGNAL(running(bool)), SLOT(running(bool)));
    connect(Dynamic::self(), SIGNAL(loadingList()), view, SLOT(showSpinner()));
    connect(Dynamic::self(), SIGNAL(loadedList()), view, SLOT(hideSpinner()));

    #ifdef Q_OS_WIN
    remoteRunningLabel=new QLabel(this);
    remoteRunningLabel->setStyleSheet(QString(".QLabel {"
                          "background-color: rgba(235, 187, 187, 196);"
                          "border-radius: 3px;"
                          "border: 1px solid red;"
                          "padding: 4px;"
                          "margin: 1px;"
                          "color: black; }"));
    remoteRunningLabel->setText(i18n("Remote dynamizer is not running."));
    #endif
    Dynamic::self()->stopAct()->setEnabled(false);
    proxy.setSourceModel(Dynamic::self());
    view->setModel(&proxy);
    view->setDeleteAction(removeAction);
    view->setMode(ItemView::Mode_List);
    controlActions();
    Configuration config(metaObject()->className());
    view->load(config);
    controls=QList<QWidget *>() << addBtn << editBtn << removeBtn << startBtn;
    init(0, QList<QWidget *>(), controls);
    #ifdef Q_OS_WIN
    addWidget(remoteRunningLabel);
    enableWidgets(false);
    #endif
}
示例#9
0
文件: labeltab.cpp 项目: KDE/kst-plot
LabelTab::LabelTab(PlotItem* plotItem, QWidget *parent)
  : DialogTab(parent), _plotItem(plotItem), _activeLineEdit(0), _fontDirty(false) {

  setupUi(this);

  int h = fontMetrics().lineSpacing();
  _globalLabelBold->setIcon(KstGetIcon("kst_bold"));
  _globalLabelBold->setFixedHeight(h);
  _globalLabelBold->setFixedWidth(h);
  _globalLabelItalic->setIcon(KstGetIcon("kst_italic"));
  _globalLabelItalic->setFixedHeight(h);
  _globalLabelItalic->setFixedWidth(h);
  _globalLabelColor->setFixedHeight(h);
  _globalLabelColor->setFixedWidth(h);

  _topLabelText->setFixedHeight(h*4/3);
  _bottomLabelText->setFixedHeight(h*4/3);
  _leftLabelText->setFixedHeight(h*4/3);
  _rightLabelText->setFixedHeight(h*4/3);

  setTabTitle(tr("Labels"));

  setGlobalFont(_plotItem->globalFont());
  _globalLabelColor->setColor(_plotItem->globalFontColor());
  _globalLabelFontSize->setValue(_plotItem->globalFontScale());

  _topLabelText->setObjectStore(kstApp->mainWindow()->document()->objectStore());
  _bottomLabelText->setObjectStore(kstApp->mainWindow()->document()->objectStore());
  _leftLabelText->setObjectStore(kstApp->mainWindow()->document()->objectStore());
  _rightLabelText->setObjectStore(kstApp->mainWindow()->document()->objectStore());

  connect(_topLabelText, SIGNAL(textChanged()), this, SIGNAL(modified()));
  connect(_leftLabelText, SIGNAL(textChanged()), this, SIGNAL(modified()));
  connect(_bottomLabelText, SIGNAL(textChanged()), this, SIGNAL(modified()));
  connect(_rightLabelText, SIGNAL(textChanged()), this, SIGNAL(modified()));

  connect(_topLabelText, SIGNAL(textChanged()), this, SLOT(_enableLabelLabels()));
  connect(_bottomLabelText, SIGNAL(textChanged()), this, SLOT(_enableLabelLabels()));
  connect(_leftLabelText, SIGNAL(textChanged()), this, SLOT(_enableLabelLabels()));
  connect(_rightLabelText, SIGNAL(textChanged()), this, SLOT(_enableLabelLabels()));

  connect(_autoScaleNumberAxis, SIGNAL(stateChanged(int)), this, SIGNAL(modified()));
  connect(_showLegend, SIGNAL(stateChanged(int)), this, SIGNAL(modified()));

  connect(_editLegendContents, SIGNAL(pressed()), _plotItem->legend(), SLOT(edit()));

  connect(_globalLabelFontSize, SIGNAL(valueChanged(double)), this, SIGNAL(globalFontUpdate()));
  connect(_globalLabelBold, SIGNAL(toggled(bool)), this, SIGNAL(globalFontUpdate()));
  connect(_globalLabelItalic, SIGNAL(toggled(bool)), this, SIGNAL(globalFontUpdate()));
  connect(_globalLabelFontFamily, SIGNAL(currentFontChanged(QFont)), this, SIGNAL(globalFontUpdate()));
  connect(_globalLabelColor, SIGNAL(changed(QColor)), this, SIGNAL(globalFontUpdate()));
  connect(_globalLabelBold, SIGNAL(toggled(bool)), this, SLOT(buttonUpdate()));
  connect(_globalLabelItalic, SIGNAL(toggled(bool)), this, SLOT(buttonUpdate()));

  connect(_topLabelAuto, SIGNAL(toggled(bool)), this, SIGNAL(modified()));
  connect(_leftLabelAuto, SIGNAL(toggled(bool)), this, SIGNAL(modified()));
  connect(_bottomLabelAuto, SIGNAL(toggled(bool)), this, SIGNAL(modified()));
  connect(_rightLabelAuto, SIGNAL(toggled(bool)), this, SIGNAL(modified()));

  connect(_topLabelAuto, SIGNAL(toggled(bool)), this, SLOT(activateFields()));
  connect(_leftLabelAuto, SIGNAL(toggled(bool)), this, SLOT(activateFields()));
  connect(_bottomLabelAuto, SIGNAL(toggled(bool)), this, SLOT(activateFields()));
  connect(_rightLabelAuto, SIGNAL(toggled(bool)), this, SLOT(activateFields()));

}
示例#10
0
ProjectInfoDialog::ProjectInfoDialog(const QString name, const QString path, const QString keyword, const QString affiliation,
									 const QString userName, const QString description)
{
	mDialog = new QDialog();
	mGrid = new QGridLayout();
	mVBox = new QVBoxLayout();
	mHBox = new QHBoxLayout();
	mHBoxDescription = new QHBoxLayout();
	mKeywordLineEdit = new QLineEdit();
	mKeywordLineEdit->setFixedWidth(200);
	mAffiliationLineEdit = new QLineEdit();
	mAffiliationLineEdit->setFixedWidth(200);
	mName = new QLabel("Project Name:");
	mNameContent = new QLabel(name);
	mName->setBuddy(mNameContent);
	mPath = new QLabel("Location:");
	mPathContent = new QLabel(path);
	mPath->setBuddy(mPathContent);
	mKeyword = new QLabel("Keyword:");
	mKeywordContent = new QLabel(keyword);
	mKeyword->setBuddy(mKeywordContent);
	mAffiliation = new QLabel("Affiliation:");
	mAffiliationContent = new QLabel(affiliation);
	mAffiliation->setBuddy(mAffiliationContent);
	mUserName = new QLabel("User Name:");
	mUserNameContent = new QLabel(userName);
	mUserName->setBuddy(mUserNameContent);
	mDescription = new QLabel("Description:");
	mDescriptionContent = new QLabel(description);
	mDescriptionContent->setFixedHeight(150);
	mDescriptionContent->setAlignment(Qt::AlignTop);
	mDescriptionText = new QTextEdit();
	mDescriptionText->setText(description);
	cancelButton = new QPushButton("Cancel");
	connect(cancelButton, SIGNAL(clicked()), this, SLOT(hide()));
	editButton = new QPushButton("Edit");
	connect(editButton, SIGNAL(clicked()), this, SLOT(edit()));
	saveButton = new QPushButton("Save");
	saveButton->setEnabled(false);
	connect(saveButton, SIGNAL(clicked()), this, SLOT(save()));
	mHBox->addWidget(saveButton, 0, Qt::AlignRight);
	mHBox->addWidget(editButton, 0, Qt::AlignRight);
	mHBox->addWidget(cancelButton, 0, Qt::AlignRight);

	mGrid->setColumnStretch(0,0);
    mGrid->setColumnStretch(1,5);
    mGrid->setVerticalSpacing(10);
   // mGrid->setSizeConstraint(QLayout::SetFixedSize);

	int row;
	row = mGrid->rowCount();
	mGrid->addWidget(mName, row, 0, 1, 1, Qt::AlignLeft);
    mGrid->addWidget(mNameContent, row, 1, 1, 1, Qt::AlignLeft);
	mGrid->setRowMinimumHeight(row, 20);

	row = mGrid->rowCount();
	mGrid->addWidget(mPath, row, 0, 1, 1, Qt::AlignLeft);
    mGrid->addWidget(mPathContent, row, 1, 1, 1, Qt::AlignLeft);
	mGrid->setRowMinimumHeight(row, 20);

	row = mGrid->rowCount();
	mGrid->addWidget(mUserName, row, 0, 1, 1, Qt::AlignLeft);
    mGrid->addWidget(mUserNameContent, row, 1, 1, 1, Qt::AlignLeft);
	mGrid->setRowMinimumHeight(row, 20);

	row = mGrid->rowCount();
	mGrid->addWidget(mKeyword, row, 0, 1, 1, Qt::AlignLeft);
    mGrid->addWidget(mKeywordContent, row, 1, 1, 1, Qt::AlignLeft);
	mGrid->setRowMinimumHeight(row, 20);

	row = mGrid->rowCount();
	mGrid->addWidget(mAffiliation, row, 0, 1, 1, Qt::AlignLeft);
    mGrid->addWidget(mAffiliationContent, row, 1, 1, 1, Qt::AlignLeft);
	mGrid->setRowMinimumHeight(row, 20);

	row = mGrid->rowCount();
	mGrid->addWidget(mDescription, row, 0, 1, 1, Qt::AlignLeft);

	mHBoxDescription->addWidget(mDescriptionContent);

	mVBox->addLayout(mGrid);
	//mVBox->setSpacing(20);
	mVBox->addLayout(mHBoxDescription);
	mVBox->addLayout(mHBox);

	mDialog->setLayout(mVBox);

    QString title = tr("Project Info: ") + name;
	
	mDialog->setWindowTitle(title);

    mDialog->setMinimumWidth(350);
    mDialog->adjustSize();
	mDialog->installEventFilter(this);

	mCurrentKeyword = keyword;
	mCurrentUserName = userName;
	mCurrentAffiliation = affiliation;
	mCurrentDescription = description;

}
示例#11
0
//current_sockfd == file descriptor of pipe from client
//buffer == input from client
//nread == num chars of input
void server_process(int current_sockfd, char *buffer, int nread){

      printf("message from client: %s\n", buffer);
      //Essentially original mystore3 main function,
      //with return statements eliminated
   
      char inputCopy[strlen(buffer)];
      strcpy(inputCopy, buffer+1);
      char *fields[5];
      //int nfields;

      




	

      if (!Process(inputCopy)) {
	if (errmsg[0] != '\0')
	  printf("%s\n",errmsg);
	else
	  printf("|status: ERROR: No command-line arguments, error in arguments, or error in writing to FIFO\n\nVersion: %s\n%s|\n",
		 version,Requests);
      }

      if (!readData()) {
	if (errmsg[0] != '\0')
	  printf("|status: ERROR: %s|\n", errmsg);
	else
	  printf("|status: ERROR: Error reading mystore.dat\n\n%s|\n", Requests);
     }

      strcpy(inputCopy, buffer+1);
      SeparateIntoFields(inputCopy, fields, 5);


      if (command == ADD && !add(fields[2],fields[3])) {
	if (errmsg[0] != '\0')
	  printf("|status: ERROR: %s|\n", errmsg);
	else
	  printf("|status: ERROR: Failure to add new item|\n");
      }

     		 
      if (command == STAT) {
	status();
      }

      
      if (command == DISPLAY && !display(fields[2])) {
	if (errmsg[0] != '\0')
	  printf("|status: ERROR: %s|\n", errmsg);
	else
	  printf("|status: ERROR: Cannot display %s|\n",fields[2]);
      }

      
      if (command == DELETE && !delete(fields[2])) {
	if (errmsg[0] != '\0')
	  printf("|status: ERROR: %s|\n", errmsg);
	else
	  printf("|status: ERROR: Cannot delete %s|\n", fields[2]);
      }

        
      if (command == EDIT && !edit(fields[2])) {
	if (errmsg[0] != '\0')
	  printf("|status: ERROR: %s|\n", errmsg);
	else
	  printf("|status: ERROR: cannot edit %s|\n",fields[2]);
      }

      if (rewrite)
	if (!writeData()) {
	  if (errmsg[0] != '\0')
	    printf("|status: ERROR: %s|\n", errmsg);
	  else
	    printf("|status: ERROR: Could not write the data, file may be destroyed|\n");
	}


}
示例#12
0
// header and do while switch that keeps showing you options until you exit
int main(){
	int choice;
	
	printf("Roncon Contact Directory\n");
	printf("========================\n");

	initList();
	load();

	do{
		choice = showMenu();

		switch(choice){
			case 0:	// exit
				printf("Goodbye\n");
				break;

			case 1:	// view all
				printf("View all:\n");
				if(listHead->next != listTail){
					view();
				}
				else{
					printf("No contacts\n");
				}
				break;

			case 2:	// search
				printf("Search:\n");
				if(encrypted){
					printf("Decrypt file first!\n");
				}
				else{
					search();
				}
				break;

			case 3:	// add
				printf("Add: \n");
				if(encrypted){
					printf("Decrypt file first!\n");
				}
				else{
					add();
				}
				break;

			case 4:	// remove
				printf("Remove:\n");
				if(encrypted){
					printf("Decrypt file first!\n");
				}
				else{
					rem();
				}
				break;

			case 5:	// edit
				printf("Edit:\n");
				if(encrypted){
					printf("Decrypt file first!\n");
				}
				else{
					edit();
				}
				break;	

			case 6:	// sort
				printf("Sort:\n");
				if(listHead->next != listTail){
					sort();
				}
				else{
					printf("No contacts\n");
				}
				break;

			case 7:	// encrypt
				printf("En/Decrypt:\n");
				encryptFile();
				break;	
				
			default:
				printf("Not a valid number, re-enter.\n");
				break;
		} // switch
	}while(choice != 0);

	save();

	printf("\n\n");
	system("pause");
} // main
示例#13
0
void PinDialog::edit_description()
{
    edit(comment->text(), edname->text().trimmed() + "_description",
         pin, TxtEdit, this, (post_edit) post_edit_description, edits);
}
void WidgetBoxCategoryListView::editCurrentItem()
{
    const QModelIndex index = currentIndex();
    if (index.isValid())
        edit(index);
}
示例#15
0
BOOL
command(int commandc)
{
	char	filename[PATHLEN + 1];	/* file path name */
	MOUSEEVENT *p;			/* mouse data */
	int	c, i;
	FILE	*file;
	HISTORY *curritem, *item;	/* command history */
	char	*s;

	switch (commandc) {

	case ctrl('C'):	/* toggle caseless mode */
		if (caseless == NO) {
			caseless = YES;
			putmsg2("Caseless mode is now ON");
		} else {
			caseless = NO;
			putmsg2("Caseless mode is now OFF");
		}
		egrepcaseless(caseless);	/* turn on/off -i flag */
		return (NO);

	case ctrl('R'):	/* rebuild the cross reference */
		if (isuptodate == YES) {
			putmsg("The -d option prevents rebuilding the "
			    "symbol database");
			return (NO);
		}
		exitcurses();
		freefilelist();		/* remake the source file list */
		makefilelist();
		rebuild();
		if (errorsfound == YES) {
			errorsfound = NO;
			askforreturn();
		}
		entercurses();
		putmsg("");		/* clear any previous message */
		totallines = 0;
		topline = nextline = 1;
		break;

	case ctrl('X'):	/* mouse selection */
		if ((p = getmouseevent()) == NULL) {
			return (NO);	/* unknown control sequence */
		}
		/* if the button number is a scrollbar tag */
		if (p->button == '0') {
			scrollbar(p);
			break;
		}
		/* ignore a sweep */
		if (p->x2 >= 0) {
			return (NO);
		}
		/* if this is a line selection */
		if (p->y1 < FLDLINE) {

			/* find the selected line */
			/* note: the selection is forced into range */
			for (i = disprefs - 1; i > 0; --i) {
				if (p->y1 >= displine[i]) {
					break;
				}
			}
			/* display it in the file with the editor */
			editref(i);
		} else {	/* this is an input field selection */
			field = mouseselection(p, FLDLINE, FIELDS);
			setfield();
			resetcmd();
			return (NO);
		}
		break;

	case '\t':	/* go to next input field */
	case '\n':
	case '\r':
	case ctrl('N'):
	case KEY_DOWN:
	case KEY_ENTER:
	case KEY_RIGHT:
		field = (field + 1) % FIELDS;
		setfield();
		resetcmd();
		return (NO);

	case ctrl('P'):	/* go to previous input field */
	case KEY_UP:
	case KEY_LEFT:
		field = (field + (FIELDS - 1)) % FIELDS;
		setfield();
		resetcmd();
		return (NO);
	case KEY_HOME:	/* go to first input field */
		field = 0;
		setfield();
		resetcmd();
		return (NO);

	case KEY_LL:	/* go to last input field */
		field = FIELDS - 1;
		setfield();
		resetcmd();
		return (NO);
	case ' ':	/* display next page */
	case '+':
	case ctrl('V'):
	case KEY_NPAGE:
		/* don't redisplay if there are no lines */
		if (totallines == 0) {
			return (NO);
		}
		/*
		 * note: seekline() is not used to move to the next
		 * page because display() leaves the file pointer at
		 * the next page to optimize paging forward
		 */
		break;

	case '-':	/* display previous page */
	case KEY_PPAGE:
		/* don't redisplay if there are no lines */
		if (totallines == 0) {
			return (NO);
		}
		i = topline;		/* save the current top line */
		nextline = topline;	/* go back to this page */

		/* if on first page but not at beginning, go to beginning */
		if (nextline > 1 && nextline <= mdisprefs) {
			nextline = 1;
		} else {	/* go back the maximum displayable lines */
			nextline -= mdisprefs;

			/* if this was the first page, go to the last page */
			if (nextline < 1) {
				nextline = totallines - mdisprefs + 1;
				if (nextline < 1) {
					nextline = 1;
				}
				/* old top is past last line */
				i = totallines + 1;
			}
		}
		/*
		 * move down til the bottom line is just before the
		 * previous top line
		 */
		c = nextline;
		for (;;) {
			seekline(nextline);
			display();
			if (i - bottomline <= 0) {
				break;
			}
			nextline = ++c;
		}
		return (NO);	/* display already up to date */

	case '>':	/* write or append the lines to a file */
		if (totallines == 0) {
			putmsg("There are no lines to write to a file");
		} else {	/* get the file name */
			(void) move(PRLINE, 0);
			(void) addstr("Write to file: ");
			s = "w";
			if ((c = mygetch()) == '>') {
				(void) move(PRLINE, 0);
				(void) addstr(appendprompt);
				c = '\0';
				s = "a";
			}
			if (c != '\r' && c != '\n' && c != KEY_ENTER &&
			    c != KEY_BREAK &&
			    getaline(newpat, COLS - sizeof (appendprompt), c,
			    NO) > 0) {
				shellpath(filename, sizeof (filename), newpat);
				if ((file = fopen(filename, s)) == NULL) {
					cannotopen(filename);
				} else {
					seekline(1);
					while ((c = getc(refsfound)) != EOF) {
						(void) putc(c, file);
					}
					seekline(topline);
					(void) fclose(file);
				}
			}
			clearprompt();
		}
		return (NO);	/* return to the previous field */

	case '<':	/* read lines from a file */
		(void) move(PRLINE, 0);
		(void) addstr(readprompt);
		if (getaline(newpat, COLS - sizeof (readprompt), '\0',
		    NO) > 0) {
			clearprompt();
			shellpath(filename, sizeof (filename), newpat);
			if (readrefs(filename) == NO) {
				putmsg2("Ignoring an empty file");
				return (NO);
			}
			return (YES);
		}
		clearprompt();
		return (NO);

	case '^':	/* pipe the lines through a shell command */
	case '|':	/* pipe the lines to a shell command */
		if (totallines == 0) {
			putmsg("There are no lines to pipe to a shell command");
			return (NO);
		}
		/* get the shell command */
		(void) move(PRLINE, 0);
		(void) addstr(pipeprompt);
		if (getaline(newpat,
		    COLS - sizeof (pipeprompt), '\0', NO) == 0) {
			clearprompt();
			return (NO);
		}
		/* if the ^ command, redirect output to a temp file */
		if (commandc == '^') {
			(void) strcat(strcat(newpat, " >"), temp2);
		}
		exitcurses();
		if ((file = mypopen(newpat, "w")) == NULL) {
			(void) fprintf(stderr,
			    "cscope: cannot open pipe to shell command: %s\n",
			    newpat);
		} else {
			seekline(1);
			while ((c = getc(refsfound)) != EOF) {
				(void) putc(c, file);
			}
			seekline(topline);
			(void) mypclose(file);
		}
		if (commandc == '^') {
			if (readrefs(temp2) == NO) {
				putmsg("Ignoring empty output of ^ command");
			}
		}
		askforreturn();
		entercurses();
		break;

	case ctrl('L'):	/* redraw screen */
	case KEY_CLEAR:
		(void) clearok(curscr, TRUE);
		(void) wrefresh(curscr);
		drawscrollbar(topline, bottomline, totallines);
		return (NO);

	case '!':	/* shell escape */
		(void) execute(shell, shell, (char *)NULL);
		seekline(topline);
		break;

	case '?':	/* help */
		(void) clear();
		help();
		(void) clear();
		seekline(topline);
		break;

	case ctrl('E'):	/* edit all lines */
		editall();
		break;

	case ctrl('A'):	/* repeat last pattern */
	case ctrl('Y'):	/* (old command) */
		if (*pattern != '\0') {
			(void) addstr(pattern);
			goto repeat;
		}
		break;

	case ctrl('B'):		/* cmd history back */
	case ctrl('F'):		/* cmd history fwd */
		curritem = currentcmd();
		item = (commandc == ctrl('F')) ? nextcmd() : prevcmd();
		clearmsg2();
		if (curritem == item) {
			/* inform user that we're at history end */
			putmsg2(
			    "End of input field and search pattern history");
		}
		if (item) {
			field = item->field;
			setfield();
			atfield();
			(void) addstr(item->text);
			(void) strcpy(pattern, item->text);
			switch (c = mygetch()) {
			case '\r':
			case '\n':
			case KEY_ENTER:
				goto repeat;
			default:
				ungetch(c);
				atfield();
				(void) clrtoeol(); /* clear current field */
				break;
			}
		}
		return (NO);

	case '\\':	/* next character is not a command */
		(void) addch('\\');	/* display the quote character */

		/* get a character from the terminal */
		if ((commandc = mygetch()) == EOF) {
			return (NO);	/* quit */
		}
		(void) addstr("\b \b");	/* erase the quote character */
		goto ispat;

	case '.':
		atfield();	/* move back to the input field */
		/* FALLTHROUGH */
	default:
		/* edit a selected line */
		if (isdigit(commandc) && commandc != '0' && !mouse) {
			if (returnrequired == NO) {
				editref(commandc - '1');
			} else {
				(void) move(PRLINE, 0);
				(void) addstr(selectionprompt);
				if (getaline(newpat,
				    COLS - sizeof (selectionprompt), commandc,
				    NO) > 0 &&
				    (i = atoi(newpat)) > 0) {
					editref(i - 1);
				}
				clearprompt();
			}
		} else if (isprint(commandc)) {
			/* this is the start of a pattern */
ispat:
			if (getaline(newpat, COLS - fldcolumn - 1, commandc,
			    caseless) > 0) {
					(void) strcpy(pattern, newpat);
					resetcmd();	/* reset history */
repeat:
				addcmd(field, pattern);	/* add to history */
				if (field == CHANGE) {
					/* prompt for the new text */
					(void) move(PRLINE, 0);
					(void) addstr(toprompt);
					(void) getaline(newpat,
					    COLS - sizeof (toprompt), '\0', NO);
				}
				/* search for the pattern */
				if (search() == YES) {
					switch (field) {
					case DEFINITION:
					case FILENAME:
						if (totallines > 1) {
							break;
						}
						topline = 1;
						editref(0);
						break;
					case CHANGE:
						return (changestring());
					}
				} else if (field == FILENAME &&
				    access(newpat, READ) == 0) {
					/* try to edit the file anyway */
					edit(newpat, "1");
				}
			} else {	/* no pattern--the input was erased */
				return (NO);
			}
		} else {	/* control character */
			return (NO);
		}
	}
	return (YES);
}
示例#16
0
文件: INVEN.C 项目: ASAP-Project/ASAP
/***************************main menu*************************************/
menu()
{
    int x;
    do {
        {
            clrscr();
            design();
            t();
            textcolor(WHITE);
            gotoxy(24,3);
            cprintf("\xDB\xDB\xDB\xDB\xB2  LYDIA'S DEPARTMENT STORE  \xB2\xDB\xDB\xDB\xDB");
            gotoxy(3,4);
            cprintf("--------------------------------------------------------------------------");
            gotoxy(35,5);
            cprintf("MAIN MENU");
            gotoxy(26,8);
            cprintf(" 1  -   INFORMATION ABOUT PRODUCTS            ");
            gotoxy(26,9);
            cprintf(" 2  -   ENTER  PURCHASE  RECORDS            ");
            gotoxy(26,10);
            cprintf(" 3  -   ENTER PRODUCTS TO BE SALE           ");
            gotoxy(26,11);
            cprintf(" 4  -   SEARCH FOR RECORD                     ");
            gotoxy(26,12);
            cprintf(" 5  -   DELETE RECORD FROM STORE DATABASE     ");
            gotoxy(26,13);
            cprintf(" 6  -   VIEW SALES , PURCHASE & PROFIT REPORT ");
            gotoxy(26,14);
            cprintf(" 7  -   PRINT RECORDS                         ");
            gotoxy(26,15);
            cprintf(" 8  -   BAR  GRAPH OF QUANTITY / PROFIT       ");
            gotoxy(26,16);
            cprintf(" 9  -   RETRIEVE INFORMATION         ");
            gotoxy(26,17);
            cprintf(" H  -   HELP                                  ");
            gotoxy(26,18);
            cprintf(" E  -   EXIT                                  ");
            gotoxy(26,23);
            //
            cprintf("ENTER YOUR CHOICE :: ");
            gotoxy(47,23);
            x=toupper(getch());
            switch(x)
            {
            case '1':
                infor();
                break;

            case '2':
                entry();
                break;

            case '3':
                edit();
                break;

            case '4':
                search();
                break;

            case '5':
                del();
                break;

            case '6':
                report2();
                break;

            case '7':
                print();
                break;

            case 'h':
            case'H':
                help();
                break;

            case'8':
                graph1();
                break;

            case '9':
                display();
                break;

            case 'e':
            case 'E':
                exit(0);
                break;

            default:
                clrscr();
                design();
                gotoxy(17,12);
                printf("\a\xDB\xB2  WRONG ENTRY : PRESS ANY KEY AND TRY AGAIN");
                getche();
            }
        }
    } while((x!='e')||(x!='E'));
    return x;
}
示例#17
0
QAction *CAccount::editAction    () { return HACC_ACCOUNTS->editAction    (id(), this, SLOT(edit())    ); }
示例#18
0
QAction *CContractor::editAction()       { return HACC_CONTRACTORS->editAction    (id(), this, SLOT(edit())      ); }
示例#19
0
 /// Remove EngEphemeris objects older than t.
 /// @param t remove EngEphemeris objects older than this
 void wiper( const CommonTime& t )
    throw()
 { edit(t); }
示例#20
0
void ActivityPartitionDialog::edit_description() {
  edit(comment->text(), 
       (edname == 0) ? QString("description")
		     : edname->text().stripWhiteSpace() + "_description",
       data, TxtEdit, this, (post_edit) post_edit_description, edits);
}
示例#21
0
void
trigger(register Rule_t* r, Rule_t* a, char* action, Flags_t flags)
{
	register Joblist_t*	job;
	register List_t*	p;
	List_t*			prereqs;
	int			n;

	/*
	 * update flags
	 */

	if (!a)
		a = r;
	if (state.exec && !state.touch || (a->property & P_always) && (!state.never || (flags & CO_URGENT)))
		flags |= CO_ALWAYS;
	if ((a->property | r->property) & P_local)
		flags |= CO_LOCAL;
	if (!state.jobs || (r->property & P_foreground) || (r->property & (P_make|P_functional)) == P_functional || (r->dynamic & D_hasmake))
		flags |= CO_FOREGROUND|CO_LOCAL;
	if (state.keepgoing || state.unwind)
		flags |= CO_KEEPGOING;
	if (state.silent)
		flags |= CO_SILENT;
	if (state.ignore)
		flags |= CO_IGNORE;
	if (r->property & (P_functional|P_read))
		flags |= CO_DATAFILE;
	if (action)
	{
		message((-1, "triggering %s action%s%s", r->name, r == a ? null : " using ", r == a ? null : a->name));
		if (state.exec)
			jobs.triggered = r;
		r->dynamic |= D_triggered;
		if ((r->property & (P_joint|P_target)) == (P_joint|P_target))
			for (p = r->prereqs->rule->prereqs; p; p = p->next)
				p->rule->dynamic |= D_triggered;
		if (!*action)
			action = 0;
	}
	if (state.coshell && (action && !(r->property & P_make) || (flags & CO_FOREGROUND)))
	{
		/*
		 * the make thread blocks when too many jobs are outstanding
		 */

		n = (flags & CO_FOREGROUND) ? 0 : (state.jobs - 1);
		while ((cozombie(state.coshell) || cojobs(state.coshell) > n) && block(0));
		if ((flags & CO_FOREGROUND) && r->active && r->active->parent && r->active->parent->prereqs && copending(state.coshell) > cojobs(state.coshell))
			serial(r, r->active->parent->prereqs);
	}
	prereqs = r->prereqs;
	if (r->active && r->active->primary)
	{
		prereqs = cons(getrule(r->active->primary), prereqs);
		flags |= CO_PRIMARY;
	}
	if (r->property & P_make)
	{
		if (r->property & P_local)
		{
			r->status = EXISTS;
			return;
		}

		/*
		 * make actions are done immediately, bypassing the job queue
		 */

		if (prereqs && complete(NiL, prereqs, NiL, 0))
			r->status = (r->property & P_dontcare) ? IGNORE : FAILED;
		else
		{
			if (action && cancel(r, prereqs))
				r->status = EXISTS;
			else if ((r->dynamic & (D_hasbefore|D_triggered)) == (D_hasbefore|D_triggered) && (makebefore(r) || complete(NiL, prereqs, NiL, 0)))
				r->status = (r->property & P_dontcare) ? IGNORE : FAILED;
			else
			{
				if (r->property & P_functional)
					setvar(r->name, null, 0);
				if (action)
					switch (parse(NiL, action, r->name, NiL))
					{
					case EXISTS:
						if (!(r->property & (P_state|P_virtual)))
							statetime(r, 0);
						break;
					case FAILED:
						r->status = (r->property & P_dontcare) ? IGNORE : FAILED;
						break;
					case TOUCH:
						r->time = internal.internal->time;
						break;
					case UPDATE:
						if ((r->property & (P_state|P_virtual)) != (P_state|P_virtual))
							r->time = CURTIME;
						break;
					}
				if (r->status == UPDATE)
					r->status = EXISTS;
			}
		}
		if ((r->property & (P_joint|P_target)) == (P_joint|P_target))
			for (p = r->prereqs->rule->prereqs; p; p = p->next)
				if (p->rule != r)
				{
					p->rule->status = r->status;
					p->rule->time = r->time;
				}
		if ((r->dynamic & (D_hasafter|D_triggered)) == (D_hasafter|D_triggered))
		{
			if (r->status == FAILED)
			{
				if (hasafter(r, P_failure) && !makeafter(r, P_failure) && !complete(NiL, prereqs, NiL, 0))
					r->status = EXISTS;
			}
			else if (hasafter(r, P_after) && (makeafter(r, P_after) || complete(NiL, prereqs, NiL, 0)))
				r->status = (r->property & P_dontcare) ? IGNORE : FAILED;
		}
	}
	else
	{
		/*
		 * only one repeat action at a time
		 */

		if ((r->property & P_repeat) && (r->property & (P_before|P_after)) && !(r->dynamic & D_hassemaphore))
		{
			a = catrule(internal.semaphore->name, ".", r->name, 1);
			a->semaphore = 2;
			r->prereqs = append(r->prereqs, cons(a, NiL));
			r->dynamic |= D_hassemaphore;
		}

		/*
		 * check if any prerequisites are blocking execution
		 * FAILED prerequisites cause the target to fail too
		 */

		n = READY;
		for (;;)
		{
			for (p = prereqs; p; p = p->next)
			{
				if ((a = p->rule)->dynamic & D_alias)
					a = makerule(a->name);
				if (a->property & P_after)
					continue;
				switch (a->status)
				{
				case FAILED:
					if (a->property & P_repeat)
						continue;
					r->status = (r->property & P_dontcare) ? IGNORE : FAILED;
					if ((r->property & (P_joint|P_target)) == (P_joint|P_target))
						for (p = r->prereqs->rule->prereqs; p; p = p->next)
							if (p->rule != r)
								p->rule->status = (p->rule->property & P_dontcare) ? IGNORE : FAILED;
					return;
				case MAKING:
					if (a->active)
						error(1, "%s: prerequisite %s is active", r->name, a->name);
					else
						n = BLOCKED;
					break;
				}
			}
			if (n != READY)
				break;
			if (action)
			{
				if (cancel(r, prereqs))
					return;
				if ((r->dynamic & D_intermediate) && r->must == 1)
				{
					n = INTERMEDIATE;
					jobs.intermediate++;
					break;
				}
			}
			if ((r->dynamic & (D_hasbefore|D_triggered)) != (D_hasbefore|D_triggered))
				break;
			if (makebefore(r))
			{
				r->status = (r->property & P_dontcare) ? IGNORE : FAILED;
				if ((r->property & (P_joint|P_target)) == (P_joint|P_target))
					for (p = r->prereqs->rule->prereqs; p; p = p->next)
						if (p->rule != r)
							p->rule->status = (p->rule->property & P_dontcare) ? IGNORE : FAILED;
				return;
			}
		}
		if (action || n != READY)
		{
			/*
			 * allocate a job cell and add to job list
			 * the first READY job from the top is executed next
			 */

			if (job = jobs.freejob)
				jobs.freejob = jobs.freejob->next;
			else
				job = newof(0, Joblist_t, 1, 0);
			if (flags & CO_URGENT)
			{
				job->prev = 0;
				if (job->next = jobs.firstjob)
					jobs.firstjob->prev = job;
				else
					jobs.lastjob = job;
				jobs.firstjob = job;
			}
			else
			{
				job->next = 0;
				if (job->prev = jobs.lastjob)
					jobs.lastjob->next = job;
				else
					jobs.firstjob = job;
				jobs.lastjob = job;
			}

			/*
			 * fill in the info
			 */

			job->target = r;
			job->prereqs = prereqs;
			job->status = n;
			job->flags = flags;
			job->action = action;
			r->status = MAKING;
			if ((r->property & (P_joint|P_target)) == (P_joint|P_target))
				for (p = r->prereqs->rule->prereqs; p; p = p->next)
					if (p->rule != r)
						p->rule->status = r->status;
			if (n == READY)
			{
				execute(job);
				if (r->dynamic & D_hasafter)
					save(job);
			}
			else
				save(job);
			jobstatus();
		}
		else
		{
			if (r->status == UPDATE)
				r->status = EXISTS;
			if ((r->property & (P_joint|P_target)) == (P_joint|P_target))
				for (p = r->prereqs->rule->prereqs; p; p = p->next)
					if (p->rule->status == UPDATE)
						p->rule->status = EXISTS;
			if ((r->dynamic & (D_hasafter|D_triggered)) == (D_hasafter|D_triggered))
			{
				if (r->status == FAILED)
				{
					if (hasafter(r, P_failure) && !makeafter(r, P_failure) && !complete(NiL, prereqs, NiL, 0))
						r->status = EXISTS;
				}
				else if (hasafter(r, P_after) && (makeafter(r, P_after) || complete(NiL, prereqs, NiL, 0)))
					r->status = (r->property & P_dontcare) ? IGNORE : FAILED;
				if (r->status == EXISTS)
				{
					char*	t;
					Sfio_t*	tmp;

					tmp = sfstropen();
					edit(tmp, r->name, KEEP, DELETE, DELETE);
					if (*(t = sfstruse(tmp)))
						newfile(r, t, r->time);
					sfstrclose(tmp);
				}
			}
		}
		if (r->dynamic & D_triggered)
		{
			r->time = CURTIME;
			if ((r->property & (P_joint|P_target)) == (P_joint|P_target))
				for (p = r->prereqs->rule->prereqs; p; p = p->next)
					p->rule->time = r->time;
		}
	}
}
示例#22
0
LabelTab::LabelTab(PlotItem* plotItem, QWidget *parent)
  : DialogTab(parent), _plotItem(plotItem), _activeLineEdit(0), _fontDirty(false) {

  setupUi(this);

  _globalLabelBold->setIcon(QPixmap(":kst_bold.png"));
  _globalLabelBold->setFixedWidth(32);
  _globalLabelItalic->setIcon(QPixmap(":kst_italic.png"));
  _globalLabelItalic->setFixedWidth(32);
  _globalLabelColor->setFixedWidth(32);
  _globalLabelColor->setFixedHeight(32);

  setTabTitle(tr("Labels"));

  setGlobalFont(_plotItem->globalFont());
  _globalLabelColor->setColor(_plotItem->globalFontColor());
  _globalLabelFontSize->setValue(_plotItem->globalFontScale());

  _topLabelText->setObjectStore(kstApp->mainWindow()->document()->objectStore());
  _bottomLabelText->setObjectStore(kstApp->mainWindow()->document()->objectStore());
  _leftLabelText->setObjectStore(kstApp->mainWindow()->document()->objectStore());
  _rightLabelText->setObjectStore(kstApp->mainWindow()->document()->objectStore());

  connect(_topLabelText, SIGNAL(textChanged()), this, SIGNAL(modified()));
  connect(_leftLabelText, SIGNAL(textChanged()), this, SIGNAL(modified()));
  connect(_bottomLabelText, SIGNAL(textChanged()), this, SIGNAL(modified()));
  connect(_rightLabelText, SIGNAL(textChanged()), this, SIGNAL(modified()));

  connect(_topLabelText, SIGNAL(textChanged()), this, SLOT(_enableLabelLabels()));
  connect(_bottomLabelText, SIGNAL(textChanged()), this, SLOT(_enableLabelLabels()));
  connect(_leftLabelText, SIGNAL(textChanged()), this, SLOT(_enableLabelLabels()));
  connect(_rightLabelText, SIGNAL(textChanged()), this, SLOT(_enableLabelLabels()));

  connect(_autoScaleNumberAxis, SIGNAL(stateChanged(int)), this, SIGNAL(modified()));
  connect(_showLegend, SIGNAL(stateChanged(int)), this, SIGNAL(modified()));

  connect(_editLegendContents, SIGNAL(pressed()), _plotItem->legend(), SLOT(edit()));

  connect(_globalLabelFontSize, SIGNAL(valueChanged(double)), this, SIGNAL(globalFontUpdate()));
  connect(_globalLabelBold, SIGNAL(toggled(bool)), this, SIGNAL(globalFontUpdate()));
  connect(_globalLabelItalic, SIGNAL(toggled(bool)), this, SIGNAL(globalFontUpdate()));
  connect(_globalLabelFontFamily, SIGNAL(currentFontChanged(QFont)), this, SIGNAL(globalFontUpdate()));
  connect(_globalLabelColor, SIGNAL(changed(QColor)), this, SIGNAL(globalFontUpdate()));
  connect(_globalLabelBold, SIGNAL(toggled(bool)), this, SLOT(buttonUpdate()));
  connect(_globalLabelItalic, SIGNAL(toggled(bool)), this, SLOT(buttonUpdate()));

  connect(_topLabelAuto, SIGNAL(toggled(bool)), this, SIGNAL(modified()));
  connect(_leftLabelAuto, SIGNAL(toggled(bool)), this, SIGNAL(modified()));
  connect(_bottomLabelAuto, SIGNAL(toggled(bool)), this, SIGNAL(modified()));
  connect(_rightLabelAuto, SIGNAL(toggled(bool)), this, SIGNAL(modified()));

  connect(_topLabelAuto, SIGNAL(toggled(bool)), this, SLOT(activateFields()));
  connect(_leftLabelAuto, SIGNAL(toggled(bool)), this, SLOT(activateFields()));
  connect(_bottomLabelAuto, SIGNAL(toggled(bool)), this, SLOT(activateFields()));
  connect(_rightLabelAuto, SIGNAL(toggled(bool)), this, SLOT(activateFields()));

  _Label_4->setProperty("si","Default plot font &size:");
  _autoScaleNumberAxis->setProperty("si","Automatically scale number axis labels");
  _topLabelLabel->setProperty("si","&Top label:");
  _topLabelAuto->setProperty("si","Auto");
  _bottomLabelLabel->setProperty("si","Botto&m label:");
  _bottomLabelAuto->setProperty("si","Auto");
  _leftLabelLabel->setProperty("si","&Left label:");
  _leftLabelAuto->setProperty("si","Auto");
  _rightLabelLabel->setProperty("si","&Right label:");
  _rightLabelAuto->setProperty("si","Auto");
  _showLegend->setProperty("si","Show le&gend");
  _editLegendContents->setProperty("si","E&dit");
}
示例#23
0
EnvironmentWidget::EnvironmentWidget(QWidget *parent, QWidget *additionalDetailsWidget)
    : QWidget(parent), d(new EnvironmentWidgetPrivate)
{
    d->m_model = new Utils::EnvironmentModel();
    connect(d->m_model, &Utils::EnvironmentModel::userChangesChanged,
            this, &EnvironmentWidget::userChangesChanged);
    connect(d->m_model, &QAbstractItemModel::modelReset,
            this, &EnvironmentWidget::invalidateCurrentIndex);

    connect(d->m_model, &Utils::EnvironmentModel::focusIndex,
            this, &EnvironmentWidget::focusIndex);

    auto vbox = new QVBoxLayout(this);
    vbox->setContentsMargins(0, 0, 0, 0);

    d->m_detailsContainer = new Utils::DetailsWidget(this);

    auto details = new QWidget(d->m_detailsContainer);
    d->m_detailsContainer->setWidget(details);
    details->setVisible(false);

    auto vbox2 = new QVBoxLayout(details);
    vbox2->setMargin(0);

    if (additionalDetailsWidget)
        vbox2->addWidget(additionalDetailsWidget);

    auto horizontalLayout = new QHBoxLayout();
    horizontalLayout->setMargin(0);
    auto tree = new Utils::TreeView(this);
    connect(tree, &QAbstractItemView::activated,
            tree, [tree](const QModelIndex &idx) { tree->edit(idx); });
    d->m_environmentView = tree;
    d->m_environmentView->setModel(d->m_model);
    d->m_environmentView->setItemDelegate(new EnvironmentDelegate(d->m_model, d->m_environmentView));
    d->m_environmentView->setMinimumHeight(400);
    d->m_environmentView->setRootIsDecorated(false);
    d->m_environmentView->setUniformRowHeights(true);
    new Utils::HeaderViewStretcher(d->m_environmentView->header(), 1);
    d->m_environmentView->setSelectionMode(QAbstractItemView::SingleSelection);
    d->m_environmentView->setSelectionBehavior(QAbstractItemView::SelectItems);
    d->m_environmentView->setFrameShape(QFrame::NoFrame);
    QFrame *findWrapper = Core::ItemViewFind::createSearchableWrapper(d->m_environmentView, Core::ItemViewFind::LightColored);
    findWrapper->setFrameStyle(QFrame::StyledPanel);
    horizontalLayout->addWidget(findWrapper);

    auto buttonLayout = new QVBoxLayout();

    d->m_editButton = new QPushButton(this);
    d->m_editButton->setText(tr("&Edit"));
    buttonLayout->addWidget(d->m_editButton);

    d->m_addButton = new QPushButton(this);
    d->m_addButton->setText(tr("&Add"));
    buttonLayout->addWidget(d->m_addButton);

    d->m_resetButton = new QPushButton(this);
    d->m_resetButton->setEnabled(false);
    d->m_resetButton->setText(tr("&Reset"));
    buttonLayout->addWidget(d->m_resetButton);

    d->m_unsetButton = new QPushButton(this);
    d->m_unsetButton->setEnabled(false);
    d->m_unsetButton->setText(tr("&Unset"));
    buttonLayout->addWidget(d->m_unsetButton);

    d->m_batchEditButton = new QPushButton(this);
    d->m_batchEditButton->setText(tr("&Batch Edit..."));
    buttonLayout->addWidget(d->m_batchEditButton);

    buttonLayout->addStretch();

    horizontalLayout->addLayout(buttonLayout);
    vbox2->addLayout(horizontalLayout);

    vbox->addWidget(d->m_detailsContainer);

    connect(d->m_model, &QAbstractItemModel::dataChanged,
            this, &EnvironmentWidget::updateButtons);

    connect(d->m_editButton, &QAbstractButton::clicked,
            this, &EnvironmentWidget::editEnvironmentButtonClicked);
    connect(d->m_addButton, &QAbstractButton::clicked,
            this, &EnvironmentWidget::addEnvironmentButtonClicked);
    connect(d->m_resetButton, &QAbstractButton::clicked,
            this, &EnvironmentWidget::removeEnvironmentButtonClicked);
    connect(d->m_unsetButton, &QAbstractButton::clicked,
            this, &EnvironmentWidget::unsetEnvironmentButtonClicked);
    connect(d->m_batchEditButton, &QAbstractButton::clicked,
            this, &EnvironmentWidget::batchEditEnvironmentButtonClicked);
    connect(d->m_environmentView->selectionModel(), &QItemSelectionModel::currentChanged,
            this, &EnvironmentWidget::environmentCurrentIndexChanged);

    connect(d->m_detailsContainer, &Utils::DetailsWidget::linkActivated,
            this, &EnvironmentWidget::linkActivated);

    connect(d->m_model, &Utils::EnvironmentModel::userChangesChanged,
            this, &EnvironmentWidget::updateSummaryText);
}
示例#24
0
BOOL CALLBACK RoomInfoProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	static std::string old_room_no;   // 原房间编号
	switch(msg)
	{
	case WM_INITDIALOG:
		{
			CListView floor_list(hwnd, IDC_L_ROOM_INFO);
			floor_list.SetSelectAndGrid(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
			floor_list.InsertColumn(1,80,"房间编号");
			floor_list.InsertColumn(2,100,"房间名称");
			try {
				InitFloorName(hwnd, IDC_FLOOR_COMBO);
				CComboBox combo(hwnd, IDC_FLOOR_COMBO);
				std::string floor_name;
				combo.GetComboBoxText(floor_name);
				ShowRoomInfo(hwnd, IDC_L_ROOM_INFO, floor_name.c_str());
			} catch (Err &err) {
				MessageBox(hwnd, err.what(), TEXT("基础信息管理"), MB_ICONERROR);
				return FALSE;
			}
			return TRUE;
		}
	case  WM_NOTIFY:
		{
			switch(LOWORD(wParam))
			{
			case IDC_L_ROOM_INFO:
				{
					if (((LPNMHDR)lParam)->code == NM_CLICK)/*点击列表中的一项*/
					{
						int index = -1;
						CEdit e_name,e_id;
						CListView room_list;
						room_list.Initialization(hwnd, IDC_L_ROOM_INFO);
						e_id.Initialization(hwnd, IDC_E_ROOM_NO);
						e_name.Initialization(hwnd, IDC_E_ROOM_NAME);
						index = room_list.GetSelectionMark();
						old_room_no = room_list.GetItem(index,0);   // 获取点中的房间编号,修改时用
						e_id.SetEditText(old_room_no);
						e_name.SetEditText(room_list.GetItem(index,1));
					}
					break;
				}
			}
			return TRUE;
		}
	case WM_COMMAND:
		{
			switch (LOWORD(wParam))
			{
			case IDC_B_ADD_ROOM:
				{
					CComboBox combo(hwnd, IDC_FLOOR_COMBO);
					std::string floor_name, room_no, room_name;
					combo.GetComboBoxText(floor_name);
					CEdit edit(hwnd, IDC_E_ROOM_NO);
					edit.GetEditText(room_no);
					if (room_no.length() > 2) {
						MessageBox(hwnd, TEXT("编号过长!\n仅允许两位!"), TEXT("基础信息管理"), MB_ICONINFORMATION);
						break;
					}
					edit.Initialization(hwnd, IDC_E_ROOM_NAME);
					edit.GetEditText(room_name);
					try {
						RoomInfo room;
						room.AddRoom(floor_name.c_str(), room_no.c_str(), room_name.c_str());
						CComboBox combo(hwnd, IDC_FLOOR_COMBO);
						std::string floor_name;
						combo.GetComboBoxText(floor_name);
						ShowRoomInfo(hwnd, IDC_L_ROOM_INFO, floor_name.c_str());
						MessageBox(hwnd, TEXT("房间信息添加成功!"), TEXT("基础信息管理"), MB_ICONINFORMATION);
					} catch (Err &err) {
						MessageBox(hwnd, err.what(), TEXT("基础信息管理"), MB_ICONERROR);
						return FALSE;
					}
					break;
				}
			case IDC_B_MODITY_ROOM:
				{
					CListView room_list(hwnd, IDC_L_ROOM_INFO);
					int select = room_list.GetSelectionMark();
					if (-1 == select) {
						MessageBox(hwnd, TEXT("请在左侧列表款选择要删除的房间编号!"), TEXT("基础信息管理"), MB_ICONINFORMATION);
						break;
					}
					CComboBox combo(hwnd, IDC_FLOOR_COMBO);
					std::string floor_name, room_no, room_name;
					combo.GetComboBoxText(floor_name);
					CEdit edit(hwnd, IDC_E_ROOM_NO);
					edit.GetEditText(room_no);       // 获取修改的房间编号
					if (room_no.length() > 2) {
						MessageBox(hwnd, TEXT("编号过长!\n仅允许两位!"), TEXT("基础信息管理"), MB_ICONINFORMATION);
						break;
					}
					edit.Initialization(hwnd, IDC_E_ROOM_NAME);
					edit.GetEditText(room_name);   // 获取修改的房间名称
					try {
						RoomInfo room;
						room.ModifyRoom(floor_name.c_str(), old_room_no.c_str(), room_no.c_str(), room_name.c_str());
						CComboBox combo(hwnd, IDC_FLOOR_COMBO);
						std::string floor_name;
						combo.GetComboBoxText(floor_name);
						ShowRoomInfo(hwnd, IDC_L_ROOM_INFO, floor_name.c_str());
						MessageBox(hwnd, TEXT("房间信息修改成功!"), TEXT("基础信息管理"), MB_ICONINFORMATION);
					} catch (Err &err) {
						MessageBox(hwnd, err.what(), TEXT("基础信息管理"), MB_ICONERROR);
						return FALSE;
					}
					break;
				}
			case IDC_B_DELETE_ROOM:
				{
					CListView room_list(hwnd, IDC_L_ROOM_INFO);
					int select = room_list.GetSelectionMark();
					if (-1 == select) {
						MessageBox(hwnd, TEXT("请在左侧列表款选择要删除的房间编号!"), TEXT("基础信息管理"), MB_ICONINFORMATION);
						break;
					}
					std::string room_no, floor_name;
					room_no = room_list.GetItem(select, 0);    // 获取房间编号
					CComboBox combo(hwnd, IDC_FLOOR_COMBO);
					combo.GetComboBoxText(floor_name);         // 获取楼层名称
					try {
						RoomInfo room;
						room.DeleteRoom(floor_name.c_str(), room_no.c_str());
						CComboBox combo(hwnd, IDC_FLOOR_COMBO);
						std::string floor_name;
						combo.GetComboBoxText(floor_name);
						ShowRoomInfo(hwnd, IDC_L_ROOM_INFO, floor_name.c_str());
						MessageBox(hwnd, TEXT("房间信息删除成功!"), TEXT("基础信息管理"), MB_ICONINFORMATION);
					} catch (Err &err) {
						MessageBox(hwnd, err.what(), TEXT("基础信息管理"), MB_ICONERROR);
						return FALSE;
					}
					break;
				}
			case IDC_B_ROOM_CANCEL:
				{
					EndDialog(hwnd,0);
					break;
				}
			case IDC_FLOOR_COMBO:
				{
					if (HIWORD(wParam) == CBN_SELCHANGE) {
						try {
							CComboBox combo(hwnd, IDC_FLOOR_COMBO);
							std::string floor_name;
							combo.GetComboBoxText(floor_name);
							ShowRoomInfo(hwnd, IDC_L_ROOM_INFO, floor_name.c_str());
						} catch (Err &err) {
							MessageBox(hwnd, err.what(), TEXT("基础信息管理"), MB_ICONERROR);
							return FALSE;
						}
						CEdit edit(hwnd, IDC_E_ROOM_NO);   // 清空右侧编辑框数据
						edit.Empty();
						edit.Initialization(hwnd, IDC_E_ROOM_NAME);
						edit.Empty();
					}
					break;
				}
			}
			return TRUE;
		}
	case WM_CLOSE:
		{
			EndDialog(hwnd,0);
			return TRUE;
		}
	}
	return FALSE;
}
示例#25
0
static void takeAction (Action *action, EnumAction actionCode) {
	unsigned int newTime, oldTime; 
	unsigned long longNewTime, longOldTime;
	int newIdxTimeframe, tempTime;
	CtnrFile *newFile;
	CtnrBlock *newBlock, *soundInsertBlock;
	int newIdxAction;
	EnumAction newActionCode;
	EnumBorderCrossing direction;
	signed long l;	
	int destination, aux, i, ret;
	int status;
	BOOL reposition = FALSE;
	BOOL isTooFar = FALSE;
	ListItem *list, *tempList;
	char filename[PATH_LENGTH];
	char *cursor, *cursor2;
	CtnrFile *replayFile;
		
	replayFile = NULL;
	list = NULL;
	oldTime = compressTime(Snd_A1800_GetCurrentTime(),context.package->timePrecision);
	newFile = 0;
	newTime = -1;
	newBlock = 0;
		
	if (actionCode == -1)
		actionCode = getActionCode(action);
	if (action) {
		aux = action->aux;
		destination = action->destination;
	}
		
	switch (actionCode) {
		case JUMP_LIST:
			stop();
			list = &context.package->lists[destination];
			context.idxActiveList = destination;
			switch (getListRotation(aux)) {
				case 0:
				    cursor = getCurrentList(list);
				    strcpy(filename,cursor);
					break;
				case 1:
				    strcpy(filename,getNextList(list,TRUE));
					break;
				case -1:
				    strcpy(filename,getPreviousList(list));
					break;
			}
			if (!filename[0]) { 
				// empty list
				insertSound(&pkgSystem.files[EMPTY_LIST_FILE_IDX],NULL,FALSE);
				// empty list of packages; redirect to current point in list of lists
				list = &context.package->lists[0];
				context.idxActiveList = 0;
			    cursor = getCurrentList(list);
			    strcpy(filename,cursor);
			} 
			if (list->listType == LIST_OF_PACKAGES) {
				// load package
				switch (filename[0]) {
					case SYS_PKG_CHAR:
						context.queuedPackageType = PKG_SYS;
						destination = replaceStack(filename+1,&pkgSystem);
						break;
					case APP_PKG_CHAR:
						context.queuedPackageType = PKG_APP;
						destination = replaceStack(filename+1,&pkgSystem);
						break;
					default:
						context.queuedPackageType = PKG_MSG;
						destination = replaceStack(filename,&pkgSystem);
						break;
				}
				context.queuedPackageNameIndex = destination;
			} else { // list->listType != LIST_OF_PACKAGES
				// play sound of subject
				newFile = getListFile(filename);
				newTime = 0;
				reposition = TRUE;
			}
			break;
		
		case JUMP_PACKAGE:
			if (aux == PKG_VARIABLE) {
				strcpy(filename,getCurrentList(&pkgSystem.lists[destination]));
				switch (filename[0]) {
					case SYS_PKG_CHAR:
						aux = PKG_SYS;
						destination = replaceStack(filename+1,&pkgSystem);
						break;
					case APP_PKG_CHAR:
						aux = PKG_APP;
						destination = replaceStack(filename+1,&pkgSystem);
						break;
					default:
						aux = PKG_MSG;
						destination = replaceStack(filename,&pkgSystem);
						break;
				}
			}
			context.queuedPackageType = aux;
			context.queuedPackageNameIndex = destination;
			break;  // sets up main loop to handle this, rather than building up a stack overflow

		case COPY:
			stop();
			tempList = &context.package->lists[destination];
			getListFilename(filename,destination,FALSE);
			cursor = getCurrentList(tempList);
			if (PRE_COPY_FILE_IDX)
				insertSound(&pkgSystem.files[PRE_COPY_FILE_IDX],NULL,TRUE);  
			ret = d2dCopy((const char *)filename,(const char *)cursor);
			if (ret == 0 && POST_COPY_FILE_IDX) 
				insertSound(&pkgSystem.files[POST_COPY_FILE_IDX],NULL,TRUE); 
//			newBlock = &context.package->blocks[aux];
//			newTime = newBlock->startTime;
//			reposition = TRUE;
			break;		

		case DELETE:
			stop();
			tempList = &context.package->lists[destination];
			getListFilename(filename,destination,TRUE);
			cursor = getCurrentList(tempList);			
			ret = findDeleteStringFromFile(LIST_PATH,filename,cursor,TRUE);
			tempList->currentFilePosition = -1; // forces next list action to reload
			if (ret != -1)
				ret = deletePackage(cursor);
			else
				logException(29,cursor,0);

			list = &context.package->lists[aux];
			context.idxActiveList = aux;
			newFile = getListFile(getCurrentList(list));
			newTime = 0;
			reposition = TRUE;

//			newBlock = &context.package->blocks[aux];
//			newTime = newBlock->startTime;
//			reposition = TRUE;
			break;
			
		case TRIM:
			stop();
			tempList = &context.package->lists[destination];
			cursor = getCurrentList(tempList);
			strcpy(filename,USER_PATH);
			strcat(filename,cursor);  //todo: address application packages
			strcat(filename,AUDIO_FILE_EXT);
			edit(filename);
			context.queuedPackageType = PKG_MSG;
			destination = replaceStack(cursor,context.package);
			context.queuedPackageNameIndex = destination;
			break;
			
		case SPEED_UP:
			adjustSpeed(SPEED_INCREMENT,TRUE);
			break;

		case SPEED_DOWN:
			adjustSpeed(-SPEED_INCREMENT,TRUE);
			break;

		case SPEED_NORMAL:
			adjustSpeed(NORMAL_SPEED,FALSE);
			break;

		case VOLUME_UP:
			adjustVolume(VOLUME_INCREMENT,TRUE,FALSE);
			break;

		case VOLUME_DOWN:
			adjustVolume(-VOLUME_INCREMENT,TRUE,FALSE);
			break;

		case VOLUME_NORMAL:
			adjustVolume(NORMAL_VOLUME,FALSE,FALSE);
			break;

		case LED_RED_ON:
			setLED(LED_RED,TRUE);
			break;	
			
		case LED_RED_OFF:
			setLED(LED_RED,FALSE);
			break;	

		case LED_GREEN_ON:
			setLED(LED_GREEN,TRUE);
			break;
			
		case LED_GREEN_OFF:	
			setLED(LED_GREEN,FALSE);
			break;

		case LED_ALL_ON:
			setLED(LED_ALL,TRUE);	
			break;	

		case LED_ALL_OFF:
			setLED(LED_ALL,TRUE);
			break;
			
		case USB_DEVICE_ON:
			setUSBDevice(TRUE);
			newBlock = &context.package->blocks[destination];
			newTime = newBlock->startTime;
			reposition = TRUE;
			break;	
					
		case USB_HOST_ON:
/*			stop();
			setUSBDevice(TRUE);
			newBlock = &context.package->blocks[destination];
			newTime = newBlock->startTime;
			reposition = TRUE;
*/			break;	
					
		case STOP:
			stop();
			enterOrExitAllBlocks(context.idxTimeframe,EXITING);
			break;

		case PLAY_PAUSE:
			status = SACM_Status();
			switch (status) {
				case 0:
//					if (context.package->pkg_type != PKG_SYS)
						markStartPlay(Snd_A1800_GetCurrentTime(),context.package->strHeapStack+context.package->idxName);
					if (context.idxActiveList == -1) {
						enterOrExitAllBlocks(context.idxTimeframe,ENTERING);
						i = getStartingBlockIdxFromTimeline(context.idxTimeframe);
						if (i != -1) 
							processStartBlock(i);
						play(context.file,getCurrentTimeframeStart());
					} else
						play(context.file,0);
					break;
				case C_SACM_RECORD:
				case C_SACM_PLAY:
					context.isPaused = TRUE;
					pause();
					break;
				case C_SACM_PAUSE:
					context.isPaused = FALSE;
					resume();	
					break;
				default:
					if (context.isPaused) {
						context.isPaused = FALSE;
						resume();	
					} else {
						context.isPaused = TRUE;
						pause();
					}		
					break;
			}
			break;
			
		case PAUSE:
			pause();
			context.isPaused = TRUE;
			break;
			
		case RECORD_TITLE: // deprecated
		case RECORD_MSG:
			stop();
/*			// Not currently allowing sound inserts before record commands since aux is used for recording from another headphone jack
			// Although the SPINS part of the headphone jack thing isn't currently working.
			if (action && hasSoundInsert(action)) {
				soundInsertBlock = &pkgSystem.blocks[getSoundInsertIdxFromAux(aux)];
				insertSound(getFileFromBlock(soundInsertBlock),soundInsertBlock,TRUE);
				wait(500);
			}
*/
			if(vCur_1 < V_MIN_RECORD_VOLTAGE) {
				refuse_lowvoltage(0);
				break;
			}
			
			cursor = getCurrentList(&pkgSystem.lists[context.package->idxMasterList]);
			do {
				strcpy(filename,USER_PATH);
				getPkgNumber(filename+strlen(USER_PATH),TRUE);
				strcat(filename,(const char *)CATEGORY_DELIM_STR);
				strcat(filename,cursor); // adds current listname to new recording name
				cursor2 = filename + strlen(filename);
				strcat(filename,AUDIO_FILE_EXT);
				ret = fileExists((LPSTR)filename); // this causes approx 1 sec delay!
			} while (ret);
			*cursor2 = 0; // remove extension
			strcpy(filename,filename+strlen(USER_PATH)); //remove path
			
			ret = createRecording(filename,aux,cursor);
			if (ret != -1) {
				destination = replaceStack(filename,context.package);
				context.queuedPackageNameIndex = destination;
				context.queuedPackageType = PKG_MSG;
			} else
				logException(28,"recording failed",RESET); //todo: add voice error msg?
			break;	

		case CALL_BLOCK:
			// TODO: handle error (return of -1) if stack is full
			stackPush(context.package,context.file,oldTime - getRewind(aux)); // times are compressed
			// this is designed to fall through
			
		case JUMP_BLOCK:
			newBlock = &context.package->blocks[destination];
			newTime = newBlock->startTime;
			reposition = TRUE;
			break;
	
		case RETURN:
			if (stackPop(&context.package,&newFile,&newTime))  // times are compressed 
				reposition = TRUE;
			break;

		case FWD:
			newActionCode = getStartEndCodeFromTimeframe(context.idxTimeframe,FORWARD_JUMPING, &newTime, &newIdxAction);
			switch (newActionCode) {
				case NOP:
				case PAUSE:
					break;
				case STOP:
					//rewind to give context before stopping
					newTime -= compressTime(BLOCK_END_LEADER,context.package->timePrecision);
					break;
				case JUMP_BLOCK:
					//follow this link
					newBlock = &context.package->blocks[context.package->actions[newIdxAction].destination];
					newTime = newBlock->startTime;
					break;
				case RETURN:
					stackPop(&context.package,&newFile,&newTime); //todo: double verify there was something on stack (shouldn't have gotten RETURN if not) 
					break;
				default:
					//no action needed
					break;
			}
			reposition = TRUE;
			break;
			
		case BACK:
			// test whether within the start leader to determine whether to go to last start or to previous start before that
			if ((oldTime - getCurrentTimeframeStart()) > compressTime(BLOCK_START_LEADER, context.package->timePrecision)) {
				// just move to start time of same timeframe 
				newTime = getCurrentTimeframeStart(); // must make sure we call the Start event 
			} else {
				newActionCode = getStartEndCodeFromTimeframe(context.idxTimeframe,BACKWARD_JUMPING, &newTime, &newIdxAction);
				switch (newActionCode) {
					case NOP:
					case PAUSE:
					case STOP:
						break;
					case JUMP_BLOCK:
						//follow this link
						newBlock = &context.package->blocks[context.package->actions[newIdxAction].destination];
						newTime = newBlock->startTime;
						break;  
					case RETURN:
						stackPop(&context.package,&newFile,&newTime); //todo: double verify there was something on stack (shouldn't have gotten RETURN if not) 
						break;
					default:
						//no action needed
						break;						
				}
			}
			reposition = TRUE;
			break;

		case JUMP_TIME:
			// skip forward/back from relative position
			// observe block boundary when they exist, but leap beyond them
			// todo:do not leap over newFile boundaries
			// if system package action, reset context to user package for this action
			if (context.returnPackage)
				context.package = context.returnPackage;
			if (context.package != &pkgSystem) {
				longOldTime = Snd_A1800_GetCurrentTime();
				l = (signed long)extractSignedTime(destination,context.package->timePrecision); // hoping this brings back an originally negative number
				longNewTime = longOldTime + l;
				if (l >= 0) 
					direction = FORWARD_JUMPING;
				else {
					direction = BACKWARD_JUMPING;
					if (abs(l) > longOldTime)
						longNewTime = 0;
				}
				newTime = compressTime(longNewTime,context.package->timePrecision);
	
				// check for interfering block events
				newIdxTimeframe = context.idxTimeframe;
				do {
					newActionCode = getStartEndCodeFromTimeframe(newIdxTimeframe,direction, &tempTime, &newIdxAction);
					if (direction == FORWARD_JUMPING) 
						isTooFar = blockTimeline[++newIdxTimeframe].time > newTime;
					else
						isTooFar = blockTimeline[--newIdxTimeframe].time < newTime;
				} while (!isTooFar && newActionCode == NOP);
				switch (newActionCode) {
					case JUMP_BLOCK:
						newBlock = &context.package->blocks[context.package->actions[newIdxAction].destination];
						newTime = newBlock->startTime;
						newFile = getFileFromBlock(newBlock);
						break;  
					case RETURN:
						stackPop(&context.package,&newFile,&newTime); //todo: double verify there was something on stack (shouldn't have gotten RETURN if not) 
						break;
					default:
						//no action needed
						break;
				}
				playActionSound(JUMP_TIME);
				reposition = TRUE;
			} // context is not system file
			break;
		case SLEEP:
			// call sleep function
			setOperationalMode((int)P_SLEEP); 
			break;
		case HALT:
			// call sleep function
			setOperationalMode((int)P_HALT); 
			break;
		case NOP:
			// no operation
			break;
		default:
			//nothing should default here
			logException(1,0,USB_MODE);
			break;
	}
		
	if (reposition) {
		//todo: am i catching every possible change in file?		
		if (newBlock && !newFile) 
			newFile = getFileFromBlock(newBlock);
		if (newFile && newFile != context.file) {
			enterOrExitAllBlocks(context.idxTimeframe,EXITING);
			context.file = newFile;
			if (!list)
				buildBlockTimelines(newFile);
			context.idxTimeframe = -1; // to signal it hasn't been set yet
			context.timeNextTimeframe = -1; // resets this -- necessary for lists that dont go to processTimelineJump
		}
		if (!list) {
			context.idxActiveList = -1;
			newIdxTimeframe = getIdxTimeline(newTime);
			if (newIdxTimeframe != context.idxTimeframe) 
				processTimelineJump(context.idxTimeframe, newIdxTimeframe);  // this resets context.idxTimeframe and context.timeNextTimeframe
		}
	}
	
	// now that context.idxTimeframe has been set for repositions, we can insert sounds
	if (action && hasSoundInsert(action)) {
		if (reposition) 
			stop();  // stop currently playing audio first or insertSound() will return to it
		if (actionCode == JUMP_TIME) {
			if (context.returnPackage)
				context.package = &pkgSystem;
			soundInsertBlock = &context.package->blocks[getSoundInsertIdxFromAux(aux)];
			insertSound(getFileFromBlock(soundInsertBlock),soundInsertBlock,TRUE);
		}
		else {
			soundInsertBlock = &context.package->blocks[getSoundInsertIdxFromAux(aux)];
			insertSound(getFileFromBlock(soundInsertBlock),soundInsertBlock,FALSE);
		}
	}
	// process start block action if landing on the start of a new block
	if (reposition && newBlock && newTime == newBlock->startTime)
		processStartBlock(newBlock - context.package->blocks);
	if (list) {
		soundInsertBlock = getStartInsert(list->actionStartEnd, list->idxFirstAction);
		if (soundInsertBlock)
			insertSound(getFileFromBlock(soundInsertBlock),soundInsertBlock,FALSE);
	}		
	if (actionCode == JUMP_TIME && context.returnPackage) {  // returning to user package after possibly inserting a system sound above
		context.package = context.returnPackage;
		context.returnPackage = NULL;
	}
	if (actionCode == SPEED_UP || actionCode == SPEED_DOWN) {
		context.isPaused = FALSE;
		resume();	
	}
	if (reposition)
		play(context.file,newTime); //todo: chg to seek if same file
	//todo: maybe for JUMP_BLOCK (not CALL_BLOCK) , allow offsets within a block (stored in first 13 bits of aux)
}
示例#26
0
int
main(int argc, char *argv[])
{
	int ch, f, error = 0;
	struct disklabel *lp;
	FILE *t;

	while ((ch = getopt(argc, argv, "ABEf:F:hRb:cdenp:tvw")) != -1)
		switch (ch) {
		case 'A':
			++aflag;
			break;
#if NUMBOOT > 0
		case 'B':
			++installboot;
			break;
		case 'b':
			xxboot = optarg;
			break;
#endif
		case 'R':
			if (op != UNSPEC)
				usage();
			op = RESTORE;
			break;
		case 'c':
			++cflag;
			break;
		case 'd':
			++dflag;
			break;
		case 'e':
			if (op != UNSPEC)
				usage();
			op = EDIT;
			break;
		case 'E':
			if (op != UNSPEC)
				usage();
			op = EDITOR;
			break;
		case 'f':
			fstabfile = optarg;
			uidflag = 0;
			break;
		case 'F':
			fstabfile = optarg;
			++uidflag;
			break;
		case 'h':
			print_unit = '*';
			break;
		case 't':
			++tflag;
			break;
		case 'w':
			if (op != UNSPEC)
				usage();
			op = WRITE;
			break;
		case 'p':
			if (strchr("bckmgtBCKMGT", optarg[0]) == NULL ||
			    optarg[1] != '\0') {
				fprintf(stderr, "Valid units are bckmgt\n");
				exit(1);
			}
			print_unit = tolower((unsigned char)optarg[0]);
			break;
		case 'n':
			donothing++;
			break;
		case 'v':
			verbose++;
			break;
		case '?':
		default:
			usage();
	}
	argc -= optind;
	argv += optind;

#if NUMBOOT > 0
	if (installboot) {
		if (op == UNSPEC)
			op = WRITEBOOT;
	} else {
		if (op == UNSPEC)
			op = READ;
	}
#else
	if (op == UNSPEC)
		op = READ;
#endif

	if (argc < 1 || (fstabfile && !(op == EDITOR || aflag)))
		usage();

	dkname = argv[0];
	f = opendev(dkname, (op == READ ? O_RDONLY : O_RDWR), OPENDEV_PART,
	    &specname);
	if (f < 0)
		err(4, "%s", specname);

	switch (op) {
	case EDIT:
		if (argc != 1)
			usage();
		readlabel(f);
		error = edit(&lab, f);
		break;
	case EDITOR:
		if (argc != 1)
			usage();
		readlabel(f);
		error = editor(f);
		break;
	case READ:
		if (argc != 1)
			usage();
		readlabel(f);
		if (tflag)
			makedisktab(stdout, &lab);
		else
			display(stdout, &lab, print_unit, 1);
		error = checklabel(&lab);
		break;
	case RESTORE:
		if (argc < 2 || argc > 3)
			usage();
		readlabel(f);
#if NUMBOOT > 0
		if (installboot && argc == 3)
			makelabel(argv[2], NULL, &lab);
#endif
		lp = makebootarea(bootarea, &lab);
		*lp = lab;
		if (!(t = fopen(argv[1], "r")))
			err(4, "%s", argv[1]);
		error = getasciilabel(t, lp);
		bzero(lp->d_uid, sizeof(lp->d_uid));
		if (error == 0)
			error = writelabel(f, bootarea, lp);
		fclose(t);
		break;
	case WRITE:
		if (dflag || aflag) {
			readlabel(f);
		} else if (argc < 2 || argc > 3)
			usage();
		else
			makelabel(argv[1], argc == 3 ? argv[2] : NULL, &lab);
		lp = makebootarea(bootarea, &lab);
		*lp = lab;
		error = checklabel(&lab);
		if (error == 0)
			error = writelabel(f, bootarea, lp);
		break;
#if NUMBOOT > 0
	case WRITEBOOT:
	{
		struct disklabel tlab;

		readlabel(f);
		tlab = lab;
		if (argc == 2)
			makelabel(argv[1], NULL, &lab);
		lp = makebootarea(bootarea, &lab);
		*lp = tlab;
		error = checklabel(&lab);
		if (error == 0)
			error = writelabel(f, bootarea, lp);
		break;
	}
#endif
	default:
		break;
	}
	exit(error);
}
示例#27
0
void EditConverter::set_str(pchar str)
{
 edit()->set_text(str);
 edit()->update();
}
CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc) :
    m_buildConfiguration(bc),
    m_configModel(new ConfigModel(this)),
    m_configFilterModel(new Utils::CategorySortFilterModel),
    m_configTextFilterModel(new Utils::CategorySortFilterModel)
{
    QTC_CHECK(bc);

    setDisplayName(tr("CMake"));

    auto vbox = new QVBoxLayout(this);
    vbox->setMargin(0);
    auto container = new Utils::DetailsWidget;
    container->setState(Utils::DetailsWidget::NoSummary);
    vbox->addWidget(container);

    auto details = new QWidget(container);
    container->setWidget(details);

    auto mainLayout = new QGridLayout(details);
    mainLayout->setMargin(0);
    mainLayout->setColumnStretch(1, 10);

    auto project = static_cast<CMakeProject *>(bc->project());

    auto buildDirChooser = new Utils::PathChooser;
    buildDirChooser->setBaseFileName(project->projectDirectory());
    buildDirChooser->setFileName(bc->buildDirectory());
    connect(buildDirChooser, &Utils::PathChooser::rawPathChanged, this,
            [this](const QString &path) {
                m_configModel->flush(); // clear out config cache...
                m_buildConfiguration->setBuildDirectory(Utils::FileName::fromString(path));
            });

    int row = 0;
    mainLayout->addWidget(new QLabel(tr("Build directory:")), row, 0);
    mainLayout->addWidget(buildDirChooser->lineEdit(), row, 1);
    mainLayout->addWidget(buildDirChooser->buttonAtIndex(0), row, 2);

    ++row;
    mainLayout->addItem(new QSpacerItem(20, 10), row, 0);

    ++row;
    m_errorLabel = new QLabel;
    m_errorLabel->setPixmap(Utils::Icons::CRITICAL.pixmap());
    m_errorLabel->setVisible(false);
    m_errorMessageLabel = new QLabel;
    m_errorMessageLabel->setVisible(false);
    auto boxLayout = new QHBoxLayout;
    boxLayout->addWidget(m_errorLabel);
    boxLayout->addWidget(m_errorMessageLabel);
    mainLayout->addLayout(boxLayout, row, 0, 1, 3, Qt::AlignHCenter);

    ++row;
    m_warningLabel = new QLabel;
    m_warningLabel->setPixmap(Utils::Icons::WARNING.pixmap());
    m_warningLabel->setVisible(false);
    m_warningMessageLabel = new QLabel;
    m_warningMessageLabel->setVisible(false);
    auto boxLayout2 = new QHBoxLayout;
    boxLayout2->addWidget(m_warningLabel);
    boxLayout2->addWidget(m_warningMessageLabel);
    mainLayout->addLayout(boxLayout2, row, 0, 1, 3, Qt::AlignHCenter);

    ++row;
    mainLayout->addItem(new QSpacerItem(20, 10), row, 0);

    ++row;
    m_filterEdit = new Utils::FancyLineEdit;
    m_filterEdit->setPlaceholderText(tr("Filter"));
    m_filterEdit->setFiltering(true);
    mainLayout->addWidget(m_filterEdit, row, 0, 1, 2);

    ++row;
    auto tree = new Utils::TreeView;
    connect(tree, &Utils::TreeView::activated,
            tree, [tree](const QModelIndex &idx) { tree->edit(idx); });
    m_configView = tree;

    m_configView->viewport()->installEventFilter(this);

    m_configFilterModel->setSourceModel(m_configModel);
    m_configFilterModel->setFilterKeyColumn(0);
    m_configFilterModel->setFilterRole(ConfigModel::ItemIsAdvancedRole);
    m_configFilterModel->setFilterFixedString("0");

    m_configTextFilterModel->setSourceModel(m_configFilterModel);
    m_configTextFilterModel->setSortRole(Qt::DisplayRole);
    m_configTextFilterModel->setFilterKeyColumn(-1);
    m_configTextFilterModel->setFilterCaseSensitivity(Qt::CaseInsensitive);

    connect(m_configTextFilterModel, &QAbstractItemModel::layoutChanged, this, [this]() {
        QModelIndex selectedIdx = m_configView->currentIndex();
        if (selectedIdx.isValid())
            m_configView->scrollTo(selectedIdx);
    });

    m_configView->setModel(m_configTextFilterModel);
    m_configView->setMinimumHeight(300);
    m_configView->setUniformRowHeights(true);
    m_configView->setSortingEnabled(true);
    m_configView->sortByColumn(0, Qt::AscendingOrder);
    auto stretcher = new Utils::HeaderViewStretcher(m_configView->header(), 0);
    m_configView->setSelectionMode(QAbstractItemView::SingleSelection);
    m_configView->setSelectionBehavior(QAbstractItemView::SelectItems);
    m_configView->setFrameShape(QFrame::NoFrame);
    m_configView->setItemDelegate(new ConfigModelItemDelegate(m_buildConfiguration->project()->projectDirectory(),
                                                              m_configView));
    QFrame *findWrapper = Core::ItemViewFind::createSearchableWrapper(m_configView, Core::ItemViewFind::LightColored);
    findWrapper->setFrameStyle(QFrame::StyledPanel);

    m_progressIndicator = new Utils::ProgressIndicator(Utils::ProgressIndicatorSize::Large, findWrapper);
    m_progressIndicator->attachToWidget(findWrapper);
    m_progressIndicator->raise();
    m_progressIndicator->hide();
    m_showProgressTimer.setSingleShot(true);
    m_showProgressTimer.setInterval(50); // don't show progress for < 50ms tasks
    connect(&m_showProgressTimer, &QTimer::timeout, [this]() { m_progressIndicator->show(); });

    mainLayout->addWidget(findWrapper, row, 0, 1, 2);

    auto buttonLayout = new QVBoxLayout;
    m_addButton = new QPushButton(tr("&Add"));
    m_addButton->setToolTip(tr("Add a new configuration value."));
    buttonLayout->addWidget(m_addButton);
    {
        m_addButtonMenu = new QMenu;
        m_addButtonMenu->addAction(tr("&Boolean"))->setData(
                    QVariant::fromValue(static_cast<int>(ConfigModel::DataItem::BOOLEAN)));
        m_addButtonMenu->addAction(tr("&String"))->setData(
                    QVariant::fromValue(static_cast<int>(ConfigModel::DataItem::STRING)));
        m_addButtonMenu->addAction(tr("&Directory"))->setData(
                    QVariant::fromValue(static_cast<int>(ConfigModel::DataItem::DIRECTORY)));
        m_addButtonMenu->addAction(tr("&File"))->setData(
                    QVariant::fromValue(static_cast<int>(ConfigModel::DataItem::FILE)));
        m_addButton->setMenu(m_addButtonMenu);
    }
    m_editButton = new QPushButton(tr("&Edit"));
    m_editButton->setToolTip(tr("Edit the current CMake configuration value."));
    buttonLayout->addWidget(m_editButton);
    m_unsetButton = new QPushButton(tr("&Unset"));
    m_unsetButton->setToolTip(tr("Unset a value in the CMake configuration."));
    buttonLayout->addWidget(m_unsetButton);
    m_resetButton = new QPushButton(tr("&Reset"));
    m_resetButton->setToolTip(tr("Reset all unapplied changes."));
    m_resetButton->setEnabled(false);
    buttonLayout->addWidget(m_resetButton);
    buttonLayout->addItem(new QSpacerItem(10, 10, QSizePolicy::Fixed, QSizePolicy::Fixed));
    m_showAdvancedCheckBox = new QCheckBox(tr("Advanced"));
    buttonLayout->addWidget(m_showAdvancedCheckBox);
    buttonLayout->addItem(new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding));

    mainLayout->addLayout(buttonLayout, row, 2);

    connect(m_configView->selectionModel(), &QItemSelectionModel::currentChanged,
            this, &CMakeBuildSettingsWidget::updateSelection);

    ++row;
    m_reconfigureButton = new QPushButton(tr("Apply Configuration Changes"));
    m_reconfigureButton->setEnabled(false);
    mainLayout->addWidget(m_reconfigureButton, row, 0, 1, 3);

    updateAdvancedCheckBox();
    setError(bc->error());
    setWarning(bc->warning());

    connect(project, &ProjectExplorer::Project::parsingStarted, this, [this]() {
        updateButtonState();
        m_configView->setEnabled(false);
        m_showProgressTimer.start();
    });

    if (m_buildConfiguration->isParsing())
        m_showProgressTimer.start();
    else {
        m_configModel->setConfiguration(m_buildConfiguration->configurationFromCMake());
        m_configView->expandAll();
    }

    connect(project, &ProjectExplorer::Project::parsingFinished,
            this, [this, buildDirChooser, stretcher]() {
        m_configModel->setConfiguration(m_buildConfiguration->configurationFromCMake());
        m_configView->expandAll();
        m_configView->setEnabled(true);
        stretcher->stretch();
        updateButtonState();
        buildDirChooser->triggerChanged(); // refresh valid state...
        m_showProgressTimer.stop();
        m_progressIndicator->hide();
    });
    connect(m_buildConfiguration, &CMakeBuildConfiguration::errorOccured,
            this, [this]() {
        m_showProgressTimer.stop();
        m_progressIndicator->hide();
    });
    connect(m_configTextFilterModel, &QAbstractItemModel::modelReset, this, [this, stretcher]() {
        m_configView->expandAll();
        stretcher->stretch();
    });

    connect(m_configModel, &QAbstractItemModel::dataChanged,
            this, &CMakeBuildSettingsWidget::updateButtonState);
    connect(m_configModel, &QAbstractItemModel::modelReset,
            this, &CMakeBuildSettingsWidget::updateButtonState);

    connect(m_showAdvancedCheckBox, &QCheckBox::stateChanged,
            this, &CMakeBuildSettingsWidget::updateAdvancedCheckBox);

    connect(m_filterEdit, &QLineEdit::textChanged,
            m_configTextFilterModel, &QSortFilterProxyModel::setFilterFixedString);

    connect(m_resetButton, &QPushButton::clicked, m_configModel, &ConfigModel::resetAllChanges);
    connect(m_reconfigureButton, &QPushButton::clicked, this, [this]() {
        m_buildConfiguration->setConfigurationForCMake(m_configModel->configurationForCMake());
    });
    connect(m_unsetButton, &QPushButton::clicked, this, [this]() {
        m_configModel->toggleUnsetFlag(mapToSource(m_configView, m_configView->currentIndex()));
    });
    connect(m_editButton, &QPushButton::clicked, this, [this]() {
        QModelIndex idx = m_configView->currentIndex();
        if (idx.column() != 1)
            idx = idx.sibling(idx.row(), 1);
        m_configView->setCurrentIndex(idx);
        m_configView->edit(idx);
    });
    connect(m_addButtonMenu, &QMenu::triggered, this, [this](QAction *action) {
        ConfigModel::DataItem::Type type =
                static_cast<ConfigModel::DataItem::Type>(action->data().value<int>());
        QString value = tr("<UNSET>");
        if (type == ConfigModel::DataItem::BOOLEAN)
            value = QString::fromLatin1("OFF");

        m_configModel->appendConfiguration(tr("<UNSET>"), value, type);
        const Utils::TreeItem *item = m_configModel->findNonRootItem([&value, type](Utils::TreeItem *item) {
                ConfigModel::DataItem dataItem = ConfigModel::dataItemFromIndex(item->index());
                return dataItem.key == tr("<UNSET>") && dataItem.type == type && dataItem.value == value;
        });
        QModelIndex idx = m_configModel->indexForItem(item);
        idx = m_configTextFilterModel->mapFromSource(m_configFilterModel->mapFromSource(idx));
        m_configView->scrollTo(idx);
        m_configView->setCurrentIndex(idx);
        m_configView->edit(idx);
    });

    connect(bc, &CMakeBuildConfiguration::errorOccured, this, &CMakeBuildSettingsWidget::setError);
    connect(bc, &CMakeBuildConfiguration::warningOccured, this, &CMakeBuildSettingsWidget::setWarning);

    updateFromKit();
    connect(m_buildConfiguration->target(), &ProjectExplorer::Target::kitChanged,
            this, &CMakeBuildSettingsWidget::updateFromKit);
    connect(m_buildConfiguration, &CMakeBuildConfiguration::enabledChanged,
            this, [this]() {
        setError(m_buildConfiguration->disabledReason());
        setConfigurationForCMake();
    });
    connect(m_buildConfiguration, &CMakeBuildConfiguration::configurationForCMakeChanged,
            this, [this]() { setConfigurationForCMake(); });

    updateSelection(QModelIndex(), QModelIndex());
}
 inline bool tst_edit(const QModelIndex &index, EditTrigger trigger, QEvent *event)
     { return edit(index, trigger, event); }
示例#30
0
int menu(userlist *users){
	system("clear"); // Clears the terminal (aesthetics!)
	printf("Welcome.\n");
	char * username = malloc(sizeof(char)*100);
	char * password = malloc(sizeof(char)*100);
	char * usertype = malloc(sizeof(char)*100);
	unsigned char c;
	do {
		c = getMenuChoice();
		switch (c) {
			case 48:
				break;
			case '1':
				// Code to add a user using the menu.
				#ifdef DEBUG
				printf("Add.\n");
				#endif
				fflush(stdin);
				username = getUsername();
				password = getPassword();
				usertype = getUsertype();
				add(users, username, password, usertype);
				getc(stdin); // Junk collection!
				break;
			case '2':
				// Code to edit a user using the menu.
				#ifdef DEBUG
				printf("Edit.\n");
				#endif
				printf("First, I'll ask for the credentials of the user you wish to edit.\n");
				username = getUsername();
				password = getPassword();
				usertype = getUsertype();
				printf("Next, I'll need the new information you wish to replace it with.\nNote: this data will overwrite the other data.\n");
				char * username2 = malloc(sizeof(char)*100);
				char * password2 = malloc(sizeof(char)*100);
				char * usertype2 = malloc(sizeof(char)*100);
				username2 = getUsername();
				password2 = getPassword();
				usertype2 = getUsertype();
				edit(users, username, password, usertype, username2, password2, usertype2);
				free(username2);
				free(password2);
				free(usertype2);
				getc(stdin); // Junk collection!
				break;
			case '3':
				// Code to delete a user using the menu.
				#ifdef DEBUG
				printf("Delete.\n");
				#endif
				fflush(stdin);
				username = getUsername();
				del(users, username);
				getc(stdin); // Junk collection!
				break;
			case '4':
				// Code to verify a user using the menu.
				#ifdef DEBUG
					printf("Verify.\n");
				#endif
				username = getUsername();
				password = getPassword();
				#ifdef DEBUG
					printf("\n%s %s\n", username, password);
				#endif
				if(verify(users, username, password) == EXIT_SUCCESS){
					printf("VALID.\n");
				}else{
					printf("INVALID.\n");
				}
				getc(stdin); // Junk collection!
				break;
#ifdef DEBUG
			case '5':
				// Code to print the list of users.
				printf("Printing them.\n");
				int pu=0;
				for (pu=0; pu<users->length; pu++) {
					print_user(users->entries[pu]);
				}
				break;
#endif
			default: printf("That is not an option. Please try again.\n");
				break;
		}
	}while(c != '0');
	system("clear");
	free(username);
	free(password);
	free(usertype);
	return EXIT_SUCCESS;
}