IndigoJo / qtm (http://qtm.blogistan.co.uk/)


A repository for the QTM blogging software
Clone URL : http://bitbucket.org/IndigoJo/qtm/ (size: 404.9 KB)
commit 100: 5f43153d9205
parent 99: c412929021f4
branch: default
Added new "export" feature EditingWindowBase.ui - Added new "Export" action EditingWindow.* - New exportEntry slot, allowing for entries to be saved "old style" so they can be imported into another QTM install. Save methods amended with new bool "exp" arguments, so that they can export or just save as needed.
Matthew Smith / IndigoJo
3 months ago

Changed (Δ1.1 KB):

raw changeset »

EditingWindow.cc (47 lines added, 22 lines removed)

EditingWindow.h (3 lines added, 2 lines removed)

EditingWindowBase.ui (6 lines added, 0 lines removed)

Up to file-list EditingWindow.cc:

@@ -1933,6 +1933,7 @@ void EditingWindow::blogger_getUsersBlog
1933
1933
				  QVariant( blogNodeList.at( a ).firstChildElement( "blogid" ).text() ) );
1934
1934
      currentBlog = cw.cbBlogSelector->currentIndex();
1935
1935
    }
1936
    cw.cbBlogSelector->setEnabled( true );
1936
1937
    addToConsole( accountsDom.toString( 2 ) );
1937
1938
1938
1939
    if( !initialChangeBlog )
@@ -2928,7 +2929,12 @@ void EditingWindow::publishPost() // slo
2928
2929
    statusBar()->showMessage( tr( "Cannot publish; HTTP is blocked" ), 2000 );
2929
2930
}
2930
2931
2931
void EditingWindow::saveAs()
2932
void EditingWindow::exportEntry()
2933
{
2934
  saveAs( true );
2935
}
2936
2937
void EditingWindow::saveAs( bool exp )
2932
2938
{
2933
2939
  QString suggestedFilename;
2934
2940
@@ -2963,7 +2969,7 @@ already checks for the existence of a fi
2963
2969
      }
2964
2970
    }
2965
2971
    else */
2966
    save( fn );
2972
    save( fn, exp );
2967
2973
2968
2974
    qtm->addRecentFile( cw.leTitle->text(), fn );
2969
2975
  }
@@ -2982,7 +2988,7 @@ void EditingWindow::save()
2982
2988
  save( filename );
