Beispiel #1
0
/**
 * LZW main compress function
 * @param s LZW state
 * @param inbuf Input buffer
 * @param insize Size of input buffer
 * @return Number of bytes written or -1 on error
 */
int ff_lzw_encode(LZWEncodeState *s, const uint8_t *inbuf, int insize)
{
    int i;

    if(insize * 3 > (s->bufsize - s->output_bytes) * 2)
    {
        return -1;
    }

    if (s->last_code == LZW_PREFIX_EMPTY)
        clearTable(s);

    for (i = 0; i < insize; i++)
    {
        uint8_t c = *inbuf++;
        int code = findCode(s, c, s->last_code);
        if (s->tab[code].hash_prefix == LZW_PREFIX_FREE)
        {
            writeCode(s, s->last_code);
            addCode(s, c, s->last_code, code);
            code = hash(0, c);
        }
        s->last_code = s->tab[code].code;
        if (s->tabsize >= s->maxcode - 1)
        {
            clearTable(s);
        }
    }

    return writtenBytes(s);
}
Beispiel #2
0
TreeItem* RhythmboxFeature::importMusicCollection() {
    qDebug() << "importMusicCollection Thread Id: " << QThread::currentThread();
     // Try and open the Rhythmbox DB. An API call which tells us where
     // the file is would be nice.
    QFile db(QDir::homePath() + "/.gnome2/rhythmbox/rhythmdb.xml");
    if (!db.exists()) {
        db.setFileName(QDir::homePath() + "/.local/share/rhythmbox/rhythmdb.xml");
        if (!db.exists()) {
            return NULL;
        }
    }

    if (!db.open(QIODevice::ReadOnly | QIODevice::Text))
        return NULL;

    //Delete all table entries of Traktor feature
    ScopedTransaction transaction(m_database);
    clearTable("rhythmbox_playlist_tracks");
    clearTable("rhythmbox_library");
    clearTable("rhythmbox_playlists");
    transaction.commit();

    transaction.transaction();
    QSqlQuery query(m_database);
    query.prepare("INSERT INTO rhythmbox_library (artist, title, album, year, "
                  "genre, comment, tracknumber, bpm, bitrate,"
                  "duration, location, rating ) "
                  "VALUES (:artist, :title, :album, :year, :genre, :comment, "
                  ":tracknumber, :bpm, :bitrate, :duration, :location, :rating )");


    QXmlStreamReader xml(&db);
    while (!xml.atEnd() && !m_cancelImport) {
        xml.readNext();
        if (xml.isStartElement() && xml.name() == "entry") {
            QXmlStreamAttributes attr = xml.attributes();
            //Check if we really parse a track and not album art information
            if (attr.value("type").toString() == "song") {
                importTrack(xml, query);
            }
        }
    }
    transaction.commit();

    if (xml.hasError()) {
        // do error handling
        qDebug() << "Cannot process Rhythmbox music collection";
        qDebug() << "XML ERROR: " << xml.errorString();
        return NULL;
    }

    db.close();
    if (m_cancelImport) {
        return NULL;
    }
    return importPlaylists();
}
	void DoMApplication::release() {
		// Borramos la información relacionada con los estados.
		clearTable();

		// Liberamos el resto de la aplicación.
		GenericApplication::release();
	}
DataStatisticsWindow::DataStatisticsWindow()
{
	_table = new QTableWidget(19,2,this);
	_table->setSelectionMode(QAbstractItemView::NoSelection);
	_table->setItemDelegate(new ItemDelegate); // Set custom item delegate to colour rows as desired

	QStringList column_headers, row_headers;
	row_headers 
		<< "Time - min" << "Distance - km" << "Elevation Gain - m" << "Elevation Loss - m"
		<< "Mean Speed - km/h" << "Mean Heart Rate - bpm" << "Mean Gradient - %" << "Mean Cadence - rpm" << "Mean Power - W"
		<< "Max Speed - km/h" << "Max Heart Rate - bpm" << "Max Gradient - %" << "Max Cadence - rpm" << "Max Power - W"
		<< "Time HR Zone1 - min" << "Time HR Zone2 - min" << "Time HR Zone3 - min" << "Time HR Zone4 - min" << "Time HR Zone5 - min";
	column_headers << " Overall " << "Selection";
	_table->setVerticalHeaderLabels(row_headers);
	_table->setHorizontalHeaderLabels(column_headers);
	for (int r = 0; r < _table->rowCount(); ++r)
	{
		_table->verticalHeaderItem(r)->setSizeHint(QSize(136,16));
		_table->setRowHeight(r,18);
	}

	_head_label = new QLabel;
	_head_label->setTextFormat(Qt::RichText);
	_head_label->setText("<b>Ride Statistics</b>");

	QVBoxLayout* layout = new QVBoxLayout();
	layout->addWidget(_head_label);
	layout->addWidget(_table);
	setLayout(layout);
	setFixedWidth(287);
	setMinimumHeight(365);
	
	clearTable();
}
Beispiel #5
0
//
// MetaTable Destructor
//
MetaTable::~MetaTable()
{
   clearTable();

   delete pImpl;
   pImpl = NULL;
}
Beispiel #6
0
int 
UtilTransactions::clearTable3(Ndb* pNdb, 
			      int records,
			      int parallelism)
{
  return clearTable(pNdb, (NdbScanOperation::ScanFlag)0,
                    records, parallelism);
}
void
QFieldContainerView::setFieldContainer(FieldContainerPtr pFC)
{
    clearTable();

    fillTable(pFC, _uiAspect);

    _pFC = pFC;
}
/*
 * HashEntry *positionTable;
    int count;
    int hits;
    int cuts;
 */
