Ejemplo n.º 1
0
void DesktopWindow::onStickToCurrentPos(bool toggled) {
  QAction* action = static_cast<QAction*>(sender());
  Fm::FileMenu* menu = static_cast<Fm::FileMenu*>(action->parent());

  QModelIndexList indexes = listView_->selectionModel()->selectedIndexes();
  if(!indexes.isEmpty()) {
    FmFileInfo* file = menu->firstFile();
    QByteArray name = fm_file_info_get_name(file);
    QModelIndex index = indexes.first();
    if(toggled) { // remember to current custom position
      QRect itemRect = listView_->rectForIndex(index);
      customItemPos_[name] = itemRect.topLeft();
      saveItemPositions();
    }
    else { // cancel custom position and perform relayout
      QHash<QByteArray, QPoint>::iterator it = customItemPos_.find(name);
      if(it != customItemPos_.end()) {
        customItemPos_.erase(it);
        saveItemPositions();
        relayoutItems();
      }
    }
  }
}
Ejemplo n.º 2
0
QStringList FileOrganiserWidget::selectedFiles() const
{
    // Retrieve all the files that are currently selected
    // Note: if there is a folder among the selected items, then we return an
    //       empty list

    QStringList res;
    QModelIndexList crtSelectedIndexes = selectedIndexes();

    for (int i = 0, iMax = crtSelectedIndexes.count(); i < iMax; ++i) {
        QString fileName = filePath(crtSelectedIndexes[i]);

        if (fileName.isEmpty())
            // The current item is not a file, so return an empty list

            return QStringList();
        else
            // The current item is a file, so just add to the list

            res << fileName;
    }

    return res;
}
Ejemplo n.º 3
0
void TourWidgetPrivate::deleteSelected()
{
    QString title = QObject::tr( "Remove Selected Items" );
    QString text = QObject::tr( "Are you sure want to remove selected items?" );
    QPointer<QMessageBox> dialog = new QMessageBox( QMessageBox::Question, title, text, QMessageBox::Yes | QMessageBox::No, q );
    dialog->setDefaultButton( QMessageBox::No );
    if ( dialog->exec() == QMessageBox::Yes ) {
        GeoDataObject *rootObject =  rootIndexObject();
        if ( rootObject && rootObject->nodeType() == GeoDataTypes::GeoDataPlaylistType ) {
            GeoDataPlaylist *playlist = static_cast<GeoDataPlaylist*>( rootObject );
            QModelIndex playlistIndex = m_widget->model()->treeModel()->index( playlist );
            QModelIndexList selected = m_tourUi.m_listView->selectionModel()->selectedIndexes();
            qSort( selected.begin(), selected.end(), qGreater<QModelIndex>() );
            QModelIndexList::iterator end = selected.end();
            QModelIndexList::iterator iter = selected.begin();
            for( ; iter != end; ++iter ) {
                m_widget->model()->treeModel()->removeTourPrimitive( playlistIndex, iter->row() );
            }
            m_isChanged = true;
            m_tourUi.m_actionSaveTour->setEnabled( true );
        }
    }
    delete dialog;
}
Ejemplo n.º 4
0
void TilesetDock::updateCurrentTiles()
{
    const int viewIndex = mViewStack->currentIndex();
    if (viewIndex == -1)
        return;

    const QItemSelectionModel *s = tilesetViewAt(viewIndex)->selectionModel();
    const QModelIndexList indexes = s->selection().indexes();

    if (indexes.isEmpty())
        return;

    const QModelIndex &first = indexes.first();
    int minX = first.column();
    int maxX = first.column();
    int minY = first.row();
    int maxY = first.row();

    foreach (const QModelIndex &index, indexes) {
        if (minX > index.column()) minX = index.column();
        if (maxX < index.column()) maxX = index.column();
        if (minY > index.row()) minY = index.row();
        if (maxY < index.row()) maxY = index.row();
    }

    // Create a tile layer from the current selection
    TileLayer *tileLayer = new TileLayer(QString(), 0, 0,
                                         maxX - minX + 1,
                                         maxY - minY + 1);

    const TilesetModel *model = static_cast<const TilesetModel*>(s->model());
    foreach (const QModelIndex &index, indexes) {
        tileLayer->setCell(index.column() - minX,
                           index.row() - minY,
                           Cell(model->tileAt(index)));
    }
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RiuMultiCaseImportDialog::on_m_removeSearchFolderButton_clicked()
{
    QModelIndexList selection = ui->m_searchFolderList->selectionModel()->selectedIndexes();
    QStringList folderNames = m_searchFolders->stringList();

    QStringList searchFoldersToRemove;

    for (int i = 0; i < selection.size(); ++i)
    {
        searchFoldersToRemove.push_back(folderNames[selection[i].row()]);
    }

    for (int i = 0; i < searchFoldersToRemove.size(); ++i)
    {
        folderNames.removeOne(searchFoldersToRemove[i]);
    }

    m_searchFolders->setStringList(folderNames);

    if (selection.size())
    {
        updateGridFileList();
    }
}
Ejemplo n.º 6
0
void CloudTableView::selectChanged(QModelIndexList lst)
{
    m_selectedtems.clear();
    foreach (QModelIndex idx, lst) {
        if (idx.column()!=0) lst.removeOne(idx);
    }

    foreach (QModelIndex idx, lst) {
        QString tmp =  cs->fullPath + myProxyModel->
                data(myProxyModel->index(idx.row(),0),Qt::DisplayRole).toString();
        if (!tmp.contains("/.."))
            m_selectedtems << cs->fullPath + CTModel->
                              data(ConvertIndexToRealModel(myProxyModel->index(idx.row(),0))
                                   ,Qt::DisplayRole).toString();
    }
Ejemplo n.º 7
0
	void FixedWidthTableView::startDrag(Qt::DropActions supportedActions)
	{
		QModelIndex item = currentIndex();
		QModelIndexList list;
		list.append(item);

		QMimeData* mimeData = model()->mimeData(list);

		QDrag *drag = new QDrag(this);
		drag->setMimeData(mimeData);
		QPixmap pixmap = getDragPixmap(mimeData->text());
		drag->setPixmap(pixmap);
		QPoint hotpoint(pixmap.width()+10, pixmap.height()/2);
		drag->setHotSpot(hotpoint);

		if (drag->exec(Qt::CopyAction|Qt::MoveAction, Qt::CopyAction) == Qt::MoveAction)
		{
			// item moved
		}
		else
		{
			// item copied
		}
	}
Ejemplo n.º 8
0
void MenuView::SetSelection(double value, bool relative) {
  QModelIndexList list = selectedIndexes();
  if (list.size() == 0) {
    return;
  }

  QModelIndex selectedIndex = list[COUNT_COLUMN];
  QModelIndex selectedIndex2 = list[REMAIN_COLUMN];
  double currentCount;
  if (relative) {
    currentCount =
      model->data(selectedIndex, Qt::DisplayRole).toDouble();
    currentCount += value;
  } else {
    currentCount = value;
  }
  double maxCount = model->data(selectedIndex2, Qt::DisplayRole).toDouble();
  if (currentCount < 0)
    currentCount = 0;
  if (currentCount > maxCount)
    currentCount = maxCount;
  model->setData(selectedIndex, currentCount, Qt::DisplayRole);
  EmitTotalPrice();
}
Ejemplo n.º 9
0
void GraphViewer::delayedInit()
{
    // make all existing objects known to the vtk widget
    const QAbstractItemModel *listModel = mProbeIface->objectListModel();
    for (int i = 0; i < listModel->rowCount(); ++i) {
        const QModelIndex index = listModel->index(i, 0);
        QObject *object = index.data(ObjectModel::ObjectRole).value<QObject*>();
        Q_ASSERT(object);
        mWidget->vtkWidget()->addObject(object);
    }
    connect(mProbeIface->probe(), SIGNAL(objectCreated(QObject*)),
            mWidget->vtkWidget(), SLOT(addObject(QObject*)));
    connect(mProbeIface->probe(), SIGNAL(objectDestroyed(QObject*)),
            mWidget->vtkWidget(), SLOT(removeObject(QObject*)));

    // select the qApp object (if any) in the object treeView
    const QAbstractItemModel *viewModel = mObjectTreeView->model();
    const QModelIndexList matches = viewModel->match(viewModel->index(0, 0),
                                    ObjectModel::ObjectRole,
                                    QVariant::fromValue<QObject*>(qApp));
    if (!matches.isEmpty()) {
        mObjectTreeView->setCurrentIndex(matches.first());
    }
}
 /// ------------------------------------------------------------------------
 ///	unset_vacation_days( const QModelIndexList &list_indexes )
 /// ------------------------------------------------------------------------
 void data_model_month::unset_vacation_days( const QModelIndexList &list_indexes )
 {
     if( !this->_data )
     {
         return;
     }
     try
     {
         QModelIndexList::const_iterator it = list_indexes.begin();
         for( ; it < list_indexes.end( ); ++it )
         {
             const QModelIndex &idx = *it;
             if( idx.isValid( ) )
             {
                 this->_data->unset_vacation( idx.row( ), idx.column( ) );
             }
         }
     }
     catch( std::exception &ex )
     {
         qDebug( ) << "data_model_month::set_vacation_days\t"
                << QString::fromStdString( ex.what( ) );
     }
 }
Ejemplo n.º 11
0
// private slots
void
DiscoveryPanel::onSelectedChatroomChanged(const QItemSelection &selected,
                                          const QItemSelection &deselected)
{
  QModelIndexList items = selected.indexes();
  QString chatroomName = m_chatroomListModel->data(items.first(), Qt::DisplayRole).toString();

  bool chatroomFound = false;
  for (int i = 0; i < m_chatroomList.size(); i++) {
    if (chatroomName == m_chatroomList[i]) {
      chatroomFound = true;
      m_chatroom = m_chatroomList[i];
      m_participant.clear();
      break;
    }
  }

  if (!chatroomFound) {
    emit warning("This should not happen: DiscoveryPanel::onSelectedChatroomChanged");
    return;
  }

  emit waitForChatroomInfo(m_chatroom);
}
Ejemplo n.º 12
0
void MainWindow::positionInPackageList(const QString &pkgName)
{
  QModelIndex columnIndex = m_packageModel->index(0, PackageModel::ctn_PACKAGE_NAME_COLUMN, QModelIndex());
  QModelIndexList foundItems = m_packageModel->match(columnIndex, Qt::DisplayRole, pkgName, -1, Qt::MatchExactly);
  QModelIndex proxyIndex;

  if (foundItems.count() == 1)
  {
    proxyIndex = foundItems.first();

    if(proxyIndex.isValid())
    {
      ui->tvPackages->scrollTo(proxyIndex, QAbstractItemView::PositionAtCenter);
      ui->tvPackages->setCurrentIndex(proxyIndex);
      changeTabWidgetPropertiesIndex(ctn_TABINDEX_INFORMATION);
    }
  }
  if (foundItems.count() == 0 || !proxyIndex.isValid())
  {
    refreshTabInfo(pkgName);
    disconnect(ui->twProperties, SIGNAL(currentChanged(int)), this, SLOT(changedTabIndex()));
    ensureTabVisible(ctn_TABINDEX_INFORMATION);
    connect(ui->twProperties, SIGNAL(currentChanged(int)), this, SLOT(changedTabIndex()));
  }
Ejemplo n.º 13
0
void GraphTableWidget::scrollToFirstOf(const QModelIndexList& indexes) {
  int xMin=INT_MAX;
  int yMin=INT_MAX;
  int rowMin = -1;
  int colMin = -1;

  for(QModelIndexList::const_iterator it = indexes.begin(); it != indexes.end(); ++it) {
    QRect indexRect = visualRect(*it);

    if(indexRect.left() < xMin) {
      xMin = indexRect.left();
      rowMin =( *it).row();
    }

    if(indexRect.top() < yMin) {
      yMin = indexRect.top();
      colMin = (*it).column();
    }
  }

  if(rowMin != -1 && colMin != -1) {
    QTableView::scrollTo(_tulipTableModel->index(rowMin,colMin),QAbstractItemView::PositionAtTop);
  }
}
Ejemplo n.º 14
0
void DesktopWindow::childDropEvent(QDropEvent* e) {
  bool moveItem = false;
  if(e->source() == listView_ && e->keyboardModifiers() == Qt::NoModifier) {
    // drag source is our list view, and no other modifier keys are pressed
    // => we're dragging desktop items
    const QMimeData *mimeData = e->mimeData();
    if(mimeData->hasFormat("application/x-qabstractitemmodeldatalist")) {
      QModelIndex dropIndex = listView_->indexAt(e->pos());
      if(dropIndex.isValid()) { // drop on an item
        QModelIndexList selected = selectedIndexes(); // the dragged items
        if(selected.contains(dropIndex)) { // drop on self, ignore
          moveItem = true;
        }
      }
      else { // drop on a blank area
        moveItem = true;
      }
    }
  }
  if(moveItem)
    e->accept();
  else
    Fm::FolderView::childDropEvent(e);
}
Ejemplo n.º 15
0
void FilesModel::matchSelToNotes()
{
    QItemSelectionModel* pNotesSelModel (m_pCommonData->m_pNotesG->selectionModel());
    QModelIndexList notesLstSel (pNotesSelModel->selection().indexes());

    set<int> sSel;
    for (QModelIndexList::iterator it = notesLstSel.begin(), end = notesLstSel.end(); it != end; ++it)
    {
//cout << "cell sel at " << it->row() << "x" << it->column() << endl;
        const Note* pNote (m_pCommonData->getCrtNotes()[it->row()]);
        int nPos (m_pCommonData->findPos(pNote));
        sSel.insert(nPos);
    }

    m_pCommonData->m_pFilesG->selectionModel()->clearSelection();

    for (set<int>::const_iterator it = sSel.begin(), end = sSel.end(); it != end; ++it)
    {
        m_pCommonData->m_pFilesG->selectionModel()->select(index(m_pCommonData->getFilesGCrtRow(), *it + 1), QItemSelectionModel::Select);
//cout << "selecting " << m_pCommonData->getFilesGCrtRow() << "x" << *it + 1 << endl;
    }

    m_pCommonData->m_pFilesG->selectionModel()->select(index(m_pCommonData->getFilesGCrtRow(), 0), QItemSelectionModel::Select);
}
Ejemplo n.º 16
0
void ViewListTreeWidget::startDrag( Qt::DropActions supportedActions )
{
    QModelIndexList indexes = selectedIndexes();
    if ( indexes.count() == 1 ) {
        ViewListItem *item = static_cast<ViewListItem*>( itemFromIndex( indexes.at( 0 ) ) );
        Q_ASSERT( item );
        QTreeWidgetItem *root = invisibleRootItem();
        int count = root->childCount();
        if ( item && item->type() == ViewListItem::ItemType_Category ) {
            root->setFlags( root->flags() | Qt::ItemIsDropEnabled );
            for ( int i = 0; i < count; ++i ) {
                QTreeWidgetItem * ch = root->child( i );
                ch->setFlags( ch->flags() & ~Qt::ItemIsDropEnabled );
            }
        } else if ( item ) {
            root->setFlags( root->flags() & ~Qt::ItemIsDropEnabled );
            for ( int i = 0; i < count; ++i ) {
                QTreeWidgetItem * ch = root->child( i );
                ch->setFlags( ch->flags() | Qt::ItemIsDropEnabled );
            }
        }
    }
    QTreeWidget::startDrag( supportedActions );
}
Ejemplo n.º 17
0
void param_search_widget::plot()
{
    // First we need to build the two Lists of property and parameters we
    // will use to plot
    QModelIndexList selectedModels =
        ui->tableViewResults->selectionModel()->selectedIndexes();

    plotParameters_.clear();
    plotValues_.clear();

    std::vector<int> cont;

    for (unsigned int i = 0; i < selectedModels.size(); ++i)
    {
        cont.push_back(selectedModels.at(i).row());
    }
    std::sort(cont.begin(), cont.end());
    cont.erase(std::unique(cont.begin(), cont.end()), cont.end());

    for (unsigned int i = 0; i < cont.size(); ++i)
    {
        plotParameters_.append(model->data(
                                   model->index(cont.at(i),0,
                                                QModelIndex())).toString());

        plotValues_.push_back(model->data(
                                  model->index(cont.at(i),1,
                                               QModelIndex())).toFloat());
    }

    param_plot_window * subWindow = new param_plot_window(this);

    subWindow->plot(plotParameters_,plotValues_,currentSearchParam_);
    mdiParent_->addSubWindow(subWindow);
    subWindow->show();
}
Ejemplo n.º 18
0
void CourseEditUI::tableViewSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
{
	if(selected.count() > 0)
	{
		QModelIndexList selectedList = selected.at(0).indexes();
		if(selectedList.count() > 0)
		{
			QString question = selectedList.value(0).data().toString();
			QString answer = selectedList.value(1).data().toString();
			txtQuestion->setText(question);
			txtAnswer->setText(answer);
			for(Items::const_iterator it = _items.begin(); it != _items.end(); ++it)
			{
				if(it->get()->GetQuestion() == question.toStdString() && it->get()->GetAnswer() == answer.toStdString())
				{
					_currentItem = *it;
					return;
				}
				
			}
			_currentItem = ItemPtr();
		}
	}
}
Ejemplo n.º 19
0
void EditTableView::removeSelected()
{
    if (!model() || !selectionModel() || !selectionModel()->hasSelection())
        return;

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

    int newSelectedRow = selectedRows.at(0).row();
    for (int i = selectedRows.count() - 1; i >= 0; --i) {
        QModelIndex idx = selectedRows.at(i);
        model()->removeRow(idx.row(), rootIndex());
    }

    // select the item at the same position
    QModelIndex newSelectedIndex = model()->index(newSelectedRow, 0, rootIndex());
    // if that was the last item
    if (!newSelectedIndex.isValid())
        newSelectedIndex = model()->index(newSelectedRow - 1, 0, rootIndex());

    selectionModel()->select(newSelectedIndex, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
    setCurrentIndex(newSelectedIndex);
}
Ejemplo n.º 20
0
bool lastfirst(QModelIndexList &list, int &first, int &last)
{
	if (!list.size())
		return false;
	first = last = list[0].row();
	for (auto item : list)
	{
		int row = item.row();
		if (row < first)
			first = row;
		if (row > last)
			last = row;
	}
	return true;
}
Ejemplo n.º 21
0
void window_addtacheunaire::ajouter_prerequis(Tache * newTache)
{
    //gestion prérequis
    if (ui->cb_prereq->isChecked()&&newTache!=NULL)
    {
        QItemSelectionModel *selection = ui->list_prereq->selectionModel();
        QModelIndexList listeSelections = selection->selectedIndexes();

        for (int i = 0 ; i < listeSelections.size() ; i++)
        {
            QVariant elementSelectionne = modele->data(listeSelections[i], Qt::DisplayRole);
            QString titreTache = elementSelectionne.toString();

            std::list<Tache*> taches = Model::getTaches();
            std::list<Tache*>::iterator it = taches.begin();
            for (unsigned int i = 0 ; i < taches.size() ; i++)
            {
                QString titre = (*it)->getTitre();
                if (titre == titreTache)
                {
                    try
                    {
                        newTache->ajouterPrerequis((*it));
                    }
                    catch (CalendarException& e)
                    {
                        QMessageBox::critical(this, "Erreur", e.getInfo());
                        return;

                    }
                }
                it++;
            }
        }
    }
}
Ejemplo n.º 22
0
void CharSelect::slot_selectionChanged( const QItemSelection& sel, const QItemSelection& )
{
	QModelIndexList indexes = sel.indexes();
	if ( indexes.isEmpty() )
		return;

	QModelIndex index = indexes.at(0);
	if ( !index.isValid() )
		return;

	// we retrieve a QStringList of two elements from data() encapsulated in a
	// QVariant, so we should make sure first that we can convert to QStringList.
	// Otherwise clear the status label
	QVariant tmp = index.data(Qt::StatusTipRole);
	if ( !tmp.canConvert(QMetaType::QStringList) )
	{
		m_statusLabel->setText(QString());
		return;
	}

	QStringList lst = tmp.toStringList();
	m_statusLabel->setText("<p><b>" + QString("%1").arg(m_unicodeSearchModel->descriptionFromHex(lst.at(0))).toUpper() +
												 "</b><br>" + QString(tr("Font: %2")).arg(lst.at(1)) + "</p>");
}
void RealTimeMultiSampleArrayWidget::markChBad()
{
    QModelIndexList selected = m_pTableView->selectionModel()->selectedIndexes();

    for(int i=0; i<selected.size(); i++) {
        if(m_qListBadChannels.contains(selected[i].row())) { //mark as good
            m_pRTMSAModel->markChBad(selected[i], false);
            m_qListBadChannels.removeAll(selected[i].row());
        }
        else {
            m_pRTMSAModel->markChBad(selected[i], true);
            m_qListBadChannels.append(selected[i].row());
        }
    }

    m_pRTMSAModel->updateProjection();

    m_pSelectionManagerWindow->updateBadChannels();

    //Update 3D plot and interpolation
    if(m_bVisualize3DSensorData) {
        m_pRtEEGSensorDataItem->updateBadChannels(*m_pFiffInfo.data());
    }
}
Ejemplo n.º 24
0
void RSSWidget::askNewFolder()
{
    bool ok;
    QString newName = AutoExpandableDialog::getText(
                this, tr("Please choose a folder name"), tr("Folder name:"), QLineEdit::Normal
                , tr("New folder"), &ok);
    if (!ok) return;

    newName = newName.trimmed();
    if (newName.isEmpty()) return;

    // Determine destination folder for new item
    QModelIndex destIndex;
    QModelIndexList selectedIndexes = m_rssTreeView->selectionModel()->selectedRows();
    if (!selectedIndexes.empty()) {
        destIndex = selectedIndexes.first();
        if (!isFolder(destIndex))
            destIndex = destIndex.parent();
    }
    // Consider the case where the user clicked on Unread item
    RSS::Folder &destFolder =
            *(!destIndex.isValid() ? RSS::Manager::instance()->rootFolder()
                                   : static_cast<RSS::Folder *>(getItemPtr(destIndex)));

    try {
        RSS::Manager::instance()->addFolder(newName, destFolder);
        // Expand destination folder to display new feed
        if (destIndex.isValid() && !isStickyItem(destIndex))
            m_rssTreeView->expand(destIndex);
        // As new RSS items are added synchronously, we can do the following here.
//        m_rssTreeWidget->setCurrentItem(id);
    }
    catch (const RuntimeError &err) {
        QMessageBox::warning(this, "qBittorrent", err.message(), QMessageBox::Ok);
    }
}
Ejemplo n.º 25
0
QModelIndex ETMViewStateSaver::indexFromConfigString(const QAbstractItemModel *model, const QString& key) const
{
  if ( key.startsWith( QLatin1Char( 'x' ) ) )
    return QModelIndex();

  Entity::Id id = key.mid( 1 ).toLongLong();
  if ( id < 0 )
    return QModelIndex();

  if ( key.startsWith( QLatin1Char( 'c' ) ) ) {
    QModelIndex idx = EntityTreeModel::modelIndexForCollection( model, Collection( id ) );
    if ( !idx.isValid() ) {
      return QModelIndex();
    }
    return idx;
  } else if ( key.startsWith( QLatin1Char( 'i' ) ) ) {
    QModelIndexList list = EntityTreeModel::modelIndexesForItem( model, Item( id ) );
    if ( list.isEmpty() ) {
      return QModelIndex();
    }
    return list.first();
   }
  return QModelIndex();
}
Ejemplo n.º 26
0
void ScheduleView::contextMenu(const QPoint & point) {

	QModelIndex index = indexAt(point);
	if (!index.isValid())
		return;

	QMenu menu;
	QAction *action;

	// Find selected dates
	QItemSelectionModel *selection_model = selectionModel();
	QModelIndexList selection = selection_model->selectedIndexes();

	// Single date selected
	if (selection.size() == 1) {
		selected_date = dynamic_cast<CalendarModel*>(model())->date(selection[0]);

		action = menu.addAction(tr("Weekly"));
		connect(action, SIGNAL(triggered()), SLOT(scheduleWeeklyBackup()));

		action = menu.addAction(tr("Once"));
		connect(action, SIGNAL(triggered()), SLOT(scheduleOneBackup()));

		action = menu.addAction(tr("Daily"));
		connect(action, SIGNAL(triggered()), SLOT(scheduleDailyBackup()));

	} else {
//		action = menu.addAction(tr("Once"));
//		connect(action, SIGNAL(triggered()), SLOT(scheduleBackup()));
//
//		action = menu.addAction(tr("Weekly"));
//		connect(action, SIGNAL(triggered()), SLOT(scheduleWeeklyBackup()));
	}

	menu.exec(viewport()->mapToGlobal(point));
}
Ejemplo n.º 27
0
void InvoicePage::on_receiptButton_clicked()
{
    if(!model)
        return;

    if(!ui->tableView->selectionModel())
        return;

    QModelIndexList indexes = ui->tableView->selectionModel()->selectedRows();

    if(indexes.isEmpty())
        return;

    bool ok;
    QModelIndex origIndex = proxyModel->mapToSource(indexes.at(0));
    CAmount amount;
    BitcreditUnits::parse(model->getMessageModel()->getOptionsModel()->getDisplayUnit(),
                        QInputDialog::getText(this,
                                              tr("Send Receipt to ")                + model->data(model->index(origIndex.row(), model->Label,  QModelIndex()), Qt::DisplayRole).toString(),
                                              tr("Amount Paid:"), QLineEdit::Normal , model->data(model->index(origIndex.row(), model->Total,  QModelIndex()), Qt::DisplayRole).toString().replace(" " + BitcreditUnits::name(model->getMessageModel()->getOptionsModel()->getDisplayUnit()), ""), &ok),
                        &amount);

    if(!ok)
        return;

    model->newReceipt(model->data(model->index(origIndex.row(), model->InvoiceNumber,  QModelIndex()), Qt::DisplayRole).toString(), amount);

    SendMessagesDialog dlg(SendMessagesDialog::Encrypted, SendMessagesDialog::Dialog, this);

    dlg.setModel(model->getMessageModel());

    dlg.loadInvoice(model->getMessageModel()->getReceiptTableModel()->getReceiptJSON(0),
                    model->data(model->index(origIndex.row(), model->FromAddress, QModelIndex()), Qt::DisplayRole).toString(),
                    model->data(model->index(origIndex.row(), model->ToAddress,   QModelIndex()), Qt::DisplayRole).toString());
    dlg.exec();
}
Ejemplo n.º 28
0
void CreateDataPlumeDialog::on_acceptProposalsButton_clicked()
{
    if(ui->proposalsTableWidget->selectedItems().count() == 0)
    {
        QMessageBox msg;
        msg.setText("Please select one or more proposals to accept.");
        msg.exec();
        return;
    }

    // get the proposal id's
    std::vector<uint256> proposalIds;
    QItemSelectionModel* selectionModel = ui->proposalsTableWidget->selectionModel();
    QModelIndexList selected = selectionModel->selectedRows();
    for(int i= 0; i< selected.count();i++)
    {
        QModelIndex index = selected.at(i);
        int r = index.row();
        uint256 hash = uint256(ui->proposalsTableWidget->item(r, 4)->text().toStdString());
        proposalIds.push_back(hash);
    }

    bool hasErrors = false;
    CPlumeApi api;
    BOOST_FOREACH(uint256 p, proposalIds)
    {
        std::string err;
        bool res = api.AcceptProposal(p, err);
        if(!res)
        {
            hasErrors = true;
            QMessageBox msg;
            msg.setText(QString::fromStdString(err));
            msg.exec();
        }
    }
Ejemplo n.º 29
0
void CQUnitsWidget::slotBtnClearClicked()
{

  int ret = CQMessageBox::question(this, tr("Confirm Delete"), "Delete all unused or non-built-in Units?",
                                   QMessageBox::Yes | QMessageBox::No, QMessageBox::No);

  if (ret == QMessageBox::Yes)
    {
      QModelIndexList mappedSelRows;
      size_t i, imax = mpUnitDM->rowCount();

      for (i = 0; i < imax; i++)
        {
          mappedSelRows.append(mpUnitDM->index((int) i, 0));
        }

      if (mappedSelRows.empty())
        return;

      mpUnitDM->removeRows(mappedSelRows);
    }

  updateDeleteBtns();
}
Ejemplo n.º 30
0
void Window::copySelected()
{
    QModelIndexList selectedIndexes = planetTreeView->selectionModel()->selectedIndexes();
    if (selectedIndexes.size() == 0) {
        return;
    }
    QString copy;
    for (int i = 0; i < planetTreeModel->columnCount(); i++) {
        if (planetTreeView->isColumnHidden(i)) {
            continue;
        }
        QString column = selectedIndexes.at(i).data().toString();
        if (!column.compare("")) {
            continue;
        }
        copy += column;
        if (i < planetTreeModel->columnCount()-1) {
            if (selectedIndexes.at(i+1).data().toString().compare("") && !planetTreeView->isColumnHidden(i+1)) {
                copy += "|";
            }
        }
    }
    QGuiApplication::clipboard()->setText(copy);
}