Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

ActionsMenu Class Reference

#include <ActionsMenu.h>

Collaboration diagram for ActionsMenu:

Collaboration graph
[legend]
List of all members.

Public Types

enum  Direction { shrink = 0, expand }

Public Methods

 ActionsMenu (MainWindow &mw_)
void shift_a_up ()
void shift_a_down ()
void shift_b_up ()
void shift_b_down ()

Private Methods

void shift (Column s_, Direction d_)

Private Attributes

MainWindowm_mw

Member Enumeration Documentation

enum ActionsMenu::Direction
 

Enumeration values:
shrink 
expand 

Definition at line 30 of file ActionsMenu.h.

Referenced by shift.

00030 { shrink = 0, expand } Direction;


Constructor & Destructor Documentation

ActionsMenu::ActionsMenu MainWindow   mw_ [inline]
 

Definition at line 28 of file ActionsMenu.h.

References m_mw.

00028 : m_mw (mw_) { /* no-op */ }


Member Function Documentation

void ActionsMenu::shift Column    s_,
Direction    d_
[private]
 

Definition at line 71 of file ActionsMenu.cpp.

References Column, Direction, dump_vector, Config::get_A_dir, Config::get_A_prefix, MainWindow::get_A_selection, Config::get_B_dir, Config::get_B_prefix, MainWindow::get_B_selection, MainWindow::get_clist, MainWindow::get_config, Config::get_proj_path, MainWindow::get_row, left_column, log_rename, m_mw, make_next_name, make_prev_name, parse_format, MainWindow::reload_cb, and shrink.

Referenced by shift_b_down, and shift_b_up.

00072 {
00073     trace("ActionsMenu::shift");
00074     string msg;
00075     Config& cfg = m_mw.get_config ();
00076 
00077     /* Figure out the file name of the selected file.
00078 
00079           /<proj_path>/<dir>/<prefix><number>.wav  or in short
00080                   /<dirpath>/<prefix><number>.wav
00081      */
00082     string prefix;
00083     string proj_path;
00084     string dirpath;
00085     string format;
00086     string fname;
00087     string target;
00088     string src;
00089 
00090     prefix = col_==left_column ? cfg.get_A_prefix () : cfg.get_B_prefix ();
00091     proj_path = cfg.get_proj_path ();
00092     dirpath = proj_path + "/" 
00093         + (col_ == left_column ? cfg.get_A_dir () : cfg.get_B_dir ());
00094     
00095     fname = prefix 
00096         + (left_column ? m_mw.get_A_selection () : m_mw.get_B_selection ())
00097         + ".wav";
00098     
00099     DL((APP,"dirpath = \"%s\"\n", dirpath.c_str ()));
00100     DL((APP,"fname   = \"%s\"\n", fname.c_str ()));
00101 
00102     vector<string> ls = m_mw.get_clist (col_);
00103     dump_vector ("=== CList sequence ===", ls);
00104 
00105     format = parse_format (prefix, ls);
00106 
00107     if (format.length () == 0) {
00108         DL((APP,"Failed to parse format!\n"));
00109         Gtk::MessageDialog error ("Error parsing format!",
00110                                   MESSAGE_ERROR, BUTTONS_CLOSE);
00111         error.run ();
00112         return;
00113     }
00114 
00115     int row = m_mw.get_row ();
00116     DL((TRACE,"Selected row %d, \"%s\"\n", row, ls[row].c_str ()));
00117 
00118     /***************************************************************************
00119      Shrink the sequence
00120     ***************************************************************************/
00121     if (d_ == ActionsMenu::shrink) {
00122         DL((TRACE,"Shrinking sequence...\n"));
00123         dump_vector ("=== Original sequence ===", ls);
00124 
00125         src = ls [row];
00126 
00127         if (row != 0) {
00128             ls.erase (ls.begin (), ls.begin () + row);
00129         }
00130         dump_vector ("=== Chopped sequence ===", ls);
00131 
00132         if (src != "gap") {
00133             src = dirpath + "/" + prefix + src + ".wav";
00134             target = src + ".bkp";
00135             log_rename (src, target);
00136             ::rename (src.c_str (), target.c_str ());
00137         }
00138         int i = 0;
00139         while (i < ls.size ()) {
00140             DL((TRACE,"Processing ls[%d] = \"%s\"\n", i, ls[i].c_str ()));
00141             if (ls [i] != "gap") {
00142                 src = dirpath + "/" + prefix + ls [i] + ".wav";
00143                 target = make_prev_name (src, format, prefix, dirpath);
00144                 log_rename (src, target);
00145                 ::rename (src.c_str (), target.c_str ());
00146             }
00147             i++;
00148         }
00149     }
00150     /***************************************************************************
00151      Expand the sequence
00152     ***************************************************************************/
00153     else {
00154         DL((TRACE,"Expanding sequence...\n"));
00155         dump_vector ("=== Original sequence ===", ls);
00156 
00157         if (row != 0) {
00158             ls.erase (ls.begin (), ls.begin () + row);
00159         }
00160         dump_vector ("=== Chopped sequence ===", ls);
00161 
00162         vector<string>::reverse_iterator rk = ls.rbegin ();
00163 
00164         while (rk != ls.rend ()) {
00165             DL((TRACE,"--------------------\n"));
00166             DL((TRACE,"Processing \"%s\"\n", (*rk).c_str ()));
00167             if ( *rk != "gap") { 
00168                 src = dirpath + "/" + prefix + *rk + ".wav";
00169                 DL((TRACE,"src: \"%s\"\n",src.c_str ()));
00170                 target = make_next_name (src, format, prefix, dirpath);
00171                 DL((TRACE,"target: \"%s\"\n",target.c_str ()));
00172                 log_rename (src, target);
00173                 ::rename (src.c_str (), target.c_str ());
00174             }
00175             rk++;
00176         }
00177     }
00178     /* Reload modified list */
00179     m_mw.reload_cb ();
00180 }

void ActionsMenu::shift_a_down   [inline]
 

Definition at line 45 of file ActionsMenu.h.

Referenced by TopMenuBar::create.

void ActionsMenu::shift_a_up   [inline]
 

Definition at line 44 of file ActionsMenu.h.

Referenced by TopMenuBar::create.

void ActionsMenu::shift_b_down   [inline]
 

Definition at line 47 of file ActionsMenu.h.

References expand, left_column, and shift.

Referenced by TopMenuBar::create.

00047 { shift (left_column,  expand); }

void ActionsMenu::shift_b_up   [inline]
 

Definition at line 46 of file ActionsMenu.h.

References left_column, shift, and shrink.

Referenced by TopMenuBar::create.

00046 { shift (left_column,  shrink); }


Member Data Documentation

MainWindow& ActionsMenu::m_mw [private]
 

Definition at line 42 of file ActionsMenu.h.

Referenced by ActionsMenu, and shift.


The documentation for this class was generated from the following files:
Generated on Tue Feb 11 23:05:32 2003 for gwavmerger by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002