Transpositiontable::Transpositiontable(int sizeMB) {
    int hashSize = 0x100000 * sizeMB;
    count = (long) (hashSize / sizeof(HashEntry));
    count -= 2;
    count = 1 << ((int) ceil(log2(count)) - 1);
    powerKey = PosKey(count - 1);
    positionTable = new HashEntry[count];
    clearTable();
}
static void
cpSpaceHashReindexQuery(cpSpaceHash *hash, cpSpatialIndexQueryFunc func, void *data)
{
	clearTable(hash);
	
	queryRehashContext context = {hash, func, data};
	cpHashSetEach(hash->handleSet, (cpHashSetIteratorFunc)queryRehash_helper, &context);
	
	cpSpatialIndexCollideStatic((cpSpatialIndex *)hash, hash->spatialIndex.staticIndex, func, data);
}
void
QFieldContainerView::setAspect(UInt32 uiAspect)
{
    // TODO: check if this can be done smarter

    _uiAspect = uiAspect;

    clearTable();

    fillTable(getFieldContainer(), _uiAspect);
}
static void
cpSpaceHashDestroy(cpSpaceHash *hash)
{
	if(hash->table) clearTable(hash);
	cpfree(hash->table);
	
	cpHashSetFree(hash->handleSet);
	
	cpArrayFreeEach(hash->allocatedBuffers, cpfree);
	cpArrayFree(hash->allocatedBuffers);
	cpArrayFree(hash->pooledHandles);
}
void
cpSpaceHashResize(cpSpaceHash *hash, cpFloat celldim, int numcells)
{
	if(hash->spatialIndex.klass != Klass()){
		cpAssertWarn(cpFalse, "Ignoring cpSpaceHashResize() call to non-cpSpaceHash spatial index.");
		return;
	}
	
	clearTable(hash);
	
	hash->celldim = celldim;
	cpSpaceHashAllocTable(hash, next_prime(numcells));
}
DemoJuceFilter::DemoJuceFilter()
{
    zeromem (&lastPosInfo, sizeof (lastPosInfo));
    lastPosInfo.timeSigNumerator = 4;
    lastPosInfo.timeSigDenominator = 4;
    lastPosInfo.bpm = 120;
	editor = 0;
	processing = true;
	xorProcessing = andProcessing = clearProcessing = setProcessing = false;
	currentSample = 0.0f;
	bufferCycle = 0;
	clearTable();
}
void ProtoMessage::clear()
{
	if (m_protoMsg == nullptr)
	{
		return;
	}
	m_protoMsg->Clear();
	clearMap();
	clearList();
	clearTable();
	m_key = -1;
	m_dataKey = -1;
}
    void initialise (const int inputCodeSize)
    {
        setCodeSize = inputCodeSize;
        codeSize = setCodeSize + 1;
        clearCode = 1 << setCodeSize;
        endCode = clearCode + 1;
        maxCodeSize = 2 * clearCode;
        maxCode = clearCode + 2;

        getCode (0, true);

        fresh = true;
        clearTable();
        sp = stack;
    }
