/// sequential sort function
void sequentialSort( const TestInfo *ti, Data *data )
{
	switch( data->medium ) {
		case File: {
			fileSort( data );
			break;
		}
		case Array: {
			qsort( data->array.data, DAL_dataSize(data), sizeof(int), compare );
			break;
		}
		default:
			DAL_UNSUPPORTED( data );
	}
}
Beispiel #2
0
Multiwin::Multiwin(std::string arg) : QWidget(NULL)
{
  //call on the parser 
  engine = new SearchEng;
  NewParse* p = new NewParse(); 
  this->parser(arg);
  engine->add_parse_from_index_file(newIndex, p);
  std::map<std::string, WebPage*> allPages = engine->getPages();


  //setting the title 
  this->setWindowTitle("GOOGLE II"); 
  //fixing  placement & width + height
  this->setGeometry(100,100, 600, 165); 
  //Overall Layout 
  overallLayout = new QVBoxLayout();  

  //Google Tu image 
  image.load("GoogleTu.png");
  imageContainer = new QLabel();
  imageContainer->setPixmap(QPixmap::fromImage(image));
  overallLayout->addWidget(imageContainer);

//searchLayout
  radioLayout = new QHBoxLayout(); 
  orRadio = new QRadioButton("OR", this); 
  andRadio = new QRadioButton("AND ", this);
  singleRadio = new QRadioButton("Single", this); 
  singleRadio->setChecked(true); 

  radioLayout->addWidget(singleRadio);
  radioLayout->addWidget(orRadio);
  radioLayout->addWidget(andRadio);
  overallLayout->addLayout(radioLayout);

  searchLayout = new QHBoxLayout();
  //search textbox
  textSearch = new QLineEdit();
  searchLayout->addWidget(textSearch); 

  //search Button 
  searchButton = new QPushButton("Search");
  searchLayout->addWidget(searchButton);
  overallLayout->addLayout(searchLayout);

//resultsLayout
   resultsLayout = new QHBoxLayout(); 

  //QTreeWidget to display the results  
  tree = new QTreeWidget;
  tree->setColumnCount(4);

  //setting the header of the TreeWidget 
  QStringList headerLabels;
  headerLabels.push_back("Filename"); 
  headerLabels.push_back("In Links"); 
  headerLabels.push_back("Out Links");
  headerLabels.push_back("Page Rank");  
  tree->setHeaderLabels(headerLabels);

  //sorting list button options
  sortList = new QVBoxLayout(); 
  sortLabel = new QLabel("Sort By: ");
  fileNameButton = new QPushButton("Filename");
  inLinkButton = new QPushButton("InLinks");
  outLinkButton = new QPushButton("OutLinks"); 
  pageRankButton = new QPushButton("Page Rank"); 
  sortList->addWidget(sortLabel); 
  sortList->addWidget(pageRankButton); 
  sortList->addWidget(fileNameButton); 
  sortList->addWidget(inLinkButton); 
  sortList->addWidget(outLinkButton);

  //The results list 
  resultsLayout->addWidget(tree);
  resultsLayout->addLayout(sortList); 
  //adding the layouts to overallLayout
  
  overallLayout->addLayout(resultsLayout);  
  //set the overall layout
  setLayout(overallLayout); 


  QVBoxLayout* mainLayout = new QVBoxLayout;
  overallLayout->addLayout(mainLayout);

  QVBoxLayout* otherLayout = new QVBoxLayout;
  otherWin = new QWidget;
  closeButton = new QPushButton("&Close Popup Window");
  otherLayout->addWidget(closeButton);
  exitButton = new QPushButton("&Exit Program"); 
  otherLayout->addWidget(exitButton); 
  overallLayout->addLayout(otherLayout);

//otherWin stuff 
  otherWin->setWindowTitle(""); 
  otherWin->setGeometry(300,200, 800, 600); 
  popupLayout = new QVBoxLayout();
  fileContent = new QTextEdit("");
  popupLayout->addWidget(fileContent);  

  //setting up bottom tier of the popup window; 
  bottom = new QHBoxLayout(); 
  inLayout = new QVBoxLayout(); 
  outLayout = new QVBoxLayout();
  sortButtons = new QVBoxLayout();  

  incomingLabel = new QLabel("Incoming");
  inList = new QTreeWidget();
  inLayout->addWidget(incomingLabel); 
  QStringList headerLabelsIn;
  headerLabelsIn.push_back("Filename"); 
  headerLabelsIn.push_back("In Links"); 
  headerLabelsIn.push_back("Out Links"); 
  inList->setHeaderLabels(headerLabelsIn);
  inLayout->addWidget(inList); 

  sortByLabel = new QLabel("SORT BY:"); 
  fSort = new QPushButton("filename");
  iSort = new QPushButton("input files");
  oSort = new QPushButton("output files"); 
  sortButtons->addWidget(sortByLabel); 
  sortButtons->addWidget(fSort); 
  sortButtons->addWidget(iSort); 
  sortButtons->addWidget(oSort); 

  outgoingLabel = new QLabel("Outgoing"); 
  outList = new QTreeWidget(); 
  outLayout->addWidget(outgoingLabel); 
  QStringList headerLabelsOut;
  headerLabelsOut.push_back("Filename"); 
  headerLabelsOut.push_back("In Links"); 
  headerLabelsOut.push_back("Out Links"); 
  outList->setHeaderLabels(headerLabelsOut);
  outLayout->addWidget(outList);
  
  bottom->addLayout(inLayout);
  bottom->addLayout(sortButtons); 
  bottom->addLayout(outLayout);
  popupLayout->addLayout(bottom);
  otherWin->setLayout(popupLayout); 
  
  QObject::connect(searchButton, SIGNAL(clicked()), this, SLOT(displayResults())); 
  QObject::connect(textSearch, SIGNAL(returnPressed()), this, SLOT(displayResults())); 
  QObject::connect(closeButton, SIGNAL(clicked()), this, SLOT(otherButtonClicked()));
  QObject::connect(fileNameButton, SIGNAL(clicked()), this, SLOT(fileSort())); 
  QObject::connect(inLinkButton, SIGNAL(clicked()), this, SLOT(inSort())); 
  QObject::connect(outLinkButton, SIGNAL(clicked()), this, SLOT(outSort())); 
  QObject::connect(pageRankButton, SIGNAL(clicked()), this, SLOT(prSort())); 
//pop up window     
  QObject::connect(fSort, SIGNAL(clicked()), this, SLOT(popFSort())); 
  QObject::connect(iSort, SIGNAL(clicked()), this, SLOT(popISort())); 
  QObject::connect(oSort, SIGNAL(clicked()), this, SLOT(popOSort())); 

  QObject::connect(inList, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(changeInLists(QTreeWidgetItem*)));
  QObject::connect(outList, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(changeOutLists(QTreeWidgetItem*)));

  QObject::connect(tree, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(mainButtonClicked()));
  QObject::connect(exitButton, SIGNAL(clicked()), this, SLOT(close()));

}