예제 #1
0
extern void
CommandExportGameText(char *sz)
{

    FILE *pf;

    sz = NextToken(&sz);

    if (!plGame) {
        outputl(_("No game in progress (type `new game' to start one)."));
        return;
    }

    if (!sz || !*sz) {
        outputl(_("You must specify a file to export to (see `help export " "game text')."));
        return;
    }

    if (!confirmOverwrite(sz, fConfirmSave))
        return;

    if (!strcmp(sz, "-"))
        pf = stdout;
    else if ((pf = g_fopen(sz, "w")) == 0) {
        outputerr(sz);
        return;
    }

    ExportGameText(pf, plGame, getGameNumber(plGame), FALSE);

    if (pf != stdout)
        fclose(pf);

    setDefaultFileName(sz);
}
예제 #2
0
extern void
CommandExportMatchText(char *sz)
{

    FILE *pf;
    listOLD *pl;
    int nGames;
    char *szCurrent;
    int i;

    sz = NextToken(&sz);

    if (!sz || !*sz) {
        outputl(_("You must specify a file to export to (see `help export " "match text')."));
        return;
    }

    /* Find number of games in match */

    for (pl = lMatch.plNext, nGames = 0; pl != &lMatch; pl = pl->plNext, nGames++);

    for (pl = lMatch.plNext, i = 0; pl != &lMatch; pl = pl->plNext, i++) {

        szCurrent = filename_from_iGame(sz, i);

        if (!i) {

            if (!confirmOverwrite(sz, fConfirmSave))
                return;

            setDefaultFileName(sz);

        }


        if (!strcmp(szCurrent, "-"))
            pf = stdout;
        else if ((pf = g_fopen(szCurrent, "w")) == 0) {
            outputerr(szCurrent);
            return;
        }

        ExportGameText(pf, pl->p, i, i == nGames - 1);

        if (pf != stdout)
            fclose(pf);

    }

}
MainWindow::MainWindow(QWidget *parent) :
	QMainWindow(parent),
	_ui(new Ui::MainWindow),
	_clipboard(QApplication::clipboard()),
	_proxyModel(new QSortFilterProxyModel),
	_storageModel(),
	_objectModel(new MtpObjectsModel()),
	_uploader(new FileUploader(_objectModel, this))
{
	_ui->setupUi(this);
	setWindowIcon(QIcon(":/android-file-transfer.png"));

	_ui->listView->setModel(_proxyModel);

	_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
	_proxyModel->sort(0);
	_proxyModel->setDynamicSortFilter(true);

	_objectModel->moveToThread(QApplication::instance()->thread());

	connect(_ui->listView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), SLOT(updateActionsState()));
	connect(_ui->listView, SIGNAL(doubleClicked(QModelIndex)), SLOT(onActivated(QModelIndex)));
	connect(_ui->listView, SIGNAL(customContextMenuRequested(QPoint)), SLOT(showContextMenu(QPoint)));
	connect(_ui->actionBack, SIGNAL(triggered()), SLOT(back()));
	connect(_ui->actionGo_Down, SIGNAL(triggered()), SLOT(down()));
	connect(_ui->actionCreateDirectory, SIGNAL(triggered()), SLOT(createDirectory()));
	connect(_ui->actionUploadDirectory, SIGNAL(triggered()), SLOT(uploadDirectories()));
	connect(_ui->actionUpload_Album, SIGNAL(triggered()), SLOT(uploadAlbum()));
	connect(_ui->actionUpload, SIGNAL(triggered()), SLOT(uploadFiles()));
	connect(_ui->actionRename, SIGNAL(triggered()), SLOT(renameFile()));
	connect(_ui->actionDownload, SIGNAL(triggered()), SLOT(downloadFiles()));
	connect(_ui->actionDelete, SIGNAL(triggered()), SLOT(deleteFiles()));
	connect(_ui->storageList, SIGNAL(activated(int)), SLOT(onStorageChanged(int)));
	connect(_ui->actionRefresh, SIGNAL(triggered()), SLOT(refresh()));
	connect(_ui->actionPaste, SIGNAL(triggered()), SLOT(pasteFromClipboard()));

	connect(_objectModel, SIGNAL(onFilesDropped(QStringList)), SLOT(uploadFiles(QStringList)));
	connect(_objectModel, SIGNAL(existingFileOverwrite(QString)), SLOT(confirmOverwrite(QString)), Qt::BlockingQueuedConnection);

	connect(_clipboard, SIGNAL(dataChanged()), SLOT(validateClipboard()));
	validateClipboard();

	//fixme: find out how to specify alternative in designer
	_ui->actionBack->setShortcuts(_ui->actionBack->shortcuts() << QKeySequence("Alt+Up") << QKeySequence("Esc"));
	_ui->actionGo_Down->setShortcuts(_ui->actionGo_Down->shortcuts() << QKeySequence("Alt+Down") << QKeySequence("Enter"));
	_ui->actionCreateDirectory->setShortcuts(_ui->actionCreateDirectory->shortcuts() << QKeySequence("F7"));
	_ui->actionRefresh->setShortcuts(_ui->actionRefresh->shortcuts() << QKeySequence("Ctrl+R"));
	_ui->listView->setFocus();
}
예제 #4
0
extern void
CommandExportPositionText(char *sz)
{

    FILE *pf;
    int fHistory;
    moverecord *pmr;
    int iMove;
    GString *gsz;

    sz = NextToken(&sz);

    if (ms.gs == GAME_NONE) {
        outputl(_("No game in progress (type `new game' to start one)."));
        return;
    }

    if (!sz || !*sz) {
        outputl(_("You must specify a file to export to (see `help export " "position text')."));
        return;
    }
    pmr = get_current_moverecord(&fHistory);

    if (!confirmOverwrite(sz, fConfirmSave))
        return;

    if (!strcmp(sz, "-"))
        pf = stdout;
    else if ((pf = g_fopen(sz, "w")) == 0) {
        outputerr(sz);
        return;
    }

    gsz = g_string_new(NULL);
    TextPrologue(gsz, &ms, getGameNumber(plGame));
    fputs(gsz->str, pf);
    g_string_free(gsz, TRUE);

    if (exsExport.fIncludeMatchInfo)
        TextMatchInfo(pf, &mi);

    if (fHistory)
        iMove = getMoveNumber(plGame, pmr) - 1;
    else if (plLastMove)
        iMove = getMoveNumber(plGame, plLastMove->p);
    else
        iMove = -1;

    gsz = g_string_new(NULL);
    TextBoardHeader(gsz, &ms, getGameNumber(plGame), iMove);
    fputs(gsz->str, pf);
    g_string_free(gsz, TRUE);


    printTextBoard(pf, &ms);

    if (pmr) {

        gsz = g_string_new(NULL);
        TextAnalysis(gsz, &ms, pmr);
        fputs(gsz->str, pf);
        g_string_free(gsz, TRUE);

        if (exsExport.fIncludeAnnotation)
            TextPrintComment(pf, pmr);

    }

    TextEpilogue(pf, &ms);

    if (pf != stdout)
        fclose(pf);

    setDefaultFileName(sz);

}