Beispiel #16
0
void ScoresTable::updateInformation()
{
    QFile scoresFile("scores_table.sapst");
    bool fileHasOpened = scoresFile.open(QIODevice::ReadOnly);
    if (!fileHasOpened)
    {
        if(!scoresFile.exists())
        {
            QMessageBox::information(this,
                                     tr("Information"),
                                     tr("Scores table file not found.\n"
                                        "It will be created automatically."),
                                     QMessageBox::Ok);
            bool fileHasCreated = scoresFile.open(QIODevice::WriteOnly);
            if (!fileHasCreated)
            {
                QMessageBox::warning(this,
                                     tr("Error"),
                                     tr("Cannot create scores table file."),
                                     QMessageBox::Ok);
                return;
            }
        }
        else
        {
            QMessageBox::warning(this,
                                 tr("Error"),
                                 tr("Cannot open scores table file."),
                                 QMessageBox::Ok);
            return;
        }
    }

    QString data = QString(QByteArray::fromHex(scoresFile.readAll()));
    scoresFile.close();

    if (data.size() % 70 != 0)
    {
        QMessageBox::warning(this,
                             tr("Error"),
                             tr("Scores table file was corrupted. "
                                "It will be cleared."),
                             QMessageBox::Ok);
        clearTable();
        return;
    }

    int nRecords = data.size() / 70;
    if (nRecords != tableWidget_->rowCount())
        tableWidget_->setRowCount(nRecords);

    int gameTime;
    QDateTime dateTime;
    QString name, difficulty;
    QTableWidgetItem *item;
    for (int i = 0; i < nRecords; i++)
    {
        //inserting player name in table
        name = data.mid(70*i+20, 30);
        item = tableWidget_->item(i, 0);
        if (item == 0)
        {
            item = new QTableWidgetItem;
            tableWidget_->setItem(i, 0, item);
        }
        item->setData(Qt::DisplayRole, name);

        //inserting game time in table
        gameTime = data.mid(70*i+50, 10).toInt();
        item = tableWidget_->item(i, 1);
        if (item == 0)
        {
            item = new QTableWidgetItem;
            tableWidget_->setItem(i, 1, item);
        }
        item->setData(Qt::DisplayRole, gameTime);

        //inserting difficulty in table
        difficulty = data.mid(70*i+60, 10);
        item = tableWidget_->item(i, 2);
        if (item == 0)
        {
            item = new QTableWidgetItem;
            tableWidget_->setItem(i, 2, item);
        }
        item->setData(Qt::DisplayRole, difficulty);

        //inserting date in table
        dateTime = QDateTime::fromMSecsSinceEpoch(data.mid(70*i, 20).toLongLong());
        item = tableWidget_->item(i, 3);
        if (item == 0)
        {
            item = new QTableWidgetItem;
            tableWidget_->setItem(i, 3, item);
        }
        item->setData(Qt::DisplayRole, dateTime.toString(Qt::SystemLocaleShortDate));
    }
    tableWidget_->sortByColumn(sortIndicator_.first, sortIndicator_.second);
    showDifficulty(difficultyLevelComboBox_->currentIndex());
}
Beispiel #17
0
ScoresTable::ScoresTable(QWidget* parent)
    : QWidget(parent)
{
    sortIndicator_ = qMakePair(0, Qt::AscendingOrder);

    difficultyLevelLabel_ = new QLabel(tr("Filter by a difficulty level:"));

    difficultyLevelComboBox_ = new QComboBox;
    difficultyLevelComboBox_->setToolTip(tr("Select a difficulty level"));
    difficultyLevelComboBox_->insertItem(GameDifficultyLevels::NOVICE,
                                         tr("Novice"));
    difficultyLevelComboBox_->insertItem(GameDifficultyLevels::APPRENTICE,
                                         tr("Apprentice"));
    difficultyLevelComboBox_->insertItem(GameDifficultyLevels::ADEPT,
                                         tr("Adept"));
    difficultyLevelComboBox_->insertItem(GameDifficultyLevels::EXPERT,
                                         tr("Expert"));
    difficultyLevelComboBox_->insertItem(GameDifficultyLevels::MASTER,
                                         tr("Master"));
    difficultyLevelComboBox_->insertItem(GameDifficultyLevels::OTHER,
                                         tr("All..."));
    difficultyLevelComboBox_->setCurrentIndex(GameDifficultyLevels::OTHER);

    tableWidget_ = new QTableWidget(0, 4);
    tableWidget_->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
    tableWidget_->horizontalHeader()->setToolTip(tr("Click to sort by this column"));
    tableWidget_->setEditTriggers(QAbstractItemView::NoEditTriggers);
    tableWidget_->setSelectionMode(QAbstractItemView::NoSelection);
    tableWidget_->setHorizontalHeaderLabels(QStringList() << tr("Name") <<
                                                             tr("Time") <<
                                                             tr("Difficulty") <<
                                                             tr("Data"));

    okButton_ = new QPushButton;
    okButton_->setFixedWidth(150);
    okButton_->setToolTip(tr("Close the scores table"));
    okButton_->setText(tr("OK"));

    clearTableButton_ = new QPushButton;
    clearTableButton_->setFixedWidth(150);
    clearTableButton_->setToolTip(tr("Delete all table data"));
    clearTableButton_->setText(tr("Clear table"));

    QSpacerItem* spacerItem = new QSpacerItem(0, 0,
                                              QSizePolicy::Expanding,
                                              QSizePolicy::Minimum);

    buttonsLayout_ = new QHBoxLayout;
    buttonsLayout_->addWidget(clearTableButton_);
    buttonsLayout_->addSpacerItem(spacerItem);
    buttonsLayout_->addWidget(okButton_);

    difficultyLevelLayout_ = new QHBoxLayout;
    difficultyLevelLayout_->addWidget(difficultyLevelLabel_);
    difficultyLevelLayout_->addWidget(difficultyLevelComboBox_);

    mainLayout_ = new QVBoxLayout;
    mainLayout_->addLayout(difficultyLevelLayout_);
    mainLayout_->addWidget(tableWidget_);
    mainLayout_->addLayout(buttonsLayout_);

    connect(okButton_, SIGNAL(clicked()), this, SLOT(close()));
    connect(clearTableButton_, SIGNAL(clicked()), this, SLOT(clearTable()));
    connect(tableWidget_->horizontalHeader(), SIGNAL(sectionClicked(int)),
            this, SLOT(sortByColumn(int)));
    connect(difficultyLevelComboBox_, SIGNAL(currentIndexChanged(int)),
            this, SLOT(showDifficulty(int)));

    setMinimumWidth(600);
    setLayout(mainLayout_);
    setWindowTitle(tr("Scores Table"));
    setWindowIcon(QIcon(":/img/icon.png"));
}
Beispiel #18
0
TreeItem* TraktorFeature::importLibrary(QString file) {
    //Give thread a low priority
    QThread* thisThread = QThread::currentThread();
    thisThread->setPriority(QThread::LowestPriority);
    //Invisible root item of Traktor's child model
    TreeItem* root = NULL;
    //Delete all table entries of Traktor feature
    ScopedTransaction transaction(m_database);
    clearTable("traktor_playlist_tracks");
    clearTable("traktor_library");
    clearTable("traktor_playlists");
    transaction.commit();

    transaction.transaction();
    QSqlQuery query(m_database);
    query.prepare("INSERT INTO traktor_library (artist, title, album, year,"
                  "genre,comment,tracknumber,bpm, bitrate,duration, location,"
                  "rating,key) VALUES (:artist, :title, :album, :year,:genre,"
                  ":comment, :tracknumber,:bpm, :bitrate,:duration, :location,"
                  ":rating,:key)");

    //Parse Trakor XML file using SAX (for performance)
    QFile traktor_file(file);
    if (!traktor_file.open(QIODevice::ReadOnly | QIODevice::Text)) {
        qDebug() << "Cannot open Traktor music collection";
        return NULL;
    }
    QXmlStreamReader xml(&traktor_file);
    bool inCollectionTag = false;
    //TODO(XXX) is this still needed to parse the library correctly?
    bool inEntryTag = false;
    bool inPlaylistsTag = false;
    bool isRootFolderParsed = false;
    int nAudioFiles = 0;

    while (!xml.atEnd() && !m_cancelImport) {
        xml.readNext();
        if (xml.isStartElement()) {
            if (xml.name() == "COLLECTION") {
                inCollectionTag = true;
            }
            // Each "ENTRY" tag in <COLLECTION> represents a track
            if (inCollectionTag && xml.name() == "ENTRY" ) {
                inEntryTag = true;
                //parse track
                parseTrack(xml, query);
                ++nAudioFiles; //increment number of files in the music collection
            }
            if (xml.name() == "PLAYLISTS") {
                inPlaylistsTag = true;
            } if (inPlaylistsTag && !isRootFolderParsed && xml.name() == "NODE") {
                QXmlStreamAttributes attr = xml.attributes();
                QString nodetype = attr.value("TYPE").toString();
                QString name = attr.value("NAME").toString();

                if (nodetype == "FOLDER" && name == "$ROOT") {
                    //process all playlists
                    root = parsePlaylists(xml);
                    isRootFolderParsed = true;
                }
            }
        }
        if (xml.isEndElement()) {
            if (xml.name() == "COLLECTION") {
                inCollectionTag = false;
            }
            if (xml.name() == "ENTRY" && inCollectionTag) {
                inEntryTag = false;
            }
            if (xml.name() == "PLAYLISTS" && inPlaylistsTag) {
                inPlaylistsTag = false;
            }
        }
    }
    if (xml.hasError()) {
         // do error handling
         qDebug() << "Cannot process Traktor music collection";
         if (root)
             delete root;
         return NULL;
    }

    qDebug() << "Found: " << nAudioFiles << " audio files in Traktor";
    //initialize TraktorTableModel
    transaction.commit();

    return root;
}
    int readLZWByte()
    {
        if (fresh)
        {
            fresh = false;

            for (;;)
            {
                firstcode = oldcode = getCode (codeSize, false);

                if (firstcode != clearCode)
                    return firstcode;
            }
        }

        if (sp > stack)
            return *--sp;

        int code;

        while ((code = getCode (codeSize, false)) >= 0)
        {
            if (code == clearCode)
            {
                clearTable();
                codeSize = setCodeSize + 1;
                maxCodeSize = 2 * clearCode;
                maxCode = clearCode + 2;
                sp = stack;
                firstcode = oldcode = getCode (codeSize, false);
                return firstcode;
            }
            else if (code == endCode)
            {
                if (dataBlockIsZero)
                    return -2;

                uint8 buf [260];
                int n;

                while ((n = readDataBlock (buf)) > 0)
                {}

                if (n != 0)
                    return -2;
            }

            const int incode = code;

            if (code >= maxCode)
            {
                *sp++ = firstcode;
                code = oldcode;
            }

            while (code >= clearCode)
            {
                *sp++ = table[1][code];
                if (code == table[0][code])
                    return -2;

                code = table[0][code];
            }

            *sp++ = firstcode = table[1][code];

            if ((code = maxCode) < maxGifCode)
            {
                table[0][code] = oldcode;
                table[1][code] = firstcode;
                ++maxCode;

                if (maxCode >= maxCodeSize && maxCodeSize < maxGifCode)
                {
                    maxCodeSize <<= 1;
                    ++codeSize;
                }
            }

            oldcode = incode;

            if (sp > stack)
                return *--sp;
        }

        return code;
    }
