Exemplo n.º 1
0
/*
 * Used in conjunction with currentRowChanged to have
 * desired effect of enabling and disabling buttons
 */
void MainWindow::on_systemsTable_clicked(const QModelIndex &index){
    if(index.isValid()){
        // Get rows
        QModelIndexList selection = ui->systemsTable->selectionModel()->selectedRows();

        // If multiple rows
        if (selection.count() > 1) {
            // Disable edit button
            ui->systemEditButton->setEnabled(false);
        }
        // Single selection
        else{
            // Enable edit button
            ui->systemEditButton->setEnabled(true);
        }
    }
}
Exemplo n.º 2
0
void StreamsBrowsePage::addBookmark()
{
    QModelIndexList selected = view->selectedIndexes(false); // Dont need sorted selection here...

    if (1!=selected.count()) {
        return;
    }

    const StreamsModel::Item *item=static_cast<const StreamsModel::Item *>(proxy.mapToSource(selected.first()).internalPointer());

    // TODO: In future, if other categories support bookmarking, then we will need to calculate parent here!!!
    if (StreamsModel::self()->addBookmark(item->url, item->name, 0)) {
        view->showMessage(tr("Bookmark added"), constMsgDisplayTime);
    } else {
        view->showMessage(tr("Already bookmarked"), constMsgDisplayTime);
    }
}
Exemplo n.º 3
0
DetailedErrorView::DetailedErrorView(QWidget *parent) :
    QTreeView(parent),
    m_copyAction(new QAction(this))
{
    header()->setSectionResizeMode(QHeaderView::ResizeToContents);
    setItemDelegateForColumn(LocationColumn, new Internal::DetailedErrorDelegate(this));

    m_copyAction->setText(tr("Copy"));
    m_copyAction->setIcon(Utils::Icons::COPY.icon());
    m_copyAction->setShortcut(QKeySequence::Copy);
    m_copyAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
    connect(m_copyAction, &QAction::triggered, [this] {
        const QModelIndexList selectedRows = selectionModel()->selectedRows();
        QTC_ASSERT(selectedRows.count() == 1, return);
        QApplication::clipboard()->setText(model()->data(selectedRows.first(),
                                                         FullTextRole).toString());
    });
Exemplo n.º 4
0
/******************************************************************************
* Return a list of events for birthdays chosen.
*/
QList<KAEvent> BirthdayDlg::events() const
{
	QList<KAEvent> list;
	QModelIndexList indexes = mListView->selectionModel()->selectedRows();
	int count = indexes.count();
	if (!count)
		return list;
	QDate today = KDateTime::currentLocalDate();
	KDateTime todayStart(today, KDateTime::ClockTime);
	int thisYear = today.year();
	int reminder = mReminder->minutes();
	const BirthdaySortModel* model = static_cast<const BirthdaySortModel*>(indexes[0].model());
	for (int i = 0;  i < count;  ++i)
	{
		BirthdayModel::Data* data = model->rowData(indexes[i]);
		if (!data)
			continue;
		QDate date = data->birthday;
		date.setYMD(thisYear, date.month(), date.day());
		if (date <= today)
			date.setYMD(thisYear + 1, date.month(), date.day());
		KAEvent event(KDateTime(date, KDateTime::ClockTime),
			      mPrefix->text() + data->name + mSuffix->text(),
			      mFontColourButton->bgColour(), mFontColourButton->fgColour(),
			      mFontColourButton->font(), KAEventData::MESSAGE, mLateCancel->minutes(),
			      mFlags, true);
		float fadeVolume;
		int   fadeSecs;
		float volume = mSoundPicker->volume(fadeVolume, fadeSecs);
		event.setAudioFile(mSoundPicker->file().prettyUrl(), volume, fadeVolume, fadeSecs);
		QList<int> months;
		months.append(date.month());
		event.setRecurAnnualByDate(1, months, 0, KARecurrence::defaultFeb29Type(), -1, QDate());
		event.setRepetition(mSubRepetition->repetition());
		event.setNextOccurrence(todayStart);
		if (reminder)
			event.setReminder(reminder, false);
		if (mSpecialActionsButton)
			event.setActions(mSpecialActionsButton->preAction(),
					 mSpecialActionsButton->postAction(),
			                 mSpecialActionsButton->cancelOnError());
		event.endChanges();
		list.append(event);
	}
	return list;
}
Exemplo n.º 5
0
void SftpFsWindow::downloadFile()
{
    const QModelIndexList selectedIndexes = m_ui->fsView->selectionModel()->selectedIndexes();
    if (selectedIndexes.count() != 2)
        return;
    const QString targetFilePath = QFileDialog::getSaveFileName(this, tr("Choose target file"),
        QDir::tempPath());
    if (targetFilePath.isEmpty())
        return;
    const SftpJobId jobId = m_fsModel->downloadFile(selectedIndexes.at(1), targetFilePath);
    QString message;
    if (jobId == SftpInvalidJob)
        message = tr("Download failed.");
    else
        message = tr("Queuing download operation %1.").arg(jobId);
    m_ui->outputTextEdit->appendPlainText(message);
}
Exemplo n.º 6
0
/******************************************************************************
* Return a list of events for birthdays chosen.
*/
QVector<KAEvent> BirthdayDlg::events() const
{
    QVector<KAEvent> list;
    QModelIndexList indexes = mListView->selectionModel()->selectedRows();
    int count = indexes.count();
    if (!count)
        return list;
    QDate today = KDateTime::currentLocalDate();
    KDateTime todayStart(today, KDateTime::Spec(KDateTime::ClockTime));
    int thisYear = today.year();
    int reminder = mReminder->minutes();
    for (int i = 0;  i < count;  ++i)
    {
        const QModelIndex nameIndex = indexes.at(i).model()->index(indexes.at(i).row(), 0);
        const QModelIndex birthdayIndex = indexes.at(i).model()->index(indexes.at(i).row(), 1);
        const QString name = nameIndex.data(Qt::DisplayRole).toString();
        QDate date = birthdayIndex.data(BirthdayModel::DateRole).toDate();
        date.setYMD(thisYear, date.month(), date.day());
        if (date <= today)
            date.setYMD(thisYear + 1, date.month(), date.day());
        KAEvent event(KDateTime(date, KDateTime::Spec(KDateTime::ClockTime)),
                      mPrefix->text() + name + mSuffix->text(),
                      mFontColourButton->bgColour(), mFontColourButton->fgColour(),
                      mFontColourButton->font(), KAEvent::MESSAGE, mLateCancel->minutes(),
                      mFlags, true);
        float fadeVolume;
        int   fadeSecs;
        float volume = mSoundPicker->volume(fadeVolume, fadeSecs);
        int   repeatPause = mSoundPicker->repeatPause();
        event.setAudioFile(mSoundPicker->file().toDisplayString(), volume, fadeVolume, fadeSecs, repeatPause);
        QVector<int> months(1, date.month());
        event.setRecurAnnualByDate(1, months, 0, KARecurrence::defaultFeb29Type(), -1, QDate());
        event.setRepetition(mSubRepetition->repetition());
        event.setNextOccurrence(todayStart);
        if (reminder)
            event.setReminder(reminder, false);
        if (mSpecialActionsButton)
            event.setActions(mSpecialActionsButton->preAction(),
                             mSpecialActionsButton->postAction(),
                             mSpecialActionsButton->options());
        event.endChanges();
        list.append(event);
    }
    return list;
}
Exemplo n.º 7
0
bool FileOrganiserWidget::canCreateNewFolder() const
{
    QModelIndexList selectedIndexes = selectionModel()->selectedIndexes();
    int selectedIndexesCount = selectedIndexes.count();

    // Determnine whether we can create a new folder

    if (selectedIndexesCount == 1)
        // One item is currently selected, so the only way we could create a new
        // folder is if the current item is also a folder

        return mModel->itemFromIndex(selectedIndexes.first())->data(Item::Folder).toBool();
    else
        // Either no item or several items are currently selected, so the only
        // way we could create a new folder is if no item is currently selected

        return !selectedIndexesCount;
}
Exemplo n.º 8
0
void
groupEdit::groupRemove()
{
	Q_ASSERT(!members->isEmpty());
	QModelIndexList sel = groupKeys->selectionModel()->selectedIndexes();
	for (int i = 0; i < sel.count(); i++) {
		if (sel.at(i).column() != 0)
			continue;
		KGpgNode *nd = m_in->nodeForIndex(sel.at(i));
		for (int j = 0; j < members->count(); j++)
			if (nd->toKeyNode()->compareId(members->at(j)->getId())) {
				members->removeAt(j);
				break;
			}
	}
	m_in->invalidate();
	m_out->invalidate();
}
Exemplo n.º 9
0
    void FenPrincipale::deleteRow()
    {
        QSqlTableModel *model = qobject_cast<QSqlTableModel *>(tablemesures->model());
        if (!model)
            return;

          model->setEditStrategy(QSqlTableModel::OnManualSubmit);

        QModelIndexList currentSelection = tablemesures->selectionModel()->selectedIndexes();
        for (int i = 0; i < currentSelection.count(); ++i) {
            if (currentSelection.at(i).column() != 0)
                continue;
            model->removeRow(currentSelection.at(i).row());

           }
            model->submitAll();
            model->setEditStrategy(QSqlTableModel ::OnManualSubmit);
       }
Exemplo n.º 10
0
void PlaylistPlayer::play()
{
    //Creation de la video window si elle n'existe pas
    ((MainWindow*)this->parent())->needVideoWindow();

    // play or resume playback
    QModelIndexList indexes = ((MainWindow*)this->parent())->currentPlaylistTableView()->selectionModel()->selectedRows();

    // if no selected item play current playlist from first item
    if (indexes.count() == 0) {
        playItemAt(0);

    // play playlist at selected item otherwise
    } else {
        const int index = indexes.first().row();
        playItemAt(index);
    }
}
Exemplo n.º 11
0
void ContactsTable::onDeleteContact()
{
   //remove selected contacts from inbox model (and database)
   QSortFilterProxyModel* model = dynamic_cast<QSortFilterProxyModel*>(ui->contact_table->model());
   //model->setUpdatesEnabled(false);
   QItemSelectionModel* selection_model = ui->contact_table->selectionModel();
   QModelIndexList sortFilterIndexes = selection_model->selectedRows();
   QModelIndexList indexes;
   foreach(QModelIndex sortFilterIndex,sortFilterIndexes)
     indexes.append(model->mapToSource(sortFilterIndex));
   qSort(indexes);
   auto sourceModel = model->sourceModel();
   for(int i = indexes.count() - 1; i > -1; --i)
       sourceModel->removeRows(indexes.at(i).row(),1);
   //model->setUpdatesEnabled(true);   

   //TODO Remove fullname/bitname for deleted contacts from QCompleter
}
Exemplo n.º 12
0
// Function to deleting record from table
bool creatordialog::delete_record(QSqlRelationalTableModel* rmodel)
{
    int row_to_delete;
    QModelIndexList selectedList = ui->tableView_CREATOR_1->selectionModel()->selectedRows();
    for( int i=0; i<selectedList.count(); i++)
    {
        row_to_delete=selectedList.at(i).row();
    }

    if(selectedList.isEmpty())
    {
        QMessageBox::information(this,"Informacja","Nie zaznaczono wiersza do usunięcia.");
        return false;
    }

    QSqlQueryModel model;
    model.setQuery("SELECT * FROM "+relational_table_2+"");

    int id_first = model.data(model.index(row_to_delete, 0)).toInt();
    int id_second = model.data(model.index(row_to_delete, 1)).toInt();

    QSqlQuery query;
    if(relational_table_2=="Maszyny_has_Daneosobowe") {
        query.prepare("Delete from Maszyny_has_Daneosobowe where idMaszyny_MaszynyDaneosobowe=:first_id and idDaneosobowe_MaszynyDaneosobowe=:second_id");
    }
    else if(relational_table_2=="Maszyny_has_Czesci") {
        query.prepare("Delete from Maszyny_has_Czesci where idMaszyny_MaszynyCzesci=:first_id and idCzesci_MaszynyCzesci=:second_id");
    }
    query.bindValue(":first_id", id_first);
    query.bindValue(":second_id", id_second);

    if(query.exec())
    {
        QMessageBox::information(this,"Informacja","USUNIĘTO");
        rmodel->select();
        count=false;
        return true;
    }
    else
    {
        QMessageBox::information(this,"Informacja",query.lastError().text());
        return false;
    }
}
void QgsDatumTransformTableWidget::editDatumTransform()
{
  QModelIndexList selectedIndexes = mTableView->selectionModel()->selectedIndexes();
  if ( selectedIndexes.count() > 0 )
  {
    QgsCoordinateReferenceSystem sourceCrs;
    QgsCoordinateReferenceSystem destinationCrs;
    int sourceTransform = -1;
    int destinationTransform = -1;
    for ( QModelIndexList::const_iterator it = selectedIndexes.constBegin(); it != selectedIndexes.constEnd(); it ++ )
    {
      switch ( it->column() )
      {
        case QgsDatumTransformTableModel::SourceCrsColumn:
          sourceCrs = QgsCoordinateReferenceSystem( mModel->data( *it, Qt::DisplayRole ).toString() );
          break;
        case QgsDatumTransformTableModel::DestinationCrsColumn:
          destinationCrs = QgsCoordinateReferenceSystem( mModel->data( *it, Qt::DisplayRole ).toString() );
          break;
        case QgsDatumTransformTableModel::SourceTransformColumn:
          sourceTransform = mModel->data( *it, Qt::UserRole ).toInt();
          break;
        case QgsDatumTransformTableModel::DestinationTransformColumn:
          destinationTransform = mModel->data( *it, Qt::UserRole ).toInt();
          break;
        default:
          break;
      }
    }
    if ( sourceCrs.isValid() && destinationCrs.isValid() &&
         ( sourceTransform != -1 || destinationTransform != -1 ) )
    {
      QgsDatumTransformDialog dlg( sourceCrs, destinationCrs, qMakePair( sourceTransform, destinationTransform ) );
      if ( dlg.exec() )
      {
        QPair< QPair<QgsCoordinateReferenceSystem, int>, QPair<QgsCoordinateReferenceSystem, int > > dt = dlg.selectedDatumTransforms();
        QgsCoordinateTransformContext context = mModel->transformContext();
        // QMap::insert takes care of replacing existing value
        context.addSourceDestinationDatumTransform( sourceCrs, destinationCrs, dt.first.second, dt.second.second );
        mModel->setTransformContext( context );
      }
    }
  }
}
Exemplo n.º 14
0
void wid_stranke::on_btn_kopiraj_clicked() {

	QClipboard *odlozisce = QApplication::clipboard();

	QModelIndexList selectedList = ui->tbl_stranke->selectionModel()->selectedRows();

	QString html_besedilo = "<table>";
	html_besedilo += "<tr>";
	html_besedilo += "<th>ID</th>";
	html_besedilo += "<th>Ime/Naziv</th>";
	html_besedilo += "<th>Priimek/Polni naziv</th>";
	html_besedilo += "<th>Telefon</th>";
	html_besedilo += "<th>GSM</th>";
	html_besedilo += "<th>Elektronski naslov</th>";
	html_besedilo += "<th>Izobrazevalna ustanova</th>";
	html_besedilo += "<th>Tip stranke</th>";
	html_besedilo += "</tr>";

	for( int i = 0; i < selectedList.count(); i++) {
		html_besedilo += "<tr>";
		for ( int a = 0; a < 8; a++ ) {
			html_besedilo += "<td>";
			html_besedilo += ui->tbl_stranke->item(selectedList.at(i).row(), a)->text();
			html_besedilo += "</td>";

		}
		html_besedilo += "</tr>";
	}

	html_besedilo += "</table>";

	QTextEdit *textedit = new QTextEdit;

	textedit->setHtml(html_besedilo);
	html_besedilo = textedit->toHtml();

	odlozisce->clear();

	QMimeData *mimeData = new QMimeData();
	mimeData->setData("text/html", html_besedilo.toUtf8());
	odlozisce->setMimeData(mimeData, QClipboard::Clipboard);

}
Exemplo n.º 15
0
void FilesListWindow::on_deleteButton_pressed()
{
    QModelIndexList indexes = ui->filesTable->selectionModel()->selection().indexes();
    for (int i = 0; i < indexes.count(); ++i)
    {
        WSqlQuery q, r;
        q.prepare("DELETE FROM files WHERE id = ?");
        r.prepare("DELETE FROM mirrors WHERE file_id = ?");
        QModelIndex index = indexes.at(i);
        if(index.column() == 0)
        {
            q.addBindValue(index.data().toInt());
            q.exec();
            r.addBindValue(index.data().toInt());
            r.exec();
        }
    }
    refresh();
}
Exemplo n.º 16
0
void OpenPagesManager::closeCurrentPage()
{
    if (!m_openPagesWidget)
        return;

    QModelIndexList indexes = m_openPagesWidget->selectionModel()->selectedRows();
    if (indexes.isEmpty())
        return;

    const bool closeOnReturn = HelpManager::customValue(QLatin1String("ReturnOnClose"),
        false).toBool();

    if (m_model->rowCount() == 1 && closeOnReturn) {
        ModeManager::activateMode(Core::Constants::MODE_EDIT);
    } else {
        Q_ASSERT(indexes.count() == 1);
        removePage(indexes.first().row());
    }
}
Exemplo n.º 17
0
/** Edits selected item */
void medDatabaseView::onEditRequested(void)
{
    QModelIndexList indexes = this->selectedIndexes();
    if(!indexes.count())
        return;

    QModelIndex index = indexes.at(0);

    medAbstractDatabaseItem *item = NULL;

    if(QSortFilterProxyModel *proxy = dynamic_cast<QSortFilterProxyModel *>(this->model()))
        item = static_cast<medAbstractDatabaseItem *>(proxy->mapToSource(index).internalPointer());

    if(item)
    {        
        QList<QVariant> attributes = item->attributes();
        QList<QVariant> values = item->values();
        QList<QString> labels;
        
        foreach(QVariant attrib, attributes)
        {
            const medMetaDataKeys::Key* key =  medMetaDataKeys::Key::fromKeyName(attrib.toString().toStdString().c_str());
            if(key)
                labels << key->label();
            else labels << "";
        }
        
        medDatabaseEditItemDialog editDialog(labels,values,this);
        
        int res =  editDialog.exec();
        medDataIndex index = item->dataIndex();

        if(res == QDialog::Accepted)
        {
            int i=0;
            foreach(QString label, labels)
            {
                QVariant data = editDialog.value(label);
                QVariant variant = item->attribute(i);
                medDataManager::instance()->setMetadata(index, variant.toString(), data.toString());
                i++;    
            }
        } 
Exemplo n.º 18
0
bool BtTreeView::multiSelected()
{
   QModelIndexList selected = selectionModel()->selectedRows();
   bool hasRecipe, hasSomethingElse;

   hasRecipe        = false;
   hasSomethingElse = false;

   if ( selected.count() == 0 ) 
      return false;

   foreach (QModelIndex selection, selected)
   {
      QModelIndex selectModel = filter->mapToSource(selection);
      if (_model->isRecipe(selectModel))
         hasRecipe = true;
      else
         hasSomethingElse = true;
   }
Exemplo n.º 19
0
void CRestoreTM::on_pushButton_2_clicked()
//////////////////////////////////////////
{
  QStandardItemModel *model = (QStandardItemModel *)ui->treeView->model();
  QModelIndexList il = ui->treeView->selectionModel()->selectedIndexes();

  if (il.count() == 0)
    return;

  QStandardItem *item = model->itemFromIndex(il.at(0));
  item_t *e = (item_t *)item->data().toLongLong();

  m_jd = e->jd;
  m_ra = e->ra;
  m_dec = e->dec;

  SkFile f(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/data/timemarks/timemarks.dat");
  QTextStream s(&f);

  if (f.open(SkFile::WriteOnly | SkFile::Text))
  {
    for (int i = 0; i < model->rowCount(); i++)
    {
      QStandardItem *item = model->item(i, 0);
      item_t *e = (item_t *)item->data().toLongLong();

      s << e->desc << ";" << QString::number(e->jd, 'f', 8);

      if (e->ra > CM_UNDEF)
      {
        s << ";" << R2D(e->ra) << ";" << R2D(e->dec);
      }

      s << "\n";

      delete e;
    }
  }

  model->removeRows(0, model->rowCount());

  done(DL_OK);
}
Exemplo n.º 20
0
/**
  * Delete the given profile preference
  *
  */
void CAMProfileSettingsList::on_bDelete_clicked() {
    // Get all selections
   QModelIndexList indexes = ui->tableView->selectionModel()->selection().indexes();

   QList<int> list;
   for (int i = 0; i < indexes.count(); ++i)
   {
       list.append(indexes.at(i).row());
   }

   list=QSet<int>::fromList(list).toList();
   qSort(list.begin(), list.end());
   while (!list.empty()) {
       camProfileDataModel->removeRows(list.takeLast(),1);
   }
   savePreferences();
   ui->tableView->resizeColumnsToContents();

}
Exemplo n.º 21
0
Song LibraryPage::coverRequest() const
{
    QModelIndexList selected = view->selectedIndexes(false); // Dont need sorted selection here...

    if (1==selected.count()) {
        QModelIndex idx=proxy.mapToSource(selected.at(0));
        QList<Song> songs=MusicLibraryModel::self()->songs(QModelIndexList() << idx, false);
        if (!songs.isEmpty()) {
            Song s=songs.at(0);

            if (MusicLibraryItem::Type_Artist==static_cast<MusicLibraryItem *>(idx.internalPointer())->itemType() &&
                !static_cast<MusicLibraryItemArtist *>(idx.internalPointer())->isComposer()) {
                s.setArtistImageRequest();
            }
            return s;
        }
    }
    return Song();
}
Exemplo n.º 22
0
void EditTagDialog::SelectionChanged() {
  const QModelIndexList sel =
      ui_->song_list->selectionModel()->selectedIndexes();
  if (sel.isEmpty()) return;

  // Set the editable fields
  UpdateUI(sel);

  // If we're editing multiple songs then we have to disable certain tabs
  const bool multiple = sel.count() > 1;
  ui_->tab_widget->setTabEnabled(ui_->tab_widget->indexOf(ui_->summary_tab),
                                 !multiple);

  if (!multiple) {
    const Song& song = data_[sel.first().row()].original_;
    UpdateSummaryTab(song);
    UpdateStatisticsTab(song);
  }
}
Exemplo n.º 23
0
unique_ptr<Team> TeamTableView::getSelectedTeam()
{
  // make sure we have a non-empty model
  auto mod = model();
  if (mod == nullptr) return nullptr;
  if (mod->rowCount() == 0) return nullptr;

  // make sure we have one item selected
  QModelIndexList indexes = selectionModel()->selection().indexes();
  if (indexes.count() == 0)
  {
    return nullptr;
  }

  // return the selected item
  TeamMngr tm{db};
  int selectedSourceRow = sortedModel->mapToSource(indexes.at(0)).row();
  return tm.getTeamBySeqNum_up(selectedSourceRow);
}
Exemplo n.º 24
0
void RepoEditor::updateMovers( const QItemSelection &cur, const QItemSelection &)
{
    QModelIndexList list = cur.indexes();

    if( !list.count() )
        return;

    int row = list.at( 0 ).row();

    if( row > 0 )
        ui->moveUp->setEnabled( true );
    else
        ui->moveUp->setEnabled( false );

    if( row < ui->tableView->model()->rowCount() - 1)
        ui->moveDown->setEnabled( true );
    else
        ui->moveDown->setEnabled( false );
}
// =============================================================================
void TimeTrackingWindow::copy() const
{
    QItemSelectionModel * itemSelectionModel = mTableView->selectionModel();
    QModelIndexList modelIndexList = itemSelectionModel->selectedIndexes();
    if (modelIndexList.isEmpty()) {
        QMessageBox::warning(NULL, tr("Cannot copy empty selection"),
                             "Please select an area before copying.",
                             QMessageBox::Ok);
        return;
    }

    QString copiedData = mTableView->model()->data(QModelIndex(),
                                                 Qt::UserRole + TableViewModel::USER_ROLE_GET_MONTH_OF_SHEET).toString();

    // Extract coordinates of rectangle selection
    QPoint leftTop = QPoint(mTableView->model()->rowCount(), mTableView->model()->columnCount());
    QPoint rightBottom = QPoint(0, 0);

    for (int idx = 0; idx < modelIndexList.count(); idx++) {
        QModelIndex index = modelIndexList[idx];
        leftTop = QPoint(std::min(leftTop.x(), index.column()),
                         std::min(leftTop.y(), index.row()));
        rightBottom = QPoint(std::max(rightBottom.x(), index.column()),
                             std::max(rightBottom.y(), index.row()));
    }

    // Create header
    for(int col = leftTop.x(); col <= rightBottom.x(); col++) {
        copiedData += "\t|" + mTableView->model()->headerData(col, Qt::Horizontal).toString();
    }
    // Copy selection
    for(int row = leftTop.y(); row <= rightBottom.y(); row++) {
        copiedData += "\n\t";
        for(int col = leftTop.x(); col <= rightBottom.x(); col++) {
            QModelIndex index = mTableView->model()->index(row, col);
            copiedData += "\t|" + mTableView->model()->data(index).toString();
        }
    }


    QApplication::clipboard()->setText(copiedData);
}
Exemplo n.º 26
0
void CheatsView::enterCheat(std::function<bool(GBACheatSet*, const char*)> callback) {
	GBACheatSet* set;
	QModelIndexList selection = m_ui.cheatList->selectionModel()->selectedIndexes();
	if (selection.count() != 1) {
		return;
	}
	set = m_model.itemAt(selection[0]);
	if (!set) {
		return;
	}
	m_controller->threadInterrupt();
	QStringList cheats = m_ui.codeEntry->toPlainText().split('\n', QString::SkipEmptyParts);
	for (const QString& string : cheats) {
		m_model.beginAppendRow(selection[0]);
		callback(set, string.toLocal8Bit().constData());
		m_model.endAppendRow();
	}
	m_controller->threadContinue();
	m_ui.codeEntry->clear();
}
Exemplo n.º 27
0
void ContactsTable::copy()
{  
  QString strContact = QString();
  QItemSelectionModel* selection_model = ui->contact_table->selectionModel();
  QModelIndexList      indexes = selection_model->selectedRows();

  for (int i = 0; i < indexes.count(); i++)
  {
    QModelIndex mapped_index = _sorted_addressbook_model->mapToSource(indexes[i]);
    if (!strContact.isEmpty())
      strContact += "\n";
    strContact += _addressbook_model->getContact(mapped_index).get_display_name().c_str();
  }
  
  if (!strContact.isEmpty())
  {
    QClipboard *clip = QApplication::clipboard();
    clip->setText (strContact);
  }
}
Exemplo n.º 28
0
void UrlCatcher::openSelectedUrls()
{
    QModelIndexList selectedIndexes = m_urlTree->selectionModel()->selectedRows(1);

    if (selectedIndexes.count() > 1)
    {
        int ret = KMessageBox::warningContinueCancel(this,
            i18n("You have selected more than one URL. Do you really want to open several URLs at once?"),
            i18n("Open URLs"),
            KStandardGuiItem::cont(),
            KStandardGuiItem::cancel(),
            QString(),
            KMessageBox::Notify | KMessageBox::Dangerous);

        if (ret != KMessageBox::Continue) return;
    }

    foreach(const QModelIndex& index, selectedIndexes)
        if (index.isValid()) Application::openUrl(index.data().toString());
}
Exemplo n.º 29
0
/*
 * QModelIndex &previous is not used simply
 * because we only want the functionality of
 * the QItemSelectionModel::CurrentRowChanged()
 * signal
 */
void MainWindow::typesTableCurrentRowChanged(const QModelIndex &current, const QModelIndex &previous){
    if(current.isValid()){
        // Enable delete button
        ui->typeDeleteButton->setEnabled(true);

        // Get rows
        QModelIndexList selection = ui->typesTable->selectionModel()->selectedRows();

        // If multiple rows
        if (selection.count() > 1) {
            // Disable edit button
            ui->typeEditButton->setEnabled(false);
        }
        // Single selection
        else{
            // Enable edit button
            ui->typeEditButton->setEnabled(true);
        }
    }
}
Exemplo n.º 30
0
QString TemplateDialog::doTemplateDialog()
{
	QString rval;

	TemplateDialog dlg;
	dlg.show();
	DialogCode	result = (DialogCode)dlg.exec();

	if (result == Accepted) {
		QModelIndexList selection = dlg.treeView->selectionModel()->selectedRows();
		if (selection.count() > 0) {
			QString filePath(dlg.model->filePath(selection[0]));
			QFileInfo fileInfo(filePath);
			if (fileInfo.isFile() && fileInfo.isReadable())
				rval = filePath;
		}
	}
	
	return rval;
}