⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainwindow.cpp

📁 Trolltech公司发布的图形界面操作系统。可在qt-embedded-2.3.10平台上编译为嵌入式图形界面操作系统。
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	    refStream << tmpTable->currentEntry().uid().toString();	    QDLLink newLink("todolist",  dataRef, tmpTable->currentEntry().description(),  "todolist/TodoList");	    e << newLink;	}	delete diag;    } else if( msg == "QDLActivateLink(QByteArray)" ) {	needShow = TRUE;	QDataStream stream( data, IO_ReadOnly );	QByteArray dataRef;	stream >> dataRef;	QDataStream refStream( dataRef, IO_ReadOnly );	QString dataRefStr;	refStream >> dataRefStr;	QUuid uid( dataRefStr  );	table->setCurrentEntry( uid );	showListView();#endif    }         if ( needShow ) {#if defined(Q_WS_QWS) || defined(_WS_QWS_)//	showMaximized();#else//	show();#endif//	raise();	QPEApplication::setKeepRunning();//	setActiveWindow();    }}void TodoWindow::showListView(){    if ( centralWidget() != listView ) {	backAction->setEnabled(FALSE);	todoView()->hide();	setCentralWidget( listView );	listView->show();	table->setFocus();	setCaption( tr("Tasks") );#ifdef QTOPIA_PHONE	newAction->setEnabled(TRUE);	actionCategory->setEnabled(TRUE);	editAction->setEnabled(FALSE);	deleteAction->setEnabled(FALSE);	if (beamAction) beamAction->setEnabled(FALSE);#endif    }}void TodoWindow::showDetailView(){    if (centralWidget() != todoView()) {	backAction->setEnabled(TRUE);	todoView()->init( table->currentEntry() );	listView->hide();	setCentralWidget( todoView() );	todoView()->show();	todoView()->setFocus();  //To avoid events being passed to QTable	setCaption( tr("Task Details") );#ifdef QTOPIA_PHONE	newAction->setEnabled(FALSE);	actionCategory->setEnabled(FALSE);	editAction->setEnabled(TRUE);	deleteAction->setEnabled(TRUE);	if (beamAction) beamAction->setEnabled(TRUE);#endif    }}TodoView* TodoWindow::todoView(){    if ( !tView ) {	tView = new TodoView(this);	tView->setMargin(0);	connect( tView, SIGNAL(done()), this, SLOT(showListView()) );	connect( tView, SIGNAL(previous()), this, SLOT(viewPrevious()) );	connect( tView, SIGNAL(next()), this, SLOT(viewNext()) );#ifdef QTOPIA_PHONE	ContextBar::setLabel(tView, Key_Select, ContextBar::NoLabel);#endif    }    return tView;}void TodoWindow::createNewEntry(){#ifdef QTOPIA_PHONE    TaskDialog e( -2, this, "edit-screen", TRUE );#else    TaskDialog e( catSelect->currentCategory(), this, "edit-screen", TRUE );#endif    e.setCaption( tr( "New Task" ) );    int ret = QPEApplication::execDialog(&e);    if ( ret == QDialog::Accepted ) {	PimTask todo = e.todoEntry();	if ( todo.description().isEmpty() && !todo.notes().isEmpty() ) {	    // Don't want to loose an entry that has some useful data	    QString desc = todo.notes();#ifdef QTOPIA_DATA_LINKING	    // filter out any qdl fields	    desc = QDL::removeLids(desc);#endif	    if ( desc.length() > 30 ) {		// keep description length sensible		desc.truncate(27);		desc.append( "..." ); // no tr	    }	    todo.setDescription( desc );	}	if ( !todo.description().isEmpty() ) {	    table->addEntry( todo );	    findAction->setEnabled( TRUE );	    currentEntryChanged( );	    showListView();	}    }}void TodoWindow::deleteCurrentEntry(){    if ( table->currentRow() == -1 )        return;    QString strName = table->currentEntry().description().left(30);    if ( table->selectionMode() == TodoTable::Extended ) {	QValueList<int> t = table->selectedTasks();		if ( !t.count() ) return;		QString str;	if ( t.count() > 1 )	    str = tr("<qt>Are you sure you want to delete the %1 selected tasks?</qt>").arg( t.count() );	else	    str = tr("<qt>Are you sure you want to delete:<p><b>%1</b>?</qt>").arg( table->currentEntry().description().left(30)  );	switch( QMessageBox::warning( this, tr("Tasks"), str, tr("Yes"), tr("No"), 0, 0, 1 ) ) {	    case 0:	    {		table->removeList(t);		currentEntryChanged();		showListView();	    }	    break;	    case 1: break;	}    } else if ( QPEMessageBox::confirmDelete( this, tr( "Tasks" ),	strName.simplifyWhiteSpace() ) ) {	table->removeEntry( table->currentEntry() );	currentEntryChanged();	showListView();    }    if ( !table->numRows() && findAction->isOn()) {	findAction->setOn(FALSE);    }}void TodoWindow::editCurrentEntry(){    PimTask todo = table->currentEntry();    TaskDialog e( todo, this, "edit-screen", TRUE );    e.setCaption( tr( "Edit Task" ) );    int ret = QPEApplication::execDialog(&e);    if ( ret == QDialog::Accepted ) {        todo = e.todoEntry();	table->updateEntry( todo );	if (table->currentEntry().uid() != todo.uid())	    showListView();	if ( centralWidget() == todoView() ) {	    todoView()->init( table->currentEntry() );	    tView->setFocus();  //To avoid events being passed to QTable	}    }    }void TodoWindow::viewPrevious(){    int cr = table->currentRow();    if ( --cr >= 0 ) {	table->setCurrentCell( cr, table->currentColumn() );	todoView()->init( table->currentEntry() );    }}void TodoWindow::viewNext(){    int cr = table->currentRow();    if ( ++cr < table->numRows() ) {	table->setCurrentCell( cr, table->currentColumn() );	todoView()->init( table->currentEntry() );    }}void TodoWindow::setShowCompleted( int s ){    if ( !table->isUpdatesEnabled() )	return;    table->setCompletedFilter( s != 1 );    table->reload();}void TodoWindow::currentEntryChanged( ){    bool entrySelected = table->hasCurrentEntry();#ifndef QTOPIA_PHONE    editAction->setEnabled(entrySelected);    deleteAction->setEnabled(entrySelected);    if (beamAction) beamAction->setEnabled(entrySelected);#endif    findAction->setEnabled(entrySelected);}void TodoWindow::reload(){    table->loadData();#ifndef QTOPIA_PHONE    QArray<int> vl( 0 );    catSelect->setCategories( vl, "Todo List", // No tr	tr("Tasks") );    catSelect->setAllCategories( TRUE );        catSelected( catSelect->currentCategory() );#else    catSelected( -2 );#endif    table->reload();    if ( centralWidget() == tView )	showDetailView();}void TodoWindow::flush(){    table->saveData();}void TodoWindow::catSelected( int c ){    table->setFilter( c ); // WAH? Why?    table->reload(); // WAH? Why?#ifndef QTOPIA_PHONE    setCaption( tr("Tasks") + " - " + table->categoryLabel( c ) );#else    if (c == -2) {	categoryLbl->hide();    } else {	categoryLbl->setText(tr("Category: %1").arg(table->categoryLabel(c)));	categoryLbl->show();    }#endif}// Loop through and validate the categories.  If any records' category list was// modified we need to updatevoid TodoWindow::catChanged(){    Categories c;    c.load( categoryFileName() );    QArray<int> cats = c.ids("Todo List", c.labels("Todo List", TRUE) ); // No tr    if (table->categoriesChanged(cats))	reload();}void TodoWindow::closeEvent( QCloseEvent *e ){    e->accept();    // repeat for categories...    // if writing configs fail, it will emit an    // error, but I feel that it is "ok" for us to exit    // espically since we aren't told if the write succeeded...    Config config( "todo" );    config.setGroup( "View" );    config.writeEntry( "ShowComplete", !table->completedFilter() );    config.writeEntry( "Category", table->filter() );}#ifdef QTOPIA_PHONEvoid TodoWindow::keyPressEvent(QKeyEvent *e){    QMainWindow::keyPressEvent(e);    if ( !e->isAccepted() && (e->key() == Key_Back || e->key() == Key_No)) {	e->accept();	if ( centralWidget() == tView )	    showListView();	else	    close();    }}#endifvoid TodoWindow::showFindWidget( bool s ){    showListView();    if ( s ) {	searchBar->show();	searchEdit->setFocus();    } else {	searchBar->hide();	if ( table->numSelections() )	    table->clearSelection();	table->clearFindRow();    }}void TodoWindow::search(){    table->find( searchEdit->text() );}void TodoWindow::findNotFound(){    Global::statusMessage( tr("Find: not found") );}void TodoWindow::findFound(){    Global::statusMessage( "" );}void TodoWindow::findWrapped(){    Global::statusMessage( tr("Find: reached end") );}void TodoWindow::setDocument( const QString &filename ){    DocLnk doc(filename);    if ( doc.isValid() )	receiveFile(doc.file());    else	receiveFile(filename);}bool TodoWindow::receiveFile( const QString &filename ){    QValueList<PimTask> tl = PimTask::readVCalendar( filename );    if (tl.count() < 1) {	// should spit out more appropriate message.	QMessageBox::information(this, tr("New Tasks"),		    tr("<p>Received empty task list.  No tasks added"),		    QMessageBox::Ok);	return FALSE;    }    QString msg = tr("<P>%1 new tasks.<p>Do you want to add them to your Tasks?").	arg(tl.count());    if ( QMessageBox::information(this, tr("New Tasks"),	    msg, QMessageBox::Ok, QMessageBox::Cancel)==QMessageBox::Ok ) {	for( QValueList<PimTask>::Iterator it = tl.begin(); it != tl.end(); ++it ) {	    table->addEntry( *it );	}	return TRUE;    }    return FALSE;}void TodoWindow::beamCurrentEntry(){    if ( !table->hasCurrentEntry() ) {	qWarning("todo::beamCurrentEntry called with nothing to beam");	return;    }        QString description;    ::unlink( beamfile.local8Bit().data() ); // delete if exists    PimTask c = table->currentEntry();    if ( table->selectionMode() == TodoTable::Extended ) {	QValueList<PimTask> l = table->selected();	PimTask::writeVCalendar( beamfile, l );		if ( l.count() > 1 )	    description = tr("the %1 selected tasks").arg( l.count() );	else	    description = c.description();    } else {	PimTask::writeVCalendar( beamfile, c );	description = c.description();    }    #if defined(Q_WS_QWS) || defined(_WS_QWS_)    Ir *ir = new Ir( this );    connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );    ir->send( beamfile, description, "text/x-vCalendar" );#endif}void TodoWindow::beamDone( Ir *ir ){#if defined(Q_WS_QWS) || defined(_WS_QWS_)    delete ir;    ::unlink( beamfile.local8Bit().data() );#endif}void TodoWindow::configure(){    TodoSettings settings(this, "", TRUE);    settings.setCurrentFields( table->fields() );    if ( QPEApplication::execDialog(&settings) == QDialog::Accepted ) {	table->setFields( settings.fields() );	table->reload(); // WAH? Why?    }}void TodoWindow::selectAll(){    table->selectAll();}void TodoWindow::selectCategory(){#ifdef QTOPIA_PHONE    if (!categoryDlg) {	categoryDlg = new CategorySelectDialog("Todo List", this, 0, TRUE);	categoryDlg->setAllCategories(TRUE);	connect(categoryDlg, SIGNAL(selected(int)), this, SLOT(catSelected(int)));    }    QPEApplication::execDialog(categoryDlg);#endif}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -