Beispiel #1
0
BinaryEditor::BinaryEditor(Binary *b, QWidget *parent):NoteEditor(b, parent){
    desc = new QTextEdit;
    desc->setText(b->getDesc());
    zone->layout()->addWidget(desc);

    //Qlabel pour le lien et un bouton "..." à côté pour sélectionner un fichier
    pathZone = new QWidget;
    pathLay = new QHBoxLayout;
    path = new QLabel("File path: " + b->getPath());
    pathLay->addWidget(path);
    chPath = new QPushButton(ico_change, "Changer de fichier ...");
    pathLay->addWidget(chPath);
    pathZone->setLayout(pathLay);
    zone->layout()->addWidget(pathZone);

    //connecte le bouton à un slot de changement de fichier
    QObject::connect(desc, SIGNAL(textChanged()), this, SLOT(descMod()));
    QObject::connect(chPath, SIGNAL(clicked()), this, SLOT(changeFile()));
}
Beispiel #2
0
MergeDoc::MergeDoc(QWidget* parent, bool importMasterPages, int targetDocPageCount, int currentPage) : QDialog(parent)
{
	masterPages = importMasterPages;
	setModal(true);
	setWindowTitle((masterPages) ? tr("Import Master Page") : tr( "Import Page(s)" ));
	setWindowIcon(QIcon(loadIcon ( "AppIcon.png" )));

	count = 0;
	dialogLayout = new QVBoxLayout(this);
	dialogLayout->setMargin(10);
	dialogLayout->setSpacing(5);
	fromInfoLayout = new QGridLayout;
	fromInfoLayout->setMargin(0);
	fromInfoLayout->setSpacing(5);
	fromDocData = new QLineEdit( this );
	fromDocData->setMinimumWidth(QWidget::fontMetrics().width('a')*50);
	fromDocLabel = new QLabel( tr( "&From Document:"), this );
	fromDocLabel->setBuddy( fromDocData );
	fromInfoLayout->addWidget( fromDocLabel, 0, 0 );
	fromInfoLayout->addWidget( fromDocData, 0, 1 );
	changeButton = new QPushButton( tr( "&Select..." ), this );
	changeButton->setAutoDefault( false );
	fromInfoLayout->addWidget( changeButton, 0, 2 );
	importPageLabel = new QLabel( tr( "&Import Page(s):" ), this );
	fromInfoLayout->addWidget( importPageLabel, 1, 0 );
	if (masterPages)
	{
		importPageLabel->setText( tr("&Import Master Page") );
		masterPageNameData = new ScComboBox(this);
		masterPageNameData->setEnabled(false);
		importPageLabel->setBuddy( masterPageNameData );
		fromInfoLayout->addWidget( masterPageNameData, 1, 1, 1, 2);
	}
	else
	{
		pageNumberData = new QLineEdit( this );
		pageNumberData->setEnabled(false);
		importPageLabel->setBuddy( pageNumberData );
		pageNumberData->setToolTip( "<qt>" + tr( "Insert a comma separated list of tokens import where "
		                           "a token can be * for all the pages, 1-5 for "
		                           "a range of pages or a single page number.") + "</qt>");
		fromInfoLayout->addWidget( pageNumberData, 1, 1 );
		fromLabel = new QLabel(this);
		fromLabel->setText( tr(" from 0"));
		fromInfoLayout->addWidget( fromLabel, 1, 2 );
		createPageData = new QCheckBox( this );
		createPageData->setText( tr("Create Page(s)"));
		fromInfoLayout->addWidget( createPageData, 2, 0 );
		importWhereData = new ScComboBox( this );
		importWhereData->setEnabled(false);
		importWhereData->addItem( tr("Before Page"));
		importWhereData->addItem( tr("After Page"));
		importWhereData->addItem( tr("At End"));
		importWhereData->setCurrentIndex( 2 );
		fromInfoLayout->addWidget( importWhereData, 2, 1 );
		importWherePageData = new QSpinBox( this );
		importWherePageData->setMinimum(1);
		importWherePageData->setMaximum(targetDocPageCount);
		importWherePageData->setValue( currentPage );
		importWherePageData->setEnabled(false);
		fromInfoLayout->addWidget( importWherePageData, 2, 2 );
	}

	dialogLayout->addLayout( fromInfoLayout );
	importCancelLayout = new QHBoxLayout;
	importCancelLayout->setMargin(0);
	importCancelLayout->setSpacing(5);
	QSpacerItem* spacer = new QSpacerItem( 1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum );
	importCancelLayout->addItem( spacer );
	importButton = new QPushButton( tr( "&Import" ), this );
	importButton->setEnabled(false);
	importCancelLayout->addWidget( importButton );
	cancelButton = new QPushButton( CommonStrings::tr_Cancel, this );
	cancelButton->setDefault( true );
	importCancelLayout->addWidget( cancelButton );
	dialogLayout->addLayout( importCancelLayout );
	resize(minimumSizeHint());

	connect( importButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
	connect( cancelButton, SIGNAL( clicked() ), this, SLOT( reject() ) );
	connect( changeButton, SIGNAL( clicked() ), this, SLOT( changeFile() ) );
	if (!masterPages)
	{
		connect( importWhereData, SIGNAL( activated(int) ), this, SLOT( checkDestPageStatus(int) ) );
		connect( createPageData, SIGNAL( clicked() ), this, SLOT( enableCreateWidgets() ) );
	}
Beispiel #3
0
int main(int argc, char **argv) 
{
	int numArguments;           // Number of command line argumetns passed
	int i, j;                   // Iterators
	string c_argv[20];          // Copy of argv
	ifstream fin;               // File input stream
	ofstream fout;              //File output stream 
	bool directoryMode = false; // Set true if "-d" is passed
	mp3Tag newTag = {};         // Tag holder
	string directory;           // The directory to change to

	/* The array Arguemtns is an array of c++ strings 
	 * 0 is the name of the file being modified
	 * All other entires are by default 0
	 * 1  is filled with "-s" and 2  is the new title
	 * 3  is filled with "-a" and 4  is the new artist name
	 * 5  is filled with "-n" and 6  is the new album name
	 * 7  is filled with "-c" and 8  is the new comment
	 * 9  is filled with "-y" and 10 is the new year
	 * 11 is filled with "-g" and 12 is the new genre
	 * 13 is filled with "-t" and 14 is the new track number
	 * 
	 * After formatting, all entries which do not contain changes will be set to the string 0
	 */
	string arguments[15];

	//Check for basic valid input.  Need a mininum of 3 arguemtns, no more than 17
	if (argc < 3 || argc > 17 )
	{
		cout << "Error: invalid input" << endl << endl;
		exitWithError();
	}
	
	//First things first - convert argv into an array of c++ strings
	for(i = 0; i < argc; i++)
    {
      c_argv[i] = argv[i];
	}
	//Resize every string in c_argv to 30 for easy math and parsing later. 
	for(i = 0; i < argc; i++)
	{
		c_argv[i].resize(30);
	}

	//Rename argc to numArguments.  Always good to avoid using argc/argv directly
	numArguments = argc;

	//Check for "-l genrelist."  
	//Will exit the program if any invalid input is found
	//otherwise will print the genrelist.
	for(i = 0; i < argc; i++)
	{
		if(c_argv[i].find("-l") != string::npos && c_argv[i+1].find("genrelist") != string::npos)
		{
			printGenrelist();
			return 0;
		}
	}

	// Parse the array and check that the command line arguments are valid
	for(i = 0; i < argc; i++)
	{
		//Check for valid use with -d.  If invalid use is found, exit
		if (c_argv[i].find("-d") != string::npos)
		{
			for (j = 0; j < numArguments; j++)
			{
				// Check for valid use
				// "-d" cannot be used with "-t", "-s", or "-c"
				if(c_argv[j].find("-t") != string::npos
				|| c_argv[j].find("-s") != string::npos
				|| c_argv[j].find("-c") != string::npos)
				{
					cout << endl << "invalid use of -d";
					exitWithError();
				}
			}

			// Set bool directoryMode to true
			directoryMode = true;

			// Store the name of the directory to change to for later use
			directory = c_argv[i+1];
		}

		//Check for valid use with -f.  If invalid use is found, exit
		if (c_argv[i].find("-f") != string::npos)
		{
			for (j = 0; j < numArguments; j++)
			{
				// Check for valid use
				// "-f" cannot be used with "-d", or "-l"
				if(c_argv[j].find("-d") != string::npos
				|| c_argv[j].find("-l") != string::npos)
				{
					cout << endl << "invalid use of -f";
					exitWithError();
				}
			}
		}
	}

	//check if directoryMode was set true.  If not, modify the single file
	if (directoryMode == false)
	{
		formatArgumentArray(c_argv, arguments, 17);
		changeFile(arguments, newTag);
	}

	//If directory mode is true, modify all the mp3 files in the directory
	if (directoryMode == true)
	{
		// Change to the directory specified.
		if (_chdir(directory.c_str()) != 0)
		{
			cout << "unable to change directories!" << endl; 
			exitWithError();
		}
		
		// Format the argument array just like we did for single files
		formatArgumentArray(c_argv, arguments, 17);

		//This block fills listOfFilesInDirectory with all the mp3
		//files in the directory, up to a maximum of 20.
		_finddata_t a_file;
		intptr_t  dir_handle;
		dir_handle = _findfirst( "*.mp3", &a_file);
		if( dir_handle == -1 ) {
			cout << "No mp3 files in the directory" << endl;
		}
		i = 0;

		//Assume there is at least 1 file in the directory, so we cna use a do
		// while loop
		do
		{
			if (i <= 10)
			{
				arguments[0] = a_file.name;
				i++;
			}

			//read in, modify, and write the tag from the file
			changeFile(arguments, newTag);
		}while( _findnext( dir_handle, &a_file ) == 0 ); //go to the next file
		_findclose( dir_handle ); //clsoe the directory
	}

	//Ask the user to press enter before closing the program
	cout << "Press enter to continue" << endl;
	cin.clear();
	cin.get();
	return 0;
}