Beispiel #20
0
void LLUIColorTable::clear()
{
	clearTable(mLoadedColors);
	clearTable(mUserSetColors);
}
Beispiel #21
0
  /** 
   * This method loads a text file into the table.
   * 
   */
  void TableMainWindow::loadTable () {
    QString fn = QFileDialog::getOpenFileName((QWidget*)parent(),
                                            "Select file to load",
                                            ".",
                                            "Text Files (*.txt)");

    //If the user cancelled or the filename is empty return
    if (fn.isEmpty()) return;

    p_currentFile.setFileName( fn );
    p_save->setEnabled(true);

    bool success = p_currentFile.open(QIODevice::ReadOnly);
    if(!success) {
      QMessageBox::critical((QWidget *)parent(),
                   "Error", "Cannot open file, please check permissions");
      p_currentFile.setFileName("");
      p_save->setDisabled(true);
      return;
    }

    clearTable();

    QList<int> column = QList<int>();

    //Set all headers to be hidden
    for (int i=0; i < p_listWidget->count() ; i++) {
      p_listWidget->item(i)->setCheckState(Qt::Unchecked);
    }

    // Strip headers off the table into the temp string
    QString temp = p_currentFile.readLine();
    temp.remove("Positive ");
    temp.remove("\"");
    temp.remove("\n");
    QStringList list = temp.split(",");

    // Loop through checking header names and setting relevant columns visible
    for (int i = 0; i < list.count(); i++) { 
      for(int j = 0; j < p_itemList.size(); j++){

        //Special cases
        if(p_itemList[j]->text() == "Ground Range" && (list[i] == "Start Latitude" || list[i] == "Start Longitude" ||
                                                       list[i] == "End Latitude" || list[i] == "End Longitude")) {
          p_itemList[j]->setCheckState(Qt::Checked);
          break;
        }
        if(p_itemList[j]->text() == "Pixel Range" && (list[i] == "Start Sample" || list[i] == "Start Line" ||
                                                       list[i] == "End Sample" || list[i] == "End Line")) {
          p_itemList[j]->setCheckState(Qt::Checked);
          break;
        }
        if(p_itemList[j]->text() == "Pixel Range" && (list[i] == "Sample" || list[i] == "Line")) {
          p_itemList[j]->setCheckState(Qt::Checked);
          break;
        }
        if(p_itemList[j]->text() == "Sample:Line" && (list[i] == "Sample" || list[i] == "Line")) {
          p_itemList[j]->setCheckState(Qt::Checked);
          break;
        }
        if(p_itemList[j]->text() == "Planetocentric Lat" && list[i] == "Planetocentric Latitude") {
          p_itemList[j]->setCheckState(Qt::Checked);
          break;
        }
        if(p_itemList[j]->text() == "Planetographic Lat" && list[i] == "Planetographic Latitude") {
          p_itemList[j]->setCheckState(Qt::Checked);
          break;
        }
        if(p_itemList[j]->text() == "Projected X:Projected Y" && (list[i] == "Projected X" || list[i] == "Projected Y")) {
          p_itemList[j]->setCheckState(Qt::Checked);
          break;
        }
        if(p_itemList[j]->text() == "Radius" && list[i] == "Local Radius") {
          p_itemList[j]->setCheckState(Qt::Checked);
          break;
        }
        if(p_itemList[j]->text() == "XYZ" && (list[i] == "Point X" || list[i] == "Point Y" || list[i] == "Point Z")) {
          p_itemList[j]->setCheckState(Qt::Checked);
          break;
        }
        if(p_itemList[j]->text() == "Ra:Dec" && (list[i] == "Right Ascension" || list[i] == "Declination")) {
          p_itemList[j]->setCheckState(Qt::Checked);
          break;
        }
        if(p_itemList[j]->text() == "Spacecraft Position" && (list[i] == "Spacecraft X" || list[i] == "Spacecraft Y" || list[i] == "Spacecraft Z")) {
          p_itemList[j]->setCheckState(Qt::Checked);
          break;
        }   
        if(p_itemList[j]->text() == "Ephemeris iTime" && list[i] == "Ephemeris Time") {
          p_itemList[j]->setCheckState(Qt::Checked);
          break;
        }
        if(p_itemList[j]->text() == "Local Solar iTime" && list[i] == "Local Solar Time") {
          p_itemList[j]->setCheckState(Qt::Checked);
          break;
        }
        if(p_itemList[j]->text() == "Segments Sum" && list[i] == "Segments Sum km") {
          p_itemList[j]->setCheckState(Qt::Checked);
          break;
        }
        //End special cases


        if(p_itemList[j]->text() == list[i]) { 
          p_itemList[j]->setCheckState(Qt::Checked);
          break;
        }
      }  
    
      // Loop through column headers to try to find a match
      bool match = false;
      for (int cols=0; cols < p_table->columnCount(); cols++) {
        QString header = p_table->horizontalHeaderItem(cols)->text();

        header.remove("Positive");
        header.remove("\n");
        header.remove(" ");

        list[i].remove(" ");

        if(header == list[i]) {
          column.push_back(cols);
          match = true;
          break;

        }
      }
      if (!match) column.push_back(-1);
    }

    // Read data into table
    QString str = p_currentFile.readLine();
    
    while (str.count() != 0) {
      // Do we need more rows?
      if (p_currentRow+1 > p_table->rowCount()) {
        p_table->insertRow(p_currentRow);
        for (int c=0; c<p_table->columnCount(); c++) {
          QTableWidgetItem *item = new QTableWidgetItem("");
          p_table->setItem(p_currentRow,c,item);
          if (c == 0) p_table->scrollToItem(item);
        }
      }

      str.remove("\n");

      QStringList list = str.split(",");
 
      for (int i=0; i < column.size(); i++) {
        QTableWidgetItem *newItem = new QTableWidgetItem(list[i]);
        if (column[i] != -1) {
          p_table->setItem(p_currentRow, column[i], newItem);
        }
      }
      p_currentRow++;
      p_currentIndex++;


      str = p_currentFile.readLine();
    }

    p_currentFile.close();
    this->setWindowTitle(p_title + " : " + fn);
    emit fileLoaded();
  }