2983
2989
}
2984
2990
2985
void EditingWindow::save( const QString &fname )
2991
void EditingWindow::save( const QString &fname, bool exp )
2986
2992
{
2987
2993
  int count, tags;
2988
2994
  QString text = EDITOR->document()->toPlainText();
@@ -3007,10 +3013,19 @@ void EditingWindow::save( const QString
3007
3013
    out << QString( "EntryNumber:%1\n" ).arg( entryNumber );
3008
3014
  out << QString( "Comments:%1\n" ).arg( cw.chComments->isChecked() ? "1" : "0" );
3009
3015
  out << QString( "TB:%1\n" ).arg( cw.chTB->isChecked() ? "1" : "0" );
3010
  out << QString( "AcctBlog:%1@%2 (%3)\n" ) // Include the blog name so it can be relayed to the user later
3011
    .arg( currentBlogid )
3012
    .arg( currentAccountId )
3013
    .arg( cw.cbBlogSelector->itemText( cw.cbBlogSelector->currentIndex() ) );
3016
  if( exp ) {
3017
    out << QString( "Server:%1\n" ).arg( server );
3018
    out << QString( "Location:%1\n" ).arg( location );
3019
    out << QString( "Login:%1\n" ).arg( login );
3020
    out << QString( "Password:%1\n" ).arg( password );
3021
    out << QString( "Blog:%1\n" ).arg( currentBlogid );
3022
  }
3023
  else {
3024
    out << QString( "AcctBlog:%1@%2 (%3)\n" ) // Include the blog name so it can be relayed to the user later
3025
      .arg( currentBlogid )
3026
      .arg( currentAccountId )
3027
      .arg( cw.cbBlogSelector->itemText( cw.cbBlogSelector->currentIndex() ) );
3028
  }
3014
3029
  out << "Tags:";
3015
3030
  tags = cw.lwTags->count();
3016
3031
  for( count = 0; count < tags; count++ ) {
@@ -3130,9 +3145,10 @@ bool EditingWindow::load( const QString
3130
3145
  QDomNodeList accts;
3131
3146
  bool getDetailsAgain = false;
3132
3147
  bool isOK;
3133
  int b, c, d, hh;
3148
  int b, c, d, g, h, hh;
3134
3149
  noAutoSave = true;
3135
3150
  QFile f( fname );
3151
  QDomElement details; 
3136
3152
3137
3153
  ui.actionSave_blogs->setEnabled( true );
3138
3154
  ui.actionSave_blogs->setVisible( true );
@@ -3302,38 +3318,47 @@ bool EditingWindow::load( const QString
3302
3318
3303
3319
  if( !loadedAccountId.isNull() ) {
3304
3320
    accts = accountsDom.elementsByTagName( "account" );
3305
    for( int g = 0; g <= accts.count(); g++ ) {
3321
    for( g = 0; g <= accts.count(); g++ ) {
3306
3322
      if( g == accts.count() ) {
3323
	qDebug() << accts.count() << "accounts";
3307
3324
	// i.e. if it gets to the end of the accounts tree without finding the account
3308
3325
	QMessageBox::information( 0, tr( "QTM - No such account" ),
3309
3326
				  tr( "QTM could not find this account (perhaps it was deleted).\n\n"
3310
				      "Will set up a blank default account; you will need to fill in the access"
3327
				      "Will set up a blank default account; you will need to fill in the access "
3311
3328
				      "details by choosing Accounts from the File menu." ),
3312
3329
				  QMessageBox::Ok );
3313
3330
	QDomElement newDefaultAccount = accountsDom.createElement( "account" );
3314
3331
	newDefaultAccount.setAttribute( "id", QString( "newAccount_%1" ).arg( QDateTime::currentDateTime().toString( Qt::ISODate ) ) );
3315
3332
	QDomElement newDetailElement = accountsDom.createElement( "details" );
3316
	QDomElement newNameElement = accountsDom.createElement( "name" );
3333
	QDomElement newNameElement = accountsDom.createElement( "title" );
3317
3334
	newNameElement.appendChild( QDomText( accountsDom.createTextNode( tr( "New blank element" ) ) ) );
3318
3335
	newDetailElement.appendChild( newNameElement );
3319
3336
	newDefaultAccount.appendChild( newDetailElement );
3320
	accountsDom.documentElement().appendChild( newDefaultAccount );
3337
	accountsDom.firstChildElement( "accounts" ).appendChild( newDefaultAccount );
3321
3338
	currentAccountElement = newDefaultAccount;
3322
        extractAccountDetails();
3339
        cw.cbAccountSelector->addItem( tr( "New blank element" ),
3340
                                       newDefaultAccount.attribute( "id" ) );
3341
        cw.cbAccountSelector->setCurrentIndex( cw.cbAccountSelector->count()-1 );
3342
	cw.cbBlogSelector->clear();
3343
        cw.cbBlogSelector->setEnabled( false );
3344
        cw.cbMainCat->clear();
3345
        cw.cbMainCat->setEnabled( false );
3346
        cw.lwOtherCats->clear();
3347
        cw.lwOtherCats->setEnabled( false );
3323
3348
	setPostClean();
3324
3349
	return true;
3325
3350
      }
3326
3351
      
3327
3352
      if( accts.at( g ).toElement().attribute( "id" ) == loadedAccountId ) {
3328
3353
	qDebug() << "found the account:" << loadedAccountId;
3329
3354
	populateAccountList();
3330
3355
	currentAccountElement = accts.at( g ).toElement();
3331
        extractAccountDetails();
3356
	extractAccountDetails();
3332
3357
3333
3358
	QString st;
3334
	for( int h = 0; h < cw.cbAccountSelector->count(); h++ ) {
3359
	for( h = 0; h < cw.cbAccountSelector->count(); h++ ) {
3335
3360
	  st = cw.cbAccountSelector->itemData( h ).toString();
3336
 	  if( st == loadedAccountId )
3361
	  if( st == loadedAccountId )
3337
3362
	    cw.cbAccountSelector->setCurrentIndex( h );
3338
3363
	}
3339
3364
@@ -3346,8 +3371,8 @@ bool EditingWindow::load( const QString
3346
3371
				      blogNodeList.at( hh ).toElement()
3347
3372
				      .firstChildElement( "blogid" ).text() );
3348
3373
3349
          if( blogNodeList.at( hh ).firstChildElement( "blogid" ).text() == currentBlogid )
3350
            currentBlogElement = blogNodeList.at( hh ).toElement();
3374
	  if( blogNodeList.at( hh ).firstChildElement( "blogid" ).text() == currentBlogid )
3375
	    currentBlogElement = blogNodeList.at( hh ).toElement();
3351
3376
	}
3352
3377
	cw.cbBlogSelector->disconnect( SIGNAL( activated( int ) ), this, 0 );
3353
3378
	qDebug() << "connecting changeBlog";
@@ -3372,8 +3397,8 @@ bool EditingWindow::load( const QString
3372
3397
	// Now populate and set the categories
3373
3398
	QDomElement catsElement = currentBlogElement.firstChildElement( "categories" );
3374
3399
	if( !catsElement.isNull() ) {
3375
          cw.cbMainCat->clear();
3376
          cw.lwOtherCats->clear();
3400
	  cw.cbMainCat->clear();
3401
	  cw.lwOtherCats->clear();
3377
3402
3378
3403
	  QDomNodeList catNodeList = catsElement.elementsByTagName( "category" );
3379
3404
	  int b = catNodeList.count();
@@ -3403,6 +3428,7 @@ bool EditingWindow::load( const QString
3403
3428
	return true;
3404
3429
      }
3405
3430
    }
3431
3406
3432
    filename = fname;
3407
3433
    setPostClean();
3408
3434
    return true;
@@ -3412,7 +3438,6 @@ bool EditingWindow::load( const QString
3412
3438
  // belong to an account; if it does, there is no need to check for the password
3413
3439
3414
3440
  qDebug() << "this is an old-style account";
3415
  QDomElement details; 
3416
3441
  QDomNodeList blogs;
3417
3442
3418
3443
  accts = accountsDom.documentElement().elementsByTagName( "account" );

Up to file-list EditingWindow.h:

@@ -189,8 +189,9 @@ class EditingWindow : public QMainWindow
189
189
  void choose( const QString fname = QString() );
190
190
  void openRecentFile();
191
191
  void save();
192
  void save( const QString & );
193
  void saveAs();
192
  void save( const QString &, bool exp = false );
193
  void exportEntry();
194
  void saveAs( bool exp = false );
194
195
  void stopThisJob();
195
196
  void handleDone( bool );
196
197
  void handleResponseHeader( const QHttpResponseHeader & );

Up to file-list EditingWindowBase.ui:

121
121
    <addaction name="actionOpen_recent" />
122
122
    <addaction name="action_Save" />
123
123
    <addaction name="actionSave_As" />
124
    <addaction name="action_Export" />
124
125
    <addaction name="action_Upload" />
125
126
    <addaction name="separator" />
126
127
    <addaction name="actionPrint" />
189
190
    <string>Sa&amp;ve As ...</string>
190
191
   </property>
191
192
  </action>
193
  <action name="action_Export" >
194
   <property name="text" >
195
    <string>&amp;Export</string>
196
   </property>
197
  </action> 
192
198
  <action name="actionPrint" >
193
199
   <property name="enabled" >
194
200
    <bool>false</bool>