コード例 #1
0
void qm_plistview::save_selected()
{
    if (topLevelItemCount() == 0 )
        return;

    QStringList tobeSaved;

    QTreeWidgetItemIterator itr(this);
    while (*itr)
    {
        if ( (*itr)->isSelected() )
        {
            tobeSaved.push_back( (*itr)->get_file );
        }
        ++itr;
    }

    if (tobeSaved.empty())
        return;

    if (tobeSaved.size() == topLevelItemCount())
    {
        save_it();
        return;
    }

    bool ok;
    QString listname = QInputDialog::getText(this, tr("Save"),
                       tr("Enter a name for the playlist"), QLineEdit::Normal,
                       "selection", &ok);
    if ( !ok || listname.isEmpty() )
        return;

    QString result = mpdCom->save_selection(tobeSaved, listname);

    if (result.startsWith("Error:"))
    {
        result = result.section("} ",1);
        QMessageBox::warning( this, tr("Error"), result);
    }
    else
        QMessageBox::information( this, tr("Confirmation"), result);
}
コード例 #2
0
ファイル: main.c プロジェクト: karelhala/FIT-projects
//hlavni funkce starajici se o chod aplikace
int main(int argc, char **argv )
{
	unsigned int cnt = 0,old_score=1;
	char_cnt = 0;
	last_ch = 0;
	//iniciaizace HW
	initialize_hardware();
	keyboard_init();
	
	int random_number,i,j;
	Tshape myshape;
	Tmatrix matrix,pane,pom;
	int pom_matrix[8][8] = {0};
	char c=0;
	int latest_line;

	//srand(2);
	//vytvoreni noveho utvaru
	myshape = create_shape(rand()%8);
	//posun na zacatek
	matrix = move_it(myshape,pom_matrix);
	//ulozeni noveho utvaru
	pane = save_it(matrix,pom_matrix);


	set_led_d6(1);                       // rozsviceni D6
	set_led_d5(1);                       // rozsviceni D5

	//inicializace LED displeje
	P6DIR=0xff;
	P4DIR=0x0f;
	P2DIR=0xf0;
	P4OUT=0x00;
	P2OUT=0x00;
	P6OUT=0xff;
	while (1)
	{
		delay_ms(1);
		cnt++;
		//pri zmacknuti klavesy
		if (c!=last_ch){
			c=last_ch;
			//pokud byla zmacknuta 6
			if (c=='6'){
				//posunu se
				x++;
				//pokusim se ulozit na to misto utvar
				matrix = move_it(myshape,pom_matrix);
				//pokud nelze ulozit	
				if (matrix.count!=4){
					//vratim se
					x--;
					//a ulozim
					matrix = move_it(myshape,pom_matrix);				
				}
			}
			//pri zmacknuti 4  
			else if (c=='4'){
				//posunu se
				x--;
				//pokusim se ulozit
				matrix = move_it(myshape,pom_matrix);
				//pokud bych vypsal mene jak 4 znaky z utvaru
				if (matrix.count!=4){
					//posouvam se zpatky
					x++;
					matrix = move_it(myshape,pom_matrix);
				}
			}
			//pokud nactu 8
			else if (c=='8'){
				//posunu se
				y++;
				//pokusim se ulozit
				matrix = move_it(myshape,pom_matrix);
				if (matrix.count!=4){
					//pokud nelze posun, posunu se nazpet
					y--;
					matrix = move_it(myshape,pom_matrix);
					matrix.last_line = 1;
				}			
			}
			//rotace
			else if (c=='5'){
				//pouzivam prvne rotate_back kvuli "hezci" rotaci
				myshape = rotate_back(myshape);
				//pokusim se ulozit dany utvar
				matrix = move_it(myshape,pom_matrix);
				//pokud pri posunu nelze vypsat vsechny 4 prvky daneho utvaru
				if (matrix.count!=4){
					//posunu se zpatky
					myshape = rotate(myshape);
					matrix = move_it(myshape,pom_matrix);
				}		
			}
			else
			{
				continue;
			}
			//ulozim do vysledneho hraciho pole
			pane = save_it(matrix,pom_matrix);
			//pokud jsem nacetl posledni radek
			if (matrix.last_line==1)
			{
				//ulozim si hraci pole do pomocne matice
				for (i=0;i<8;i++)
				{
					for (j=0;j<8;j++)
					{
						pom_matrix[i][j] = pane.shape[i][j];
					}
				}
				matrix.last_line=0;
				//smazu radky
				pane=delete_rows(pane);

				x=0;
				y=0;
				//vygeneruji novy utvar
				myshape = create_shape(rand()%8);
				int i,t;
				//ulozim do pomocne matice hraci pole
				for (i=0;i<8;i++)
					for (t=0;t<8;t++)
						pom_matrix[i][t]=pane.shape[i][t];
				//posunu nove vygenerovany utvar na zacatek hraciho pole
				matrix = move_it(myshape,pom_matrix);
				//ulozim tento stav
				pane = save_it(matrix,pom_matrix);
				
			}
			c=last_ch;
		}
		//tisknuti skore
		if (old_score!=score && (cnt%100)==0){
			old_score=score;
			print_score("Score: ");
		}
		
		if (cnt > 1000)
		{
			cnt = 0;
			flip_led_d6();                   // negace portu na ktere je LED
		}
		
		print_it(pane.shape);
		keyboard_idle();                   // obsluha klavesnice
		terminal_idle();                   // obsluha terminalu
  } 
	
	return 0;
}
コード例 #3
0
qm_plistview::qm_plistview(QWidget *parent)
{
    setParent(parent);

    if (objectName().isEmpty())
        setObjectName("plist_view");

    // initVars
    dropBeforeIndex = -1;
    line = new QWidget(viewport());
    line->hide();
    line->setAutoFillBackground(true);
    QPalette pal = line->palette();
    pal.setColor(line->backgroundRole(), QColor("#5f8ba9"));
    line->setPalette(pal);
    setDragDropMode(QAbstractItemView::DragDrop);
    setDropIndicatorShown(false);
    setDragEnabled(true);

    current_songPos = -1;
    current_songID = -1;
    current_status = 0;
    b_panel_max = false;
    b_streamplaying = false;
    b_waspurged = true;
    b_mpd_connected = false;
    col_default_fg = this->palette().color(QPalette::Foreground);
    col_played_fg  = QColor("#70707A");
    col_playing_fg = QColor("#003070");

    //setupUI
    setRootIsDecorated(false);
    setItemsExpandable (false);
    setUniformRowHeights(true);
    setAllColumnsShowFocus(true);
    setSelectionMode(ExtendedSelection);
    sortByColumn (-1); // no sorting
    setColumnCount(6);
    QStringList labels;
    labels << "#" << " " << " " + tr("artist") + " " << " " + tr("title") + " " << " " + tr("m:s") + " " << " " + tr("album : nr") + " ";
    setHeaderLabels(labels);
    headerItem()->setIcon(1, QIcon(":/tr_trackplayed.png"));
    QObject::connect( this, SIGNAL( itemDoubleClicked (QTreeWidgetItem *, int)), this, SLOT( on_item_dclicked(QTreeWidgetItem *)));

    context_menu = new QMenu();
    this->setContextMenuPolicy(Qt::DefaultContextMenu);

    a_clearlist = new QAction(context_menu);
    a_clearlist->setText(tr("Clear list"));
    a_clearlist->setIcon(QIcon(":/tr_redcross.png"));
    QObject::connect( a_clearlist, SIGNAL( triggered() ), this, SLOT( clear_it() ) );
    context_menu->addAction(a_clearlist);

    a_delsel = new QAction(context_menu);
    a_delsel->setText(tr("Remove selected"));
    a_delsel->setIcon(QIcon(":/tr_delete.png"));
    QObject::connect( a_delsel, SIGNAL( triggered() ), this, SLOT( delete_it() ) );
    context_menu->addAction(a_delsel);

    QAction *purge = new QAction(context_menu);
    purge->setText(tr("Purge played"));
    purge->setIcon(QIcon(":/tr_purge.png"));
    QObject::connect( purge, SIGNAL( triggered() ), this, SLOT( purge_it() ) );
    context_menu->addAction(purge);
    context_menu->addSeparator();

    a_playreset = new QAction(context_menu);
    a_playreset->setText(tr("Reset status"));
    a_playreset->setIcon(QIcon(":/tr_played_reset"));
    QObject::connect( a_playreset, SIGNAL( triggered() ), this, SLOT( reset_played() ) );
    context_menu->addAction(a_playreset);

    a_shuffle = new QAction(context_menu);
    a_shuffle->setText(tr("Shuffle list"));
    a_shuffle->setIcon(QIcon(":/tr_shuffle.png"));
    QObject::connect( a_shuffle, SIGNAL( triggered() ), this, SLOT( shuffle_it() ) );
    context_menu->addAction(a_shuffle);
    context_menu->addSeparator();

    a_savelist = new QAction(context_menu);
    a_savelist->setText(tr("Save list"));
    a_savelist->setIcon(QIcon(":/tr_save.png"));
    QObject::connect( a_savelist, SIGNAL( triggered() ), this, SLOT( save_it() ) );
    context_menu->addAction(a_savelist);

    a_savesel = new QAction(context_menu);
    a_savesel->setText(tr("Save selected"));
    a_savesel->setIcon(QIcon(":/tr_saveselect.png"));
    QObject::connect( a_savesel, SIGNAL( triggered() ), this, SLOT( save_selected() ) );
    context_menu->addAction(a_savesel);
/*    context_menu->addSeparator();

    a_loadlist = new QAction(context_menu);
    a_loadlist->setText(tr("Reload list"));
    a_loadlist->setIcon(QIcon(":/menu_load.png"));
    QObject::connect( a_loadlist, SIGNAL( triggered() ), this, SLOT( reload_playlist() ) );
    context_menu->addAction(a_loadlist); */
}
コード例 #4
0
int save_map(){
	int i = 0, j = 115, tru = 1;
	char Key;
	buffer[0] = '\0';
	int x1 = 100, y1 = 2, x2 = 145, y2 = 17, min = 115, max = 130, mv = 8, ind1 = 4;
	FILE  *saved_maps;

	print_border(y1, x1, y2, x2);
	mvprintw(y1 + 1, x1 + 15, " S A V E  M A P  A S");
	mvprintw(y1 + 6, x1 + 2, " Map Name :  _______________");
	mvprintw(y1 + 13, x1 + 2, "ESC : Return to main menu ");
	attron(COLOR_WHITE | A_REVERSE);
	mvprintw(y1 + 11, x1 + 1, " Max. 15 characters(letters & num allowed!)");
	attroff(COLOR_WHITE | A_REVERSE);
	refresh();
	while (tru)
	{

		switch (Key = getch()){
		case KEY_UP: case KEY_DOWN: case KEY_LEFT: case KEY_RIGHT:  break;
		case ENTER:if (buffer[0] == '\0') name_it(); else  tru = check_if_legit(buffer); break;
		default: if (j < max) 
		{ buffer[i++] = Key; buffer[i] = '\0'; mvaddch(y1 + 6, j++, Key); 
		}; refresh(); break;
		case BACKSPACE: if (j > min) 
		{ 
			buffer[--i] = '\0'; mvaddch(y1 + 6, --j, '_'); 
		}; refresh(); break;
		case ESC: delete_menu(y1, x1, y2, x2); return 1; break;
		}
	}
	buffer[i] = '.'; buffer[i + 1] = buffer[i + 3] = 't'; buffer[i + 2] = 'x'; buffer[i + 4] = '\0';
	save_it();
	if (!(saved_maps = fopen("saved_maps.txt", "r+"))) saved_maps = fopen("saved_maps.txt", "w");
	i = 0;
	while ((Key = fgetc(saved_maps)) != EOF){   // does this map already exist in the file?
		while (Key == buffer[i])
		{
			Key = fgetc(saved_maps);
			i++;
		}
		if (i == strlen(buffer)) break; else i = 0;
	}
	if (i == strlen(buffer)) fclose(saved_maps); else // if it does->do nothing, if it doesn't, then save it in the file;
	{
		fprintf(saved_maps, "%s\n", buffer);
		fclose(saved_maps);
	}

	delete_menu(y1, x1, y2, x2);
	print_border(y1, x1, y2, x2);
	mvprintw(y1 + 4, x1 + 2, " Continue with editting this map?");
	attron(COLOR_PAIR(8));
	mvprintw(y1 + 6, x1 + 18, " Yes ");
	attroff(COLOR_PAIR(8));
	mvprintw(y1 + 8, x1 + 18, " No ");
	refresh();
	while (1){
		switch (getch()){
		case KEY_UP: menu_up(&mv, y1 + 6, &ind1, x1 + 18); break;
		case KEY_DOWN: menu_down(&mv, y1 + 8, &ind1, x1 + 18); break;
		case ENTER: if (mv == 8)
		{
			delete_menu(y1, x1, y2, x2); return 0;
		}
					else
					{
						delete_menu(y1, x1, y2, x2); return 1;
					}
					break;
		}
	}


}