Beispiel #22
0
int main()
{
    /** Variables to measure the time **/
    double start,finish;

    node *Table[MAX];
    clearTable(Table);
    char input[CHARS];

    int j,k,i,x;

    /** For Hash function 1, dispersion and time for inserting the elements**/
    start=clock();
    for(k=1;k<=200;k++)
        for(j=1;j<=10;j++)
        {
            strcpy(input,mkrndstr(j));
            x=hashFunction1(input);
            if (hasValue(Table[x],input))
            {
                /**printf("%s is in the table!\n",input);**/
            }
            else
            {
                    Table[x] = insertValue(Table[x],input);
            }
        }
    finish=clock();
    printf("\nThe time (in seconds) for 1st function=%lf \n",(finish-start)/CLOCKS_PER_SEC);

    printf("\nDispersion for 1st function:\n");
    for (i=0;i<MAX;i++)
    {
        printf("[%d]: %d \n",i,countElements(Table[i]));
    }


    /** For Hash function 2, dispersion and time for inserting the elements**/
    clearTable(Table);
    start=clock();
    for(k=1;k<=200;k++)
        for(j=1;j<=10;j++)
        {
            strcpy(input,mkrndstr(j));
            x=hashFunction2(input);
            if (hasValue(Table[x],input))
            {
                /**printf("%s is in the table!\n",input);**/
            }
            else
            {
                    Table[x] = insertValue(Table[x],input);
            }
        }
    finish=clock();
    printf("\nThe time (in seconds) for 2nd function=%lf \n",(finish-start)/CLOCKS_PER_SEC);
    printf("\nDispersion for 2nd function:\n");
    for (i=0;i<MAX;i++)
    {
        printf("[%d]: %d \n",i,countElements(Table[i]));
    }


    /**
    node *Table[MAX];
    clearTable(Table);
    char input[CHARS];
    int in=-1;
    int i;
    while(in!=0)
    {
        printf("(1)Insert\n(2)Search\n(3)Count all\n(4)List all\n(0)Escape\n\n");
        printf(" > ");
        scanf("%d",&in);
        switch(in)
        {
            case 1:
                printf("\tInserting: \n");
                printf("\t > ");
                scanf("%s",input);
                if (hasValue(Table[hashFunction1(input)],input))
                {
                    printf("%s is in the table!\n",input);
                }
                else
                {
                    Table[hashFunction1(input)] = insertValue(Table[hashFunction1(input)],input);
                }
                break;
            case 2:
                printf("\tSearching value: \n");
                printf("\t > ");
                scanf("%s", &input);
                if (hasValue(Table[hashFunction1(input)],input))
                {
                    printf("%s is in the table!\n",input);
                }
                else
                {
                    printf("%s is not in the table!\n",input);
                }
                break;
            case 4:
                for (i = 0; i < MAX; i++)
                {
                    printf("[%d] ",i);
                    printList(Table[i]);
                }
                break;
            case 3:
                for (i = 0; i < MAX; i++)
                {
                    printf("\n[%d]: %d ",i, countElements(Table[i]));
                }
                break;
        }
        printf("_______________________________________________________\n");
    }
    **/
    return 0;
}
Beispiel #23
0
void freqDmaRun(void)
{

	LDD_TDeviceData *DMAPtr = NULL;
	LDD_DMA_TTransferDescriptor TransferDesc;
	
	volatile bool Completed = FALSE;
	bool monitorEnable = FALSE;
	unsigned int uTimerCaptureClock = CAPTURE_CLOCK_HZ;
  
	// My local init
	clearTable();

	                         
		
	
	// Init the DMA		
	TransferDesc = DMA_TRANSFER_DESC_NULL;
  TP3_ptr = TP3_Init(NULL);
  TP4_ptr = TP4_Init(NULL);
  // TINT1Ptr = TINT1_Init(NULL);
  DMAPtr = DMA0_Init(NULL);
  /* Initialize transfer descriptor */
  	// Source
  TransferDesc.SourceAddress = (LDD_DMA_TAddress)&FTM0_C4V;											//	(FTM1_C0SC, FTM1_C0V)  FTM1_CH0 capture
  TransferDesc.SourceAddressOffset = (LDD_DMA_TAddressOffset)0;										//	Single source		
  TransferDesc.SourceTransferSize = (LDD_DMA_TTransferSize)DMA_PDD_16_BIT;				//	16-bit value
  TransferDesc.SourceModuloSize = (LDD_DMA_TModuloSize)0;													// 	non relevant (single source)
  	// Destination
  TransferDesc.DestinationAddress = (LDD_DMA_TAddress)aDmaCaptureTbl;								//	Move to Capture table	
  TransferDesc.DestinationAddressOffset = (LDD_DMA_TAddressOffset)sizeof(aDmaCaptureTbl[0]);	// Next write offset
  TransferDesc.DestinationTransferSize = (LDD_DMA_TTransferSize)DMA_PDD_16_BIT;		// moving 16-bit data
  TransferDesc.DestinationModuloSize = (LDD_DMA_TModuloSize)0;										// we will set manually a new address
    
    // We have Major loop = Move 4 bytes per interrupt and repeat 8 times 
  TransferDesc.TransferMode = LDD_DMA_NESTED_TRANSFERS;						
  TransferDesc.ByteCount = (LDD_DMA_TByteCount)2;	
  TransferDesc.OuterLoopCount = (LDD_DMA_TOuterLoopCount)NBR_DMA_CAPTURE_SAMPLES;
    
    //	DMA channel
  TransferDesc.ChannelAutoSelection = FALSE;// TRUE;								// Fixed to ch 0	
  TransferDesc.ChannelNumber = (LDD_DMA_TChannelNumber)0;		// Channel 0 in this example
    
    //	Trigger
  TransferDesc.TriggerType = LDD_DMA_HW_TRIGGER;						// Triggered by Peripheral request
  																										//	
  TransferDesc.TriggerSource = (LDD_DMA_TTriggerSource)24;	// DMA source Table 3-24 == FTM0_CH4 
  TransferDesc.Interrupts = TRUE;	// we are here									We are not going to interrupt on DMA transfer complete 
  TransferDesc.OnComplete = TRUE;										// Signal an DMA-done	
  TransferDesc.OnCompleteEventPtr = &TransferComplete;			// call this function
  TransferDesc.UserDataPtr = (LDD_TUserData*)&Completed;		// the UserDataPtr to pass data	
    
    // AFter transfer
  TransferDesc.AfterTransferComplete = LDD_DMA_ADDRESS_ADJUSTMENT;
  TransferDesc.DestinationAddressAdjustment = -(2*NBR_DMA_CAPTURE_SAMPLES);	
  
  /* Start DMA transfer */
  DMA0_AllocateChannel(DMAPtr, &TransferDesc);					// Still need to call this method even  we have a fixed channel
  DMA0_EnableChannel(DMAPtr, &TransferDesc);						// This moves the TransferDesc to the TCD 32 bytes
  // DMA0_StartChannelTransfer(DMAPtr, &TransferDesc);
    
  
      
  //============ Using PEX DMA, TCAP Components =========================
  // TCAP:TimerUnit_LDD  !!! DO not enable in init code and do not Autoninit in PEX properties !!  
  TimerPtr = TCAP_Init(NULL);		// 	Set the desired PEX Properties and get the pointer to static memory
  //	Individually disable Channels 
  FTM0_C0SC &= ~FTM_CnSC_CHIE_MASK;		// Disable CH0 interrupt and repeat for other channels
  FTM0_C4SC &= ~FTM_CnSC_CHIE_MASK;		// Disable CH1 interrupt
  FTM0_C0V = 0x7FFF;									//	Need to have DMA ready before OVrs
    
  // 	Enable the base Timer Module by selecting the clk source in CLKS[FTM1_SC]
  TCAP_Enable(TimerPtr);
  // DONE! to start capturing, enable the Channel capture IE in the App
  
  
  // remove Debug UART buffering (stream i/o)
  setvbuf(stdout, NULL, _IONBF, 0); // no buffering on stdout - for printf()
  setvbuf(stdin, NULL, _IONBF, 0); // no buffering on stdin - for getchar() etc
  
  printf("Capture FTM1_CH0 at PTA12 - press '1','t' to start, 'm' to monitor\n\r");
  printf("\n\r");
  unsigned int uLocalCapture=0;
  
  // Init Periodic Time Interrupt
  // TINT1_Enable(TINT1Ptr);	// Enable interrupts after we get the pointer to PTA17
  int i, ch =0;
  uCapture = uLocalCapture =0;
  float fFreq;
  unsigned int uCtr=0;
    	
  while(1)
  {
  	if(uLocalCapture != uCapture)
  	{
  		if(uCapture > 99)
  			uCapture =0;
  		uLocalCapture = uCapture; 
  		  		
  		// PTA17_NegVal(PTA17_ptr);
  		printf("(%2u,%u) ", uCapture, tPeriodIsr);	// Isr executed 
  	}
  	if( (ch = getchar()) != EOF )
  	switch(ch)
  	{
  	// Diable all interrupts
  	case '0':	
  		FTM0_C0SC &= 	~FTM_CnSC_CHIE_MASK;
  		FTM0_C4SC &=  ~(FTM_CnSC_CHIE_MASK | FTM_CnSC_DMA_MASK);		
  		break;
  	// Enable DMA 
  	case '1' :
  		FTM0_C4SC |= (FTM_CnSC_CHIE_MASK | FTM_CnSC_DMA_MASK);		// Enable TCAP_CH4 DMA request
  		break;
  		
  	// Enable Isr in Capture 
  	case '2' :
  		FTM0_C4SC |= FTM_CnSC_CHIE_MASK;													// Test TCAP_CH4 ISR is working
  		break;
  		
  	// Enable (OvfIsr)
  	case 't' : case 'T':
  	  FTM0_C0SC |= FTM_CnSC_CHIE_MASK;													// Test TCAP_CH0 (OVF) ISR is working		
  	  break;
  	
  	case '4':
 			monitorEnable = monitorEnable ? 0 :1;
 			break;
 			
 		case 'm':
 			//  			bDisplay = TRUE;
 			monitorEnable = monitorEnable? FALSE : TRUE;
 			break;
 		case '?': 
 			printf("\r\nMon=%d, Clk= %u, type '+'/'-' to inc/dec", monitorEnable, uTimerCaptureClock);
 			if(tFreqInput.uNbrEdges >1 )
 				fFreq = (float)tFreqInput.uNbrEdges * uTimerCaptureClock/tFreqInput.utCalcPeriod.l;	//(saves one multiplication)
 			else
 				fFreq = (float)uTimerCaptureClock/tFreqInput.utCalcPeriod.l;
 			//	Output the value
 			printf("%5u %f\r\n", ++uCtr, fFreq);
 			  		
 			break;
 			
 		case ' ':
 			bDisplay = TRUE;
 			break;
 		case '+':
 			++uTimerCaptureClock;
 			break;
 		case '-':
 			--uTimerCaptureClock;
 			break;
 			
 		case 'c': case 'C':
 			clearTable();
 			break;
 			
  	}
  	if(monitorEnable && tFreqInput.fNewFreq)
  	{
  		//TP3_SetVal(TimerPtr);
  		tFreqInput.fNewFreq = FALSE;
  		if(tFreqInput.uNbrEdges >1 )
  			fFreq = (float)tFreqInput.uNbrEdges * uTimerCaptureClock/tFreqInput.utCalcPeriod.l;	//(saves one multiplication)
  		else
  			fFreq = (float)uTimerCaptureClock/tFreqInput.utCalcPeriod.l;
  		//	Output the value
  		printf("%5u %f\r\n", ++uCtr, fFreq);
  		
  		//TP3_ClrVal(TimerPtr); 
  	}
  		
  }
  //  DMA_Deinit(DMAPtr);
  // TIMER_Deinit(TimerPtr);
	
}
void DemoJuceFilter::releaseResources()
{
	clearTable();
}
static void
cpSpaceHashRehash(cpSpaceHash *hash)
{
	clearTable(hash);
	cpHashSetEach(hash->handleSet, (cpHashSetIteratorFunc)rehash_helper, hash);
}
Beispiel #26
0
void freqDmaRun(void)
{
	uint8 i;
	
  bool fTCapCmpIE = 0, afDmaIE[NBR_FREQ_CHANNELS] = {0,0,0,0};
  const char abHelpStr[] = 
  		"\r\nFrequency Measurement Using DMA, press:\r\n" \
  		"'t' to toggle Tcap IE\r\n" \
  		"'1' to '4' to toggle DMA channel IE\r\n" \
  		"'+'/'-' to adjust TCAP Clock frequency calibration\n\r" \
  		"'n' to toggle new line\n\r" \
  		"'?' displays this message\r\n";
  
  
	// My local init
	clearTable();
	
	uPeriodLimit = 40000L;
	uint16 uPreset = 4;
	
	// Init Test points GPIOs
	TP3_ptr = TP3_Init(NULL);
	TP4_ptr = TP4_Init(NULL);
	
	// Init the DMA		
	initFreqDma();
  // DONE! to start capturing, enable the Channel capture IE in the App
  
	bChannelEnblMsk = 0x0F;
  
  // remove Debug UART buffering (stream i/o)
  setvbuf(stdout, NULL, _IONBF, 0); // no buffering on stdout - for printf()
  setvbuf(stdin, NULL, _IONBF, 0); // no buffering on stdin - for getchar() etc
  
  unsigned int uLocalCapture=0;
  
  // Init Periodic Time Interrupt
  // TINT1_Enable(TINT1Ptr);	// Enable interrupts after we get the pointer to PTA17
  int ch =0;
  uCapture = uLocalCapture =0;
  printf("%s", abHelpStr);
  while(1)
  {
  	if( (ch = getchar()) != EOF )
  	switch(ch)
  	{
  	// Diable all interrupts
  	case '0':	
  		
  		FTM0_C0SC &= 	~FTM_CnSC_CHIE_MASK;
  		fTCapCmpIE = FALSE;
  		afDmaIE[0] = afDmaIE[1] = afDmaIE[2] = afDmaIE[3] = FALSE;
  		FTM0_C4SC &=  ~(FTM_CnSC_CHIE_MASK | FTM_CnSC_DMA_MASK);
  		FTM0_C5SC &=  ~(FTM_CnSC_CHIE_MASK | FTM_CnSC_DMA_MASK);
  		FTM0_C6SC &=  ~(FTM_CnSC_CHIE_MASK | FTM_CnSC_DMA_MASK);
  		FTM0_C7SC &=  ~(FTM_CnSC_CHIE_MASK | FTM_CnSC_DMA_MASK);
  		break;
  		
  	// Enable/Dsbl DMA on Ch 1
  	case '1' :
  		if(!afDmaIE[0])
  		{
  			afDmaIE[0] = TRUE;
  			FTM0_C4SC |= (FTM_CnSC_CHIE_MASK | FTM_CnSC_DMA_MASK);		// Enable TCAP_CH4 DMA request
  		}
  		else
  		{
  			afDmaIE[0] = FALSE;
  			FTM0_C4SC &=  ~(FTM_CnSC_CHIE_MASK | FTM_CnSC_DMA_MASK);
  		}
  		
  		break;
  		
  	// Enable/Dsbl DMA on Ch 2  
  	case '2' :
  		if(!afDmaIE[1])
  		{
  			afDmaIE[1] = TRUE;
  			FTM0_C5SC |= (FTM_CnSC_CHIE_MASK | FTM_CnSC_DMA_MASK);		// Enable TCAP_CH5 DMA request
  		}
  		else
  		{
  			afDmaIE[1] = FALSE;
  			FTM0_C5SC &=  ~(FTM_CnSC_CHIE_MASK | FTM_CnSC_DMA_MASK);
  		}
  		break;
  		
      // Enable/Dsbl DMA on Ch 3  
    case '3' :
    	if(!afDmaIE[2])
    	{
    		afDmaIE[2] = TRUE;
    		FTM0_C6SC |= (FTM_CnSC_CHIE_MASK | FTM_CnSC_DMA_MASK);		// Enable TCAP_CH5 DMA request
    	}
    	else
    	{
    		afDmaIE[2] = FALSE;
    		FTM0_C6SC &=  ~(FTM_CnSC_CHIE_MASK | FTM_CnSC_DMA_MASK);
    	}
    	break;
      	
      // Enable/Dsb DMA on Ch 4  
    case '4' :
    	if(!afDmaIE[3])
    	{
    		afDmaIE[3] = TRUE;
    		FTM0_C7SC |= (FTM_CnSC_CHIE_MASK | FTM_CnSC_DMA_MASK);		// Enable TCAP_CH4 DMA request
    	}
    	else
    	{
    		afDmaIE[3] = FALSE;
    		FTM0_C7SC &=  ~(FTM_CnSC_CHIE_MASK | FTM_CnSC_DMA_MASK);
    	}
    	break;
    		
  	// Enable (OvfIsr)
  	case 't' : case 'T':
  		if(!fTCapCmpIE)
  		{
  			fTCapCmpIE = TRUE;
  			FTM0_C0SC |= FTM_CnSC_CHIE_MASK;													// TCAP_CH0 (OVF) ISR will IE will be enabled
  		}
  		else
  		{
  			fTCapCmpIE = FALSE;
  			FTM0_C0SC &= 	~FTM_CnSC_CHIE_MASK;			 
  		}

  				
  	  break;
  	
  	case 'n': case 'N':
  		fNewLine = fNewLine ? FALSE: TRUE;
  		break;
  		
 		case 'f':	case 'F':
 			//  			bDisplay = TRUE;
 			displayFloatMode = displayFloatMode? FALSE : TRUE;
 			break;
 			
 		case '?':
 			// Some help here
 			printf("%s", abHelpStr);
 			printf("\r\n Status: \r\nTCapAdjFreqCalib %lu Hz, TCAPIE: %d, DMA CH0:%d CH1:%d CH2:%d CH3:%d\n\n", uTimerCaptureClock, fTCapCmpIE, \ 
 					afDmaIE[0], afDmaIE[1], afDmaIE[2], afDmaIE[3]);
 			break;
 			
 		case ' ':
 			//fDisplayFreq = TRUE;
 			for(i=0; i< NBR_FREQ_CHANNELS; ++i)
 			if(atFreqIn[i].fDmaChReady && bChannelEnblMsk & (1 << i) )
 				atFreqIn[i].fDisplay = TRUE;		// Display a freq Value when Captured 
 			break;
 		case '+':
 			++uTimerCaptureClock;
 			break;
 		case '-':
 			--uTimerCaptureClock;
 			break;
 			
 		case 'c': case 'C':
 			clearTable();
 			break;
 			
  	}
  	//	Every 5*0.028 = 140mS
  	if(timerCapCtr >= uPreset)
  	{
  		timerCapCtr =0;
  		displayFreqBuffers();
  	}
  	
  		
  }
  //  DMA_Deinit(DMAPtr);
  // TIMER_Deinit(TimerPtr);
	
}
Beispiel #27
0
// This method is executed in a separate thread
// via QtConcurrent::run
TreeItem* ITunesFeature::importLibrary() {
    //Give thread a low priority
    QThread* thisThread = QThread::currentThread();
    thisThread->setPriority(QThread::LowestPriority);

    //Delete all table entries of iTunes feature
    ScopedTransaction transaction(m_database);
    clearTable("itunes_playlist_tracks");
    clearTable("itunes_library");
    clearTable("itunes_playlists");
    transaction.commit();

    qDebug() << "ITunesFeature::importLibrary() ";

    transaction.transaction();

    // By default set m_mixxxItunesRoot and m_dbItunesRoot to strip out
    // file://localhost/ from the URL. When we load the user's iTunes XML
    // configuration we may replace this with something based on the detected
    // location of the user's iTunes path but the defaults are necessary in case
    // their iTunes XML does not include the "Music Folder" key.
    m_mixxxItunesRoot = "";
    m_dbItunesRoot = localhost_token();

    //Parse iTunes XML file using SAX (for performance)
    QFile itunes_file(m_dbfile);
    if (!itunes_file.open(QIODevice::ReadOnly | QIODevice::Text)) {
        qDebug() << "Cannot open iTunes music collection";
        return NULL;
    }
    QXmlStreamReader xml(&itunes_file);
    TreeItem* playlist_root = NULL;
    while (!xml.atEnd() && !m_cancelImport) {
        xml.readNext();
        if (xml.isStartElement()) {
            if (xml.name() == "key") {
                QString key = xml.readElementText();
                if (key == "Music Folder") {
                    if (readNextStartElement(xml)) {
                        guessMusicLibraryMountpoint(xml);
                    }
                } else if (key == "Tracks") {
                    parseTracks(xml);
                    playlist_root = parsePlaylists(xml);
                }
            }
        }
    }

    itunes_file.close();

    // Even if an error occured, commit the transaction. The file may have been
    // half-parsed.
    transaction.commit();

    if (xml.hasError()) {
        // do error handling
        qDebug() << "Cannot process iTunes music collection";
        qDebug() << "XML ERROR: " << xml.errorString();
        if (playlist_root)
            delete playlist_root;
        playlist_root = NULL;
    }
    return playlist_root;
}
Beispiel #28
0
// SymbolTable destructor. Deallocates and clears out the internal symbol data structure.
SymbolTable::~SymbolTable()
{
	clearTable();
}
Beispiel #29
0
  /** 
   * This creates the table main window.  The table and docking 
   * area are created here. It also adds the two default menus to 
   * the menu bar. Programmers can add more menus to the menu bar 
   * once an instance of this class is established. 
   */  
  void TableMainWindow::createTable() {
    #if defined(__APPLE__)
      setWindowFlags(Qt::Tool);
    #endif

    #if !defined(__APPLE__)
      setWindowFlags(Qt::Dialog);
    #endif

    statusBar()->setSizeGripEnabled(true);
    // Create the table widget 
    p_table = new QTableWidget(this);
    p_table->setAlternatingRowColors(true);
    setCentralWidget(p_table);   

   // Create the dock area 
    p_dock = new QDockWidget("Columns",this);
    p_dock->setObjectName("dock");
    p_dock->setAllowedAreas(Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea);
    p_dock->setMinimumWidth(190);
    p_listWidget = new QListWidget(p_dock);
    p_dock->setWidget(p_listWidget);
    addDockWidget(Qt::LeftDockWidgetArea,p_dock,Qt::Vertical);
    connect(p_listWidget,SIGNAL(itemChanged(QListWidgetItem *)),
            this,SLOT(syncColumns()));
			
    // Create the file menu 
    QMenuBar *menuBar = this->menuBar();
    QMenu *fileMenu = menuBar->addMenu("&File");
    
    p_save = new QAction(this);
    p_save->setText("Save...");
    p_save->setShortcut(Qt::CTRL + Qt::Key_S);
    connect(p_save,SIGNAL(activated()),this,SLOT(saveTable()));
    p_save->setDisabled(true);
    
    QAction *saveas = new QAction(this);
    saveas->setText("Save As...");
    connect(saveas,SIGNAL(activated()),this,SLOT(saveAsTable()));
    
    QAction *load = new QAction(this);
    load->setText("Load...");
    connect(load,SIGNAL(activated()),this,SLOT(loadTable()));
    
    QAction *del = new QAction(this);
    del->setText("Delete Selected Row(s)");
    del->setShortcut(Qt::Key_Delete);
    connect(del,SIGNAL(activated()),this,SLOT(deleteRows()));
    
    QAction *clear = new QAction(this);
    clear->setText("Clear table");
    connect(clear,SIGNAL(activated()),this,SLOT(clearTable()));
    
    QAction *close = new QAction(this);
    close->setText("Close");
    connect(close,SIGNAL(activated()),this,SLOT(hide()));
    
    fileMenu->addAction(p_save);
    fileMenu->addAction(saveas);
    fileMenu->addAction(load);
    fileMenu->addAction(del);
    fileMenu->addAction(clear);
    fileMenu->addAction(close);

    //2009-01-12
    //If we have the Mainwindow flag set to Qt::Tool so that on Macs the 
    //table window always stays on top, then we can not access the
    //menu bar to the table window, so we need to add the file options
    //for the table to the tool bar.
    #if defined(__APPLE__)
     QToolBar *toolBar = new QToolBar();
     toolBar->addAction(p_save);
     toolBar->addAction(saveas);
     toolBar->addAction(load);
     toolBar->addAction(del);
     toolBar->addAction(clear);
     toolBar->addAction(close);
     this->addToolBar(toolBar);
   #endif 

    // Create the view menu
    QMenu *viewMenu = menuBar->addMenu("&View");
    QAction *cols = new QAction(this);
    cols->setText("Columns");
    connect(cols,SIGNAL(activated()),p_dock,SLOT(show()));
    viewMenu->addAction(cols);

    this->setMenuBar(menuBar);
    installEventFilter(this);
  }
/*
 *  Stitching page (multiple shots for panoramas).
 *
 *  Purpose:
 *  1. select best shot,
 *  2. increase resolution, and
 *  3. increase coverage (e.g., panoramas, collages).
 *
 *  For all of these purposes, it is best to maintain a fixed aperture,
 *  focal distance, focal length, ISO setting, subject distance, and white
 *  balance. That means Manual mode, and no auto ISO, no auto white balance,
 *  no auto focus (or turn off auto focus once focus has been achieved when
 *  setting up the shot) and use a tripod if available (turn off image
 *  stabilization).
 */
QWidget *
MultiShot::getStitchPage()
{
    /*
     *  Settings.
     */
    QLabel *columnsLabel = new QLabel( tr("Horizontal size:") );
    columnsLabel->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
    columns = new QSpinBox();
    columns->setRange( 1, 7 );

    QLabel *rowsLabel = new QLabel( tr("Vertical size:") );
    rowsLabel->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
    rows = new QSpinBox();
    rows->setRange( 1, 2 );

    QLabel *orderLabel = new QLabel( tr("Order:") );
    orderLabel->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
    QComboBox *order = new QComboBox();
    order->addItem( "L-to-R", ORDER_LtoR );
    order->addItem( "L-to-R (alt)", ORDER_LtoR_alt );
    order->addItem( "R-to-L", ORDER_RtoL );
    order->addItem( "R-to-L (alt)", ORDER_RtoL_alt );
    order->setCurrentIndex( 0 );

    QLabel *overlapLabel = new QLabel( tr("Overlap:") );
    overlapLabel->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
    overlap = new QSpinBox();
    overlap->setRange( 20, 40 );
    overlap->setValue( 30 );
    overlap->setSuffix( "%" );

    QLabel *opacityLabel = new QLabel( tr("Opacity:") );
    opacityLabel->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
    opacity = new QSpinBox();
    opacity->setRange( 0, 100 );
    opacity->setValue( 50 );
    opacity->setSuffix( "%" );

    QPushButton *clearButton = new QPushButton( tr("Clear table") );

    QLabel *note = new QLabel();
    QFont font;
    font.setItalic( true );
    note->setFont( font );
    note->setText(
	tr("Use live view and the shutter button to align and take individual images.") );

    /*
     *  Table of images.
     */
    imageTable = new ImageTable();
    QObject::connect(
	columns, SIGNAL(valueChanged(int)),
	imageTable, SLOT(setColumns(int)) );
    QObject::connect(
	rows, SIGNAL(valueChanged(int)),
	imageTable, SLOT(setRows(int)) );
    QObject::connect(
	order, SIGNAL(activated(int)),
	imageTable, SLOT(setOrder(int)) );
    QObject::connect(
	clearButton, SIGNAL(clicked()),
	imageTable, SLOT(clearTable()) );

    scrollArea = new QScrollArea();
    scrollArea->setWidget( imageTable );
    scrollArea->setFocusPolicy( Qt::NoFocus );
    scrollArea->setAlignment( Qt::AlignCenter );

    /*
     *  Final layout.
     */
    QGridLayout *settingsLayout = new QGridLayout();
    settingsLayout->addWidget( columnsLabel, 0, 0 );
    settingsLayout->addWidget( columns,	     0, 1 );
    settingsLayout->addWidget( rowsLabel,    1, 0 );
    settingsLayout->addWidget( rows,	     1, 1 );
    settingsLayout->addWidget( orderLabel,   2, 0 );
    settingsLayout->addWidget( order,	     2, 1 );
    settingsLayout->addWidget( overlapLabel, 0, 2 );
    settingsLayout->addWidget( overlap,	     0, 3 );
    settingsLayout->addWidget( opacityLabel, 1, 2 );
    settingsLayout->addWidget( opacity,	     1, 3 );
    settingsLayout->addWidget( clearButton,  2, 3 );
    settingsLayout->addWidget( note,         3, 0, 1, 4 );
    settingsLayout->setColumnStretch( 4, 1 );
    settingsLayout->setColumnMinimumWidth( 0, 100 );
    settingsLayout->setColumnMinimumWidth( 1, 80 );
    settingsLayout->setColumnMinimumWidth( 2, 100 );
    settingsLayout->setColumnMinimumWidth( 3, 80 );

    QGroupBox *settingsGroupBox = new QGroupBox( tr("Settings") );
    settingsGroupBox->setLayout( settingsLayout );

    QVBoxLayout *layout = new QVBoxLayout();
    layout->addWidget( settingsGroupBox );
    layout->addWidget( scrollArea );

    QWidget *widget = new QWidget( this );
    widget->setLayout( layout );

    return( widget );
}